Author: Ronan Lamy <[email protected]>
Branch: anntype
Changeset: r80626:d38e7b673e7e
Date: 2015-11-09 05:03 +0000
http://bitbucket.org/pypy/pypy/changeset/d38e7b673e7e/

Log:    Implement SomeTypeOf union

diff --git a/rpython/annotator/binaryop.py b/rpython/annotator/binaryop.py
--- a/rpython/annotator/binaryop.py
+++ b/rpython/annotator/binaryop.py
@@ -9,7 +9,7 @@
     SomeTuple, SomeImpossibleValue, s_ImpossibleValue, SomeInstance,
     SomeBuiltinMethod, SomeIterator, SomePBC, SomeNone, SomeFloat, s_None,
     SomeByteArray, SomeWeakRef, SomeSingleFloat,
-    SomeLongFloat, SomeType, SomeConstantType, unionof, UnionError,
+    SomeLongFloat, SomeType, SomeTypeOf, SomeConstantType, unionof, UnionError,
     read_can_only_throw, add_knowntypedata,
     merge_knowntypedata,)
 from rpython.annotator.bookkeeper import immutablevalue
@@ -157,6 +157,17 @@
                 result.is_type_of = is_type_of1
         return result
 
+class __extend__(pairtype(SomeTypeOf, SomeTypeOf)):
+    def union((s_obj1, s_obj2)):
+        if s_obj1 == s_obj2:
+            return s_obj1
+        else:
+            s_1 = SomeType()
+            s_1.is_type_of = s_obj1.is_type_of
+            s_2 = SomeType()
+            s_2.is_type_of = s_obj2.is_type_of
+            return unionof(s_1, s_2)
+
 
 # cloning a function with identical code, for the can_only_throw attribute
 def _clone(f, can_only_throw = None):
diff --git a/rpython/annotator/model.py b/rpython/annotator/model.py
--- a/rpython/annotator/model.py
+++ b/rpython/annotator/model.py
@@ -141,8 +141,11 @@
 class SomeTypeOf(SomeType):
     """The type of a variable"""
     def __init__(self, v_arg):
-        self.is_type_of = [v_arg]
+        self.v_arg = v_arg
 
+    @property
+    def is_type_of(self):
+        return [self.v_arg]
 
 class SomeFloat(SomeObject):
     "Stands for a float or an integer."
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit

Reply via email to