1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-07-06 17:40:29 +02:00

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
This commit is contained in:
Ian Price 2013-03-26 05:41:32 +00:00
parent f5302e62a7
commit ddb685ee52
3 changed files with 20 additions and 8 deletions

View file

@ -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)