]> Cypherpunks repositories - gostls13.git/commitdiff
cmd/compile: make ssa blocks collapsable in ssa.html
authorYury Smolsky <yury@smolsky.by>
Thu, 25 Oct 2018 10:33:09 +0000 (13:33 +0300)
committerYury Smolsky <yury@smolsky.by>
Fri, 23 Nov 2018 22:03:37 +0000 (22:03 +0000)
This CL adds a button that collapses values list of a block.
Button is displayed for every block with non-empty values.

Change-Id: I4b65af81e25349f38341df487d42698c9d006a00
Reviewed-on: https://go-review.googlesource.com/c/144557
Run-TryBot: Yury Smolsky <yury@smolsky.by>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
src/cmd/compile/internal/ssa/html.go

index 6b8748bdb5a952bdee87beff79694b3a96ae6439..1202987acc4a5e8874d4fc8210cb59d347a15357 100644 (file)
@@ -176,6 +176,20 @@ ul.ssa-print-func {
     padding-left: 0;
 }
 
+li.ssa-start-block button {
+    padding: 0 1em;
+    margin: 0;
+    border: none;
+    display: inline;
+    font-size: 14px;
+    float: right;
+}
+
+button:hover {
+    background-color: #eee;
+    cursor: pointer;
+}
+
 dl.ssa-gen {
     padding-left: 0;
 }
@@ -490,6 +504,20 @@ function toggle_visibility(id) {
     }
 }
 
+function hideBlock(el) {
+    var es = el.parentNode.parentNode.getElementsByClassName("ssa-value-list");
+    if (es.length===0)
+        return;
+    var e = es[0];
+    if (e.style.display === 'block' || e.style.display === '') {
+        e.style.display = 'none';
+        el.innerHTML = '+';
+    } else {
+        e.style.display = 'block';
+        el.innerHTML = '-';
+    }
+}
+
 // TODO: scale the graph with the viewBox attribute.
 function graphReduce(id) {
     var node = document.getElementById(id);
@@ -985,7 +1013,6 @@ type htmlFuncPrinter struct {
 func (p htmlFuncPrinter) header(f *Func) {}
 
 func (p htmlFuncPrinter) startBlock(b *Block, reachable bool) {
-       // TODO: Make blocks collapsable?
        var dead string
        if !reachable {
                dead = "dead-block"
@@ -999,6 +1026,9 @@ func (p htmlFuncPrinter) startBlock(b *Block, reachable bool) {
                        fmt.Fprintf(p.w, " %s", pred.HTML())
                }
        }
+       if len(b.Values) > 0 {
+               io.WriteString(p.w, `<button onclick="hideBlock(this)">-</button>`)
+       }
        io.WriteString(p.w, "</li>")
        if len(b.Values) > 0 { // start list of values
                io.WriteString(p.w, "<li class=\"ssa-value-list\">")