mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
cmd/compile: rename strlit, Bool, and Int64 *Node accessors
The Node type has shortcuts to access bool and int Values:
func (n *Node) Int64() int64
for n.Val().U.(*Mpint).Int64()
func (n *Node) Bool() bool
for n.Val().U.(bool)
I was convinced we didn't have one for string literal nodes, until I
noticed that we do, it's just called strlit, it's not a method, and
it's later in the file:
func strlit(n *Node) string
This change, for consistency:
- Renames strlit to StringVal and makes it a *Node method
- Renames Bool and Int64 to BoolVal and Int64Val
- Moves StringVal near the other two
Change-Id: I18e635384c35eb3a238fd52b1ccd322b1a74d733
Reviewed-on: https://go-review.googlesource.com/c/go/+/261361
Trust: Alberto Donizetti <alb.donizetti@gmail.com>
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
parent
7c58ef732e
commit
e2931612b0
10 changed files with 72 additions and 69 deletions
|
|
@ -774,7 +774,7 @@ func (p *noder) sum(x syntax.Expr) *Node {
|
|||
n := p.expr(x)
|
||||
if Isconst(n, CTSTR) && n.Sym == nil {
|
||||
nstr = n
|
||||
chunks = append(chunks, strlit(nstr))
|
||||
chunks = append(chunks, nstr.StringVal())
|
||||
}
|
||||
|
||||
for i := len(adds) - 1; i >= 0; i-- {
|
||||
|
|
@ -784,12 +784,12 @@ func (p *noder) sum(x syntax.Expr) *Node {
|
|||
if Isconst(r, CTSTR) && r.Sym == nil {
|
||||
if nstr != nil {
|
||||
// Collapse r into nstr instead of adding to n.
|
||||
chunks = append(chunks, strlit(r))
|
||||
chunks = append(chunks, r.StringVal())
|
||||
continue
|
||||
}
|
||||
|
||||
nstr = r
|
||||
chunks = append(chunks, strlit(nstr))
|
||||
chunks = append(chunks, nstr.StringVal())
|
||||
} else {
|
||||
if len(chunks) > 1 {
|
||||
nstr.SetVal(Val{U: strings.Join(chunks, "")})
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue