No longer needed now that IR construction uses types2.
Change-Id: If8b7aff80cd8472be7d87fd3a36da911a5df163c
Reviewed-on: https://go-review.googlesource.com/c/go/+/403839
Reviewed-by: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Reviewed-by: David Chase <drchase@google.com>
Run-TryBot: Matthew Dempsky <mdempsky@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
newfn.Nname = ir.NewNameAt(oldfn.Nname.Pos(), oldfn.Nname.Sym())
// XXX OK to share fn.Type() ??
newfn.Nname.SetType(oldfn.Nname.Type())
- // Ntype can be nil for -G=3 mode.
- if oldfn.Nname.Ntype != nil {
- newfn.Nname.Ntype = inlcopy(oldfn.Nname.Ntype).(ir.Ntype)
- }
newfn.Body = inlcopylist(oldfn.Body)
// Make shallow copy of the Dcl and ClosureVar slices
newfn.Dcl = append([]*ir.Name(nil), oldfn.Dcl...)
oldfn := n.Func
newfn := ir.NewClosureFunc(oldfn.Pos(), true)
- // Ntype can be nil for -G=3 mode.
- if oldfn.Nname.Ntype != nil {
- newfn.Nname.Ntype = subst.node(oldfn.Nname.Ntype).(ir.Ntype)
- }
-
if subst.newclofn != nil {
//fmt.Printf("Inlining a closure with a nested closure\n")
}
fmt.Fprintf(w, "%+v", n.Op())
}
dumpNodeHeader(w, n)
- if n.Type() == nil && n.Name() != nil && n.Name().Ntype != nil {
- indent(w, depth)
- fmt.Fprintf(w, "%+v-ntype", n.Op())
- dumpNode(w, n.Name().Ntype, depth+1)
- }
return
case OASOP:
case OTYPE:
fmt.Fprintf(w, "%+v %+v", n.Op(), n.Sym())
dumpNodeHeader(w, n)
- if n.Type() == nil && n.Name() != nil && n.Name().Ntype != nil {
- indent(w, depth)
- fmt.Fprintf(w, "%+v-ntype", n.Op())
- dumpNode(w, n.Name().Ntype, depth+1)
- }
return
case OCLOSURE:
// The function, method, or closure in which local variable or param is declared.
Curfn *Func
- Ntype Ntype
Heapaddr *Name // temp holding heap address of param
// ONAME closure linkage
_64bit uintptr // size on 64bit platforms
}{
{Func{}, 184, 320},
- {Name{}, 108, 192},
+ {Name{}, 100, 176},
}
for _, tt := range tests {
func setType(n ir.Node, typ *types.Type) {
n.SetType(typ)
n.SetTypecheck(1)
-
- if name, ok := n.(*ir.Name); ok {
- name.Ntype = ir.TypeNode(name.Type())
- }
}
func setValue(name *ir.Name, val constant.Value) {
var DeclContext ir.Class = ir.PEXTERN // PEXTERN/PAUTO
-func DeclFunc(sym *types.Sym, tfn ir.Ntype) *ir.Func {
+func DeclFunc(sym *types.Sym, tfn *ir.FuncType) *ir.Func {
if tfn.Op() != ir.OTFUNC {
base.Fatalf("expected OTFUNC node, got %v", tfn)
}
fn.Nname = ir.NewNameAt(base.Pos, sym)
fn.Nname.Func = fn
fn.Nname.Defn = fn
- fn.Nname.Ntype = tfn
ir.MarkFunc(fn.Nname)
- StartFuncBody(fn)
- fn.Nname.Ntype = typecheckNtype(fn.Nname.Ntype)
+ StartFuncBody(fn, tfn)
return fn
}
// and declare the arguments.
// called in extern-declaration context
// returns in auto-declaration context.
-func StartFuncBody(fn *ir.Func) {
+func StartFuncBody(fn *ir.Func, tfn *ir.FuncType) {
// change the declaration context from extern to auto
funcStack = append(funcStack, funcStackEnt{ir.CurFunc, DeclContext})
ir.CurFunc = fn
types.Markdcl()
- if fn.Nname.Ntype != nil {
- funcargs(fn.Nname.Ntype.(*ir.FuncType))
- } else {
- funcargs2(fn.Type())
- }
+ funcargs(tfn)
+
+ tfn = tcFuncType(tfn)
+ fn.Nname.SetType(tfn.Type())
+ fn.Nname.SetTypecheck(1)
}
// finish the body.
name := ir.NewNameAt(n.Pos, n.Sym)
n.Decl = name
- name.Ntype = nil
Declare(name, ctxt)
}
}
if name := n.Nname; name.Typecheck() == 0 {
- if name.Ntype != nil {
- name.Ntype = typecheckNtype(name.Ntype)
- name.SetType(name.Ntype.Type())
- }
+ base.AssertfAt(name.Type() != nil, n.Pos(), "missing type: %v", name)
name.SetTypecheck(1)
}
}
)
// tcFuncType typechecks an OTFUNC node.
-func tcFuncType(n *ir.FuncType) ir.Node {
+func tcFuncType(n *ir.FuncType) *ir.FuncType {
misc := func(f *types.Field, nf *ir.Field) {
f.SetIsDDD(nf.IsDDD)
if nf.Decl != nil {