summaryrefslogtreecommitdiff
path: root/module/language/ecmascript/compile-ghil.scm
diff options
context:
space:
mode:
authorAndy Wingo <wingo@pobox.com>2009-02-18 01:17:14 +0100
committerAndy Wingo <wingo@pobox.com>2009-02-18 01:18:18 +0100
commit8fa6886d7af7c012c4cd17f793e5038931ffb4a0 (patch)
tree4fb22649c856f8b1131d5a1c1b01c5c6612eef5b /module/language/ecmascript/compile-ghil.scm
parentb912a1cd6b5d22e1fd3eadca10858d8d0dd9c027 (diff)
downloadguile-8fa6886d7af7c012c4cd17f793e5038931ffb4a0.tar.gz
add more ecmascript compilation -- functions work now
* module/language/ecmascript/parse.scm (parse-ecmascript): Lambdas always just have one member in their bodies. * module/language/ecmascript/compile-ghil.scm (comp): Add some more silly compilers.
Diffstat (limited to 'module/language/ecmascript/compile-ghil.scm')
-rw-r--r--module/language/ecmascript/compile-ghil.scm13
1 files changed, 13 insertions, 0 deletions
diff --git a/module/language/ecmascript/compile-ghil.scm b/module/language/ecmascript/compile-ghil.scm
index 03578af77..deaf70805 100644
--- a/module/language/ecmascript/compile-ghil.scm
+++ b/module/language/ecmascript/compile-ghil.scm
@@ -59,6 +59,19 @@
(make-ghil-inline e l 'div (list (comp a e) (comp b e))))
((* ,a ,b)
(make-ghil-inline e l 'mul (list (comp a e) (comp b e))))
+ ((ref ,id)
+ (make-ghil-ref e l (ghil-var-for-ref! e (string->symbol id))))
+ ((define ,id ,val)
+ (make-ghil-define e l (ghil-var-define! (ghil-env-parent e) (string->symbol id))
+ (comp val e)))
+ ((begin . ,forms)
+ (make-ghil-begin e l (map (lambda (x) (comp x e)) forms)))
+ ((lambda ,formals ,body)
+ (call-with-ghil-environment e formals
+ (lambda (env vars)
+ (make-ghil-lambda env l vars #f '() (comp body env)))))
+ ((call ,proc ,args)
+ (make-ghil-call e l (comp proc e) (map (lambda (x) (comp x e)) args)))
(else
(error "compilation not yet implemented:" x)))))