integrated compiler in DSA editor
This commit is contained in:
@@ -16,6 +16,7 @@ required-features = ["config"]
|
|||||||
[dependencies]
|
[dependencies]
|
||||||
common = { path = "../common" }
|
common = { path = "../common" }
|
||||||
assembler = { path = "../assembler" }
|
assembler = { path = "../assembler" }
|
||||||
|
compiler = { path = "../compiler" }
|
||||||
dsa_editor = { path = "../dsa_editor" }
|
dsa_editor = { path = "../dsa_editor" }
|
||||||
egui = "0.31.1"
|
egui = "0.31.1"
|
||||||
dirs = "6.0.0"
|
dirs = "6.0.0"
|
||||||
|
|||||||
@@ -451,6 +451,29 @@ impl Editor {
|
|||||||
.flat_map(|i| i.encode().to_be_bytes().to_vec())
|
.flat_map(|i| i.encode().to_be_bytes().to_vec())
|
||||||
.collect();
|
.collect();
|
||||||
}
|
}
|
||||||
|
Some("dsc") => {
|
||||||
|
let output_path = Path::new(path).with_extension("dsa");
|
||||||
|
if let Err(e) = compiler::compile_file(path, &output_path) {
|
||||||
|
self.error = Some(format!("Compiler error: {}", e));
|
||||||
|
}
|
||||||
|
|
||||||
|
let mut compiler = CompilerEngine::new();
|
||||||
|
compiler.start_compilation(&output_path);
|
||||||
|
|
||||||
|
// Or block until done
|
||||||
|
let instructions = match compiler.wait_for_result() {
|
||||||
|
Ok(instructions) => instructions,
|
||||||
|
Err(e) => {
|
||||||
|
self.error = Some(format!("Assembler error: {}", e));
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
self.output = instructions
|
||||||
|
.iter()
|
||||||
|
.flat_map(|i| i.encode().to_be_bytes().to_vec())
|
||||||
|
.collect();
|
||||||
|
}
|
||||||
Some("dsb") => {
|
Some("dsb") => {
|
||||||
if let Ok(bytes) = fs::read(path) {
|
if let Ok(bytes) = fs::read(path) {
|
||||||
self.output = bytes;
|
self.output = bytes;
|
||||||
|
|||||||
Reference in New Issue
Block a user