doc/list-exports.lisp: Better pretty formatting for keywords.
[sod] / src / codegen-proto.lisp
index 602b51e..7c8f65c 100644 (file)
@@ -49,7 +49,7 @@
 
 ;; Root class.
 
-(export 'temporary-name)
+(export '(temporary-name temp-tag))
 (defclass temporary-name ()
   ((tag :initarg :tag :reader temp-tag))
   (:documentation
@@ -74,6 +74,8 @@
   (make-instance 'temporary-name :tag "sod__ap"))
 (defparameter *sod-master-ap*
   (make-instance 'temporary-name :tag "sod__master_ap"))
+(defparameter *sod-tmp-ap*
+  (make-instance 'temporary-name :tag "sod__tmp_ap"))
 
 ;;;--------------------------------------------------------------------------
 ;;; Instructions.
                 (format stream "~@<~@{~S ~@_~S~^ ~_~}~:>"
                         ,@(mappend #'list keys args)))
               (progn ,@body))))
-       ,@(and export `((export '(,class-name ,constructor-name))))
+       ,@(and export `((export '(,class-name ,constructor-name
+                                ,@(mapcar (lambda (arg)
+                                            (symbolicate 'inst- arg))
+                                          args)))))
        ',code)))
 
 ;; Important instruction classes.
 (definst var (stream :export t) (name type init)
   (pprint-c-type type stream name)
   (when init
-    (format stream " = ~A" init)))
+    (format stream " = ~A" init))
+  (write-char #\; stream))
 (definst set (stream :export t) (var expr)
   (format stream "~@<~A = ~@_~2I~A;~:>" var expr))
 (definst update (stream :export t) (var op expr)
 (definst expr (stream :export t) (expr)
   (format stream "~A;" expr))
 (definst block (stream :export t) (decls body)
-  (format stream "{~:@_~@<  ~2I~@[~{~A;~:@_~}~:@_~]~{~A~^~:@_~}~:>~:@_}"
+  (format stream "{~:@_~@<  ~2I~@[~{~A~:@_~}~:@_~]~{~A~^~:@_~}~:>~:@_}"
          decls body))
 (definst function (stream :export t) (name type body)
   (pprint-logical-block (stream nil)
   (:method (codegen insts)
     (dolist (inst insts) (emit-inst codegen inst))))
 
+(export '(emit-decl emit-decls))
+(defgeneric emit-decl (codegen inst)
+  (:documentation
+   "Add INST to the end of CODEGEN's list of declarations."))
+(defgeneric emit-decls (codegen insts)
+  (:documentation
+   "Add a list of INSTS to the end of CODEGEN's list of declarations."))
+
 (export 'codegen-push)
 (defgeneric codegen-push (codegen)
   (:documentation