From 0a3b98d0f93abafd8c0471e0790fce2b6e6e3ff3 Mon Sep 17 00:00:00 2001 From: Hanting Zhang Date: Tue, 29 Oct 2024 12:51:05 -0700 Subject: [PATCH] Implement case and if segments, memory macro. --- loam/allocation.lisp | 9 ++++----- loam/datalog.lisp | 4 +--- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/loam/allocation.lisp b/loam/allocation.lisp index 879b39d..b6a6e06 100644 --- a/loam/allocation.lisp +++ b/loam/allocation.lisp @@ -231,8 +231,9 @@ (defun ptr-wide-tag (ptr) (widen (ptr-tag ptr))) -(defun concat-sym (root suf) - (intern (format nil "~A~A" root suf))) +(eval-when (:compile-toplevel :load-toplevel :execute) + (defun concat-sym (root suf) + (intern (format nil "~A~A" root suf)))) (defmacro mem-constructor (name (tag initial-addr hasher) &body args) (multiple-value-bind @@ -547,9 +548,7 @@ always (= next-addr (1+ addr))))) (test mem-constructor-spec - (let ((unnamed-spec (cddr (spec (find-prototype 'cons-mem)))) ; Strip off the program name. - (unnamed-syn-spec (cddr (spec (find-prototype 'syn-cons-mem))))) - (is (equal unnamed-spec unnamed-syn-spec)))) + (is (compare-spec 'syn-cons-mem 'cons-mem))) (test allocation (let* ((program (make-program-instance 'map-double)) diff --git a/loam/datalog.lisp b/loam/datalog.lisp index 253c228..820e608 100644 --- a/loam/datalog.lisp +++ b/loam/datalog.lisp @@ -737,7 +737,6 @@ and a list of free variables in FORM." (defun synthesize-if-segment (if-segment curr-rhs end-handle) (destructuring-bind (head if-form &rest branches) if-segment - (display head) (assert (eql head 'if)) (assert (= (length branches) 2)) ; Must only have then and else branches. (loop with first = t @@ -754,7 +753,6 @@ and a list of free variables in FORM." (defun synthesize-case-segment (case-segment curr-rhs end-handle) (destructuring-bind (head case-form &rest branches) case-segment - (display head) (assert (eql head 'case)) (loop for (test branch-segments) in branches for test-segment = `(when (eql ,case-form ,test)) @@ -791,7 +789,7 @@ and a list of free variables in FORM." finally ;; If we don't hit a case statement, then after we process all segments, ;; we must finish with an final rule. - (let ((final-rule (display (make-rule `(,end-handle <-- ,@curr-rhs-tail))))) + (let ((final-rule (make-rule `(,end-handle <-- ,@curr-rhs-tail)))) (return `(,@output-rules ,final-rule))))) ;; This function takes a unsynthesized rule and synthesizes it.