[pypy-svn] r6359 - in pypy/trunk/src/pypy: objspace/flow translator

arigo at codespeak.net arigo at codespeak.net
Wed Sep 8 15:30:29 CEST 2004


Author: arigo
Date: Wed Sep  8 15:30:28 2004
New Revision: 6359

Modified:
   pypy/trunk/src/pypy/objspace/flow/model.py
   pypy/trunk/src/pypy/translator/transform.py
Log:
Bug fix in the transformations.  Actually caused by list objects that were
shared between the 'args' attributes of several Link objects, so that
modifying the list of args of one Link changed another one unexpectedly.



Modified: pypy/trunk/src/pypy/objspace/flow/model.py
==============================================================================
--- pypy/trunk/src/pypy/objspace/flow/model.py	(original)
+++ pypy/trunk/src/pypy/objspace/flow/model.py	Wed Sep  8 15:30:28 2004
@@ -35,7 +35,7 @@
 class Link:
     def __init__(self, args, target, exitcase=None):
         assert len(args) == len(target.inputargs), "output args mismatch"
-        self.args = args           # mixed list of var/const
+        self.args = list(args)     # mixed list of var/const
         self.target = target       # block
         self.exitcase = exitcase   # this is a concrete value
         self.prevblock = None      # the block this Link is an exit of
@@ -44,10 +44,10 @@
     isstartblock = False
     
     def __init__(self, inputargs):
-        self.inputargs = inputargs    # mixed list of variable/const 
-        self.operations = []          # list of SpaceOperation(s)
-        self.exitswitch = None        # variable
-        self.exits      = []          # list of Link(s)
+        self.inputargs = list(inputargs)  # mixed list of variable/const 
+        self.operations = []              # list of SpaceOperation(s)
+        self.exitswitch = None            # variable
+        self.exits      = []              # list of Link(s)
 
     def getvariables(self):
         "Return all variables mentionned in this Block."

Modified: pypy/trunk/src/pypy/translator/transform.py
==============================================================================
--- pypy/trunk/src/pypy/translator/transform.py	(original)
+++ pypy/trunk/src/pypy/translator/transform.py	Wed Sep  8 15:30:28 2004
@@ -158,9 +158,11 @@
         # Otherwise the link.args get out of sync with the
         # link.target.inputargs.
         for link in block.exits:
+            assert len(link.args) == len(link.target.inputargs)
             for i in range(len(link.args)-1, -1, -1):
                 if link.target.inputargs[i] not in read_vars:
                     del link.args[i]
+            # the above assert would fail here
 
     for block in self.annotated:
         # look for input variables never used



More information about the Pypy-commit mailing list