[pypy-svn] r12025 - pypy/dist/pypy/translator
arigo at codespeak.net
arigo at codespeak.net
Fri May 6 18:02:47 CEST 2005
Author: arigo
Date: Fri May 6 18:02:47 2005
New Revision: 12025
Modified:
pypy/dist/pypy/translator/typer.py
Log:
Cannot attach a concretetype attribute in-place to an old Constant instance.
Who knows who else is using it?
Modified: pypy/dist/pypy/translator/typer.py
==============================================================================
--- pypy/dist/pypy/translator/typer.py (original)
+++ pypy/dist/pypy/translator/typer.py Fri May 6 18:02:47 2005
@@ -34,14 +34,15 @@
self.specialize_block(block)
def settype(self, a, concretetype):
- """Set the concretetype of a Variable or Constant."""
+ """Set the concretetype of a Variable."""
+ assert isinstance(a, Variable)
if hasattr(a, 'concretetype') and a.concretetype != concretetype:
raise TyperError, "inconsitent type for %r: %r != %r" % (
a, a.concretetype, concretetype)
a.concretetype = concretetype
def setbesttype(self, a):
- """Set the best concretetype for a Variable or Constant according to
+ """Set the best concretetype for a Variable according to
the annotations."""
try:
return a.concretetype
@@ -64,12 +65,9 @@
"""Get the operation(s) needed to convert 'v' to the given type."""
ops = []
if isinstance(v, Constant):
- try:
- # mark the concrete type of the Constant
- self.settype(v, concretetype)
- except TyperError:
- v = Constant(v.value) # need a copy of the Constant
- self.settype(v, concretetype)
+ # we should never modify a Constant in-place
+ v = Constant(v.value)
+ v.concretetype = concretetype
elif v.concretetype != concretetype:
# XXX do we need better conversion paths?
More information about the Pypy-commit
mailing list