cmd/compile: enhance astdump flag to also generate HTML

AI-generated code, 3 merged commits, plus a LOT of hand
cleanups and tweaks, including removing cargo-culted dead
code from the SSA example, reorganizing CSS and JS out of a
single giant comment, using defer appropriately to ensure
balanced open/close tags, running output through tidy to
check compliance.  Prompts are included for reference.

This is intended to produce an HTML file in the style of "ssa.html",
but for AST.  The result of various phases appears in columns,
which can be scrolled side to side, and also dragged sideways
to make them wider (because AST tends wide).

This supports three kinds of highlighting, which I tweaked
along the way to make them (in my opinion) more useful.

1) Node outlining.  This outlines a node and all of its subtrees.
When the cursor is a "cell" (outlined cross) node highlighting
is available.  Note that "NAME" nodes are repeated within the
tree, so click on one of these will outline every occurrence.
This is actually done with pointer identity.

2) Name highlighting, available with a "crosshair" cursor.
This highlights a name, e.g. "autotmp_1".

3) Position highlighting, available with a "crosshair" cursor.
This highlights either a file (all occurrences of that file's positions),
a line within a file (all occurrences of that file:line combination),
or a column (all occurrences of that particular file:line:column).
Inlined positions are treated as a sequence of positions, not a single
position.

Prompts:
```
The file cmd/compile/internal/ir/dump.go contains a function AstDump
that calls FDump to generate a textual representation of the AST from
several phases within the compiler.

The file cmd/compile/internal/ir/fmt.go contains the definition of
FDump.

The SSA phases of the compiler use code in
cmd/compile/internal/ssa/html.go to render its textual representation
into an html display that allows hiding phases and highlighting blocks,
identifiers and line numbers.

Please write a similar HTML-generating phase for AST that produces an
output that will allow hiding phases and perhaps hiding subtrees, and
highlighting identifiers and line numbers.  The idioms and hacks used
in the SSA html display have worked well, if you want to copy them.
```

```
Not bad, but the output contains a strike-through beginning on a line
that contains  "TYPE  type *testing.B tc(1)".  The strike through
begins after "TYPE " and continues for the rest of the output.  Can you
find that bug and fix it?
```

```
The AST output is often wider than the statically sized columns in the
HTML output.  Either the columns need to have a width that can be
resized (dragged wider, for example) or the AST needs to be draggable,
side-to-side, within the columns.  Resizable columns seems like the
preferable choice, if it is possible.
```

```
The highlighting for file name and line number is not quite right -- all
the lines in the same file are grouped together, where what I want, is
that each different file:line:column gets its own number.  There's also
the issue of inlining, in some cases the location is described as more
than one file:line:column, where the first is the call site and the
second is the inlined function.  I think it makes sense to treat each
single file:line:column as its own item for highlighting, instead of
trying to treat the sequence of file:line:column as a single distinct
location.  One thing that might be interesting, but I am not sure how
hard it would be, is to distinguish between clicks to the file part,
the line part, and the column part -- click on file means highlight
all that matches file, click on line means all that machines file:line
(not just the line numner, since there may be different files, with
inlining) and click on the column means to highlight the specific
file:line:column triple.  That is, if it is possible.
```

```
Lovely.  Can you implement highlighting for names, strings
like "NAME-testing.b" so that all uses of a variable or a temporary can
easily be seen?
```

Change-Id: I1ed97cd92cdae16d556e3334e543af37973799e5
Reviewed-on: https://go-review.googlesource.com/c/go/+/740563
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: t hepudds <thepudds1460@gmail.com>
Reviewed-by: Keith Randall <khr@google.com>
4 files changed
tree: 0b6796d269ca076e023d7cadcfc88d529f5ec630
  1. .github/
  2. api/
  3. doc/
  4. lib/
  5. misc/
  6. src/
  7. test/
  8. .gitattributes
  9. .gitignore
  10. codereview.cfg
  11. CONTRIBUTING.md
  12. go.env
  13. LICENSE
  14. PATENTS
  15. README.md
  16. SECURITY.md
README.md

The Go Programming Language

Go is an open source programming language that makes it easy to build simple, reliable, and efficient software.

Gopher image Gopher image by Renee French, licensed under Creative Commons 4.0 Attribution license.

Our canonical Git repository is located at https://go.googlesource.com/go. There is a mirror of the repository at https://github.com/golang/go.

Unless otherwise noted, the Go source files are distributed under the BSD-style license found in the LICENSE file.

Download and Install

Binary Distributions

Official binary distributions are available at https://go.dev/dl/.

After downloading a binary release, visit https://go.dev/doc/install for installation instructions.

Install From Source

If a binary distribution is not available for your combination of operating system and architecture, visit https://go.dev/doc/install/source for source installation instructions.

Contributing

Go is the work of thousands of contributors. We appreciate your help!

To contribute, please read the contribution guidelines at https://go.dev/doc/contribute.

Note that the Go project uses the issue tracker for bug reports and proposals only. See https://go.dev/wiki/Questions for a list of places to ask questions about the Go language.