matsud224 / wamcompiler

Prolog implementation based on Warren's abstract machine
The Unlicense
38 stars 6 forks source link

I fixed a bug in the ! cut #3

Closed FemtoEmacs closed 4 years ago

FemtoEmacs commented 4 years ago

I fixed two bugs in the ! cut. Besides this, I added a few predicates, such as cputime(X), which can be useful for benchmarks.

A third bug remains to be fixed. I still canot use a cut as the last element of a clause body. When the cut appears in the last position of the body, E or B become large negative numbers. I added predicates that check whether E or B are negative to prevent the execution of the cut in this case. However, this is a temporary solution:

;;; Temporary solution: turn the cut off, when *B* or *E* are negative
   (cut (let ( (y (cadr inst)) )
              (when (and *B* *E* (>= *B* 0) (>= *E* 0) 
                     (addr< (stack (addr+ *E* 2 y)) *B*))
                (setf *B* (stack (addr+ *E* 2 y)))
                (tidy-trail))
              (setq *P* (cdr *P*))))
matsud224 commented 4 years ago

Thank you for fixing some bugs and improvements!