Commit 2e1b42a8 authored by Matthew Dempsky's avatar Matthew Dempsky

cmd/compile/internal/gc: remove a bunch of uses of typenod

Passes toolstash-check -all.

Change-Id: Ic9eb0c52bedac185ab86cc62207f199d93700344
Reviewed-on: https://go-review.googlesource.com/39795
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: default avatarRobert Griesemer <gri@golang.org>
parent 25fc842f
...@@ -1273,11 +1273,11 @@ func (p *exporter) expr(n *Node) { ...@@ -1273,11 +1273,11 @@ func (p *exporter) expr(n *Node) {
p.op(ODOTTYPE) p.op(ODOTTYPE)
p.pos(n) p.pos(n)
p.expr(n.Left) p.expr(n.Left)
if p.bool(n.Right != nil) { if n.Right != nil {
p.expr(n.Right) Fatalf("impossible")
} else {
p.typ(n.Type)
} }
p.bool(false)
p.typ(n.Type)
case OINDEX, OINDEXMAP: case OINDEX, OINDEXMAP:
p.op(OINDEX) p.op(OINDEX)
......
...@@ -884,13 +884,11 @@ func (p *importer) node() *Node { ...@@ -884,13 +884,11 @@ func (p *importer) node() *Node {
// again. Re-introduce explicit uintptr(c) conversion. // again. Re-introduce explicit uintptr(c) conversion.
// (issue 16317). // (issue 16317).
if typ.IsUnsafePtr() { if typ.IsUnsafePtr() {
conv := nod(OCALL, typenod(Types[TUINTPTR]), nil) n = nod(OCONV, n, nil)
conv.List.Set1(n) n.Type = Types[TUINTPTR]
n = conv
} }
conv := nod(OCALL, typenod(typ), nil) n = nod(OCONV, n, nil)
conv.List.Set1(n) n.Type = typ
n = conv
} }
return n return n
...@@ -963,10 +961,9 @@ func (p *importer) node() *Node { ...@@ -963,10 +961,9 @@ func (p *importer) node() *Node {
case ODOTTYPE: case ODOTTYPE:
n := nodl(p.pos(), ODOTTYPE, p.expr(), nil) n := nodl(p.pos(), ODOTTYPE, p.expr(), nil)
if p.bool() { if p.bool() {
n.Right = p.expr() Fatalf("impossible")
} else {
n.Right = typenod(p.typ())
} }
n.Type = p.typ()
return n return n
// case OINDEX, OINDEXMAP, OSLICE, OSLICESTR, OSLICEARR, OSLICE3, OSLICE3ARR: // case OINDEX, OINDEXMAP, OSLICE, OSLICESTR, OSLICEARR, OSLICE3, OSLICE3ARR:
...@@ -989,8 +986,13 @@ func (p *importer) node() *Node { ...@@ -989,8 +986,13 @@ func (p *importer) node() *Node {
// unreachable - mapped to OCONV case below by exporter // unreachable - mapped to OCONV case below by exporter
case OCONV: case OCONV:
n := nodl(p.pos(), OCALL, typenod(p.typ()), nil) n := nodl(p.pos(), OCONV, nil, nil)
n.List.Set(p.exprList()) n.Type = p.typ()
exprs := p.exprList()
if len(exprs) != 1 {
Fatalf("impossible")
}
n.Left = exprs[0]
return n return n
case OCOPY, OCOMPLEX, OREAL, OIMAG, OAPPEND, OCAP, OCLOSE, ODELETE, OLEN, OMAKE, ONEW, OPANIC, ORECOVER, OPRINT, OPRINTN: case OCOPY, OCOMPLEX, OREAL, OIMAG, OAPPEND, OCAP, OCLOSE, ODELETE, OLEN, OMAKE, ONEW, OPANIC, ORECOVER, OPRINT, OPRINTN:
......
...@@ -395,7 +395,7 @@ func transformclosure(xfunc *Node) { ...@@ -395,7 +395,7 @@ func transformclosure(xfunc *Node) {
// Declare variable holding addresses taken from closure // Declare variable holding addresses taken from closure
// and initialize in entry prologue. // and initialize in entry prologue.
addr := newname(lookup("&" + v.Sym.Name)) addr := newname(lookup("&" + v.Sym.Name))
addr.Name.Param.Ntype = nod(OIND, typenod(v.Type), nil) addr.Type = typPtr(v.Type)
addr.Class = PAUTO addr.Class = PAUTO
addr.SetUsed(true) addr.SetUsed(true)
addr.Name.Curfn = xfunc addr.Name.Curfn = xfunc
...@@ -626,10 +626,10 @@ func makepartialcall(fn *Node, t0 *Type, meth *Sym) *Node { ...@@ -626,10 +626,10 @@ func makepartialcall(fn *Node, t0 *Type, meth *Sym) *Node {
xfunc.Func.Dcl = append(xfunc.Func.Dcl, ptr) xfunc.Func.Dcl = append(xfunc.Func.Dcl, ptr)
var body []*Node var body []*Node
if rcvrtype.IsPtr() || rcvrtype.IsInterface() { if rcvrtype.IsPtr() || rcvrtype.IsInterface() {
ptr.Name.Param.Ntype = typenod(rcvrtype) ptr.Type = rcvrtype
body = append(body, nod(OAS, ptr, cv)) body = append(body, nod(OAS, ptr, cv))
} else { } else {
ptr.Name.Param.Ntype = typenod(typPtr(rcvrtype)) ptr.Type = typPtr(rcvrtype)
body = append(body, nod(OAS, ptr, nod(OADDR, cv, nil))) body = append(body, nod(OAS, ptr, nod(OADDR, cv, nil)))
} }
......
...@@ -182,10 +182,10 @@ func typecheckswitch(n *Node) { ...@@ -182,10 +182,10 @@ func typecheckswitch(n *Node) {
nvar := ncase.Rlist.First() nvar := ncase.Rlist.First()
if ll.Len() == 1 && ll.First().Type != nil && !ll.First().Type.IsKind(TNIL) { if ll.Len() == 1 && ll.First().Type != nil && !ll.First().Type.IsKind(TNIL) {
// single entry type switch // single entry type switch
nvar.Name.Param.Ntype = typenod(ll.First().Type) nvar.Type = ll.First().Type
} else { } else {
// multiple entry type switch or default // multiple entry type switch or default
nvar.Name.Param.Ntype = typenod(n.Type) nvar.Type = n.Type
} }
nvar = typecheck(nvar, Erv|Easgn) nvar = typecheck(nvar, Erv|Easgn)
......
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