// pointer from the Func back to the OCALLPART.
type Func struct {
miniNode
- typ *types.Type
Body Nodes
Iota int64
func (f *Func) isStmt() {}
-func (f *Func) Type() *types.Type { return f.typ }
-func (f *Func) SetType(x *types.Type) { f.typ = x }
-
+func (f *Func) Type() *types.Type { return f.Nname.Type() }
func (f *Func) Sym() *types.Sym { return f.Nname.Sym() }
func (f *Func) Linksym() *obj.LSym { return f.Nname.Linksym() }
return s.Name + "·f"
}
-// NewFuncNameAt generates a new name node for a function or method.
-func NewFuncNameAt(pos src.XPos, s *types.Sym, fn *Func) *Name {
- if fn.Nname != nil {
- base.Fatalf("newFuncName - already have name")
- }
- n := NewNameAt(pos, s)
- n.SetFunc(fn)
- fn.Nname = n
- return n
-}
-
// MarkFunc marks a node as a function.
func MarkFunc(n *Name) {
if n.Op() != ONAME || n.Class_ != Pxxx {
_32bit uintptr // size on 32bit platforms
_64bit uintptr // size on 64bit platforms
}{
- {Func{}, 200, 352},
+ {Func{}, 196, 344},
{Name{}, 132, 232},
}
name = ir.BlankNode.Sym() // filled in by typecheckfunc
}
- f.Nname = ir.NewFuncNameAt(p.pos(fun.Name), name, f)
+ f.Nname = ir.NewNameAt(p.pos(fun.Name), name)
+ f.Nname.Func = f
f.Nname.Defn = f
f.Nname.Ntype = t
fn := ir.NewFunc(p.pos(expr))
fn.SetIsHiddenClosure(ir.CurFunc != nil)
- fn.Nname = ir.NewFuncNameAt(p.pos(expr), ir.BlankNode.Sym(), fn) // filled in by typecheckclosure
+
+ fn.Nname = ir.NewNameAt(p.pos(expr), ir.BlankNode.Sym()) // filled in by typecheckclosure
+ fn.Nname.Func = fn
fn.Nname.Ntype = xtype
fn.Nname.Defn = fn
}
fn := ir.NewFunc(base.Pos)
- fn.Nname = ir.NewFuncNameAt(base.Pos, sym, fn)
+ fn.Nname = ir.NewNameAt(base.Pos, sym)
+ fn.Nname.Func = fn
fn.Nname.Defn = fn
fn.Nname.Ntype = tfn
ir.MarkFunc(fn.Nname)
// ipkg is the package being imported
func importfunc(ipkg *types.Pkg, pos src.XPos, s *types.Sym, t *types.Type) *ir.Name {
n := importobj(ipkg, pos, s, ir.ONAME, ir.PFUNC, t)
-
- fn := ir.NewFunc(pos)
- fn.SetType(t)
- n.SetFunc(fn)
- fn.Nname = n
-
+ n.Func = ir.NewFunc(pos)
+ n.Func.Nname = n
return n
}
if t == nil {
return
}
- n.SetType(t)
rcvr := t.Recv()
if rcvr != nil && n.Shortname != nil {
m := addmethod(n, n.Shortname, t, true, n.Pragma&ir.Nointerface != 0)
recv := r.param()
mtyp := r.signature(recv)
- fn := ir.NewFunc(mpos)
- fn.SetType(mtyp)
- m := ir.NewFuncNameAt(mpos, ir.MethodSym(recv.Type, msym), fn)
- m.SetType(mtyp)
- m.Class_ = ir.PFUNC
// methodSym already marked m.Sym as a function.
+ m := ir.NewNameAt(mpos, ir.MethodSym(recv.Type, msym))
+ m.Class_ = ir.PFUNC
+ m.SetType(mtyp)
+
+ m.Func = ir.NewFunc(mpos)
+ m.Func.Nname = m
f := types.NewField(mpos, msym, mtyp)
f.Nname = m
}
types.CalcSize(f.Type())
- fn.SetType(f.Type()) // update type of ODCLFUNC
+ fn.Nname.SetType(f.Type()) // update type of ODCLFUNC
} else {
// The closure is not called, so it is going to stay as closure.
var body []ir.Node