Skip to content

v.eval #

fn create #

fn create() Eval

Host API

fn new_eval #

fn new_eval(table &ast.Table, pref_ &pref.Preferences) Eval

fn (Object) string #

fn (o Object) string() string

string is the same as the autogenerated str() methods

fn (Object) int_val #

fn (o Object) int_val() i64

fn (Object) float_val #

fn (o Object) float_val() f64

struct Array #

struct Array {
pub mut:
	val []Object
}

struct Eval #

struct Eval {
	pref &pref.Preferences = unsafe { nil }
pub mut:
	table                  &ast.Table = unsafe { nil }
	mods                   map[string]map[string]Symbol
	future_register_consts map[string]map[string]map[string]ast.ConstField // mod:file:name:field
	local_vars             map[string]Var
	local_vars_stack       []map[string]Var
	stack_vals             []Object // host stack popped by host_pop() on interpreted code
	user_files             []string // user additional files
	scope_idx              int      // this is increased when e.open_scope() is called, decreased when e.close_scope() (and all variables with that scope level deleted)
	returning              bool
	return_values          []Object
	cur_mod                string
	cur_file               string
	//
	trace_file_paths     []string
	trace_function_names []string
	back_trace           []EvalTrace
}

fn (Eval) add #

fn (mut e Eval) add(expr ast.Expr, val Object)

val and expr must be both numeric types, or both string

fn (Eval) close_scope #

fn (mut e Eval) close_scope()

fn (Eval) comptime_cond #

fn (mut e Eval) comptime_cond(cond ast.Expr) bool

fn (Eval) eval #

fn (mut e Eval) eval(mut files []&ast.File)

fn (Eval) expr #

fn (mut e Eval) expr(expr ast.Expr, expecting ast.Type) Object

fn (Eval) open_scope #

fn (mut e Eval) open_scope()

fn (Eval) register_symbol #

fn (mut e Eval) register_symbol(stmt ast.Stmt, mod string, file string)

fn (Eval) register_symbol_stmts #

fn (mut e Eval) register_symbol_stmts(stmts []ast.Stmt, mod string, file string)

fn (Eval) register_symbols #

fn (mut e Eval) register_symbols(mut files []&ast.File)

fn (Eval) run_func #

fn (mut e Eval) run_func(func ast.FnDecl, _args ...Object)

first arg is receiver (if method)

fn (Eval) set #

fn (mut e Eval) set(expr ast.Expr, val Object, init bool, typ ast.Type)

fn (Eval) stmt #

fn (mut e Eval) stmt(stmt ast.Stmt)

fn (Eval) stmts #

fn (mut e Eval) stmts(stmts []ast.Stmt)

struct EvalTrace #

struct EvalTrace {
	fn_idx   int
	file_idx int
	line     int
}

struct FixedArray #

struct FixedArray {
pub mut:
	val []Object
}

struct Float #

struct Float {
pub mut:
	val  f64
	size i8 // 8/16/32/64
}

struct Int #

struct Int {
pub mut:
	val  i64
	size i8 // 8/16/32/64
}

struct Ptr #

struct Ptr {
	val &Object = unsafe { nil }
}

struct Uint #

struct Uint {
pub mut:
	val  u64
	size i8 // 8/16/32/64
}

struct Var #

struct Var {
pub mut:
	val Object
pub:
	scope_idx int
	typ       ast.Type
}