summaryrefslogtreecommitdiff
path: root/module/language/lua/compile-tree-il.scm
diff options
context:
space:
mode:
authorIan Price <ianprice90@googlemail.com>2013-03-26 05:41:32 +0000
committerIan Price <ianprice90@googlemail.com>2013-09-09 17:01:24 +0100
commitddb685ee52796c720d7c32d7adf50b744129f3f0 (patch)
tree94374485cbd4b7c732d40b34b55ed4ccc5d642d7 /module/language/lua/compile-tree-il.scm
parentf5302e62a75a57e59b2986b519e7db6b5250745a (diff)
downloadguile-ddb685ee52796c720d7c32d7adf50b744129f3f0.tar.gz
Compile Lua's ... form.
* module/language/lua/compile-tree-il.scm (compile): Add clause for ast-variable-arguments. * module/language/lua/parser.scm (define-ast, make-parser): Add vararg-gensym field to functions, gensym field to variable-arguments. Propagate *vararg-gensym* from functions to variable-arguments. * test-suite/tests/lua-eval-2.test ("lua-eval"): Check for #nil
Diffstat (limited to 'module/language/lua/compile-tree-il.scm')
-rw-r--r--module/language/lua/compile-tree-il.scm11
1 files changed, 8 insertions, 3 deletions
diff --git a/module/language/lua/compile-tree-il.scm b/module/language/lua/compile-tree-il.scm
index 48c1a58b1..72c0d1b77 100644
--- a/module/language/lua/compile-tree-il.scm
+++ b/module/language/lua/compile-tree-il.scm
@@ -156,7 +156,7 @@ dropped silently"
src (make-primitive-ref src 'return/values)
(if (list? exp) (map-compile exp #t) (list (compile exp))))))
- ((ast-function src name arguments argument-gensyms variable-arguments? body)
+ ((ast-function src name arguments argument-gensyms variable-arguments? vararg-gensym body)
;; ... is always attached because lua functions must ignore
;; variable arguments; the parser will catch it if ... is used in a
;; function that doesn't have ... in the parameter list
@@ -165,7 +165,7 @@ dropped silently"
src meta
(make-lambda-case src '() arguments '... #f
(map (lambda (x) (make-const src #nil)) arguments)
- (append argument-gensyms (list (gensym "...")))
+ (append argument-gensyms (list vararg-gensym))
(compile body)
#f))))
@@ -476,7 +476,12 @@ dropped silently"
(make-lexical-ref src 'and-tmp tmp)
right
(make-lexical-ref src 'and-tmp tmp)))))
- (else (error #:COMPILE "unknown binary operator" operator)))))))
+ (else (error #:COMPILE "unknown binary operator" operator)))))
+ ((ast-variable-arguments src gensym)
+ (make-application src
+ (make-primitive-ref src 'apply)
+ (list (make-primitive-ref src 'values)
+ (make-lexical-ref src '... gensym))))))
;; exported compiler function
(define (compile-tree-il exp env opts)