[pypy-svn] r47980 - in pypy/dist/pypy/lang/smalltalk: . tool
tverwaes at codespeak.net
tverwaes at codespeak.net
Thu Oct 25 20:22:03 CEST 2007
Author: tverwaes
Date: Thu Oct 25 20:22:02 2007
New Revision: 47980
Modified:
pypy/dist/pypy/lang/smalltalk/constants.py
pypy/dist/pypy/lang/smalltalk/tool/analyseimage.py
Log:
adding constants for MESSAGE_CLASS
Modified: pypy/dist/pypy/lang/smalltalk/constants.py
==============================================================================
--- pypy/dist/pypy/lang/smalltalk/constants.py (original)
+++ pypy/dist/pypy/lang/smalltalk/constants.py Thu Oct 25 20:22:02 2007
@@ -18,6 +18,10 @@
METHODDICT_VALUES_INDEX = 1
METHODDICT_NAMES_INDEX = 2
+MESSAGE_SELECTOR_INDEX = 0
+MESSAGE_ARGUMENTS_INDEX = 1
+MESSAGE_LOOKUP_CLASS_INDEX = 2
+
ASSOCIATION_KEY_INDEX = 0
ASSOCIATION_VALUE_INDEX = 1
@@ -36,7 +40,6 @@
MTHDCTX_RECEIVER_MAP = 4
MTHDCTX_RECEIVER = 5
MTHDCTX_TEMP_FRAME_START = 6
-
# ----- special objects indices -------
SO_NIL = 0
Modified: pypy/dist/pypy/lang/smalltalk/tool/analyseimage.py
==============================================================================
--- pypy/dist/pypy/lang/smalltalk/tool/analyseimage.py (original)
+++ pypy/dist/pypy/lang/smalltalk/tool/analyseimage.py Thu Oct 25 20:22:02 2007
@@ -3,9 +3,11 @@
from pypy.lang.smalltalk import squeakimage
from pypy.lang.smalltalk import constants
from pypy.lang.smalltalk import model
+from pypy.lang.smalltalk import objtable
+from pypy.lang.smalltalk import classtable
from pypy.lang.smalltalk import interpreter
-mini_image = py.magic.autopath().dirpath().dirpath().join('mini.image')
+mini_image = py.magic.autopath().dirpath().dirpath().join('tool/squeak3.9.image')
def get_miniimage():
return squeakimage.ImageReader(squeakimage.Stream(mini_image.open()))
@@ -22,7 +24,8 @@
image = create_squeakimage()
for each in image.objects:
if isinstance(each,model.W_BytesObject):
- print each.bytes
+ print each.shadow_of_my_class()
+ print each.as_string()
def testCompiledMethods():
image = create_squeakimage()
@@ -47,6 +50,45 @@
except interpreter.ReturnFromTopLevel, e:
return e.object
+def testDoesNotUnderstand():
+ image = create_squeakimage()
+ amethod = None
+
+ w_doesnot = image.special(constants.SO_DOES_NOT_UNDERSTAND)
+ w_object = objtable.wrap_int(3)
+ w_message_class = image.special(constants.SO_MESSAGE_CLASS)
+ s_message_class = w_message_class.as_class_get_shadow()
+
+ #Build message argument
+ w_message = s_message_class.new(1)
+ w_message.store(constants.MESSAGE_SELECTOR_INDEX, objtable.wrap_string("zork"))
+ w_aarray = classtable.w_Array.as_class_get_shadow().new(0)
+ w_message.store(constants.MESSAGE_ARGUMENTS_INDEX, w_aarray)
+ if s_message_class.instsize() > constants.MESSAGE_LOOKUP_CLASS_INDEX:
+ w_message.store(constants.MESSAGE_LOOKUP_CLASS_INDEX, w_object.getclass())
+
+ s_class = w_object.shadow_of_my_class()
+ w_method = s_class.lookup(w_doesnot)
+
+ interp = interpreter.Interpreter()
+
+ # First literal of the abs method is
+ # a real smalltalk int
+ w_frame = w_method.createFrame(w_object, [w_message])
+ print "WFRAME: %r" % (w_frame,)
+ interp.w_active_context = w_frame
+
+ print w_method
+
+ while True:
+ try:
+ print "Stackbefore: %r" % (interp.w_active_context.stack,)
+ interp.step()
+ print "Stackafter: %r" % (interp.w_active_context.stack,)
+ except interpreter.ReturnFromTopLevel, e:
+ return e.object
+
+
def testSelector():
image = create_squeakimage()
w_doesnot = image.special(constants.SO_DOES_NOT_UNDERSTAND)
@@ -61,8 +103,9 @@
print w_doesnot.getclass().fetch(constants.CLASS_METHODDICT_INDEX)._vars[constants.METHODDICT_VALUES_INDEX]._vars
def test_do():
- testSelector()
- #printStringsInImage()
+ #testSelector()
+ printStringsInImage()
+ #testDoesNotUnderstand()
if __name__ == '__main__':
test_do()
More information about the Pypy-commit
mailing list