[pypy-svn] r9664 - pypy/dist/pypy/annotation
arigo at codespeak.net
arigo at codespeak.net
Sat Mar 5 17:29:08 CET 2005
Author: arigo
Date: Sat Mar 5 17:29:08 2005
New Revision: 9664
Modified:
pypy/dist/pypy/annotation/classdef.py
pypy/dist/pypy/annotation/unaryop.py
Log:
More precise calls to methods.
Modified: pypy/dist/pypy/annotation/classdef.py
==============================================================================
--- pypy/dist/pypy/annotation/classdef.py (original)
+++ pypy/dist/pypy/annotation/classdef.py Sat Mar 5 17:29:08 2005
@@ -157,6 +157,7 @@
for clsdef in self.getmro():
if attr in clsdef.attrs:
clsdef._generalize_attr(attr, s_value)
+ break
else:
self._generalize_attr(attr, s_value)
Modified: pypy/dist/pypy/annotation/unaryop.py
==============================================================================
--- pypy/dist/pypy/annotation/unaryop.py (original)
+++ pypy/dist/pypy/annotation/unaryop.py Sat Mar 5 17:29:08 2005
@@ -166,7 +166,22 @@
attrdef = ins.classdef.find_attribute(attr)
position = getbookkeeper().position_key
attrdef.read_locations[position] = True
- return attrdef.getvalue()
+ s_result = attrdef.getvalue()
+ # hack: if s_result is a set of methods, discard the ones
+ # that can't possibly apply to an instance of ins.classdef.
+ if isinstance(s_result, SomePBC):
+ d = {}
+ for func, value in s_result.prebuiltinstances.items():
+ if (isclassdef(value) and
+ value not in ins.classdef.getmro() and
+ ins.classdef not in value.getmro()):
+ continue
+ d[func] = value
+ if d:
+ s_result = SomePBC(d)
+ else:
+ s_result = SomeImpossibleValue()
+ return s_result
return SomeObject()
def setattr(ins, s_attr, s_value):
More information about the Pypy-commit
mailing list