[pypy-svn] r55546 - in pypy/branch/js-refactoring/pypy/lang/js: . test/ecma

santagada at codespeak.net santagada at codespeak.net
Wed Jun 4 04:50:19 CEST 2008


Author: santagada
Date: Wed Jun  4 04:50:16 2008
New Revision: 55546

Modified:
   pypy/branch/js-refactoring/pypy/lang/js/jscode.py
   pypy/branch/js-refactoring/pypy/lang/js/jsobj.py
   pypy/branch/js-refactoring/pypy/lang/js/test/ecma/conftest.py
Log:
proper resolve_identifier semantics

Modified: pypy/branch/js-refactoring/pypy/lang/js/jscode.py
==============================================================================
--- pypy/branch/js-refactoring/pypy/lang/js/jscode.py	(original)
+++ pypy/branch/js-refactoring/pypy/lang/js/jscode.py	Wed Jun  4 04:50:16 2008
@@ -287,7 +287,7 @@
         self.identifier = identifier
 
     def eval(self, ctx, stack):
-        stack.append(ctx.resolve_identifier(self.identifier))
+        stack.append(ctx.resolve_identifier(ctx, self.identifier))
 
     def __repr__(self):
         return 'LOAD_VARIABLE "%s"' % (self.identifier,)
@@ -428,7 +428,7 @@
 
     def eval(self, ctx, stack):
         try:
-            var = ctx.resolve_identifier(self.name)
+            var = ctx.resolve_identifier(ctx, self.name)
             stack.append(W_String(var.type()))
         except ThrowException:
             stack.append(W_String('undefined'))
@@ -601,7 +601,7 @@
 class BaseAssignOper(BaseStore):
     def process(self, ctx, name, stack):
         right = stack.pop()
-        left = ctx.resolve_identifier(name)
+        left = ctx.resolve_identifier(ctx, name)
         result = self.operation(ctx, left, right)
         stack.append(result)
         return result
@@ -609,7 +609,7 @@
 class BaseAssignBitOper(BaseStore):
     def process(self, ctx, name, stack):
         right = stack.pop().ToInt32(ctx)
-        left = ctx.resolve_identifier(name).ToInt32(ctx)
+        left = ctx.resolve_identifier(ctx, name).ToInt32(ctx)
         result = self.operation(ctx, left, right)
         stack.append(result)
         return result
@@ -640,14 +640,14 @@
 
 class STORE_POSTINCR(BaseStore):
     def process(self, ctx, name, stack):
-        value = ctx.resolve_identifier(name)
+        value = ctx.resolve_identifier(ctx, name)
         newval = increment(ctx, value)
         stack.append(value)
         return newval
 
 class STORE_POSTDECR(BaseStore):
     def process(self, ctx, name, stack):
-        value = ctx.resolve_identifier(name)
+        value = ctx.resolve_identifier(ctx, name)
         newval = increment(ctx, value, -1)
         stack.append(value)
         return newval
@@ -873,7 +873,7 @@
         self.name = name
 
     def eval(self, ctx, stack):
-        ctx.push_object(ctx.resolve_identifier(self.name).ToObject(ctx))
+        ctx.push_object(ctx.resolve_identifier(ctx, self.name).ToObject(ctx))
 
 class WITH_END(Opcode):
     def eval(self, ctx, stack):

Modified: pypy/branch/js-refactoring/pypy/lang/js/jsobj.py
==============================================================================
--- pypy/branch/js-refactoring/pypy/lang/js/jsobj.py	(original)
+++ pypy/branch/js-refactoring/pypy/lang/js/jsobj.py	Wed Jun  4 04:50:16 2008
@@ -605,14 +605,12 @@
         """remove the last pushed object"""
         return self.scope.pop()
         
-    def resolve_identifier(self, identifier):
+    def resolve_identifier(self, ctx, identifier):
         for i in range(len(self.scope)-1, -1, -1):
             obj = self.scope[i]
             assert isinstance(obj, W_PrimitiveObject)
-            try:
-                return obj.propdict[identifier].value
-            except KeyError:
-                pass
+            if obj.HasProperty(identifier):
+                return obj.Get(ctx, identifier)
         raise ThrowException(W_String("ReferenceError: %s is not defined" % identifier))
 
 def global_context(w_global):

Modified: pypy/branch/js-refactoring/pypy/lang/js/test/ecma/conftest.py
==============================================================================
--- pypy/branch/js-refactoring/pypy/lang/js/test/ecma/conftest.py	(original)
+++ pypy/branch/js-refactoring/pypy/lang/js/test/ecma/conftest.py	Wed Jun  4 04:50:16 2008
@@ -50,8 +50,8 @@
         if not hasattr(cls, 'shellfile'):
             cls.shellfile = load_file(str(shellpath))
         cls.interp.run(cls.shellfile)
-        cls.testcases = cls.interp.global_context.resolve_identifier('testcases')
-        cls.tc = cls.interp.global_context.resolve_identifier('tc')
+        cls.testcases = cls.interp.global_context.resolve_identifier(cls.interp.global_context, 'testcases')
+        cls.tc = cls.interp.global_context.resolve_identifier(cls.interp.global_context, 'tc')
         # override eval
         cls.interp.w_Global.Put(cls.interp.global_context, 'eval', W_Builtin(overriden_evaljs))
         
@@ -83,8 +83,8 @@
         except:
             raise Failed(excinfo=py.code.ExceptionInfo())
         ctx = self.interp.global_context
-        testcases = ctx.resolve_identifier('testcases')
-        self.tc = ctx.resolve_identifier('tc')
+        testcases = ctx.resolve_identifier(ctx, 'testcases')
+        self.tc = ctx.resolve_identifier(ctx, 'tc')
         testcount = testcases.Get(ctx, 'length').ToInt32(ctx)
         self.testcases = testcases
         return range(testcount)
@@ -99,7 +99,7 @@
         
     def run(self):
         ctx = JSTestFile.interp.global_context
-        r3 = ctx.resolve_identifier('run_test')
+        r3 = ctx.resolve_identifier(ctx, 'run_test')
         w_test_number = W_IntNumber(self.number)
         result = r3.Call(ctx=ctx, args=[w_test_number]).ToString()
         __tracebackhide__ = True



More information about the Pypy-commit mailing list