[pypy-commit] pypy anntype: Create SomeTypeOf
rlamy
noreply at buildbot.pypy.org
Tue Nov 10 18:24:23 EST 2015
Author: Ronan Lamy <ronan.lamy at gmail.com>
Branch: anntype
Changeset: r80625:e0901d853668
Date: 2015-11-09 01:45 +0000
http://bitbucket.org/pypy/pypy/changeset/e0901d853668/
Log: Create SomeTypeOf
diff --git a/rpython/annotator/annrpython.py b/rpython/annotator/annrpython.py
--- a/rpython/annotator/annrpython.py
+++ b/rpython/annotator/annrpython.py
@@ -6,10 +6,10 @@
from rpython.tool.pairtype import pair
from rpython.tool.error import (format_blocked_annotation_error,
gather_error, source_lines)
-from rpython.flowspace.model import (
- Variable, Constant, FunctionGraph, checkgraph)
+from rpython.flowspace.model import Variable, Constant, checkgraph
from rpython.translator import simplify, transform
from rpython.annotator import model as annmodel, signature
+from rpython.annotator.model import SomeTypeOf
from rpython.annotator.bookkeeper import Bookkeeper
from rpython.rtyper.normalizecalls import perform_normalizations
@@ -503,11 +503,8 @@
if isinstance(v_last_exc_value, Variable):
self.setbinding(v_last_exc_value, s_last_exc_value)
-
if isinstance(v_last_exc_type, Variable):
- s_etype = annmodel.SomeType()
- s_etype.is_type_of = [v_last_exc_value]
- self.setbinding(v_last_exc_type, s_etype)
+ self.setbinding(v_last_exc_type, SomeTypeOf(v_last_exc_value))
s_last_exc_type = annmodel.SomeType()
if isinstance(v_last_exc_type, Constant):
diff --git a/rpython/annotator/model.py b/rpython/annotator/model.py
--- a/rpython/annotator/model.py
+++ b/rpython/annotator/model.py
@@ -138,6 +138,11 @@
def can_be_none(self):
return False
+class SomeTypeOf(SomeType):
+ """The type of a variable"""
+ def __init__(self, v_arg):
+ self.is_type_of = [v_arg]
+
class SomeFloat(SomeObject):
"Stands for a float or an integer."
diff --git a/rpython/annotator/unaryop.py b/rpython/annotator/unaryop.py
--- a/rpython/annotator/unaryop.py
+++ b/rpython/annotator/unaryop.py
@@ -11,7 +11,7 @@
from rpython.annotator.model import (SomeObject, SomeInteger, SomeBool,
SomeString, SomeChar, SomeList, SomeDict, SomeTuple, SomeImpossibleValue,
SomeUnicodeCodePoint, SomeInstance, SomeBuiltin, SomeBuiltinMethod,
- SomeFloat, SomeIterator, SomePBC, SomeNone, SomeType, s_ImpossibleValue,
+ SomeFloat, SomeIterator, SomePBC, SomeNone, SomeTypeOf, s_ImpossibleValue,
s_Bool, s_None, s_Int, unionof, add_knowntypedata,
SomeWeakRef, SomeUnicodeString, SomeByteArray)
from rpython.annotator.bookkeeper import getbookkeeper, immutablevalue
@@ -26,11 +26,11 @@
if oper.dispatch == 1])
UNARY_OPERATIONS.remove('contains')
+
@op.type.register(SomeObject)
-def type_SomeObject(annotator, arg):
- r = SomeType()
- r.is_type_of = [arg]
- return r
+def type_SomeObject(annotator, v_arg):
+ return SomeTypeOf(v_arg)
+
@op.bool.register(SomeObject)
def bool_SomeObject(annotator, obj):
More information about the pypy-commit
mailing list