[pypy-svn] r7307 - pypy/trunk/src/pypy/annotation

arigo at codespeak.net arigo at codespeak.net
Wed Nov 17 10:31:08 CET 2004


Author: arigo
Date: Wed Nov 17 10:31:08 2004
New Revision: 7307

Modified:
   pypy/trunk/src/pypy/annotation/builtin.py
   pypy/trunk/src/pypy/annotation/unaryop.py
Log:
- calling prebuilt constant instances with a custom __call__ method
- getattr() and type() built-ins


Modified: pypy/trunk/src/pypy/annotation/builtin.py
==============================================================================
--- pypy/trunk/src/pypy/annotation/builtin.py	(original)
+++ pypy/trunk/src/pypy/annotation/builtin.py	Wed Nov 17 10:31:08 2004
@@ -39,6 +39,18 @@
             return immutablevalue(True)
     return SomeBool()
 
+def builtin_getattr(s_obj, s_attr):
+    if not s_attr.is_constant() or not isinstance(s_attr.const, str):
+        raise Exception, 'getattr(%r, %r) is not RPythonic enough' % (
+            s_obj, s_attr)
+    return s_obj.getattr(s_attr)
+
+def builtin_type(s_obj, *moreargs):
+    if moreargs:
+        raise Exception, 'type() called with more than one argument'
+    #...
+    return SomeObject(knowntype=type)
+
 
 # collect all functions
 import __builtin__

Modified: pypy/trunk/src/pypy/annotation/unaryop.py
==============================================================================
--- pypy/trunk/src/pypy/annotation/unaryop.py	(original)
+++ pypy/trunk/src/pypy/annotation/unaryop.py	Wed Nov 17 10:31:08 2004
@@ -181,7 +181,9 @@
             results.append(factory.pycall(func, s_self, *args))
         return unionof(*results)
 
+
 class __extend__(SomePrebuiltConstant):
+
     def getattr(pbc, s_attr):
         assert s_attr.is_constant()
         bookkeeper = getbookkeeper()
@@ -195,4 +197,7 @@
 
     def setattr(pbc, s_attr, s_value):
         raise Exception, "oops!"
-    
+
+    def simple_call(pbc, *args):
+        s_meth = pbc.getattr(immutablevalue("__call__"))
+        return s_meth.simple_call(*args)



More information about the Pypy-commit mailing list