From: Mark Wooding Date: Sun, 30 Aug 2015 09:58:38 +0000 (+0100) Subject: src/codegen-{proto,impl}.lisp: Protocol for emitting custom declarations. X-Git-Tag: 0.2.0~52 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~mdw/git/sod/commitdiff_plain/3f4ac959a30787a952451c672e6e97d4469631a9 src/codegen-{proto,impl}.lisp: Protocol for emitting custom declarations. --- diff --git a/src/codegen-impl.lisp b/src/codegen-impl.lisp index e99a0c2..acb0da1 100644 --- a/src/codegen-impl.lisp +++ b/src/codegen-impl.lisp @@ -125,6 +125,12 @@ (defmethod emit-inst ((codegen basic-codegen) inst) (defmethod emit-insts ((codegen basic-codegen) insts) (asetf (codegen-insts codegen) (revappend insts it))) +(defmethod emit-decl ((codegen basic-codegen) inst) + (push inst (codegen-vars codegen))) + +(defmethod emit-decls ((codegen basic-codegen) insts) + (asetf (codegen-vars codegen) (revappend insts it))) + (defmethod ensure-var ((codegen basic-codegen) name type &optional init) (let* ((vars (codegen-vars codegen)) (var (find name diff --git a/src/codegen-proto.lisp b/src/codegen-proto.lisp index 743c89f..f6cd4bd 100644 --- a/src/codegen-proto.lisp +++ b/src/codegen-proto.lisp @@ -261,6 +261,14 @@ (defgeneric emit-insts (codegen insts) (: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