[pypy-svn] r24676 - in pypy/dist/pypy: rpython/ootypesystem/test rpython/test translator/squeak
nik at codespeak.net
nik at codespeak.net
Tue Mar 21 14:06:43 CET 2006
Author: nik
Date: Tue Mar 21 14:06:42 2006
New Revision: 24676
Modified:
pypy/dist/pypy/rpython/ootypesystem/test/test_oopbc.py
pypy/dist/pypy/rpython/test/test_rpbc.py
pypy/dist/pypy/translator/squeak/node.py
Log:
use dynamicType where appropriate or necessary.
Modified: pypy/dist/pypy/rpython/ootypesystem/test/test_oopbc.py
==============================================================================
--- pypy/dist/pypy/rpython/ootypesystem/test/test_oopbc.py (original)
+++ pypy/dist/pypy/rpython/ootypesystem/test/test_oopbc.py Tue Mar 21 14:06:42 2006
@@ -28,9 +28,9 @@
cls = A
return cls()
res = interpret(f, [0], type_system='ootype')
- assert ootype.classof(res)._INSTANCE._name.split(".")[-1] == 'A'
+ assert ootype.dynamicType(res)._name.split(".")[-1] == 'A'
res = interpret(f, [1], type_system='ootype')
- assert ootype.classof(res)._INSTANCE._name.split(".")[-1] == 'B'
+ assert ootype.dynamicType(res)._name.split(".")[-1] == 'B'
def test_call_classes_init():
class A:
Modified: pypy/dist/pypy/rpython/test/test_rpbc.py
==============================================================================
--- pypy/dist/pypy/rpython/test/test_rpbc.py (original)
+++ pypy/dist/pypy/rpython/test/test_rpbc.py Tue Mar 21 14:06:42 2006
@@ -1388,9 +1388,9 @@
ts = "ootype"
def class_name(self, value):
- return ootype.classof(value)._INSTANCE._name.split(".")[-1]
+ return ootype.dynamicType(value)._name.split(".")[-1]
def read_attr(self, value, attr):
- value = ootype.oodowncast(ootype.classof(value)._INSTANCE, value)
+ value = ootype.oodowncast(ootype.dynamicType(value), value)
return getattr(value, "o" + attr)
Modified: pypy/dist/pypy/translator/squeak/node.py
==============================================================================
--- pypy/dist/pypy/translator/squeak/node.py (original)
+++ pypy/dist/pypy/translator/squeak/node.py Tue Mar 21 14:06:42 2006
@@ -4,6 +4,7 @@
from pypy.translator.squeak.codeformatter import CodeFormatter, Message
from pypy.translator.squeak.codeformatter import Field, Assignment, CustomVariable
from pypy.rpython.ootypesystem.ootype import Instance, Class, ROOT, _view
+from pypy.rpython.ootypesystem.ootype import dynamicType, oodowncast
class CodeNode:
@@ -159,7 +160,7 @@
exc_exits.append(exit)
for exit in exc_exits:
yield "(%s type isKindOf: %s) ifTrue: [" \
- % (exc_var, codef.format(exit.llexitcase))
+ % (exc_var, codef.format(dynamicType(exit.llexitcase)))
if exit.last_exception is not None:
yield "%s := %s type." \
% (codef.format(exit.last_exception), exc_var)
@@ -341,17 +342,10 @@
def dependencies(self):
# Important: Field initializers for the *runtime* type
- return [FieldInitializerNode(self.gen, self._dynamic_type(c.value))
+ return [FieldInitializerNode(self.gen, dynamicType(c.value))
for c in self.constants.iterkeys()] + \
[ClassNode(self.gen, self.CONSTANTS, class_vars=["Constants"])]
- def _dynamic_type(self, instance):
- # XXX move this to ootype?
- if isinstance(instance, _view):
- return instance._inst._TYPE
- else:
- return instance._TYPE
-
def render(self):
codef = CodeFormatter(self.gen)
# XXX use CodeFormatter throughout here
@@ -361,8 +355,8 @@
yield codef.format(message.with_args([]))
yield " Constants := Dictionary new."
for const, const_id in self.constants.iteritems():
- INST = self._dynamic_type(const.value)
- inst = const.value._downcast(INST)
+ INST = dynamicType(const.value)
+ inst = oodowncast(INST, const.value)
field_names = INST._allfields().keys()
field_values = [getattr(inst, f) for f in field_names]
new = Message("new").send_to(INST, [])
More information about the Pypy-commit
mailing list