Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Func ¶
Func is the signature of a normal go function that can be called from the interpreter. TODO: currently the parameters can only reliably contain simple values.
type Interpreter ¶
type Interpreter struct { Context *interp.Context Panic interface{} MainPkg *ssa.Package // contains filtered or unexported fields }
Interpreter defines the datastructure to run an interpreter.
func Run ¶
func Run(code string, extFns []ExtFunc, args []string, output io.Writer) (interp *Interpreter, exitCode int, error error)
Run the interpreter, given some code.
Example ¶
ExampleRun trivial example, more to add.
package main import ( "bytes" "fmt" "github.com/go-interpreter/ssainterp" ) const code = ` package main import "fmt" func main() { fmt.Println("42") } ` // ExampleRun trivial example, more to add. func main() { var output bytes.Buffer ssainterp.Run(code, nil, nil, &output) fmt.Println(output.String()) }
Output: 42
Click to show internal directories.
Click to hide internal directories.