[pypy-commit] lang-js default: OPERATIONS is finally static enough

stepahn noreply at buildbot.pypy.org
Tue Jun 14 20:09:31 CEST 2011


Author: Stephan <stephan at stzal.com>
Branch: 
Changeset: r102:de89ec32a7dc
Date: 2011-06-14 20:09 +0200
http://bitbucket.org/pypy/lang-js/changeset/de89ec32a7dc/

Log:	OPERATIONS is finally static enough

diff --git a/js/operations.py b/js/operations.py
--- a/js/operations.py
+++ b/js/operations.py
@@ -123,7 +123,6 @@
 
 
 OPERANDS = {
-    '='   : '',
     '+='  : 'ADD',
     '-='  : 'SUB',
     '*='  : 'MUL',
@@ -137,8 +136,7 @@
     '>>=' : 'RSH'
     }
 
-# OPERANDS.values() is not staic enough
-OPERATIONS = unrolling_iterable(['ADD', 'SUB', 'MUL', 'DIV', 'MOD', 'BITAND', 'BITOR', 'BITXOR', 'BITNOT', 'URSH', 'RSH', 'LSH', 'INCR', 'DECR'])
+OPERATIONS = unrolling_iterable(OPERANDS.items())
 
 class BaseAssignment(Expression):
     noops = ['=']
@@ -166,18 +164,16 @@
 
     def emit_operation(self, bytecode):
         # calls to bytecode.emit have to be very very very static
-        operation = self.get_operation()
-        for op in OPERATIONS:
-            if op == operation:
-                bytecode.emit(op)
+        op = self.operand
+        for key, value in OPERATIONS:
+            if op == key:
+                bytecode.emit(value)
+                return
+        assert 0
 
     def emit_store(self, bytecode):
         raise NotImplementedError
 
-    def get_operation(self):
-        operation = OPERANDS[self.operand]
-        return operation
-
 class AssignmentOperation(BaseAssignment):
     def __init__(self, pos, left, right, operand, post = False):
         self.left = left


More information about the pypy-commit mailing list