projects
/
jscl.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Use comment instead of docstring to make bootstrapping easier
[jscl.git]
/
lispstrack.lisp
diff --git
a/lispstrack.lisp
b/lispstrack.lisp
index
9efa0bc
..
d531561
100644
(file)
--- a/
lispstrack.lisp
+++ b/
lispstrack.lisp
@@
-54,8
+54,9
@@
(error "Undefined variable `~a'" symbol))))
(defmacro define-compilation (name args &body body)
(error "Undefined variable `~a'" symbol))))
(defmacro define-compilation (name args &body body)
- "creates a new primitive `name' with parameters args and @body. The
-body can access to the local environment through the variable env"
+ ;; Creates a new primitive `name' with parameters args and
+ ;; @body. The body can access to the local environment through the
+ ;; variable ENV.
`(push (list ',name (lambda (env ,@args) ,@body))
*compilations*))
`(push (list ',name (lambda (env ,@args) ,@body))
*compilations*))
@@
-92,18
+93,18
@@
body can access to the local environment through the variable env"
(define-compilation debug (form)
(format nil "console.log(~a)" (ls-compile form env)))
(define-compilation debug (form)
(format nil "console.log(~a)" (ls-compile form env)))
-(defun compile-test ()
- (with-open-file (in "test.lisp")
- (with-open-file (out "test.js" :direction :output :if-exists :supersede)
- (loop
- for x = (read in nil) while x
- do (write-string (concat (ls-compile x) "; ") out)))))
-
(define-compilation while (pred &rest body)
(format nil "(function(){while(~a){~a}})() "
(ls-compile pred env)
(ls-compile-sexps body env)))
(define-compilation while (pred &rest body)
(format nil "(function(){while(~a){~a}})() "
(ls-compile pred env)
(ls-compile-sexps body env)))
+(defmacro eval-when-compile (&body body)
+ `(eval-when (:compile-toplevel :execute)
+ ,@body))
+
+(define-compilation eval-when-compile (when &rest body)
+ (eval body))
+
;;; aritmetic primitives
(define-compilation + (x y)
(concat "((" (ls-compile x env) ") + (" (ls-compile y env) "))"))
;;; aritmetic primitives
(define-compilation + (x y)
(concat "((" (ls-compile x env) ") + (" (ls-compile y env) "))"))
@@
-136,3
+137,13
@@
body can access to the local environment through the variable env"
(funcall (ls-compile (car sexp) env) )
;; funcall
)))))
(funcall (ls-compile (car sexp) env) )
;; funcall
)))))
+
+
+;;; Testing
+
+(defun compile-test ()
+ (with-open-file (in "test.lisp")
+ (with-open-file (out "test.js" :direction :output :if-exists :supersede)
+ (loop
+ for x = (read in nil) while x
+ do (write-string (concat (ls-compile x) "; ") out)))))