diff options
| author | Thomas Voss <mail@thomasvoss.com> | 2026-03-15 23:07:01 +0100 |
|---|---|---|
| committer | Thomas Voss <mail@thomasvoss.com> | 2026-03-15 23:07:25 +0100 |
| commit | bb4d0a8b49aed021fe8f13893d2e651923368c23 (patch) | |
| tree | c80e4c63581cac95f5998daa11b8e477c1f07a28 /oryxc/src/depmap.rs | |
| parent | 72b874a081fed4788378e16b0bfb3a0ed7e5725f (diff) | |
New DepMap type
Diffstat (limited to 'oryxc/src/depmap.rs')
| -rw-r--r-- | oryxc/src/depmap.rs | 31 |
1 files changed, 31 insertions, 0 deletions
diff --git a/oryxc/src/depmap.rs b/oryxc/src/depmap.rs new file mode 100644 index 0000000..60e358e --- /dev/null +++ b/oryxc/src/depmap.rs @@ -0,0 +1,31 @@ +use boxcar; +use dashmap::DashMap; + +use crate::compiler::Job; +use crate::prelude::*; + +pub struct DepMap(DashMap<Dependency, boxcar::Vec<Job>>); + +#[derive(Eq, Hash, PartialEq)] +pub enum Dependency { + Symbol(SymbolId), +} + +impl DepMap { + pub fn with_capacity(n: usize) -> Self { + return Self(DashMap::with_capacity(n)); + } + + pub fn add(&self, d: Dependency, j: Job) { + self.0 + .entry(d) + .and_modify(|v| { + v.push(j.clone()); + }) + .or_insert_with(|| boxcar::vec![j]); + } + + pub fn pop(&self, d: Dependency) -> Option<boxcar::Vec<Job>> { + return self.0.remove(&d).map(|(_, v)| v); + } +} |