[pypy-svn] r9572 - in pypy/dist/pypy/translator: . test
pedronis at codespeak.net
pedronis at codespeak.net
Tue Mar 1 22:48:13 CET 2005
Author: pedronis
Date: Tue Mar 1 22:48:13 2005
New Revision: 9572
Modified:
pypy/dist/pypy/translator/annrpython.py
pypy/dist/pypy/translator/test/snippet.py
pypy/dist/pypy/translator/test/test_annrpython.py
Log:
failing test that exemplifies how translate_pypy0 right now after a while get stuck.
currentdef() cares about freshness (checks revision), so contains usages (e.g. inst setattr one)
cannot ignore revision otherwise fresher SomeInstances will not be propagated to where currentdef
because of a stale SomeInstance blocked inference.
Modified: pypy/dist/pypy/translator/annrpython.py
==============================================================================
--- pypy/dist/pypy/translator/annrpython.py (original)
+++ pypy/dist/pypy/translator/annrpython.py Tue Mar 1 22:48:13 2005
@@ -82,7 +82,7 @@
self.addpendingblock(func, flowgraph.startblock, inputcells)
# recursively proceed until no more pending block is left
self.complete()
- return self.binding(flowgraph.getreturnvar())
+ return self.binding(flowgraph.getreturnvar(), extquery=True)
def gettype(self, variable):
"""Return the known type of a control flow graph variable,
@@ -155,10 +155,16 @@
print "++-" * 20
- def binding(self, arg):
+ def binding(self, arg, extquery=False):
"Gives the SomeValue corresponding to the given Variable or Constant."
if isinstance(arg, Variable):
- return self.bindings[arg]
+ try:
+ return self.bindings[arg]
+ except KeyError:
+ if extquery:
+ return None
+ else:
+ raise
elif isinstance(arg, UndefinedConstant): # undefined local variables
return annmodel.SomeImpossibleValue()
elif isinstance(arg, Constant):
Modified: pypy/dist/pypy/translator/test/snippet.py
==============================================================================
--- pypy/dist/pypy/translator/test/snippet.py (original)
+++ pypy/dist/pypy/translator/test/snippet.py Tue Mar 1 22:48:13 2005
@@ -892,3 +892,24 @@
def one_thing2():
return thing2
+
+# propagation of fresh instances through attributes
+
+class Stk:
+ def __init__(self):
+ self.itms = []
+
+ def push(self, v):
+ self.itms.append(v)
+
+class EC:
+
+ def __init__(self):
+ self.stk = Stk()
+
+ def enter(self, f):
+ self.stk.push(f)
+
+def propagation_of_fresh_instances_through_attrs(x):
+ e = EC()
+ e.enter(x)
Modified: pypy/dist/pypy/translator/test/test_annrpython.py
==============================================================================
--- pypy/dist/pypy/translator/test/test_annrpython.py (original)
+++ pypy/dist/pypy/translator/test/test_annrpython.py Tue Mar 1 22:48:13 2005
@@ -526,6 +526,11 @@
assert isinstance(a.binding(g_flowgraph.getreturnvar()),
annmodel.SomeString)
+ def test_propagation_of_fresh_instances_through_attrs(self):
+ a = RPythonAnnotator()
+ s = a.build_types(snippet.propagation_of_fresh_instances_through_attrs, [int])
+ assert s is not None
+
def g(n):
return [0,1,2,n]
More information about the Pypy-commit
mailing list