[pypy-svn] r48050 - in pypy/dist/pypy/lang/smalltalk: . test
niko at codespeak.net
niko at codespeak.net
Fri Oct 26 14:15:56 CEST 2007
Author: niko
Date: Fri Oct 26 14:15:56 2007
New Revision: 48050
Modified:
pypy/dist/pypy/lang/smalltalk/interpreter.py
pypy/dist/pypy/lang/smalltalk/model.py
pypy/dist/pypy/lang/smalltalk/primitives.py
pypy/dist/pypy/lang/smalltalk/test/test_interpreter.py
Log:
(niko, lukas)
1. improved fake_literal to handle arrays
2. make value_with_args test pass
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 14:15:56 2007
@@ -36,7 +36,9 @@
next = self.w_active_context.getNextBytecode()
bytecodeimpl = BYTECODE_TABLE[next]
if option.bc_trace:
- print "About to execute bytecode %s:" % (bytecodeimpl.__name__,)
+ print "About to execute bytecode at %d (%d:%s):" % (
+ self.w_active_context.pc,
+ next, bytecodeimpl.__name__,)
print " Stack=%s" % (repr(self.w_active_context.stack),)
bytecodeimpl(self.w_active_context, self)
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 14:15:56 2007
@@ -128,6 +128,10 @@
instsize = self.getclass().as_class_get_shadow().instsize()
return self._vars[idx+instsize]
+ def storevarpointer(self, idx, value):
+ instsize = self.getclass().as_class_get_shadow().instsize()
+ self._vars[idx+instsize] = value
+
def size(self):
return len(self._vars)
Modified: pypy/dist/pypy/lang/smalltalk/primitives.py
==============================================================================
--- pypy/dist/pypy/lang/smalltalk/primitives.py (original)
+++ pypy/dist/pypy/lang/smalltalk/primitives.py Fri Oct 26 14:15:56 2007
@@ -665,7 +665,7 @@
exp_arg_cnt = w_block_ctx.expected_argument_count()
# Check that our arguments have pointers format and the right size:
- if not isinstance(w_args, model.W_PointersObject):
+ if w_args.getclass() != classtable.w_Array:
raise PrimitiveFailedError()
if w_args.size() != exp_arg_cnt:
raise PrimitiveFailedError()
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 14:15:56 2007
@@ -50,11 +50,20 @@
return result
def fakeliterals(*literals):
- lst = ["methodheader"] + list(literals)
- for i in range(len(lst)):
- if isinstance(lst[i], str):
- lst[i] = fakesymbol(lst[i])
- return lst
+ def fakeliteral(lit):
+ if isinstance(lit, str):
+ return fakesymbol(lit)
+ elif isinstance(lit, int):
+ return wrap_int(lit)
+ elif isinstance(lit, list):
+ lstlen = len(lit)
+ res = ct.w_Array.as_class_get_shadow().new(lstlen)
+ for i in range(lstlen):
+ res.storevarpointer(i, fakeliteral(lit[i]))
+ return res
+ return lit
+
+ return ["methodheader"] + [fakeliteral(lit) for lit in literals]
def new_interpreter(bytes, receiver=objtable.w_nil):
assert isinstance(bytes, str)
@@ -550,10 +559,11 @@
# " (self >> #value1) literals "
#
# [ :a :b | a - b ] valueWithArguments: #(3 2)
- py.test.skip("in progress")
def test():
assert interpret_bc(
- [ 137, 119, 200, 164, 6, 105, 104, 16, 17, 177, 125, 33, 224, 124 ],
+ [ 137, 119, 200, 164, 6,
+ 105, 104, 16, 17, 177,
+ 125, 33, 224, 124 ],
fakeliterals("valueWithArguments:",
[3, 2])).value == 1
run_with_faked_methods(
More information about the Pypy-commit
mailing list