diff --git a/assembler/src/resolver.rs b/assembler/src/resolver.rs index 3ec1891..b93de50 100644 --- a/assembler/src/resolver.rs +++ b/assembler/src/resolver.rs @@ -66,7 +66,7 @@ fn generate_symbol_table(nodes: &[Node]) -> Result, Assembl } pub fn resolve_dependencies(mut nodes: Vec) -> Result, AssembleError> { - // first we get a list of imports + // First we get a list of imports. let mut dependencies = Vec::new(); for node in &nodes { if let Opcode::Include = node.opcode() { @@ -81,7 +81,11 @@ pub fn resolve_dependencies(mut nodes: Vec) -> Result, AssembleE } else { unreachable!() }; - let hash = quick_hash(&PathBuf::from(path).canonicalize().unwrap()); + let hash = quick_hash( + &PathBuf::from(path) + .canonicalize() + .expect("ERROR: Invalid import path."), + ); dependencies.push((name, hash)); } diff --git a/emulator/src/emulator/ui/editor.rs b/emulator/src/emulator/ui/editor.rs index b08bd14..d06c758 100644 --- a/emulator/src/emulator/ui/editor.rs +++ b/emulator/src/emulator/ui/editor.rs @@ -146,7 +146,7 @@ impl Editor { } if let Some(path) = FileDialog::new() - .add_filter("damn simple files", &["dsa", "dsb", "dsc", "dsd"]) + .add_filter("Assembly Files or Binaries", &["dsa", "dsb"]) .add_filter("all", &["*"]) .set_directory(&work_dir) .save_file() @@ -169,17 +169,22 @@ impl Editor { }); if let Some(path) = FileDialog::new() - .add_filter("damn simple files", &["dsa", "dsb", "dsc", "dsd"]) + .add_filter("Assembly Files or Binaries", &["dsa", "dsb"]) .add_filter("all", &["*"]) .set_directory(&work_dir) .pick_file() { if let Ok(contents) = std::fs::read_to_string(&path) { - self.path = Some(path); + self.path = Some(path.clone()); self.text.clone_from(&contents); self.buffer = contents; self.unsaved = false; } + + std::env::set_current_dir( + path.parent().expect("A file should be in a directory!"), + ) + .expect("ERROR: Failed to set current working directory."); } } diff --git a/resources/dsa/test.dsa b/resources/dsa/test.dsa index 26d21dd..8287ed0 100644 --- a/resources/dsa/test.dsa +++ b/resources/dsa/test.dsa @@ -1,5 +1,5 @@ -include print "../resources/dsa/print.dsa" -include fib "../resources/dsa/fib.dsa" +include print "print.dsa" +include fib "fib.dsa" dw stack: 0x10000 db string: "An idiot admires complexity, a genius admires simplicity,