"cmd/compile/internal/objw"
"cmd/compile/internal/ssagen"
"cmd/compile/internal/staticinit"
- "cmd/compile/internal/typecheck"
"cmd/compile/internal/types"
"cmd/compile/internal/walk"
"cmd/internal/obj"
// Calculate parameter offsets.
types.CalcSize(fn.Type())
- typecheck.DeclContext = ir.PAUTO
ir.CurFunc = fn
walk.Walk(fn)
ir.CurFunc = nil // enforce no further uses of CurFunc
- typecheck.DeclContext = ir.PEXTERN
}
// compileFunctions compiles all functions in compilequeue.
}
base.Pos = base.AutogeneratedPos // less confusing than end of input
- typecheck.DeclContext = ir.PEXTERN
// func sym(p *T, h uintptr) uintptr
args := []*ir.Field{
return sym.Def.(*ir.Name).Func
}
base.Pos = base.AutogeneratedPos // less confusing than end of input
- typecheck.DeclContext = ir.PEXTERN
// func sym(p, q *T) bool
fn := typecheck.DeclFunc(sym, nil,
// Q: is this needed?
savepos := base.Pos
- savedclcontext := typecheck.DeclContext
savedcurfn := ir.CurFunc
base.Pos = base.AutogeneratedPos
- typecheck.DeclContext = ir.PEXTERN
// At the moment we don't support wrapping a method, we'd need machinery
// below to handle the receiver. Panic if we see this scenario.
// Restore previous context.
base.Pos = savepos
- typecheck.DeclContext = savedclcontext
ir.CurFunc = savedcurfn
}
"cmd/internal/src"
)
-var DeclContext ir.Class = ir.PEXTERN // PEXTERN/PAUTO
+var funcStack []*ir.Func // stack of previous values of ir.CurFunc
func DeclFunc(sym *types.Sym, recv *ir.Field, params, results []*ir.Field) *ir.Func {
fn := ir.NewFunc(base.Pos, base.Pos, sym, nil)
- StartFuncBody(fn)
+
+ funcStack = append(funcStack, ir.CurFunc)
+ ir.CurFunc = fn
var recv1 *types.Field
if recv != nil {
return fn
}
-// declare the function proper
-// and declare the arguments.
-// called in extern-declaration context
-// returns in auto-declaration context.
-func StartFuncBody(fn *ir.Func) {
- // change the declaration context from extern to auto
- funcStack = append(funcStack, funcStackEnt{ir.CurFunc, DeclContext})
- ir.CurFunc = fn
- DeclContext = ir.PAUTO
-}
-
// finish the body.
// called in auto-declaration context.
// returns in extern-declaration context.
func FinishFuncBody() {
- // change the declaration context from auto to previous context
- var e funcStackEnt
- funcStack, e = funcStack[:len(funcStack)-1], funcStack[len(funcStack)-1]
- ir.CurFunc, DeclContext = e.curfn, e.dclcontext
+ funcStack, ir.CurFunc = funcStack[:len(funcStack)-1], funcStack[len(funcStack)-1]
}
func CheckFuncStack() {
}
}
-var funcStack []funcStackEnt // stack of previous values of ir.CurFunc/DeclContext
-
-type funcStackEnt struct {
- curfn *ir.Func
- dclcontext ir.Class
-}
-
func declareParams(fn *ir.Func, ctxt ir.Class, l []*ir.Field) []*types.Field {
fields := make([]*types.Field, len(l))
for i, n := range l {