From a5cea857580c1060f4e7d7aa3ec6d800e8e7b5cd Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20V=C3=A1zquez?= Date: Mon, 1 Jul 2013 02:24:12 +0200 Subject: [PATCH] Migrate keyword argument parsing --- src/compiler-codegen.lisp | 2 + src/compiler.lisp | 110 ++++++++++++++++++++++++--------------------- 2 files changed, 60 insertions(+), 52 deletions(-) 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