[pypy-svn] r36514 - in pypy/dist/pypy/annotation: . test
fijal at codespeak.net
fijal at codespeak.net
Thu Jan 11 17:22:27 CET 2007
Author: fijal
Date: Thu Jan 11 17:22:23 2007
New Revision: 36514
Modified:
pypy/dist/pypy/annotation/binaryop.py
pypy/dist/pypy/annotation/test/test_annrpython.py
Log:
Add a possibility to select a callback
Modified: pypy/dist/pypy/annotation/binaryop.py
==============================================================================
--- pypy/dist/pypy/annotation/binaryop.py (original)
+++ pypy/dist/pypy/annotation/binaryop.py Thu Jan 11 17:22:23 2007
@@ -19,6 +19,7 @@
from pypy.annotation.model import read_can_only_throw
from pypy.annotation.model import add_knowntypedata, merge_knowntypedata
from pypy.annotation.model import lltype_to_annotation
+from pypy.annotation.model import SomeGenericCallable
from pypy.annotation.bookkeeper import getbookkeeper
from pypy.objspace.flow.model import Variable
from pypy.annotation.listdef import ListDef
@@ -682,6 +683,12 @@
s.const = False # no common desc in the two sets
return s
+class __extend__(pairtype(SomeGenericCallable, SomePBC)):
+ def union((gencall, pbc)):
+ unique_key = (gencall, pbc.const)
+ getbookkeeper().emulate_pbc_call(unique_key, pbc, gencall.args_s)
+ return gencall
+
class __extend__(pairtype(SomeImpossibleValue, SomeObject)):
def union((imp1, obj2)):
return obj2
Modified: pypy/dist/pypy/annotation/test/test_annrpython.py
==============================================================================
--- pypy/dist/pypy/annotation/test/test_annrpython.py (original)
+++ pypy/dist/pypy/annotation/test/test_annrpython.py Thu Jan 11 17:22:23 2007
@@ -2464,12 +2464,12 @@
assert not hasattr(s, 'const')
def test_some_generic_function_callback(self):
- py.test.skip("Not implemented")
def g(a):
pass
g._known_annotation_ = annmodel.SomeGenericCallable(
- args=[annmodel.SomeGenericCallable(args=[SomeInteger()],
- retval=SomeInteger())])
+ args=[annmodel.SomeGenericCallable(args=[annmodel.SomeInteger()],
+ retval=annmodel.SomeInteger())],
+ retval=annmodel.SomeInteger())
def fun2(x):
return x
@@ -2478,8 +2478,17 @@
return g(fun2)
a = self.RPythonAnnotator(policy=policy.AnnotatorPolicy())
- s = a.build_types(func, [])
- # assert that annotator knows about fun2 and is flown well
+ s = a.build_types(fun, [])
+ assert isinstance(s, annmodel.SomeInteger)
+ graphs = a.annotated.values()
+ found = False
+ for graph in graphs:
+ if graph.name == "fun2":
+ found = True
+ inputcells = graph.startblock.inputargs
+ assert len(inputcells) == 1
+ assert isinstance(a.bindings[inputcells[0]], annmodel.SomeInteger)
+ assert found
def g(n):
return [0,1,2,n]
More information about the Pypy-commit
mailing list