[pypy-svn] r23708 - in pypy/dist/pypy: annotation rpython rpython/test
jgilbert at codespeak.net
jgilbert at codespeak.net
Mon Feb 27 22:23:08 CET 2006
Author: jgilbert
Date: Mon Feb 27 22:22:56 2006
New Revision: 23708
Added:
pypy/dist/pypy/rpython/extregistry.py
Modified:
pypy/dist/pypy/annotation/bookkeeper.py
pypy/dist/pypy/rpython/test/test_extregistry.py
Log:
No longer skip test_extregistry.
Implemented extregistry (enough to pass existence test).
Added two cases to bookkeeper that are currently unused.
Modified: pypy/dist/pypy/annotation/bookkeeper.py
==============================================================================
--- pypy/dist/pypy/annotation/bookkeeper.py (original)
+++ pypy/dist/pypy/annotation/bookkeeper.py Mon Feb 27 22:22:56 2006
@@ -23,6 +23,7 @@
from pypy.rpython.lltypesystem import lltype, llmemory
from pypy.rpython.ootypesystem import ootype
from pypy.rpython.memory import lladdress
+from pypy.rpython.extregistry import EXT_REGISTRY_BY_VALUE, EXT_REGISTRY_BY_TYPE
class Stats:
@@ -358,8 +359,12 @@
elif ishashable(x) and x in BUILTIN_ANALYZERS:
_module = getattr(x,"__module__","unknown")
result = SomeBuiltin(BUILTIN_ANALYZERS[x], methodname="%s.%s" % (_module, x.__name__))
+ elif ishashable(x) and x in EXT_REGISTRY_BY_VALUE:
+ result = EXT_REGISTRY_BY_VALUE[x].get_annotation(x)
elif hasattr(x, "compute_result_annotation"):
result = SomeBuiltin(x.compute_result_annotation, methodname=x.__name__)
+ elif tp in EXT_REGISTRY_BY_TYPE:
+ result = EXT_REGISTRY_BY_TYPE[tp].get_annotation(x)
elif hasattr(tp, "compute_annotation"):
result = tp.compute_annotation()
elif tp in DEFINED_SOMEOBJECTS:
Added: pypy/dist/pypy/rpython/extregistry.py
==============================================================================
--- (empty file)
+++ pypy/dist/pypy/rpython/extregistry.py Mon Feb 27 22:22:56 2006
@@ -0,0 +1,25 @@
+class ExtRegistryFunc:
+ def __init__(self, compute_result_annotation):
+ self.compute_result_annotation = compute_result_annotation
+
+ def get_annotation(self, func):
+ from pypy.annotation import model as annmodel
+ return annmodel.SomeBuiltin(self.compute_result_annotation, methodname=func.__name__)
+
+EXT_REGISTRY_BY_VALUE = {}
+EXT_REGISTRY_BY_TYPE = {}
+
+def register_func(func, compute_result_annotation):
+ from pypy.annotation import model as annmodel
+ if isinstance(compute_result_annotation, annmodel.SomeObject):
+ s_result = compute_result_annotation
+ def annotation(*args):
+ return s_result
+
+ compute_result_annotation = annotation
+
+ EXT_REGISTRY_BY_VALUE[func] = ExtRegistryFunc(compute_result_annotation)
+
+def register_type():
+ pass
+
Modified: pypy/dist/pypy/rpython/test/test_extregistry.py
==============================================================================
--- pypy/dist/pypy/rpython/test/test_extregistry.py (original)
+++ pypy/dist/pypy/rpython/test/test_extregistry.py Mon Feb 27 22:22:56 2006
@@ -1,6 +1,6 @@
import py
-py.test.skip('In progress at PyCon')
+##py.test.skip('In progress at PyCon')
from pypy.rpython.extregistry import EXT_REGISTRY_BY_VALUE, EXT_REGISTRY_BY_TYPE
from pypy.rpython.extregistry import register_func, register_type
More information about the Pypy-commit
mailing list