From 1ac84999b93876bb06887e483ae45b27e03d7423 Mon Sep 17 00:00:00 2001 From: Yury Smolsky Date: Thu, 25 Oct 2018 13:33:09 +0300 Subject: [PATCH] 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 TryBot-Result: Gobot Gobot Reviewed-by: Keith Randall --- src/cmd/compile/internal/ssa/html.go | 32 +++++++++++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) 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, ``) + } io.WriteString(p.w, "") if len(b.Values) > 0 { // start list of values io.WriteString(p.w, "
  • ") -- 2.50.0