(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)
+ (format stream "~@<~A ~A= ~@_~2I~A;~:>" var op expr))
(definst return (stream :export t) (expr)
(format stream "return~@[ (~A)~];" expr))
+(definst break (stream :export t) ()
+ (format stream "break;"))
+(definst continue (stream :export t) ()
+ (format stream "continue;"))
(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