Skip to documentation
SLOP

tiny.python.execute

Reference tiny.python execute

Defined in runtime.vm.

Tokenizes, parses, compiles and runs the source text, then returns the program's value together with the heap that owns the value's objects.

Called byCallsprivate sourcelib.python.src.runtime.vmexecuteValueprivate sourcelib.python.src.runtime.vmexpectExecutedStringtest sourcelib.python.src.runtime.vmtest: execute dictionary displaystest sourcelib.python.src.runtime.vmtest: execute list builtin creates li...test sourcelib.python.src.runtime.vmtest: execute list clear and copy met...+5 morecompile.compilercompileruntime.Vmdeinitruntime.Vminitruntime.Vmrunruntime.VmtakeHeapruntime.vmexecute
Static calls · unresolved targets: 1 · external targets: 4.

Source

Source: lib/python/src/runtime/vm.zig:106

zig
/// Tokenizes, parses, compiles and runs the source text, then returns the program's value together/// with the heap that owns the value's objects. The README's example and nearly every test of the/// package call it with a short program. The call borrows the source text. Before it returns, the/// call frees the tokens, the syntax tree, the chunk and the machine's own state, so the result's/// heap is the only memory it hands back. The returned value borrows the result's heap and stays/// valid only until `Result.deinit`. The returned value can also point into the source text,/// through string literals and their slices, so the text has to stay alive while the value is used./// `Result.deinit` frees the heap with the allocator passed to this call. The call returns the/// errors of `tokenize`, `parse`, `compile` and `Vm.run`, and `error.OutOfMemory`, as one inferred/// error set. On any error the call frees everything it allocated, the heap included.pub fn execute(allocator: std.mem.Allocator, bytes: []const u8) !Result {    var stream = try source.tokenize(allocator, bytes);    defer stream.deinit(allocator);    var program = try syntax.parse(allocator, bytes, stream.tokens);    defer program.deinit();    var chunk_value = try compiler.compile(allocator, &program);    defer chunk_value.deinit(allocator);    var vm = Vm.init(allocator, &chunk_value);    defer vm.deinit();    const value = try vm.run();    return .{        .value = value,        .heap = vm.takeHeap(),    };}

Source: lib/python/src/root.zig:97

zig
pub const execute = runtime.execute;

Also reachable as

runtime.execute.

Complete caller list

10 direct callers.

Audit

Definitions1
Public names3
Members0
Version26.7.0
Revisiondaab053ee433