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

fijal at codespeak.net fijal at codespeak.net
Fri Apr 4 07:29:26 CEST 2008


Author: fijal
Date: Fri Apr  4 07:29:25 2008
New Revision: 53321

Modified:
   pypy/branch/js-refactoring/pypy/lang/js/jscode.py
   pypy/branch/js-refactoring/pypy/lang/js/operations.py
   pypy/branch/js-refactoring/pypy/lang/js/test/ecma/conftest.py
Log:
* kill optimization that is wrong
* fix some minor issues
* fix post incr/decr


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 07:29:25 2008
@@ -285,6 +285,7 @@
         self.identifier = identifier
 
     def eval(self, ctx, stack):
+        xxx
         scope = ctx.scope[self.depth]
         stack.append(scope.Get(self.identifier))
         #stack.append(W_Reference(self.identifier, scope))
@@ -627,7 +628,14 @@
     def process(self, ctx, name, stack):
         value = ctx.resolve_identifier(name)
         newval = increment(ctx, value)
-        stack.append(newval)
+        stack.append(value)
+        return newval
+
+class STORE_POSTDECR(BaseStore):
+    def process(self, ctx, name, stack):
+        value = ctx.resolve_identifier(name)
+        newval = increment(ctx, value, -1)
+        stack.append(value)
         return newval
 
 class LABEL(Opcode):

Modified: pypy/branch/js-refactoring/pypy/lang/js/operations.py
==============================================================================
--- pypy/branch/js-refactoring/pypy/lang/js/operations.py	(original)
+++ pypy/branch/js-refactoring/pypy/lang/js/operations.py	Fri Apr  4 07:29:25 2008
@@ -215,38 +215,6 @@
         self.what.emit(bytecode)
         bytecode.emit('STORE_MEMBER' + self._get_name())
 
-class StuffAssignment(Expression):
-
-    def eval(self, ctx):
-        v1 = self.left.eval(ctx)
-        v3 = self.right.eval(ctx).GetValue()
-        op = self.type
-        if op == "=":
-            val = v3
-        elif op == "*=":
-            val = mult(ctx, v1.GetValue(), v3)
-        elif op == "+=":
-            val = plus(ctx, v1.GetValue(), v3)
-        elif op == "-=":
-            val = sub(ctx, v1.GetValue(), v3)
-        elif op == "/=":
-            val = division(ctx, v1.GetValue(), v3)
-        elif op == "%=":
-            val = mod(ctx, v1.GetValue(), v3)
-        elif op == "&=":
-            val = W_IntNumber(v1.GetValue().ToInt32() & v3.ToInt32())
-        elif op == "|=":
-            val = W_IntNumber(v1.GetValue().ToInt32() | v3.ToInt32())
-        elif op == "^=":
-            val = W_IntNumber(v1.GetValue().ToInt32() ^ v3.ToInt32())
-        else:
-            print op
-            raise NotImplementedError()
-        
-        v1.PutValue(val, ctx)
-        return val
-    
-
 class Block(Statement):
     def __init__(self, pos, nodes):
         self.pos = pos
@@ -308,13 +276,6 @@
         self.condition = condition
         self.truepart = truepart
         self.falsepart = falsepart
-    
-    def eval(self, ctx):
-        if self.condition.eval(ctx).GetValue().ToBoolean():
-            return self.truepart.eval(ctx).GetValue()
-        else:
-            return self.falsepart.eval(ctx).GetValue()
-    
 
 class Member(Expression):
     "this is for object[name]"
@@ -709,14 +670,6 @@
             bytecode.emit('STORE', self.identifier)
         else:
             return True
-    
-    def eval(self, ctx):
-        name = self.identifier.get_literal()
-        if self.expr is None:
-            ctx.variable.Put(name, w_Undefined, dd=True)
-        else:
-            ctx.variable.Put(name, self.expr.eval(ctx).GetValue(), dd=True)
-        return self.identifier.eval(ctx)
 
 class VariableIdentifier(Expression):
     def __init__(self, pos, depth, identifier):
@@ -725,7 +678,7 @@
         self.identifier = identifier
 
     def emit(self, bytecode):
-        bytecode.emit('LOAD_REALVAR', self.depth, self.identifier)
+        bytecode.emit('LOAD_VARIABLE', self.identifier)
 
     def get_literal(self):
         return self.identifier

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 07:29:25 2008
@@ -82,7 +82,7 @@
         ctx = JSTestFile.interp.global_context
         r3 = ctx.resolve_identifier('run_test')
         w_test_number = W_IntNumber(self.number)
-        result = r3.Call(ctx=ctx, args=[w_test_number,]).ToString()
+        result = r3.Call(ctx=ctx, args=[w_test_number]).ToString()
         if result != "passed":
             raise Failed(msg=result)
         elif result == -1:



More information about the Pypy-commit mailing list