當前位置: 首頁>>代碼示例>>Golang>>正文


Golang Frame.Caller方法代碼示例

本文整理匯總了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()
	}
}
開發者ID:rocky,項目名稱:ssa-interp,代碼行數:34,代碼來源:frame.go

示例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++
	}
}
開發者ID:rocky,項目名稱:ssa-interp,代碼行數:14,代碼來源:frame.go


注:本文中的github.com/rocky/ssa-interp/interp.Frame.Caller方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。