[Scummvm-cvs-logs] SF.net SVN: scummvm: [28660] tools/branches/gsoc2007-decompiler/finalD

brixxie at users.sourceforge.net brixxie at users.sourceforge.net
Sun Aug 19 09:36:23 CEST 2007


Revision: 28660
          http://scummvm.svn.sourceforge.net/scummvm/?rev=28660&view=rev
Author:   brixxie
Date:     2007-08-19 00:36:23 -0700 (Sun, 19 Aug 2007)

Log Message:
-----------
PseudoCode.py: fixed tiny bug in PseudoCode._write_code() which
  caused it not to terminate along the branches of a control
  structure if the structure's follow node was reached
cfg.py: removed code that tagged loops with a one-way latching
  node and a two-way header node whose outgoing neighbours both are
  part of the loop as endless.

Modified Paths:
--------------
    tools/branches/gsoc2007-decompiler/finalD/PseudoCode.py
    tools/branches/gsoc2007-decompiler/finalD/cfg.py

Modified: tools/branches/gsoc2007-decompiler/finalD/PseudoCode.py
===================================================================
--- tools/branches/gsoc2007-decompiler/finalD/PseudoCode.py	2007-08-19 05:12:26 UTC (rev 28659)
+++ tools/branches/gsoc2007-decompiler/finalD/PseudoCode.py	2007-08-19 07:36:23 UTC (rev 28660)
@@ -100,7 +100,6 @@
             # loop follow already traversed
             self._emit_goto(bb.loop_follow, i)
 
-    # TODO: buggy deluxe
     def _write_two_way(self, bbn, i, latch, ifollow):
         """
         Write code for tree rooted at bbn.
@@ -180,7 +179,7 @@
         if bbn == None:
             return
         bb = self.cfg.node_data(bbn)
-        if bb == ifollow or bbn in self.traversed:
+        if bbn == ifollow or bbn in self.traversed:
             return
         self.traversed.append(bbn)
         if bb.loop_head == bbn:

Modified: tools/branches/gsoc2007-decompiler/finalD/cfg.py
===================================================================
--- tools/branches/gsoc2007-decompiler/finalD/cfg.py	2007-08-19 05:12:26 UTC (rev 28659)
+++ tools/branches/gsoc2007-decompiler/finalD/cfg.py	2007-08-19 07:36:23 UTC (rev 28660)
@@ -350,11 +350,7 @@
             lt = LT.post_tested
     else:
         if hblock.btype == BT.two_way:
-            # I guess that is... "important"
-            if all(hsucc in nodes_in_loop for hsucc in g.out_nbrs(head)):
-                lt = LT.endless
-            else:
-                lt = LT.pre_tested
+            lt = LT.pre_tested
         else:
             lt = LT.endless
     hblock.loop_type = lt
@@ -481,23 +477,29 @@
     def in_head_latch(block):
         """Return True if block is a loop header or latching node."""
         return block.loop_latch == block or block.loop_head == block
-    nodes = g.node_list()[:]
-    nodes.sort(key=node_to_revpo, reverse=True)
+    nodes_desc = g.node_list()[:]
+    nodes_desc.sort(key=node_to_revpo, reverse=True)
     unresolved = []
-    for m in nodes:
+    for m in nodes_desc:
         block = g.node_data(m)
         if block.btype == BT.two_way and not in_head_latch(block):
+            # nodes_desc already sorted, no need for max() below
             dominated_nways = [i for i in g.node_list()
                                if g.node_data(i).idom == m
                                and g.inc_degree(i) >= 2]
             if dominated_nways:
                 n = max(dominated_nways, key=node_to_revpo)
                 block.if_follow = n
-                for unres in unresolved:
-                    g.node_data(unres).if_follow = n
-                unresolved = []
+                for unres in unresolved[:]:
+                    if n > unres:
+                        print "%d resolved to %d through %d" % (unres, n, m)
+                        g.node_data(unres).if_follow = n
+                        unresolved.remove(unres)
+                        print unresolved
             else:
                 unresolved.append(m)
+    if unresolved:
+        print "STILL UNRESOLVED: %s" % unresolved
 
 def merge_conditionals(g, n0, n1, type):
     """


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list