rebirth: Add define/define-macro rest support
That is: `(define (foo bar . rest))'. * build-aux/bootstrap/rebirth.scm (params->es): Add rest support.master
parent
1d6756a709
commit
462d99fb99
|
@ -718,12 +718,30 @@
|
|||
|
||||
;; Compile parameter list.
|
||||
;;
|
||||
;; This simply takes the value of the symbol and outputs it (formatted),
|
||||
;; delimited by commas.
|
||||
;; This takes the value of the symbol and outputs it (formatted), delimited
|
||||
;; by commas.
|
||||
;;
|
||||
;; Since we do not support actual pairs (yet), the "." syntax that normally
|
||||
;; denotes the cdr is retained and presents itself here. The form "(arg1,
|
||||
;; arg2 . rest)" creates a list `rest' containing all remaining arguments
|
||||
;; after that point. Conveniently, ECMAScript Harmony supports this
|
||||
;; natively with the "..." syntax.
|
||||
(define (params->es params)
|
||||
(join ", " (map (lambda (t)
|
||||
(tname->id (token-value t)))
|
||||
params)))
|
||||
(define (%param-conv params)
|
||||
(let* ((param (car params))
|
||||
(name (token-value param))
|
||||
(id (tname->id name))
|
||||
(rest (cdr params)))
|
||||
(if (string=? name ".")
|
||||
(list (string-append
|
||||
"..." (car (%param-conv rest))))
|
||||
(if (pair? rest)
|
||||
(cons id (%param-conv rest))
|
||||
(list id)))))
|
||||
|
||||
(if (pair? params)
|
||||
(join "," (%param-conv params))
|
||||
""))
|
||||
|
||||
|
||||
;; Compile body s-expressions into ECMAScript
|
||||
|
|
Loading…
Reference in New Issue