[fine] Multi-module compilation
It's a little bit complicated, loading a module is a two-step dance but here's how it's done. Probably some surface-area refactoring needs to happen so that we do the right thing.
This commit is contained in:
parent
ab477cd783
commit
a3d4c24f11
8 changed files with 506 additions and 274 deletions
|
|
@ -116,6 +116,12 @@ impl From<u64> for ModuleId {
|
|||
}
|
||||
}
|
||||
|
||||
impl fmt::Display for ModuleId {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
write!(f, "#{}", self.0)
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub struct ImportRecord {
|
||||
pub name: String,
|
||||
|
|
@ -762,6 +768,12 @@ impl Semantics {
|
|||
self.import_map.set(imports).expect("imports already set");
|
||||
}
|
||||
|
||||
pub fn import_ids(&self) -> Vec<ModuleId> {
|
||||
// TODO: Pull from by_name when we go global
|
||||
let import_map = self.import_map.get().unwrap();
|
||||
import_map.by_id.keys().map(|id| *id).collect()
|
||||
}
|
||||
|
||||
pub fn import_by_id(&self, mid: ModuleId) -> Option<Rc<Semantics>> {
|
||||
// TODO: ACTUALLY THIS IS WRONG, WE NEED THE GLOBAL MAP HERE, NOT THE LOCAL ONE.
|
||||
let import_map = self.import_map.get()?;
|
||||
|
|
@ -815,6 +827,10 @@ impl Semantics {
|
|||
}
|
||||
}
|
||||
|
||||
pub fn mid(&self) -> ModuleId {
|
||||
self.mid
|
||||
}
|
||||
|
||||
fn report_error_span<T>(&self, start_pos: usize, end_pos: usize, error: T) -> Rc<Error>
|
||||
where
|
||||
T: ToString,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue