[pypy-svn] r37379 - in pypy/dist/pypy: rpython/ootypesystem translator/cli

antocuni at codespeak.net antocuni at codespeak.net
Fri Jan 26 12:47:44 CET 2007


Author: antocuni
Date: Fri Jan 26 12:47:43 2007
New Revision: 37379

Modified:
   pypy/dist/pypy/rpython/ootypesystem/ootype.py
   pypy/dist/pypy/translator/cli/database.py
   pypy/dist/pypy/translator/cli/dotnet.py
   pypy/dist/pypy/translator/cli/query.py
Log:
- Handle correctly circular dependencies when inspecting System.Type

- Assert that box() can't throw any exception

- Mangle also square brackets when constructing the Record name.



Modified: pypy/dist/pypy/rpython/ootypesystem/ootype.py
==============================================================================
--- pypy/dist/pypy/rpython/ootypesystem/ootype.py	(original)
+++ pypy/dist/pypy/rpython/ootypesystem/ootype.py	Fri Jan 26 12:47:43 2007
@@ -51,9 +51,8 @@
         if _is_root:
             self._superclass = None
         else:
-            assert isinstance(superclass, Instance)
-            self._superclass = superclass
-            self._superclass._add_subclass(self)
+            if superclass is not None:
+                self._set_superclass(superclass)
 
         self._methods = frozendict()
         self._fields = frozendict()
@@ -85,6 +84,11 @@
     def __str__(self):
         return '%s(%s)' % (self.__class__.__name__, self._name)
 
+    def _set_superclass(self, superclass):
+        assert isinstance(superclass, Instance)
+        self._superclass = superclass
+        self._superclass._add_subclass(self)
+
     def _add_subclass(self, INSTANCE):
         assert isinstance(INSTANCE, Instance)
         self._subclasses.append(INSTANCE)

Modified: pypy/dist/pypy/translator/cli/database.py
==============================================================================
--- pypy/dist/pypy/translator/cli/database.py	(original)
+++ pypy/dist/pypy/translator/cli/database.py	Fri Jan 26 12:47:43 2007
@@ -48,7 +48,7 @@
         return self.unique()
 
     def _default_record_name(self, RECORD):
-        trans = string.maketrans('<>(), :', '_______')
+        trans = string.maketrans('[]<>(), :', '_________')
         name = ['Record']
         # XXX: refactor this: we need a proper way to ensure unique names
         for f_name, (FIELD_TYPE, f_default) in RECORD._fields.iteritems():

Modified: pypy/dist/pypy/translator/cli/dotnet.py
==============================================================================
--- pypy/dist/pypy/translator/cli/dotnet.py	(original)
+++ pypy/dist/pypy/translator/cli/dotnet.py	Fri Jan 26 12:47:43 2007
@@ -321,6 +321,7 @@
     def specialize_call(self, hop):
         v_obj, = hop.inputargs(*hop.args_r)
 
+        hop.exception_cannot_occur()
         TYPE = v_obj.concretetype
         if (TYPE is ootype.String or isinstance(TYPE, NativeInstance)):
             return hop.genop('ooupcast', [v_obj], hop.r_result.lowleveltype)

Modified: pypy/dist/pypy/translator/cli/query.py
==============================================================================
--- pypy/dist/pypy/translator/cli/query.py	(original)
+++ pypy/dist/pypy/translator/cli/query.py	Fri Jan 26 12:47:43 2007
@@ -118,8 +118,14 @@
         namespace, name = self.FullName.rsplit('.', 1)
 
         # construct OOTYPE and CliClass
-        load_class_maybe(self.BaseType)
-        BASETYPE = ClassCache[self.BaseType]._INSTANCE
+        if self.FullName == 'System.Type':
+            # we need to special case System.Type because it contains
+            # circular dependencies, since its superclasses have got
+            # methods which take System.Type as parameters
+            BASETYPE = None
+        else:
+            load_class_maybe(self.BaseType)
+            BASETYPE = ClassCache[self.BaseType]._INSTANCE
         TYPE = NativeInstance('[mscorlib]', namespace, name, BASETYPE, {}, {})
         TYPE._isArray = self.IsArray
         if self.IsArray:
@@ -129,6 +135,11 @@
         OOTypeCache[self.OOType] = TYPE
         ClassCache[self.FullName] = Class
 
+        if BASETYPE is None:
+            load_class_maybe(self.BaseType)
+            BASETYPE = ClassCache[self.BaseType]._INSTANCE
+            TYPE._set_superclass(BASETYPE)
+
         # render dependencies
         for name in self.Depend:
             load_class_maybe(name)



More information about the Pypy-commit mailing list