Codebase list cafeobj / 26f4343
Fix a bug in nested search. Toshimi Sawada 5 years ago
1 changed file(s) with 22 addition(s) and 28 deletion(s). Raw diff Collapse all Expand all
139139 (bind nil) ; ....
140140 (if nil) ;
141141 (pr-out? nil) ;
142 (term-hash nil :type simple-vector) ;
142143 )
143144
144145 (defun print-sch-context (ctxt &optional (stream *standard-output*) &rest ignore)
749750 (term-hash-equal (term-builtin-value term))))
750751 ((term-is-variable? term) (term-hash-eq term))))
751752
752 (defun dump-cexec-term-hash (term-hash &optional (size term-hash-size))
753 (dotimes (x size)
754 (let ((ent (svref term-hash x)))
755 (when ent
756 (format t "~%[~3d]: ~d entrie(s)" x (length ent))
757 (dotimes (y (length ent))
758 (let ((e (nth y ent)))
759 (format t "~%(~d)" y)
760 (let ((*print-indent* (+ 2 *print-indent*)))
761 (term-print (car e))
762 (print-next)
763 (princ "==>")
764 (print-next)
765 (term-print (cdr e)))))))))
753 (defun dump-cexec-term-hash (&optional (size term-hash-size))
754 (let ((mod (get-context-module)))
755 (unless mod (return-from dump-cexec-term-hash nil))
756 (with-in-module (mod)
757 (dotimes (x size)
758 (let ((ent (svref .cexec-term-hash. x)))
759 (when ent
760 (format t "~%[~3d]: ~d entrie(s)" x (length ent))
761 (dotimes (y (length ent))
762 (let ((e (nth y ent)))
763 (format t "~%(~d)" y)
764 (let ((*print-indent* (+ 2 *print-indent*)))
765 (term-print (car e))
766 (print-next)
767 (princ "==>")
768 (print-next)
769 (term-print (cdr e)))))))))))
766770
767771 (defvar .cexec-term-hash. nil)
768
769 (declaim (inline init-rwl-term-hash))
770 (defun init-rwl-term-hash (depth)
771 (declare (type fixnum depth)
772 (optimize (speed 3) (safety 0)))
773 (unless .cexec-term-hash.
774 (setq .cexec-term-hash. (alloc-svec term-hash-size)))
775 (when (zerop depth)
776 (dotimes (x term-hash-size)
777 (setf (svref .cexec-term-hash. x) nil))))
778772
779773 (declaim (inline get-sch-hashed-term))
780774 (defun get-sch-hashed-term (term term-hash)
11361130 (push (dag-node-datum node)
11371131 (rwl-sch-context-answers sch-context))
11381132 ;;
1139 (when (and (= (rwl-state-depth state) 0)
1133 (when (and ;; (= (rwl-state-depth state) 0)
11401134 (not *rwl-search-no-state-report*))
11411135 (format t "~%** Found [state ~D-~D] " (rwl-state-depth state) (rwl-state-state state))
11421136 (term-print-with-sort (rwl-state-term state))
12751269 :max-depth max-depth
12761270 :state-predicate nil
12771271 :bind bind
1278 :if if))
1272 :if if
1273 :term-hash (alloc-svec term-hash-size)))
12791274 (root nil)
12801275 (res nil)
12811276 (no-more nil)
13141309 (setf (rwl-sch-context-state-predicate sch-context) (make-state-pred-pat))
13151310 (let ((.rwl-sch-context. sch-context)
13161311 (.rwl-search-depth. (1+ .rwl-search-depth.))
1312 (.cexec-term-hash. (rwl-sch-context-term-hash sch-context))
13171313 (.ignore-term-id-limit. t))
13181314 (declare (special .rwl-sch-context. .cexec.term-hash. .ignore-term-id-limit.))
13191315 (push sch-context .rwl-context-stack.)
1320 (init-rwl-term-hash .rwl-search-depth.)
13211316 ;; the first state is 0
13221317 (set-sch-hashed-term t1 .cexec-term-hash. 0)
13231318 ;;
14411436 ;; the followings are experimental
14421437 (if nil))
14431438 (declare (type term term pattern)
1444 (type fixnum max-result max-depth)
14451439 (type (or null t) zero? final?))
14461440 (let ((module (get-context-module))
14471441 max-r