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

fijal at codespeak.net fijal at codespeak.net
Fri Apr 4 05:51:00 CEST 2008


Author: fijal
Date: Fri Apr  4 05:51:00 2008
New Revision: 53314

Modified:
   pypy/branch/js-refactoring/pypy/lang/js/jscode.py
   pypy/branch/js-refactoring/pypy/lang/js/test/ecma/conftest.py
   pypy/branch/js-refactoring/pypy/lang/js/test/test_interp.py
Log:
a test and a fix for x.x += stuff


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	Fri Apr  4 05:51:00 2008
@@ -503,13 +503,22 @@
         left = stack.pop()
         elem = stack.pop()
         value = stack.pop()
-        self.operation()
-        left.Put(elem.ToString(), value)
+        name = elem.ToString()
+        value = self.operation(ctx, left, name, value)
+        left.Put(name, value)
         stack.append(left)
 
 class STORE_MEMBER(BaseStoreMember):
-    def operation(self):
-        pass
+    def operation(self, ctx, left, elem, value):
+        return value
+
+class BaseStoreMemberAssign(BaseStoreMember):
+    def operation(self, ctx, left, name, value):
+        prev = left.Get(name)
+        return self.decision(ctx, value, prev)
+
+class STORE_MEMBER_ADD(BaseStoreMemberAssign):
+    decision = staticmethod(ADD.operation)
 
 class STORE_MEMBER_POSTINCR(BaseStoreMember):
     def operation(self):

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	Fri Apr  4 05:51:00 2008
@@ -36,10 +36,9 @@
             cls.tc.PutValue(W_IntNumber(0), cls.interp.global_context)
 
         cls.interp = Interpreter()
-        ctx = cls.interp.global_context
         shellpath = rootdir/'shell.js'
         t = load_file(str(shellpath))
-        t.execute(ctx)
+        cls.interp.run(t)
         cls.testcases = cls.interp.global_context.resolve_identifier('testcases')
         cls.tc = cls.interp.global_context.resolve_identifier('tc')
     init_interp = classmethod(init_interp)

Modified: pypy/branch/js-refactoring/pypy/lang/js/test/test_interp.py
==============================================================================
--- pypy/branch/js-refactoring/pypy/lang/js/test/test_interp.py	(original)
+++ pypy/branch/js-refactoring/pypy/lang/js/test/test_interp.py	Fri Apr  4 05:51:00 2008
@@ -268,6 +268,7 @@
 def test_assignments():
     yield assertv, "var x = 3; x += 4; x;", 7
     yield assertv, "x = 8; x -= 3; x;", 5
+    yield assertv, "x = {}; x.x = 3; x.x += 8; x.x", 8+3
 
 def test_object_creation():
     yield assertv, """



More information about the Pypy-commit mailing list