summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--module/language/ecmascript/compile-ghil.scm20
-rw-r--r--module/language/ecmascript/impl.scm3
-rw-r--r--module/language/ecmascript/parse.scm4
3 files changed, 18 insertions, 9 deletions
diff --git a/module/language/ecmascript/compile-ghil.scm b/module/language/ecmascript/compile-ghil.scm
index 8c1cfc877..23a92a633 100644
--- a/module/language/ecmascript/compile-ghil.scm
+++ b/module/language/ecmascript/compile-ghil.scm
@@ -43,7 +43,7 @@
(make-ghil-ref
,e ,l
(ghil-var-at-module! ,e '(language ecmascript impl) ',sym #t))
- (map (lambda (x) (comp x ,e)) ,args)))
+ ,args))
(define (comp x e)
(let ((l (location x)))
@@ -84,7 +84,13 @@
((return ,expr)
(make-ghil-inline e l 'return (list (comp expr e))))
((array . ,args)
- (@impl e l new-array args))
+ (@impl e l new-array (map (lambda (x) (comp x e)) args)))
+ ((pref ,obj ,prop)
+ (@impl e l pget (list (comp obj e) (make-ghil-quote e l prop))))
+ ((= (ref ,name) ,val)
+ (make-ghil-set e l (ghil-var-for-set! e name) (comp val e)))
+ ((= (pref ,obj ,prop) ,val)
+ (@impl e l pput (list (comp obj e) (make-ghil-quote e l prop) (comp val e))))
(else
(error "compilation not yet implemented:" x)))))
@@ -92,14 +98,16 @@
(define (process)
(let lp ((in body) (out '()) (rvars (reverse formals)))
(pmatch in
- (((var ,x) . ,rest)
- (lp rest
+ (((var (,x) . ,morevars) . ,rest)
+ (lp `((var . ,morevars) . ,rest)
out
(if (memq x rvars) rvars (cons x rvars))))
- (((var ,x ,y) . ,rest)
- (lp rest
+ (((var (,x ,y) . ,morevars) . ,rest)
+ (lp `((var . ,morevars) . ,rest)
`((= (ref ,x) ,y) . ,out)
(if (memq x rvars) rvars (cons x rvars))))
+ (((var) . ,rest)
+ (lp rest out rvars))
((,x . ,rest) (guard (and (pair? x) (eq? (car x) 'lambda)))
(lp rest
(cons x out)
diff --git a/module/language/ecmascript/impl.scm b/module/language/ecmascript/impl.scm
index c335af0b9..65a46fa80 100644
--- a/module/language/ecmascript/impl.scm
+++ b/module/language/ecmascript/impl.scm
@@ -55,7 +55,8 @@
*undefined*)))))
(define-method (prop-attrs (o <js-object>) p)
- (or (hashq-ref (js-prop-attrs o) p)
+ (or (let ((attrs (js-prop-attrs o)))
+ (and attrs (hashq-ref (js-prop-attrs o) p)))
(let ((proto (js-prototype o)))
(if proto
(prop-attrs proto p)
diff --git a/module/language/ecmascript/parse.scm b/module/language/ecmascript/parse.scm
index 82e9f770a..d034f7f4f 100644
--- a/module/language/ecmascript/parse.scm
+++ b/module/language/ecmascript/parse.scm
@@ -102,8 +102,8 @@
(Identifier Initialiser) -> `(,$1 ,$2))
(VariableDeclarationNoIn (Identifier) -> `(,$1)
(Identifier Initialiser) -> `(,$1 ,$2))
- (Initialiser (= AssignmentExpression) -> $1)
- (InitialiserNoIn (= AssignmentExpressionNoIn) -> $1)
+ (Initialiser (= AssignmentExpression) -> $2)
+ (InitialiserNoIn (= AssignmentExpressionNoIn) -> $2)
(EmptyStatement (semicolon) -> '(begin))