From d722bda7a87706b630b4e61f494556e9105490b1 Mon Sep 17 00:00:00 2001 From: =?utf8?q?David=20V=C3=A1zquez?= Date: Sun, 30 Jun 2013 16:38:15 +0200 Subject: [PATCH] Migrate compile-lambda --- src/compiler.lisp | 46 ++++++++++++++++++++-------------------------- 1 file changed, 20 insertions(+), 26 deletions(-) diff --git a/src/compiler.lisp b/src/compiler.lisp index e6e441b..045ab63 100644 --- a/src/compiler.lisp +++ b/src/compiler.lisp @@ -265,13 +265,11 @@ (block nil ;; Special case: a positive exact number of arguments. (when (and (< 0 min) (eql min max)) - (return `(code "checkArgs(nargs, " ,min ");"))) + (return `(call |checkArgs| |nargs| ,min))) ;; General case: - `(code - ,(when (< 0 min) - `(code "checkArgsAtLeast(nargs, " ,min ");")) - ,(when (numberp max) - `(code "checkArgsAtMost(nargs, " ,max ");")))))) + `(progn + ,(when (< 0 min) `(call |checkArgsAtLeast| |nargs| ,min)) + ,(when (numberp max) `(call |checkArgsAtMost| |nargs| ,max)))))) (defun compile-lambda-optional (ll) (let* ((optional-arguments (ll-optional-arguments-canonical ll)) @@ -417,26 +415,22 @@ keyword-arguments (ll-svars ll))))) (lambda-name/docstring-wrapper name documentation - `(code - "(function (" - ,(join (list* "values" - "nargs" - (mapcar #'translate-variable - (append required-arguments optional-arguments))) - ",") - "){" - ;; Check number of arguments - ,(lambda-check-argument-count n-required-arguments - n-optional-arguments - (or rest-argument keyword-arguments)) - ,(compile-lambda-optional ll) - ,(compile-lambda-rest ll) - ,(compile-lambda-parse-keywords ll) - ,(let ((*multiple-value-p* t)) - (if block - (ls-compile-block `((block ,block ,@body)) t) - (ls-compile-block body t))) - "})")))))) + `(function (|values| |nargs| ,@(mapcar (lambda (x) + (make-symbol (translate-variable x))) + (append required-arguments optional-arguments))) + ;; Check number of arguments + ,(lambda-check-argument-count n-required-arguments + n-optional-arguments + (or rest-argument keyword-arguments)) + (code + ,(compile-lambda-optional ll) + ,(compile-lambda-rest ll) + ,(compile-lambda-parse-keywords ll)) + + ,(let ((*multiple-value-p* t)) + (if block + (ls-compile-block `((block ,block ,@body)) t) + (ls-compile-block body t))))))))) (defun setq-pair (var val) -- 1.7.10.4