connect0459/starlark/eval does not have a README file

    DebugFrame

    pub struct DebugFrame {
    // private fields
    }

    A snapshot of a single Starlark call frame for debugger inspection. Obtained via Thread::debug_frame(depth).

    DebugFrame::callable

    Returns the callable value (Function or Builtin) that owns this frame.

    Returns the Value representing the function or builtin being executed in this frame.

    DebugFrame::frame_local

    Returns the binding descriptor and current value of the i-th local. The value is None if the local has not yet been assigned.

    Parameters:

    • self : The debug frame to inspect.
    • i : Zero-based index into the frame's local variable list.

    Returns a tuple of the Binding descriptor (name and declaration position) and the current value of that local, or None if it has not been assigned.

    DebugFrame::local_by_name

    fn DebugFrame::local_by_name(self : DebugFrame, name : String) ->
    Value
    ?

    Returns the current value of the local variable named name, or None if the name is absent or the variable has not yet been assigned.

    Parameters:

    • self : The debug frame to inspect.
    • name : The name of the local variable to look up.

    Returns the current Value of the named local, or None if the name is not found or the variable has not yet been assigned.

    DebugFrame::num_locals

    fn DebugFrame::num_locals(self : DebugFrame) -> Int

    Returns the number of local variables (parameters + body locals) in this frame.

    Returns the total count of named locals, including both function parameters and variables declared in the function body.

    DebugFrame::position

    Returns the source position of the current execution point within this frame.

    Returns the Position indicating where execution is currently paused inside this call frame.

    Module

    pub struct Module {
    // private fields
    }

    The result of executing a Starlark file: a frozen mapping of global names to their values, plus any injected predeclared bindings.

    Module::freeze

    fn Module::freeze(self : Module) -> Unit

    Freezes the module: marks the globals dict and all contained values as immutable so they can safely be shared across threads.

    Module::from_map

    Creates a frozen Module pre-populated from m.

    Parameters:

    • m : A map of global name strings to their initial values.

    Returns a new, frozen Module containing the bindings from m.

    Module::get

    fn Module::get(self : Module, name : String) ->
    Value
    ?

    Returns the value bound to name in the module globals, or None.

    Parameters:

    • self : The module to look up in.
    • name : The global name to retrieve.

    Returns Some(value) if name is present, None otherwise.

    Module::global_names

    fn Module::global_names(self : Module) -> Array[String]

    Returns the names of all exported globals in insertion order.

    Returns an Array[String] of every global name bound in the module.

    Module::globals_count

    fn Module::globals_count(self : Module) -> Int

    Returns the number of exported globals in the module.

    Module::is_frozen

    fn Module::is_frozen(self : Module) -> Bool

    Returns true if this module has been frozen.

    Module::new

    fn Module::new() -> Module

    Creates an empty, unfrozen Module.

    Module::predeclared_count

    fn Module::predeclared_count(self : Module) -> Int

    Returns the number of predeclared bindings injected before execution.

    Module::predeclared_names

    fn Module::predeclared_names(self : Module) -> Array[String]

    Returns the names of all predeclared bindings that were injected before execution.

    Returns an Array[String] of every predeclared name.

    Options

    pub struct Options {
    // private fields
    }

    Feature-flag set controlling which optional Starlark dialect features are enabled. The default dialect is spec-conformant: the standard features allow_set, allow_lambda, allow_bytes, and allow_float default to true, while the non-standard extensions allow_recursion, allow_while, allow_top_level_control, allow_global_reassign, and load_binds_globally default to false — matching starlark-go's zero-value FileOptions for the extensions. The one intentional divergence is allow_set: starlark-go's zero value still has Set = false, but set is now part of the Starlark spec, so it is enabled by default here.

    Options::allow_bytes

    fn Options::allow_bytes(self : Options) -> Bool

    Returns true if bytes literals and the bytes() builtin are allowed.

    Options::allow_float

    fn Options::allow_float(self : Options) -> Bool

    Returns true if floating-point literals and float arithmetic are allowed.

    Options::allow_global_reassign

    fn Options::allow_global_reassign(self : Options) -> Bool

    Returns true if module-level globals may be reassigned after their initial binding.

    Options::allow_lambda

    fn Options::allow_lambda(self : Options) -> Bool

    Returns true if lambda expressions are allowed.

    Options::allow_recursion

    fn Options::allow_recursion(self : Options) -> Bool

    Returns true if recursive function calls are allowed at runtime.

    Options::allow_set

    fn Options::allow_set(self : Options) -> Bool

    Returns true if set literals and set comprehensions are allowed.

    Options::allow_top_level_control

    fn Options::allow_top_level_control(self : Options) -> Bool

    Returns true if if, for, and while statements are allowed at the module (top) level.

    Options::allow_while

    fn Options::allow_while(self : Options) -> Bool

    Returns true if while loops are allowed.

    Options::default

    fn Options::default() -> Options

    Returns the default Options: the spec-conformant Starlark dialect. The standard features (allow_set, allow_lambda, allow_bytes, allow_float) are enabled; the non-standard extensions (allow_recursion, allow_while, allow_top_level_control, allow_global_reassign, load_binds_globally) are disabled and must be opted into explicitly, matching starlark-go's zero-value FileOptions for those extensions. allow_set intentionally diverges from that zero value (Set = false) because set is now standard.

    Options::load_binds_globally

    fn Options::load_binds_globally(self : Options) -> Bool

    Returns true if load-imported names are bound at module (global) scope rather than file-local scope.

    Options::with_allow_bytes

    fn Options::with_allow_bytes(self : Options, v : Bool) -> Options

    Returns a copy of self with allow_bytes set to v.

    Parameters:

    • self : The options to copy.
    • v : The new value for the allow_bytes flag.

    Returns a new Options with the allow_bytes flag set to v.

    Options::with_allow_float

    fn Options::with_allow_float(self : Options, v : Bool) -> Options

    Returns a copy of self with allow_float set to v.

    Parameters:

    • self : The options to copy.
    • v : The new value for the allow_float flag.

    Returns a new Options with the allow_float flag set to v.

    Options::with_allow_global_reassign

    fn Options::with_allow_global_reassign(self : Options, v : Bool) -> Options

    Returns a copy of self with allow_global_reassign set to v.

    Parameters:

    • self : The options to copy.
    • v : The new value for the allow_global_reassign flag.

    Returns a new Options with the allow_global_reassign flag set to v.

    Options::with_allow_lambda

    fn Options::with_allow_lambda(self : Options, v : Bool) -> Options

    Returns a copy of self with allow_lambda set to v.

    Parameters:

    • self : The options to copy.
    • v : The new value for the allow_lambda flag.

    Returns a new Options with the allow_lambda flag set to v.

    Options::with_allow_recursion

    fn Options::with_allow_recursion(self : Options, v : Bool) -> Options

    Returns a copy of self with allow_recursion set to v.

    Parameters:

    • self : The options to copy.
    • v : The new value for the allow_recursion flag.

    Returns a new Options with the allow_recursion flag set to v.

    Options::with_allow_set

    fn Options::with_allow_set(self : Options, v : Bool) -> Options

    Returns a copy of self with allow_set set to v.

    Parameters:

    • self : The options to copy.
    • v : The new value for the allow_set flag.

    Returns a new Options with the allow_set flag set to v.

    Options::with_allow_top_level_control

    fn Options::with_allow_top_level_control(self : Options, v : Bool) -> Options

    Returns a copy of self with allow_top_level_control set to v.

    Parameters:

    • self : The options to copy.
    • v : The new value for the allow_top_level_control flag.

    Returns a new Options with the allow_top_level_control flag set to v.

    Options::with_allow_while

    fn Options::with_allow_while(self : Options, v : Bool) -> Options

    Returns a copy of self with allow_while set to v.

    Parameters:

    • self : The options to copy.
    • v : The new value for the allow_while flag.

    Returns a new Options with the allow_while flag set to v.

    Options::with_load_binds_globally

    fn Options::with_load_binds_globally(self : Options, v : Bool) -> Options

    Returns a copy of self with load_binds_globally set to v.

    Parameters:

    • self : The options to copy.
    • v : The new value for the load_binds_globally flag.

    Returns a new Options with the load_binds_globally flag set to v.

    Predeclared

    pub struct Predeclared {
    // private fields
    }

    Per-execution extra bindings injected before user globals. Visible to both the resolver and evaluator but not exported in the resulting Module.

    Predeclared::delete

    fn Predeclared::delete(self : Predeclared, name : String) -> Bool

    Removes the binding for name.

    Parameters:

    • self : The predeclared set to modify.
    • name : The name to remove.

    Returns true if name was present (and removed), false if absent.

    Predeclared::each

    fn Predeclared::each(self : Predeclared, f : (String,
    Value
    ) -> Unit) -> Unit

    Calls f(name, value) for every binding in the set.

    Parameters:

    • self : The predeclared set to iterate.
    • f : Callback receiving each name and its bound value.

    Predeclared::from_map

    Creates a Predeclared set wrapping an existing map.

    Parameters:

    • m : The map to wrap; keys are name strings, values are the bindings.

    Returns a Predeclared backed by m.

    Predeclared::get

    Returns the value bound to name, or None.

    Parameters:

    • self : The predeclared set to look up in.
    • name : The name to retrieve.

    Returns Some(value) if name is present, None otherwise.

    Predeclared::has

    fn Predeclared::has(self : Predeclared, name : String) -> Bool

    Returns true if name is present in the predeclared set.

    Parameters:

    • self : The predeclared set to query.
    • name : The name to test for presence.

    Returns true if name exists in the set.

    Predeclared::keys

    fn Predeclared::keys(self : Predeclared) -> Array[String]

    Returns the predeclared names in lexicographic order.

    Parameters:

    • self : The predeclared set whose names to retrieve.

    Returns an array of all names sorted lexicographically.

    Predeclared::new

    Creates an empty Predeclared set.

    Predeclared::set

    fn Predeclared::set(self : Predeclared, name : String, v :
    Value
    ) -> Unit

    Adds or replaces the binding for name.

    Parameters:

    • self : The predeclared set to modify.
    • name : The name to bind.
    • v : The value to associate with name.

    Predeclared::values

    Returns all bound values in the set.

    Parameters:

    • self : The predeclared set whose values to retrieve.

    Returns an array of all bound values.

    Program

    pub struct Program {
    // private fields
    }

    A parsed and resolved Starlark source file. Execute via init; parsing and resolution costs are paid once. A Program may be init'd multiple times with different predeclared dictionaries.

    Program::filename

    fn Program::filename(self : Program) -> String

    Returns the source filename recorded in the program.

    Returns the filename string that was supplied when the program was created.

    Program::init

    fn Program::init(self : Program, thread : Thread, predeclared : Predeclared) -> Result[Module,
    EvalError
    ]

    Executes the program with the given predeclared bindings, returning an unfrozen Module. Unlike exec_file, does not freeze the module on return. May be called multiple times with different predeclared dictionaries.

    Parameters:

    • self : The resolved program to execute.
    • thread : The thread context that carries the call stack and load handler.
    • predeclared : The set of predeclared name–value bindings visible to the program during execution.

    Returns an unfrozen Module whose globals are the top-level bindings produced by the execution, or an EvalError if execution fails.

    Program::load

    fn Program::load(self : Program, i : Int) -> (String,
    Position
    )

    Returns the path string and source position of the i-th load statement. Returns an empty string and unknown position if i is out of range.

    Parameters:

    • self : The program whose load statements are queried.
    • i : Zero-based index of the load statement to retrieve.

    Returns a tuple of the module path string and the source position of that load statement, or an empty string and unknown position if i is out of range.

    Program::num_loads

    fn Program::num_loads(self : Program) -> Int

    Returns the number of load(...) statements in the program.

    Returns the count of top-level load statements found in the program.

    Program::options

    fn Program::options(self : Program) -> Options

    Returns the file-level dialect options this program was resolved with. These options are bound to the program (and survive serialization), so a Program plays the role starlark-go assigns to a file's FileOptions: per-file, immutable dialect configuration rather than global flags.

    Program::write

    fn Program::write(self : Program) -> Bytes

    Serializes this program to a self-describing byte sequence that compiled_program can reload without re-parsing, re-resolving, or re-compiling the source. The encoding holds the compiled bytecode program plus the program's options; it is specific to this implementation and is NOT compatible with starlark-go's Program.Write format.

    Thread

    pub struct Thread {
    // private fields
    }

    Execution context for a single Starlark evaluation. Carries the print and load callbacks, call stack, recursion limit, step budget, and cancellation state. A Thread is not safe for concurrent use.

    Thread::call_frame

    Returns the call frame at n steps from the innermost frame (0 = innermost, 1 = its caller, etc.), or None if out of range.

    Parameters:

    • self : The thread whose call stack to inspect.
    • n : Distance from the innermost frame (0 = innermost).

    Returns Some(frame) if the index is valid, None otherwise.

    Thread::call_stack

    Returns a snapshot of the current call stack (outermost frame first).

    Thread::call_stack_depth

    fn Thread::call_stack_depth(self : Thread) -> Int

    Returns the current call-stack depth (number of active Starlark frames).

    Thread::cancel

    fn Thread::cancel(self : Thread, reason : String) -> Unit

    Marks the thread as cancelled with the given reason. The evaluator checks this flag at each step and raises an error on the next opportunity. Only the first call takes effect.

    Parameters:

    • self : The thread to cancel.
    • reason : A message describing why the thread was cancelled; used in the raised error.

    Thread::debug_frame

    fn Thread::debug_frame(self : Thread, depth : Int) -> DebugFrame?

    Returns a snapshot of the active Starlark call frame at depth steps from the innermost frame (0 = innermost). Returns None if depth is out of range or the frame is not a Starlark function frame.

    Parameters:

    • self : The thread whose debug call stack to inspect.
    • depth : Distance from the innermost Starlark function frame (0 = innermost).

    Returns Some(frame) if a Starlark frame exists at that depth, None otherwise.

    Thread::execution_steps

    fn Thread::execution_steps(self : Thread) -> Int

    Returns the total number of evaluation steps executed on this thread.

    Thread::get_local

    fn Thread::get_local(self : Thread, key : String) ->
    Value
    ?

    Retrieves the thread-local value previously stored under key, or None.

    Parameters:

    • self : The thread to retrieve from.
    • key : The key identifying the thread-local slot.

    Returns Some(value) if a value was stored under key, None otherwise.

    Thread::max_recursion_depth

    fn Thread::max_recursion_depth(self : Thread) -> Int

    Returns the maximum call-stack depth before a recursion-limit error is raised.

    Thread::max_steps

    fn Thread::max_steps(self : Thread) -> Int?

    Returns the current step budget, or None if no budget was set.

    Thread::name

    fn Thread::name(self : Thread) -> String

    Returns the name the thread was created with.

    Thread::new

    fn Thread::new(name : String) -> Thread

    Creates a Thread with the given name, printing to stdout, no loader, and the default recursion depth limit.

    Parameters:

    • name : A label for the thread used in diagnostics.

    Returns a new Thread ready for Starlark execution.

    Thread::reset_steps

    fn Thread::reset_steps(self : Thread) -> Unit

    Resets the accumulated step counter to zero without changing the budget.

    Thread::set_loader

    fn Thread::set_loader(self : Thread, load_fn : (Thread, String) -> Result[Module,
    EvalError
    ]) -> Unit

    Replaces the load callback used by load() statements.

    Parameters:

    • self : The thread to update.
    • load_fn : The new load callback; receives the active thread and the module path, returns the loaded module or an error.

    Thread::set_local

    fn Thread::set_local(self : Thread, key : String, value :
    Value
    ) -> Unit

    Stores a thread-local value under key. Used by extension libraries (e.g. time.now()) to communicate per-thread state such as clock overrides.

    Parameters:

    • self : The thread to store the value on.
    • key : The key identifying this thread-local slot.
    • value : The value to store.

    Thread::set_max_steps

    fn Thread::set_max_steps(self : Thread, max : Int) -> Unit

    Sets the execution-step budget without resetting the accumulated step count. Use reset_steps to zero the counter explicitly.

    Parameters:

    • self : The thread to update.
    • max : The new maximum step count.

    Thread::set_on_max_steps

    fn Thread::set_on_max_steps(self : Thread, cb : (Thread) -> Unit) -> Unit

    Registers a callback invoked when the step budget is exhausted, before the error is raised.

    Parameters:

    • self : The thread to update.
    • cb : The callback to invoke when the step budget is exhausted.

    Thread::set_print

    fn Thread::set_print(self : Thread, print_fn : (Thread, String) -> Unit) -> Unit

    Replaces the print callback. Combined with set_loader and set_max_steps, this lets a single thread carry all three settings.

    Parameters:

    • self : The thread to update.
    • print_fn : The new print callback; receives the active thread and the formatted message string.

    Thread::uncancel

    fn Thread::uncancel(self : Thread) -> Unit

    Clears a previous cancellation, allowing execution to resume.

    Thread::with_loader

    fn Thread::with_loader(name : String, load_fn : (Thread, String) -> Result[Module,
    EvalError
    ]) -> Thread

    Creates a Thread with a load callback for load() statements.

    Parameters:

    • name : A label for the thread used in diagnostics.
    • load_fn : Callback invoked for each load("path", ...) statement; receives the active thread and the module path, returns the loaded module.

    Returns a new Thread with the given load callback.

    Thread::with_print

    fn Thread::with_print(name : String, print_fn : (Thread, String) -> Unit) -> Thread

    Creates a Thread with a custom print callback.

    Parameters:

    • name : A label for the thread used in diagnostics.
    • print_fn : Callback invoked for each print() call; receives the active thread and the formatted message string.

    Returns a new Thread with the given print callback.

    Thread::with_step_budget

    fn Thread::with_step_budget(name : String, max_steps : Int) -> Thread

    Creates a Thread with a maximum step budget; execution raises an error when the budget is exhausted.

    Parameters:

    • name : A label for the thread used in diagnostics.
    • max_steps : Maximum number of evaluation steps before the execution is cancelled with an error.

    Returns a new Thread with the given step budget.

    Universe

    pub struct Universe {
    // private fields
    }

    The set of predeclared built-in bindings shared across all modules. Universe::standard() provides the default Starlark built-ins; embedders may extend it with set().

    Universe::delete

    fn Universe::delete(self : Universe, name : String) -> Bool

    Removes the binding for name.

    Parameters:

    • self : The universe to modify.
    • name : The name to remove.

    Returns true if name was present (and removed), false if absent.

    Universe::each

    fn Universe::each(self : Universe, f : (String,
    Value
    ) -> Unit) -> Unit

    Calls f(name, value) for every binding in the universe.

    Parameters:

    • self : The universe to iterate.
    • f : Callback receiving each name and its bound value.

    Universe::from_map

    Creates a Universe wrapping an existing binding map.

    Parameters:

    • m : The map to wrap; keys are name strings, values are the bindings.

    Returns a Universe backed by m.

    Universe::get

    fn Universe::get(self : Universe, name : String) ->
    Value
    ?

    Returns the value bound to name in the universe, or None.

    Parameters:

    • self : The universe to look up in.
    • name : The predeclared name to retrieve.

    Returns Some(value) if name is present, None otherwise.

    Universe::has

    fn Universe::has(self : Universe, name : String) -> Bool

    Returns true if name is present in the universe.

    Parameters:

    • self : The universe to query.
    • name : The name to test for presence.

    Returns true if name exists in the universe.

    Universe::keys

    fn Universe::keys(self : Universe) -> Array[String]

    Returns the predeclared names in lexicographic order.

    Parameters:

    • self : The universe whose names to retrieve.

    Returns an array of all names sorted lexicographically.

    Universe::new

    fn Universe::new() -> Universe

    Creates an empty Universe with no predeclared names.

    Universe::set

    fn Universe::set(self : Universe, name : String, value :
    Value
    ) -> Unit

    Adds or replaces the binding for name in the universe.

    Parameters:

    • self : The universe to modify.
    • name : The predeclared name to bind.
    • value : The value to associate with name.

    Universe::standard

    fn Universe::standard() -> Universe

    Creates a Universe pre-populated with all standard Starlark built-ins (None, True, False, print, range, etc.).

    Universe::values

    Returns all bound values in the universe.

    Parameters:

    • self : The universe whose values to retrieve.

    Returns an array of all bound values.

    binary

    Applies a Starlark binary operator by name to x and y. Valid operators: "+", "-", "*", "/", "//", "%", "&", "|", "^", "<<", ">>".

    Parameters:

    • op : The binary operator name.
    • x : The left-hand operand.
    • y : The right-hand operand.

    Returns the operation result, or an EvalError on type mismatch or arithmetic error.

    call

    Invokes a Starlark callable from host code with positional args and keyword kwargs.

    Parameters:

    • thread : Execution context providing print/load callbacks and step budget.
    • func : The Starlark callable to invoke (function, builtin, or bound method).
    • args : Positional arguments to pass.
    • kwargs : Keyword arguments as (name, value) pairs.

    Returns the call result, or an EvalError on failure.

    compare

    Applies a Starlark comparison operator by name to x and y. Valid operators: "==", "!=", "<", "<=", ">", ">=".

    Parameters:

    • op : The comparison operator name.
    • x : The left-hand operand.
    • y : The right-hand operand.

    Returns Ok(result) on success, or an EvalError on type mismatch.

    compiled_program

    fn compiled_program(data : Bytes) -> Result[Program,
    EvalError
    ]

    Reconstructs a Program from bytes produced by Program::write. The input is trusted to already carry the compiled bytecode program: neither resolution nor compilation is re-run during decode (re-resolution would require the original is_predeclared predicate), so the bytes hydrate straight into a runnable CompiledProgram. Returns an EvalError if the bytes are truncated, carry an unknown magic header, or were written by an incompatible serializer version.

    eval_expr

    Parses and evaluates a single Starlark expression with the default options, using env as the global environment.

    Parameters:

    • thread : Execution context providing print/load callbacks and step budget.
    • filename : Source file name used in error messages and position info.
    • src : Starlark expression source text to evaluate.
    • env : Global environment dict supplying variable bindings.

    Returns the evaluated Value, or an EvalError on failure.

    eval_expr_with_opts

    Like eval_expr but accepts explicit opts.

    Parameters:

    • thread : Execution context providing print/load callbacks and step budget.
    • filename : Source file name used in error messages and position info.
    • src : Starlark expression source text to evaluate.
    • opts : Feature flags controlling which dialect features are active.
    • env : Global environment dict supplying variable bindings.

    Returns the evaluated Value, or an EvalError on failure.

    eval_parsed_expr

    Evaluates a pre-parsed expression node under opts with the bindings in env as the global environment.

    Parameters:

    • thread : Execution context providing print/load callbacks and step budget.
    • expr : Pre-parsed expression AST node to evaluate.
    • opts : Feature flags controlling which dialect features are active.
    • env : Global environment dict supplying variable bindings.

    Returns the evaluated Value, or an EvalError on runtime failure.

    exec_file

    fn exec_file(thread : Thread, filename : String, src : String, opts : Options) -> Result[Module,
    EvalError
    ]

    Parses, resolves, and executes a Starlark source file; returns the frozen module whose globals are the file's top-level bindings.

    Parameters:

    • thread : Execution context providing print/load callbacks and step budget.
    • filename : Source file name used in error messages and position info.
    • src : Starlark source text to execute.
    • opts : Feature flags controlling which dialect features are active.

    Returns the frozen Module, or an EvalError on parse, resolve, or runtime failure.

    exec_file_with_predeclared

    fn exec_file_with_predeclared(thread : Thread, filename : String, src : String, opts : Options, predeclared : Predeclared) -> Result[Module,
    EvalError
    ]

    Like exec_file but injects extra predeclared bindings that are visible to the script but not included in the returned module's globals.

    Parameters:

    • thread : Execution context providing print/load callbacks and step budget.
    • filename : Source file name used in error messages and position info.
    • src : Starlark source text to execute.
    • opts : Feature flags controlling which dialect features are active.
    • predeclared : Extra per-execution bindings injected before user globals.

    Returns the frozen Module, or an EvalError on failure.

    exec_file_with_universe

    fn exec_file_with_universe(thread : Thread, filename : String, src : String, opts : Options, universe : Universe) -> Result[Module,
    EvalError
    ]

    Like exec_file but replaces the default built-in universe with universe, allowing the embedder to override or extend predeclared names.

    Parameters:

    • thread : Execution context providing print/load callbacks and step budget.
    • filename : Source file name used in error messages and position info.
    • src : Starlark source text to execute.
    • opts : Feature flags controlling which dialect features are active.
    • universe : Custom universe of predeclared bindings to use instead of the standard built-ins.

    Returns the frozen Module, or an EvalError on failure.

    exec_repl_chunk

    fn exec_repl_chunk(thread : Thread, filename : String, src : String, globals :
    StringDict
    , opts : Options) -> Result[Unit,
    EvalError
    ]

    Executes one REPL chunk: parses src, resolves it against globals, evaluates it, and writes any new or updated bindings back into globals.

    Parameters:

    • thread : Execution context providing print/load callbacks and step budget.
    • filename : Source file name used in error messages and position info.
    • src : Starlark source chunk to execute (may be statements or an expression).
    • globals : Mutable dict that persists global bindings across REPL chunks.
    • opts : Feature flags controlling which dialect features are active.

    Returns Ok(()) on success, or an EvalError on failure.

    file_program

    fn file_program(file :
    File
    , opts : Options, is_predeclared : (String) -> Bool) -> Result[Program,
    EvalError
    ]

    Resolves an already-parsed File AST with the given options, returning a Program ready for init. Skips lexing and parsing.

    Parameters:

    • file : A previously parsed File AST to resolve.
    • opts : Evaluation options controlling language features.
    • is_predeclared : A predicate that returns true if a given name is provided by the embedder's predeclared environment.

    Returns a resolved Program, or an EvalError if name resolution fails.

    parse_expr

    fn parse_expr(filename : String, src : String) -> Result[
    Expr
    ,
    EvalError
    ]

    Parses src as a single Starlark expression and returns its AST node.

    Parameters:

    • filename : Source file name used in error messages and position info.
    • src : Starlark expression source text to parse.

    Returns the parsed @syntax.Expr, or an EvalError on syntax failure.

    parse_file

    fn parse_file(filename : String, src : String) -> Result[
    File
    ,
    EvalError
    ]

    Parses src as a Starlark source file and returns its AST.

    Parameters:

    • filename : Source file name used in error messages and position info.
    • src : Starlark source text to parse.

    Returns the parsed @syntax.File, or an EvalError on syntax failure.

    source_program

    fn source_program(filename : String, src : String, opts : Options, is_predeclared : (String) -> Bool) -> Result[Program,
    EvalError
    ]

    Parses and resolves src as a Starlark file named filename, returning an immutable Program on success. is_predeclared answers whether a name is provided by the embedder's predeclared environment.

    Parameters:

    • filename : The name used to identify this source file in error messages and stack traces.
    • src : The Starlark source text to parse and resolve.
    • opts : Evaluation options controlling language features.
    • is_predeclared : A predicate that returns true if a given name is provided by the embedder's predeclared environment.

    Returns a Program ready for init, or an EvalError if parsing or resolution fails.

    source_program_with_file

    fn source_program_with_file(filename : String, src : String, opts : Options, is_predeclared : (String) -> Bool) -> Result[(
    File
    , Program),
    EvalError
    ]

    Like source_program but also returns the parsed File AST alongside the Program, useful when the caller needs to inspect load statements before executing.

    Parameters:

    • filename : The name used to identify this source file in error messages and stack traces.
    • src : The Starlark source text to parse and resolve.
    • opts : Evaluation options controlling language features.
    • is_predeclared : A predicate that returns true if a given name is provided by the embedder's predeclared environment.

    Returns a pair of the parsed File AST and the resolved Program, or an EvalError if parsing or resolution fails.

    unary

    Applies a Starlark unary operator by name to x. Valid operators: "+", "-", "~", "not".

    Parameters:

    • op : The unary operator name.
    • x : The operand.

    Returns the operation result, or an EvalError on type mismatch.