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

Function cmd_hll_to_ir

src/cli/main.rs:274–296  ·  view source on GitHub ↗
(args: &Args)

Source from the content-addressed store, hash-verified

272 fs::write(output_path, &elf_bytes)?;
273 eprintln!("fsc: wrote linked ELF to `{output_path}`");
274
275 Ok(ExitCode::SUCCESS)
276}
277
278// --- hll-to-ir ---
279
280fn cmd_hll_to_ir(args: &Args) -> Result<ExitCode, CliError> {
281 let input = require_single_input(args)?;
282 let src = fs::read_to_string(input)?;
283
284 let mut pipeline = make_pipeline(args.mode, "_u_");
285 pipeline.set_run_semantic_analysis(false);
286 pipeline.set_artifact_stem(Some(source_stem(input, "module")));
287 pipeline.set_current_source_path(Some(input.to_owned()));
288
289 let result = pipeline
290 .compile(&src)
291 .map_err(|e| CliError::Compile(e.to_string()))?;
292
293 let ir_text = result.ir_program.to_string();
294
295 write_or_print(args.output.as_deref(), &ir_text)?;
296
297 for diag in &result.diagnostics {
298 eprintln!("{}", diag.render(input));
299 }

Callers 1

run_cliFunction · 0.85

Calls 8

require_single_inputFunction · 0.85
source_stemFunction · 0.85
write_or_printFunction · 0.85
set_artifact_stemMethod · 0.80
make_pipelineFunction · 0.70
compileMethod · 0.45

Tested by

no test coverage detected