mirror of
https://github.com/golang/go.git
synced 2025-12-08 06:10:04 +00:00
[dev.regabi] cmd/compile: introduce OMETHEXPR instead of overloading ONAME
A method expression today is an ONAME that has none of the invariants or properties of other ONAMEs and is always a special case (hence the Node.IsMethodExpression method). Remove the special cases by making a separate Op. Passes toolstash -cmp. Change-Id: I7667693c9155d5486a6924dbf75ebb59891c4afc Reviewed-on: https://go-review.googlesource.com/c/go/+/272867 Trust: Russ Cox <rsc@golang.org> Run-TryBot: Russ Cox <rsc@golang.org> TryBot-Result: Go Bot <gobot@golang.org> Reviewed-by: Matthew Dempsky <mdempsky@google.com>
This commit is contained in:
parent
4f9d54e41d
commit
ee6132a698
11 changed files with 60 additions and 65 deletions
|
|
@ -68,7 +68,7 @@ func (s *InitSchedule) tryStaticInit(n *Node) bool {
|
|||
// like staticassign but we are copying an already
|
||||
// initialized value r.
|
||||
func (s *InitSchedule) staticcopy(l *Node, r *Node) bool {
|
||||
if r.Op != ONAME {
|
||||
if r.Op != ONAME && r.Op != OMETHEXPR {
|
||||
return false
|
||||
}
|
||||
if r.Class() == PFUNC {
|
||||
|
|
@ -95,7 +95,7 @@ func (s *InitSchedule) staticcopy(l *Node, r *Node) bool {
|
|||
}
|
||||
|
||||
switch r.Op {
|
||||
case ONAME:
|
||||
case ONAME, OMETHEXPR:
|
||||
if s.staticcopy(l, r) {
|
||||
return true
|
||||
}
|
||||
|
|
@ -171,7 +171,7 @@ func (s *InitSchedule) staticassign(l *Node, r *Node) bool {
|
|||
}
|
||||
|
||||
switch r.Op {
|
||||
case ONAME:
|
||||
case ONAME, OMETHEXPR:
|
||||
return s.staticcopy(l, r)
|
||||
|
||||
case ONIL:
|
||||
|
|
@ -383,7 +383,7 @@ func readonlystaticname(t *types.Type) *Node {
|
|||
}
|
||||
|
||||
func (n *Node) isSimpleName() bool {
|
||||
return n.Op == ONAME && n.Class() != PAUTOHEAP && n.Class() != PEXTERN
|
||||
return (n.Op == ONAME || n.Op == OMETHEXPR) && n.Class() != PAUTOHEAP && n.Class() != PEXTERN
|
||||
}
|
||||
|
||||
func litas(l *Node, r *Node, init *Nodes) {
|
||||
|
|
@ -870,7 +870,7 @@ func anylit(n *Node, var_ *Node, init *Nodes) {
|
|||
default:
|
||||
Fatalf("anylit: not lit, op=%v node=%v", n.Op, n)
|
||||
|
||||
case ONAME:
|
||||
case ONAME, OMETHEXPR:
|
||||
a := nod(OAS, var_, n)
|
||||
a = typecheck(a, ctxStmt)
|
||||
init.Append(a)
|
||||
|
|
@ -1007,7 +1007,7 @@ func stataddr(nam *Node, n *Node) bool {
|
|||
}
|
||||
|
||||
switch n.Op {
|
||||
case ONAME:
|
||||
case ONAME, OMETHEXPR:
|
||||
*nam = *n
|
||||
return true
|
||||
|
||||
|
|
@ -1172,7 +1172,7 @@ func genAsStatic(as *Node) {
|
|||
switch {
|
||||
case as.Right.Op == OLITERAL:
|
||||
litsym(&nam, as.Right, int(as.Right.Type.Width))
|
||||
case as.Right.Op == ONAME && as.Right.Class() == PFUNC:
|
||||
case (as.Right.Op == ONAME || as.Right.Op == OMETHEXPR) && as.Right.Class() == PFUNC:
|
||||
pfuncsym(&nam, as.Right)
|
||||
default:
|
||||
Fatalf("genAsStatic: rhs %v", as.Right)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue