flow: improve dot-rendering for debugging
authorJean Privat <jean@pryen.org>
Sat, 11 Apr 2015 16:52:46 +0000 (23:52 +0700)
committerJean Privat <jean@pryen.org>
Sat, 11 Apr 2015 16:52:46 +0000 (23:52 +0700)
Signed-off-by: Jean Privat <jean@pryen.org>

src/semantize/flow.nit

index 4bf6ffb..b0e833a 100644 (file)
@@ -78,7 +78,7 @@ private class FlowVisitor
        fun printflow
        do
                var file = new FileWriter.open("flow.dot")
-               file.write("digraph \{\n")
+               file.write("digraph \{\nnode[shape=box];")
                for f in flows do
                        var s = ""
                        if f.node isa AExpr then
@@ -86,13 +86,14 @@ private class FlowVisitor
                        end
                        file.write "F{f.object_id} [label=\"{f.object_id}\\n{f.node.location}\\n{f.node.class_name}\\n{f.name}{s}\"];\n"
                        for p in f.previous do
-                               file.write "F{p.object_id} -> F{f.object_id};\n"
+                               s = ""
+                               if f.when_true == p then s = "[label=TRUE, style=dotted]"
+                               if f.when_false == p then s = "[label=FALSE, style=dotted]"
+                               if f.when_true == p and f.when_false == p then s = "[label=TRUE_FALSE, style=dotted]"
+                               file.write "F{p.object_id} -> F{f.object_id}{s};\n"
                        end
-                       if f.when_true != f then
-                               file.write "F{f.object_id} -> F{f.when_true.object_id}[label=TRUE, style=dotted];\n"
-                       end
-                       if f.when_false != f then
-                               file.write "F{f.object_id} -> F{f.when_false.object_id}[label=FALSE,style=dotted];\n"
+                       for p in f.loops do
+                               file.write "F{p.object_id} -> F{f.object_id}[label=LOOP, style=dashed, constraint=false];\n"
                        end
                end
                file.write("\}\n")