Commit 502a03ff authored by Josh Bleecher Snyder's avatar Josh Bleecher Snyder

cmd/compile: move Node.Typecheck to flags

Change-Id: Id5aa4a1499068bf2d3497b21d794f970b7e47fdf
Reviewed-on: https://go-review.googlesource.com/41795
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarBrad Fitzpatrick <bradfitz@golang.org>
parent e2560ace
...@@ -489,8 +489,8 @@ func (n *Node) jconv(s fmt.State, flag FmtFlag) { ...@@ -489,8 +489,8 @@ func (n *Node) jconv(s fmt.State, flag FmtFlag) {
fmt.Fprintf(s, " ld(%d)", e.Loopdepth) fmt.Fprintf(s, " ld(%d)", e.Loopdepth)
} }
if c == 0 && n.Typecheck != 0 { if c == 0 && n.Typecheck() != 0 {
fmt.Fprintf(s, " tc(%d)", n.Typecheck) fmt.Fprintf(s, " tc(%d)", n.Typecheck())
} }
if n.Isddd() { if n.Isddd() {
......
...@@ -359,7 +359,7 @@ func nodarg(t interface{}, fp int) *Node { ...@@ -359,7 +359,7 @@ func nodarg(t interface{}, fp int) *Node {
} }
} }
n.Typecheck = 1 n.SetTypecheck(1)
n.SetAddrtaken(true) // keep optimizers at bay n.SetAddrtaken(true) // keep optimizers at bay
return n return n
} }
......
...@@ -124,7 +124,7 @@ func caninl(fn *Node) { ...@@ -124,7 +124,7 @@ func caninl(fn *Node) {
return return
} }
if fn.Typecheck == 0 { if fn.Typecheck() == 0 {
Fatalf("caninl on non-typechecked function %v", fn) Fatalf("caninl on non-typechecked function %v", fn)
} }
...@@ -478,7 +478,7 @@ func inlnode(n *Node) *Node { ...@@ -478,7 +478,7 @@ func inlnode(n *Node) *Node {
if n.Op == OAS2FUNC && n.Rlist.First().Op == OINLCALL { if n.Op == OAS2FUNC && n.Rlist.First().Op == OINLCALL {
n.Rlist.Set(inlconv2list(n.Rlist.First())) n.Rlist.Set(inlconv2list(n.Rlist.First()))
n.Op = OAS2 n.Op = OAS2
n.Typecheck = 0 n.SetTypecheck(0)
n = typecheck(n, Etop) n = typecheck(n, Etop)
} else { } else {
s := n.Rlist.Slice() s := n.Rlist.Slice()
...@@ -757,7 +757,7 @@ func mkinlcall1(n *Node, fn *Node, isddd bool) *Node { ...@@ -757,7 +757,7 @@ func mkinlcall1(n *Node, fn *Node, isddd bool) *Node {
call.Nbody.Set(body) call.Nbody.Set(body)
call.Rlist.Set(retvars) call.Rlist.Set(retvars)
call.Type = n.Type call.Type = n.Type
call.Typecheck = 1 call.SetTypecheck(1)
// Hide the args from setPos -- the parameters to the inlined // Hide the args from setPos -- the parameters to the inlined
// call already have good line numbers that should be preserved. // call already have good line numbers that should be preserved.
......
...@@ -623,7 +623,7 @@ func appendinit(np **Node, init Nodes) { ...@@ -623,7 +623,7 @@ func appendinit(np **Node, init Nodes) {
n = nod(OCONVNOP, n, nil) n = nod(OCONVNOP, n, nil)
n.Type = n.Left.Type n.Type = n.Left.Type
n.Typecheck = 1 n.SetTypecheck(1)
*np = n *np = n
} }
......
...@@ -123,10 +123,10 @@ func typecheckrange(n *Node) { ...@@ -123,10 +123,10 @@ func typecheckrange(n *Node) {
// second half of dance // second half of dance
out: out:
n.Typecheck = 1 n.SetTypecheck(1)
ls = n.List.Slice() ls = n.List.Slice()
for i1, n1 := range ls { for i1, n1 := range ls {
if n1.Typecheck == 0 { if n1.Typecheck() == 0 {
ls[i1] = typecheck(ls[i1], Erv|Easgn) ls[i1] = typecheck(ls[i1], Erv|Easgn)
} }
} }
...@@ -231,9 +231,9 @@ func walkrange(n *Node) *Node { ...@@ -231,9 +231,9 @@ func walkrange(n *Node) *Node {
tmp := nod(OADD, hp, nodintconst(t.Elem().Width)) tmp := nod(OADD, hp, nodintconst(t.Elem().Width))
tmp.Type = hp.Type tmp.Type = hp.Type
tmp.Typecheck = 1 tmp.SetTypecheck(1)
tmp.Right.Type = types.Types[types.Tptr] tmp.Right.Type = types.Types[types.Tptr]
tmp.Right.Typecheck = 1 tmp.Right.SetTypecheck(1)
a = nod(OAS, hp, tmp) a = nod(OAS, hp, tmp)
a = typecheck(a, Etop) a = typecheck(a, Etop)
n.Right.Ninit.Set1(a) n.Right.Ninit.Set1(a)
...@@ -283,7 +283,7 @@ func walkrange(n *Node) *Node { ...@@ -283,7 +283,7 @@ func walkrange(n *Node) *Node {
n.Left = nil n.Left = nil
hv1 := temp(t.Elem()) hv1 := temp(t.Elem())
hv1.Typecheck = 1 hv1.SetTypecheck(1)
if types.Haspointers(t.Elem()) { if types.Haspointers(t.Elem()) {
init = append(init, nod(OAS, hv1, nil)) init = append(init, nod(OAS, hv1, nil))
} }
...@@ -291,7 +291,7 @@ func walkrange(n *Node) *Node { ...@@ -291,7 +291,7 @@ func walkrange(n *Node) *Node {
n.Left = nod(ONE, hb, nodbool(false)) n.Left = nod(ONE, hb, nodbool(false))
a := nod(OAS2RECV, nil, nil) a := nod(OAS2RECV, nil, nil)
a.Typecheck = 1 a.SetTypecheck(1)
a.List.Set2(hv1, hb) a.List.Set2(hv1, hb)
a.Rlist.Set1(nod(ORECV, ha, nil)) a.Rlist.Set1(nod(ORECV, ha, nil))
n.Left.Ninit.Set1(a) n.Left.Ninit.Set1(a)
......
...@@ -945,14 +945,14 @@ func typename(t *types.Type) *Node { ...@@ -945,14 +945,14 @@ func typename(t *types.Type) *Node {
n := newnamel(src.NoXPos, s) n := newnamel(src.NoXPos, s)
n.Type = types.Types[TUINT8] n.Type = types.Types[TUINT8]
n.Class = PEXTERN n.Class = PEXTERN
n.Typecheck = 1 n.SetTypecheck(1)
s.Def = asTypesNode(n) s.Def = asTypesNode(n)
} }
n := nod(OADDR, asNode(s.Def), nil) n := nod(OADDR, asNode(s.Def), nil)
n.Type = types.NewPtr(asNode(s.Def).Type) n.Type = types.NewPtr(asNode(s.Def).Type)
n.SetAddable(true) n.SetAddable(true)
n.Typecheck = 1 n.SetTypecheck(1)
return n return n
} }
...@@ -965,7 +965,7 @@ func itabname(t, itype *types.Type) *Node { ...@@ -965,7 +965,7 @@ func itabname(t, itype *types.Type) *Node {
n := newname(s) n := newname(s)
n.Type = types.Types[TUINT8] n.Type = types.Types[TUINT8]
n.Class = PEXTERN n.Class = PEXTERN
n.Typecheck = 1 n.SetTypecheck(1)
s.Def = asTypesNode(n) s.Def = asTypesNode(n)
itabs = append(itabs, itabEntry{t: t, itype: itype, lsym: s.Linksym()}) itabs = append(itabs, itabEntry{t: t, itype: itype, lsym: s.Linksym()})
} }
...@@ -973,7 +973,7 @@ func itabname(t, itype *types.Type) *Node { ...@@ -973,7 +973,7 @@ func itabname(t, itype *types.Type) *Node {
n := nod(OADDR, asNode(s.Def), nil) n := nod(OADDR, asNode(s.Def), nil)
n.Type = types.NewPtr(asNode(s.Def).Type) n.Type = types.NewPtr(asNode(s.Def).Type)
n.SetAddable(true) n.SetAddable(true)
n.Typecheck = 1 n.SetTypecheck(1)
return n return n
} }
...@@ -1822,12 +1822,12 @@ func zeroaddr(size int64) *Node { ...@@ -1822,12 +1822,12 @@ func zeroaddr(size int64) *Node {
x := newname(s) x := newname(s)
x.Type = types.Types[TUINT8] x.Type = types.Types[TUINT8]
x.Class = PEXTERN x.Class = PEXTERN
x.Typecheck = 1 x.SetTypecheck(1)
s.Def = asTypesNode(x) s.Def = asTypesNode(x)
} }
z := nod(OADDR, asNode(s.Def), nil) z := nod(OADDR, asNode(s.Def), nil)
z.Type = types.NewPtr(types.Types[TUINT8]) z.Type = types.NewPtr(types.Types[TUINT8])
z.SetAddable(true) z.SetAddable(true)
z.Typecheck = 1 z.SetTypecheck(1)
return z return z
} }
...@@ -74,7 +74,7 @@ func typecheckselect(sel *Node) { ...@@ -74,7 +74,7 @@ func typecheckselect(sel *Node) {
case ORECV: case ORECV:
n = nod(OSELRECV, nil, n) n = nod(OSELRECV, nil, n)
n.Typecheck = 1 n.SetTypecheck(1)
ncase.Left = n ncase.Left = n
case OSEND: case OSEND:
...@@ -150,7 +150,7 @@ func walkselect(sel *Node) { ...@@ -150,7 +150,7 @@ func walkselect(sel *Node) {
n.Rlist.Set1(n.Right) n.Rlist.Set1(n.Right)
n.Right = nil n.Right = nil
n.Left = nil n.Left = nil
n.Typecheck = 0 n.SetTypecheck(0)
n = typecheck(n, Etop) n = typecheck(n, Etop)
} }
......
...@@ -1083,7 +1083,7 @@ func anylit(n *Node, var_ *Node, init *Nodes) { ...@@ -1083,7 +1083,7 @@ func anylit(n *Node, var_ *Node, init *Nodes) {
r = typecheck(r, Erv) r = typecheck(r, Erv)
} else { } else {
r = nod(ONEW, nil, nil) r = nod(ONEW, nil, nil)
r.Typecheck = 1 r.SetTypecheck(1)
r.Type = t r.Type = t
r.Esc = n.Esc r.Esc = n.Esc
} }
......
...@@ -965,7 +965,7 @@ func assignconvfn(n *Node, t *types.Type, context func() string) *Node { ...@@ -965,7 +965,7 @@ func assignconvfn(n *Node, t *types.Type, context func() string) *Node {
if n.Op == ONAME || n.Op == OLITERAL { if n.Op == ONAME || n.Op == OLITERAL {
r := nod(OCONVNOP, n, nil) r := nod(OCONVNOP, n, nil)
r.Type = types.Types[TBOOL] r.Type = types.Types[TBOOL]
r.Typecheck = 1 r.SetTypecheck(1)
r.SetImplicit(true) r.SetImplicit(true)
n = r n = r
} }
...@@ -986,7 +986,7 @@ func assignconvfn(n *Node, t *types.Type, context func() string) *Node { ...@@ -986,7 +986,7 @@ func assignconvfn(n *Node, t *types.Type, context func() string) *Node {
r := nod(op, n, nil) r := nod(op, n, nil)
r.Type = t r.Type = t
r.Typecheck = 1 r.SetTypecheck(1)
r.SetImplicit(true) r.SetImplicit(true)
r.Orig = n.Orig r.Orig = n.Orig
return r return r
...@@ -1965,7 +1965,7 @@ func addinit(n *Node, init []*Node) *Node { ...@@ -1965,7 +1965,7 @@ func addinit(n *Node, init []*Node) *Node {
// Introduce OCONVNOP to hold init list. // Introduce OCONVNOP to hold init list.
n = nod(OCONVNOP, n, nil) n = nod(OCONVNOP, n, nil)
n.Type = n.Left.Type n.Type = n.Left.Type
n.Typecheck = 1 n.SetTypecheck(1)
} }
n.Ninit.Prepend(init...) n.Ninit.Prepend(init...)
...@@ -2029,7 +2029,7 @@ func checknil(x *Node, init *Nodes) { ...@@ -2029,7 +2029,7 @@ func checknil(x *Node, init *Nodes) {
} }
n := nod(OCHECKNIL, x, nil) n := nod(OCHECKNIL, x, nil)
n.Typecheck = 1 n.SetTypecheck(1)
init.Append(n) init.Append(n)
} }
...@@ -2061,7 +2061,7 @@ func isdirectiface(t *types.Type) bool { ...@@ -2061,7 +2061,7 @@ func isdirectiface(t *types.Type) bool {
func itabType(itab *Node) *Node { func itabType(itab *Node) *Node {
typ := nodSym(ODOTPTR, itab, nil) typ := nodSym(ODOTPTR, itab, nil)
typ.Type = types.NewPtr(types.Types[TUINT8]) typ.Type = types.NewPtr(types.Types[TUINT8])
typ.Typecheck = 1 typ.SetTypecheck(1)
typ.Xoffset = int64(Widthptr) // offset of _type in runtime.itab typ.Xoffset = int64(Widthptr) // offset of _type in runtime.itab
typ.SetBounded(true) // guaranteed not to fault typ.SetBounded(true) // guaranteed not to fault
return typ return typ
...@@ -2074,14 +2074,14 @@ func ifaceData(n *Node, t *types.Type) *Node { ...@@ -2074,14 +2074,14 @@ func ifaceData(n *Node, t *types.Type) *Node {
ptr := nodSym(OIDATA, n, nil) ptr := nodSym(OIDATA, n, nil)
if isdirectiface(t) { if isdirectiface(t) {
ptr.Type = t ptr.Type = t
ptr.Typecheck = 1 ptr.SetTypecheck(1)
return ptr return ptr
} }
ptr.Type = types.NewPtr(t) ptr.Type = types.NewPtr(t)
ptr.SetBounded(true) ptr.SetBounded(true)
ptr.Typecheck = 1 ptr.SetTypecheck(1)
ind := nod(OIND, ptr, nil) ind := nod(OIND, ptr, nil)
ind.Type = t ind.Type = t
ind.Typecheck = 1 ind.SetTypecheck(1)
return ind return ind
} }
...@@ -752,7 +752,7 @@ func (s *typeSwitch) walk(sw *Node) { ...@@ -752,7 +752,7 @@ func (s *typeSwitch) walk(sw *Node) {
// Load hash from type or itab. // Load hash from type or itab.
h := nodSym(ODOTPTR, itab, nil) h := nodSym(ODOTPTR, itab, nil)
h.Type = types.Types[TUINT32] h.Type = types.Types[TUINT32]
h.Typecheck = 1 h.SetTypecheck(1)
if cond.Right.Type.IsEmptyInterface() { if cond.Right.Type.IsEmptyInterface() {
h.Xoffset = int64(2 * Widthptr) // offset of hash in runtime._type h.Xoffset = int64(2 * Widthptr) // offset of hash in runtime._type
} else { } else {
......
...@@ -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
Typecheck uint8 // tracks state during typechecking; 2 == loop detected
} }
// IsAutoTmp indicates if n was created by the compiler as a temporary, // IsAutoTmp indicates if n was created by the compiler as a temporary,
...@@ -73,6 +72,8 @@ func (n *Node) IsAutoTmp() bool { ...@@ -73,6 +72,8 @@ func (n *Node) IsAutoTmp() bool {
const ( const (
nodeWalkdef, _ = iota, 1 << iota // tracks state during typecheckdef; 2 == loop detected; two bits nodeWalkdef, _ = iota, 1 << iota // tracks state during typecheckdef; 2 == loop detected; two bits
_, _ // second nodeWalkdef bit _, _ // second nodeWalkdef bit
nodeTypecheck, _ // tracks state during typechecking; 2 == loop detected; two bits
_, _ // second nodeTypecheck bit
nodeInitorder, _ // tracks state during init1; two bits nodeInitorder, _ // tracks state during init1; two bits
_, _ // second nodeInitorder bit _, _ // second nodeInitorder bit
_, nodeHasBreak _, nodeHasBreak
...@@ -99,6 +100,7 @@ const ( ...@@ -99,6 +100,7 @@ const (
) )
func (n *Node) Walkdef() uint8 { return n.flags.get2(nodeWalkdef) } func (n *Node) Walkdef() uint8 { return n.flags.get2(nodeWalkdef) }
func (n *Node) Typecheck() uint8 { return n.flags.get2(nodeTypecheck) }
func (n *Node) Initorder() uint8 { return n.flags.get2(nodeInitorder) } func (n *Node) Initorder() uint8 { return n.flags.get2(nodeInitorder) }
func (n *Node) HasBreak() bool { return n.flags&nodeHasBreak != 0 } func (n *Node) HasBreak() bool { return n.flags&nodeHasBreak != 0 }
...@@ -124,6 +126,7 @@ func (n *Node) HasOpt() bool { return n.flags&nodeHasOpt != 0 } ...@@ -124,6 +126,7 @@ func (n *Node) HasOpt() bool { return n.flags&nodeHasOpt != 0 }
func (n *Node) Embedded() bool { return n.flags&nodeEmbedded != 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) }
func (n *Node) SetTypecheck(b uint8) { n.flags.set2(nodeTypecheck, b) }
func (n *Node) SetInitorder(b uint8) { n.flags.set2(nodeInitorder, b) } func (n *Node) SetInitorder(b uint8) { n.flags.set2(nodeInitorder, b) }
func (n *Node) SetHasBreak(b bool) { n.flags.set(nodeHasBreak, b) } func (n *Node) SetHasBreak(b bool) { n.flags.set(nodeHasBreak, b) }
......
...@@ -144,7 +144,7 @@ func typecheck(n *Node, top int) *Node { ...@@ -144,7 +144,7 @@ func typecheck(n *Node, top int) *Node {
// Skip typecheck if already done. // Skip typecheck if already done.
// But re-typecheck ONAME/OTYPE/OLITERAL/OPACK node in case context has changed. // But re-typecheck ONAME/OTYPE/OLITERAL/OPACK node in case context has changed.
if n.Typecheck == 1 { if n.Typecheck() == 1 {
switch n.Op { switch n.Op {
case ONAME, OTYPE, OLITERAL, OPACK: case ONAME, OTYPE, OLITERAL, OPACK:
break break
...@@ -155,7 +155,7 @@ func typecheck(n *Node, top int) *Node { ...@@ -155,7 +155,7 @@ func typecheck(n *Node, top int) *Node {
} }
} }
if n.Typecheck == 2 { if n.Typecheck() == 2 {
// Typechecking loop. Trying printing a meaningful message, // Typechecking loop. Trying printing a meaningful message,
// otherwise a stack trace of typechecking. // otherwise a stack trace of typechecking.
switch n.Op { switch n.Op {
...@@ -195,12 +195,12 @@ func typecheck(n *Node, top int) *Node { ...@@ -195,12 +195,12 @@ func typecheck(n *Node, top int) *Node {
return n return n
} }
n.Typecheck = 2 n.SetTypecheck(2)
typecheck_tcstack = append(typecheck_tcstack, n) typecheck_tcstack = append(typecheck_tcstack, n)
n = typecheck1(n, top) n = typecheck1(n, top)
n.Typecheck = 1 n.SetTypecheck(1)
last := len(typecheck_tcstack) - 1 last := len(typecheck_tcstack) - 1
typecheck_tcstack[last] = nil typecheck_tcstack[last] = nil
...@@ -633,7 +633,7 @@ OpSwitch: ...@@ -633,7 +633,7 @@ OpSwitch:
if r.Type.IsInterface() == l.Type.IsInterface() || l.Type.Width >= 1<<16 { if r.Type.IsInterface() == l.Type.IsInterface() || l.Type.Width >= 1<<16 {
l = nod(aop, l, nil) l = nod(aop, l, nil)
l.Type = r.Type l.Type = r.Type
l.Typecheck = 1 l.SetTypecheck(1)
n.Left = l n.Left = l
} }
...@@ -655,7 +655,7 @@ OpSwitch: ...@@ -655,7 +655,7 @@ OpSwitch:
if r.Type.IsInterface() == l.Type.IsInterface() || r.Type.Width >= 1<<16 { if r.Type.IsInterface() == l.Type.IsInterface() || r.Type.Width >= 1<<16 {
r = nod(aop, r, nil) r = nod(aop, r, nil)
r.Type = l.Type r.Type = l.Type
r.Typecheck = 1 r.SetTypecheck(1)
n.Right = r n.Right = r
} }
...@@ -3149,10 +3149,10 @@ func typecheckcomplit(n *Node) *Node { ...@@ -3149,10 +3149,10 @@ func typecheckcomplit(n *Node) *Node {
n.Orig = norig n.Orig = norig
if n.Type.IsPtr() { if n.Type.IsPtr() {
n = nod(OPTRLIT, n, nil) n = nod(OPTRLIT, n, nil)
n.Typecheck = 1 n.SetTypecheck(1)
n.Type = n.Left.Type n.Type = n.Left.Type
n.Left.Type = t n.Left.Type = t
n.Left.Typecheck = 1 n.Left.SetTypecheck(1)
} }
n.Orig = norig n.Orig = norig
...@@ -3302,9 +3302,9 @@ func typecheckas(n *Node) { ...@@ -3302,9 +3302,9 @@ func typecheckas(n *Node) {
// second half of dance. // second half of dance.
// now that right is done, typecheck the left // now that right is done, typecheck the left
// just to get it over with. see dance above. // just to get it over with. see dance above.
n.Typecheck = 1 n.SetTypecheck(1)
if n.Left.Typecheck == 0 { if n.Left.Typecheck() == 0 {
n.Left = typecheck(n.Left, Erv|Easgn) n.Left = typecheck(n.Left, Erv|Easgn)
} }
} }
...@@ -3431,10 +3431,10 @@ mismatch: ...@@ -3431,10 +3431,10 @@ mismatch:
// second half of dance // second half of dance
out: out:
n.Typecheck = 1 n.SetTypecheck(1)
ls = n.List.Slice() ls = n.List.Slice()
for i1, n1 := range ls { for i1, n1 := range ls {
if n1.Typecheck == 0 { if n1.Typecheck() == 0 {
ls[i1] = typecheck(ls[i1], Erv|Easgn) ls[i1] = typecheck(ls[i1], Erv|Easgn)
} }
} }
...@@ -3571,7 +3571,7 @@ func typecheckdeftype(n *Node) { ...@@ -3571,7 +3571,7 @@ func typecheckdeftype(n *Node) {
lno := lineno lno := lineno
setlineno(n) setlineno(n)
n.Type.Sym = n.Sym n.Type.Sym = n.Sym
n.Typecheck = 1 n.SetTypecheck(1)
n.Name.Param.Ntype = typecheck(n.Name.Param.Ntype, Etype) n.Name.Param.Ntype = typecheck(n.Name.Param.Ntype, Etype)
t := n.Name.Param.Ntype.Type t := n.Name.Param.Ntype.Type
if t == nil { if t == nil {
......
...@@ -180,7 +180,7 @@ func walkstmt(n *Node) *Node { ...@@ -180,7 +180,7 @@ func walkstmt(n *Node) *Node {
OEMPTY, OEMPTY,
ORECOVER, ORECOVER,
OGETG: OGETG:
if n.Typecheck == 0 { if n.Typecheck() == 0 {
Fatalf("missing typecheck: %+v", n) Fatalf("missing typecheck: %+v", n)
} }
wascopy := n.Op == OCOPY wascopy := n.Op == OCOPY
...@@ -195,7 +195,7 @@ func walkstmt(n *Node) *Node { ...@@ -195,7 +195,7 @@ func walkstmt(n *Node) *Node {
// special case for a receive where we throw away // special case for a receive where we throw away
// the value received. // the value received.
case ORECV: case ORECV:
if n.Typecheck == 0 { if n.Typecheck() == 0 {
Fatalf("missing typecheck: %+v", n) Fatalf("missing typecheck: %+v", n)
} }
init := n.Ninit init := n.Ninit
...@@ -479,7 +479,7 @@ func walkexpr(n *Node, init *Nodes) *Node { ...@@ -479,7 +479,7 @@ func walkexpr(n *Node, init *Nodes) *Node {
Dump("walk-before", n) Dump("walk-before", n)
} }
if n.Typecheck != 1 { if n.Typecheck() != 1 {
Fatalf("missed typecheck: %+v", n) Fatalf("missed typecheck: %+v", n)
} }
...@@ -552,7 +552,7 @@ opswitch: ...@@ -552,7 +552,7 @@ opswitch:
if t.IsArray() { if t.IsArray() {
safeexpr(n.Left, init) safeexpr(n.Left, init)
nodconst(n, n.Type, t.NumElem()) nodconst(n, n.Type, t.NumElem())
n.Typecheck = 1 n.SetTypecheck(1)
} }
case OLSH, ORSH: case OLSH, ORSH:
...@@ -826,7 +826,7 @@ opswitch: ...@@ -826,7 +826,7 @@ opswitch:
// don't generate a = *var if a is _ // don't generate a = *var if a is _
if !isblank(a) { if !isblank(a) {
var_ := temp(types.NewPtr(t.Val())) var_ := temp(types.NewPtr(t.Val()))
var_.Typecheck = 1 var_.SetTypecheck(1)
var_.SetNonNil(true) // mapaccess always returns a non-nil pointer var_.SetNonNil(true) // mapaccess always returns a non-nil pointer
n.List.SetFirst(var_) n.List.SetFirst(var_)
n = walkexpr(n, init) n = walkexpr(n, init)
...@@ -869,7 +869,7 @@ opswitch: ...@@ -869,7 +869,7 @@ opswitch:
} }
l := nod(OEFACE, t, n.Left) l := nod(OEFACE, t, n.Left)
l.Type = n.Type l.Type = n.Type
l.Typecheck = n.Typecheck l.SetTypecheck(n.Typecheck())
n = l n = l
break break
} }
...@@ -917,7 +917,7 @@ opswitch: ...@@ -917,7 +917,7 @@ opswitch:
} }
l := nod(OEFACE, t, typecheck(nod(OADDR, value, nil), Erv)) l := nod(OEFACE, t, typecheck(nod(OADDR, value, nil), Erv))
l.Type = n.Type l.Type = n.Type
l.Typecheck = n.Typecheck l.SetTypecheck(n.Typecheck())
n = l n = l
break break
} }
...@@ -945,7 +945,7 @@ opswitch: ...@@ -945,7 +945,7 @@ opswitch:
// Build the result. // Build the result.
e := nod(OEFACE, tmp, ifaceData(c, types.NewPtr(types.Types[TUINT8]))) e := nod(OEFACE, tmp, ifaceData(c, types.NewPtr(types.Types[TUINT8])))
e.Type = n.Type // assign type manually, typecheck doesn't understand OEFACE. e.Type = n.Type // assign type manually, typecheck doesn't understand OEFACE.
e.Typecheck = 1 e.SetTypecheck(1)
n = e n = e
break break
} }
...@@ -1191,7 +1191,7 @@ opswitch: ...@@ -1191,7 +1191,7 @@ opswitch:
n.SetNonNil(true) // mapaccess1* and mapassign always return non-nil pointers. n.SetNonNil(true) // mapaccess1* and mapassign always return non-nil pointers.
n = nod(OIND, n, nil) n = nod(OIND, n, nil)
n.Type = t.Val() n.Type = t.Val()
n.Typecheck = 1 n.SetTypecheck(1)
case ORECV: case ORECV:
Fatalf("walkexpr ORECV") // should see inside OAS only Fatalf("walkexpr ORECV") // should see inside OAS only
...@@ -1596,8 +1596,8 @@ opswitch: ...@@ -1596,8 +1596,8 @@ opswitch:
rd := nod(OIDATA, n.Right, nil) rd := nod(OIDATA, n.Right, nil)
ld.Type = types.Types[TUNSAFEPTR] ld.Type = types.Types[TUNSAFEPTR]
rd.Type = types.Types[TUNSAFEPTR] rd.Type = types.Types[TUNSAFEPTR]
ld.Typecheck = 1 ld.SetTypecheck(1)
rd.Typecheck = 1 rd.SetTypecheck(1)
call := mkcall1(fn, n.Type, init, lt, ld, rd) call := mkcall1(fn, n.Type, init, lt, ld, rd)
// Check itable/type before full compare. // Check itable/type before full compare.
...@@ -1876,7 +1876,7 @@ func ascompatte(call *Node, isddd bool, lhs *types.Type, rhs []*Node, fp int, in ...@@ -1876,7 +1876,7 @@ func ascompatte(call *Node, isddd bool, lhs *types.Type, rhs []*Node, fp int, in
ret: ret:
for _, n := range nn { for _, n := range nn {
n.Typecheck = 1 n.SetTypecheck(1)
} }
return nn return nn
} }
...@@ -2111,7 +2111,7 @@ func convas(n *Node, init *Nodes) *Node { ...@@ -2111,7 +2111,7 @@ func convas(n *Node, init *Nodes) *Node {
Fatalf("convas: not OAS %v", n.Op) Fatalf("convas: not OAS %v", n.Op)
} }
n.Typecheck = 1 n.SetTypecheck(1)
var lt *types.Type var lt *types.Type
var rt *types.Type var rt *types.Type
...@@ -2622,7 +2622,7 @@ func byteindex(n *Node) *Node { ...@@ -2622,7 +2622,7 @@ func byteindex(n *Node) *Node {
} }
n = nod(OCONV, n, nil) n = nod(OCONV, n, nil)
n.Type = types.Types[TUINT8] n.Type = types.Types[TUINT8]
n.Typecheck = 1 n.SetTypecheck(1)
return n return n
} }
...@@ -3100,7 +3100,7 @@ func walkcompare(n *Node, init *Nodes) *Node { ...@@ -3100,7 +3100,7 @@ func walkcompare(n *Node, init *Nodes) *Node {
rtyp := typename(r.Type) rtyp := typename(r.Type)
if l.Type.IsEmptyInterface() { if l.Type.IsEmptyInterface() {
tab.Type = types.NewPtr(types.Types[TUINT8]) tab.Type = types.NewPtr(types.Types[TUINT8])
tab.Typecheck = 1 tab.SetTypecheck(1)
eqtype = nod(eq, tab, rtyp) eqtype = nod(eq, tab, rtyp)
} else { } else {
nonnil := nod(brcom(eq), nodnil(), tab) nonnil := nod(brcom(eq), nodnil(), tab)
...@@ -3236,7 +3236,7 @@ func finishcompare(n, r *Node, init *Nodes) *Node { ...@@ -3236,7 +3236,7 @@ func finishcompare(n, r *Node, init *Nodes) *Node {
if r.Type != n.Type { if r.Type != n.Type {
r = nod(OCONVNOP, r, nil) r = nod(OCONVNOP, r, nil)
r.Type = n.Type r.Type = n.Type
r.Typecheck = 1 r.SetTypecheck(1)
nn = r nn = r
} }
return nn return nn
......
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