[pypy-svn] r48031 - pypy/dist/pypy/lang/smalltalk
niko at codespeak.net
niko at codespeak.net
Fri Oct 26 11:52:43 CEST 2007
Author: niko
Date: Fri Oct 26 11:52:43 2007
New Revision: 48031
Added:
pypy/dist/pypy/lang/smalltalk/conftest.py
Modified:
pypy/dist/pypy/lang/smalltalk/interpreter.py
Log:
(niko, arigo)
make a py.test option --bc-trace to enable bytecode tracing
Added: pypy/dist/pypy/lang/smalltalk/conftest.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/lang/smalltalk/conftest.py Fri Oct 26 11:52:43 2007
@@ -0,0 +1,10 @@
+import py
+
+Option = py.test.config.Option
+option = py.test.config.addoptions("smalltalk options",
+ Option('--bc-trace',
+ action="store_true",
+ dest="bc_trace",
+ default=False,
+ help="print bytecodes and stack during execution"),
+ )
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 11:52:43 2007
@@ -2,6 +2,7 @@
from pypy.lang.smalltalk import model, constants, primitives
from pypy.lang.smalltalk import objtable
from pypy.lang.smalltalk.model import W_ContextPart
+from pypy.lang.smalltalk.conftest import option
class MissingBytecode(NotImplementedError):
@@ -34,6 +35,9 @@
def step(self):
next = self.w_active_context.getNextBytecode()
bytecodeimpl = BYTECODE_TABLE[next]
+ if option.bc_trace:
+ print "About to execute bytecode %s:" % (bytecodeimpl.__name__,)
+ print " Stack=%s" % (repr(self.w_active_context.stack),)
bytecodeimpl(self.w_active_context, self)
class ReturnFromTopLevel(Exception):
@@ -478,21 +482,12 @@
def initialize_bytecode_table():
result = [None] * 256
for entry in BYTECODE_RANGES:
- def dump_func(f):
- def wrapped(self, interp):
- print "Bytecode: %s" % (f.__name__,)
- res = f(self, interp)
- print " stack after: %s" % (
- interp.w_active_context.stack)
- return res
- return wrapped
if len(entry) == 2:
positions = [entry[0]]
else:
positions = range(entry[0], entry[1]+1)
for pos in positions:
- result[pos] = dump_func(entry[-1])
- #result[pos] = entry[-1]
+ result[pos] = entry[-1]
assert None not in result
return result
More information about the Pypy-commit
mailing list