WIP optimization code

This commit is contained in:
2025-12-12 17:23:04 -07:00
parent 3fb04aef3b
commit 0be2e644e4
7 changed files with 889 additions and 15 deletions

View File

@@ -88,9 +88,15 @@ fn run_logic<'a>() -> Result<(), Error<'a>> {
None => BufWriter::new(Box::new(std::io::stdout())),
};
let compiler = Compiler::new(parser, &mut writer, None);
let mut tmp = BufWriter::new(vec![]);
let CompilationResult { errors, .. } = compiler.compile();
let compiler = Compiler::new(parser, &mut tmp, None);
let CompilationResult {
errors,
instructions,
..
} = compiler.compile();
if !errors.is_empty() {
let mut std_error = stderr();
@@ -103,6 +109,12 @@ fn run_logic<'a>() -> Result<(), Error<'a>> {
}
}
let instructions = optimizer::optimize(instructions);
for instruction in instructions {
writer.write_all(format!("{}\n", instruction.instruction).as_bytes())?;
}
writer.flush()?;
Ok(())