1
Fork 0
mirror of https://git.savannah.gnu.org/git/guile.git synced 2025-06-14 15:40:19 +02:00

compile for-in

* module/language/ecmascript/base.scm (prop-keys): New method, returns
  the list of keys of props of this instance.

* module/language/ecmascript/impl.scm: Refactor the global object into a
  special kind of module object. Provide a prop-keys implementation for
  module objects.

* module/language/ecmascript/compile-ghil.scm (comp): Compile for-in.

* module/language/ecmascript/impl.scm: Reshuffly things, and implement
  make-enumerator, a helper for use in for-in statements.

* module/language/ecmascript/parse.scm (parse-ecmascript): Fix parsing of
  for (var foo in bar) {}...
This commit is contained in:
Andy Wingo 2009-02-22 16:01:11 +01:00
parent bb67fe27ab
commit e05320fa54
4 changed files with 65 additions and 27 deletions

View file

@ -24,7 +24,7 @@
#:export (*undefined* *this*
<js-object> *object-prototype*
js-prototype js-props js-prop-attrs js-value js-constructor js-class
pget prop-attrs prop-has-attr? pput has-property? pdel
pget prop-keys prop-attrs prop-has-attr? pput has-property? pdel
object->string object->number object->value/string
object->value/number object->value
@ -48,6 +48,9 @@
(constructor #:getter js-constructor #:init-value #f #:init-keyword #:constructor)
(class #:getter js-class #:init-value "Object" #:init-keyword #:class))
(define-method (prop-keys (o <js-object>))
(hash-map->list (lambda (k v) k) (js-props o)))
(define-method (pget (o <js-object>) (p <string>))
(pget o (string->symbol p)))