[pypy-commit] lang-smalltalk default: added three more bytecodes with tests

lwassermann noreply at buildbot.pypy.org
Mon Feb 18 19:07:12 CET 2013


Author: Lars Wassermann <lars.wassermann at gmail.com>
Branch: 
Changeset: r55:bcc14b793a2c
Date: 2013-02-18 19:06 +0100
http://bitbucket.org/pypy/lang-smalltalk/changeset/bcc14b793a2c/

Log:	added three more bytecodes with tests

diff --git a/spyvm/interpreter.py b/spyvm/interpreter.py
--- a/spyvm/interpreter.py
+++ b/spyvm/interpreter.py
@@ -377,7 +377,6 @@
         else:
            newArray = interp.space.w_Array.as_class_get_shadow(interp.space).new(arraySize)
         self.push(newArray)
-        # raise MissingBytecode("not yet implemented: pushNewArray")
 
     def experimentalBytecode(self, interp):
         raise MissingBytecode("experimentalBytecode")
@@ -385,17 +384,23 @@
     def pushTempAtInTempVectorAt(self, interp):
         k = self.getbytecode()
         j = self.getbytecode()
-        raise MissingBytecode("not yet implemented: pushTempAt k inTempVectorAt j")
+        context = interp.s_active_context()
+        indirectTemps = context.gettemp(j)
+        context.push(indirectTemps.at0(self, k))
 
     def storeTempAtInTempVectorAt(self, interp):
         k = self.getbytecode()
         j = self.getbytecode()
-        raise MissingBytecode("not yet implemented: storeTempAt k inTempVectorAt j")
+        context = interp.s_active_context()
+        indirectTemps = context.gettemp(j)
+        indirectTemps.atput0(self, k, context.top())
 
     def popAndStoreTempAtInTempVectorAt(self, interp):
         k = self.getbytecode()
         j = self.getbytecode()
-        raise MissingBytecode("not yet implemented: popAndstoreTempAt k inTempVectorAt j")
+        context = interp.s_active_context()
+        indirectTemps = context.gettemp(j)
+        indirectTemps.atput0(self, k, context.pop())
 
     def pushClosureNumCopiedNumArgsBlockSize(self, interp):
         l, k = splitter[4, 4](self.getbytecode())
diff --git a/spyvm/test/test_interpreter.py b/spyvm/test/test_interpreter.py
--- a/spyvm/test/test_interpreter.py
+++ b/spyvm/test/test_interpreter.py
@@ -850,3 +850,38 @@
     array = context.pop()
     assert array.size() == 7
     assert array.at0(space, 0) == space.w_nil
+
+def test_pushTempAt0InTempVectorAt0(bytecode = pushTempAtInTempVectorAt):
+    interp = new_interpreter(bytecode + chr(0) + chr(0))
+    context = interp.s_active_context()
+    context.push(fakeliterals(space, "jam"))
+    context.settemp(0, space.w_Array.as_class_get_shadow(interp.space).new(2))
+    interp.step(interp.s_active_context())
+    assert context.top() == space.w_nil
+
+def setupTempArrayAndContext(bytecode):
+    # both indizes are 0-relative
+    interp = new_interpreter(bytecode + chr(2) + chr(1))
+    context = interp.s_active_context()
+    context.push(fakeliterals(space, "english"))
+    context.push(fakeliterals(space, "bar"))
+    temp_array = space.w_Array.as_class_get_shadow(interp.space).new(3)
+    temp_array.atput0(space, 2, fakeliterals(space, "pub"))
+    context.settemp(1, temp_array)
+    interp.step(interp.s_active_context())
+    return context, temp_array
+
+def test_pushTempAt3InTempVectorAt1(bytecode = pushTempAtInTempVectorAt):
+    context, _ = setupTempArrayAndContext(bytecode)
+    assert context.top() == fakeliterals(space, "pub")
+
+def test_storeTempAtInTempVectorAt(bytecode = storeTempAtInTempVectorAt):
+    context, temp_array = setupTempArrayAndContext(bytecode)
+    assert context.top() == fakeliterals(space, "bar")
+    assert temp_array.at0(space, 2) == fakeliterals(space, "bar")
+
+def test_popAndStoreTempAtInTempVectorAt(bytecode = popAndStoreTempAtInTempVectorAt):
+    context, temp_array = setupTempArrayAndContext(bytecode)
+    assert temp_array.at0(space, 2) == fakeliterals(space, "bar")
+    assert context.top() == fakeliterals(space, "english")
+


More information about the pypy-commit mailing list