From 0a14bfd61a2b30d47a4040719347c4ae3c7ff8e7 Mon Sep 17 00:00:00 2001 From: Olof-Joachim Frahm Date: Sat, 18 May 2013 00:43:07 +0200 Subject: [PATCH] Strip declarations when compiling a block. I.e. not only for LAMBDA. Currently enabled for LET and LET*. --- src/compiler.lisp | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/compiler.lisp b/src/compiler.lisp index 3fe2823..5ef99f3 100644 --- a/src/compiler.lisp +++ b/src/compiler.lisp @@ -719,7 +719,7 @@ variables) ",") "){" *newline* - (let ((body (ls-compile-block body t))) + (let ((body (ls-compile-block body t t))) (indent (let-binding-wrapper dynamic-bindings body))) "})(" (join cvalues ",") ")"))) @@ -767,7 +767,7 @@ (js!selfcall (let ((specials (remove-if-not #'special-variable-p (mapcar #'first bindings))) (body (concat (mapconcat #'let*-initialize-value bindings) - (ls-compile-block body t)))) + (ls-compile-block body t t)))) (let*-binding-wrapper specials body))))) @@ -1675,13 +1675,16 @@ (t (code (ls-compile `#',function) arglist))))) -(defun ls-compile-block (sexps &optional return-last-p) - (if return-last-p - (code (ls-compile-block (butlast sexps)) - "return " (ls-compile (car (last sexps)) *multiple-value-p*) ";") - (join-trailing - (remove-if #'null-or-empty-p (mapcar #'ls-compile sexps)) - (concat ";" *newline*)))) +(defun ls-compile-block (sexps &optional return-last-p decls-allowed-p) + (multiple-value-bind (sexps decls) + (parse-body sexps :declarations decls-allowed-p) + (declare (ignore decls)) + (if return-last-p + (code (ls-compile-block (butlast sexps) nil decls-allowed-p) + "return " (ls-compile (car (last sexps)) *multiple-value-p*) ";") + (join-trailing + (remove-if #'null-or-empty-p (mapcar #'ls-compile sexps)) + (concat ";" *newline*))))) (defun ls-compile (sexp &optional multiple-value-p) (multiple-value-bind (sexp expandedp) (!macroexpand-1 sexp) -- 1.7.10.4