[pypy-commit] lang-js default: implemented STORE_BITRSH

stepahn noreply at buildbot.pypy.org
Wed May 18 19:27:48 CEST 2011


Author: Stephan <stephan at stzal.com>
Branch: 
Changeset: r73:bacae58940c2
Date: 2011-05-18 16:09 +0200
http://bitbucket.org/pypy/lang-js/changeset/bacae58940c2/

Log:	implemented STORE_BITRSH

diff --git a/js/jscode.py b/js/jscode.py
--- a/js/jscode.py
+++ b/js/jscode.py
@@ -701,6 +701,10 @@
     def operation(self, ctx, op1, op2):
         return W_IntNumber(op1^op2)
 
+class STORE_BITRSH(BaseAssignBitOper):
+    def operation(self, ctx, op1, op2):
+        return W_IntNumber(op1 >> op2)
+
 class STORE_POSTINCR(BaseStore):
     def process(self, ctx, name, stack):
         value = ctx.resolve_identifier(ctx, name)
diff --git a/js/operations.py b/js/operations.py
--- a/js/operations.py
+++ b/js/operations.py
@@ -129,17 +129,18 @@
         return addoper
 
 OPERANDS = {
-    '='  : '',
-    '+=' : 'ADD',
-    '-=' : 'SUB',
-    '*=' : 'MUL',
-    '/=' : 'DIV',
-    '++' : 'INCR',
-    '--' : 'DECR',
-    '%=' : 'MOD',
-    '&=' : 'BITAND',
-    '|=' : 'BITOR',
-    '^=' : 'BITXOR',
+    '='   : '',
+    '+='  : 'ADD',
+    '-='  : 'SUB',
+    '*='  : 'MUL',
+    '/='  : 'DIV',
+    '++'  : 'INCR',
+    '--'  : 'DECR',
+    '%='  : 'MOD',
+    '&='  : 'BITAND',
+    '|='  : 'BITOR',
+    '^='  : 'BITXOR',
+    '>>=' : 'BITRSH'
     }
 
 class SimpleIncrement(Expression):
diff --git a/js/test/test_interp.py b/js/test/test_interp.py
--- a/js/test/test_interp.py
+++ b/js/test/test_interp.py
@@ -732,6 +732,13 @@
     yield assertv, 'var i = {x:1}; i.x|=0;', 1
     yield assertv, 'var i = {x:1}; i.x|=1;', 1
 
+def test_store_bitrsh():
+    yield assertv, 'var i = 1; i>>=0;', 1
+    yield assertv, 'var i = 2; i>>=1;', 1
+    yield assertv, 'var i = 4; i>>=1;', 2
+    yield assertv, 'var i = 4; i>>=2;', 1
+    yield assertv, 'var i = 4; i>>=3;', 0
+
 def test_loop_continue():
     yield assertv, """
       i = 0;


More information about the pypy-commit mailing list