[pypy-svn] r48071 - in pypy/dist/pypy/lang/smalltalk: . test

niko at codespeak.net niko at codespeak.net
Fri Oct 26 16:58:05 CEST 2007


Author: niko
Date: Fri Oct 26 16:58:04 2007
New Revision: 48071

Modified:
   pypy/dist/pypy/lang/smalltalk/interpreter.py
   pypy/dist/pypy/lang/smalltalk/test/test_interpreter.py
Log:
(niko, toon)
fix the bytecodeAt functions when working with strings



Modified: pypy/dist/pypy/lang/smalltalk/interpreter.py
==============================================================================
--- pypy/dist/pypy/lang/smalltalk/interpreter.py	(original)
+++ pypy/dist/pypy/lang/smalltalk/interpreter.py	Fri Oct 26 16:58:04 2007
@@ -366,10 +366,16 @@
         self.callPrimitiveAndPush(primitives.BIT_OR, "|", 1, interp)
 
     def bytecodePrimAt(self, interp):
-        self.callPrimitiveAndPush(primitives.AT, "at:", 1, interp)
+        # n.b.: depending on the type of the receiver, this may invoke
+        # primitives.AT, primitives.STRING_AT, or something else for all
+        # I know.  
+        #self.callPrimitiveAndPush(primitives.AT, "at:", 1, interp)
+        self._sendSelfSelector("at:", 1, interp)
 
     def bytecodePrimAtPut(self, interp):
-        self.callPrimitiveAndPush(primitives.AT_PUT, "at:put:", 2, interp)
+        # n.b. as above
+        #self.callPrimitiveAndPush(primitives.AT_PUT, "at:put:", 2, interp)
+        self._sendSelfSelector("at:put:", 2, interp)
 
     def bytecodePrimSize(self, interp):
         self.callPrimitiveAndPush(primitives.SIZE, "size", 0, interp)

Modified: pypy/dist/pypy/lang/smalltalk/test/test_interpreter.py
==============================================================================
--- pypy/dist/pypy/lang/smalltalk/test/test_interpreter.py	(original)
+++ pypy/dist/pypy/lang/smalltalk/test/test_interpreter.py	Fri Oct 26 16:58:04 2007
@@ -1,7 +1,7 @@
 import py
 from pypy.lang.smalltalk import model, interpreter, primitives, shadow
 from pypy.lang.smalltalk import objtable
-from pypy.lang.smalltalk.objtable import wrap_int
+from pypy.lang.smalltalk.objtable import wrap_int, wrap_char
 import pypy.lang.smalltalk.classtable as ct
 
 mockclass = ct.bootstrap_class
@@ -570,3 +570,23 @@
           1, "valueWithArguments:"]],
         test)
 
+def test_bc_primBytecodeAt_string():
+    # 	^ 'a' at: 1
+    def test():
+        assert interpret_bc(
+            [ 32, 118, 192, 124],
+            fakeliterals("a")) == wrap_char("a")
+    run_with_faked_methods(
+        [[ct.w_String, primitives.STRING_AT, 1, "at:"]],
+        test)
+    
+def test_bc_primBytecodeAtPut_string():
+    # 	^ 'a' at: 1 put:'b'
+    def test():
+        assert interpret_bc(
+            [ 32, 118, 33, 193, 124 ],
+            fakeliterals("a", wrap_char("b"))) == wrap_char("b")
+    run_with_faked_methods(
+        [[ct.w_String, primitives.STRING_AT_PUT, 2, "at:put:"]],
+        test)
+



More information about the Pypy-commit mailing list