type continuation … const kNext … const kReturn … const kJump … type Mode … const DisableRecover … const EnableTracing … type methodSet … type interpreter … type deferred … type frame … func (fr *frame) get(key ssa.Value) value { … } // runDefer runs a deferred call d. // It always returns normally, but may set or clear fr.panic. func (fr *frame) runDefer(d *deferred) { … } // runDefers executes fr's deferred function calls in LIFO order. // // On entry, fr.panicking indicates a state of panic; if // true, fr.panic contains the panic value. // // On completion, if a deferred call started a panic, or if no // deferred call recovered from a previous state of panic, then // runDefers itself panics after the last deferred call has run. // // If there was no initial state of panic, or it was recovered from, // runDefers returns normally. func (fr *frame) runDefers() { … } // lookupMethod returns the method set for type typ, which may be one // of the interpreter's fake types. func lookupMethod(i *interpreter, typ types.Type, meth *types.Func) *ssa.Function { … } // visitInstr interprets a single ssa.Instruction within the activation // record frame. It returns a continuation value indicating where to // read the next instruction from. func visitInstr(fr *frame, instr ssa.Instruction) continuation { … } // prepareCall determines the function value and argument values for a // function call in a Call, Go or Defer instruction, performing // interface method lookup if needed. func prepareCall(fr *frame, call *ssa.CallCommon) (fn value, args []value) { … } // call interprets a call to a function (function, builtin or closure) // fn with arguments args, returning its result. // callpos is the position of the callsite. func call(i *interpreter, caller *frame, callpos token.Pos, fn value, args []value) value { … } func loc(fset *token.FileSet, pos token.Pos) string { … } // callSSA interprets a call to function fn with arguments args, // and lexical environment env, returning its result. // callpos is the position of the callsite. func callSSA(i *interpreter, caller *frame, callpos token.Pos, fn *ssa.Function, args []value, env []value) value { … } // runFrame executes SSA instructions starting at fr.block and // continuing until a return, a panic, or a recovered panic. // // After a panic, runFrame panics. // // After a normal return, fr.result contains the result of the call // and fr.block is nil. // // A recovered panic in a function without named return parameters // (NRPs) becomes a normal return of the zero value of the function's // result type. // // After a recovered panic in a function with NRPs, fr.result is // undefined and fr.block contains the block at which to resume // control. func runFrame(fr *frame) { … } // doRecover implements the recover() built-in. func doRecover(caller *frame) value { … } // Interpret interprets the Go program whose main package is mainpkg. // mode specifies various interpreter options. filename and args are // the initial values of os.Args for the target program. sizes is the // effective type-sizing function for this program. // // Interpret returns the exit code of the program: 2 for panic (like // gc does), or the argument to os.Exit for normal termination. // // The SSA program must include the "runtime" package. // // Type parameterized functions must have been built with // InstantiateGenerics in the ssa.BuilderMode to be interpreted. func Interpret(mainpkg *ssa.Package, mode Mode, sizes types.Sizes, filename string, args []string) (exitCode int) { … }