- updated common with new compiler/builder trait to provide a common
interface for build tools - updated editor and build tooling to use new system
This commit is contained in:
@@ -5,7 +5,9 @@ use std::{
|
||||
path::{Path, PathBuf},
|
||||
};
|
||||
|
||||
use common::build::Builder;
|
||||
use common::prelude::Instruction;
|
||||
use compiler::Compiler;
|
||||
use egui::{Align, Context, Key, Layout, Ui};
|
||||
|
||||
use dsa_editor::{CodeEditor, ColorTheme, Syntax};
|
||||
@@ -423,45 +425,39 @@ impl Editor {
|
||||
if let Some(path) = &self.path {
|
||||
match path.extension().and_then(|ext| ext.to_str()) {
|
||||
Some("dsa") => {
|
||||
let mut compiler = CompilerEngine::new();
|
||||
compiler.start_compilation(path);
|
||||
let mut assembler = Assembler::new(path);
|
||||
assembler.start();
|
||||
|
||||
// Or block until done
|
||||
let instructions = match compiler.wait_for_result() {
|
||||
self.output = match assembler.output() {
|
||||
Ok(instructions) => instructions,
|
||||
Err(e) => {
|
||||
self.error = Some(e.to_string());
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
self.output = instructions
|
||||
.iter()
|
||||
.flat_map(|i| i.encode().to_be_bytes().to_vec())
|
||||
.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 dsa_path = Path::new(path).with_extension("dsa");
|
||||
let mut compiler = Compiler::new(path);
|
||||
compiler.start();
|
||||
|
||||
if let Err(e) = compiler.write_result(&dsa_path) {
|
||||
self.error = Some(e.to_string());
|
||||
return;
|
||||
}
|
||||
|
||||
let mut compiler = CompilerEngine::new();
|
||||
compiler.start_compilation(&output_path);
|
||||
let mut assembler = Assembler::new(&dsa_path);
|
||||
compiler.start();
|
||||
|
||||
// Or block until done
|
||||
let instructions = match compiler.wait_for_result() {
|
||||
self.output = match assembler.output() {
|
||||
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") => {
|
||||
if let Ok(bytes) = fs::read(path) {
|
||||
|
||||
Reference in New Issue
Block a user