[pypy-svn] r7454 - in pypy/trunk/src/pypy: annotation translator

arigo at codespeak.net arigo at codespeak.net
Fri Nov 19 17:01:29 CET 2004


Author: arigo
Date: Fri Nov 19 17:01:29 2004
New Revision: 7454

Modified:
   pypy/trunk/src/pypy/annotation/factory.py
   pypy/trunk/src/pypy/translator/genc.py
Log:
translate a bit more of the needed attributes of prebuilt constants

Modified: pypy/trunk/src/pypy/annotation/factory.py
==============================================================================
--- pypy/trunk/src/pypy/annotation/factory.py	(original)
+++ pypy/trunk/src/pypy/annotation/factory.py	Fri Nov 19 17:01:29 2004
@@ -298,4 +298,10 @@
             for factory in self.getallfactories():
                 bookkeeper.annotator.reflowfromposition(factory.position_key)
 
+    def about_attribute(self, name):
+        for cdef in self.getmro():
+            if name in cdef.attrs:
+                return cdef.attrs[name]
+        return SomeImpossibleValue()
+
 from pypy.annotation.builtin  import BUILTIN_ANALYZERS

Modified: pypy/trunk/src/pypy/translator/genc.py
==============================================================================
--- pypy/trunk/src/pypy/translator/genc.py	(original)
+++ pypy/trunk/src/pypy/translator/genc.py	Fri Nov 19 17:01:29 2004
@@ -9,6 +9,7 @@
 from pypy.objspace.flow.model import traverse, uniqueitems, checkgraph
 from pypy.translator.simplify import remove_direct_loops
 from pypy.interpreter.pycode import CO_VARARGS
+from pypy.annotation import model as annmodel
 from types import FunctionType
 
 from pypy.objspace.std.restricted_int import r_int, r_uint
@@ -186,7 +187,13 @@
         ann = self.translator.annotator
         if ann is None:
             return "good luck" # True
-        return attr in ann.getpbcattrs(pbc)
+        if attr in ann.getpbcattrs(pbc):
+            return True
+        classdef = ann.getuserclasses().get(pbc.__class__)
+        if (classdef and
+            classdef.about_attribute(attr) != annmodel.SomeImpossibleValue()):
+            return True
+        return False
 
     def nameof_instance(self, instance):
         name = self.uniquename('ginst_' + instance.__class__.__name__)



More information about the Pypy-commit mailing list