[pypy-svn] r4329 - pypy/trunk/src/pypy/annotation
arigo at codespeak.net
arigo at codespeak.net
Sat May 8 19:01:56 CEST 2004
Author: arigo
Date: Sat May 8 19:01:55 2004
New Revision: 4329
Modified:
pypy/trunk/src/pypy/annotation/binaryop.py
pypy/trunk/src/pypy/annotation/factory.py
pypy/trunk/src/pypy/annotation/model.py
pypy/trunk/src/pypy/annotation/unaryop.py
Log:
Fixed SomeMethod to record the class of their 'self' argument instead of a
specific s_self = SomeInstance(). This allows SomeMethods to be created in
advance when the classdef is created. SomeMethod unions can then retain all
the necessary precision.
Modified: pypy/trunk/src/pypy/annotation/binaryop.py
==============================================================================
--- pypy/trunk/src/pypy/annotation/binaryop.py (original)
+++ pypy/trunk/src/pypy/annotation/binaryop.py Sat May 8 19:01:55 2004
@@ -138,12 +138,14 @@
def union((met1, met2)):
# the union of the two meths dictionaries is a dictionary
- # {func: unionof(met1[func], met2[func])}
+ # {func: commonbase(met1[func], met2[func])}
+ # note that this case is probably very rare
+ # (the same Python object found in two different classes)
d = met1.meths.copy()
- for func, s_self in met2.meths.items():
+ for func, classdef in met2.meths.items():
if func in d:
- s_self = unionof(d[func], s_self)
- d[func] = s_self
+ classdef = classdef.commonbase(d[func])
+ d[func] = classdef
return SomeMethod(d)
Modified: pypy/trunk/src/pypy/annotation/factory.py
==============================================================================
--- pypy/trunk/src/pypy/annotation/factory.py (original)
+++ pypy/trunk/src/pypy/annotation/factory.py Sat May 8 19:01:55 2004
@@ -163,6 +163,7 @@
# the following might still invalidate some blocks if it
# generalizes existing values in parent classes
s_value = immutablevalue(value)
+ s_value = s_value.classattribute(self)
self.generalize(name, s_value, bookkeeper)
def __repr__(self):
Modified: pypy/trunk/src/pypy/annotation/model.py
==============================================================================
--- pypy/trunk/src/pypy/annotation/model.py (original)
+++ pypy/trunk/src/pypy/annotation/model.py Sat May 8 19:01:55 2004
@@ -110,7 +110,7 @@
"Stands for a bound Python method (or some method out of a list)."
knowntype = MethodType
def __init__(self, meths):
- self.meths = meths # map {python_function: s_self}
+ self.meths = meths # map {python_function: classdef}
class SomeImpossibleValue(SomeObject):
"""The empty set. Instances are placeholders for objects that
Modified: pypy/trunk/src/pypy/annotation/unaryop.py
==============================================================================
--- pypy/trunk/src/pypy/annotation/unaryop.py (original)
+++ pypy/trunk/src/pypy/annotation/unaryop.py Sat May 8 19:01:55 2004
@@ -37,8 +37,8 @@
return SomeBuiltin(getattr(obj, 'method_' + attr))
return SomeObject()
- def get(obj, s_self):
- return obj # default __get__ implementation
+ def classattribute(obj, classdef):
+ return obj # default unbound __get__ implementation
class __extend__(SomeTuple):
@@ -71,7 +71,7 @@
# XXX we can't see the difference between function objects
# XXX on classes or on instances, so this will incorrectly
# XXX turn functions read from instances into methods
- return clsdef.attrs[attr].get(ins)
+ return clsdef.attrs[attr]
# maybe the attribute exists in some subclass? if so, lift it
clsdef = ins.classdef
clsdef.generalize(attr, SomeImpossibleValue(), getbookkeeper())
@@ -125,10 +125,10 @@
results = [factory.pycall(func, arglist) for func in fun.funcs]
return unionof(*results)
- def get(fun, s_self): # function -> bound method
+ def classattribute(fun, classdef): # function -> unbound method
d = {}
for func in fun.funcs:
- d[func] = s_self
+ d[func] = classdef
return SomeMethod(d)
@@ -139,6 +139,6 @@
#print 'methodcall:', met, arglist
assert arglist is not None
factory = getbookkeeper().getfactory(FuncCallFactory)
- results = [factory.pycall(func, [s_self] + arglist)
- for func, s_self in met.meths.items()]
+ results = [factory.pycall(func, [SomeInstance(classdef)]+arglist)
+ for func, classdef in met.meths.items()]
return unionof(*results)
More information about the Pypy-commit
mailing list