[pypy-commit] pypy var-in-Some: use annotated values in consider_op()
rlamy
noreply at buildbot.pypy.org
Sat May 17 01:04:46 CEST 2014
Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: var-in-Some
Changeset: r71546:bf8ea3ebe67a
Date: 2014-05-16 20:01 +0100
http://bitbucket.org/pypy/pypy/changeset/bf8ea3ebe67a/
Log: use annotated values in consider_op()
diff --git a/rpython/annotator/annrpython.py b/rpython/annotator/annrpython.py
--- a/rpython/annotator/annrpython.py
+++ b/rpython/annotator/annrpython.py
@@ -10,6 +10,7 @@
c_last_exception, checkgraph)
from rpython.translator import simplify, transform
from rpython.annotator import model as annmodel, signature
+from rpython.annotator.value import AnnotatedValue
from rpython.annotator.bookkeeper import Bookkeeper
import py
@@ -240,6 +241,9 @@
else:
raise TypeError('Variable or Constant expected, got %r' % (arg,))
+ def annvalue(self, arg):
+ return AnnotatedValue(arg, self.binding(arg))
+
def typeannotation(self, t):
return signature.annotation(t, self.bookkeeper)
@@ -577,11 +581,10 @@
self.links_followed[link] = True
self.addpendingblock(graph, link.target, cells)
-
#___ creating the annotations based on operations ______
def consider_op(self, op):
- argcells = [self.binding(a) for a in op.args]
+ argcells = [self.annvalue(a) for a in op.args]
# let's be careful about avoiding propagated SomeImpossibleValues
# to enter an op; the latter can result in violations of the
@@ -590,7 +593,7 @@
# is_(SomeInstance(not None), None) -> SomeBool(const=False) ...
# boom -- in the assert of setbinding()
for arg in argcells:
- if isinstance(arg, annmodel.SomeImpossibleValue):
+ if isinstance(arg.ann, annmodel.SomeImpossibleValue):
raise BlockedInference(self, op, -1)
resultcell = op.consider(self, *argcells)
if resultcell is None:
diff --git a/rpython/flowspace/operation.py b/rpython/flowspace/operation.py
--- a/rpython/flowspace/operation.py
+++ b/rpython/flowspace/operation.py
@@ -90,10 +90,7 @@
return None
def consider(self, annotator, *argcells):
- consider_meth = getattr(annotator, 'consider_op_' + self.opname, None)
- if not consider_meth:
- raise Exception("unknown op: %r" % op)
- return consider_meth(*argcells)
+ raise NotImplementedError
class PureOperation(HLOperation):
pure = True
@@ -141,15 +138,17 @@
dispatch = 1
def consider(self, annotator, arg, *other_args):
- impl = getattr(arg, self.opname)
- return impl(*other_args)
+ impl = getattr(arg.ann, self.opname)
+ s_others = [x.ann for x in other_args]
+ return impl(*s_others)
class DoubleDispatchMixin(object):
dispatch = 2
def consider(self, annotator, arg1, arg2, *other_args):
- impl = getattr(pair(arg1, arg2), self.opname)
- return impl(*other_args)
+ impl = getattr(pair(arg1.ann, arg2.ann), self.opname)
+ s_others = [arg.ann for arg in other_args]
+ return impl(*s_others)
def add_operator(name, arity, dispatch=None, pyfunc=None, pure=False, ovf=False):
@@ -374,7 +373,7 @@
# XXX "contains" clash with SomeObject method
def consider(self, annotator, seq, elem):
- return seq.op_contains(elem)
+ return seq.ann.op_contains(elem.ann)
class NewDict(HLOperation):
@@ -391,7 +390,7 @@
canraise = []
def consider(self, annotator, *args):
- return SomeTuple(items=args)
+ return SomeTuple(items=[arg.ann for arg in args])
class NewList(HLOperation):
@@ -399,7 +398,7 @@
canraise = []
def consider(self, annotator, *args):
- return annotator.bookkeeper.newlist(*args)
+ return annotator.bookkeeper.newlist(*[arg.ann for arg in args])
class Pow(PureOperation):
More information about the pypy-commit
mailing list