-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Populating methods for all primitive types into a new methods table r…
…eturned by the prelude
- Loading branch information
Showing
4 changed files
with
157 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
use std::{collections::HashMap, sync::Arc}; | ||
|
||
use crate::nir; | ||
|
||
#[derive(Debug, Default)] | ||
pub struct PrimMethods { | ||
pub unit: Methods, | ||
pub bool: Methods, | ||
pub i64: Methods, | ||
pub u8: Methods, | ||
pub list: Methods, | ||
} | ||
|
||
#[derive(Debug, Default)] | ||
pub struct Methods { | ||
methods: HashMap<Arc<str>, nir::DefId>, | ||
} | ||
|
||
impl Methods { | ||
pub fn insert(&mut self, name: Arc<str>, id: nir::DefId) { | ||
debug_assert!(!self.methods.contains_key(&name), | ||
"bug: inserted same method twice"); | ||
self.methods.insert(name, id); | ||
} | ||
|
||
pub fn get(&self, name: &str) -> Option<nir::DefId> { | ||
self.methods.get(name).copied() | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters