[pypy-svn] r18682 - in pypy/dist/pypy/rpython/l3interp: . test

cfbolz at codespeak.net cfbolz at codespeak.net
Sun Oct 16 14:07:33 CEST 2005


Author: cfbolz
Date: Sun Oct 16 14:07:31 2005
New Revision: 18682

Modified:
   pypy/dist/pypy/rpython/l3interp/model.py
   pypy/dist/pypy/rpython/l3interp/test/test_l3interp.py
Log:
(cfbolz, pedronis):

remove the arguments exitswitch and exits from the Block constructor and
rather build this incrementally. This is needed for dependency reasons in the
graph converter.


Modified: pypy/dist/pypy/rpython/l3interp/model.py
==============================================================================
--- pypy/dist/pypy/rpython/l3interp/model.py	(original)
+++ pypy/dist/pypy/rpython/l3interp/model.py	Sun Oct 16 14:07:31 2005
@@ -114,11 +114,11 @@
     pass
 
 class Block(object):
-    def __init__(self, exitswitch, exits):
-        self.operations = []         # list of Operations
-        self.exitswitch = exitswitch # positives are variables
-                                     # negatives see above
-        self.exits = exits           # list of Links
+    def __init__(self):
+        self.operations = [] # list of Operations
+        self.exitswitch = 0  # positives are variables
+                             # negatives see above
+        self.exits = []      # list of Links
 
 class Graph(object):
     def __init__(self, name, startlink):
@@ -130,19 +130,6 @@
     def set_constants_int(self, constants):
         self.constants_int = constants
 
-    def blocklist(self):
-        result = []
-        pending = [self.startblock]
-        seen = {}
-        while len(pending):
-            block = pending.pop()
-            if block in seen:
-                continue
-            result.append(block)
-            for i in range(len(block.exits)):
-                pending.append(block.exits[i].target)
-        return result
-
 class Globals(object):
     def __init__(self):
         self.graphs = []    # list of Graphs

Modified: pypy/dist/pypy/rpython/l3interp/test/test_l3interp.py
==============================================================================
--- pypy/dist/pypy/rpython/l3interp/test/test_l3interp.py	(original)
+++ pypy/dist/pypy/rpython/l3interp/test/test_l3interp.py	Sun Oct 16 14:07:31 2005
@@ -18,7 +18,9 @@
     #    return 3 + 4
     op = model.Operation(l3interp.LLFrame.op_int_add, 0, [-1, -2])
     returnlink = model.ReturnLink()
-    block = model.Block(model.ONE_EXIT, [returnlink])
+    block = model.Block()
+    block.exitswitch = model.ONE_EXIT
+    block.exits = [returnlink]
     block.operations.append(op)
     startlink = model.Link(block, [])
     graph = model.Graph("testgraph", startlink)
@@ -42,7 +44,9 @@
     #    return x + 4
     op = model.Operation(l3interp.LLFrame.op_int_add, 1, [0, -1])
     returnlink = model.ReturnLink(return_val=1)
-    block = model.Block(model.ONE_EXIT, [returnlink])
+    block = model.Block()
+    block.exitswitch = model.ONE_EXIT
+    block.exits = [returnlink]
     block.operations.append(op)
     startlink = model.Link(target=block)
     startlink.move_int_registers = [0, 0]
@@ -70,7 +74,9 @@
     op = model.Operation(l3interp.LLFrame.op_int_is_true, 1, [0])
     returnlink1 = model.ReturnLink(-1)
     returnlink2 = model.ReturnLink(-2)
-    block = model.Block(1, [returnlink1, returnlink2])
+    block = model.Block()
+    block.exitswitch = 1
+    block.exits = [returnlink1, returnlink2]
     block.operations.append(op)
     startlink = model.Link(target=block)
     startlink.move_int_registers = [0, 0]
@@ -105,14 +111,18 @@
     call_op = model.Operation(l3interp.LLFrame.op_call_graph_int, 1, [0, 0])
     returnlink_g = model.ReturnLink(1)
     returnlink_f = model.ReturnLink(2)
-    block_g = model.Block(model.ONE_EXIT, [returnlink_g])
+    block_g = model.Block()
+    block_g.exitswitch = model.ONE_EXIT
+    block_g.exits = [returnlink_g]
     block_g.operations.append(op_g)
     startlink_g = model.StartLink(target=block_g)
     startlink_g.move_int_registers = [0, 0]
     graph_g = model.Graph("g", startlink_g)
     graph_g.set_constants_int([1])
 
-    block_f = model.Block(model.ONE_EXIT, [returnlink_f])
+    block_f = model.Block()
+    block_f.exitswitch = model.ONE_EXIT
+    block_f.exits = [returnlink_f]
     block_f.operations.extend([call_op, op_f])
     startlink_f = model.StartLink(target=block_f)
     startlink_f.move_int_registers = [0, 0]



More information about the Pypy-commit mailing list