Example #1
0
// return a barebones Runtime with almost nothing in it -- variable
// assignment and lookup works, but not much else
func minimalRuntime() *Runtime {
	stack := types.NewValueStack()
	locals := types.NewValueMap()
	stack.Push(locals)
	return &Runtime{
		stack: &stack,
		dag:   dag.NewDAG(),
	}
}
Example #2
0
func NewRuntime(
	options build.BuildOptions, script string, ast *dsl.ASTRoot) *Runtime {
	stack := types.NewValueStack()

	builtins := defineBuiltins()
	stack.Push(builtins)

	// Local variables are per-script, but we only support a single
	// script right now. So might as well initialize the script-local
	// namespace right here.
	locals := types.NewValueMap()
	stack.Push(locals)

	return &Runtime{
		options:  options,
		script:   script,
		ast:      ast,
		builtins: builtins,
		stack:    &stack,
		dag:      dag.NewDAG(),
	}
}