Mike Gerwitz

Activist for User Freedom

aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMike Gerwitz <mtg@gnu.org>2017-12-05 00:35:54 -0500
committerMike Gerwitz <mtg@gnu.org>2017-12-05 00:38:39 -0500
commit639948da0201c56505047442d15c72b50f3e3ccc (patch)
treebc874d5068cc3879793ccca1dc5943d63eab0e01
parent4702184c33ac0b57c1500eb1e95724e3cd60859a (diff)
downloadulambda-639948da0201c56505047442d15c72b50f3e3ccc.tar.gz
ulambda-639948da0201c56505047442d15c72b50f3e3ccc.tar.bz2
ulambda-639948da0201c56505047442d15c72b50f3e3ccc.zip
birth,rebirth: Add cond-expand, string->es
`cond-expand' allows moving forward with implementing features based on the current bootstrapped state of the system---rebirth will be able to recursively compile itself and introduce new features along the way. `string->es' allows outputting raw ECMAScript, which gives us more control over the code that is generated without having to hard-code it in the compiler itself. * build-aux/bootstrap/birth.scm (fnmap)[cond-expand]: Always yield the empty string (do nothing). * build-aux/bootstrap/rebirth.scm (fnmap)[cond-expand]: Expand `string->es' only. (fnmap)[string->es]: Add macro.
-rw-r--r--build-aux/bootstrap/birth.scm4
-rw-r--r--build-aux/bootstrap/rebirth.scm13
2 files changed, 17 insertions, 0 deletions
diff --git a/build-aux/bootstrap/birth.scm b/build-aux/bootstrap/birth.scm
index 3b2ae07..378d6c0 100644
--- a/build-aux/bootstrap/birth.scm
+++ b/build-aux/bootstrap/birth.scm
@@ -377,6 +377,10 @@
(("js:console")
(string-append "console.log(" (map sexp->es args) ")"))
+ ;; always expands into nothing; this is just to facilitate its use
+ ;; moving forward
+ (("cond-expand") "")
+
;; yes, there are more important things to do until we get to the
;; point where it's worth implementing proper tail calls
(("js:while")
diff --git a/build-aux/bootstrap/rebirth.scm b/build-aux/bootstrap/rebirth.scm
index aa4514a..18927de 100644
--- a/build-aux/bootstrap/rebirth.scm
+++ b/build-aux/bootstrap/rebirth.scm
@@ -398,6 +398,19 @@
(("js:console")
(string-append "console.log(" (map sexp->es args) ")"))
+ ;; very primitive cond-expand
+ (("cond-expand")
+ (let* ((clause (car args))
+ (feature (token-value (car clause)))
+ (body (cdr clause)))
+ (case feature
+ (("string->es") (body->es body #f))
+ (else ""))))
+
+ ;; output raw code into the compiled ECMAScript (what could go wrong?)
+ (("string->es")
+ (token-value (car args)))
+
;; yes, there are more important things to do until we get to the
;; point where it's worth implementing proper tail calls
(("js:while")