[pypy-svn] r26665 - in pypy/dist/pypy: annotation jit/hintannotator rpython translator/goal translator/stackless
pedronis at codespeak.net
pedronis at codespeak.net
Tue May 2 14:46:55 CEST 2006
Author: pedronis
Date: Tue May 2 14:46:51 2006
New Revision: 26665
Modified:
pypy/dist/pypy/annotation/annrpython.py
pypy/dist/pypy/annotation/bookkeeper.py
pypy/dist/pypy/jit/hintannotator/bookkeeper.py
pypy/dist/pypy/rpython/rtyper.py
pypy/dist/pypy/translator/goal/query.py
pypy/dist/pypy/translator/stackless/transform.py
Log:
issue166: testing
converted RPythonAnnotator.binding interface to be like dict.get taking an optional default or raising KeyError if
the default is not specified.
Modified: pypy/dist/pypy/annotation/annrpython.py
==============================================================================
--- pypy/dist/pypy/annotation/annrpython.py (original)
+++ pypy/dist/pypy/annotation/annrpython.py Tue May 2 14:46:51 2006
@@ -15,6 +15,7 @@
class AnnotatorError(Exception):
pass
+FAIL = object()
class RPythonAnnotator:
"""Block annotator for RPython.
@@ -136,7 +137,7 @@
# recursively proceed until no more pending block is left
if complete_now:
self.complete()
- return self.binding(flowgraph.getreturnvar(), extquery=True)
+ return self.binding(flowgraph.getreturnvar(), None)
def gettype(self, variable):
"""Return the known type of a control flow graph variable,
@@ -217,14 +218,14 @@
# policy-dependent computation
self.bookkeeper.compute_at_fixpoint()
- def binding(self, arg, extquery=False):
+ def binding(self, arg, default=FAIL):
"Gives the SomeValue corresponding to the given Variable or Constant."
if isinstance(arg, Variable):
try:
return self.bindings[arg]
except KeyError:
- if extquery:
- return None
+ if default is not FAIL:
+ return default
else:
raise
elif isinstance(arg, Constant):
Modified: pypy/dist/pypy/annotation/bookkeeper.py
==============================================================================
--- pypy/dist/pypy/annotation/bookkeeper.py (original)
+++ pypy/dist/pypy/annotation/bookkeeper.py Tue May 2 14:46:51 2006
@@ -207,7 +207,7 @@
if op.opname in ('simple_call', 'call_args'):
yield op
# some blocks are partially annotated
- if binding(op.result, extquery=True) is None:
+ if binding(op.result, None) is None:
break # ignore the unannotated part
for call_op in call_sites():
@@ -235,9 +235,7 @@
s_callable = self.immutablevalue(adtmeth.func)
args_s = [SomePtr(adtmeth.ll_ptrtype)] + args_s
if isinstance(s_callable, SomePBC):
- s_result = binding(call_op.result, extquery=True)
- if s_result is None:
- s_result = s_ImpossibleValue
+ s_result = binding(call_op.result, s_ImpossibleValue)
self.consider_call_site_for_pbc(s_callable,
call_op.opname,
args_s, s_result)
@@ -577,9 +575,7 @@
fn, block, i = self.position_key
op = block.operations[i]
s_previous_result = self.annotator.binding(op.result,
- extquery=True)
- if s_previous_result is None:
- s_previous_result = s_ImpossibleValue
+ s_ImpossibleValue)
else:
if emulated is True:
whence = None
Modified: pypy/dist/pypy/jit/hintannotator/bookkeeper.py
==============================================================================
--- pypy/dist/pypy/jit/hintannotator/bookkeeper.py (original)
+++ pypy/dist/pypy/jit/hintannotator/bookkeeper.py Tue May 2 14:46:51 2006
@@ -97,9 +97,7 @@
def current_op_binding(self):
_, block, i = self.position_key
op = block.operations[i]
- hs_res = self.annotator.binding(op.result, extquery=True)
- if hs_res is None:
- hs_res = annmodel.s_ImpossibleValue
+ hs_res = self.annotator.binding(op.result, annmodel.s_ImpossibleValue)
return hs_res
def getvirtualcontainerdef(self, TYPE, constructor=None):
Modified: pypy/dist/pypy/rpython/rtyper.py
==============================================================================
--- pypy/dist/pypy/rpython/rtyper.py (original)
+++ pypy/dist/pypy/rpython/rtyper.py Tue May 2 14:46:51 2006
@@ -137,9 +137,7 @@
return result
def binding(self, var):
- s_obj = self.annotator.binding(var, True)
- if s_obj is None:
- s_obj = annmodel.SomeObject()
+ s_obj = self.annotator.binding(var, annmodel.SomeObject())
return s_obj
def bindingrepr(self, var):
Modified: pypy/dist/pypy/translator/goal/query.py
==============================================================================
--- pypy/dist/pypy/translator/goal/query.py (original)
+++ pypy/dist/pypy/translator/goal/query.py Tue May 2 14:46:51 2006
@@ -33,7 +33,7 @@
def visit(block):
if isinstance(block, flowmodel.Block):
for v in block.getvariables():
- s = annotator.binding(v, extquery=True)
+ s = annotator.binding(v, None)
if s and s.__class__ == annmodel.SomeObject and s.knowntype != type:
raise Found
for g in translator.graphs:
@@ -47,8 +47,8 @@
annotator = translator.annotator
for graph in translator.graphs:
et, ev = graph.exceptblock.inputargs
- s_et = annotator.binding(et, extquery=True)
- s_ev = annotator.binding(ev, extquery=True)
+ s_et = annotator.binding(et, None)
+ s_ev = annotator.binding(ev, None)
if s_et:
if s_et.knowntype == type:
if s_et.__class__ == annmodel.SomeObject:
Modified: pypy/dist/pypy/translator/stackless/transform.py
==============================================================================
--- pypy/dist/pypy/translator/stackless/transform.py (original)
+++ pypy/dist/pypy/translator/stackless/transform.py Tue May 2 14:46:51 2006
@@ -349,7 +349,7 @@
# about annotations :(
ann = self.translator.annotator
for f, t in zip(link.args, link.target.inputargs):
- nb = ann.binding(f, True)
+ nb = ann.binding(f, None)
if nb is not None:
ann.setbinding(t, nb)
block.exitswitch = model.c_last_exception
More information about the Pypy-commit
mailing list