[pypy-svn] r30214 - pypy/dist/pypy/translator/cli

antocuni at codespeak.net antocuni at codespeak.net
Wed Jul 19 11:43:35 CEST 2006


Author: antocuni
Date: Wed Jul 19 11:43:34 2006
New Revision: 30214

Modified:
   pypy/dist/pypy/translator/cli/database.py
Log:
Make sure the type on the stack are casted correctly.



Modified: pypy/dist/pypy/translator/cli/database.py
==============================================================================
--- pypy/dist/pypy/translator/cli/database.py	(original)
+++ pypy/dist/pypy/translator/cli/database.py	Wed Jul 19 11:43:34 2006
@@ -147,7 +147,7 @@
             self.consts[value] = const
             self.pending_node(const)
 
-        return '%s.%s::%s' % (CONST_NAMESPACE, CONST_CLASS, const.name)
+        return '%s.%s::%s' % (CONST_NAMESPACE, CONST_CLASS, const.name), const.get_type()
 
     def record_delegate(self, TYPE):
         try:
@@ -253,9 +253,10 @@
         else:
             assert TYPE not in cls.PRIMITIVE_TYPES
             cts = CTS(db)
-            name = db.record_const(value)
-            cts_type = cts.lltype_to_cts(TYPE)
-            ilasm.opcode('ldsfld %s %s' % (cts_type, name))
+            name, cts_static_type = db.record_const(value)
+            ilasm.opcode('ldsfld %s %s' % (cts_static_type, name))
+            if cts_static_type != cts.lltype_to_cts(TYPE):
+                ilasm.opcode('castclass', cts.lltype_to_cts(TYPE, include_class=False))
     load = classmethod(load)
 
     def __hash__(self):
@@ -572,6 +573,8 @@
             return
 
         INSTANCE = self.value._TYPE
+        if INSTANCE is not self.static_type:
+            ilasm.opcode('castclass', self.cts.lltype_to_cts(INSTANCE, include_class=False))
         while INSTANCE is not None:
             for name, (TYPE, default) in INSTANCE._fields.iteritems():
                 if TYPE is ootype.Void:



More information about the Pypy-commit mailing list