Author: Lars Wassermann <[email protected]>
Branch: 
Changeset: r101:c60b0b0bebae
Date: 2013-02-26 13:57 +0100
http://bitbucket.org/pypy/lang-smalltalk/changeset/c60b0b0bebae/

Log:    added printing to MethodContextShadow, printing the method with pc-
        arrow and the stack.

diff --git a/spyvm/model.py b/spyvm/model.py
--- a/spyvm/model.py
+++ b/spyvm/model.py
@@ -490,11 +490,15 @@
         return space.w_CompiledMethod
 
     def __str__(self):
+        return self.as_string()
+
+    def as_string(self, markBytecode=0):
         from spyvm.interpreter import BYTECODE_TABLE
         j = 1
         retval  = "\nMethodname: " + self._likely_methodname 
         retval += "\nBytecode:------------\n"
         for i in self.bytes:
+            retval += '->' if j is markBytecode else '  '
             retval += ('%0.2i: 0x%0.2x(%0.3i) ' % (j ,ord(i), ord(i))) + 
BYTECODE_TABLE[ord(i)].__name__ + "\n"
             j += 1
         return retval + "---------------------\n"
diff --git a/spyvm/shadow.py b/spyvm/shadow.py
--- a/spyvm/shadow.py
+++ b/spyvm/shadow.py
@@ -317,7 +317,6 @@
         self._w_sender = space.w_nil
         AbstractRedirectingShadow.__init__(self, space, w_self)
 
-
     @staticmethod
     def is_block_context(w_pointers, space):
         method_or_argc = w_pointers.fetch(space, constants.MTHDCTX_METHOD)
@@ -749,6 +748,12 @@
         else:
             return self._return(self.top(), interp, self.s_home().w_sender())
 
+    def __str__(self):
+        retval = '\nMethodContext of:'
+        retval += self.w_method().as_string(markBytecode=self.pc())
+        retval += "Stackptr: %i" % self._stack_ptr
+        retval += "\nStack   : " + str(self.stack())
+        return retval
 
 class CompiledMethodShadow(object):
     _immutable_fields_ = ["_w_self", "bytecode",
_______________________________________________
pypy-commit mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to