Commit 5e43856a authored by Matthew Dempsky's avatar Matthew Dempsky

cmd/compile: rename Etype to ctxType

golang.org/cl/150140 renamed the other Efoo constants to ctxFoo, but
forgot about Etype.

gorename -from '"cmd/compile/internal/gc".Etype -to ctxType

Change-Id: I142dd42ca84a398f8d2316d75ead3331c023b820
Reviewed-on: https://go-review.googlesource.com/c/go/+/193958
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarJosh Bleecher Snyder <josharian@gmail.com>
parent 2da9c3e0
...@@ -73,7 +73,7 @@ func (p *noder) funcLit(expr *syntax.FuncLit) *Node { ...@@ -73,7 +73,7 @@ func (p *noder) funcLit(expr *syntax.FuncLit) *Node {
func typecheckclosure(clo *Node, top int) { func typecheckclosure(clo *Node, top int) {
xfunc := clo.Func.Closure xfunc := clo.Func.Closure
clo.Func.Ntype = typecheck(clo.Func.Ntype, Etype) clo.Func.Ntype = typecheck(clo.Func.Ntype, ctxType)
clo.Type = clo.Func.Ntype.Type clo.Type = clo.Func.Ntype.Type
clo.Func.Top = top clo.Func.Top = top
......
...@@ -544,7 +544,7 @@ func structfield(n *Node) *types.Field { ...@@ -544,7 +544,7 @@ func structfield(n *Node) *types.Field {
f.Sym = n.Sym f.Sym = n.Sym
if n.Left != nil { if n.Left != nil {
n.Left = typecheck(n.Left, Etype) n.Left = typecheck(n.Left, ctxType)
n.Type = n.Left.Type n.Type = n.Left.Type
n.Left = nil n.Left = nil
} }
...@@ -668,7 +668,7 @@ func interfacefield(n *Node) *types.Field { ...@@ -668,7 +668,7 @@ func interfacefield(n *Node) *types.Field {
// Otherwise, Left is InterfaceTypeName. // Otherwise, Left is InterfaceTypeName.
if n.Left != nil { if n.Left != nil {
n.Left = typecheck(n.Left, Etype) n.Left = typecheck(n.Left, ctxType)
n.Type = n.Left.Type n.Type = n.Left.Type
n.Left = nil n.Left = nil
} }
...@@ -1020,7 +1020,7 @@ func dclfunc(sym *types.Sym, tfn *Node) *Node { ...@@ -1020,7 +1020,7 @@ func dclfunc(sym *types.Sym, tfn *Node) *Node {
fn.Func.Nname.Name.Param.Ntype = tfn fn.Func.Nname.Name.Param.Ntype = tfn
declare(fn.Func.Nname, PFUNC) declare(fn.Func.Nname, PFUNC)
funchdr(fn) funchdr(fn)
fn.Func.Nname.Name.Param.Ntype = typecheck(fn.Func.Nname.Name.Param.Ntype, Etype) fn.Func.Nname.Name.Param.Ntype = typecheck(fn.Func.Nname.Name.Param.Ntype, ctxType)
return fn return fn
} }
......
...@@ -1286,7 +1286,7 @@ func dotpath(s *types.Sym, t *types.Type, save **types.Field, ignorecase bool) ( ...@@ -1286,7 +1286,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|ctxExpr) n.Left = typecheck(n.Left, ctxType|ctxExpr)
if n.Left.Diag() { if n.Left.Diag() {
n.SetDiag(true) n.SetDiag(true)
} }
......
...@@ -63,7 +63,7 @@ func typecheckswitch(n *Node) { ...@@ -63,7 +63,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 = ctxType
n.Left.Right = typecheck(n.Left.Right, ctxExpr) 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() {
...@@ -121,7 +121,7 @@ func typecheckswitch(n *Node) { ...@@ -121,7 +121,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], ctxExpr|Etype) ls[i1] = typecheck(ls[i1], ctxExpr|ctxType)
n1 = ls[i1] n1 = ls[i1]
if n1.Type == nil || t == nil { if n1.Type == nil || t == nil {
continue continue
...@@ -149,7 +149,7 @@ func typecheckswitch(n *Node) { ...@@ -149,7 +149,7 @@ func typecheckswitch(n *Node) {
} }
// type switch // type switch
case Etype: case ctxType:
var missing, have *types.Field var missing, have *types.Field
var ptr int var ptr int
switch { switch {
...@@ -183,7 +183,7 @@ func typecheckswitch(n *Node) { ...@@ -183,7 +183,7 @@ func typecheckswitch(n *Node) {
} }
} }
if top == Etype { if top == ctxType {
ll := ncase.List ll := ncase.List
if ncase.Rlist.Len() != 0 { if ncase.Rlist.Len() != 0 {
nvar := ncase.Rlist.First() nvar := ncase.Rlist.First()
......
...@@ -58,7 +58,7 @@ func tracePrint(title string, n *Node) func(np **Node) { ...@@ -58,7 +58,7 @@ func tracePrint(title string, n *Node) func(np **Node) {
const ( const (
ctxStmt = 1 << iota // evaluated at statement level ctxStmt = 1 << iota // evaluated at statement level
ctxExpr // evaluated in value context ctxExpr // evaluated in value context
Etype // evaluated in type context ctxType // evaluated in type context
ctxCallee // call-only expressions are ok ctxCallee // call-only expressions are ok
ctxMultiOK // multivalue function returns are ok ctxMultiOK // multivalue function returns are ok
ctxAssign // assigning to expression ctxAssign // assigning to expression
...@@ -242,14 +242,14 @@ func typecheck(n *Node, top int) (res *Node) { ...@@ -242,14 +242,14 @@ func typecheck(n *Node, top int) (res *Node) {
switch n.Op { switch n.Op {
// We can already diagnose variables used as types. // We can already diagnose variables used as types.
case ONAME: case ONAME:
if top&(ctxExpr|Etype) == Etype { if top&(ctxExpr|ctxType) == ctxType {
yyerror("%v is not a type", n) yyerror("%v is not a type", n)
} }
case OTYPE: case OTYPE:
// Only report a type cycle if we are expecting a type. // Only report a type cycle if we are expecting a type.
// Otherwise let other code report an error. // Otherwise let other code report an error.
if top&Etype == Etype { if top&ctxType == ctxType {
// A cycle containing only alias types is an error // A cycle containing only alias types is an error
// since it would expand indefinitely when aliases // since it would expand indefinitely when aliases
// are substituted. // are substituted.
...@@ -272,7 +272,7 @@ func typecheck(n *Node, top int) (res *Node) { ...@@ -272,7 +272,7 @@ func typecheck(n *Node, top int) (res *Node) {
} }
case OLITERAL: case OLITERAL:
if top&(ctxExpr|Etype) == Etype { if top&(ctxExpr|ctxType) == ctxType {
yyerror("%v is not a type", n) yyerror("%v is not a type", n)
break break
} }
...@@ -397,15 +397,15 @@ func typecheck1(n *Node, top int) (res *Node) { ...@@ -397,15 +397,15 @@ func typecheck1(n *Node, top int) (res *Node) {
// types (ODEREF is with exprs) // types (ODEREF is with exprs)
case OTYPE: case OTYPE:
ok |= Etype ok |= ctxType
if n.Type == nil { if n.Type == nil {
return n return n
} }
case OTARRAY: case OTARRAY:
ok |= Etype ok |= ctxType
r := typecheck(n.Right, Etype) r := typecheck(n.Right, ctxType)
if r.Type == nil { if r.Type == nil {
n.Type = nil n.Type = nil
return n return n
...@@ -464,9 +464,9 @@ func typecheck1(n *Node, top int) (res *Node) { ...@@ -464,9 +464,9 @@ func typecheck1(n *Node, top int) (res *Node) {
} }
case OTMAP: case OTMAP:
ok |= Etype ok |= ctxType
n.Left = typecheck(n.Left, Etype) n.Left = typecheck(n.Left, ctxType)
n.Right = typecheck(n.Right, Etype) n.Right = typecheck(n.Right, ctxType)
l := n.Left l := n.Left
r := n.Right r := n.Right
if l.Type == nil || r.Type == nil { if l.Type == nil || r.Type == nil {
...@@ -486,8 +486,8 @@ func typecheck1(n *Node, top int) (res *Node) { ...@@ -486,8 +486,8 @@ func typecheck1(n *Node, top int) (res *Node) {
n.Right = nil n.Right = nil
case OTCHAN: case OTCHAN:
ok |= Etype ok |= ctxType
n.Left = typecheck(n.Left, Etype) n.Left = typecheck(n.Left, ctxType)
l := n.Left l := n.Left
if l.Type == nil { if l.Type == nil {
n.Type = nil n.Type = nil
...@@ -502,16 +502,16 @@ func typecheck1(n *Node, top int) (res *Node) { ...@@ -502,16 +502,16 @@ func typecheck1(n *Node, top int) (res *Node) {
n.ResetAux() n.ResetAux()
case OTSTRUCT: case OTSTRUCT:
ok |= Etype ok |= ctxType
setTypeNode(n, tostruct(n.List.Slice())) setTypeNode(n, tostruct(n.List.Slice()))
n.List.Set(nil) n.List.Set(nil)
case OTINTER: case OTINTER:
ok |= Etype ok |= ctxType
setTypeNode(n, tointerface(n.List.Slice())) setTypeNode(n, tointerface(n.List.Slice()))
case OTFUNC: case OTFUNC:
ok |= Etype ok |= ctxType
setTypeNode(n, functype(n.Left, n.List.Slice(), n.Rlist.Slice())) setTypeNode(n, functype(n.Left, n.List.Slice(), n.Rlist.Slice()))
n.Left = nil n.Left = nil
n.List.Set(nil) n.List.Set(nil)
...@@ -519,7 +519,7 @@ func typecheck1(n *Node, top int) (res *Node) { ...@@ -519,7 +519,7 @@ func typecheck1(n *Node, top int) (res *Node) {
// type or expr // type or expr
case ODEREF: case ODEREF:
n.Left = typecheck(n.Left, ctxExpr|Etype|top&ctxCompLit) n.Left = typecheck(n.Left, ctxExpr|ctxType|top&ctxCompLit)
l := n.Left l := n.Left
t := l.Type t := l.Type
if t == nil { if t == nil {
...@@ -527,7 +527,7 @@ func typecheck1(n *Node, top int) (res *Node) { ...@@ -527,7 +527,7 @@ func typecheck1(n *Node, top int) (res *Node) {
return n return n
} }
if l.Op == OTYPE { if l.Op == OTYPE {
ok |= Etype ok |= ctxType
setTypeNode(n, types.NewPtr(l.Type)) setTypeNode(n, types.NewPtr(l.Type))
// Ensure l.Type gets dowidth'd for the backend. Issue 20174. // Ensure l.Type gets dowidth'd for the backend. Issue 20174.
// Don't checkwidth [...] arrays, though, since they // Don't checkwidth [...] arrays, though, since they
...@@ -876,7 +876,7 @@ func typecheck1(n *Node, top int) (res *Node) { ...@@ -876,7 +876,7 @@ func typecheck1(n *Node, top int) (res *Node) {
} }
} }
n.Left = typecheck(n.Left, ctxExpr|Etype) n.Left = typecheck(n.Left, ctxExpr|ctxType)
n.Left = defaultlit(n.Left, nil) n.Left = defaultlit(n.Left, nil)
...@@ -969,7 +969,7 @@ func typecheck1(n *Node, top int) (res *Node) { ...@@ -969,7 +969,7 @@ func typecheck1(n *Node, top int) (res *Node) {
} }
if n.Right != nil { if n.Right != nil {
n.Right = typecheck(n.Right, Etype) n.Right = typecheck(n.Right, ctxType)
n.Type = n.Right.Type n.Type = n.Right.Type
n.Right = nil n.Right = nil
if n.Type == nil { if n.Type == nil {
...@@ -1235,7 +1235,7 @@ func typecheck1(n *Node, top int) (res *Node) { ...@@ -1235,7 +1235,7 @@ func typecheck1(n *Node, top int) (res *Node) {
// call and call like // call and call like
case OCALL: case OCALL:
typecheckslice(n.Ninit.Slice(), ctxStmt) // imported rewritten f(g()) calls (#30907) typecheckslice(n.Ninit.Slice(), ctxStmt) // imported rewritten f(g()) calls (#30907)
n.Left = typecheck(n.Left, ctxExpr|Etype|ctxCallee) n.Left = typecheck(n.Left, ctxExpr|ctxType|ctxCallee)
if n.Left.Diag() { if n.Left.Diag() {
n.SetDiag(true) n.SetDiag(true)
} }
...@@ -1689,7 +1689,7 @@ func typecheck1(n *Node, top int) (res *Node) { ...@@ -1689,7 +1689,7 @@ func typecheck1(n *Node, top int) (res *Node) {
n.List.Set(nil) n.List.Set(nil)
l := args[0] l := args[0]
l = typecheck(l, Etype) l = typecheck(l, ctxType)
t := l.Type t := l.Type
if t == nil { if t == nil {
n.Type = nil n.Type = nil
...@@ -1799,7 +1799,7 @@ func typecheck1(n *Node, top int) (res *Node) { ...@@ -1799,7 +1799,7 @@ func typecheck1(n *Node, top int) (res *Node) {
} }
l := args.First() l := args.First()
l = typecheck(l, Etype) l = typecheck(l, ctxType)
t := l.Type t := l.Type
if t == nil { if t == nil {
n.Type = nil n.Type = nil
...@@ -2034,7 +2034,7 @@ func typecheck1(n *Node, top int) (res *Node) { ...@@ -2034,7 +2034,7 @@ func typecheck1(n *Node, top int) (res *Node) {
case ODCLTYPE: case ODCLTYPE:
ok |= ctxStmt ok |= ctxStmt
n.Left = typecheck(n.Left, Etype) n.Left = typecheck(n.Left, ctxType)
checkwidth(n.Left.Type) checkwidth(n.Left.Type)
if n.Left.Type != nil && n.Left.Type.NotInHeap() && n.Left.Name.Param.Pragma&NotInHeap == 0 { if n.Left.Type != nil && n.Left.Type.NotInHeap() && n.Left.Name.Param.Pragma&NotInHeap == 0 {
// The type contains go:notinheap types, so it // The type contains go:notinheap types, so it
...@@ -2057,7 +2057,7 @@ func typecheck1(n *Node, top int) (res *Node) { ...@@ -2057,7 +2057,7 @@ func typecheck1(n *Node, top int) (res *Node) {
} }
evconst(n) evconst(n)
if n.Op == OTYPE && top&Etype == 0 { if n.Op == OTYPE && top&ctxType == 0 {
if !n.Type.Broke() { if !n.Type.Broke() {
yyerror("type %v is not an expression", n.Type) yyerror("type %v is not an expression", n.Type)
} }
...@@ -2065,20 +2065,20 @@ func typecheck1(n *Node, top int) (res *Node) { ...@@ -2065,20 +2065,20 @@ func typecheck1(n *Node, top int) (res *Node) {
return n return n
} }
if top&(ctxExpr|Etype) == Etype && n.Op != OTYPE { if top&(ctxExpr|ctxType) == ctxType && n.Op != OTYPE {
yyerror("%v is not a type", n) yyerror("%v is not a type", n)
n.Type = nil n.Type = nil
return n return n
} }
// TODO(rsc): simplify // TODO(rsc): simplify
if (top&(ctxCallee|ctxExpr|Etype) != 0) && top&ctxStmt == 0 && ok&(ctxExpr|Etype|ctxCallee) == 0 { if (top&(ctxCallee|ctxExpr|ctxType) != 0) && top&ctxStmt == 0 && ok&(ctxExpr|ctxType|ctxCallee) == 0 {
yyerror("%v used as value", n) yyerror("%v used as value", n)
n.Type = nil n.Type = nil
return n return n
} }
if (top&ctxStmt != 0) && top&(ctxCallee|ctxExpr|Etype) == 0 && ok&ctxStmt == 0 { if (top&ctxStmt != 0) && top&(ctxCallee|ctxExpr|ctxType) == 0 && ok&ctxStmt == 0 {
if !n.Diag() { if !n.Diag() {
yyerror("%v evaluated but not used", n) yyerror("%v evaluated but not used", n)
n.SetDiag(true) n.SetDiag(true)
...@@ -2475,11 +2475,11 @@ func lookdot(n *Node, t *types.Type, dostrcmp int) *types.Field { ...@@ -2475,11 +2475,11 @@ func lookdot(n *Node, t *types.Type, dostrcmp int) *types.Field {
checklvalue(n.Left, "call pointer method on") checklvalue(n.Left, "call pointer method on")
n.Left = nod(OADDR, n.Left, nil) n.Left = nod(OADDR, n.Left, nil)
n.Left.SetImplicit(true) n.Left.SetImplicit(true)
n.Left = typecheck(n.Left, Etype|ctxExpr) n.Left = typecheck(n.Left, ctxType|ctxExpr)
} else if tt.IsPtr() && !rcvr.IsPtr() && types.Identical(tt.Elem(), rcvr) { } else if tt.IsPtr() && !rcvr.IsPtr() && types.Identical(tt.Elem(), rcvr) {
n.Left = nod(ODEREF, n.Left, nil) n.Left = nod(ODEREF, n.Left, nil)
n.Left.SetImplicit(true) n.Left.SetImplicit(true)
n.Left = typecheck(n.Left, Etype|ctxExpr) n.Left = typecheck(n.Left, ctxType|ctxExpr)
} else if tt.IsPtr() && tt.Elem().IsPtr() && types.Identical(derefall(tt), derefall(rcvr)) { } else if tt.IsPtr() && tt.Elem().IsPtr() && types.Identical(derefall(tt), derefall(rcvr)) {
yyerror("calling method %v with receiver %L requires explicit dereference", n.Sym, n.Left) yyerror("calling method %v with receiver %L requires explicit dereference", n.Sym, n.Left)
for tt.IsPtr() { for tt.IsPtr() {
...@@ -2489,7 +2489,7 @@ func lookdot(n *Node, t *types.Type, dostrcmp int) *types.Field { ...@@ -2489,7 +2489,7 @@ func lookdot(n *Node, t *types.Type, dostrcmp int) *types.Field {
} }
n.Left = nod(ODEREF, n.Left, nil) n.Left = nod(ODEREF, n.Left, nil)
n.Left.SetImplicit(true) n.Left.SetImplicit(true)
n.Left = typecheck(n.Left, Etype|ctxExpr) n.Left = typecheck(n.Left, ctxType|ctxExpr)
tt = tt.Elem() tt = tt.Elem()
} }
} else { } else {
...@@ -2753,7 +2753,7 @@ func pushtype(n *Node, t *types.Type) { ...@@ -2753,7 +2753,7 @@ func pushtype(n *Node, t *types.Type) {
n.SetImplicit(true) // don't print n.SetImplicit(true) // don't print
n.Right.SetImplicit(true) // * is okay n.Right.SetImplicit(true) // * is okay
} else if Debug['s'] != 0 { } else if Debug['s'] != 0 {
n.Right = typecheck(n.Right, Etype) n.Right = typecheck(n.Right, ctxType)
if n.Right.Type != nil && types.Identical(n.Right.Type, t) { if n.Right.Type != nil && types.Identical(n.Right.Type, t) {
fmt.Printf("%v: redundant type: %v\n", n.Line(), t) fmt.Printf("%v: redundant type: %v\n", n.Line(), t)
} }
...@@ -2782,7 +2782,7 @@ func typecheckcomplit(n *Node) (res *Node) { ...@@ -2782,7 +2782,7 @@ func typecheckcomplit(n *Node) (res *Node) {
norig := n.copy() norig := n.copy()
setlineno(n.Right) setlineno(n.Right)
n.Right = typecheck(n.Right, Etype|ctxCompLit) n.Right = typecheck(n.Right, ctxType|ctxCompLit)
l := n.Right // sic l := n.Right // sic
t := l.Type t := l.Type
if t == nil { if t == nil {
...@@ -3497,7 +3497,7 @@ func typecheckdeftype(n *Node) { ...@@ -3497,7 +3497,7 @@ func typecheckdeftype(n *Node) {
} }
n.SetTypecheck(1) n.SetTypecheck(1)
n.Name.Param.Ntype = typecheck(n.Name.Param.Ntype, Etype) n.Name.Param.Ntype = typecheck(n.Name.Param.Ntype, ctxType)
t := n.Name.Param.Ntype.Type t := n.Name.Param.Ntype.Type
if t == nil { if t == nil {
n.SetDiag(true) n.SetDiag(true)
...@@ -3559,7 +3559,7 @@ func typecheckdef(n *Node) { ...@@ -3559,7 +3559,7 @@ func typecheckdef(n *Node) {
case OLITERAL: case OLITERAL:
if n.Name.Param.Ntype != nil { if n.Name.Param.Ntype != nil {
n.Name.Param.Ntype = typecheck(n.Name.Param.Ntype, Etype) n.Name.Param.Ntype = typecheck(n.Name.Param.Ntype, ctxType)
n.Type = n.Name.Param.Ntype.Type n.Type = n.Name.Param.Ntype.Type
n.Name.Param.Ntype = nil n.Name.Param.Ntype = nil
if n.Type == nil { if n.Type == nil {
...@@ -3611,7 +3611,7 @@ func typecheckdef(n *Node) { ...@@ -3611,7 +3611,7 @@ func typecheckdef(n *Node) {
case ONAME: case ONAME:
if n.Name.Param.Ntype != nil { if n.Name.Param.Ntype != nil {
n.Name.Param.Ntype = typecheck(n.Name.Param.Ntype, Etype) n.Name.Param.Ntype = typecheck(n.Name.Param.Ntype, ctxType)
n.Type = n.Name.Param.Ntype.Type n.Type = n.Name.Param.Ntype.Type
if n.Type == nil { if n.Type == nil {
n.SetDiag(true) n.SetDiag(true)
...@@ -3651,7 +3651,7 @@ func typecheckdef(n *Node) { ...@@ -3651,7 +3651,7 @@ func typecheckdef(n *Node) {
// to create a new type. // to create a new type.
// If we have a syntax error, p.Ntype may be nil. // If we have a syntax error, p.Ntype may be nil.
if p.Ntype != nil { if p.Ntype != nil {
p.Ntype = typecheck(p.Ntype, Etype) p.Ntype = typecheck(p.Ntype, ctxType)
n.Type = p.Ntype.Type n.Type = p.Ntype.Type
if n.Type == nil { if n.Type == nil {
n.SetDiag(true) n.SetDiag(true)
......
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