本文整理匯總了Golang中github.com/rocky/ssa-interp/interp.Frame.Caller方法的典型用法代碼示例。如果您正苦於以下問題:Golang Frame.Caller方法的具體用法?Golang Frame.Caller怎麽用?Golang Frame.Caller使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類github.com/rocky/ssa-interp/interp.Frame
的用法示例。
在下文中一共展示了Frame.Caller方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: frameInit
func frameInit(fr *interp.Frame) {
topFrame = fr
curFrame = fr
frameIndex = 0
curBlock = fr.Block()
// EvalEnv = interp.MakeEnv(EvalEnvironment(), program, fr)
for stackSize = 0; fr != nil; fr = fr.Caller(0) {
stackSize++
}
switch TraceEvent {
case ssa2.CALL_RETURN, ssa2.PROGRAM_TERMINATION:
/* These guys are not in a basic block, so curFrame.Scope
won't work here. . Not sure why fr.Fn() memory crashes either.
Otherwise, I'd use fr.Fn().Scope
*/
curScope = nil
/* A "block end" sets the frame block can be nil. There should
be a better way to do this inside the interpreter but I get:
panic: unexpected type: <nil>: <nil>
when I tried it and don't know why. */
switch instr := (*Instr).(type) {
case *ssa2.Return:
if curBlock == nil {
curBlock = instr.Block()
}
}
default:
// FIXME: may need other cases like defer_enter, panic,
// block_end?
curScope = curFrame.Scope()
}
}
示例2: PrintStack
func PrintStack(fr *interp.Frame, count int) {
if fr == nil {
return
}
for i := 0; fr != nil && i < count; fr = fr.Caller(0) {
pointer := " "
if fr == curFrame {
pointer = "=> "
}
Msg("%s#%d %s", pointer, i, fr.FnAndParamString())
Msg("\t%s", fr.PositionRange())
i++
}
}