From 357885be46389c70dc9e7c7859f47af68aeb58ae Mon Sep 17 00:00:00 2001 From: Mark Wooding Date: Thu, 7 Jan 2016 19:33:52 +0000 Subject: [PATCH] src/: Introduce `deliver-call' to abbreviate function calls. This will turn out to be more useful soon. --- doc/SYMBOLS | 1 + doc/clang.tex | 4 ++++ src/codegen-proto.lisp | 5 +++++ src/codegen-test.lisp | 6 ++---- src/method-proto.lisp | 6 +++--- 5 files changed, 15 insertions(+), 7 deletions(-) diff --git a/doc/SYMBOLS b/doc/SYMBOLS index 2c33ad0..4d7b384 100644 --- a/doc/SYMBOLS +++ b/doc/SYMBOLS @@ -364,6 +364,7 @@ codegen-proto.lisp continue-inst class convert-stmts function definst macro + deliver-call function deliver-expr function emit-decl generic emit-decls generic diff --git a/doc/clang.tex b/doc/clang.tex index e8bb1b5..3b692d8 100644 --- a/doc/clang.tex +++ b/doc/clang.tex @@ -982,6 +982,10 @@ Temporary names are represented by objects which implement a simple protocol. \begin{describe}{fun}{deliver-expr @ @ @} \end{describe} +\begin{describe}{fun} + {deliver-call @ @ @ \&rest @} +\end{describe} + \begin{describe}{fun}{convert-stmts @ @ @ @} \end{describe} diff --git a/src/codegen-proto.lisp b/src/codegen-proto.lisp index e7486fa..5364f72 100644 --- a/src/codegen-proto.lisp +++ b/src/codegen-proto.lisp @@ -406,4 +406,9 @@ (emit-inst codegen (make-return-inst nil))) (t (funcall func target)))) +(export 'deliver-call) +(defun deliver-call (codegen target func &rest args) + "Emit a statement to call FUNC with ARGS and deliver the result to TARGET." + (deliver-expr codegen target (make-call-inst func args))) + ;;;----- That's all, folks -------------------------------------------------- diff --git a/src/codegen-test.lisp b/src/codegen-test.lisp index 81fa3e0..da3763b 100644 --- a/src/codegen-test.lisp +++ b/src/codegen-test.lisp @@ -65,10 +65,8 @@ do (ensure-var codegen name c-type-int init)) (ensure-var codegen "g" c-type-int (make-call-inst "gcd" (list "u" "v" "&a"))) - (emit-inst codegen (make-expr-inst - (make-call-inst "printf" - (list "\"%d*%d == %d (mod %d)\\n\"" - "a" "u" "g" "v")))) + (deliver-call codegen :void "printf" + "\"%d*%d == %d (mod %d)\\n\"" "a" "u" "g" "v") (deliver-expr codegen :return 0) (codegen-pop-function codegen "main" (c-type (fun int diff --git a/src/method-proto.lisp b/src/method-proto.lisp index 12cefc8..c8b47ad 100644 --- a/src/method-proto.lisp +++ b/src/method-proto.lisp @@ -296,11 +296,11 @@ (emit-inst codegen (make-va-copy-inst *sod-tmp-ap* *sod-ap*)) - (deliver-expr codegen var - (make-call-inst function arguments)) + (apply #'deliver-call codegen var + function arguments) (emit-inst codegen (make-va-end-inst *sod-tmp-ap*)))) - (deliver-expr codegen target (make-call-inst function arguments))))) + (apply #'deliver-call codegen target function arguments)))) (export 'ensure-ilayout-var) (defun ensure-ilayout-var (codegen super) -- 2.11.0