Author: Ronan Lamy <[email protected]>
Branch: anntype
Changeset: r80809:c17dbcc48d6a
Date: 2015-11-20 15:59 +0000
http://bitbucket.org/pypy/pypy/changeset/c17dbcc48d6a/
Log: Split off SomeTypeOf-specific path in handling of op.issubtype
diff --git a/rpython/annotator/annrpython.py b/rpython/annotator/annrpython.py
--- a/rpython/annotator/annrpython.py
+++ b/rpython/annotator/annrpython.py
@@ -11,7 +11,7 @@
from rpython.translator import simplify, transform
from rpython.annotator import model as annmodel, signature
from rpython.annotator.model import (
- typeof, SomeTypeOf, SomeException, SomeExceptCase, s_ImpossibleValue)
+ typeof, SomeExceptCase, s_ImpossibleValue)
from rpython.annotator.bookkeeper import Bookkeeper
from rpython.rtyper.normalizecalls import perform_normalizations
diff --git a/rpython/annotator/unaryop.py b/rpython/annotator/unaryop.py
--- a/rpython/annotator/unaryop.py
+++ b/rpython/annotator/unaryop.py
@@ -100,18 +100,17 @@
callspec = complex_args([annotator.annotation(v_arg) for v_arg in args_v])
return annotator.annotation(func).call(callspec)
[email protected](SomeObject)
+def issubtype(annotator, v_type, v_cls):
+ s_type = v_type.annotation
+ s_cls = annotator.annotation(v_cls)
+ if s_type.is_constant() and s_cls.is_constant():
+ return annotator.bookkeeper.immutablevalue(
+ issubclass(s_type.const, s_cls.const))
+ return s_Bool
+
class __extend__(SomeObject):
- def issubtype(self, s_cls):
- if hasattr(self, 'is_type_of'):
- 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
-
def len(self):
return SomeInteger(nonneg=True)
@@ -914,6 +913,12 @@
# really crash translated code). It can be generalized later.
return SomeImpossibleValue()
[email protected](SomeTypeOf)
+def issubtype(annotator, v_type, v_cls):
+ args_v = v_type.annotation.is_type_of
+ return builtin.builtin_isinstance(
+ args_v[0].annotation, annotator.annotation(v_cls), args_v)
+
#_________________________________________
# weakrefs
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit