From: David Vázquez Date: Mon, 1 Jul 2013 00:24:12 +0000 (+0200) Subject: Migrate keyword argument parsing X-Git-Url: http://repo.macrolet.net/gitweb/?a=commitdiff_plain;h=a5cea857580c1060f4e7d7aa3ec6d800e8e7b5cd;p=jscl.git Migrate keyword argument parsing --- diff --git a/src/compiler-codegen.lisp b/src/compiler-codegen.lisp index 2c9e1e8..480a856 100644 --- a/src/compiler-codegen.lisp +++ b/src/compiler-codegen.lisp @@ -178,6 +178,8 @@ (case (length (cdr form)) (1 `(unary- ,(cadr form))) (t (reduce (lambda (x y) `(- ,x ,y)) (cdr form))))) + ((and or) + (reduce (lambda (x y) `(,(car form) ,x ,y)) (cdr form))) ((progn comma) (reduce (lambda (x y) `(comma ,x ,y)) (cdr form) :from-end t)) (t form)) diff --git a/src/compiler.lisp b/src/compiler.lisp index 0829144..3826be6 100644 --- a/src/compiler.lisp +++ b/src/compiler.lisp @@ -228,7 +228,7 @@ (flet ((canonicalize (keyarg) ;; Build a canonical keyword argument descriptor, filling ;; the optional fields. The result is a list of the form - ;; ((keyword-name var) init-form). + ;; ((keyword-name var) init-form svar). (let ((arg (ensure-list keyarg))) (cons (if (listp (car arg)) (car arg) @@ -310,55 +310,62 @@ (length (ll-optional-arguments ll))) (keyword-arguments (ll-keyword-arguments-canonical ll))) - `(code - ;; Declare variables - ,@(mapcar (lambda (arg) - (let ((var (second (car arg)))) - `(code "var " ,(translate-variable var) "; " - ,(when (third arg) - `(code "var " ,(translate-variable (third arg)) - " = " ,(ls-compile nil) - ";" ))))) - keyword-arguments) - ;; Parse keywords - ,(flet ((parse-keyword (keyarg) - ;; ((keyword-name var) init-form) - `(code "for (i=" ,(+ n-required-arguments n-optional-arguments) - "; i