diff options
author | Yury Smolsky <yury@smolsky.by> | 2018-10-25 13:33:09 +0300 |
---|---|---|
committer | Yury Smolsky <yury@smolsky.by> | 2018-11-23 22:03:37 +0000 |
commit | 1ac84999b93876bb06887e483ae45b27e03d7423 (patch) | |
tree | 065a7418675bbb408de8036ab8ffa36b8d92fd5f /src/cmd/compile/internal/ssa/html.go | |
parent | c6d493937e7047057a9833661d6d20ce72f904b4 (diff) | |
download | go-1ac84999b93876bb06887e483ae45b27e03d7423.tar.gz go-1ac84999b93876bb06887e483ae45b27e03d7423.zip |
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: Keith Randall <khr@golang.org>
Diffstat (limited to 'src/cmd/compile/internal/ssa/html.go')
-rw-r--r-- | src/cmd/compile/internal/ssa/html.go | 32 |
1 files changed, 31 insertions, 1 deletions
diff --git a/src/cmd/compile/internal/ssa/html.go b/src/cmd/compile/internal/ssa/html.go index 6b8748bdb5..1202987acc 100644 --- a/src/cmd/compile/internal/ssa/html.go +++ b/src/cmd/compile/internal/ssa/html.go @@ -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\">") |