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

fijal at codespeak.net fijal at codespeak.net
Wed Apr 2 05:23:09 CEST 2008


Author: fijal
Date: Wed Apr  2 05:23:08 2008
New Revision: 53248

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/operations.py
   pypy/branch/js-refactoring/pypy/lang/js/test/test_parser.py
Log:
Some minor fixes.


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 Apr  2 05:23:08 2008
@@ -239,6 +239,9 @@
         del stack[to_cut:]
         stack.append(W_List(list_w))
 
+    def __repr__(self):
+        return 'LOAD_LIST %d' % (self.counter,)
+
 class LOAD_FUNCTION(Opcode):
     def __init__(self, funcobj):
         self.funcobj = funcobj

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 Apr  2 05:23:08 2008
@@ -557,7 +557,7 @@
                 return obj.propdict[identifier].value
             except KeyError:
                 pass
-        raise Exception("stuff")
+        raise Exception("XXX shall never land here, fix")
         #return W_Reference(identifier)
 
 def global_context(w_global):

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	Wed Apr  2 05:23:08 2008
@@ -212,26 +212,6 @@
         bytecode.emit('STORE_MEMBER' + self._get_name())
 
 class StuffAssignment(Expression):
-    def __init__(self, pos, left, right, operand):
-        self.pos = pos
-        # check the sanity of lefthandside
-        if isinstance(left, Identifier):
-            self.identifier = left.name
-            self.single_assignement = True
-        elif isinstance(left, Member):
-            import pdb
-            pdb.set_trace()
-            self.lefthandside = left
-            self.single_assignement = False
-        self.right = right
-        self.operand = operand
-
-    def emit(self, bytecode):
-        op = self.operand
-        if op == '==':
-            bytecode.emit('STORE', self.identifier)
-        else:
-            XXX
 
     def eval(self, ctx):
         v1 = self.left.eval(ctx)
@@ -672,8 +652,6 @@
 
         for node in self.nodes:
             node.emit(bytecode)
-            # we don't need to pop after certain instructions, let's
-            # list them
 
     def execute(self, ctx):
         for varname in self.var_decl:
@@ -766,9 +744,9 @@
     def emit(self, bytecode):
         if self.expr is not None:
             self.expr.emit(bytecode)
+            bytecode.emit('STORE', self.identifier)
         else:
-            bytecode.emit('LOAD_UNDEFINED')
-        bytecode.emit('STORE', self.identifier)
+            return True
     
     def eval(self, ctx):
         name = self.identifier.get_literal()
@@ -797,12 +775,8 @@
 
     def emit(self, bytecode):
         for node in self.nodes:
-            node.emit(bytecode)
-    
-    def eval(self, ctx):
-        for var in self.nodes:
-            var.eval(ctx)
-        return w_Undefined
+            if node.emit(bytecode) is None:
+                bytecode.emit('POP')                
     
 class Variable(Statement):
     def __init__(self, pos, body):
@@ -811,7 +785,6 @@
 
     def emit(self, bytecode):
         self.body.emit(bytecode)
-        bytecode.emit('POP')
     
     def execute(self, ctx):
         return self.body.eval(ctx)

Modified: pypy/branch/js-refactoring/pypy/lang/js/test/test_parser.py
==============================================================================
--- pypy/branch/js-refactoring/pypy/lang/js/test/test_parser.py	(original)
+++ pypy/branch/js-refactoring/pypy/lang/js/test/test_parser.py	Wed Apr  2 05:23:08 2008
@@ -460,10 +460,16 @@
             'STORE "x"',
             'POP'])
 
+    def test_var_declr(self):
+        self.check('x; var x;', [
+            'DECLARE_VAR "x"',
+            'LOAD_VARIABLE "x"',
+            'POP'])
+
     def test_call(self):
         self.check('print("stuff")',[
             'LOAD_STRINGCONSTANT "stuff"',
-            'LOAD_ARRAY 1',
+            'LOAD_LIST 1',
             'LOAD_VARIABLE "print"',
             'CALL',
             'POP'])


More information about the pypy-svn mailing list