Remove scope.get

This commit is contained in:
Ayaz Hafiz 2023-06-09 15:42:45 -05:00
parent bbef63f28f
commit 4d65db22d2
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58
2 changed files with 6 additions and 13 deletions

View file

@ -2736,12 +2736,9 @@ fn load_symbol_and_lambda_set<'a, 'ctx>(
scope: &Scope<'a, 'ctx>,
symbol: &Symbol,
) -> (BasicValueEnum<'ctx>, LambdaSet<'a>) {
match scope
.get(symbol)
.map(|(l, v)| (layout_interner.get_repr(*l), v))
{
Some((LayoutRepr::LambdaSet(lambda_set), ptr)) => (*ptr, lambda_set),
Some((other, ptr)) => panic!("Not a lambda set: {:?}, {:?}", other, ptr),
None => panic!("There was no entry for {:?} in scope {:?}", symbol, scope),
let (ptr, layout) = scope.load_symbol_and_layout(symbol);
match layout_interner.get_repr(layout) {
LayoutRepr::LambdaSet(lambda_set) => (ptr, lambda_set),
other => panic!("Not a lambda set: {:?}, {:?}", other, ptr),
}
}

View file

@ -20,12 +20,8 @@ pub(crate) struct Scope<'a, 'ctx> {
pub(crate) struct JoinPointNotFound;
impl<'a, 'ctx> Scope<'a, 'ctx> {
pub fn get(&self, symbol: &Symbol) -> Option<&(InLayout<'a>, BasicValueEnum<'ctx>)> {
self.symbols.get(symbol)
}
pub fn load_symbol(&self, symbol: &Symbol) -> BasicValueEnum<'ctx> {
match self.get(symbol) {
match self.symbols.get(symbol) {
Some((_, ptr)) => *ptr,
None => panic!(
@ -39,7 +35,7 @@ impl<'a, 'ctx> Scope<'a, 'ctx> {
&self,
symbol: &Symbol,
) -> (BasicValueEnum<'ctx>, InLayout<'a>) {
match self.get(symbol) {
match self.symbols.get(symbol) {
Some((layout, ptr)) => (*ptr, *layout),
None => panic!("There was no entry for {:?} in scope {:?}", symbol, self),
}