[pypy-svn] r26424 - pypy/dist/pypy/translator/squeak
nik at codespeak.net
nik at codespeak.net
Thu Apr 27 11:00:31 CEST 2006
Author: nik
Date: Thu Apr 27 11:00:25 2006
New Revision: 26424
Modified:
pypy/dist/pypy/translator/squeak/codeformatter.py
pypy/dist/pypy/translator/squeak/gensqueak.py
pypy/dist/pypy/translator/squeak/node.py
Log:
added Record support to gensqueak with surprisingly little code.
Modified: pypy/dist/pypy/translator/squeak/codeformatter.py
==============================================================================
--- pypy/dist/pypy/translator/squeak/codeformatter.py (original)
+++ pypy/dist/pypy/translator/squeak/codeformatter.py Thu Apr 27 11:00:25 2006
@@ -96,7 +96,7 @@
def name_constant(self, value):
if isinstance(value, bool):
return str(value).lower()
- elif isinstance(value, ootype.Instance):
+ elif isinstance(value, (ootype.Instance, ootype.Record)):
return self.format_Instance(value)
elif value is None:
return "nil"
Modified: pypy/dist/pypy/translator/squeak/gensqueak.py
==============================================================================
--- pypy/dist/pypy/translator/squeak/gensqueak.py (original)
+++ pypy/dist/pypy/translator/squeak/gensqueak.py Thu Apr 27 11:00:25 2006
@@ -1,6 +1,7 @@
from pypy.translator.gensupp import NameManager
from pypy.translator.squeak.node import FunctionNode, ClassNode, SetupNode
from pypy.translator.squeak.node import MethodNode, SetterNode, GetterNode
+from pypy.rpython.ootypesystem.ootype import Record
try:
set
except NameError:
@@ -71,8 +72,11 @@
return squeak_method_name
def unique_class_name(self, INSTANCE):
- self.schedule_node(ClassNode(self, INSTANCE))
- class_name = INSTANCE._name.split(".")[-1]
+ class_node = self.schedule_node(ClassNode(self, INSTANCE))
+ if isinstance(INSTANCE, Record): # XXX quick hack
+ class_name = "Record"
+ else:
+ class_name = INSTANCE._name.split(".")[-1]
squeak_class_name = self.unique_name(INSTANCE, class_name)
return "Py%s" % squeak_class_name
Modified: pypy/dist/pypy/translator/squeak/node.py
==============================================================================
--- pypy/dist/pypy/translator/squeak/node.py (original)
+++ pypy/dist/pypy/translator/squeak/node.py Thu Apr 27 11:00:25 2006
@@ -4,7 +4,7 @@
from pypy.translator.squeak.opformatter import OpFormatter
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 Instance, Class, Record, ROOT, _view
from pypy.rpython.ootypesystem.ootype import dynamicType, oodowncast
class CodeNode:
@@ -31,11 +31,15 @@
self.class_vars = class_vars
self.host_base = host_base
self.hash_key = INSTANCE
+ # We can treat Instances and Records uniformly, this looks
+ # slightly hackish but just works.
+ if isinstance(INSTANCE, Record):
+ self.host_base = "Object"
def dependencies(self):
deps = []
- if self.INSTANCE._superclass is not None \
- and self.host_base is None: # not root
+ if self.host_base is None \
+ and self.INSTANCE._superclass is not None: # not root or record
deps.append(ClassNode(self.gen, self.INSTANCE._superclass))
return deps
More information about the Pypy-commit
mailing list