v2.eval #
fn create #
fn create() Eval
create returns a capturing evaluator convenient for tests.
fn new #
fn new(prefs_ &pref.Preferences) Eval
new returns a new evaluator configured for direct execution.
struct Eval #
struct Eval {
pub mut:
capture_output bool
prefs pref.Preferences
mut:
stdout_data string
stderr_data string
functions map[string]map[string]FunctionDef
consts map[string]map[string]ConstEntry
sum_types map[string]SumTypeInfo
struct_field_types map[string]map[string]map[string]ast.Expr
type_names map[string]map[string]bool
file_import_alias map[string]map[string]string
modules map[string]bool
scopes []ScopeFrame
call_stack []CallFrame
next_token_pos_id i64
}
Eval interprets the v2 AST directly for a limited subset of V.
fn (Eval) stdout #
fn (e &Eval) stdout() string
stdout returns the captured stdout stream.
fn (Eval) stderr #
fn (e &Eval) stderr() string
stderr returns the captured stderr stream.
fn (Eval) run_text #
fn (mut e Eval) run_text(code string) ![]Value
run_text parses and executes a single V source string.
fn (Eval) run_files #
fn (mut e Eval) run_files(files []ast.File) ![]Value
run_files executes parsed AST files and invokes main.main.