Commit af7da9a5 authored by Josh Bleecher Snyder's avatar Josh Bleecher Snyder

cmd/compile: convert Node.Embedded into a flag

Change-Id: I30c59ba84dcacc3de39c42f94484b47bb7c36eba
Reviewed-on: https://go-review.googlesource.com/41792
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
parent 7a92395d
...@@ -570,7 +570,7 @@ func structfield(n *Node) *types.Field { ...@@ -570,7 +570,7 @@ func structfield(n *Node) *types.Field {
if n.Left != nil { if n.Left != nil {
n.Left.Type = n.Type n.Left.Type = n.Type
} }
if n.Embedded != 0 { if n.Embedded() {
checkembeddedtype(n.Type) checkembeddedtype(n.Type)
} }
} }
...@@ -593,7 +593,11 @@ func structfield(n *Node) *types.Field { ...@@ -593,7 +593,11 @@ func structfield(n *Node) *types.Field {
if n.Left != nil && n.Left.Op == ONAME { if n.Left != nil && n.Left.Op == ONAME {
f.Nname = asTypesNode(n.Left) f.Nname = asTypesNode(n.Left)
f.Embedded = n.Embedded if n.Embedded() {
f.Embedded = 1
} else {
f.Embedded = 0
}
f.Sym = asNode(f.Nname).Sym f.Sym = asNode(f.Nname).Sym
} }
...@@ -779,7 +783,7 @@ func embedded(s *types.Sym, pkg *types.Pkg) *Node { ...@@ -779,7 +783,7 @@ func embedded(s *types.Sym, pkg *types.Pkg) *Node {
n = newname(s.Pkg.Lookup(name)) n = newname(s.Pkg.Lookup(name))
} }
n = nod(ODCLFIELD, n, oldname(s)) n = nod(ODCLFIELD, n, oldname(s))
n.Embedded = 1 n.SetEmbedded(true)
return n return n
} }
......
...@@ -501,8 +501,8 @@ func (n *Node) jconv(s fmt.State, flag FmtFlag) { ...@@ -501,8 +501,8 @@ func (n *Node) jconv(s fmt.State, flag FmtFlag) {
fmt.Fprintf(s, " implicit(%v)", n.Implicit()) fmt.Fprintf(s, " implicit(%v)", n.Implicit())
} }
if n.Embedded != 0 { if n.Embedded() {
fmt.Fprintf(s, " embedded(%d)", n.Embedded) fmt.Fprintf(s, " embedded")
} }
if n.Addrtaken() { if n.Addrtaken() {
......
...@@ -58,7 +58,6 @@ type Node struct { ...@@ -58,7 +58,6 @@ type Node struct {
Op Op Op Op
Etype types.EType // op for OASOP, etype for OTYPE, exclam for export, 6g saved reg, ChanDir for OTCHAN, for OINDEXMAP 1=LHS,0=RHS Etype types.EType // op for OASOP, etype for OTYPE, exclam for export, 6g saved reg, ChanDir for OTCHAN, for OINDEXMAP 1=LHS,0=RHS
Class Class // PPARAM, PAUTO, PEXTERN, etc Class Class // PPARAM, PAUTO, PEXTERN, etc
Embedded uint8 // ODCLFIELD embedded type
Typecheck uint8 // tracks state during typechecking; 2 == loop detected Typecheck uint8 // tracks state during typechecking; 2 == loop detected
Initorder uint8 Initorder uint8
} }
...@@ -95,6 +94,7 @@ const ( ...@@ -95,6 +94,7 @@ const (
_, nodeLikely // if statement condition likely _, nodeLikely // if statement condition likely
_, nodeHasVal // node.E contains a Val _, nodeHasVal // node.E contains a Val
_, nodeHasOpt // node.E contains an Opt _, nodeHasOpt // node.E contains an Opt
_, nodeEmbedded // ODCLFIELD embedded type
) )
func (n *Node) Walkdef() uint8 { return n.flags.get2(nodeWalkdef) } func (n *Node) Walkdef() uint8 { return n.flags.get2(nodeWalkdef) }
...@@ -119,6 +119,7 @@ func (n *Node) HasCall() bool { return n.flags&nodeHasCall != 0 } ...@@ -119,6 +119,7 @@ func (n *Node) HasCall() bool { return n.flags&nodeHasCall != 0 }
func (n *Node) Likely() bool { return n.flags&nodeLikely != 0 } func (n *Node) Likely() bool { return n.flags&nodeLikely != 0 }
func (n *Node) HasVal() bool { return n.flags&nodeHasVal != 0 } func (n *Node) HasVal() bool { return n.flags&nodeHasVal != 0 }
func (n *Node) HasOpt() bool { return n.flags&nodeHasOpt != 0 } func (n *Node) HasOpt() bool { return n.flags&nodeHasOpt != 0 }
func (n *Node) Embedded() bool { return n.flags&nodeEmbedded != 0 }
func (n *Node) SetWalkdef(b uint8) { n.flags.set2(nodeWalkdef, b) } func (n *Node) SetWalkdef(b uint8) { n.flags.set2(nodeWalkdef, b) }
...@@ -142,6 +143,7 @@ func (n *Node) SetHasCall(b bool) { n.flags.set(nodeHasCall, b) } ...@@ -142,6 +143,7 @@ func (n *Node) SetHasCall(b bool) { n.flags.set(nodeHasCall, b) }
func (n *Node) SetLikely(b bool) { n.flags.set(nodeLikely, b) } func (n *Node) SetLikely(b bool) { n.flags.set(nodeLikely, b) }
func (n *Node) SetHasVal(b bool) { n.flags.set(nodeHasVal, b) } func (n *Node) SetHasVal(b bool) { n.flags.set(nodeHasVal, b) }
func (n *Node) SetHasOpt(b bool) { n.flags.set(nodeHasOpt, b) } func (n *Node) SetHasOpt(b bool) { n.flags.set(nodeHasOpt, b) }
func (n *Node) SetEmbedded(b bool) { n.flags.set(nodeEmbedded, b) }
// Val returns the Val for the node. // Val returns the Val for the node.
func (n *Node) Val() Val { func (n *Node) Val() Val {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment