[pypy-svn] r12277 - pypy/dist/pypy/annotation
pedronis at codespeak.net
pedronis at codespeak.net
Sun May 15 03:29:57 CEST 2005
Author: pedronis
Date: Sun May 15 03:29:57 2005
New Revision: 12277
Modified:
pypy/dist/pypy/annotation/binaryop.py
pypy/dist/pypy/annotation/model.py
pypy/dist/pypy/annotation/unaryop.py
Log:
more consistent faking that there are only new-style classes, so knowntype cannot be classobj
use SomeObject(knowntype=type) to carry types around, before we used a bare SomeObject
preserve .const and .knowntype if possible when unifying SomeObjects
do possibly the right thing when unifying SomeObjects with == .const and attached is_type_of
Modified: pypy/dist/pypy/annotation/binaryop.py
==============================================================================
--- pypy/dist/pypy/annotation/binaryop.py (original)
+++ pypy/dist/pypy/annotation/binaryop.py Sun May 15 03:29:57 2005
@@ -49,10 +49,24 @@
return obj1
else:
result = SomeObject()
+ if obj1.knowntype == obj2.knowntype and obj1.knowntype != object:
+ result.knowntype = obj1.knowntype
is_type_of1 = getattr(obj1, 'is_type_of', None)
is_type_of2 = getattr(obj2, 'is_type_of', None)
- if is_type_of1 and is_type_of1 == is_type_of2:
- result.is_type_of = is_type_of1
+ if obj1.is_constant() and obj2.is_constant() and obj1.const == obj2.const:
+ result.const = obj1.const
+ is_type_of = {}
+ if is_type_of1:
+ for v in is_type_of1:
+ is_type_of[v] = True
+ if is_type_of2:
+ for v in is_type_of2:
+ is_type_of[v] = True
+ if is_type_of:
+ result.is_type_of = is_type_of
+ else:
+ if is_type_of1 and is_type_of1 == is_type_of2:
+ result.is_type_of = is_type_of1
# try to preserve the origin of SomeObjects
if obj1 == result:
return obj1
Modified: pypy/dist/pypy/annotation/model.py
==============================================================================
--- pypy/dist/pypy/annotation/model.py (original)
+++ pypy/dist/pypy/annotation/model.py Sun May 15 03:29:57 2005
@@ -130,7 +130,10 @@
def origin(self):
return SomeObject._coming_from.get(id(self), (None, None))[0]
- origin = property(origin)
+ def set_origin(self, nvalue):
+ SomeObject._coming_from[id(self)] = nvalue, self.caused_by_merge
+ origin = property(origin, set_origin)
+ del set_origin
def caused_by_merge(self):
return SomeObject._coming_from.get(id(self), (None, None))[1]
@@ -260,6 +263,8 @@
[new_or_old_class(x)
for x in prebuiltinstances
if x is not None])
+ if self.knowntype == type(Exception):
+ self.knowntype = type
if prebuiltinstances.values() == [True]:
# hack for the convenience of direct callers to SomePBC():
# only if there is a single object in prebuiltinstances and
@@ -364,7 +369,11 @@
return s1
def tracking_unionof(ctxt, *somevalues):
- return unionof(*somevalues)
+ s1 = unionof(*somevalues)
+ if not s1.origin and type(ctxt) is tuple:
+ s1.origin = ctxt+(0,)
+ return s1
+
# ____________________________________________________________
Modified: pypy/dist/pypy/annotation/unaryop.py
==============================================================================
--- pypy/dist/pypy/annotation/unaryop.py (original)
+++ pypy/dist/pypy/annotation/unaryop.py Sun May 15 03:29:57 2005
@@ -41,6 +41,7 @@
r = immutablevalue(obj.knowntype)
else:
r = SomeObject()
+ r.knowntype = type
bk = getbookkeeper()
fn, block, i = bk.position_key
annotator = bk.annotator
More information about the Pypy-commit
mailing list