[pypy-svn] r73263 - pypy/branch/cpython-extension/pypy/annotation

afa at codespeak.net afa at codespeak.net
Fri Apr 2 00:50:13 CEST 2010


Author: afa
Date: Fri Apr  2 00:50:12 2010
New Revision: 73263

Modified:
   pypy/branch/cpython-extension/pypy/annotation/description.py
Log:
This is also needed for specialise.memo() when there is a function in the arguments


Modified: pypy/branch/cpython-extension/pypy/annotation/description.py
==============================================================================
--- pypy/branch/cpython-extension/pypy/annotation/description.py	(original)
+++ pypy/branch/cpython-extension/pypy/annotation/description.py	Fri Apr  2 00:50:12 2010
@@ -169,6 +169,8 @@
 class NoStandardGraph(Exception):
     """The function doesn't have a single standard non-specialized graph."""
 
+NODEFAULT = object()
+
 class FunctionDesc(Desc):
     knowntype = types.FunctionType
     overridden = False
@@ -191,6 +193,7 @@
         #                                 or => s_result (overridden/memo cases)
         self.specializer = specializer
         self._cache = {}     # convenience for the specializer
+        self.memofield = {}
 
     def buildgraph(self, alt_name=None, builder=None):
         translator = self.bookkeeper.annotator.translator
@@ -355,7 +358,27 @@
 
             return s_sigs
 
-NODEFAULT = object()
+    def create_new_attribute(self, name, value):
+        assert name.startswith('$memofield_')
+        self.memofield[name] = value
+
+    def read_attribute(self, name, default=NODEFAULT):
+        assert name.startswith('$memofield_')
+        try:
+            return self.memofield[name]
+        except:
+            if default is not NODEFAULT:
+                return default
+            else:
+                raise AttributeError
+
+    def s_read_attribute(self, attr):
+        from pypy.annotation.model import s_ImpossibleValue
+        return s_ImpossibleValue
+
+    def mergeattrfamilies(self, others, attrname):
+        # no attr to merge
+        return False
 
 class ClassDesc(Desc):
     knowntype = type



More information about the Pypy-commit mailing list