[pypy-svn] r47956 - in pypy/dist/pypy/lang/smalltalk: . tool
tverwaes at codespeak.net
tverwaes at codespeak.net
Thu Oct 25 18:00:39 CEST 2007
Author: tverwaes
Date: Thu Oct 25 18:00:39 2007
New Revision: 47956
Modified:
pypy/dist/pypy/lang/smalltalk/model.py
pypy/dist/pypy/lang/smalltalk/tool/analyseimage.py
Log:
(toon, arigo, akuhn) repr of AbstractObjectWithClassReference
Modified: pypy/dist/pypy/lang/smalltalk/model.py
==============================================================================
--- pypy/dist/pypy/lang/smalltalk/model.py (original)
+++ pypy/dist/pypy/lang/smalltalk/model.py Thu Oct 25 18:00:39 2007
@@ -84,6 +84,9 @@
def getclass(self):
return self.w_class
+ def __repr__(self):
+ return "<%s %s>" % (self.__class__.__name__, self)
+
def __str__(self):
if isinstance(self, W_PointersObject) and self._shadow is not None:
return "%s class" % (self.as_class_get_shadow().name or '?',)
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 18:00:39 2007
@@ -1,41 +1,41 @@
import autopath
import py
-from pypy.lang.smalltalk import squeakimage as sq
-from pypy.lang.smalltalk import constants as sqc
-from pypy.lang.smalltalk import model as sqm
-from pypy.lang.smalltalk import interpreter as sqi
+from pypy.lang.smalltalk import squeakimage
+from pypy.lang.smalltalk import constants
+from pypy.lang.smalltalk import model
+from pypy.lang.smalltalk import interpreter
mini_image = py.magic.autopath().dirpath().dirpath().join('mini.image')
def get_miniimage():
- return sq.ImageReader(sq.Stream(mini_image.open()))
+ return squeakimage.ImageReader(squeakimage.Stream(mini_image.open()))
def create_squeakimage():
example = get_miniimage()
example.initialize()
- image = sq.SqueakImage()
+ image = squeakimage.SqueakImage()
image.from_reader(example)
return image
def printStringsInImage():
image = create_squeakimage()
for each in image.objects:
- if isinstance(each,sqm.W_BytesObject):
+ if isinstance(each,model.W_BytesObject):
print each.bytes
def testCompiledMethods():
image = create_squeakimage()
amethod = None
- w_smallint_class = image.special(sqc.SO_SMALLINTEGER_CLASS)
+ w_smallint_class = image.special(constants.SO_SMALLINTEGER_CLASS)
- interp = sqi.Interpreter()
+ interp = interpreter.Interpreter()
amethod = w_smallint_class.lookup("abs")
# First literal of the abs method is
# a real smalltalk int
- w_frame = amethod.createFrame(sqm.W_SmallInteger(3), [])
+ w_frame = amethod.createFrame(model.W_SmallInteger(3), [])
interp.activeContext = w_frame
print amethod
@@ -44,13 +44,14 @@
try:
interp.step()
print interp.activeContext.stack
- except sqi.ReturnFromTopLevel, e:
+ except interpreter.ReturnFromTopLevel, e:
return e.object
def testSelector():
image = create_squeakimage()
- w_doesnot = image.special(sqc.SO_DOES_NOT_UNDERSTAND)
+ w_doesnot = image.special(constants.SO_DOES_NOT_UNDERSTAND)
assert repr(w_doesnot.shadow_of_my_class()) == "<ClassShadow Symbol>"
+ print w_doesnot.getclass().fetch(constants.CLASS_METHODDICT_INDEX)._vars
def test_do():
testSelector()
More information about the Pypy-commit
mailing list