Author: Ronan Lamy <[email protected]>
Branch: online-transforms
Changeset: r74001:3b7f29937dd9
Date: 2014-10-17 16:18 +0100
http://bitbucket.org/pypy/pypy/changeset/3b7f29937dd9/
Log: progress
diff --git a/rpython/annotator/bookkeeper.py b/rpython/annotator/bookkeeper.py
--- a/rpython/annotator/bookkeeper.py
+++ b/rpython/annotator/bookkeeper.py
@@ -317,6 +317,9 @@
s_self = self.immutablevalue(x.__self__)
result = s_self.find_method(x.__name__)
assert result is not None
+ elif hasattr(x, '__objclass__'):
+ s_type = self.valueoftype(x.__objclass__)
+ result = s_type.find_unboundmethod(x.__name__)
else:
result = None
if result is None:
diff --git a/rpython/annotator/model.py b/rpython/annotator/model.py
--- a/rpython/annotator/model.py
+++ b/rpython/annotator/model.py
@@ -558,6 +558,18 @@
return False
+class SomeUnboundMethod(SomeBuiltin):
+ "Stands for an unbound built-in method."
+ def __init__(self, analyser, methodname=None):
+ if isinstance(analyser, MethodType):
+ analyser = descriptor.InstanceMethod(
+ analyser.im_func,
+ analyser.im_self,
+ analyser.im_class)
+ self.analyser = analyser
+ self.methodname = methodname
+
+
class SomeBuiltinMethod(SomeBuiltin):
""" Stands for a built-in method which has got special meaning
"""
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
@@ -434,7 +434,6 @@
constmeth = getattr(type(example), methname)
s_constmeth = iv(constmeth)
assert isinstance(s_constmeth, annmodel.SomeObject)
- assert s_constmeth.getKind() == 0
s_meth = iv(example).getattr(iv(methname))
assert isinstance(s_meth, annmodel.SomeObject)
diff --git a/rpython/annotator/unaryop.py b/rpython/annotator/unaryop.py
--- a/rpython/annotator/unaryop.py
+++ b/rpython/annotator/unaryop.py
@@ -8,7 +8,7 @@
from rpython.flowspace.model import const
from rpython.annotator.model import (SomeObject, SomeInteger, SomeBool,
SomeString, SomeChar, SomeList, SomeDict, SomeTuple, SomeImpossibleValue,
- SomeUnicodeCodePoint, SomeInstance, SomeBuiltin, SomeBuiltinMethod,
+ SomeUnicodeCodePoint, SomeInstance, SomeBuiltin, SomeUnboundMethod,
SomeBuiltinMethod,
SomeFloat, SomeIterator, SomePBC, SomeNone, SomeType, s_ImpossibleValue,
s_Bool, s_None, unionof, add_knowntypedata,
HarmlesslyBlocked, SomeWeakRef, SomeUnicodeString, SomeByteArray)
@@ -119,6 +119,15 @@
else:
return SomeBuiltinMethod(analyser, self, name)
+ def find_unboundmethod(self, name):
+ "Look for a special-case implementation for the named method."
+ try:
+ analyser = getattr(self.__class__, 'method_' + name)
+ except AttributeError:
+ return None
+ else:
+ return SomeUnboundMethod(analyser, name)
+
def getattr(self, s_attr):
# get a SomeBuiltin if the SomeObject has
# a corresponding method to handle it
_______________________________________________
pypy-commit mailing list
[email protected]
https://mail.python.org/mailman/listinfo/pypy-commit