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

Function run_hll

tests/integration/cli_pipeline.rs:24–51  ·  view source on GitHub ↗

Compile HLL + hosted stdlib -> assembled output -> run -> (uart, exit_code).

(src: &str)

Source from the content-addressed store, hash-verified

22
23// Compile HLL + hosted stdlib -> assembled output -> run -> (uart, exit_code).
24fn run_hll(src: &str) -> (String, i64) {
25 let stdlib_objs = CompilationPipeline::compile_stdlib_objects(TargetMode::Hosted)
26 .expect("stdlib compile failed");
27
28 let user_pipeline = make_pipeline(TargetMode::Hosted, USER_PREFIX);
29 let user_result = user_pipeline.compile(src).expect("user compile failed");
30 let (_, user_tokens) =
31 user_pipeline.compile_ir_to_assembly_with_tokens(&user_result.ir_program);
32 let user_obj = user_pipeline
33 .assemble(&user_tokens)
34 .expect("assemble user object failed");
35
36 let mut modules: Vec<(&str, &AssembledOutput)> =
37 stdlib_objs.iter().map(|(n, o)| (n.as_str(), o)).collect();
38 modules.push(("user", &user_obj));
39 let assembled = user_pipeline
40 .link_assembled_objects(&modules)
41 .expect("object link failed");
42
43 let mut vm = VirtualMachine::new(&assembled);
44 let result = vm.run(5_000_000);
45
46 let code = match result.outcome {
47 StepOutcome::Halted(c) => c,
48 StepOutcome::Continue => panic!("program timed out"),
49 };
50 (result.uart_output, code)
51}
52
53// Compile HLL to IR text (mirrors `fsc hll-to-ir`).
54fn hll_to_ir_text(src: &str) -> String {

Callers 9

run_simple_return_valueFunction · 0.70
run_arithmetic_exit_codeFunction · 0.70
run_conditional_branchFunction · 0.70
run_function_callFunction · 0.70
run_zero_exit_codeFunction · 0.70

Calls 9

compile_stdlib_objectsFunction · 0.85
collectMethod · 0.80
pushMethod · 0.80
make_pipelineFunction · 0.70
compileMethod · 0.45
assembleMethod · 0.45
runMethod · 0.45

Tested by 9

run_simple_return_valueFunction · 0.56
run_arithmetic_exit_codeFunction · 0.56
run_conditional_branchFunction · 0.56
run_function_callFunction · 0.56
run_zero_exit_codeFunction · 0.56