[pypy-commit] lang-js default: fixed iterator

stepahn noreply at buildbot.pypy.org
Fri Dec 28 11:34:29 CET 2012


Author: Stephan <stephan at stzal.com>
Branch: 
Changeset: r248:5cc51d4185be
Date: 2012-06-05 18:28 +0200
http://bitbucket.org/pypy/lang-js/changeset/5cc51d4185be/

Log:	fixed iterator

diff --git a/js/jsobj.py b/js/jsobj.py
--- a/js/jsobj.py
+++ b/js/jsobj.py
@@ -578,6 +578,14 @@
     def ToObject(self):
         return self
 
+    ###
+
+    def named_properties(self):
+        properties = set(self._properties_.keys())
+        if not isnull_or_undefined(self._prototype_):
+            properties.update(self._prototype_.named_properties())
+        return properties
+
 class W__PrimitiveObject(W_BasicObject):
     def __init__(self, primitive_value):
         W_BasicObject.__init__(self)
diff --git a/js/opcodes.py b/js/opcodes.py
--- a/js/opcodes.py
+++ b/js/opcodes.py
@@ -677,9 +677,11 @@
         from js.jsobj import W_BasicObject
         assert isinstance(obj, W_BasicObject)
 
-        properties = obj._properties_.items()
+        properties = list(obj.named_properties())
         properties.sort()
-        for key, prop in properties:
+
+        for key in properties:
+            prop = obj.get_property(key)
             if prop.enumerable is True:
                 props.append(_w(key))
 
@@ -798,6 +800,25 @@
     #def __repr__(self):
         #return 'STORE_LOCAL %d' % (self.local,)
 
+class SETUP_TRY(Opcode):
+    def __init__(self, end):
+        self.end = end
+
+    def eval(self, ctx):
+        from js.jsobj import W_Try
+        ctx.stack_push(W_Try(self.end))
+
+    def __str__(self):
+        return 'SETUP_TRY %d' % (self.end)
+
+class POP_BLOCK(Opcode):
+    def eval(self, ctx):
+        from js.jsobj import W_Block
+        while True:
+            b = ctx.stack_pop()
+            if isinstance(b, W_Block):
+                break
+
 # different opcode mappings, to make annotator happy
 
 OpcodeMap = {}


More information about the pypy-commit mailing list