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

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