diff options
author | Robert Griesemer <gri@golang.org> | 2020-12-10 21:16:02 -0800 |
---|---|---|
committer | Robert Griesemer <gri@golang.org> | 2020-12-14 21:41:25 +0000 |
commit | 3a912f279fb6e3b6942a3a6c2449288a33351b69 (patch) | |
tree | e8098ab2709d66c9d35ecea60b403490301c0b47 /src/cmd/compile/internal/syntax/nodes.go | |
parent | 8ec9e890008e681dcebdae50379b785eb6f160bb (diff) | |
download | go-3a912f279fb6e3b6942a3a6c2449288a33351b69.tar.gz go-3a912f279fb6e3b6942a3a6c2449288a33351b69.zip |
[dev.typeparams] cmd/compile/internal/syntax: export NewName and use it
Most syntax.Nodes are allocated in one place and there didn't
seem a need to provide factory methods - so as a matter of
API design, all nodes are "naked", without any constructors.
However, Name nodes are frequently used/replaced and also
are created as helper nodes in clients (types2). Make an
exception and export NewName.
Change-Id: I4b5c499d65bba74592dea68b0936c118b3edaca7
Reviewed-on: https://go-review.googlesource.com/c/go/+/277572
Trust: Robert Griesemer <gri@golang.org>
Run-TryBot: Robert Griesemer <gri@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Robert Findley <rfindley@google.com>
Diffstat (limited to 'src/cmd/compile/internal/syntax/nodes.go')
-rw-r--r-- | src/cmd/compile/internal/syntax/nodes.go | 7 |
1 files changed, 7 insertions, 0 deletions
diff --git a/src/cmd/compile/internal/syntax/nodes.go b/src/cmd/compile/internal/syntax/nodes.go index 306e695a33..fe8f62c6e6 100644 --- a/src/cmd/compile/internal/syntax/nodes.go +++ b/src/cmd/compile/internal/syntax/nodes.go @@ -122,6 +122,13 @@ type Group struct { // ---------------------------------------------------------------------------- // Expressions +func NewName(pos Pos, value string) *Name { + n := new(Name) + n.pos = pos + n.Value = value + return n +} + type ( Expr interface { Node |