emulator: imports work relatively to file being assembled (set cwd)

This commit is contained in:
2025-06-19 16:35:00 +01:00
parent b5ce5e0011
commit 6f834025ed
3 changed files with 16 additions and 7 deletions
+6 -2
View File
@@ -66,7 +66,7 @@ fn generate_symbol_table(nodes: &[Node]) -> Result<HashMap<Symbol, u32>, Assembl
}
pub fn resolve_dependencies(mut nodes: Vec<Node>) -> Result<Vec<Node>, 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<Node>) -> Result<Vec<Node>, 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));
}