Commit 1ac84999 authored by Yury Smolsky's avatar Yury Smolsky

cmd/compile: make ssa blocks collapsable in ssa.html

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: default avatarKeith Randall <khr@golang.org>
parent c6d49393
......@@ -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\">")
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment