refactor & fixed assembler path handling
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user