Package interp
Overview ▹
Index ▹
Variables
If CapturedOutput is non-nil, all writes by the interpreted program to file descriptors 1 and 2 will also be written to CapturedOutput.
(The $GOROOT/test system requires that the test be considered a failure if "BUG" appears in the combined stdout/stderr output, even if it exits zero. This is a global variable shared by all interpreters in the same process.)
var CapturedOutput *bytes.Buffer
func Interpret ¶
func Interpret(mainpkg *ssa.Package, mode Mode, sizes types.Sizes, filename string, args []string) (exitCode int)
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 Mode ¶
Mode is a bitmask of options affecting the interpreter.
type Mode uint
const ( DisableRecover Mode = 1 << iota // Disable recover() in target programs; show interpreter crash instead. EnableTracing // Print a trace of all instructions as they are interpreted. )