mirror of
https://git.savannah.gnu.org/git/guile.git
synced 2025-06-18 09:40:25 +02:00
property gets and puts implemented, yays
* module/language/ecmascript/compile-ghil.scm (@impl): Ok, don't recurse on args here. (comp): Implement property gets and puts and lexical assignment. (comp-body): Fix scanning of var forms. * module/language/ecmascript/impl.scm (prop-attrs): Allow for the prop attr array to be #f. * module/language/ecmascript/parse.scm (parse-ecmascript): Fix assignment parsing.
This commit is contained in:
parent
10e1bd278f
commit
7fb4230060
3 changed files with 18 additions and 9 deletions
|
@ -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)
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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))
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue