fmt.Fprintf(s, " ld(%d)", e.Loopdepth)
}
- if c == 0 && n.Typecheck != 0 {
- fmt.Fprintf(s, " tc(%d)", n.Typecheck)
+ if c == 0 && n.Typecheck() != 0 {
+ fmt.Fprintf(s, " tc(%d)", n.Typecheck())
}
if n.Isddd() {
}
}
- n.Typecheck = 1
+ n.SetTypecheck(1)
n.SetAddrtaken(true) // keep optimizers at bay
return n
}
return
}
- if fn.Typecheck == 0 {
+ if fn.Typecheck() == 0 {
Fatalf("caninl on non-typechecked function %v", fn)
}
if n.Op == OAS2FUNC && n.Rlist.First().Op == OINLCALL {
n.Rlist.Set(inlconv2list(n.Rlist.First()))
n.Op = OAS2
- n.Typecheck = 0
+ n.SetTypecheck(0)
n = typecheck(n, Etop)
} else {
s := n.Rlist.Slice()
call.Nbody.Set(body)
call.Rlist.Set(retvars)
call.Type = n.Type
- call.Typecheck = 1
+ call.SetTypecheck(1)
// Hide the args from setPos -- the parameters to the inlined
// call already have good line numbers that should be preserved.
n = nod(OCONVNOP, n, nil)
n.Type = n.Left.Type
- n.Typecheck = 1
+ n.SetTypecheck(1)
*np = n
}
// second half of dance
out:
- n.Typecheck = 1
+ n.SetTypecheck(1)
ls = n.List.Slice()
for i1, n1 := range ls {
- if n1.Typecheck == 0 {
+ if n1.Typecheck() == 0 {
ls[i1] = typecheck(ls[i1], Erv|Easgn)
}
}
tmp := nod(OADD, hp, nodintconst(t.Elem().Width))
tmp.Type = hp.Type
- tmp.Typecheck = 1
+ tmp.SetTypecheck(1)
tmp.Right.Type = types.Types[types.Tptr]
- tmp.Right.Typecheck = 1
+ tmp.Right.SetTypecheck(1)
a = nod(OAS, hp, tmp)
a = typecheck(a, Etop)
n.Right.Ninit.Set1(a)
n.Left = nil
hv1 := temp(t.Elem())
- hv1.Typecheck = 1
+ hv1.SetTypecheck(1)
if types.Haspointers(t.Elem()) {
init = append(init, nod(OAS, hv1, nil))
}
n.Left = nod(ONE, hb, nodbool(false))
a := nod(OAS2RECV, nil, nil)
- a.Typecheck = 1
+ a.SetTypecheck(1)
a.List.Set2(hv1, hb)
a.Rlist.Set1(nod(ORECV, ha, nil))
n.Left.Ninit.Set1(a)
n := newnamel(src.NoXPos, s)
n.Type = types.Types[TUINT8]
n.Class = PEXTERN
- n.Typecheck = 1
+ n.SetTypecheck(1)
s.Def = asTypesNode(n)
}
n := nod(OADDR, asNode(s.Def), nil)
n.Type = types.NewPtr(asNode(s.Def).Type)
n.SetAddable(true)
- n.Typecheck = 1
+ n.SetTypecheck(1)
return n
}
n := newname(s)
n.Type = types.Types[TUINT8]
n.Class = PEXTERN
- n.Typecheck = 1
+ n.SetTypecheck(1)
s.Def = asTypesNode(n)
itabs = append(itabs, itabEntry{t: t, itype: itype, lsym: s.Linksym()})
}
n := nod(OADDR, asNode(s.Def), nil)
n.Type = types.NewPtr(asNode(s.Def).Type)
n.SetAddable(true)
- n.Typecheck = 1
+ n.SetTypecheck(1)
return n
}
x := newname(s)
x.Type = types.Types[TUINT8]
x.Class = PEXTERN
- x.Typecheck = 1
+ x.SetTypecheck(1)
s.Def = asTypesNode(x)
}
z := nod(OADDR, asNode(s.Def), nil)
z.Type = types.NewPtr(types.Types[TUINT8])
z.SetAddable(true)
- z.Typecheck = 1
+ z.SetTypecheck(1)
return z
}
case ORECV:
n = nod(OSELRECV, nil, n)
- n.Typecheck = 1
+ n.SetTypecheck(1)
ncase.Left = n
case OSEND:
n.Rlist.Set1(n.Right)
n.Right = nil
n.Left = nil
- n.Typecheck = 0
+ n.SetTypecheck(0)
n = typecheck(n, Etop)
}
r = typecheck(r, Erv)
} else {
r = nod(ONEW, nil, nil)
- r.Typecheck = 1
+ r.SetTypecheck(1)
r.Type = t
r.Esc = n.Esc
}
if n.Op == ONAME || n.Op == OLITERAL {
r := nod(OCONVNOP, n, nil)
r.Type = types.Types[TBOOL]
- r.Typecheck = 1
+ r.SetTypecheck(1)
r.SetImplicit(true)
n = r
}
r := nod(op, n, nil)
r.Type = t
- r.Typecheck = 1
+ r.SetTypecheck(1)
r.SetImplicit(true)
r.Orig = n.Orig
return r
// Introduce OCONVNOP to hold init list.
n = nod(OCONVNOP, n, nil)
n.Type = n.Left.Type
- n.Typecheck = 1
+ n.SetTypecheck(1)
}
n.Ninit.Prepend(init...)
}
n := nod(OCHECKNIL, x, nil)
- n.Typecheck = 1
+ n.SetTypecheck(1)
init.Append(n)
}
func itabType(itab *Node) *Node {
typ := nodSym(ODOTPTR, itab, nil)
typ.Type = types.NewPtr(types.Types[TUINT8])
- typ.Typecheck = 1
+ typ.SetTypecheck(1)
typ.Xoffset = int64(Widthptr) // offset of _type in runtime.itab
typ.SetBounded(true) // guaranteed not to fault
return typ
ptr := nodSym(OIDATA, n, nil)
if isdirectiface(t) {
ptr.Type = t
- ptr.Typecheck = 1
+ ptr.SetTypecheck(1)
return ptr
}
ptr.Type = types.NewPtr(t)
ptr.SetBounded(true)
- ptr.Typecheck = 1
+ ptr.SetTypecheck(1)
ind := nod(OIND, ptr, nil)
ind.Type = t
- ind.Typecheck = 1
+ ind.SetTypecheck(1)
return ind
}
// Load hash from type or itab.
h := nodSym(ODOTPTR, itab, nil)
h.Type = types.Types[TUINT32]
- h.Typecheck = 1
+ h.SetTypecheck(1)
if cond.Right.Type.IsEmptyInterface() {
h.Xoffset = int64(2 * Widthptr) // offset of hash in runtime._type
} else {
Esc uint16 // EscXXX
- 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
- Class Class // PPARAM, PAUTO, PEXTERN, etc
- Typecheck uint8 // tracks state during typechecking; 2 == loop detected
+ 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
+ Class Class // PPARAM, PAUTO, PEXTERN, etc
}
// IsAutoTmp indicates if n was created by the compiler as a temporary,
const (
nodeWalkdef, _ = iota, 1 << iota // tracks state during typecheckdef; 2 == loop detected; two bits
_, _ // second nodeWalkdef bit
+ nodeTypecheck, _ // tracks state during typechecking; 2 == loop detected; two bits
+ _, _ // second nodeTypecheck bit
nodeInitorder, _ // tracks state during init1; two bits
_, _ // second nodeInitorder bit
_, nodeHasBreak
)
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) HasBreak() bool { return n.flags&nodeHasBreak != 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) SetTypecheck(b uint8) { n.flags.set2(nodeTypecheck, b) }
func (n *Node) SetInitorder(b uint8) { n.flags.set2(nodeInitorder, b) }
func (n *Node) SetHasBreak(b bool) { n.flags.set(nodeHasBreak, b) }
// Skip typecheck if already done.
// But re-typecheck ONAME/OTYPE/OLITERAL/OPACK node in case context has changed.
- if n.Typecheck == 1 {
+ if n.Typecheck() == 1 {
switch n.Op {
case ONAME, OTYPE, OLITERAL, OPACK:
break
}
}
- if n.Typecheck == 2 {
+ if n.Typecheck() == 2 {
// Typechecking loop. Trying printing a meaningful message,
// otherwise a stack trace of typechecking.
switch n.Op {
return n
}
- n.Typecheck = 2
+ n.SetTypecheck(2)
typecheck_tcstack = append(typecheck_tcstack, n)
n = typecheck1(n, top)
- n.Typecheck = 1
+ n.SetTypecheck(1)
last := len(typecheck_tcstack) - 1
typecheck_tcstack[last] = nil
if r.Type.IsInterface() == l.Type.IsInterface() || l.Type.Width >= 1<<16 {
l = nod(aop, l, nil)
l.Type = r.Type
- l.Typecheck = 1
+ l.SetTypecheck(1)
n.Left = l
}
if r.Type.IsInterface() == l.Type.IsInterface() || r.Type.Width >= 1<<16 {
r = nod(aop, r, nil)
r.Type = l.Type
- r.Typecheck = 1
+ r.SetTypecheck(1)
n.Right = r
}
n.Orig = norig
if n.Type.IsPtr() {
n = nod(OPTRLIT, n, nil)
- n.Typecheck = 1
+ n.SetTypecheck(1)
n.Type = n.Left.Type
n.Left.Type = t
- n.Left.Typecheck = 1
+ n.Left.SetTypecheck(1)
}
n.Orig = norig
// second half of dance.
// now that right is done, typecheck the left
// 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)
}
}
// second half of dance
out:
- n.Typecheck = 1
+ n.SetTypecheck(1)
ls = n.List.Slice()
for i1, n1 := range ls {
- if n1.Typecheck == 0 {
+ if n1.Typecheck() == 0 {
ls[i1] = typecheck(ls[i1], Erv|Easgn)
}
}
lno := lineno
setlineno(n)
n.Type.Sym = n.Sym
- n.Typecheck = 1
+ n.SetTypecheck(1)
n.Name.Param.Ntype = typecheck(n.Name.Param.Ntype, Etype)
t := n.Name.Param.Ntype.Type
if t == nil {
OEMPTY,
ORECOVER,
OGETG:
- if n.Typecheck == 0 {
+ if n.Typecheck() == 0 {
Fatalf("missing typecheck: %+v", n)
}
wascopy := n.Op == OCOPY
// special case for a receive where we throw away
// the value received.
case ORECV:
- if n.Typecheck == 0 {
+ if n.Typecheck() == 0 {
Fatalf("missing typecheck: %+v", n)
}
init := n.Ninit
Dump("walk-before", n)
}
- if n.Typecheck != 1 {
+ if n.Typecheck() != 1 {
Fatalf("missed typecheck: %+v", n)
}
if t.IsArray() {
safeexpr(n.Left, init)
nodconst(n, n.Type, t.NumElem())
- n.Typecheck = 1
+ n.SetTypecheck(1)
}
case OLSH, ORSH:
// don't generate a = *var if a is _
if !isblank(a) {
var_ := temp(types.NewPtr(t.Val()))
- var_.Typecheck = 1
+ var_.SetTypecheck(1)
var_.SetNonNil(true) // mapaccess always returns a non-nil pointer
n.List.SetFirst(var_)
n = walkexpr(n, init)
}
l := nod(OEFACE, t, n.Left)
l.Type = n.Type
- l.Typecheck = n.Typecheck
+ l.SetTypecheck(n.Typecheck())
n = l
break
}
}
l := nod(OEFACE, t, typecheck(nod(OADDR, value, nil), Erv))
l.Type = n.Type
- l.Typecheck = n.Typecheck
+ l.SetTypecheck(n.Typecheck())
n = l
break
}
// Build the result.
e := nod(OEFACE, tmp, ifaceData(c, types.NewPtr(types.Types[TUINT8])))
e.Type = n.Type // assign type manually, typecheck doesn't understand OEFACE.
- e.Typecheck = 1
+ e.SetTypecheck(1)
n = e
break
}
n.SetNonNil(true) // mapaccess1* and mapassign always return non-nil pointers.
n = nod(OIND, n, nil)
n.Type = t.Val()
- n.Typecheck = 1
+ n.SetTypecheck(1)
case ORECV:
Fatalf("walkexpr ORECV") // should see inside OAS only
rd := nod(OIDATA, n.Right, nil)
ld.Type = types.Types[TUNSAFEPTR]
rd.Type = types.Types[TUNSAFEPTR]
- ld.Typecheck = 1
- rd.Typecheck = 1
+ ld.SetTypecheck(1)
+ rd.SetTypecheck(1)
call := mkcall1(fn, n.Type, init, lt, ld, rd)
// Check itable/type before full compare.
ret:
for _, n := range nn {
- n.Typecheck = 1
+ n.SetTypecheck(1)
}
return nn
}
Fatalf("convas: not OAS %v", n.Op)
}
- n.Typecheck = 1
+ n.SetTypecheck(1)
var lt *types.Type
var rt *types.Type
}
n = nod(OCONV, n, nil)
n.Type = types.Types[TUINT8]
- n.Typecheck = 1
+ n.SetTypecheck(1)
return n
}
rtyp := typename(r.Type)
if l.Type.IsEmptyInterface() {
tab.Type = types.NewPtr(types.Types[TUINT8])
- tab.Typecheck = 1
+ tab.SetTypecheck(1)
eqtype = nod(eq, tab, rtyp)
} else {
nonnil := nod(brcom(eq), nodnil(), tab)
if r.Type != n.Type {
r = nod(OCONVNOP, r, nil)
r.Type = n.Type
- r.Typecheck = 1
+ r.SetTypecheck(1)
nn = r
}
return nn