[pypy-svn] r48079 - in pypy/dist/pypy/lang/smalltalk: . test
niko at codespeak.net
niko at codespeak.net
Fri Oct 26 17:27:40 CEST 2007
Author: niko
Date: Fri Oct 26 17:27:40 2007
New Revision: 48079
Modified:
pypy/dist/pypy/lang/smalltalk/model.py
pypy/dist/pypy/lang/smalltalk/test/test_interpreter.py
Log:
(niko, toon)
change AT and AT_PUT to fetch from the variable-sized region
Modified: pypy/dist/pypy/lang/smalltalk/model.py
==============================================================================
--- pypy/dist/pypy/lang/smalltalk/model.py (original)
+++ pypy/dist/pypy/lang/smalltalk/model.py Fri Oct 26 17:27:40 2007
@@ -118,10 +118,10 @@
self._vars = [w_nil] * size
def at0(self, index0):
- return self.fetch(index0)
+ return self.fetchvarpointer(index0)
def atput0(self, index0, w_value):
- self.store(index0, w_value)
+ self.storevarpointer(index0, w_value)
def fetch(self, n0):
return self._vars[n0]
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 17:27:40 2007
@@ -580,9 +580,9 @@
storeAssociation(doubleExtendedDoAnythingBytecode + chr(7<<5) + chr(0))
-def interpret_bc(bcodes, literals):
+def interpret_bc(bcodes, literals, receiver=objtable.w_nil):
bcode = "".join([chr(x) for x in bcodes])
- interp = new_interpreter(bcode)
+ interp = new_interpreter(bcode, receiver=receiver)
interp.w_active_context.w_method().literals = literals
return interp.interpret()
@@ -681,4 +681,36 @@
fakeliterals("a", wrap_char("b"))) == wrap_char("b")
run_with_faked_methods(
[[ct.w_String, primitives.STRING_AT_PUT, 2, "at:put:"]],
- test)
\ No newline at end of file
+ test)
+
+def test_bc_primBytecodeAt_with_instvars():
+ # ^ self at: 1
+ w_fakeclass = mockclass(1, name='fakeclass', varsized=True)
+ w_fakeinst = w_fakeclass.as_class_get_shadow().new(1)
+ w_fakeinst.store(0, wrap_char("a")) # static slot 0: instance variable
+ w_fakeinst.store(1, wrap_char("b")) # varying slot 1
+ def test():
+ assert objtable.ord_w_char(interpret_bc(
+ [112, 118, 192, 124],
+ fakeliterals(),
+ receiver=w_fakeinst)) == ord("b")
+ run_with_faked_methods(
+ [[w_fakeclass, primitives.AT, 1, "at:"]],
+ test)
+
+def test_bc_primBytecodeAtPut_with_instvars():
+ # ^ self at: 1 put: #b
+ w_fakeclass = mockclass(1, name='fakeclass', varsized=True)
+ w_fakeinst = w_fakeclass.as_class_get_shadow().new(1)
+ w_fakeinst.store(0, wrap_char("a")) # static slot 0: instance variable
+ w_fakeinst.store(1, wrap_char("a")) # varying slot 1
+ def test():
+ assert objtable.ord_w_char(interpret_bc(
+ [0x70, 0x76, 0x20, 0xc1, 0x7c],
+ fakeliterals(wrap_char("b")),
+ receiver=w_fakeinst)) == ord("b")
+ assert objtable.ord_w_char(w_fakeinst.fetch(0)) == ord("a")
+ assert objtable.ord_w_char(w_fakeinst.fetch(1)) == ord("b")
+ run_with_faked_methods(
+ [[w_fakeclass, primitives.AT_PUT, 2, "at:put:"]],
+ test)
More information about the Pypy-commit
mailing list