n := newname(sym)
n.SetClass(PFUNC)
+ n.Sym.SetFunc(true)
n.Type = functype(nil, []*Node{
anonfield(types.NewPtr(t)),
anonfield(types.Types[TUINTPTR]),
s.Def = asTypesNode(n)
n.Name.Vargen = int32(gen)
n.SetClass(ctxt)
+ if ctxt == PFUNC {
+ n.Sym.SetFunc(true)
+ }
autoexport(n, ctxt)
}
// Method symbols can be used to distinguish the same method appearing
// in different method sets. For example, T.M and (*T).M have distinct
// method symbols.
+//
+// The returned symbol will be marked as a function.
func methodSym(recv *types.Type, msym *types.Sym) *types.Sym {
- return methodSymSuffix(recv, msym, "")
+ sym := methodSymSuffix(recv, msym, "")
+ sym.SetFunc(true)
+ return sym
}
// methodSymSuffix is like methodsym, but allows attaching a
n.Op = op
n.Pos = pos
n.SetClass(ctxt)
+ if ctxt == PFUNC {
+ n.Sym.SetFunc(true)
+ }
n.Type = t
return n
}
m := newfuncnamel(mpos, methodSym(recv.Type, msym))
m.Type = mtyp
m.SetClass(PFUNC)
+ // methodSym already marked m.Sym as a function.
// (comment from parser.go)
// inl.C's inlnode in on a dotmeth node expects to find the inlineable body as
Curfn = nil
peekitabs()
+ // The "init" function is the only user-spellable symbol that
+ // we construct later. Mark it as a function now before
+ // anything can ask for its Linksym.
+ lookup("init").SetFunc(true)
+
// Phase 8: Compile top level functions.
// Don't use range--walk can add functions to xtop.
timings.Start("be", "compilefuncs")
n2 := newnamel(fn.Pos, fn.Sym)
n2.Name.Curfn = s.curfn
n2.SetClass(PFUNC)
+ n2.Sym.SetFunc(true)
n2.Pos = fn.Pos
n2.Type = types.Types[TUINT8] // dummy type for a static closure. Could use runtime.funcval if we had it.
closure = s.expr(n2)
n := newname(sym)
n.SetClass(PFUNC)
+ n.Sym.SetFunc(true)
n.Type = functype(nil, []*Node{
anonfield(types.NewPtr(t)),
anonfield(types.Types[TUINTPTR]),
n.Type = methodfunc(m.Type, n.Left.Type)
n.Xoffset = 0
n.SetClass(PFUNC)
+ // methodSym already marked n.Sym as a function.
return n
}
sym := typesymprefix(".eq", t)
n := newname(sym)
n.SetClass(PFUNC)
+ n.Sym.SetFunc(true)
n.Type = functype(nil, []*Node{
anonfield(types.NewPtr(t)),
anonfield(types.NewPtr(t)),
symSiggen // type symbol has been generated
symAsm // on asmlist, for writing to -asmhdr
symAlgGen // algorithm table has been generated
+ symFunc // function symbol; uses internal ABI
)
func (sym *Sym) OnExportList() bool { return sym.flags&symOnExportList != 0 }
func (sym *Sym) Siggen() bool { return sym.flags&symSiggen != 0 }
func (sym *Sym) Asm() bool { return sym.flags&symAsm != 0 }
func (sym *Sym) AlgGen() bool { return sym.flags&symAlgGen != 0 }
+func (sym *Sym) Func() bool { return sym.flags&symFunc != 0 }
func (sym *Sym) SetOnExportList(b bool) { sym.flags.set(symOnExportList, b) }
func (sym *Sym) SetUniq(b bool) { sym.flags.set(symUniq, b) }
func (sym *Sym) SetSiggen(b bool) { sym.flags.set(symSiggen, b) }
func (sym *Sym) SetAsm(b bool) { sym.flags.set(symAsm, b) }
func (sym *Sym) SetAlgGen(b bool) { sym.flags.set(symAlgGen, b) }
+func (sym *Sym) SetFunc(b bool) { sym.flags.set(symFunc, b) }
func (sym *Sym) IsBlank() bool {
return sym != nil && sym.Name == "_"