X-Git-Url: https://git.distorted.org.uk/~mdw/sod/blobdiff_plain/b559689bf01c399ac0a15e8b73da7488dded72f4..bf8aadd76bceba05d2a325181a71763a5625c89b:/src/codegen-proto.lisp diff --git a/src/codegen-proto.lisp b/src/codegen-proto.lisp index 602b51e..e947a72 100644 --- a/src/codegen-proto.lisp +++ b/src/codegen-proto.lisp @@ -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. @@ -173,7 +175,8 @@ (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) @@ -187,7 +190,7 @@ (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) @@ -260,6 +263,14 @@ (: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