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.
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
Complete caller list
10 direct callers.
lib.python.src.runtime.vm.executeValue[function] — private source atlib/python/src/runtime/vm.zig:1594in nearest public ownertiny.python.runtime.vmlib.python.src.runtime.vm.expectExecutedString[function] — private source atlib/python/src/runtime/vm.zig:3131in nearest public ownertiny.python.runtime.vmlib.python.src.runtime.vm.test_execute_dictionary_displays[function] — test source atlib/python/src/runtime/vm.zig:2674in nearest public ownertiny.python.runtime.vmlib.python.src.runtime.vm.test_execute_list_builtin_creates_lists[function] — test source atlib/python/src/runtime/vm.zig:2456in nearest public ownertiny.python.runtime.vmlib.python.src.runtime.vm.test_execute_list_clear_and_copy_methods[function] — test source atlib/python/src/runtime/vm.zig:2169in nearest public ownertiny.python.runtime.vmlib.python.src.runtime.vm.test_execute_list_displays[function] — test source atlib/python/src/runtime/vm.zig:1976in nearest public ownertiny.python.runtime.vmlib.python.src.runtime.vm.test_execute_range_builtin_creates_range_objects[function] — test source atlib/python/src/runtime/vm.zig:2356in nearest public ownertiny.python.runtime.vmlib.python.src.runtime.vm.test_execute_string_slices[function] — test source atlib/python/src/runtime/vm.zig:2234in nearest public ownertiny.python.runtime.vmlib.python.src.runtime.vm.test_execute_tuple_builtin_creates_tuples[function] — test source atlib/python/src/runtime/vm.zig:3033in nearest public ownertiny.python.runtime.vmlib.python.src.runtime.vm.test_execute_tuple_literals[function] — test source atlib/python/src/runtime/vm.zig:1907in nearest public ownertiny.python.runtime.vm
Audit
| Definitions | 1 |
|---|---|
| Public names | 3 |
| Members | 0 |
| Version | 26.7.0 |
| Revision | daab053ee433 |