[pypy-svn] r23323 - in pypy/dist/pypy/jit: . test

ac at codespeak.net ac at codespeak.net
Tue Feb 14 14:11:03 CET 2006


Author: ac
Date: Tue Feb 14 14:11:02 2006
New Revision: 23323

Modified:
   pypy/dist/pypy/jit/test/test_jit_tl.py
   pypy/dist/pypy/jit/test/test_tl.py
   pypy/dist/pypy/jit/tl.py
   pypy/dist/pypy/jit/tlopcode.py
Log:
Adhere to cultural heritage.



Modified: pypy/dist/pypy/jit/test/test_jit_tl.py
==============================================================================
--- pypy/dist/pypy/jit/test/test_jit_tl.py	(original)
+++ pypy/dist/pypy/jit/test/test_jit_tl.py	Tue Feb 14 14:11:02 2006
@@ -74,7 +74,7 @@
     run_jit('''
             PUSH 42
             PUSH -42
-            ROT 2   # at the moment we see a potential IndexError here
+            ROLL 2   # at the moment we see a potential IndexError here
     ''')
 
 def test_calls():

Modified: pypy/dist/pypy/jit/test/test_tl.py
==============================================================================
--- pypy/dist/pypy/jit/test/test_tl.py	(original)
+++ pypy/dist/pypy/jit/test/test_tl.py	Tue Feb 14 14:11:02 2006
@@ -113,12 +113,19 @@
     assert interp(list2bytecode([PUSH,7, RETURN, PUSH,5])) == 7
 
 def test_rot():
-    code = [PUSH,1, PUSH,2, PUSH,3, ROT,3] 
+    code = [PUSH,1, PUSH,2, PUSH,3, ROLL, 3] 
+    assert interp(list2bytecode(code)) == 1
+    assert interp(list2bytecode(code + [POP])) == 3
+    assert interp(list2bytecode(code + [POP, POP])) == 2
+
+    py.test.raises(IndexError, interp, list2bytecode([PUSH,1, PUSH,2, PUSH,3, ROLL,4]))
+
+    code = [PUSH,1, PUSH,2, PUSH,3, ROLL, -3] 
     assert interp(list2bytecode(code)) == 2
     assert interp(list2bytecode(code + [POP])) == 1
     assert interp(list2bytecode(code + [POP, POP])) == 3
 
-    py.test.raises(IndexError, interp, list2bytecode([PUSH,1, PUSH,2, PUSH,3, ROT,4]))
+    py.test.raises(IndexError, interp, list2bytecode([PUSH,1, PUSH,2, PUSH,3, ROLL,-4]))
 
 def test_call_ret():
     assert interp(list2bytecode([CALL,1, RETURN, PUSH,2])) == 2

Modified: pypy/dist/pypy/jit/tl.py
==============================================================================
--- pypy/dist/pypy/jit/tl.py	(original)
+++ pypy/dist/pypy/jit/tl.py	Tue Feb 14 14:11:02 2006
@@ -38,13 +38,19 @@
             stack.append(a)
             stack.append(b)
 
-        elif opcode == ROT: #rotate stack top to somewhere below
+        elif opcode == ROLL: #rotate stack top to somewhere below
             r = char2int(code[pc])
-            if r > 1:
-                i = len(stack) - r
+            if r < -1:
+                i = len(stack) + r
                 if i < 0:
                     raise IndexError
                 stack.insert( i, stack.pop() )
+            elif r > 1:
+                i = len(stack) - r
+                if i < 0:
+                    raise IndexError
+                stack.append(stack.pop(i))
+                
             pc += 1
 
         elif opcode == PICK:

Modified: pypy/dist/pypy/jit/tlopcode.py
==============================================================================
--- pypy/dist/pypy/jit/tlopcode.py	(original)
+++ pypy/dist/pypy/jit/tlopcode.py	Tue Feb 14 14:11:02 2006
@@ -8,7 +8,7 @@
 opcode(2,  "PUSH")     #1 operand
 opcode(3,  "POP")
 opcode(4,  "SWAP")
-opcode(5,  "ROT")
+opcode(5,  "ROLL")
 
 opcode(6,  "PICK")     #1 operand (DUP = PICK,0)
 opcode(7,  "PUT")      #1 operand



More information about the Pypy-commit mailing list