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

cmd/compile: bulk rename

This change does a bulk rename of several identifiers in the compiler.
See #27167 and https://docs.google.com/document/d/19_ExiylD9MRfeAjKIfEsMU1_RGhuxB9sA0b5Zv7byVI/
for context and for discussion of these particular renames.

Commands run to generate this change:

gorename -from '"cmd/compile/internal/gc".OPROC' -to OGO
gorename -from '"cmd/compile/internal/gc".OCOM' -to OBITNOT
gorename -from '"cmd/compile/internal/gc".OMINUS' -to ONEG
gorename -from '"cmd/compile/internal/gc".OIND' -to ODEREF
gorename -from '"cmd/compile/internal/gc".OARRAYBYTESTR' -to OBYTES2STR
gorename -from '"cmd/compile/internal/gc".OARRAYBYTESTRTMP' -to OBYTES2STRTMP
gorename -from '"cmd/compile/internal/gc".OARRAYRUNESTR' -to ORUNES2STR
gorename -from '"cmd/compile/internal/gc".OSTRARRAYBYTE' -to OSTR2BYTES
gorename -from '"cmd/compile/internal/gc".OSTRARRAYBYTETMP' -to OSTR2BYTESTMP
gorename -from '"cmd/compile/internal/gc".OSTRARRAYRUNE' -to OSTR2RUNES

gorename -from '"cmd/compile/internal/gc".Etop' -to ctxStmt
gorename -from '"cmd/compile/internal/gc".Erv' -to ctxExpr
gorename -from '"cmd/compile/internal/gc".Ecall' -to ctxCallee
gorename -from '"cmd/compile/internal/gc".Efnstruct' -to ctxMultiOK
gorename -from '"cmd/compile/internal/gc".Easgn' -to ctxAssign
gorename -from '"cmd/compile/internal/gc".Ecomplit' -to ctxCompLit

Not altered: parameters and local variables (mostly in typecheck.go) named top,
which should probably now be called ctx (and which should probably have a named type).
Also not altered: Field called Top in gc.Func.

gorename -from '"cmd/compile/internal/gc".Node.Isddd' -to IsDDD
gorename -from '"cmd/compile/internal/gc".Node.SetIsddd' -to SetIsDDD
gorename -from '"cmd/compile/internal/gc".nodeIsddd' -to nodeIsDDD
gorename -from '"cmd/compile/internal/types".Field.Isddd' -to IsDDD
gorename -from '"cmd/compile/internal/types".Field.SetIsddd' -to SetIsDDD
gorename -from '"cmd/compile/internal/types".fieldIsddd' -to fieldIsDDD

Not altered: function gc.hasddd, params and local variables called isddd
Also not altered: fmt.go prints nodes using "isddd(%v)".

cd cmd/compile/internal/gc; go generate

I then manually found impacted comments using exact string match
and fixed them up by hand. The comment changes were trivial.

Passes toolstash-check.

Fixes #27167. If this experiment is deemed a success,
we will open a new tracking issue for renames to do
at the end of the 1.13 cycles.

Change-Id: I2dc541533d2ab0d06cb3d31d65df205ecfb151e8
Reviewed-on: https://go-review.googlesource.com/c/150140
Run-TryBot: Josh Bleecher Snyder <josharian@gmail.com>
Reviewed-by: default avatarMatthew Dempsky <mdempsky@google.com>
parent 404ab866
...@@ -217,7 +217,7 @@ func genhash(sym *types.Sym, t *types.Type) { ...@@ -217,7 +217,7 @@ func genhash(sym *types.Sym, t *types.Type) {
// pure memory. // pure memory.
hashel := hashfor(t.Elem()) hashel := hashfor(t.Elem())
n := nod(ORANGE, nil, nod(OIND, np, nil)) n := nod(ORANGE, nil, nod(ODEREF, np, nil))
ni := newname(lookup("i")) ni := newname(lookup("i"))
ni.Type = types.Types[TINT] ni.Type = types.Types[TINT]
n.List.Set1(ni) n.List.Set1(ni)
...@@ -290,10 +290,10 @@ func genhash(sym *types.Sym, t *types.Type) { ...@@ -290,10 +290,10 @@ func genhash(sym *types.Sym, t *types.Type) {
funcbody() funcbody()
fn.Func.SetDupok(true) fn.Func.SetDupok(true)
fn = typecheck(fn, Etop) fn = typecheck(fn, ctxStmt)
Curfn = fn Curfn = fn
typecheckslice(fn.Nbody.Slice(), Etop) typecheckslice(fn.Nbody.Slice(), ctxStmt)
Curfn = nil Curfn = nil
if debug_dclstack != 0 { if debug_dclstack != 0 {
...@@ -375,7 +375,7 @@ func geneq(sym *types.Sym, t *types.Type) { ...@@ -375,7 +375,7 @@ func geneq(sym *types.Sym, t *types.Type) {
// pure memory. Even if we unrolled the range loop, // pure memory. Even if we unrolled the range loop,
// each iteration would be a function call, so don't bother // each iteration would be a function call, so don't bother
// unrolling. // unrolling.
nrange := nod(ORANGE, nil, nod(OIND, np, nil)) nrange := nod(ORANGE, nil, nod(ODEREF, np, nil))
ni := newname(lookup("i")) ni := newname(lookup("i"))
ni.Type = types.Types[TINT] ni.Type = types.Types[TINT]
...@@ -465,10 +465,10 @@ func geneq(sym *types.Sym, t *types.Type) { ...@@ -465,10 +465,10 @@ func geneq(sym *types.Sym, t *types.Type) {
funcbody() funcbody()
fn.Func.SetDupok(true) fn.Func.SetDupok(true)
fn = typecheck(fn, Etop) fn = typecheck(fn, ctxStmt)
Curfn = fn Curfn = fn
typecheckslice(fn.Nbody.Slice(), Etop) typecheckslice(fn.Nbody.Slice(), ctxStmt)
Curfn = nil Curfn = nil
if debug_dclstack != 0 { if debug_dclstack != 0 {
...@@ -497,8 +497,8 @@ func eqfield(p *Node, q *Node, field *types.Sym) *Node { ...@@ -497,8 +497,8 @@ func eqfield(p *Node, q *Node, field *types.Sym) *Node {
func eqmem(p *Node, q *Node, field *types.Sym, size int64) *Node { func eqmem(p *Node, q *Node, field *types.Sym, size int64) *Node {
nx := nod(OADDR, nodSym(OXDOT, p, field), nil) nx := nod(OADDR, nodSym(OXDOT, p, field), nil)
ny := nod(OADDR, nodSym(OXDOT, q, field), nil) ny := nod(OADDR, nodSym(OXDOT, q, field), nil)
nx = typecheck(nx, Erv) nx = typecheck(nx, ctxExpr)
ny = typecheck(ny, Erv) ny = typecheck(ny, ctxExpr)
fn, needsize := eqmemfunc(size, nx.Type.Elem()) fn, needsize := eqmemfunc(size, nx.Type.Elem())
call := nod(OCALL, fn, nil) call := nod(OCALL, fn, nil)
......
...@@ -93,7 +93,7 @@ func typecheckclosure(clo *Node, top int) { ...@@ -93,7 +93,7 @@ func typecheckclosure(clo *Node, top int) {
xfunc.Func.Nname.Sym = closurename(Curfn) xfunc.Func.Nname.Sym = closurename(Curfn)
disableExport(xfunc.Func.Nname.Sym) disableExport(xfunc.Func.Nname.Sym)
declare(xfunc.Func.Nname, PFUNC) declare(xfunc.Func.Nname, PFUNC)
xfunc = typecheck(xfunc, Etop) xfunc = typecheck(xfunc, ctxStmt)
clo.Func.Ntype = typecheck(clo.Func.Ntype, Etype) clo.Func.Ntype = typecheck(clo.Func.Ntype, Etype)
clo.Type = clo.Func.Ntype.Type clo.Type = clo.Func.Ntype.Type
...@@ -108,7 +108,7 @@ func typecheckclosure(clo *Node, top int) { ...@@ -108,7 +108,7 @@ func typecheckclosure(clo *Node, top int) {
Curfn = xfunc Curfn = xfunc
olddd := decldepth olddd := decldepth
decldepth = 1 decldepth = 1
typecheckslice(xfunc.Nbody.Slice(), Etop) typecheckslice(xfunc.Nbody.Slice(), ctxStmt)
decldepth = olddd decldepth = olddd
Curfn = oldfn Curfn = oldfn
} }
...@@ -199,7 +199,7 @@ func capturevars(xfunc *Node) { ...@@ -199,7 +199,7 @@ func capturevars(xfunc *Node) {
Warnl(v.Pos, "%v capturing by %s: %v (addr=%v assign=%v width=%d)", name, how, v.Sym, outermost.Addrtaken(), outermost.Assigned(), int32(v.Type.Width)) Warnl(v.Pos, "%v capturing by %s: %v (addr=%v assign=%v width=%d)", name, how, v.Sym, outermost.Addrtaken(), outermost.Assigned(), int32(v.Type.Width))
} }
outer = typecheck(outer, Erv) outer = typecheck(outer, ctxExpr)
clo.Func.Enter.Append(outer) clo.Func.Enter.Append(outer)
} }
...@@ -214,7 +214,7 @@ func transformclosure(xfunc *Node) { ...@@ -214,7 +214,7 @@ func transformclosure(xfunc *Node) {
lineno = xfunc.Pos lineno = xfunc.Pos
clo := xfunc.Func.Closure clo := xfunc.Func.Closure
if clo.Func.Top&Ecall != 0 { if clo.Func.Top&ctxCallee != 0 {
// If the closure is directly called, we transform it to a plain function call // If the closure is directly called, we transform it to a plain function call
// with variables passed as args. This avoids allocation of a closure object. // with variables passed as args. This avoids allocation of a closure object.
// Here we do only a part of the transformation. Walk of OCALLFUNC(OCLOSURE) // Here we do only a part of the transformation. Walk of OCALLFUNC(OCLOSURE)
...@@ -305,7 +305,7 @@ func transformclosure(xfunc *Node) { ...@@ -305,7 +305,7 @@ func transformclosure(xfunc *Node) {
} }
if len(body) > 0 { if len(body) > 0 {
typecheckslice(body, Etop) typecheckslice(body, ctxStmt)
xfunc.Func.Enter.Set(body) xfunc.Func.Enter.Set(body)
xfunc.Func.SetNeedctxt(true) xfunc.Func.SetNeedctxt(true)
} }
...@@ -383,7 +383,7 @@ func walkclosure(clo *Node, init *Nodes) *Node { ...@@ -383,7 +383,7 @@ func walkclosure(clo *Node, init *Nodes) *Node {
typ := closureType(clo) typ := closureType(clo)
clos := nod(OCOMPLIT, nil, nod(OIND, typenod(typ), nil)) clos := nod(OCOMPLIT, nil, nod(ODEREF, typenod(typ), nil))
clos.Esc = clo.Esc clos.Esc = clo.Esc
clos.Right.SetImplicit(true) clos.Right.SetImplicit(true)
clos.List.Set(append([]*Node{nod(OCFUNC, xfunc.Func.Nname, nil)}, clo.Func.Enter.Slice()...)) clos.List.Set(append([]*Node{nod(OCFUNC, xfunc.Func.Nname, nil)}, clo.Func.Enter.Slice()...))
...@@ -467,7 +467,7 @@ func makepartialcall(fn *Node, t0 *types.Type, meth *types.Sym) *Node { ...@@ -467,7 +467,7 @@ func makepartialcall(fn *Node, t0 *types.Type, meth *types.Sym) *Node {
call := nod(OCALL, nodSym(OXDOT, ptr, meth), nil) call := nod(OCALL, nodSym(OXDOT, ptr, meth), nil)
call.List.Set(paramNnames(tfn.Type)) call.List.Set(paramNnames(tfn.Type))
call.SetIsddd(tfn.Type.IsVariadic()) call.SetIsDDD(tfn.Type.IsVariadic())
if t0.NumResults() != 0 { if t0.NumResults() != 0 {
n := nod(ORETURN, nil, nil) n := nod(ORETURN, nil, nil)
n.List.Set1(call) n.List.Set1(call)
...@@ -478,7 +478,7 @@ func makepartialcall(fn *Node, t0 *types.Type, meth *types.Sym) *Node { ...@@ -478,7 +478,7 @@ func makepartialcall(fn *Node, t0 *types.Type, meth *types.Sym) *Node {
xfunc.Nbody.Set(body) xfunc.Nbody.Set(body)
funcbody() funcbody()
xfunc = typecheck(xfunc, Etop) xfunc = typecheck(xfunc, ctxStmt)
sym.Def = asTypesNode(xfunc) sym.Def = asTypesNode(xfunc)
xtop = append(xtop, xfunc) xtop = append(xtop, xfunc)
Curfn = savecurfn Curfn = savecurfn
...@@ -516,7 +516,7 @@ func walkpartialcall(n *Node, init *Nodes) *Node { ...@@ -516,7 +516,7 @@ func walkpartialcall(n *Node, init *Nodes) *Node {
typ := partialCallType(n) typ := partialCallType(n)
clos := nod(OCOMPLIT, nil, nod(OIND, typenod(typ), nil)) clos := nod(OCOMPLIT, nil, nod(ODEREF, typenod(typ), nil))
clos.Esc = n.Esc clos.Esc = n.Esc
clos.Right.SetImplicit(true) clos.Right.SetImplicit(true)
clos.List.Set2(nod(OCFUNC, n.Func.Nname, nil), n.Left) clos.List.Set2(nod(OCFUNC, n.Func.Nname, nil), n.Left)
......
...@@ -588,7 +588,7 @@ func evconst(n *Node) { ...@@ -588,7 +588,7 @@ func evconst(n *Node) {
// Pick off just the opcodes that can be constant evaluated. // Pick off just the opcodes that can be constant evaluated.
switch op := n.Op; op { switch op := n.Op; op {
case OPLUS, OMINUS, OCOM, ONOT: case OPLUS, ONEG, OBITNOT, ONOT:
if nl.Op == OLITERAL { if nl.Op == OLITERAL {
setconst(n, unaryOp(op, nl.Val(), n.Type)) setconst(n, unaryOp(op, nl.Val(), n.Type))
} }
...@@ -623,7 +623,7 @@ func evconst(n *Node) { ...@@ -623,7 +623,7 @@ func evconst(n *Node) {
setconst(n, convlit1(nl, n.Type, true, false).Val()) setconst(n, convlit1(nl, n.Type, true, false).Val())
} }
case OARRAYBYTESTR: case OBYTES2STR:
// string([]byte(nil)) or string([]rune(nil)) // string([]byte(nil)) or string([]rune(nil))
if nl.Op == OLITERAL && nl.Val().Ctype() == CTNIL { if nl.Op == OLITERAL && nl.Val().Ctype() == CTNIL {
setconst(n, Val{U: ""}) setconst(n, Val{U: ""})
...@@ -873,7 +873,7 @@ func unaryOp(op Op, x Val, t *types.Type) Val { ...@@ -873,7 +873,7 @@ func unaryOp(op Op, x Val, t *types.Type) Val {
return x return x
} }
case OMINUS: case ONEG:
switch x.Ctype() { switch x.Ctype() {
case CTINT, CTRUNE: case CTINT, CTRUNE:
x := x.U.(*Mpint) x := x.U.(*Mpint)
...@@ -900,7 +900,7 @@ func unaryOp(op Op, x Val, t *types.Type) Val { ...@@ -900,7 +900,7 @@ func unaryOp(op Op, x Val, t *types.Type) Val {
return Val{U: u} return Val{U: u}
} }
case OCOM: case OBITNOT:
x := x.U.(*Mpint) x := x.U.(*Mpint)
u := new(Mpint) u := new(Mpint)
...@@ -1024,9 +1024,9 @@ func idealkind(n *Node) Ctype { ...@@ -1024,9 +1024,9 @@ func idealkind(n *Node) Ctype {
case OADD, case OADD,
OAND, OAND,
OANDNOT, OANDNOT,
OCOM, OBITNOT,
ODIV, ODIV,
OMINUS, ONEG,
OMOD, OMOD,
OMUL, OMUL,
OSUB, OSUB,
...@@ -1281,7 +1281,7 @@ func (n *Node) isGoConst() bool { ...@@ -1281,7 +1281,7 @@ func (n *Node) isGoConst() bool {
OAND, OAND,
OANDAND, OANDAND,
OANDNOT, OANDNOT,
OCOM, OBITNOT,
ODIV, ODIV,
OEQ, OEQ,
OGE, OGE,
...@@ -1289,7 +1289,7 @@ func (n *Node) isGoConst() bool { ...@@ -1289,7 +1289,7 @@ func (n *Node) isGoConst() bool {
OLE, OLE,
OLSH, OLSH,
OLT, OLT,
OMINUS, ONEG,
OMOD, OMOD,
OMUL, OMUL,
ONE, ONE,
......
...@@ -283,7 +283,7 @@ func oldname(s *types.Sym) *Node { ...@@ -283,7 +283,7 @@ func oldname(s *types.Sym) *Node {
c = newname(s) c = newname(s)
c.SetClass(PAUTOHEAP) c.SetClass(PAUTOHEAP)
c.SetIsClosureVar(true) c.SetIsClosureVar(true)
c.SetIsddd(n.Isddd()) c.SetIsDDD(n.IsDDD())
c.Name.Defn = n c.Name.Defn = n
c.SetAddable(false) c.SetAddable(false)
...@@ -455,7 +455,7 @@ func funcarg(n *Node, ctxt Class) { ...@@ -455,7 +455,7 @@ func funcarg(n *Node, ctxt Class) {
n.Right = newnamel(n.Pos, n.Sym) n.Right = newnamel(n.Pos, n.Sym)
n.Right.Name.Param.Ntype = n.Left n.Right.Name.Param.Ntype = n.Left
n.Right.SetIsddd(n.Isddd()) n.Right.SetIsDDD(n.IsDDD())
declare(n.Right, ctxt) declare(n.Right, ctxt)
vargen++ vargen++
...@@ -488,7 +488,7 @@ func funcarg2(f *types.Field, ctxt Class) { ...@@ -488,7 +488,7 @@ func funcarg2(f *types.Field, ctxt Class) {
n := newnamel(f.Pos, f.Sym) n := newnamel(f.Pos, f.Sym)
f.Nname = asTypesNode(n) f.Nname = asTypesNode(n)
n.Type = f.Type n.Type = f.Type
n.SetIsddd(f.Isddd()) n.SetIsDDD(f.IsDDD())
declare(n, ctxt) declare(n, ctxt)
} }
...@@ -628,7 +628,7 @@ func tofunargs(l []*Node, funarg types.Funarg) *types.Type { ...@@ -628,7 +628,7 @@ func tofunargs(l []*Node, funarg types.Funarg) *types.Type {
fields := make([]*types.Field, len(l)) fields := make([]*types.Field, len(l))
for i, n := range l { for i, n := range l {
f := structfield(n) f := structfield(n)
f.SetIsddd(n.Isddd()) f.SetIsDDD(n.IsDDD())
if n.Right != nil { if n.Right != nil {
n.Right.Type = f.Type n.Right.Type = f.Type
f.Nname = asTypesNode(n.Right) f.Nname = asTypesNode(n.Right)
......
...@@ -671,7 +671,7 @@ func (e *EscState) isSliceSelfAssign(dst, src *Node) bool { ...@@ -671,7 +671,7 @@ func (e *EscState) isSliceSelfAssign(dst, src *Node) bool {
// when we evaluate it for dst and for src. // when we evaluate it for dst and for src.
// dst is ONAME dereference. // dst is ONAME dereference.
if dst.Op != OIND && dst.Op != ODOTPTR || dst.Left.Op != ONAME { if dst.Op != ODEREF && dst.Op != ODOTPTR || dst.Left.Op != ONAME {
return false return false
} }
// src is a slice operation. // src is a slice operation.
...@@ -695,7 +695,7 @@ func (e *EscState) isSliceSelfAssign(dst, src *Node) bool { ...@@ -695,7 +695,7 @@ func (e *EscState) isSliceSelfAssign(dst, src *Node) bool {
return false return false
} }
// slice is applied to ONAME dereference. // slice is applied to ONAME dereference.
if src.Left.Op != OIND && src.Left.Op != ODOTPTR || src.Left.Left.Op != ONAME { if src.Left.Op != ODEREF && src.Left.Op != ODOTPTR || src.Left.Left.Op != ONAME {
return false return false
} }
// dst and src reference the same base ONAME. // dst and src reference the same base ONAME.
...@@ -757,8 +757,8 @@ func (e *EscState) mayAffectMemory(n *Node) bool { ...@@ -757,8 +757,8 @@ func (e *EscState) mayAffectMemory(n *Node) bool {
return e.mayAffectMemory(n.Left) || e.mayAffectMemory(n.Right) return e.mayAffectMemory(n.Left) || e.mayAffectMemory(n.Right)
// Left group. // Left group.
case ODOT, ODOTPTR, OIND, OCONVNOP, OCONV, OLEN, OCAP, case ODOT, ODOTPTR, ODEREF, OCONVNOP, OCONV, OLEN, OCAP,
ONOT, OCOM, OPLUS, OMINUS, OALIGNOF, OOFFSETOF, OSIZEOF: ONOT, OBITNOT, OPLUS, ONEG, OALIGNOF, OOFFSETOF, OSIZEOF:
return e.mayAffectMemory(n.Left) return e.mayAffectMemory(n.Left)
default: default:
...@@ -935,7 +935,7 @@ opSwitch: ...@@ -935,7 +935,7 @@ opSwitch:
e.escassignSinkWhy(n, arg, "defer func arg") e.escassignSinkWhy(n, arg, "defer func arg")
} }
case OPROC: case OGO:
// go f(x) - f and x escape // go f(x) - f and x escape
e.escassignSinkWhy(n, n.Left.Left, "go func") e.escassignSinkWhy(n, n.Left.Left, "go func")
e.escassignSinkWhy(n, n.Left.Right, "go func ...") // ODDDARG for call e.escassignSinkWhy(n, n.Left.Right, "go func ...") // ODDDARG for call
...@@ -991,7 +991,7 @@ opSwitch: ...@@ -991,7 +991,7 @@ opSwitch:
e.escassignSinkWhy(n, n.Left, "panic") e.escassignSinkWhy(n, n.Left, "panic")
case OAPPEND: case OAPPEND:
if !n.Isddd() { if !n.IsDDD() {
for _, nn := range n.List.Slice()[1:] { for _, nn := range n.List.Slice()[1:] {
e.escassignSinkWhy(n, nn, "appended to slice") // lose track of assign to dereference e.escassignSinkWhy(n, nn, "appended to slice") // lose track of assign to dereference
} }
...@@ -1072,7 +1072,7 @@ opSwitch: ...@@ -1072,7 +1072,7 @@ opSwitch:
a = nod(OADDR, a, nil) a = nod(OADDR, a, nil)
a.Pos = v.Pos a.Pos = v.Pos
e.nodeEscState(a).Loopdepth = e.loopdepth e.nodeEscState(a).Loopdepth = e.loopdepth
a = typecheck(a, Erv) a = typecheck(a, ctxExpr)
} }
e.escassignWhyWhere(n, a, "captured by a closure", n) e.escassignWhyWhere(n, a, "captured by a closure", n)
...@@ -1083,10 +1083,10 @@ opSwitch: ...@@ -1083,10 +1083,10 @@ opSwitch:
OMAKEMAP, OMAKEMAP,
OMAKESLICE, OMAKESLICE,
ONEW, ONEW,
OARRAYRUNESTR, ORUNES2STR,
OARRAYBYTESTR, OBYTES2STR,
OSTRARRAYRUNE, OSTR2RUNES,
OSTRARRAYBYTE, OSTR2BYTES,
ORUNESTR: ORUNESTR:
e.track(n) e.track(n)
...@@ -1223,7 +1223,7 @@ func (e *EscState) escassign(dst, src *Node, step *EscStep) { ...@@ -1223,7 +1223,7 @@ func (e *EscState) escassign(dst, src *Node, step *EscStep) {
dstwhy = "slice-element-equals" dstwhy = "slice-element-equals"
dst = &e.theSink // lose track of dereference dst = &e.theSink // lose track of dereference
case OIND: case ODEREF:
dstwhy = "star-equals" dstwhy = "star-equals"
dst = &e.theSink // lose track of dereference dst = &e.theSink // lose track of dereference
...@@ -1243,7 +1243,7 @@ func (e *EscState) escassign(dst, src *Node, step *EscStep) { ...@@ -1243,7 +1243,7 @@ func (e *EscState) escassign(dst, src *Node, step *EscStep) {
switch src.Op { switch src.Op {
case OADDR, // dst = &x case OADDR, // dst = &x
OIND, // dst = *x ODEREF, // dst = *x
ODOTPTR, // dst = (*x).f ODOTPTR, // dst = (*x).f
ONAME, ONAME,
ODDDARG, ODDDARG,
...@@ -1255,10 +1255,10 @@ func (e *EscState) escassign(dst, src *Node, step *EscStep) { ...@@ -1255,10 +1255,10 @@ func (e *EscState) escassign(dst, src *Node, step *EscStep) {
OMAKECHAN, OMAKECHAN,
OMAKEMAP, OMAKEMAP,
OMAKESLICE, OMAKESLICE,
OARRAYRUNESTR, ORUNES2STR,
OARRAYBYTESTR, OBYTES2STR,
OSTRARRAYRUNE, OSTR2RUNES,
OSTRARRAYBYTE, OSTR2BYTES,
OADDSTR, OADDSTR,
ONEW, ONEW,
OCALLPART, OCALLPART,
...@@ -1293,7 +1293,7 @@ func (e *EscState) escassign(dst, src *Node, step *EscStep) { ...@@ -1293,7 +1293,7 @@ func (e *EscState) escassign(dst, src *Node, step *EscStep) {
case OCONV, case OCONV,
OCONVNOP, OCONVNOP,
ODOTMETH, ODOTMETH,
// treat recv.meth as a value with recv in it, only happens in ODEFER and OPROC // treat recv.meth as a value with recv in it, only happens in ODEFER and OGO
// iface.method already leaks iface in esccall, no need to put in extra ODOTINTER edge here // iface.method already leaks iface in esccall, no need to put in extra ODOTINTER edge here
OSLICE, OSLICE,
OSLICE3, OSLICE3,
...@@ -1338,8 +1338,8 @@ func (e *EscState) escassign(dst, src *Node, step *EscStep) { ...@@ -1338,8 +1338,8 @@ func (e *EscState) escassign(dst, src *Node, step *EscStep) {
OAND, OAND,
OANDNOT, OANDNOT,
OPLUS, OPLUS,
OMINUS, ONEG,
OCOM: OBITNOT:
e.escassign(dst, src.Left, e.stepAssign(step, originalDst, src, dstwhy)) e.escassign(dst, src.Left, e.stepAssign(step, originalDst, src, dstwhy))
e.escassign(dst, src.Right, e.stepAssign(step, originalDst, src, dstwhy)) e.escassign(dst, src.Right, e.stepAssign(step, originalDst, src, dstwhy))
...@@ -1500,16 +1500,16 @@ func (e *EscState) escassignDereference(dst *Node, src *Node, step *EscStep) { ...@@ -1500,16 +1500,16 @@ func (e *EscState) escassignDereference(dst *Node, src *Node, step *EscStep) {
e.escassign(dst, e.addDereference(src), step) e.escassign(dst, e.addDereference(src), step)
} }
// addDereference constructs a suitable OIND note applied to src. // addDereference constructs a suitable ODEREF note applied to src.
// Because this is for purposes of escape accounting, not execution, // Because this is for purposes of escape accounting, not execution,
// some semantically dubious node combinations are (currently) possible. // some semantically dubious node combinations are (currently) possible.
func (e *EscState) addDereference(n *Node) *Node { func (e *EscState) addDereference(n *Node) *Node {
ind := nod(OIND, n, nil) ind := nod(ODEREF, n, nil)
e.nodeEscState(ind).Loopdepth = e.nodeEscState(n).Loopdepth e.nodeEscState(ind).Loopdepth = e.nodeEscState(n).Loopdepth
ind.Pos = n.Pos ind.Pos = n.Pos
t := n.Type t := n.Type
if t.IsPtr() || t.IsSlice() { if t.IsPtr() || t.IsSlice() {
// This should model our own sloppy use of OIND to encode // This should model our own sloppy use of ODEREF to encode
// decreasing levels of indirection; i.e., "indirecting" a slice // decreasing levels of indirection; i.e., "indirecting" a slice
// yields the type of an element. // yields the type of an element.
t = t.Elem() t = t.Elem()
...@@ -1665,7 +1665,7 @@ func (e *EscState) esccall(call *Node, parent *Node) { ...@@ -1665,7 +1665,7 @@ func (e *EscState) esccall(call *Node, parent *Node) {
continue continue
} }
arg := args[0] arg := args[0]
if n.Isddd() && !call.Isddd() { if n.IsDDD() && !call.IsDDD() {
// Introduce ODDDARG node to represent ... allocation. // Introduce ODDDARG node to represent ... allocation.
arg = nod(ODDDARG, nil, nil) arg = nod(ODDDARG, nil, nil)
arr := types.NewArray(n.Type.Elem(), int64(len(args))) arr := types.NewArray(n.Type.Elem(), int64(len(args)))
...@@ -1722,7 +1722,7 @@ func (e *EscState) esccall(call *Node, parent *Node) { ...@@ -1722,7 +1722,7 @@ func (e *EscState) esccall(call *Node, parent *Node) {
for i, param := range fntype.Params().FieldSlice() { for i, param := range fntype.Params().FieldSlice() {
note := param.Note note := param.Note
var arg *Node var arg *Node
if param.Isddd() && !call.Isddd() { if param.IsDDD() && !call.IsDDD() {
rest := args[i:] rest := args[i:]
if len(rest) == 0 { if len(rest) == 0 {
break break
...@@ -1754,7 +1754,7 @@ func (e *EscState) esccall(call *Node, parent *Node) { ...@@ -1754,7 +1754,7 @@ func (e *EscState) esccall(call *Node, parent *Node) {
} }
} }
if types.Haspointers(param.Type) && e.escassignfromtag(note, cE.Retval, arg, call)&EscMask == EscNone && parent.Op != ODEFER && parent.Op != OPROC { if types.Haspointers(param.Type) && e.escassignfromtag(note, cE.Retval, arg, call)&EscMask == EscNone && parent.Op != ODEFER && parent.Op != OGO {
a := arg a := arg
for a.Op == OCONVNOP { for a.Op == OCONVNOP {
a = a.Left a = a.Left
...@@ -2057,10 +2057,10 @@ func (e *EscState) escwalkBody(level Level, dst *Node, src *Node, step *EscStep, ...@@ -2057,10 +2057,10 @@ func (e *EscState) escwalkBody(level Level, dst *Node, src *Node, step *EscStep,
case OMAKECHAN, case OMAKECHAN,
OMAKEMAP, OMAKEMAP,
OMAKESLICE, OMAKESLICE,
OARRAYRUNESTR, ORUNES2STR,
OARRAYBYTESTR, OBYTES2STR,
OSTRARRAYRUNE, OSTR2RUNES,
OSTRARRAYBYTE, OSTR2BYTES,
OADDSTR, OADDSTR,
OMAPLIT, OMAPLIT,
ONEW, ONEW,
...@@ -2100,7 +2100,7 @@ func (e *EscState) escwalkBody(level Level, dst *Node, src *Node, step *EscStep, ...@@ -2100,7 +2100,7 @@ func (e *EscState) escwalkBody(level Level, dst *Node, src *Node, step *EscStep,
e.escwalk(level.inc(), dst, src.Left, e.stepWalk(dst, src.Left, "dot of pointer", step)) e.escwalk(level.inc(), dst, src.Left, e.stepWalk(dst, src.Left, "dot of pointer", step))
case OINDEXMAP: case OINDEXMAP:
e.escwalk(level.inc(), dst, src.Left, e.stepWalk(dst, src.Left, "map index", step)) e.escwalk(level.inc(), dst, src.Left, e.stepWalk(dst, src.Left, "map index", step))
case OIND: case ODEREF:
e.escwalk(level.inc(), dst, src.Left, e.stepWalk(dst, src.Left, "indirection", step)) e.escwalk(level.inc(), dst, src.Left, e.stepWalk(dst, src.Left, "indirection", step))
// In this case a link went directly to a call, but should really go // In this case a link went directly to a call, but should really go
...@@ -2142,7 +2142,7 @@ func addrescapes(n *Node) { ...@@ -2142,7 +2142,7 @@ func addrescapes(n *Node) {
default: default:
// Unexpected Op, probably due to a previous type error. Ignore. // Unexpected Op, probably due to a previous type error. Ignore.
case OIND, ODOTPTR: case ODEREF, ODOTPTR:
// Nothing to do. // Nothing to do.
case ONAME: case ONAME:
...@@ -2347,7 +2347,7 @@ func (e *EscState) esctag(fn *Node) { ...@@ -2347,7 +2347,7 @@ func (e *EscState) esctag(fn *Node) {
f.Note = uintptrEscapesTag f.Note = uintptrEscapesTag
} }
if f.Isddd() && f.Type.Elem().Etype == TUINTPTR { if f.IsDDD() && f.Type.Elem().Etype == TUINTPTR {
// final argument is ...uintptr. // final argument is ...uintptr.
if Debug['m'] != 0 { if Debug['m'] != 0 {
Warnl(fn.Pos, "%v marking %v as escaping ...uintptr", funcSym(fn), name(f.Sym, narg)) Warnl(fn.Pos, "%v marking %v as escaping ...uintptr", funcSym(fn), name(f.Sym, narg))
......
...@@ -159,7 +159,7 @@ var goopnames = []string{ ...@@ -159,7 +159,7 @@ var goopnames = []string{
OCASE: "case", OCASE: "case",
OCLOSE: "close", OCLOSE: "close",
OCOMPLEX: "complex", OCOMPLEX: "complex",
OCOM: "^", OBITNOT: "^",
OCONTINUE: "continue", OCONTINUE: "continue",
OCOPY: "copy", OCOPY: "copy",
ODELETE: "delete", ODELETE: "delete",
...@@ -174,13 +174,13 @@ var goopnames = []string{ ...@@ -174,13 +174,13 @@ var goopnames = []string{
OGT: ">", OGT: ">",
OIF: "if", OIF: "if",
OIMAG: "imag", OIMAG: "imag",
OIND: "*", ODEREF: "*",
OLEN: "len", OLEN: "len",
OLE: "<=", OLE: "<=",
OLSH: "<<", OLSH: "<<",
OLT: "<", OLT: "<",
OMAKE: "make", OMAKE: "make",
OMINUS: "-", ONEG: "-",
OMOD: "%", OMOD: "%",
OMUL: "*", OMUL: "*",
ONEW: "new", ONEW: "new",
...@@ -464,8 +464,8 @@ func (n *Node) jconv(s fmt.State, flag FmtFlag) { ...@@ -464,8 +464,8 @@ func (n *Node) jconv(s fmt.State, flag FmtFlag) {
fmt.Fprintf(s, " tc(%d)", n.Typecheck()) fmt.Fprintf(s, " tc(%d)", n.Typecheck())
} }
if n.Isddd() { if n.IsDDD() {
fmt.Fprintf(s, " isddd(%v)", n.Isddd()) fmt.Fprintf(s, " isddd(%v)", n.IsDDD())
} }
if n.Implicit() { if n.Implicit() {
...@@ -942,7 +942,7 @@ func (n *Node) stmtfmt(s fmt.State, mode fmtMode) { ...@@ -942,7 +942,7 @@ func (n *Node) stmtfmt(s fmt.State, mode fmtMode) {
case ORETJMP: case ORETJMP:
mode.Fprintf(s, "retjmp %v", n.Sym) mode.Fprintf(s, "retjmp %v", n.Sym)
case OPROC: case OGO:
mode.Fprintf(s, "go %v", n.Left) mode.Fprintf(s, "go %v", n.Left)
case ODEFER: case ODEFER:
...@@ -1066,10 +1066,10 @@ func (n *Node) stmtfmt(s fmt.State, mode fmtMode) { ...@@ -1066,10 +1066,10 @@ func (n *Node) stmtfmt(s fmt.State, mode fmtMode) {
var opprec = []int{ var opprec = []int{
OALIGNOF: 8, OALIGNOF: 8,
OAPPEND: 8, OAPPEND: 8,
OARRAYBYTESTR: 8, OBYTES2STR: 8,
OARRAYLIT: 8, OARRAYLIT: 8,
OSLICELIT: 8, OSLICELIT: 8,
OARRAYRUNESTR: 8, ORUNES2STR: 8,
OCALLFUNC: 8, OCALLFUNC: 8,
OCALLINTER: 8, OCALLINTER: 8,
OCALLMETH: 8, OCALLMETH: 8,
...@@ -1098,8 +1098,8 @@ var opprec = []int{ ...@@ -1098,8 +1098,8 @@ var opprec = []int{
OPRINT: 8, OPRINT: 8,
ORUNESTR: 8, ORUNESTR: 8,
OSIZEOF: 8, OSIZEOF: 8,
OSTRARRAYBYTE: 8, OSTR2BYTES: 8,
OSTRARRAYRUNE: 8, OSTR2RUNES: 8,
OSTRUCTLIT: 8, OSTRUCTLIT: 8,
OTARRAY: 8, OTARRAY: 8,
OTCHAN: 8, OTCHAN: 8,
...@@ -1125,10 +1125,10 @@ var opprec = []int{ ...@@ -1125,10 +1125,10 @@ var opprec = []int{
OCALLPART: 8, OCALLPART: 8,
OPLUS: 7, OPLUS: 7,
ONOT: 7, ONOT: 7,
OCOM: 7, OBITNOT: 7,
OMINUS: 7, ONEG: 7,
OADDR: 7, OADDR: 7,
OIND: 7, ODEREF: 7,
ORECV: 7, ORECV: 7,
OMUL: 6, OMUL: 6,
ODIV: 6, ODIV: 6,
...@@ -1172,7 +1172,7 @@ var opprec = []int{ ...@@ -1172,7 +1172,7 @@ var opprec = []int{
OGOTO: -1, OGOTO: -1,
OIF: -1, OIF: -1,
OLABEL: -1, OLABEL: -1,
OPROC: -1, OGO: -1,
ORANGE: -1, ORANGE: -1,
ORETURN: -1, ORETURN: -1,
OSELECT: -1, OSELECT: -1,
...@@ -1183,7 +1183,7 @@ var opprec = []int{ ...@@ -1183,7 +1183,7 @@ var opprec = []int{
} }
func (n *Node) exprfmt(s fmt.State, prec int, mode fmtMode) { func (n *Node) exprfmt(s fmt.State, prec int, mode fmtMode) {
for n != nil && n.Implicit() && (n.Op == OIND || n.Op == OADDR) { for n != nil && n.Implicit() && (n.Op == ODEREF || n.Op == OADDR) {
n = n.Left n = n.Left
} }
...@@ -1406,10 +1406,10 @@ func (n *Node) exprfmt(s fmt.State, prec int, mode fmtMode) { ...@@ -1406,10 +1406,10 @@ func (n *Node) exprfmt(s fmt.State, prec int, mode fmtMode) {
case OCONV, case OCONV,
OCONVIFACE, OCONVIFACE,
OCONVNOP, OCONVNOP,
OARRAYBYTESTR, OBYTES2STR,
OARRAYRUNESTR, ORUNES2STR,
OSTRARRAYBYTE, OSTR2BYTES,
OSTRARRAYRUNE, OSTR2RUNES,
ORUNESTR: ORUNESTR:
if n.Type == nil || n.Type.Sym == nil { if n.Type == nil || n.Type.Sym == nil {
mode.Fprintf(s, "(%v)", n.Type) mode.Fprintf(s, "(%v)", n.Type)
...@@ -1442,7 +1442,7 @@ func (n *Node) exprfmt(s fmt.State, prec int, mode fmtMode) { ...@@ -1442,7 +1442,7 @@ func (n *Node) exprfmt(s fmt.State, prec int, mode fmtMode) {
mode.Fprintf(s, "%#v(%v)", n.Op, n.Left) mode.Fprintf(s, "%#v(%v)", n.Op, n.Left)
return return
} }
if n.Isddd() { if n.IsDDD() {
mode.Fprintf(s, "%#v(%.v...)", n.Op, n.List) mode.Fprintf(s, "%#v(%.v...)", n.Op, n.List)
return return
} }
...@@ -1450,7 +1450,7 @@ func (n *Node) exprfmt(s fmt.State, prec int, mode fmtMode) { ...@@ -1450,7 +1450,7 @@ func (n *Node) exprfmt(s fmt.State, prec int, mode fmtMode) {
case OCALL, OCALLFUNC, OCALLINTER, OCALLMETH, OGETG: case OCALL, OCALLFUNC, OCALLINTER, OCALLMETH, OGETG:
n.Left.exprfmt(s, nprec, mode) n.Left.exprfmt(s, nprec, mode)
if n.Isddd() { if n.IsDDD() {
mode.Fprintf(s, "(%.v...)", n.List) mode.Fprintf(s, "(%.v...)", n.List)
return return
} }
...@@ -1471,7 +1471,7 @@ func (n *Node) exprfmt(s fmt.State, prec int, mode fmtMode) { ...@@ -1471,7 +1471,7 @@ func (n *Node) exprfmt(s fmt.State, prec int, mode fmtMode) {
} }
mode.Fprintf(s, "make(%v)", n.Type) mode.Fprintf(s, "make(%v)", n.Type)
case OPLUS, OMINUS, OADDR, OCOM, OIND, ONOT, ORECV: case OPLUS, ONEG, OADDR, OBITNOT, ODEREF, ONOT, ORECV:
// Unary // Unary
mode.Fprintf(s, "%#v", n.Op) mode.Fprintf(s, "%#v", n.Op)
if n.Left != nil && n.Left.Op == n.Op { if n.Left != nil && n.Left.Op == n.Op {
...@@ -1694,7 +1694,7 @@ func fldconv(f *types.Field, flag FmtFlag, mode fmtMode, depth int, funarg types ...@@ -1694,7 +1694,7 @@ func fldconv(f *types.Field, flag FmtFlag, mode fmtMode, depth int, funarg types
} }
var typ string var typ string
if f.Isddd() { if f.IsDDD() {
var et *types.Type var et *types.Type
if f.Type != nil { if f.Type != nil {
et = f.Type.Elem() et = f.Type.Elem()
......
...@@ -439,7 +439,7 @@ func (p *iexporter) doDecl(n *Node) { ...@@ -439,7 +439,7 @@ func (p *iexporter) doDecl(n *Node) {
case OLITERAL: case OLITERAL:
// Constant. // Constant.
n = typecheck(n, Erv) n = typecheck(n, ctxExpr)
w.tag('C') w.tag('C')
w.pos(n.Pos) w.pos(n.Pos)
w.value(n.Type, n.Val()) w.value(n.Type, n.Val())
...@@ -707,7 +707,7 @@ func (w *exportWriter) signature(t *types.Type) { ...@@ -707,7 +707,7 @@ func (w *exportWriter) signature(t *types.Type) {
w.paramList(t.Params().FieldSlice()) w.paramList(t.Params().FieldSlice())
w.paramList(t.Results().FieldSlice()) w.paramList(t.Results().FieldSlice())
if n := t.Params().NumFields(); n > 0 { if n := t.Params().NumFields(); n > 0 {
w.bool(t.Params().Field(n - 1).Isddd()) w.bool(t.Params().Field(n - 1).IsDDD())
} }
} }
...@@ -1047,7 +1047,7 @@ func (w *exportWriter) stmt(n *Node) { ...@@ -1047,7 +1047,7 @@ func (w *exportWriter) stmt(n *Node) {
// case ORETJMP: // case ORETJMP:
// unreachable - generated by compiler for trampolin routines // unreachable - generated by compiler for trampolin routines
case OPROC, ODEFER: case OGO, ODEFER:
w.op(op) w.op(op)
w.pos(n.Pos) w.pos(n.Pos)
w.expr(n.Left) w.expr(n.Left)
...@@ -1127,7 +1127,7 @@ func (w *exportWriter) expr(n *Node) { ...@@ -1127,7 +1127,7 @@ func (w *exportWriter) expr(n *Node) {
// } // }
// from exprfmt (fmt.go) // from exprfmt (fmt.go)
for n.Op == OPAREN || n.Implicit() && (n.Op == OIND || n.Op == OADDR || n.Op == ODOT || n.Op == ODOTPTR) { for n.Op == OPAREN || n.Implicit() && (n.Op == ODEREF || n.Op == OADDR || n.Op == ODOT || n.Op == ODOTPTR) {
n = n.Left n = n.Left
} }
...@@ -1252,7 +1252,7 @@ func (w *exportWriter) expr(n *Node) { ...@@ -1252,7 +1252,7 @@ func (w *exportWriter) expr(n *Node) {
w.expr(n.Right) w.expr(n.Right)
w.op(OEND) w.op(OEND)
case OCONV, OCONVIFACE, OCONVNOP, OARRAYBYTESTR, OARRAYRUNESTR, OSTRARRAYBYTE, OSTRARRAYRUNE, ORUNESTR: case OCONV, OCONVIFACE, OCONVNOP, OBYTES2STR, ORUNES2STR, OSTR2BYTES, OSTR2RUNES, ORUNESTR:
w.op(OCONV) w.op(OCONV)
w.pos(n.Pos) w.pos(n.Pos)
w.expr(n.Left) w.expr(n.Left)
...@@ -1269,8 +1269,8 @@ func (w *exportWriter) expr(n *Node) { ...@@ -1269,8 +1269,8 @@ func (w *exportWriter) expr(n *Node) {
} }
// only append() calls may contain '...' arguments // only append() calls may contain '...' arguments
if op == OAPPEND { if op == OAPPEND {
w.bool(n.Isddd()) w.bool(n.IsDDD())
} else if n.Isddd() { } else if n.IsDDD() {
Fatalf("exporter: unexpected '...' with %v call", op) Fatalf("exporter: unexpected '...' with %v call", op)
} }
...@@ -1279,7 +1279,7 @@ func (w *exportWriter) expr(n *Node) { ...@@ -1279,7 +1279,7 @@ func (w *exportWriter) expr(n *Node) {
w.pos(n.Pos) w.pos(n.Pos)
w.expr(n.Left) w.expr(n.Left)
w.exprList(n.List) w.exprList(n.List)
w.bool(n.Isddd()) w.bool(n.IsDDD())
case OMAKEMAP, OMAKECHAN, OMAKESLICE: case OMAKEMAP, OMAKECHAN, OMAKESLICE:
w.op(op) // must keep separate from OMAKE for importer w.op(op) // must keep separate from OMAKE for importer
...@@ -1301,7 +1301,7 @@ func (w *exportWriter) expr(n *Node) { ...@@ -1301,7 +1301,7 @@ func (w *exportWriter) expr(n *Node) {
} }
// unary expressions // unary expressions
case OPLUS, OMINUS, OADDR, OCOM, OIND, ONOT, ORECV: case OPLUS, ONEG, OADDR, OBITNOT, ODEREF, ONOT, ORECV:
w.op(op) w.op(op)
w.pos(n.Pos) w.pos(n.Pos)
w.expr(n.Left) w.expr(n.Left)
......
...@@ -608,7 +608,7 @@ func (r *importReader) signature(recv *types.Field) *types.Type { ...@@ -608,7 +608,7 @@ func (r *importReader) signature(recv *types.Field) *types.Type {
params := r.paramList() params := r.paramList()
results := r.paramList() results := r.paramList()
if n := len(params); n > 0 { if n := len(params); n > 0 {
params[n-1].SetIsddd(r.bool()) params[n-1].SetIsDDD(r.bool())
} }
t := functypefield(recv, params, results) t := functypefield(recv, params, results)
t.SetPkg(r.currPkg) t.SetPkg(r.currPkg)
...@@ -820,7 +820,7 @@ func (r *importReader) node() *Node { ...@@ -820,7 +820,7 @@ func (r *importReader) node() *Node {
if !r.bool() /* !implicit, i.e. '&' operator */ { if !r.bool() /* !implicit, i.e. '&' operator */ {
if n.Op == OCOMPLIT { if n.Op == OCOMPLIT {
// Special case for &T{...}: turn into (*T){...}. // Special case for &T{...}: turn into (*T){...}.
n.Right = nodl(pos, OIND, n.Right, nil) n.Right = nodl(pos, ODEREF, n.Right, nil)
n.Right.SetImplicit(true) n.Right.SetImplicit(true)
} else { } else {
n = nodl(pos, OADDR, n, nil) n = nodl(pos, OADDR, n, nil)
...@@ -887,7 +887,7 @@ func (r *importReader) node() *Node { ...@@ -887,7 +887,7 @@ func (r *importReader) node() *Node {
n.SetSliceBounds(low, high, max) n.SetSliceBounds(low, high, max)
return n return n
// case OCONV, OCONVIFACE, OCONVNOP, OARRAYBYTESTR, OARRAYRUNESTR, OSTRARRAYBYTE, OSTRARRAYRUNE, ORUNESTR: // case OCONV, OCONVIFACE, OCONVNOP, OBYTES2STR, ORUNES2STR, OSTR2BYTES, OSTR2RUNES, ORUNESTR:
// unreachable - mapped to OCONV case below by exporter // unreachable - mapped to OCONV case below by exporter
case OCONV: case OCONV:
...@@ -899,7 +899,7 @@ func (r *importReader) node() *Node { ...@@ -899,7 +899,7 @@ func (r *importReader) node() *Node {
n := npos(r.pos(), builtinCall(op)) n := npos(r.pos(), builtinCall(op))
n.List.Set(r.exprList()) n.List.Set(r.exprList())
if op == OAPPEND { if op == OAPPEND {
n.SetIsddd(r.bool()) n.SetIsDDD(r.bool())
} }
return n return n
...@@ -909,7 +909,7 @@ func (r *importReader) node() *Node { ...@@ -909,7 +909,7 @@ func (r *importReader) node() *Node {
case OCALL: case OCALL:
n := nodl(r.pos(), OCALL, r.expr(), nil) n := nodl(r.pos(), OCALL, r.expr(), nil)
n.List.Set(r.exprList()) n.List.Set(r.exprList())
n.SetIsddd(r.bool()) n.SetIsDDD(r.bool())
return n return n
case OMAKEMAP, OMAKECHAN, OMAKESLICE: case OMAKEMAP, OMAKECHAN, OMAKESLICE:
...@@ -919,7 +919,7 @@ func (r *importReader) node() *Node { ...@@ -919,7 +919,7 @@ func (r *importReader) node() *Node {
return n return n
// unary expressions // unary expressions
case OPLUS, OMINUS, OADDR, OCOM, OIND, ONOT, ORECV: case OPLUS, ONEG, OADDR, OBITNOT, ODEREF, ONOT, ORECV:
return nodl(r.pos(), op, r.expr(), nil) return nodl(r.pos(), op, r.expr(), nil)
// binary expressions // binary expressions
...@@ -982,7 +982,7 @@ func (r *importReader) node() *Node { ...@@ -982,7 +982,7 @@ func (r *importReader) node() *Node {
// case ORETJMP: // case ORETJMP:
// unreachable - generated by compiler for trampolin routines (not exported) // unreachable - generated by compiler for trampolin routines (not exported)
case OPROC, ODEFER: case OGO, ODEFER:
return nodl(r.pos(), op, r.expr(), nil) return nodl(r.pos(), op, r.expr(), nil)
case OIF: case OIF:
......
...@@ -166,7 +166,7 @@ func fninit(n []*Node) { ...@@ -166,7 +166,7 @@ func fninit(n []*Node) {
rhs := asNode(s.Def) rhs := asNode(s.Def)
rhs.checkInitFuncSignature() rhs.checkInitFuncSignature()
as := nod(OAS, lhs, rhs) as := nod(OAS, lhs, rhs)
as = typecheck(as, Etop) as = typecheck(as, ctxStmt)
genAsStatic(as) genAsStatic(as)
} }
...@@ -187,7 +187,7 @@ func fninit(n []*Node) { ...@@ -187,7 +187,7 @@ func fninit(n []*Node) {
loop.Nbody.Set1(body) loop.Nbody.Set1(body)
loop.Ninit.Set1(zero) loop.Ninit.Set1(zero)
loop = typecheck(loop, Etop) loop = typecheck(loop, ctxStmt)
r = append(r, loop) r = append(r, loop)
} }
...@@ -206,8 +206,8 @@ func fninit(n []*Node) { ...@@ -206,8 +206,8 @@ func fninit(n []*Node) {
funcbody() funcbody()
Curfn = fn Curfn = fn
fn = typecheck(fn, Etop) fn = typecheck(fn, ctxStmt)
typecheckslice(r, Etop) typecheckslice(r, ctxStmt)
Curfn = nil Curfn = nil
funccompile(fn) funccompile(fn)
} }
......
...@@ -90,7 +90,7 @@ func typecheckinl(fn *Node) { ...@@ -90,7 +90,7 @@ func typecheckinl(fn *Node) {
savefn := Curfn savefn := Curfn
Curfn = fn Curfn = fn
typecheckslice(fn.Func.Inl.Body, Etop) typecheckslice(fn.Func.Inl.Body, ctxStmt)
Curfn = savefn Curfn = savefn
// During typechecking, declarations are added to // During typechecking, declarations are added to
...@@ -377,7 +377,7 @@ func (v *hairyVisitor) visit(n *Node) bool { ...@@ -377,7 +377,7 @@ func (v *hairyVisitor) visit(n *Node) bool {
OFORUNTIL, OFORUNTIL,
OSELECT, OSELECT,
OTYPESW, OTYPESW,
OPROC, OGO,
ODEFER, ODEFER,
ODCLTYPE, // can't print yet ODCLTYPE, // can't print yet
OBREAK, OBREAK,
...@@ -552,7 +552,7 @@ func inlnode(n *Node, maxCost int32) *Node { ...@@ -552,7 +552,7 @@ func inlnode(n *Node, maxCost int32) *Node {
switch n.Op { switch n.Op {
// inhibit inlining of their argument // inhibit inlining of their argument
case ODEFER, OPROC: case ODEFER, OGO:
switch n.Left.Op { switch n.Left.Op {
case OCALLFUNC, OCALLMETH: case OCALLFUNC, OCALLMETH:
n.Left.SetNoInline(true) n.Left.SetNoInline(true)
...@@ -620,7 +620,7 @@ func inlnode(n *Node, maxCost int32) *Node { ...@@ -620,7 +620,7 @@ func inlnode(n *Node, maxCost int32) *Node {
n.Rlist.Set(inlconv2list(n.Rlist.First())) n.Rlist.Set(inlconv2list(n.Rlist.First()))
n.Op = OAS2 n.Op = OAS2
n.SetTypecheck(0) n.SetTypecheck(0)
n = typecheck(n, Etop) n = typecheck(n, ctxStmt)
} else { } else {
s := n.Rlist.Slice() s := n.Rlist.Slice()
for i1, n1 := range s { for i1, n1 := range s {
...@@ -815,7 +815,7 @@ func tinlvar(t *types.Field, inlvars map[*Node]*Node) *Node { ...@@ -815,7 +815,7 @@ func tinlvar(t *types.Field, inlvars map[*Node]*Node) *Node {
return inlvar return inlvar
} }
return typecheck(nblank, Erv|Easgn) return typecheck(nblank, ctxExpr|ctxAssign)
} }
var inlgen int var inlgen int
...@@ -897,21 +897,21 @@ func mkinlcall(n, fn *Node, maxCost int32) *Node { ...@@ -897,21 +897,21 @@ func mkinlcall(n, fn *Node, maxCost int32) *Node {
} }
if v.Name.Byval() { if v.Name.Byval() {
iv := typecheck(inlvar(v), Erv) iv := typecheck(inlvar(v), ctxExpr)
ninit.Append(nod(ODCL, iv, nil)) ninit.Append(nod(ODCL, iv, nil))
ninit.Append(typecheck(nod(OAS, iv, o), Etop)) ninit.Append(typecheck(nod(OAS, iv, o), ctxStmt))
inlvars[v] = iv inlvars[v] = iv
} else { } else {
addr := newname(lookup("&" + v.Sym.Name)) addr := newname(lookup("&" + v.Sym.Name))
addr.Type = types.NewPtr(v.Type) addr.Type = types.NewPtr(v.Type)
ia := typecheck(inlvar(addr), Erv) ia := typecheck(inlvar(addr), ctxExpr)
ninit.Append(nod(ODCL, ia, nil)) ninit.Append(nod(ODCL, ia, nil))
ninit.Append(typecheck(nod(OAS, ia, nod(OADDR, o, nil)), Etop)) ninit.Append(typecheck(nod(OAS, ia, nod(OADDR, o, nil)), ctxStmt))
inlvars[addr] = ia inlvars[addr] = ia
// When capturing by reference, all occurrence of the captured var // When capturing by reference, all occurrence of the captured var
// must be substituted with dereference of the temporary address // must be substituted with dereference of the temporary address
inlvars[v] = typecheck(nod(OIND, ia, nil), Erv) inlvars[v] = typecheck(nod(ODEREF, ia, nil), ctxExpr)
} }
} }
} }
...@@ -927,7 +927,7 @@ func mkinlcall(n, fn *Node, maxCost int32) *Node { ...@@ -927,7 +927,7 @@ func mkinlcall(n, fn *Node, maxCost int32) *Node {
if ln.isParamStackCopy() { // ignore the on-stack copy of a parameter that moved to the heap if ln.isParamStackCopy() { // ignore the on-stack copy of a parameter that moved to the heap
continue continue
} }
inlvars[ln] = typecheck(inlvar(ln), Erv) inlvars[ln] = typecheck(inlvar(ln), ctxExpr)
if ln.Class() == PPARAM || ln.Name.Param.Stackcopy != nil && ln.Name.Param.Stackcopy.Class() == PPARAM { if ln.Class() == PPARAM || ln.Name.Param.Stackcopy != nil && ln.Name.Param.Stackcopy.Class() == PPARAM {
ninit.Append(nod(ODCL, inlvars[ln], nil)) ninit.Append(nod(ODCL, inlvars[ln], nil))
} }
...@@ -950,7 +950,7 @@ func mkinlcall(n, fn *Node, maxCost int32) *Node { ...@@ -950,7 +950,7 @@ func mkinlcall(n, fn *Node, maxCost int32) *Node {
mpos := t.Pos mpos := t.Pos
if n := asNode(t.Nname); n != nil && !n.isBlank() { if n := asNode(t.Nname); n != nil && !n.isBlank() {
m = inlvar(n) m = inlvar(n)
m = typecheck(m, Erv) m = typecheck(m, ctxExpr)
inlvars[n] = m inlvars[n] = m
} else { } else {
// anonymous return values, synthesize names for use in assignment that replaces return // anonymous return values, synthesize names for use in assignment that replaces return
...@@ -990,7 +990,7 @@ func mkinlcall(n, fn *Node, maxCost int32) *Node { ...@@ -990,7 +990,7 @@ func mkinlcall(n, fn *Node, maxCost int32) *Node {
Fatalf("method call without receiver: %+v", n) Fatalf("method call without receiver: %+v", n)
} }
ras := nod(OAS, tinlvar(rcv, inlvars), n.Left.Left) ras := nod(OAS, tinlvar(rcv, inlvars), n.Left.Left)
ras = typecheck(ras, Etop) ras = typecheck(ras, ctxStmt)
ninit.Append(ras) ninit.Append(ras)
} else { } else {
// For T.M(...), add the receiver parameter to // For T.M(...), add the receiver parameter to
...@@ -1007,7 +1007,7 @@ func mkinlcall(n, fn *Node, maxCost int32) *Node { ...@@ -1007,7 +1007,7 @@ func mkinlcall(n, fn *Node, maxCost int32) *Node {
// For ordinary parameters or variadic parameters in // For ordinary parameters or variadic parameters in
// dotted calls, just add the variable to the // dotted calls, just add the variable to the
// assignment list, and we're done. // assignment list, and we're done.
if !param.Isddd() || n.Isddd() { if !param.IsDDD() || n.IsDDD() {
as.List.Append(tinlvar(param, inlvars)) as.List.Append(tinlvar(param, inlvars))
continue continue
} }
...@@ -1037,19 +1037,19 @@ func mkinlcall(n, fn *Node, maxCost int32) *Node { ...@@ -1037,19 +1037,19 @@ func mkinlcall(n, fn *Node, maxCost int32) *Node {
} }
if as.Rlist.Len() != 0 { if as.Rlist.Len() != 0 {
as = typecheck(as, Etop) as = typecheck(as, ctxStmt)
ninit.Append(as) ninit.Append(as)
} }
if vas != nil { if vas != nil {
vas = typecheck(vas, Etop) vas = typecheck(vas, ctxStmt)
ninit.Append(vas) ninit.Append(vas)
} }
// Zero the return parameters. // Zero the return parameters.
for _, n := range retvars { for _, n := range retvars {
ras := nod(OAS, n, nil) ras := nod(OAS, n, nil)
ras = typecheck(ras, Etop) ras = typecheck(ras, ctxStmt)
ninit.Append(ras) ninit.Append(ras)
} }
...@@ -1083,7 +1083,7 @@ func mkinlcall(n, fn *Node, maxCost int32) *Node { ...@@ -1083,7 +1083,7 @@ func mkinlcall(n, fn *Node, maxCost int32) *Node {
lab := nodSym(OLABEL, nil, retlabel) lab := nodSym(OLABEL, nil, retlabel)
body = append(body, lab) body = append(body, lab)
typecheckslice(body, Etop) typecheckslice(body, ctxStmt)
if genDwarfInline > 0 { if genDwarfInline > 0 {
for _, v := range inlfvars { for _, v := range inlfvars {
...@@ -1239,12 +1239,12 @@ func (subst *inlsubst) node(n *Node) *Node { ...@@ -1239,12 +1239,12 @@ func (subst *inlsubst) node(n *Node) *Node {
as.List.Append(n) as.List.Append(n)
} }
as.Rlist.Set(subst.list(n.List)) as.Rlist.Set(subst.list(n.List))
as = typecheck(as, Etop) as = typecheck(as, ctxStmt)
m.Ninit.Append(as) m.Ninit.Append(as)
} }
typecheckslice(m.Ninit.Slice(), Etop) typecheckslice(m.Ninit.Slice(), ctxStmt)
m = typecheck(m, Etop) m = typecheck(m, ctxStmt)
// dump("Return after substitution", m); // dump("Return after substitution", m);
return m return m
......
...@@ -509,7 +509,7 @@ func Main(archInit func(*Arch)) { ...@@ -509,7 +509,7 @@ func Main(archInit func(*Arch)) {
for i := 0; i < len(xtop); i++ { for i := 0; i < len(xtop); i++ {
n := xtop[i] n := xtop[i]
if op := n.Op; op != ODCL && op != OAS && op != OAS2 && (op != ODCLTYPE || !n.Left.Name.Param.Alias) { if op := n.Op; op != ODCL && op != OAS && op != OAS2 && (op != ODCLTYPE || !n.Left.Name.Param.Alias) {
xtop[i] = typecheck(n, Etop) xtop[i] = typecheck(n, ctxStmt)
} }
} }
...@@ -521,7 +521,7 @@ func Main(archInit func(*Arch)) { ...@@ -521,7 +521,7 @@ func Main(archInit func(*Arch)) {
for i := 0; i < len(xtop); i++ { for i := 0; i < len(xtop); i++ {
n := xtop[i] n := xtop[i]
if op := n.Op; op == ODCL || op == OAS || op == OAS2 || op == ODCLTYPE && n.Left.Name.Param.Alias { if op := n.Op; op == ODCL || op == OAS || op == OAS2 || op == ODCLTYPE && n.Left.Name.Param.Alias {
xtop[i] = typecheck(n, Etop) xtop[i] = typecheck(n, ctxStmt)
} }
} }
resumecheckwidth() resumecheckwidth()
...@@ -536,7 +536,7 @@ func Main(archInit func(*Arch)) { ...@@ -536,7 +536,7 @@ func Main(archInit func(*Arch)) {
Curfn = n Curfn = n
decldepth = 1 decldepth = 1
saveerrors() saveerrors()
typecheckslice(Curfn.Nbody.Slice(), Etop) typecheckslice(Curfn.Nbody.Slice(), ctxStmt)
checkreturn(Curfn) checkreturn(Curfn)
if nerrors != 0 { if nerrors != 0 {
Curfn.Nbody.Set(nil) // type errors; do not compile Curfn.Nbody.Set(nil) // type errors; do not compile
...@@ -693,7 +693,7 @@ func Main(archInit func(*Arch)) { ...@@ -693,7 +693,7 @@ func Main(archInit func(*Arch)) {
timings.Start("be", "externaldcls") timings.Start("be", "externaldcls")
for i, n := range externdcl { for i, n := range externdcl {
if n.Op == ONAME { if n.Op == ONAME {
externdcl[i] = typecheck(externdcl[i], Erv) externdcl[i] = typecheck(externdcl[i], ctxExpr)
} }
} }
// Check the map keys again, since we typechecked the external // Check the map keys again, since we typechecked the external
......
...@@ -542,9 +542,9 @@ func (p *noder) param(param *syntax.Field, dddOk, final bool) *Node { ...@@ -542,9 +542,9 @@ func (p *noder) param(param *syntax.Field, dddOk, final bool) *Node {
typ.Op = OTARRAY typ.Op = OTARRAY
typ.Right = typ.Left typ.Right = typ.Left
typ.Left = nil typ.Left = nil
n.SetIsddd(true) n.SetIsDDD(true)
if n.Left != nil { if n.Left != nil {
n.Left.SetIsddd(true) n.Left.SetIsDDD(true)
} }
} }
...@@ -632,7 +632,7 @@ func (p *noder) expr(expr syntax.Expr) *Node { ...@@ -632,7 +632,7 @@ func (p *noder) expr(expr syntax.Expr) *Node {
x = unparen(x) // TODO(mdempsky): Needed? x = unparen(x) // TODO(mdempsky): Needed?
if x.Op == OCOMPLIT { if x.Op == OCOMPLIT {
// Special case for &T{...}: turn into (*T){...}. // Special case for &T{...}: turn into (*T){...}.
x.Right = p.nod(expr, OIND, x.Right, nil) x.Right = p.nod(expr, ODEREF, x.Right, nil)
x.Right.SetImplicit(true) x.Right.SetImplicit(true)
return x return x
} }
...@@ -643,7 +643,7 @@ func (p *noder) expr(expr syntax.Expr) *Node { ...@@ -643,7 +643,7 @@ func (p *noder) expr(expr syntax.Expr) *Node {
case *syntax.CallExpr: case *syntax.CallExpr:
n := p.nod(expr, OCALL, p.expr(expr.Fun), nil) n := p.nod(expr, OCALL, p.expr(expr.Fun), nil)
n.List.Set(p.exprs(expr.ArgList)) n.List.Set(p.exprs(expr.ArgList))
n.SetIsddd(expr.HasDots) n.SetIsDDD(expr.HasDots)
return n return n
case *syntax.ArrayType: case *syntax.ArrayType:
...@@ -870,7 +870,7 @@ func (p *noder) embedded(typ syntax.Expr) *Node { ...@@ -870,7 +870,7 @@ func (p *noder) embedded(typ syntax.Expr) *Node {
n.SetEmbedded(true) n.SetEmbedded(true)
if isStar { if isStar {
n.Left = p.nod(op, OIND, n.Left, nil) n.Left = p.nod(op, ODEREF, n.Left, nil)
} }
return n return n
} }
...@@ -969,7 +969,7 @@ func (p *noder) stmtFall(stmt syntax.Stmt, fallOK bool) *Node { ...@@ -969,7 +969,7 @@ func (p *noder) stmtFall(stmt syntax.Stmt, fallOK bool) *Node {
case syntax.Defer: case syntax.Defer:
op = ODEFER op = ODEFER
case syntax.Go: case syntax.Go:
op = OPROC op = OGO
default: default:
panic("unhandled CallStmt") panic("unhandled CallStmt")
} }
...@@ -1245,13 +1245,13 @@ func (p *noder) labeledStmt(label *syntax.LabeledStmt, fallOK bool) *Node { ...@@ -1245,13 +1245,13 @@ func (p *noder) labeledStmt(label *syntax.LabeledStmt, fallOK bool) *Node {
var unOps = [...]Op{ var unOps = [...]Op{
syntax.Recv: ORECV, syntax.Recv: ORECV,
syntax.Mul: OIND, syntax.Mul: ODEREF,
syntax.And: OADDR, syntax.And: OADDR,
syntax.Not: ONOT, syntax.Not: ONOT,
syntax.Xor: OCOM, syntax.Xor: OBITNOT,
syntax.Add: OPLUS, syntax.Add: OPLUS,
syntax.Sub: OMINUS, syntax.Sub: ONEG,
} }
func (p *noder) unOp(op syntax.Operator) Op { func (p *noder) unOp(op syntax.Operator) Op {
......
...@@ -4,9 +4,9 @@ package gc ...@@ -4,9 +4,9 @@ package gc
import "strconv" import "strconv"
const _Op_name = "XXXNAMENONAMETYPEPACKLITERALADDSUBORXORADDSTRADDRANDANDAPPENDARRAYBYTESTRARRAYBYTESTRTMPARRAYRUNESTRSTRARRAYBYTESTRARRAYBYTETMPSTRARRAYRUNEASAS2AS2FUNCAS2RECVAS2MAPRAS2DOTTYPEASOPCALLCALLFUNCCALLMETHCALLINTERCALLPARTCAPCLOSECLOSURECOMPLITMAPLITSTRUCTLITARRAYLITSLICELITPTRLITCONVCONVIFACECONVNOPCOPYDCLDCLFUNCDCLFIELDDCLCONSTDCLTYPEDELETEDOTDOTPTRDOTMETHDOTINTERXDOTDOTTYPEDOTTYPE2EQNELTLEGEGTINDINDEXINDEXMAPKEYSTRUCTKEYLENMAKEMAKECHANMAKEMAPMAKESLICEMULDIVMODLSHRSHANDANDNOTNEWNOTCOMPLUSMINUSORORPANICPRINTPRINTNPARENSENDSLICESLICEARRSLICESTRSLICE3SLICE3ARRSLICEHEADERRECOVERRECVRUNESTRSELRECVSELRECV2IOTAREALIMAGCOMPLEXALIGNOFOFFSETOFSIZEOFBLOCKBREAKCASEXCASECONTINUEDEFEREMPTYFALLFORFORUNTILGOTOIFLABELPROCRANGERETURNSELECTSWITCHTYPESWTCHANTMAPTSTRUCTTINTERTFUNCTARRAYDDDDDDARGINLCALLEFACEITABIDATASPTRCLOSUREVARCFUNCCHECKNILVARDEFVARKILLVARLIVEINDREGSPRETJMPGETGEND" const _Op_name = "XXXNAMENONAMETYPEPACKLITERALADDSUBORXORADDSTRADDRANDANDAPPENDBYTES2STRBYTES2STRTMPRUNES2STRSTR2BYTESSTR2BYTESTMPSTR2RUNESASAS2AS2FUNCAS2RECVAS2MAPRAS2DOTTYPEASOPCALLCALLFUNCCALLMETHCALLINTERCALLPARTCAPCLOSECLOSURECOMPLITMAPLITSTRUCTLITARRAYLITSLICELITPTRLITCONVCONVIFACECONVNOPCOPYDCLDCLFUNCDCLFIELDDCLCONSTDCLTYPEDELETEDOTDOTPTRDOTMETHDOTINTERXDOTDOTTYPEDOTTYPE2EQNELTLEGEGTDEREFINDEXINDEXMAPKEYSTRUCTKEYLENMAKEMAKECHANMAKEMAPMAKESLICEMULDIVMODLSHRSHANDANDNOTNEWNOTBITNOTPLUSNEGORORPANICPRINTPRINTNPARENSENDSLICESLICEARRSLICESTRSLICE3SLICE3ARRSLICEHEADERRECOVERRECVRUNESTRSELRECVSELRECV2IOTAREALIMAGCOMPLEXALIGNOFOFFSETOFSIZEOFBLOCKBREAKCASEXCASECONTINUEDEFEREMPTYFALLFORFORUNTILGOTOIFLABELGORANGERETURNSELECTSWITCHTYPESWTCHANTMAPTSTRUCTTINTERTFUNCTARRAYDDDDDDARGINLCALLEFACEITABIDATASPTRCLOSUREVARCFUNCCHECKNILVARDEFVARKILLVARLIVEINDREGSPRETJMPGETGEND"
var _Op_index = [...]uint16{0, 3, 7, 13, 17, 21, 28, 31, 34, 36, 39, 45, 49, 55, 61, 73, 88, 100, 112, 127, 139, 141, 144, 151, 158, 165, 175, 179, 183, 191, 199, 208, 216, 219, 224, 231, 238, 244, 253, 261, 269, 275, 279, 288, 295, 299, 302, 309, 317, 325, 332, 338, 341, 347, 354, 362, 366, 373, 381, 383, 385, 387, 389, 391, 393, 396, 401, 409, 412, 421, 424, 428, 436, 443, 452, 455, 458, 461, 464, 467, 470, 476, 479, 482, 485, 489, 494, 498, 503, 508, 514, 519, 523, 528, 536, 544, 550, 559, 570, 577, 581, 588, 595, 603, 607, 611, 615, 622, 629, 637, 643, 648, 653, 657, 662, 670, 675, 680, 684, 687, 695, 699, 701, 706, 710, 715, 721, 727, 733, 739, 744, 748, 755, 761, 766, 772, 775, 781, 788, 793, 797, 802, 806, 816, 821, 829, 835, 842, 849, 857, 863, 867, 870} var _Op_index = [...]uint16{0, 3, 7, 13, 17, 21, 28, 31, 34, 36, 39, 45, 49, 55, 61, 70, 82, 91, 100, 112, 121, 123, 126, 133, 140, 147, 157, 161, 165, 173, 181, 190, 198, 201, 206, 213, 220, 226, 235, 243, 251, 257, 261, 270, 277, 281, 284, 291, 299, 307, 314, 320, 323, 329, 336, 344, 348, 355, 363, 365, 367, 369, 371, 373, 375, 380, 385, 393, 396, 405, 408, 412, 420, 427, 436, 439, 442, 445, 448, 451, 454, 460, 463, 466, 472, 476, 479, 483, 488, 493, 499, 504, 508, 513, 521, 529, 535, 544, 555, 562, 566, 573, 580, 588, 592, 596, 600, 607, 614, 622, 628, 633, 638, 642, 647, 655, 660, 665, 669, 672, 680, 684, 686, 691, 693, 698, 704, 710, 716, 722, 727, 731, 738, 744, 749, 755, 758, 764, 771, 776, 780, 785, 789, 799, 804, 812, 818, 825, 832, 840, 846, 850, 853}
func (i Op) String() string { func (i Op) String() string {
if i >= Op(len(_Op_index)-1) { if i >= Op(len(_Op_index)-1) {
......
...@@ -81,7 +81,7 @@ func (o *Order) newTemp(t *types.Type, clear bool) *Node { ...@@ -81,7 +81,7 @@ func (o *Order) newTemp(t *types.Type, clear bool) *Node {
} }
if clear { if clear {
a := nod(OAS, v, nil) a := nod(OAS, v, nil)
a = typecheck(a, Etop) a = typecheck(a, ctxStmt)
o.out = append(o.out, a) o.out = append(o.out, a)
} }
...@@ -104,7 +104,7 @@ func (o *Order) newTemp(t *types.Type, clear bool) *Node { ...@@ -104,7 +104,7 @@ func (o *Order) newTemp(t *types.Type, clear bool) *Node {
func (o *Order) copyExpr(n *Node, t *types.Type, clear bool) *Node { func (o *Order) copyExpr(n *Node, t *types.Type, clear bool) *Node {
v := o.newTemp(t, clear) v := o.newTemp(t, clear)
a := nod(OAS, v, n) a := nod(OAS, v, n)
a = typecheck(a, Etop) a = typecheck(a, ctxStmt)
o.out = append(o.out, a) o.out = append(o.out, a)
return v return v
} }
...@@ -128,7 +128,7 @@ func (o *Order) cheapExpr(n *Node) *Node { ...@@ -128,7 +128,7 @@ func (o *Order) cheapExpr(n *Node) *Node {
} }
a := n.sepcopy() a := n.sepcopy()
a.Left = l a.Left = l
return typecheck(a, Erv) return typecheck(a, ctxExpr)
} }
return o.copyExpr(n, n.Type, false) return o.copyExpr(n, n.Type, false)
...@@ -153,16 +153,16 @@ func (o *Order) safeExpr(n *Node) *Node { ...@@ -153,16 +153,16 @@ func (o *Order) safeExpr(n *Node) *Node {
} }
a := n.sepcopy() a := n.sepcopy()
a.Left = l a.Left = l
return typecheck(a, Erv) return typecheck(a, ctxExpr)
case ODOTPTR, OIND: case ODOTPTR, ODEREF:
l := o.cheapExpr(n.Left) l := o.cheapExpr(n.Left)
if l == n.Left { if l == n.Left {
return n return n
} }
a := n.sepcopy() a := n.sepcopy()
a.Left = l a.Left = l
return typecheck(a, Erv) return typecheck(a, ctxExpr)
case OINDEX, OINDEXMAP: case OINDEX, OINDEXMAP:
var l *Node var l *Node
...@@ -178,7 +178,7 @@ func (o *Order) safeExpr(n *Node) *Node { ...@@ -178,7 +178,7 @@ func (o *Order) safeExpr(n *Node) *Node {
a := n.sepcopy() a := n.sepcopy()
a.Left = l a.Left = l
a.Right = r a.Right = r
return typecheck(a, Erv) return typecheck(a, ctxExpr)
default: default:
Fatalf("ordersafeexpr %v", n.Op) Fatalf("ordersafeexpr %v", n.Op)
...@@ -213,7 +213,7 @@ func (o *Order) addrTemp(n *Node) *Node { ...@@ -213,7 +213,7 @@ func (o *Order) addrTemp(n *Node) *Node {
if out != nil { if out != nil {
Fatalf("staticassign of const generated code: %+v", n) Fatalf("staticassign of const generated code: %+v", n)
} }
vstat = typecheck(vstat, Erv) vstat = typecheck(vstat, ctxExpr)
return vstat return vstat
} }
if isaddrokay(n) { if isaddrokay(n) {
...@@ -233,7 +233,7 @@ func (o *Order) mapKeyTemp(t *types.Type, n *Node) *Node { ...@@ -233,7 +233,7 @@ func (o *Order) mapKeyTemp(t *types.Type, n *Node) *Node {
return n return n
} }
// mapKeyReplaceStrConv replaces OARRAYBYTESTR by OARRAYBYTESTRTMP // mapKeyReplaceStrConv replaces OBYTES2STR by OBYTES2STRTMP
// in n to avoid string allocations for keys in map lookups. // in n to avoid string allocations for keys in map lookups.
// Returns a bool that signals if a modification was made. // Returns a bool that signals if a modification was made.
// //
...@@ -250,8 +250,8 @@ func (o *Order) mapKeyTemp(t *types.Type, n *Node) *Node { ...@@ -250,8 +250,8 @@ func (o *Order) mapKeyTemp(t *types.Type, n *Node) *Node {
func mapKeyReplaceStrConv(n *Node) bool { func mapKeyReplaceStrConv(n *Node) bool {
var replaced bool var replaced bool
switch n.Op { switch n.Op {
case OARRAYBYTESTR: case OBYTES2STR:
n.Op = OARRAYBYTESTRTMP n.Op = OBYTES2STRTMP
replaced = true replaced = true
case OSTRUCTLIT: case OSTRUCTLIT:
for _, elem := range n.List.Slice() { for _, elem := range n.List.Slice() {
...@@ -300,11 +300,11 @@ func (o *Order) cleanTempNoPop(mark ordermarker) []*Node { ...@@ -300,11 +300,11 @@ func (o *Order) cleanTempNoPop(mark ordermarker) []*Node {
n.Name.SetKeepalive(false) n.Name.SetKeepalive(false)
n.SetAddrtaken(true) // ensure SSA keeps the n variable n.SetAddrtaken(true) // ensure SSA keeps the n variable
live := nod(OVARLIVE, n, nil) live := nod(OVARLIVE, n, nil)
live = typecheck(live, Etop) live = typecheck(live, ctxStmt)
out = append(out, live) out = append(out, live)
} }
kill := nod(OVARKILL, n, nil) kill := nod(OVARKILL, n, nil)
kill = typecheck(kill, Etop) kill = typecheck(kill, ctxStmt)
out = append(out, kill) out = append(out, kill)
} }
return out return out
...@@ -418,7 +418,7 @@ func (o *Order) copyRet(n *Node) []*Node { ...@@ -418,7 +418,7 @@ func (o *Order) copyRet(n *Node) []*Node {
as := nod(OAS2, nil, nil) as := nod(OAS2, nil, nil)
as.List.Set(l1) as.List.Set(l1)
as.Rlist.Set1(n) as.Rlist.Set1(n)
as = typecheck(as, Etop) as = typecheck(as, ctxStmt)
o.stmt(as) o.stmt(as)
return l2 return l2
...@@ -463,7 +463,7 @@ func (o *Order) call(n *Node) { ...@@ -463,7 +463,7 @@ func (o *Order) call(n *Node) {
for i, t := range n.Left.Type.Params().FieldSlice() { for i, t := range n.Left.Type.Params().FieldSlice() {
// Check for "unsafe-uintptr" tag provided by escape analysis. // Check for "unsafe-uintptr" tag provided by escape analysis.
if t.Isddd() && !n.Isddd() { if t.IsDDD() && !n.IsDDD() {
if t.Note == uintptrEscapesTag { if t.Note == uintptrEscapesTag {
for ; i < n.List.Len(); i++ { for ; i < n.List.Len(); i++ {
keepAlive(i) keepAlive(i)
...@@ -528,7 +528,7 @@ func (o *Order) mapAssign(n *Node) { ...@@ -528,7 +528,7 @@ func (o *Order) mapAssign(n *Node) {
t := o.newTemp(m.Type, false) t := o.newTemp(m.Type, false)
n.List.SetIndex(i, t) n.List.SetIndex(i, t)
a := nod(OAS, m, t) a := nod(OAS, m, t)
a = typecheck(a, Etop) a = typecheck(a, ctxStmt)
post = append(post, a) post = append(post, a)
} }
} }
...@@ -602,7 +602,7 @@ func (o *Order) stmt(n *Node) { ...@@ -602,7 +602,7 @@ func (o *Order) stmt(n *Node) {
} }
l = o.copyExpr(l, n.Left.Type, false) l = o.copyExpr(l, n.Left.Type, false)
n.Right = nod(n.SubOp(), l, n.Right) n.Right = nod(n.SubOp(), l, n.Right)
n.Right = typecheck(n.Right, Erv) n.Right = typecheck(n.Right, ctxExpr)
n.Right = o.expr(n.Right, nil) n.Right = o.expr(n.Right, nil)
n.Op = OAS n.Op = OAS
...@@ -657,10 +657,10 @@ func (o *Order) stmt(n *Node) { ...@@ -657,10 +657,10 @@ func (o *Order) stmt(n *Node) {
tmp2 := o.newTemp(types.Types[TBOOL], false) tmp2 := o.newTemp(types.Types[TBOOL], false)
o.out = append(o.out, n) o.out = append(o.out, n)
r := nod(OAS, n.List.First(), tmp1) r := nod(OAS, n.List.First(), tmp1)
r = typecheck(r, Etop) r = typecheck(r, ctxStmt)
o.mapAssign(r) o.mapAssign(r)
r = okas(n.List.Second(), tmp2) r = okas(n.List.Second(), tmp2)
r = typecheck(r, Etop) r = typecheck(r, ctxStmt)
o.mapAssign(r) o.mapAssign(r)
n.List.Set2(tmp1, tmp2) n.List.Set2(tmp1, tmp2)
o.cleanTemp(t) o.cleanTemp(t)
...@@ -689,7 +689,7 @@ func (o *Order) stmt(n *Node) { ...@@ -689,7 +689,7 @@ func (o *Order) stmt(n *Node) {
o.cleanTemp(t) o.cleanTemp(t)
// Special: order arguments to inner call but not call itself. // Special: order arguments to inner call but not call itself.
case ODEFER, OPROC: case ODEFER, OGO:
t := o.markTemp() t := o.markTemp()
o.call(n.Left) o.call(n.Left)
o.out = append(o.out, n) o.out = append(o.out, n)
...@@ -751,8 +751,8 @@ func (o *Order) stmt(n *Node) { ...@@ -751,8 +751,8 @@ func (o *Order) stmt(n *Node) {
// Mark []byte(str) range expression to reuse string backing storage. // Mark []byte(str) range expression to reuse string backing storage.
// It is safe because the storage cannot be mutated. // It is safe because the storage cannot be mutated.
if n.Right.Op == OSTRARRAYBYTE { if n.Right.Op == OSTR2BYTES {
n.Right.Op = OSTRARRAYBYTETMP n.Right.Op = OSTR2BYTESTMP
} }
t := o.markTemp() t := o.markTemp()
...@@ -779,7 +779,7 @@ func (o *Order) stmt(n *Node) { ...@@ -779,7 +779,7 @@ func (o *Order) stmt(n *Node) {
if r.Type.IsString() && r.Type != types.Types[TSTRING] { if r.Type.IsString() && r.Type != types.Types[TSTRING] {
r = nod(OCONV, r, nil) r = nod(OCONV, r, nil)
r.Type = types.Types[TSTRING] r.Type = types.Types[TSTRING]
r = typecheck(r, Erv) r = typecheck(r, ctxExpr)
} }
n.Right = o.copyExpr(r, r.Type, false) n.Right = o.copyExpr(r, r.Type, false)
...@@ -897,13 +897,13 @@ func (o *Order) stmt(n *Node) { ...@@ -897,13 +897,13 @@ func (o *Order) stmt(n *Node) {
if r.Colas() { if r.Colas() {
tmp2 := nod(ODCL, tmp1, nil) tmp2 := nod(ODCL, tmp1, nil)
tmp2 = typecheck(tmp2, Etop) tmp2 = typecheck(tmp2, ctxStmt)
n2.Ninit.Append(tmp2) n2.Ninit.Append(tmp2)
} }
r.Left = o.newTemp(r.Right.Left.Type.Elem(), types.Haspointers(r.Right.Left.Type.Elem())) r.Left = o.newTemp(r.Right.Left.Type.Elem(), types.Haspointers(r.Right.Left.Type.Elem()))
tmp2 := nod(OAS, tmp1, r.Left) tmp2 := nod(OAS, tmp1, r.Left)
tmp2 = typecheck(tmp2, Etop) tmp2 = typecheck(tmp2, ctxStmt)
n2.Ninit.Append(tmp2) n2.Ninit.Append(tmp2)
} }
...@@ -914,13 +914,13 @@ func (o *Order) stmt(n *Node) { ...@@ -914,13 +914,13 @@ func (o *Order) stmt(n *Node) {
tmp1 := r.List.First() tmp1 := r.List.First()
if r.Colas() { if r.Colas() {
tmp2 := nod(ODCL, tmp1, nil) tmp2 := nod(ODCL, tmp1, nil)
tmp2 = typecheck(tmp2, Etop) tmp2 = typecheck(tmp2, ctxStmt)
n2.Ninit.Append(tmp2) n2.Ninit.Append(tmp2)
} }
r.List.Set1(o.newTemp(types.Types[TBOOL], false)) r.List.Set1(o.newTemp(types.Types[TBOOL], false))
tmp2 := okas(tmp1, r.List.First()) tmp2 := okas(tmp1, r.List.First())
tmp2 = typecheck(tmp2, Etop) tmp2 = typecheck(tmp2, ctxStmt)
n2.Ninit.Append(tmp2) n2.Ninit.Append(tmp2)
} }
orderBlock(&n2.Ninit, o.free) orderBlock(&n2.Ninit, o.free)
...@@ -1064,14 +1064,14 @@ func (o *Order) expr(n, lhs *Node) *Node { ...@@ -1064,14 +1064,14 @@ func (o *Order) expr(n, lhs *Node) *Node {
haslit := false haslit := false
for _, n1 := range n.List.Slice() { for _, n1 := range n.List.Slice() {
hasbyte = hasbyte || n1.Op == OARRAYBYTESTR hasbyte = hasbyte || n1.Op == OBYTES2STR
haslit = haslit || n1.Op == OLITERAL && len(n1.Val().U.(string)) != 0 haslit = haslit || n1.Op == OLITERAL && len(n1.Val().U.(string)) != 0
} }
if haslit && hasbyte { if haslit && hasbyte {
for _, n2 := range n.List.Slice() { for _, n2 := range n.List.Slice() {
if n2.Op == OARRAYBYTESTR { if n2.Op == OBYTES2STR {
n2.Op = OARRAYBYTESTRTMP n2.Op = OBYTES2STRTMP
} }
} }
} }
...@@ -1153,9 +1153,9 @@ func (o *Order) expr(n, lhs *Node) *Node { ...@@ -1153,9 +1153,9 @@ func (o *Order) expr(n, lhs *Node) *Node {
ONEW, ONEW,
OREAL, OREAL,
ORECOVER, ORECOVER,
OSTRARRAYBYTE, OSTR2BYTES,
OSTRARRAYBYTETMP, OSTR2BYTESTMP,
OSTRARRAYRUNE: OSTR2RUNES:
if isRuneCount(n) { if isRuneCount(n) {
// len([]rune(s)) is rewritten to runtime.countrunes(s) later. // len([]rune(s)) is rewritten to runtime.countrunes(s) later.
...@@ -1248,11 +1248,11 @@ func (o *Order) expr(n, lhs *Node) *Node { ...@@ -1248,11 +1248,11 @@ func (o *Order) expr(n, lhs *Node) *Node {
// Mark string(byteSlice) arguments to reuse byteSlice backing // Mark string(byteSlice) arguments to reuse byteSlice backing
// buffer during conversion. String comparison does not // buffer during conversion. String comparison does not
// memorize the strings for later use, so it is safe. // memorize the strings for later use, so it is safe.
if n.Left.Op == OARRAYBYTESTR { if n.Left.Op == OBYTES2STR {
n.Left.Op = OARRAYBYTESTRTMP n.Left.Op = OBYTES2STRTMP
} }
if n.Right.Op == OARRAYBYTESTR { if n.Right.Op == OBYTES2STR {
n.Right.Op = OARRAYBYTESTRTMP n.Right.Op = OBYTES2STRTMP
} }
case t.IsStruct() || t.IsArray(): case t.IsStruct() || t.IsArray():
...@@ -1301,7 +1301,7 @@ func (o *Order) as2(n *Node) { ...@@ -1301,7 +1301,7 @@ func (o *Order) as2(n *Node) {
as := nod(OAS2, nil, nil) as := nod(OAS2, nil, nil)
as.List.Set(left) as.List.Set(left)
as.Rlist.Set(tmplist) as.Rlist.Set(tmplist)
as = typecheck(as, Etop) as = typecheck(as, ctxStmt)
o.stmt(as) o.stmt(as)
} }
...@@ -1322,13 +1322,13 @@ func (o *Order) okAs2(n *Node) { ...@@ -1322,13 +1322,13 @@ func (o *Order) okAs2(n *Node) {
if tmp1 != nil { if tmp1 != nil {
r := nod(OAS, n.List.First(), tmp1) r := nod(OAS, n.List.First(), tmp1)
r = typecheck(r, Etop) r = typecheck(r, ctxStmt)
o.mapAssign(r) o.mapAssign(r)
n.List.SetFirst(tmp1) n.List.SetFirst(tmp1)
} }
if tmp2 != nil { if tmp2 != nil {
r := okas(n.List.Second(), tmp2) r := okas(n.List.Second(), tmp2)
r = typecheck(r, Etop) r = typecheck(r, ctxStmt)
o.mapAssign(r) o.mapAssign(r)
n.List.SetSecond(tmp2) n.List.SetSecond(tmp2)
} }
......
...@@ -28,17 +28,17 @@ func typecheckrange(n *Node) { ...@@ -28,17 +28,17 @@ func typecheckrange(n *Node) {
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], ctxExpr|ctxAssign)
} }
} }
decldepth++ decldepth++
typecheckslice(n.Nbody.Slice(), Etop) typecheckslice(n.Nbody.Slice(), ctxStmt)
decldepth-- decldepth--
} }
func typecheckrangeExpr(n *Node) { func typecheckrangeExpr(n *Node) {
n.Right = typecheck(n.Right, Erv) n.Right = typecheck(n.Right, ctxExpr)
t := n.Right.Type t := n.Right.Type
if t == nil { if t == nil {
...@@ -48,7 +48,7 @@ func typecheckrangeExpr(n *Node) { ...@@ -48,7 +48,7 @@ func typecheckrangeExpr(n *Node) {
ls := n.List.Slice() ls := n.List.Slice()
for i1, n1 := range ls { for i1, n1 := range ls {
if n1.Name == nil || n1.Name.Defn != n { if n1.Name == nil || n1.Name.Defn != n {
ls[i1] = typecheck(ls[i1], Erv|Easgn) ls[i1] = typecheck(ls[i1], ctxExpr|ctxAssign)
} }
} }
...@@ -278,7 +278,7 @@ func walkrange(n *Node) *Node { ...@@ -278,7 +278,7 @@ func walkrange(n *Node) *Node {
// of the form "v1, a[v1] := range". // of the form "v1, a[v1] := range".
a := nod(OAS2, nil, nil) a := nod(OAS2, nil, nil)
a.List.Set2(v1, v2) a.List.Set2(v1, v2)
a.Rlist.Set2(hv1, nod(OIND, hp, nil)) a.Rlist.Set2(hv1, nod(ODEREF, hp, nil))
body = append(body, a) body = append(body, a)
// Advance pointer as part of the late increment. // Advance pointer as part of the late increment.
...@@ -287,7 +287,7 @@ func walkrange(n *Node) *Node { ...@@ -287,7 +287,7 @@ func walkrange(n *Node) *Node {
// advancing the pointer is safe and won't go past the // advancing the pointer is safe and won't go past the
// end of the allocation. // end of the allocation.
a = nod(OAS, hp, addptr(hp, t.Elem().Width)) a = nod(OAS, hp, addptr(hp, t.Elem().Width))
a = typecheck(a, Etop) a = typecheck(a, ctxStmt)
n.List.Set1(a) n.List.Set1(a)
case TMAP: case TMAP:
...@@ -312,14 +312,14 @@ func walkrange(n *Node) *Node { ...@@ -312,14 +312,14 @@ func walkrange(n *Node) *Node {
n.Right = mkcall1(fn, nil, nil, nod(OADDR, hit, nil)) n.Right = mkcall1(fn, nil, nil, nod(OADDR, hit, nil))
key := nodSym(ODOT, hit, keysym) key := nodSym(ODOT, hit, keysym)
key = nod(OIND, key, nil) key = nod(ODEREF, key, nil)
if v1 == nil { if v1 == nil {
body = nil body = nil
} else if v2 == nil { } else if v2 == nil {
body = []*Node{nod(OAS, v1, key)} body = []*Node{nod(OAS, v1, key)}
} else { } else {
val := nodSym(ODOT, hit, valsym) val := nodSym(ODOT, hit, valsym)
val = nod(OIND, val, nil) val = nod(ODEREF, val, nil)
a := nod(OAS2, nil, nil) a := nod(OAS2, nil, nil)
a.List.Set2(v1, v2) a.List.Set2(v1, v2)
a.Rlist.Set2(key, val) a.Rlist.Set2(key, val)
...@@ -427,21 +427,21 @@ func walkrange(n *Node) *Node { ...@@ -427,21 +427,21 @@ func walkrange(n *Node) *Node {
} }
n.Op = translatedLoopOp n.Op = translatedLoopOp
typecheckslice(init, Etop) typecheckslice(init, ctxStmt)
if ifGuard != nil { if ifGuard != nil {
ifGuard.Ninit.Append(init...) ifGuard.Ninit.Append(init...)
ifGuard = typecheck(ifGuard, Etop) ifGuard = typecheck(ifGuard, ctxStmt)
} else { } else {
n.Ninit.Append(init...) n.Ninit.Append(init...)
} }
typecheckslice(n.Left.Ninit.Slice(), Etop) typecheckslice(n.Left.Ninit.Slice(), ctxStmt)
n.Left = typecheck(n.Left, Erv) n.Left = typecheck(n.Left, ctxExpr)
n.Left = defaultlit(n.Left, nil) n.Left = defaultlit(n.Left, nil)
n.Right = typecheck(n.Right, Etop) n.Right = typecheck(n.Right, ctxStmt)
typecheckslice(body, Etop) typecheckslice(body, ctxStmt)
n.Nbody.Prepend(body...) n.Nbody.Prepend(body...)
if ifGuard != nil { if ifGuard != nil {
...@@ -512,7 +512,7 @@ func mapClear(m *Node) *Node { ...@@ -512,7 +512,7 @@ func mapClear(m *Node) *Node {
fn = substArgTypes(fn, t.Key(), t.Elem()) fn = substArgTypes(fn, t.Key(), t.Elem())
n := mkcall1(fn, nil, nil, typename(t), m) n := mkcall1(fn, nil, nil, typename(t), m)
n = typecheck(n, Etop) n = typecheck(n, ctxStmt)
n = walkstmt(n) n = walkstmt(n)
return n return n
...@@ -601,9 +601,9 @@ func arrayClear(n, v1, v2, a *Node) bool { ...@@ -601,9 +601,9 @@ func arrayClear(n, v1, v2, a *Node) bool {
n.Nbody.Append(v1) n.Nbody.Append(v1)
n.Left = typecheck(n.Left, Erv) n.Left = typecheck(n.Left, ctxExpr)
n.Left = defaultlit(n.Left, nil) n.Left = defaultlit(n.Left, nil)
typecheckslice(n.Nbody.Slice(), Etop) typecheckslice(n.Nbody.Slice(), ctxStmt)
n = walkstmt(n) n = walkstmt(n)
return true return true
} }
......
...@@ -333,7 +333,7 @@ func methodfunc(f *types.Type, receiver *types.Type) *types.Type { ...@@ -333,7 +333,7 @@ func methodfunc(f *types.Type, receiver *types.Type) *types.Type {
for _, t := range f.Params().Fields().Slice() { for _, t := range f.Params().Fields().Slice() {
d := anonfield(t.Type) d := anonfield(t.Type)
d.SetIsddd(t.Isddd()) d.SetIsDDD(t.IsDDD())
in = append(in, d) in = append(in, d)
} }
...@@ -1180,7 +1180,7 @@ func dtypesym(t *types.Type) *obj.LSym { ...@@ -1180,7 +1180,7 @@ func dtypesym(t *types.Type) *obj.LSym {
} }
isddd := false isddd := false
for _, t1 := range t.Params().Fields().Slice() { for _, t1 := range t.Params().Fields().Slice() {
isddd = t1.Isddd() isddd = t1.IsDDD()
dtypesym(t1.Type) dtypesym(t1.Type)
} }
for _, t1 := range t.Results().Fields().Slice() { for _, t1 := range t.Results().Fields().Slice() {
......
...@@ -10,7 +10,7 @@ import "cmd/compile/internal/types" ...@@ -10,7 +10,7 @@ import "cmd/compile/internal/types"
func typecheckselect(sel *Node) { func typecheckselect(sel *Node) {
var def *Node var def *Node
lno := setlineno(sel) lno := setlineno(sel)
typecheckslice(sel.Ninit.Slice(), Etop) typecheckslice(sel.Ninit.Slice(), ctxStmt)
for _, ncase := range sel.List.Slice() { for _, ncase := range sel.List.Slice() {
if ncase.Op != OXCASE { if ncase.Op != OXCASE {
setlineno(ncase) setlineno(ncase)
...@@ -27,7 +27,7 @@ func typecheckselect(sel *Node) { ...@@ -27,7 +27,7 @@ func typecheckselect(sel *Node) {
} else if ncase.List.Len() > 1 { } else if ncase.List.Len() > 1 {
yyerrorl(ncase.Pos, "select cases cannot be lists") yyerrorl(ncase.Pos, "select cases cannot be lists")
} else { } else {
ncase.List.SetFirst(typecheck(ncase.List.First(), Etop)) ncase.List.SetFirst(typecheck(ncase.List.First(), ctxStmt))
n := ncase.List.First() n := ncase.List.First()
ncase.Left = n ncase.Left = n
ncase.List.Set(nil) ncase.List.Set(nil)
...@@ -83,7 +83,7 @@ func typecheckselect(sel *Node) { ...@@ -83,7 +83,7 @@ func typecheckselect(sel *Node) {
} }
} }
typecheckslice(ncase.Nbody.Slice(), Etop) typecheckslice(ncase.Nbody.Slice(), ctxStmt)
} }
lineno = lno lineno = lno
...@@ -148,7 +148,7 @@ func walkselectcases(cases *Nodes) []*Node { ...@@ -148,7 +148,7 @@ func walkselectcases(cases *Nodes) []*Node {
} }
if n.Left == nil { if n.Left == nil {
nblank = typecheck(nblank, Erv|Easgn) nblank = typecheck(nblank, ctxExpr|ctxAssign)
n.Left = nblank n.Left = nblank
} }
...@@ -158,7 +158,7 @@ func walkselectcases(cases *Nodes) []*Node { ...@@ -158,7 +158,7 @@ func walkselectcases(cases *Nodes) []*Node {
n.Right = nil n.Right = nil
n.Left = nil n.Left = nil
n.SetTypecheck(0) n.SetTypecheck(0)
n = typecheck(n, Etop) n = typecheck(n, ctxStmt)
} }
// if ch == nil { block() }; n; // if ch == nil { block() }; n;
...@@ -169,7 +169,7 @@ func walkselectcases(cases *Nodes) []*Node { ...@@ -169,7 +169,7 @@ func walkselectcases(cases *Nodes) []*Node {
ln.Set(l) ln.Set(l)
a.Nbody.Set1(mkcall("block", nil, &ln)) a.Nbody.Set1(mkcall("block", nil, &ln))
l = ln.Slice() l = ln.Slice()
a = typecheck(a, Etop) a = typecheck(a, ctxStmt)
l = append(l, a, n) l = append(l, a, n)
} }
...@@ -189,7 +189,7 @@ func walkselectcases(cases *Nodes) []*Node { ...@@ -189,7 +189,7 @@ func walkselectcases(cases *Nodes) []*Node {
switch n.Op { switch n.Op {
case OSEND: case OSEND:
n.Right = nod(OADDR, n.Right, nil) n.Right = nod(OADDR, n.Right, nil)
n.Right = typecheck(n.Right, Erv) n.Right = typecheck(n.Right, ctxExpr)
case OSELRECV, OSELRECV2: case OSELRECV, OSELRECV2:
if n.Op == OSELRECV2 && n.List.Len() == 0 { if n.Op == OSELRECV2 && n.List.Len() == 0 {
...@@ -198,7 +198,7 @@ func walkselectcases(cases *Nodes) []*Node { ...@@ -198,7 +198,7 @@ func walkselectcases(cases *Nodes) []*Node {
if n.Left != nil { if n.Left != nil {
n.Left = nod(OADDR, n.Left, nil) n.Left = nod(OADDR, n.Left, nil)
n.Left = typecheck(n.Left, Erv) n.Left = typecheck(n.Left, ctxExpr)
} }
} }
} }
...@@ -249,11 +249,11 @@ func walkselectcases(cases *Nodes) []*Node { ...@@ -249,11 +249,11 @@ func walkselectcases(cases *Nodes) []*Node {
elem = nodnil() elem = nodnil()
} }
receivedp := nod(OADDR, n.List.First(), nil) receivedp := nod(OADDR, n.List.First(), nil)
receivedp = typecheck(receivedp, Erv) receivedp = typecheck(receivedp, ctxExpr)
r.Left = mkcall1(chanfn("selectnbrecv2", 2, ch.Type), types.Types[TBOOL], &r.Ninit, elem, receivedp, ch) r.Left = mkcall1(chanfn("selectnbrecv2", 2, ch.Type), types.Types[TBOOL], &r.Ninit, elem, receivedp, ch)
} }
r.Left = typecheck(r.Left, Erv) r.Left = typecheck(r.Left, ctxExpr)
r.Nbody.Set(cas.Nbody.Slice()) r.Nbody.Set(cas.Nbody.Slice())
r.Rlist.Set(append(dflt.Ninit.Slice(), dflt.Nbody.Slice()...)) r.Rlist.Set(append(dflt.Ninit.Slice(), dflt.Nbody.Slice()...))
return []*Node{r, nod(OBREAK, nil, nil)} return []*Node{r, nod(OBREAK, nil, nil)}
...@@ -265,12 +265,12 @@ func walkselectcases(cases *Nodes) []*Node { ...@@ -265,12 +265,12 @@ func walkselectcases(cases *Nodes) []*Node {
lineno = sellineno lineno = sellineno
selv := temp(types.NewArray(scasetype(), int64(n))) selv := temp(types.NewArray(scasetype(), int64(n)))
r := nod(OAS, selv, nil) r := nod(OAS, selv, nil)
r = typecheck(r, Etop) r = typecheck(r, ctxStmt)
init = append(init, r) init = append(init, r)
order := temp(types.NewArray(types.Types[TUINT16], 2*int64(n))) order := temp(types.NewArray(types.Types[TUINT16], 2*int64(n)))
r = nod(OAS, order, nil) r = nod(OAS, order, nil)
r = typecheck(r, Etop) r = typecheck(r, ctxStmt)
init = append(init, r) init = append(init, r)
// register cases // register cases
...@@ -310,7 +310,7 @@ func walkselectcases(cases *Nodes) []*Node { ...@@ -310,7 +310,7 @@ func walkselectcases(cases *Nodes) []*Node {
setField := func(f string, val *Node) { setField := func(f string, val *Node) {
r := nod(OAS, nodSym(ODOT, nod(OINDEX, selv, nodintconst(int64(i))), lookup(f)), val) r := nod(OAS, nodSym(ODOT, nod(OINDEX, selv, nodintconst(int64(i))), lookup(f)), val)
r = typecheck(r, Etop) r = typecheck(r, ctxStmt)
init = append(init, r) init = append(init, r)
} }
...@@ -340,7 +340,7 @@ func walkselectcases(cases *Nodes) []*Node { ...@@ -340,7 +340,7 @@ func walkselectcases(cases *Nodes) []*Node {
r.List.Set2(chosen, recvOK) r.List.Set2(chosen, recvOK)
fn := syslook("selectgo") fn := syslook("selectgo")
r.Rlist.Set1(mkcall1(fn, fn.Type.Results(), nil, bytePtrToIndex(selv, 0), bytePtrToIndex(order, 0), nodintconst(int64(n)))) r.Rlist.Set1(mkcall1(fn, fn.Type.Results(), nil, bytePtrToIndex(selv, 0), bytePtrToIndex(order, 0), nodintconst(int64(n))))
r = typecheck(r, Etop) r = typecheck(r, ctxStmt)
init = append(init, r) init = append(init, r)
// selv and order are no longer alive after selectgo. // selv and order are no longer alive after selectgo.
...@@ -352,14 +352,14 @@ func walkselectcases(cases *Nodes) []*Node { ...@@ -352,14 +352,14 @@ func walkselectcases(cases *Nodes) []*Node {
setlineno(cas) setlineno(cas)
cond := nod(OEQ, chosen, nodintconst(int64(i))) cond := nod(OEQ, chosen, nodintconst(int64(i)))
cond = typecheck(cond, Erv) cond = typecheck(cond, ctxExpr)
cond = defaultlit(cond, nil) cond = defaultlit(cond, nil)
r = nod(OIF, cond, nil) r = nod(OIF, cond, nil)
if n := cas.Left; n != nil && n.Op == OSELRECV2 { if n := cas.Left; n != nil && n.Op == OSELRECV2 {
x := nod(OAS, n.List.First(), recvOK) x := nod(OAS, n.List.First(), recvOK)
x = typecheck(x, Etop) x = typecheck(x, ctxStmt)
r.Nbody.Append(x) r.Nbody.Append(x)
} }
......
...@@ -411,7 +411,7 @@ func staticassign(l *Node, r *Node, out *[]*Node) bool { ...@@ -411,7 +411,7 @@ func staticassign(l *Node, r *Node, out *[]*Node) bool {
} }
//dump("not static ptrlit", r); //dump("not static ptrlit", r);
case OSTRARRAYBYTE: case OSTR2BYTES:
if l.Class() == PEXTERN && r.Left.Op == OLITERAL { if l.Class() == PEXTERN && r.Left.Op == OLITERAL {
sval := r.Left.Val().U.(string) sval := r.Left.Val().U.(string)
slicebytes(l, sval, len(sval)) slicebytes(l, sval, len(sval))
...@@ -585,7 +585,7 @@ func (n *Node) isSimpleName() bool { ...@@ -585,7 +585,7 @@ func (n *Node) isSimpleName() bool {
func litas(l *Node, r *Node, init *Nodes) { func litas(l *Node, r *Node, init *Nodes) {
a := nod(OAS, l, r) a := nod(OAS, l, r)
a = typecheck(a, Etop) a = typecheck(a, ctxStmt)
a = walkexpr(a, init) a = walkexpr(a, init)
init.Append(a) init.Append(a)
} }
...@@ -746,7 +746,7 @@ func fixedlit(ctxt initContext, kind initKind, n *Node, var_ *Node, init *Nodes) ...@@ -746,7 +746,7 @@ func fixedlit(ctxt initContext, kind initKind, n *Node, var_ *Node, init *Nodes)
// build list of assignments: var[index] = expr // build list of assignments: var[index] = expr
setlineno(value) setlineno(value)
a = nod(OAS, a, value) a = nod(OAS, a, value)
a = typecheck(a, Etop) a = typecheck(a, ctxStmt)
switch kind { switch kind {
case initKindStatic: case initKindStatic:
genAsStatic(a) genAsStatic(a)
...@@ -774,7 +774,7 @@ func slicelit(ctxt initContext, n *Node, var_ *Node, init *Nodes) { ...@@ -774,7 +774,7 @@ func slicelit(ctxt initContext, n *Node, var_ *Node, init *Nodes) {
fixedlit(ctxt, initKindDynamic, n, vstat, init) fixedlit(ctxt, initKindDynamic, n, vstat, init)
// copy static to slice // copy static to slice
var_ = typecheck(var_, Erv|Easgn) var_ = typecheck(var_, ctxExpr|ctxAssign)
var nam Node var nam Node
if !stataddr(&nam, var_) || nam.Class() != PEXTERN { if !stataddr(&nam, var_) || nam.Class() != PEXTERN {
Fatalf("slicelit: %v", var_) Fatalf("slicelit: %v", var_)
...@@ -839,7 +839,7 @@ func slicelit(ctxt initContext, n *Node, var_ *Node, init *Nodes) { ...@@ -839,7 +839,7 @@ func slicelit(ctxt initContext, n *Node, var_ *Node, init *Nodes) {
if vstat == nil { if vstat == nil {
a = nod(OAS, x, nil) a = nod(OAS, x, nil)
a = typecheck(a, Etop) a = typecheck(a, ctxStmt)
init.Append(a) // zero new temp init.Append(a) // zero new temp
} else { } else {
// Declare that we're about to initialize all of x. // Declare that we're about to initialize all of x.
...@@ -852,7 +852,7 @@ func slicelit(ctxt initContext, n *Node, var_ *Node, init *Nodes) { ...@@ -852,7 +852,7 @@ func slicelit(ctxt initContext, n *Node, var_ *Node, init *Nodes) {
a = temp(t) a = temp(t)
if vstat == nil { if vstat == nil {
a = nod(OAS, temp(t), nil) a = nod(OAS, temp(t), nil)
a = typecheck(a, Etop) a = typecheck(a, ctxStmt)
init.Append(a) // zero new temp init.Append(a) // zero new temp
a = a.Left a = a.Left
} else { } else {
...@@ -866,16 +866,16 @@ func slicelit(ctxt initContext, n *Node, var_ *Node, init *Nodes) { ...@@ -866,16 +866,16 @@ func slicelit(ctxt initContext, n *Node, var_ *Node, init *Nodes) {
} }
a = nod(OAS, vauto, a) a = nod(OAS, vauto, a)
a = typecheck(a, Etop) a = typecheck(a, ctxStmt)
a = walkexpr(a, init) a = walkexpr(a, init)
init.Append(a) init.Append(a)
if vstat != nil { if vstat != nil {
// copy static to heap (4) // copy static to heap (4)
a = nod(OIND, vauto, nil) a = nod(ODEREF, vauto, nil)
a = nod(OAS, a, vstat) a = nod(OAS, a, vstat)
a = typecheck(a, Etop) a = typecheck(a, ctxStmt)
a = walkexpr(a, init) a = walkexpr(a, init)
init.Append(a) init.Append(a)
} }
...@@ -910,7 +910,7 @@ func slicelit(ctxt initContext, n *Node, var_ *Node, init *Nodes) { ...@@ -910,7 +910,7 @@ func slicelit(ctxt initContext, n *Node, var_ *Node, init *Nodes) {
setlineno(value) setlineno(value)
a = nod(OAS, a, value) a = nod(OAS, a, value)
a = typecheck(a, Etop) a = typecheck(a, ctxStmt)
a = orderStmtInPlace(a, map[string][]*Node{}) a = orderStmtInPlace(a, map[string][]*Node{})
a = walkstmt(a) a = walkstmt(a)
init.Append(a) init.Append(a)
...@@ -919,7 +919,7 @@ func slicelit(ctxt initContext, n *Node, var_ *Node, init *Nodes) { ...@@ -919,7 +919,7 @@ func slicelit(ctxt initContext, n *Node, var_ *Node, init *Nodes) {
// make slice out of heap (6) // make slice out of heap (6)
a = nod(OAS, var_, nod(OSLICE, vauto, nil)) a = nod(OAS, var_, nod(OSLICE, vauto, nil))
a = typecheck(a, Etop) a = typecheck(a, ctxStmt)
a = orderStmtInPlace(a, map[string][]*Node{}) a = orderStmtInPlace(a, map[string][]*Node{})
a = walkstmt(a) a = walkstmt(a)
init.Append(a) init.Append(a)
...@@ -993,7 +993,7 @@ func maplit(n *Node, m *Node, init *Nodes) { ...@@ -993,7 +993,7 @@ func maplit(n *Node, m *Node, init *Nodes) {
loop.Nbody.Set1(body) loop.Nbody.Set1(body)
loop.Ninit.Set1(zero) loop.Ninit.Set1(zero)
loop = typecheck(loop, Etop) loop = typecheck(loop, ctxStmt)
loop = walkstmt(loop) loop = walkstmt(loop)
init.Append(loop) init.Append(loop)
} else { } else {
...@@ -1023,19 +1023,19 @@ func addMapEntries(m *Node, dyn []*Node, init *Nodes) { ...@@ -1023,19 +1023,19 @@ func addMapEntries(m *Node, dyn []*Node, init *Nodes) {
setlineno(index) setlineno(index)
a := nod(OAS, key, index) a := nod(OAS, key, index)
a = typecheck(a, Etop) a = typecheck(a, ctxStmt)
a = walkstmt(a) a = walkstmt(a)
init.Append(a) init.Append(a)
setlineno(value) setlineno(value)
a = nod(OAS, val, value) a = nod(OAS, val, value)
a = typecheck(a, Etop) a = typecheck(a, ctxStmt)
a = walkstmt(a) a = walkstmt(a)
init.Append(a) init.Append(a)
setlineno(val) setlineno(val)
a = nod(OAS, nod(OINDEX, m, key), val) a = nod(OAS, nod(OINDEX, m, key), val)
a = typecheck(a, Etop) a = typecheck(a, ctxStmt)
a = walkstmt(a) a = walkstmt(a)
init.Append(a) init.Append(a)
...@@ -1045,10 +1045,10 @@ func addMapEntries(m *Node, dyn []*Node, init *Nodes) { ...@@ -1045,10 +1045,10 @@ func addMapEntries(m *Node, dyn []*Node, init *Nodes) {
} }
a := nod(OVARKILL, key, nil) a := nod(OVARKILL, key, nil)
a = typecheck(a, Etop) a = typecheck(a, ctxStmt)
init.Append(a) init.Append(a)
a = nod(OVARKILL, val, nil) a = nod(OVARKILL, val, nil)
a = typecheck(a, Etop) a = typecheck(a, ctxStmt)
init.Append(a) init.Append(a)
} }
...@@ -1068,7 +1068,7 @@ func anylit(n *Node, var_ *Node, init *Nodes) { ...@@ -1068,7 +1068,7 @@ func anylit(n *Node, var_ *Node, init *Nodes) {
// n.Right is stack temporary used as backing store. // n.Right is stack temporary used as backing store.
init.Append(nod(OAS, n.Right, nil)) // zero backing store, just in case (#18410) init.Append(nod(OAS, n.Right, nil)) // zero backing store, just in case (#18410)
r = nod(OADDR, n.Right, nil) r = nod(OADDR, n.Right, nil)
r = typecheck(r, Erv) r = typecheck(r, ctxExpr)
} else { } else {
r = nod(ONEW, nil, nil) r = nod(ONEW, nil, nil)
r.SetTypecheck(1) r.SetTypecheck(1)
...@@ -1079,11 +1079,11 @@ func anylit(n *Node, var_ *Node, init *Nodes) { ...@@ -1079,11 +1079,11 @@ func anylit(n *Node, var_ *Node, init *Nodes) {
r = walkexpr(r, init) r = walkexpr(r, init)
a := nod(OAS, var_, r) a := nod(OAS, var_, r)
a = typecheck(a, Etop) a = typecheck(a, ctxStmt)
init.Append(a) init.Append(a)
var_ = nod(OIND, var_, nil) var_ = nod(ODEREF, var_, nil)
var_ = typecheck(var_, Erv|Easgn) var_ = typecheck(var_, ctxExpr|ctxAssign)
anylit(n.Left, var_, init) anylit(n.Left, var_, init)
case OSTRUCTLIT, OARRAYLIT: case OSTRUCTLIT, OARRAYLIT:
...@@ -1105,7 +1105,7 @@ func anylit(n *Node, var_ *Node, init *Nodes) { ...@@ -1105,7 +1105,7 @@ func anylit(n *Node, var_ *Node, init *Nodes) {
// copy static to var // copy static to var
a := nod(OAS, var_, vstat) a := nod(OAS, var_, vstat)
a = typecheck(a, Etop) a = typecheck(a, ctxStmt)
a = walkexpr(a, init) a = walkexpr(a, init)
init.Append(a) init.Append(a)
...@@ -1123,7 +1123,7 @@ func anylit(n *Node, var_ *Node, init *Nodes) { ...@@ -1123,7 +1123,7 @@ func anylit(n *Node, var_ *Node, init *Nodes) {
// initialization of an array or struct with unspecified components (missing fields or arrays) // initialization of an array or struct with unspecified components (missing fields or arrays)
if var_.isSimpleName() || int64(n.List.Len()) < components { if var_.isSimpleName() || int64(n.List.Len()) < components {
a := nod(OAS, var_, nil) a := nod(OAS, var_, nil)
a = typecheck(a, Etop) a = typecheck(a, ctxStmt)
a = walkexpr(a, init) a = walkexpr(a, init)
init.Append(a) init.Append(a)
} }
......
...@@ -803,7 +803,7 @@ func (s *state) stmt(n *Node) { ...@@ -803,7 +803,7 @@ func (s *state) stmt(n *Node) {
} }
case ODEFER: case ODEFER:
s.call(n.Left, callDefer) s.call(n.Left, callDefer)
case OPROC: case OGO:
s.call(n.Left, callGo) s.call(n.Left, callGo)
case OAS2DOTTYPE: case OAS2DOTTYPE:
...@@ -1268,25 +1268,25 @@ var opToSSA = map[opAndType]ssa.Op{ ...@@ -1268,25 +1268,25 @@ var opToSSA = map[opAndType]ssa.Op{
opAndType{ONOT, TBOOL}: ssa.OpNot, opAndType{ONOT, TBOOL}: ssa.OpNot,
opAndType{OMINUS, TINT8}: ssa.OpNeg8, opAndType{ONEG, TINT8}: ssa.OpNeg8,
opAndType{OMINUS, TUINT8}: ssa.OpNeg8, opAndType{ONEG, TUINT8}: ssa.OpNeg8,
opAndType{OMINUS, TINT16}: ssa.OpNeg16, opAndType{ONEG, TINT16}: ssa.OpNeg16,
opAndType{OMINUS, TUINT16}: ssa.OpNeg16, opAndType{ONEG, TUINT16}: ssa.OpNeg16,
opAndType{OMINUS, TINT32}: ssa.OpNeg32, opAndType{ONEG, TINT32}: ssa.OpNeg32,
opAndType{OMINUS, TUINT32}: ssa.OpNeg32, opAndType{ONEG, TUINT32}: ssa.OpNeg32,
opAndType{OMINUS, TINT64}: ssa.OpNeg64, opAndType{ONEG, TINT64}: ssa.OpNeg64,
opAndType{OMINUS, TUINT64}: ssa.OpNeg64, opAndType{ONEG, TUINT64}: ssa.OpNeg64,
opAndType{OMINUS, TFLOAT32}: ssa.OpNeg32F, opAndType{ONEG, TFLOAT32}: ssa.OpNeg32F,
opAndType{OMINUS, TFLOAT64}: ssa.OpNeg64F, opAndType{ONEG, TFLOAT64}: ssa.OpNeg64F,
opAndType{OCOM, TINT8}: ssa.OpCom8, opAndType{OBITNOT, TINT8}: ssa.OpCom8,
opAndType{OCOM, TUINT8}: ssa.OpCom8, opAndType{OBITNOT, TUINT8}: ssa.OpCom8,
opAndType{OCOM, TINT16}: ssa.OpCom16, opAndType{OBITNOT, TINT16}: ssa.OpCom16,
opAndType{OCOM, TUINT16}: ssa.OpCom16, opAndType{OBITNOT, TUINT16}: ssa.OpCom16,
opAndType{OCOM, TINT32}: ssa.OpCom32, opAndType{OBITNOT, TINT32}: ssa.OpCom32,
opAndType{OCOM, TUINT32}: ssa.OpCom32, opAndType{OBITNOT, TUINT32}: ssa.OpCom32,
opAndType{OCOM, TINT64}: ssa.OpCom64, opAndType{OBITNOT, TINT64}: ssa.OpCom64,
opAndType{OCOM, TUINT64}: ssa.OpCom64, opAndType{OBITNOT, TUINT64}: ssa.OpCom64,
opAndType{OIMAG, TCOMPLEX64}: ssa.OpComplexImag, opAndType{OIMAG, TCOMPLEX64}: ssa.OpComplexImag,
opAndType{OIMAG, TCOMPLEX128}: ssa.OpComplexImag, opAndType{OIMAG, TCOMPLEX128}: ssa.OpComplexImag,
...@@ -1655,12 +1655,12 @@ func (s *state) expr(n *Node) *ssa.Value { ...@@ -1655,12 +1655,12 @@ func (s *state) expr(n *Node) *ssa.Value {
s.stmtList(n.Ninit) s.stmtList(n.Ninit)
switch n.Op { switch n.Op {
case OARRAYBYTESTRTMP: case OBYTES2STRTMP:
slice := s.expr(n.Left) slice := s.expr(n.Left)
ptr := s.newValue1(ssa.OpSlicePtr, s.f.Config.Types.BytePtr, slice) ptr := s.newValue1(ssa.OpSlicePtr, s.f.Config.Types.BytePtr, slice)
len := s.newValue1(ssa.OpSliceLen, types.Types[TINT], slice) len := s.newValue1(ssa.OpSliceLen, types.Types[TINT], slice)
return s.newValue2(ssa.OpStringMake, n.Type, ptr, len) return s.newValue2(ssa.OpStringMake, n.Type, ptr, len)
case OSTRARRAYBYTETMP: case OSTR2BYTESTMP:
str := s.expr(n.Left) str := s.expr(n.Left)
ptr := s.newValue1(ssa.OpStringPtr, s.f.Config.Types.BytePtr, str) ptr := s.newValue1(ssa.OpStringPtr, s.f.Config.Types.BytePtr, str)
len := s.newValue1(ssa.OpStringLen, types.Types[TINT], str) len := s.newValue1(ssa.OpStringLen, types.Types[TINT], str)
...@@ -2174,7 +2174,7 @@ func (s *state) expr(n *Node) *ssa.Value { ...@@ -2174,7 +2174,7 @@ func (s *state) expr(n *Node) *ssa.Value {
return s.newValue2(ssa.OpComplexMake, n.Type, r, i) return s.newValue2(ssa.OpComplexMake, n.Type, r, i)
// unary ops // unary ops
case OMINUS: case ONEG:
a := s.expr(n.Left) a := s.expr(n.Left)
if n.Type.IsComplex() { if n.Type.IsComplex() {
tp := floatForComplex(n.Type) tp := floatForComplex(n.Type)
...@@ -2184,7 +2184,7 @@ func (s *state) expr(n *Node) *ssa.Value { ...@@ -2184,7 +2184,7 @@ func (s *state) expr(n *Node) *ssa.Value {
s.newValue1(negop, tp, s.newValue1(ssa.OpComplexImag, tp, a))) s.newValue1(negop, tp, s.newValue1(ssa.OpComplexImag, tp, a)))
} }
return s.newValue1(s.ssaOp(n.Op, n.Type), a.Type, a) return s.newValue1(s.ssaOp(n.Op, n.Type), a.Type, a)
case ONOT, OCOM: case ONOT, OBITNOT:
a := s.expr(n.Left) a := s.expr(n.Left)
return s.newValue1(s.ssaOp(n.Op, n.Type), a.Type, a) return s.newValue1(s.ssaOp(n.Op, n.Type), a.Type, a)
case OIMAG, OREAL: case OIMAG, OREAL:
...@@ -2200,7 +2200,7 @@ func (s *state) expr(n *Node) *ssa.Value { ...@@ -2200,7 +2200,7 @@ func (s *state) expr(n *Node) *ssa.Value {
addr := s.constOffPtrSP(types.NewPtr(n.Type), n.Xoffset) addr := s.constOffPtrSP(types.NewPtr(n.Type), n.Xoffset)
return s.load(n.Type, addr) return s.load(n.Type, addr)
case OIND: case ODEREF:
p := s.exprPtr(n.Left, false, n.Pos) p := s.exprPtr(n.Left, false, n.Pos)
return s.load(n.Type, p) return s.load(n.Type, p)
...@@ -2838,7 +2838,7 @@ func (s *state) sfcall(op ssa.Op, args ...*ssa.Value) (*ssa.Value, bool) { ...@@ -2838,7 +2838,7 @@ func (s *state) sfcall(op ssa.Op, args ...*ssa.Value) (*ssa.Value, bool) {
args[0], args[1] = args[1], args[0] args[0], args[1] = args[1], args[0]
case ssa.OpSub32F, case ssa.OpSub32F,
ssa.OpSub64F: ssa.OpSub64F:
args[1] = s.newValue1(s.ssaOp(OMINUS, types.Types[callDef.rtype]), args[1].Type, args[1]) args[1] = s.newValue1(s.ssaOp(ONEG, types.Types[callDef.rtype]), args[1].Type, args[1])
} }
result := s.rtcall(callDef.rtfn, true, []*types.Type{types.Types[callDef.rtype]}, args...)[0] result := s.rtcall(callDef.rtfn, true, []*types.Type{types.Types[callDef.rtype]}, args...)[0]
...@@ -2915,7 +2915,7 @@ func init() { ...@@ -2915,7 +2915,7 @@ func init() {
if !instrumenting { if !instrumenting {
add("runtime", "slicebytetostringtmp", add("runtime", "slicebytetostringtmp",
func(s *state, n *Node, args []*ssa.Value) *ssa.Value { func(s *state, n *Node, args []*ssa.Value) *ssa.Value {
// Compiler frontend optimizations emit OARRAYBYTESTRTMP nodes // Compiler frontend optimizations emit OBYTES2STRTMP nodes
// for the backend instead of slicebytetostringtmp calls // for the backend instead of slicebytetostringtmp calls
// when not instrumenting. // when not instrumenting.
slice := args[0] slice := args[0]
...@@ -3861,7 +3861,7 @@ func (s *state) addr(n *Node, bounded bool) *ssa.Value { ...@@ -3861,7 +3861,7 @@ func (s *state) addr(n *Node, bounded bool) *ssa.Value {
} }
return s.newValue2(ssa.OpPtrIndex, types.NewPtr(n.Left.Type.Elem()), a, i) return s.newValue2(ssa.OpPtrIndex, types.NewPtr(n.Left.Type.Elem()), a, i)
} }
case OIND: case ODEREF:
return s.exprPtr(n.Left, bounded, n.Pos) return s.exprPtr(n.Left, bounded, n.Pos)
case ODOT: case ODOT:
p := s.addr(n.Left, bounded) p := s.addr(n.Left, bounded)
......
...@@ -767,10 +767,10 @@ func convertop(src *types.Type, dst *types.Type, why *string) Op { ...@@ -767,10 +767,10 @@ func convertop(src *types.Type, dst *types.Type, why *string) Op {
if src.IsSlice() && dst.IsString() { if src.IsSlice() && dst.IsString() {
if src.Elem().Etype == types.Bytetype.Etype { if src.Elem().Etype == types.Bytetype.Etype {
return OARRAYBYTESTR return OBYTES2STR
} }
if src.Elem().Etype == types.Runetype.Etype { if src.Elem().Etype == types.Runetype.Etype {
return OARRAYRUNESTR return ORUNES2STR
} }
} }
...@@ -778,10 +778,10 @@ func convertop(src *types.Type, dst *types.Type, why *string) Op { ...@@ -778,10 +778,10 @@ func convertop(src *types.Type, dst *types.Type, why *string) Op {
// String to slice. // String to slice.
if src.IsString() && dst.IsSlice() { if src.IsString() && dst.IsSlice() {
if dst.Elem().Etype == types.Bytetype.Etype { if dst.Elem().Etype == types.Bytetype.Etype {
return OSTRARRAYBYTE return OSTR2BYTES
} }
if dst.Elem().Etype == types.Runetype.Etype { if dst.Elem().Etype == types.Runetype.Etype {
return OSTRARRAYRUNE return OSTR2RUNES
} }
} }
...@@ -999,14 +999,14 @@ func calcHasCall(n *Node) bool { ...@@ -999,14 +999,14 @@ func calcHasCall(n *Node) bool {
return true return true
} }
case OINDEX, OSLICE, OSLICEARR, OSLICE3, OSLICE3ARR, OSLICESTR, case OINDEX, OSLICE, OSLICEARR, OSLICE3, OSLICE3ARR, OSLICESTR,
OIND, ODOTPTR, ODOTTYPE, ODIV, OMOD: ODEREF, ODOTPTR, ODOTTYPE, ODIV, OMOD:
// These ops might panic, make sure they are done // These ops might panic, make sure they are done
// before we start marshaling args for a call. See issue 16760. // before we start marshaling args for a call. See issue 16760.
return true return true
// When using soft-float, these ops might be rewritten to function calls // When using soft-float, these ops might be rewritten to function calls
// so we ensure they are evaluated first. // so we ensure they are evaluated first.
case OADD, OSUB, OMINUS, OMUL: case OADD, OSUB, ONEG, OMUL:
if thearch.SoftFloat && (isFloat[n.Type.Etype] || isComplex[n.Type.Etype]) { if thearch.SoftFloat && (isFloat[n.Type.Etype] || isComplex[n.Type.Etype]) {
return true return true
} }
...@@ -1116,11 +1116,11 @@ func safeexpr(n *Node, init *Nodes) *Node { ...@@ -1116,11 +1116,11 @@ func safeexpr(n *Node, init *Nodes) *Node {
} }
r := n.copy() r := n.copy()
r.Left = l r.Left = l
r = typecheck(r, Erv) r = typecheck(r, ctxExpr)
r = walkexpr(r, init) r = walkexpr(r, init)
return r return r
case ODOTPTR, OIND: case ODOTPTR, ODEREF:
l := safeexpr(n.Left, init) l := safeexpr(n.Left, init)
if l == n.Left { if l == n.Left {
return n return n
...@@ -1158,7 +1158,7 @@ func safeexpr(n *Node, init *Nodes) *Node { ...@@ -1158,7 +1158,7 @@ func safeexpr(n *Node, init *Nodes) *Node {
func copyexpr(n *Node, t *types.Type, init *Nodes) *Node { func copyexpr(n *Node, t *types.Type, init *Nodes) *Node {
l := temp(t) l := temp(t)
a := nod(OAS, l, n) a := nod(OAS, l, n)
a = typecheck(a, Etop) a = typecheck(a, ctxStmt)
a = walkexpr(a, init) a = walkexpr(a, init)
init.Append(a) init.Append(a)
return l return l
...@@ -1308,7 +1308,7 @@ func dotpath(s *types.Sym, t *types.Type, save **types.Field, ignorecase bool) ( ...@@ -1308,7 +1308,7 @@ func dotpath(s *types.Sym, t *types.Type, save **types.Field, ignorecase bool) (
// will give shortest unique addressing. // will give shortest unique addressing.
// modify the tree with missing type names. // modify the tree with missing type names.
func adddot(n *Node) *Node { func adddot(n *Node) *Node {
n.Left = typecheck(n.Left, Etype|Erv) n.Left = typecheck(n.Left, Etype|ctxExpr)
if n.Left.Diag() { if n.Left.Diag() {
n.SetDiag(true) n.SetDiag(true)
} }
...@@ -1478,7 +1478,7 @@ func structargs(tl *types.Type, mustname bool) []*Node { ...@@ -1478,7 +1478,7 @@ func structargs(tl *types.Type, mustname bool) []*Node {
} }
a := symfield(s, t.Type) a := symfield(s, t.Type)
a.Pos = t.Pos a.Pos = t.Pos
a.SetIsddd(t.Isddd()) a.SetIsDDD(t.IsDDD())
args = append(args, a) args = append(args, a)
} }
...@@ -1571,7 +1571,7 @@ func genwrapper(rcvr *types.Type, method *types.Field, newnam *types.Sym) { ...@@ -1571,7 +1571,7 @@ func genwrapper(rcvr *types.Type, method *types.Field, newnam *types.Sym) {
fn.Func.SetWrapper(true) // ignore frame for panic+recover matching fn.Func.SetWrapper(true) // ignore frame for panic+recover matching
call := nod(OCALL, dot, nil) call := nod(OCALL, dot, nil)
call.List.Set(paramNnames(tfn.Type)) call.List.Set(paramNnames(tfn.Type))
call.SetIsddd(tfn.Type.IsVariadic()) call.SetIsDDD(tfn.Type.IsVariadic())
if method.Type.NumResults() > 0 { if method.Type.NumResults() > 0 {
n := nod(ORETURN, nil, nil) n := nod(ORETURN, nil, nil)
n.List.Set1(call) n.List.Set1(call)
...@@ -1589,10 +1589,10 @@ func genwrapper(rcvr *types.Type, method *types.Field, newnam *types.Sym) { ...@@ -1589,10 +1589,10 @@ func genwrapper(rcvr *types.Type, method *types.Field, newnam *types.Sym) {
testdclstack() testdclstack()
} }
fn = typecheck(fn, Etop) fn = typecheck(fn, ctxStmt)
Curfn = fn Curfn = fn
typecheckslice(fn.Nbody.Slice(), Etop) typecheckslice(fn.Nbody.Slice(), ctxStmt)
// Inline calls within (*T).M wrappers. This is safe because we only // Inline calls within (*T).M wrappers. This is safe because we only
// generate those wrappers within the same compilation unit as (T).M. // generate those wrappers within the same compilation unit as (T).M.
...@@ -1852,7 +1852,7 @@ func checknil(x *Node, init *Nodes) { ...@@ -1852,7 +1852,7 @@ func checknil(x *Node, init *Nodes) {
x = walkexpr(x, nil) // caller has not done this yet x = walkexpr(x, nil) // caller has not done this yet
if x.Type.IsInterface() { if x.Type.IsInterface() {
x = nod(OITAB, x, nil) x = nod(OITAB, x, nil)
x = typecheck(x, Erv) x = typecheck(x, ctxExpr)
} }
n := nod(OCHECKNIL, x, nil) n := nod(OCHECKNIL, x, nil)
...@@ -1910,7 +1910,7 @@ func ifaceData(n *Node, t *types.Type) *Node { ...@@ -1910,7 +1910,7 @@ func ifaceData(n *Node, t *types.Type) *Node {
ptr.Type = types.NewPtr(t) ptr.Type = types.NewPtr(t)
ptr.SetBounded(true) ptr.SetBounded(true)
ptr.SetTypecheck(1) ptr.SetTypecheck(1)
ind := nod(OIND, ptr, nil) ind := nod(ODEREF, ptr, nil)
ind.Type = t ind.Type = t
ind.SetTypecheck(1) ind.SetTypecheck(1)
return ind return ind
......
...@@ -56,7 +56,7 @@ type caseClauses struct { ...@@ -56,7 +56,7 @@ type caseClauses struct {
// typecheckswitch typechecks a switch statement. // typecheckswitch typechecks a switch statement.
func typecheckswitch(n *Node) { func typecheckswitch(n *Node) {
typecheckslice(n.Ninit.Slice(), Etop) typecheckslice(n.Ninit.Slice(), ctxStmt)
var nilonly string var nilonly string
var top int var top int
...@@ -65,7 +65,7 @@ func typecheckswitch(n *Node) { ...@@ -65,7 +65,7 @@ func typecheckswitch(n *Node) {
if n.Left != nil && n.Left.Op == OTYPESW { if n.Left != nil && n.Left.Op == OTYPESW {
// type switch // type switch
top = Etype top = Etype
n.Left.Right = typecheck(n.Left.Right, Erv) n.Left.Right = typecheck(n.Left.Right, ctxExpr)
t = n.Left.Right.Type t = n.Left.Right.Type
if t != nil && !t.IsInterface() { if t != nil && !t.IsInterface() {
yyerrorl(n.Pos, "cannot type switch on non-interface value %L", n.Left.Right) yyerrorl(n.Pos, "cannot type switch on non-interface value %L", n.Left.Right)
...@@ -78,9 +78,9 @@ func typecheckswitch(n *Node) { ...@@ -78,9 +78,9 @@ func typecheckswitch(n *Node) {
} }
} else { } else {
// expression switch // expression switch
top = Erv top = ctxExpr
if n.Left != nil { if n.Left != nil {
n.Left = typecheck(n.Left, Erv) n.Left = typecheck(n.Left, ctxExpr)
n.Left = defaultlit(n.Left, nil) n.Left = defaultlit(n.Left, nil)
t = n.Left.Type t = n.Left.Type
} else { } else {
...@@ -122,7 +122,7 @@ func typecheckswitch(n *Node) { ...@@ -122,7 +122,7 @@ func typecheckswitch(n *Node) {
ls := ncase.List.Slice() ls := ncase.List.Slice()
for i1, n1 := range ls { for i1, n1 := range ls {
setlineno(n1) setlineno(n1)
ls[i1] = typecheck(ls[i1], Erv|Etype) ls[i1] = typecheck(ls[i1], ctxExpr|Etype)
n1 = ls[i1] n1 = ls[i1]
if n1.Type == nil || t == nil { if n1.Type == nil || t == nil {
continue continue
...@@ -131,7 +131,7 @@ func typecheckswitch(n *Node) { ...@@ -131,7 +131,7 @@ func typecheckswitch(n *Node) {
setlineno(ncase) setlineno(ncase)
switch top { switch top {
// expression switch // expression switch
case Erv: case ctxExpr:
ls[i1] = defaultlit(ls[i1], t) ls[i1] = defaultlit(ls[i1], t)
n1 = ls[i1] n1 = ls[i1]
switch { switch {
...@@ -203,16 +203,16 @@ func typecheckswitch(n *Node) { ...@@ -203,16 +203,16 @@ func typecheckswitch(n *Node) {
nvar.Type = n.Type nvar.Type = n.Type
} }
nvar = typecheck(nvar, Erv|Easgn) nvar = typecheck(nvar, ctxExpr|ctxAssign)
ncase.Rlist.SetFirst(nvar) ncase.Rlist.SetFirst(nvar)
} }
} }
typecheckslice(ncase.Nbody.Slice(), Etop) typecheckslice(ncase.Nbody.Slice(), ctxStmt)
} }
switch top { switch top {
// expression switch // expression switch
case Erv: case ctxExpr:
checkDupExprCases(n.Left, n.List.Slice()) checkDupExprCases(n.Left, n.List.Slice())
} }
} }
...@@ -222,7 +222,7 @@ func walkswitch(sw *Node) { ...@@ -222,7 +222,7 @@ func walkswitch(sw *Node) {
// convert switch {...} to switch true {...} // convert switch {...} to switch true {...}
if sw.Left == nil { if sw.Left == nil {
sw.Left = nodbool(true) sw.Left = nodbool(true)
sw.Left = typecheck(sw.Left, Erv) sw.Left = typecheck(sw.Left, ctxExpr)
sw.Left = defaultlit(sw.Left, nil) sw.Left = defaultlit(sw.Left, nil)
} }
...@@ -271,7 +271,7 @@ func (s *exprSwitch) walk(sw *Node) { ...@@ -271,7 +271,7 @@ func (s *exprSwitch) walk(sw *Node) {
// because walkexpr will lower the string // because walkexpr will lower the string
// conversion into a runtime call. // conversion into a runtime call.
// See issue 24937 for more discussion. // See issue 24937 for more discussion.
if cond.Op == OARRAYBYTESTR { if cond.Op == OBYTES2STR {
ok := true ok := true
for _, cas := range sw.List.Slice() { for _, cas := range sw.List.Slice() {
if cas.Op != OCASE { if cas.Op != OCASE {
...@@ -283,7 +283,7 @@ func (s *exprSwitch) walk(sw *Node) { ...@@ -283,7 +283,7 @@ func (s *exprSwitch) walk(sw *Node) {
} }
} }
if ok { if ok {
cond.Op = OARRAYBYTESTRTMP cond.Op = OBYTES2STRTMP
} }
} }
...@@ -303,7 +303,7 @@ func (s *exprSwitch) walk(sw *Node) { ...@@ -303,7 +303,7 @@ func (s *exprSwitch) walk(sw *Node) {
} else { } else {
s.exprname = temp(cond.Type) s.exprname = temp(cond.Type)
cas = []*Node{nod(OAS, s.exprname, cond)} cas = []*Node{nod(OAS, s.exprname, cond)}
typecheckslice(cas, Etop) typecheckslice(cas, ctxStmt)
} }
// Enumerate the cases and prepare the default case. // Enumerate the cases and prepare the default case.
...@@ -362,7 +362,7 @@ func (s *exprSwitch) walkCases(cc []caseClause) *Node { ...@@ -362,7 +362,7 @@ func (s *exprSwitch) walkCases(cc []caseClause) *Node {
// s.kind == switchKindFalse // s.kind == switchKindFalse
a.Left = nod(ONOT, n.Left, nil) // if !val a.Left = nod(ONOT, n.Left, nil) // if !val
} }
a.Left = typecheck(a.Left, Erv) a.Left = typecheck(a.Left, ctxExpr)
a.Left = defaultlit(a.Left, nil) a.Left = defaultlit(a.Left, nil)
a.Nbody.Set1(n.Right) // goto l a.Nbody.Set1(n.Right) // goto l
...@@ -391,7 +391,7 @@ func (s *exprSwitch) walkCases(cc []caseClause) *Node { ...@@ -391,7 +391,7 @@ func (s *exprSwitch) walkCases(cc []caseClause) *Node {
} else { } else {
a.Left = le a.Left = le
} }
a.Left = typecheck(a.Left, Erv) a.Left = typecheck(a.Left, ctxExpr)
a.Left = defaultlit(a.Left, nil) a.Left = defaultlit(a.Left, nil)
a.Nbody.Set1(s.walkCases(cc[:half])) a.Nbody.Set1(s.walkCases(cc[:half]))
a.Rlist.Set1(s.walkCases(cc[half:])) a.Rlist.Set1(s.walkCases(cc[half:]))
...@@ -493,7 +493,7 @@ func casebody(sw *Node, typeswvar *Node) { ...@@ -493,7 +493,7 @@ func casebody(sw *Node, typeswvar *Node) {
nod(ODCL, n.Rlist.First(), nil), nod(ODCL, n.Rlist.First(), nil),
nod(OAS, n.Rlist.First(), typeswvar), nod(OAS, n.Rlist.First(), typeswvar),
} }
typecheckslice(l, Etop) typecheckslice(l, ctxStmt)
stat = append(stat, l...) stat = append(stat, l...)
} }
stat = append(stat, n.Nbody.Slice()...) stat = append(stat, n.Nbody.Slice()...)
...@@ -742,14 +742,14 @@ func (s *typeSwitch) walk(sw *Node) { ...@@ -742,14 +742,14 @@ func (s *typeSwitch) walk(sw *Node) {
s.facename = temp(cond.Right.Type) s.facename = temp(cond.Right.Type)
a := nod(OAS, s.facename, cond.Right) a := nod(OAS, s.facename, cond.Right)
a = typecheck(a, Etop) a = typecheck(a, ctxStmt)
cas = append(cas, a) cas = append(cas, a)
s.okname = temp(types.Types[TBOOL]) s.okname = temp(types.Types[TBOOL])
s.okname = typecheck(s.okname, Erv) s.okname = typecheck(s.okname, ctxExpr)
s.hashname = temp(types.Types[TUINT32]) s.hashname = temp(types.Types[TUINT32])
s.hashname = typecheck(s.hashname, Erv) s.hashname = typecheck(s.hashname, ctxExpr)
// set up labels and jumps // set up labels and jumps
casebody(sw, s.facename) casebody(sw, s.facename)
...@@ -785,7 +785,7 @@ func (s *typeSwitch) walk(sw *Node) { ...@@ -785,7 +785,7 @@ func (s *typeSwitch) walk(sw *Node) {
blk.List.Set2(nodSym(OLABEL, nil, lbl), def) blk.List.Set2(nodSym(OLABEL, nil, lbl), def)
def = blk def = blk
} }
i.Left = typecheck(i.Left, Erv) i.Left = typecheck(i.Left, ctxExpr)
i.Left = defaultlit(i.Left, nil) i.Left = defaultlit(i.Left, nil)
cas = append(cas, i) cas = append(cas, i)
...@@ -800,7 +800,7 @@ func (s *typeSwitch) walk(sw *Node) { ...@@ -800,7 +800,7 @@ func (s *typeSwitch) walk(sw *Node) {
} }
h.SetBounded(true) // guaranteed not to fault h.SetBounded(true) // guaranteed not to fault
a = nod(OAS, s.hashname, h) a = nod(OAS, s.hashname, h)
a = typecheck(a, Etop) a = typecheck(a, ctxStmt)
cas = append(cas, a) cas = append(cas, a)
cc := clauses.list cc := clauses.list
...@@ -868,12 +868,12 @@ func (s *typeSwitch) typeone(t *Node) *Node { ...@@ -868,12 +868,12 @@ func (s *typeSwitch) typeone(t *Node) *Node {
var init Nodes var init Nodes
if t.Rlist.Len() == 0 { if t.Rlist.Len() == 0 {
name = nblank name = nblank
nblank = typecheck(nblank, Erv|Easgn) nblank = typecheck(nblank, ctxExpr|ctxAssign)
} else { } else {
name = t.Rlist.First() name = t.Rlist.First()
init.Append(nod(ODCL, name, nil)) init.Append(nod(ODCL, name, nil))
a := nod(OAS, name, nil) a := nod(OAS, name, nil)
a = typecheck(a, Etop) a = typecheck(a, ctxStmt)
init.Append(a) init.Append(a)
} }
...@@ -882,7 +882,7 @@ func (s *typeSwitch) typeone(t *Node) *Node { ...@@ -882,7 +882,7 @@ func (s *typeSwitch) typeone(t *Node) *Node {
b := nod(ODOTTYPE, s.facename, nil) b := nod(ODOTTYPE, s.facename, nil)
b.Type = t.Left.Type // interface.(type) b.Type = t.Left.Type // interface.(type)
a.Rlist.Set1(b) a.Rlist.Set1(b)
a = typecheck(a, Etop) a = typecheck(a, ctxStmt)
a = walkexpr(a, &init) a = walkexpr(a, &init)
init.Append(a) init.Append(a)
...@@ -905,7 +905,7 @@ func (s *typeSwitch) walkCases(cc []caseClause) *Node { ...@@ -905,7 +905,7 @@ func (s *typeSwitch) walkCases(cc []caseClause) *Node {
} }
a := nod(OIF, nil, nil) a := nod(OIF, nil, nil)
a.Left = nod(OEQ, s.hashname, nodintconst(int64(c.hash))) a.Left = nod(OEQ, s.hashname, nodintconst(int64(c.hash)))
a.Left = typecheck(a.Left, Erv) a.Left = typecheck(a.Left, ctxExpr)
a.Left = defaultlit(a.Left, nil) a.Left = defaultlit(a.Left, nil)
a.Nbody.Set1(n.Right) a.Nbody.Set1(n.Right)
cas = append(cas, a) cas = append(cas, a)
...@@ -917,7 +917,7 @@ func (s *typeSwitch) walkCases(cc []caseClause) *Node { ...@@ -917,7 +917,7 @@ func (s *typeSwitch) walkCases(cc []caseClause) *Node {
half := len(cc) / 2 half := len(cc) / 2
a := nod(OIF, nil, nil) a := nod(OIF, nil, nil)
a.Left = nod(OLE, s.hashname, nodintconst(int64(cc[half-1].hash))) a.Left = nod(OLE, s.hashname, nodintconst(int64(cc[half-1].hash)))
a.Left = typecheck(a.Left, Erv) a.Left = typecheck(a.Left, ctxExpr)
a.Left = defaultlit(a.Left, nil) a.Left = defaultlit(a.Left, nil)
a.Nbody.Set1(s.walkCases(cc[:half])) a.Nbody.Set1(s.walkCases(cc[:half]))
a.Rlist.Set1(s.walkCases(cc[half:])) a.Rlist.Set1(s.walkCases(cc[half:]))
......
...@@ -144,7 +144,7 @@ const ( ...@@ -144,7 +144,7 @@ const (
_, nodeAssigned // is the variable ever assigned to _, nodeAssigned // is the variable ever assigned to
_, nodeAddrtaken // address taken, even if not moved to heap _, nodeAddrtaken // address taken, even if not moved to heap
_, nodeImplicit _, nodeImplicit
_, nodeIsddd // is the argument variadic _, nodeIsDDD // is the argument variadic
_, nodeDiag // already printed error about this _, nodeDiag // already printed error about this
_, nodeColas // OAS resulting from := _, nodeColas // OAS resulting from :=
_, nodeNonNil // guaranteed to be non-nil _, nodeNonNil // guaranteed to be non-nil
...@@ -172,7 +172,7 @@ func (n *Node) IsOutputParamHeapAddr() bool { return n.flags&nodeIsOutputParamHe ...@@ -172,7 +172,7 @@ func (n *Node) IsOutputParamHeapAddr() bool { return n.flags&nodeIsOutputParamHe
func (n *Node) Assigned() bool { return n.flags&nodeAssigned != 0 } func (n *Node) Assigned() bool { return n.flags&nodeAssigned != 0 }
func (n *Node) Addrtaken() bool { return n.flags&nodeAddrtaken != 0 } func (n *Node) Addrtaken() bool { return n.flags&nodeAddrtaken != 0 }
func (n *Node) Implicit() bool { return n.flags&nodeImplicit != 0 } func (n *Node) Implicit() bool { return n.flags&nodeImplicit != 0 }
func (n *Node) Isddd() bool { return n.flags&nodeIsddd != 0 } func (n *Node) IsDDD() bool { return n.flags&nodeIsDDD != 0 }
func (n *Node) Diag() bool { return n.flags&nodeDiag != 0 } func (n *Node) Diag() bool { return n.flags&nodeDiag != 0 }
func (n *Node) Colas() bool { return n.flags&nodeColas != 0 } func (n *Node) Colas() bool { return n.flags&nodeColas != 0 }
func (n *Node) NonNil() bool { return n.flags&nodeNonNil != 0 } func (n *Node) NonNil() bool { return n.flags&nodeNonNil != 0 }
...@@ -199,7 +199,7 @@ func (n *Node) SetIsOutputParamHeapAddr(b bool) { n.flags.set(nodeIsOutputParamH ...@@ -199,7 +199,7 @@ func (n *Node) SetIsOutputParamHeapAddr(b bool) { n.flags.set(nodeIsOutputParamH
func (n *Node) SetAssigned(b bool) { n.flags.set(nodeAssigned, b) } func (n *Node) SetAssigned(b bool) { n.flags.set(nodeAssigned, b) }
func (n *Node) SetAddrtaken(b bool) { n.flags.set(nodeAddrtaken, b) } func (n *Node) SetAddrtaken(b bool) { n.flags.set(nodeAddrtaken, b) }
func (n *Node) SetImplicit(b bool) { n.flags.set(nodeImplicit, b) } func (n *Node) SetImplicit(b bool) { n.flags.set(nodeImplicit, b) }
func (n *Node) SetIsddd(b bool) { n.flags.set(nodeIsddd, b) } func (n *Node) SetIsDDD(b bool) { n.flags.set(nodeIsDDD, b) }
func (n *Node) SetDiag(b bool) { n.flags.set(nodeDiag, b) } func (n *Node) SetDiag(b bool) { n.flags.set(nodeDiag, b) }
func (n *Node) SetColas(b bool) { n.flags.set(nodeColas, b) } func (n *Node) SetColas(b bool) { n.flags.set(nodeColas, b) }
func (n *Node) SetNonNil(b bool) { n.flags.set(nodeNonNil, b) } func (n *Node) SetNonNil(b bool) { n.flags.set(nodeNonNil, b) }
...@@ -477,7 +477,7 @@ type Func struct { ...@@ -477,7 +477,7 @@ type Func struct {
FieldTrack map[*types.Sym]struct{} FieldTrack map[*types.Sym]struct{}
DebugInfo *ssa.FuncDebug DebugInfo *ssa.FuncDebug
Ntype *Node // signature Ntype *Node // signature
Top int // top context (Ecall, Eproc, etc) Top int // top context (ctxCallee, etc)
Closure *Node // OCLOSURE <-> ODCLFUNC Closure *Node // OCLOSURE <-> ODCLFUNC
Nname *Node Nname *Node
lsym *obj.LSym lsym *obj.LSym
...@@ -589,12 +589,12 @@ const ( ...@@ -589,12 +589,12 @@ const (
OADDR // &Left OADDR // &Left
OANDAND // Left && Right OANDAND // Left && Right
OAPPEND // append(List); after walk, Left may contain elem type descriptor OAPPEND // append(List); after walk, Left may contain elem type descriptor
OARRAYBYTESTR // Type(Left) (Type is string, Left is a []byte) OBYTES2STR // Type(Left) (Type is string, Left is a []byte)
OARRAYBYTESTRTMP // Type(Left) (Type is string, Left is a []byte, ephemeral) OBYTES2STRTMP // Type(Left) (Type is string, Left is a []byte, ephemeral)
OARRAYRUNESTR // Type(Left) (Type is string, Left is a []rune) ORUNES2STR // Type(Left) (Type is string, Left is a []rune)
OSTRARRAYBYTE // Type(Left) (Type is []byte, Left is a string) OSTR2BYTES // Type(Left) (Type is []byte, Left is a string)
OSTRARRAYBYTETMP // Type(Left) (Type is []byte, Left is a string, ephemeral) OSTR2BYTESTMP // Type(Left) (Type is []byte, Left is a string, ephemeral)
OSTRARRAYRUNE // Type(Left) (Type is []rune, Left is a string) OSTR2RUNES // Type(Left) (Type is []rune, Left is a string)
OAS // Left = Right or (if Colas=true) Left := Right OAS // Left = Right or (if Colas=true) Left := Right
OAS2 // List = Rlist (x, y, z = a, b, c) OAS2 // List = Rlist (x, y, z = a, b, c)
OAS2FUNC // List = Rlist (x, y = f()) OAS2FUNC // List = Rlist (x, y = f())
...@@ -650,7 +650,7 @@ const ( ...@@ -650,7 +650,7 @@ const (
OLE // Left <= Right OLE // Left <= Right
OGE // Left >= Right OGE // Left >= Right
OGT // Left > Right OGT // Left > Right
OIND // *Left ODEREF // *Left
OINDEX // Left[Right] (index of array or slice) OINDEX // Left[Right] (index of array or slice)
OINDEXMAP // Left[Right] (index of map) OINDEXMAP // Left[Right] (index of map)
OKEY // Left:Right (key:value in struct/array/map literal) OKEY // Left:Right (key:value in struct/array/map literal)
...@@ -669,9 +669,9 @@ const ( ...@@ -669,9 +669,9 @@ const (
OANDNOT // Left &^ Right OANDNOT // Left &^ Right
ONEW // new(Left) ONEW // new(Left)
ONOT // !Left ONOT // !Left
OCOM // ^Left OBITNOT // ^Left
OPLUS // +Left OPLUS // +Left
OMINUS // -Left ONEG // -Left
OOROR // Left || Right OOROR // Left || Right
OPANIC // panic(Left) OPANIC // panic(Left)
OPRINT // print(List) OPRINT // print(List)
...@@ -720,7 +720,7 @@ const ( ...@@ -720,7 +720,7 @@ const (
OGOTO // goto Sym OGOTO // goto Sym
OIF // if Ninit; Left { Nbody } else { Rlist } OIF // if Ninit; Left { Nbody } else { Rlist }
OLABEL // Sym: OLABEL // Sym:
OPROC // go Left (Left must be call) OGO // go Left (Left must be call)
ORANGE // for List = range Right { Nbody } ORANGE // for List = range Right { Nbody }
ORETURN // return List ORETURN // return List
OSELECT // select { List } (List is list of OXCASE or OCASE) OSELECT // select { List } (List is list of OXCASE or OCASE)
......
This diff is collapsed.
...@@ -294,8 +294,8 @@ func typeinit() { ...@@ -294,8 +294,8 @@ func typeinit() {
okfor[ORSH] = okforand[:] okfor[ORSH] = okforand[:]
// unary // unary
okfor[OCOM] = okforand[:] okfor[OBITNOT] = okforand[:]
okfor[OMINUS] = okforarith[:] okfor[ONEG] = okforarith[:]
okfor[ONOT] = okforbool[:] okfor[ONOT] = okforbool[:]
okfor[OPLUS] = okforarith[:] okfor[OPLUS] = okforarith[:]
......
...@@ -8,7 +8,7 @@ package gc ...@@ -8,7 +8,7 @@ package gc
func evalunsafe(n *Node) int64 { func evalunsafe(n *Node) int64 {
switch n.Op { switch n.Op {
case OALIGNOF, OSIZEOF: case OALIGNOF, OSIZEOF:
n.Left = typecheck(n.Left, Erv) n.Left = typecheck(n.Left, ctxExpr)
n.Left = defaultlit(n.Left, nil) n.Left = defaultlit(n.Left, nil)
tr := n.Left.Type tr := n.Left.Type
if tr == nil { if tr == nil {
...@@ -30,10 +30,10 @@ func evalunsafe(n *Node) int64 { ...@@ -30,10 +30,10 @@ func evalunsafe(n *Node) int64 {
// Remember base of selector to find it back after dot insertion. // Remember base of selector to find it back after dot insertion.
// Since r->left may be mutated by typechecking, check it explicitly // Since r->left may be mutated by typechecking, check it explicitly
// first to track it correctly. // first to track it correctly.
n.Left.Left = typecheck(n.Left.Left, Erv) n.Left.Left = typecheck(n.Left.Left, ctxExpr)
base := n.Left.Left base := n.Left.Left
n.Left = typecheck(n.Left, Erv) n.Left = typecheck(n.Left, ctxExpr)
if n.Left.Type == nil { if n.Left.Type == nil {
return 0 return 0
} }
......
This diff is collapsed.
...@@ -92,7 +92,7 @@ func identical(t1, t2 *Type, cmpTags bool, assumedEqual map[typePair]struct{}) b ...@@ -92,7 +92,7 @@ func identical(t1, t2 *Type, cmpTags bool, assumedEqual map[typePair]struct{}) b
} }
for i, f1 := range fs1 { for i, f1 := range fs1 {
f2 := fs2[i] f2 := fs2[i]
if f1.Isddd() != f2.Isddd() || !identical(f1.Type, f2.Type, cmpTags, assumedEqual) { if f1.IsDDD() != f2.IsDDD() || !identical(f1.Type, f2.Type, cmpTags, assumedEqual) {
return false return false
} }
} }
......
...@@ -374,16 +374,16 @@ type Field struct { ...@@ -374,16 +374,16 @@ type Field struct {
} }
const ( const (
fieldIsddd = 1 << iota // field is ... argument fieldIsDDD = 1 << iota // field is ... argument
fieldBroke // broken field definition fieldBroke // broken field definition
fieldNointerface fieldNointerface
) )
func (f *Field) Isddd() bool { return f.flags&fieldIsddd != 0 } func (f *Field) IsDDD() bool { return f.flags&fieldIsDDD != 0 }
func (f *Field) Broke() bool { return f.flags&fieldBroke != 0 } func (f *Field) Broke() bool { return f.flags&fieldBroke != 0 }
func (f *Field) Nointerface() bool { return f.flags&fieldNointerface != 0 } func (f *Field) Nointerface() bool { return f.flags&fieldNointerface != 0 }
func (f *Field) SetIsddd(b bool) { f.flags.set(fieldIsddd, b) } func (f *Field) SetIsDDD(b bool) { f.flags.set(fieldIsDDD, b) }
func (f *Field) SetBroke(b bool) { f.flags.set(fieldBroke, b) } func (f *Field) SetBroke(b bool) { f.flags.set(fieldBroke, b) }
func (f *Field) SetNointerface(b bool) { f.flags.set(fieldNointerface, b) } func (f *Field) SetNointerface(b bool) { f.flags.set(fieldNointerface, b) }
...@@ -743,7 +743,7 @@ func (t *Type) NumResults() int { return t.FuncType().Results.NumFields() } ...@@ -743,7 +743,7 @@ func (t *Type) NumResults() int { return t.FuncType().Results.NumFields() }
// IsVariadic reports whether function type t is variadic. // IsVariadic reports whether function type t is variadic.
func (t *Type) IsVariadic() bool { func (t *Type) IsVariadic() bool {
n := t.NumParams() n := t.NumParams()
return n > 0 && t.Params().Field(n-1).Isddd() return n > 0 && t.Params().Field(n-1).IsDDD()
} }
// Recv returns the receiver of function type t, if any. // Recv returns the receiver of function type t, if any.
...@@ -1163,8 +1163,8 @@ func (t *Type) cmp(x *Type) Cmp { ...@@ -1163,8 +1163,8 @@ func (t *Type) cmp(x *Type) Cmp {
for i := 0; i < len(tfs) && i < len(xfs); i++ { for i := 0; i < len(tfs) && i < len(xfs); i++ {
ta := tfs[i] ta := tfs[i]
tb := xfs[i] tb := xfs[i]
if ta.Isddd() != tb.Isddd() { if ta.IsDDD() != tb.IsDDD() {
return cmpForNe(!ta.Isddd()) return cmpForNe(!ta.IsDDD())
} }
if c := ta.Type.cmp(tb.Type); c != CMPeq { if c := ta.Type.cmp(tb.Type); c != CMPeq {
return c return c
......
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