Author: Ronan Lamy <[email protected]>
Branch: annotator
Changeset: r68730:9a3e720c790c
Date: 2013-12-14 13:18 +0100
http://bitbucket.org/pypy/pypy/changeset/9a3e720c790c/
Log: kill missing_operation()
diff --git a/rpython/annotator/binaryop.py b/rpython/annotator/binaryop.py
--- a/rpython/annotator/binaryop.py
+++ b/rpython/annotator/binaryop.py
@@ -12,7 +12,7 @@
SomeBuiltin, SomeIterator, SomePBC, SomeFloat, s_None, SomeByteArray,
SomeWeakRef, SomeAddress, SomeTypedAddressAccess, SomeSingleFloat,
SomeLongFloat, SomeType, SomeConstantType, unionof, UnionError,
- missing_operation, read_can_only_throw, add_knowntypedata,
+ read_can_only_throw, add_knowntypedata,
merge_knowntypedata,)
from rpython.annotator.bookkeeper import getbookkeeper
from rpython.flowspace.model import Variable, Constant
@@ -26,8 +26,7 @@
BINARY_OPERATIONS = set([oper.opname for oper in op.__dict__.values()
if oper.dispatch == 2])
-for opname in BINARY_OPERATIONS:
- missing_operation(pairtype(SomeObject, SomeObject), opname)
+
class __extend__(pairtype(SomeObject, SomeObject)):
diff --git a/rpython/annotator/model.py b/rpython/annotator/model.py
--- a/rpython/annotator/model.py
+++ b/rpython/annotator/model.py
@@ -796,12 +796,6 @@
assert 0, "couldn't get to commonbase of %r and %r" % (cls1, cls2)
-def missing_operation(cls, name):
- def default_op(*args):
- return s_ImpossibleValue
- setattr(cls, name, default_op)
-
-
class HarmlesslyBlocked(Exception):
"""Raised by the unaryop/binaryop to signal a harmless kind of
BlockedInference: the current block is blocked, but not in a way
diff --git a/rpython/annotator/unaryop.py b/rpython/annotator/unaryop.py
--- a/rpython/annotator/unaryop.py
+++ b/rpython/annotator/unaryop.py
@@ -10,7 +10,7 @@
SomeString, SomeChar, SomeList, SomeDict, SomeTuple, SomeImpossibleValue,
SomeUnicodeCodePoint, SomeInstance, SomeBuiltin, SomeFloat, SomeIterator,
SomePBC, SomeTypedAddressAccess, SomeAddress, SomeType, s_ImpossibleValue,
- s_Bool, s_None, unionof, missing_operation, add_knowntypedata,
+ s_Bool, s_None, unionof, add_knowntypedata,
HarmlesslyBlocked, SomeWeakRef, SomeUnicodeString, SomeByteArray)
from rpython.annotator.bookkeeper import getbookkeeper
from rpython.annotator import builtin
@@ -23,8 +23,6 @@
UNARY_OPERATIONS = set([oper.opname for oper in op.__dict__.values()
if oper.dispatch == 1])
-for opname in UNARY_OPERATIONS:
- missing_operation(SomeObject, opname)
class __extend__(SomeObject):
diff --git a/rpython/flowspace/operation.py b/rpython/flowspace/operation.py
--- a/rpython/flowspace/operation.py
+++ b/rpython/flowspace/operation.py
@@ -14,6 +14,7 @@
from rpython.flowspace.model import (Constant, WrapException, const, Variable,
SpaceOperation)
from rpython.flowspace.specialcase import register_flow_sc
+from rpython.annotator.model import s_ImpossibleValue
NOT_REALLY_CONST = {
Constant(sys): {
@@ -136,13 +137,19 @@
class SingleDispatchMixin(object):
dispatch = 1
def consider(self, annotator, arg, *other_args):
- impl = getattr(arg, self.opname)
+ try:
+ impl = getattr(arg, self.opname)
+ except AttributeError:
+ return s_ImpossibleValue
return impl(*other_args)
class DoubleDispatchMixin(object):
dispatch = 2
def consider(self, annotator, arg1, arg2, *other_args):
- impl = getattr(pair(arg1, arg2), self.opname)
+ try:
+ impl = getattr(pair(arg1, arg2), self.opname)
+ except AttributeError:
+ return s_ImpossibleValue
return impl(*other_args)
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit