X-Git-Url: http://repo.macrolet.net/gitweb/?a=blobdiff_plain;f=src%2Fcompiler.lisp;h=931e9a2d6138083fa52fc18f0df6d08e5acf88dd;hb=ce86ba5f70b9e35bfb795402913f417de493e23f;hp=a806cf3d734a0f1779ebbb089a822234f787bc18;hpb=0105d7b5712cbfd3b0bf8e527f562071b3c12151;p=jscl.git diff --git a/src/compiler.lisp b/src/compiler.lisp index a806cf3..931e9a2 100644 --- a/src/compiler.lisp +++ b/src/compiler.lisp @@ -54,11 +54,6 @@ (js-expr arg))))) args)) -;;; Wrap X with a Javascript code to convert the result from -;;; Javascript generalized booleans to T or NIL. -(defun js!bool (x) - `(if ,x ,(ls-compile t) ,(ls-compile nil))) - ;;; Concatenate the arguments and wrap them with a self-calling ;;; Javascript anonymous function. It is used to make some Javascript ;;; statements valid expressions and provide a private scope as well. @@ -550,9 +545,9 @@ dumped (let ((jsvar (genlit))) (push (cons sexp jsvar) *literal-table*) - (toplevel-compilation `(code "var " ,jsvar " = " ,dumped)) + (toplevel-compilation `(var (,(make-symbol jsvar) ,dumped))) (when (keywordp sexp) - (toplevel-compilation `(code ,jsvar ".value = " ,jsvar))) + (toplevel-compilation `(= ,(get (make-symbol jsvar) "value") ,(make-symbol jsvar)))) jsvar))))))) @@ -1021,7 +1016,7 @@ `(define-raw-builtin ,op (x &rest args) (let ((args (cons x args))) (variable-arity args - (js!bool (comparison-conjuntion args ',sym)))))) + `(bool ,(comparison-conjuntion args ',sym)))))) (define-builtin-comparison > >) (define-builtin-comparison < <) @@ -1475,11 +1470,10 @@ (let ((form-string (prin1-to-string sexp))) (format t "Compiling ~a..." (truncate-string form-string)))) (let ((code (ls-compile sexp multiple-value-p))) - `(code - ,@(interleave (get-toplevel-compilations) "; -" t) - ,(when code - `(code ,code ";")))))))) + `(progn + ,@(interleave (get-toplevel-compilations) '(code "; +") t) + (code ,code ";"))))))) (defun ls-compile-toplevel (sexp &optional multiple-value-p) (with-output-to-string (*standard-output*)