refactor & fixed assembler path handling

This commit is contained in:
2025-06-21 04:05:22 +01:00
parent 42c26d4184
commit 528ceddade
17 changed files with 447 additions and 184 deletions
+15 -3
View File
@@ -346,12 +346,24 @@ impl Editor {
// builds the current file
if ui.button("Build").clicked() && !self.unsaved {
if let Some(path) = &self.path {
let instructions = match assemble(path) {
Ok(instructions) => instructions,
Err(error) => {
let mut assembler = CompilerEngine::new();
if let Err(error) = assembler.assemble(path) {
self.error = Some(format!("Failed to assemble: {error:?}"));
return;
}
let instructions = match assembler.result() {
Some(Ok(instructions)) => instructions,
Some(Err(error)) => {
self.error = Some(format!("Failed to assemble: {error:?}"));
return;
}
None => {
self.error = Some(
"Failed to assemble: No result available".to_string(),
);
return;
}
};
self.output = instructions