mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-03 19:58:18 +00:00
Remove scope.get
This commit is contained in:
parent
bbef63f28f
commit
4d65db22d2
2 changed files with 6 additions and 13 deletions
|
@ -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),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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),
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue