Author: Ronan Lamy <[email protected]>
Branch: var-in-Some
Changeset: r73787:0660898bd1b3
Date: 2014-10-04 23:32 +0100
http://bitbucket.org/pypy/pypy/changeset/0660898bd1b3/
Log: Don't put AnnotatedValues in ._is_type_of
diff --git a/rpython/annotator/annrpython.py b/rpython/annotator/annrpython.py
--- a/rpython/annotator/annrpython.py
+++ b/rpython/annotator/annrpython.py
@@ -243,9 +243,6 @@
def annvalue(self, arg):
if isinstance(arg, Variable):
- annvalue = arg.binding
- if arg.binding is None:
- arg.binding = AnnotatedValue(arg, None)
return arg.binding
else:
return AnnotatedValue(arg,
self.bookkeeper.immutablevalue(arg.value))
@@ -508,13 +505,13 @@
last_exception_object = annmodel.SomeType()
if isinstance(last_exception_var, Constant):
last_exception_object.const = last_exception_var.value
+ last_exception_object.is_type_of = [last_exc_value_var]
- last_exception_object.is_type_of = [
- self.annvalue(last_exc_value_var)]
if isinstance(last_exception_var, Variable):
self.setbinding(last_exception_var, last_exception_object)
if isinstance(last_exc_value_var, Variable):
self.setbinding(last_exc_value_var, last_exc_value_object)
+
last_exception_object = annmodel.SomeType()
if isinstance(last_exception_var, Constant):
last_exception_object.const = last_exception_var.value
@@ -536,7 +533,7 @@
elif a == last_exc_value_var:
assert in_except_block
cells.append(last_exc_value_object)
- last_exc_value_vars.append(self.annvalue(v))
+ last_exc_value_vars.append(v)
else:
cell = self.binding(a)
if (link.exitcase, a) in knowntypedata:
@@ -549,8 +546,8 @@
if hasattr(cell,'is_type_of'):
renamed_is_type_of = []
for v in cell.is_type_of:
- new_vs = renaming.get(v.value, [])
- renamed_is_type_of += map(self.annvalue, new_vs)
+ new_vs = renaming.get(v,[])
+ renamed_is_type_of += new_vs
assert cell.knowntype is type
newcell = annmodel.SomeType()
if cell.is_constant():
diff --git a/rpython/annotator/binaryop.py b/rpython/annotator/binaryop.py
--- a/rpython/annotator/binaryop.py
+++ b/rpython/annotator/binaryop.py
@@ -42,7 +42,7 @@
if hasattr(tgt_obj.ann, 'is_type_of') and src_obj.ann.is_constant():
add_knowntypedata(
knowntypedata, True,
- [inst.value for inst in tgt_obj.ann.is_type_of],
+ tgt_obj.ann.is_type_of,
getbookkeeper().valueoftype(src_obj.ann.const))
add_knowntypedata(knowntypedata, True, [tgt_obj.value], src_obj.ann)
s_nonnone = tgt_obj.ann
diff --git a/rpython/annotator/test/test_annrpython.py
b/rpython/annotator/test/test_annrpython.py
--- a/rpython/annotator/test/test_annrpython.py
+++ b/rpython/annotator/test/test_annrpython.py
@@ -1402,7 +1402,7 @@
et, ev = fg.exceptblock.inputargs
t = annmodel.SomeType()
t.const = KeyError
- t.is_type_of = [a.annvalue(ev)]
+ t.is_type_of = [ev]
assert a.binding(et) == t
assert isinstance(a.binding(ev), annmodel.SomeInstance) and
a.binding(ev).classdef == a.bookkeeper.getuniqueclassdef(KeyError)
@@ -1417,7 +1417,7 @@
fg = graphof(a, f)
et, ev = fg.exceptblock.inputargs
t = annmodel.SomeType()
- t.is_type_of = [a.annvalue(ev)]
+ t.is_type_of = [ev]
t.const = KeyError # IndexError ignored because 'dic' is a dict
assert a.binding(et) == t
assert isinstance(a.binding(ev), annmodel.SomeInstance) and
a.binding(ev).classdef == a.bookkeeper.getuniqueclassdef(KeyError)
@@ -1452,7 +1452,7 @@
fg = graphof(a, f)
et, ev = fg.exceptblock.inputargs
t = annmodel.SomeType()
- t.is_type_of = [a.annvalue(ev)]
+ t.is_type_of = [ev]
assert a.binding(et) == t
assert isinstance(a.binding(ev), annmodel.SomeInstance) and
a.binding(ev).classdef == a.bookkeeper.getuniqueclassdef(Exception)
@@ -1474,7 +1474,7 @@
fg = graphof(a, f)
et, ev = fg.exceptblock.inputargs
t = annmodel.SomeType()
- t.is_type_of = [a.annvalue(ev)]
+ t.is_type_of = [ev]
assert a.binding(et) == t
assert isinstance(a.binding(ev), annmodel.SomeInstance) and
a.binding(ev).classdef == a.bookkeeper.getuniqueclassdef(Exception)
diff --git a/rpython/annotator/unaryop.py b/rpython/annotator/unaryop.py
--- a/rpython/annotator/unaryop.py
+++ b/rpython/annotator/unaryop.py
@@ -24,7 +24,7 @@
@op.type.register(SomeObject)
def type_SomeObject(arg):
r = SomeType()
- r.is_type_of = [arg]
+ r.is_type_of = [arg.value]
return r
@op.bool.register(SomeObject)
@@ -56,9 +56,10 @@
def issubtype(self, s_cls):
if hasattr(self, 'is_type_of'):
- instances = self.is_type_of
- return builtin.builtin_isinstance(instances[0].ann, s_cls,
- [x.value for x in instances])
+ vars = self.is_type_of
+ annotator = getbookkeeper().annotator
+ return builtin.builtin_isinstance(annotator.binding(vars[0]),
+ s_cls, vars)
if self.is_constant() and s_cls.is_constant():
return immutablevalue(issubclass(self.const, s_cls.const))
return s_Bool
diff --git a/rpython/translator/goal/query.py b/rpython/translator/goal/query.py
--- a/rpython/translator/goal/query.py
+++ b/rpython/translator/goal/query.py
@@ -48,12 +48,11 @@
s_ev = annotator.binding(ev, None)
if s_et:
if s_et.knowntype == type:
- if isinstance(s_et, annmodel.SomeType):
- if (hasattr(s_et, 'is_type_of') and
- s_et.is_type_of == [annotator.annvalue(ev)]):
+ if s_et.__class__ == annmodel.SomeType:
+ if hasattr(s_et, 'is_type_of') and s_et.is_type_of ==
[ev]:
continue
else:
- if isinstance(s_et, annmodel.SomePBC):
+ if s_et.__class__ == annmodel.SomePBC:
continue
yield "%s exceptblock is not completely sane" % graph.name
diff --git a/rpython/translator/transform.py b/rpython/translator/transform.py
--- a/rpython/translator/transform.py
+++ b/rpython/translator/transform.py
@@ -191,7 +191,7 @@
# fix the annotation of the exceptblock.inputargs
etype, evalue = graph.exceptblock.inputargs
s_type = annmodel.SomeType()
- s_type.is_type_of = [self.annvalue(evalue)]
+ s_type.is_type_of = [evalue]
s_value =
annmodel.SomeInstance(self.bookkeeper.getuniqueclassdef(Exception))
self.setbinding(etype, s_type)
self.setbinding(evalue, s_value)
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit