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

Function cmd_hll_to_asm

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

Source from the content-addressed store, hash-verified

298 for diag in &result.diagnostics {
299 eprintln!("{}", diag.render(input));
300 }
301
302 Ok(ExitCode::SUCCESS)
303}
304
305// --- hll-to-asm ---
306
307fn cmd_hll_to_asm(args: &Args) -> Result<ExitCode, CliError> {
308 let input = require_single_input(args)?;
309 let src = fs::read_to_string(input)?;
310
311 let mut pipeline = make_pipeline(args.mode, "_u_");
312 pipeline.set_run_semantic_analysis(false);
313 pipeline.set_artifact_stem(Some(source_stem(input, "module")));
314 pipeline.set_current_source_path(Some(input.to_owned()));
315
316 let result = pipeline
317 .compile(&src)
318 .map_err(|e| CliError::Compile(e.to_string()))?;
319 let (_, tokens) = pipeline.compile_ir_to_assembly_with_tokens(&result.ir_program);
320 let assembled = pipeline
321 .assemble(&tokens)
322 .map_err(|e| CliError::Assemble(e.to_string()))?;
323
324 if args.emit_object {
325 let object_name = Path::new(input)
326 .file_name()
327 .and_then(|n| n.to_str())
328 .unwrap_or("module.o");
329 let object_bytes = assembled.to_object(object_name);
330 let output_path = args.output.as_deref().ok_or_else(|| {
331 CliError::Usage("--emit-o requires --output <path> to write the object file".to_owned())
332 })?;
333 fs::write(output_path, object_bytes)?;
334 } else {
335 let asm_text = pipeline.compile_ir_to_assembly(&result.ir_program);
336 write_or_print(args.output.as_deref(), &asm_text)?;

Callers 1

run_cliFunction · 0.85

Calls 12

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

Tested by

no test coverage detected