MCPcopy Create free account
hub / github.com/LPC4/Full-Stack / run_hll_closure_with_path

Function run_hll_closure_with_path

tests/integration/vm_execution.rs:121–146  ·  view source on GitHub ↗

Compile a program's import closure (primary plus every qualified `import("...")` module), link it against the cached stdlib, and run. Backward-compatible with single-TU programs.

(
    src: &str,
    source_path: Option<&str>,
    max_steps: u64,
)

Source from the content-addressed store, hash-verified

119/// Compile a program's import closure (primary plus every qualified `import("...")` module),
120/// link it against the cached stdlib, and run. Backward-compatible with single-TU programs.
121fn run_hll_closure_with_path(
122 src: &str,
123 source_path: Option<&str>,
124 max_steps: u64,
125) -> (StepOutcome, String) {
126 let mut pipeline = CompilationPipeline::new();
127 pipeline.set_write_artifacts(false);
128 pipeline.set_current_source_path(source_path.map(str::to_owned));
129 let closure = pipeline
130 .compile_program_closure("user", src)
131 .expect("closure compile failed");
132
133 let mut modules: Vec<(&str, &AssembledOutput)> = cached_stdlib_objs()
134 .iter()
135 .map(|(n, o)| (n.as_str(), o))
136 .collect();
137 for (name, obj) in &closure {
138 modules.push((name.as_str(), obj));
139 }
140 let assembled = pipeline
141 .link_assembled_objects(&modules)
142 .expect("link failed");
143 let mut vm = VirtualMachine::new(&assembled);
144 let run = vm.run(max_steps);
145 (run.outcome, run.uart_output.clone())
146}
147
148// A qualified `alias := import("path")` program links and runs its imported module: the
149// closure compiles `mathlib` alongside the primary, so `mathlib.add` resolves at link.

Callers 1

examples_exit_zero_in_vmFunction · 0.85

Calls 9

set_write_artifactsMethod · 0.80
collectMethod · 0.80
pushMethod · 0.80
cached_stdlib_objsFunction · 0.70
runMethod · 0.45
cloneMethod · 0.45

Tested by 1

examples_exit_zero_in_vmFunction · 0.68