mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 21:39:07 +00:00
Remove LambdaName::from_non_multimorphic
This commit is contained in:
parent
9714376b64
commit
1903ce4db9
3 changed files with 16 additions and 38 deletions
|
@ -343,7 +343,7 @@ impl<'a> CodeGenHelp<'a> {
|
||||||
};
|
};
|
||||||
|
|
||||||
self.specializations[spec_index].proc = Some(Proc {
|
self.specializations[spec_index].proc = Some(Proc {
|
||||||
name: LambdaName::from_non_multimorphic(proc_symbol),
|
name: LambdaName::only_receiver(proc_symbol),
|
||||||
args,
|
args,
|
||||||
body,
|
body,
|
||||||
closure_data_layout: None,
|
closure_data_layout: None,
|
||||||
|
|
|
@ -2847,7 +2847,7 @@ fn generate_runtime_error_function<'a>(
|
||||||
};
|
};
|
||||||
|
|
||||||
Proc {
|
Proc {
|
||||||
name: LambdaName::from_non_multimorphic(name),
|
name: LambdaName::only_receiver(name),
|
||||||
args,
|
args,
|
||||||
body: runtime_error,
|
body: runtime_error,
|
||||||
closure_data_layout: None,
|
closure_data_layout: None,
|
||||||
|
@ -2949,7 +2949,7 @@ fn specialize_external<'a>(
|
||||||
);
|
);
|
||||||
|
|
||||||
let proc = Proc {
|
let proc = Proc {
|
||||||
name: LambdaName::from_non_multimorphic(name),
|
name: LambdaName::only_receiver(name),
|
||||||
args: proc_arguments.into_bump_slice(),
|
args: proc_arguments.into_bump_slice(),
|
||||||
body,
|
body,
|
||||||
closure_data_layout: None,
|
closure_data_layout: None,
|
||||||
|
@ -3611,8 +3611,7 @@ fn specialize_naked_symbol<'a>(
|
||||||
opt_fn_var,
|
opt_fn_var,
|
||||||
symbol,
|
symbol,
|
||||||
result,
|
result,
|
||||||
// The function symbol is the only receiver, so not multimorphic
|
LambdaName::only_receiver(original),
|
||||||
LambdaName::from_non_multimorphic(original),
|
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4033,9 +4032,7 @@ pub fn with_hole<'a>(
|
||||||
Some(variable),
|
Some(variable),
|
||||||
symbol,
|
symbol,
|
||||||
stmt,
|
stmt,
|
||||||
// If it's a known function (and not an expression) there can only be
|
LambdaName::only_receiver(symbol),
|
||||||
// one receiver, so not multimorphic
|
|
||||||
LambdaName::from_non_multimorphic(symbol),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
Field::Field(field) => {
|
Field::Field(field) => {
|
||||||
|
@ -4434,8 +4431,7 @@ pub fn with_hole<'a>(
|
||||||
|
|
||||||
match procs.insert_anonymous(
|
match procs.insert_anonymous(
|
||||||
env,
|
env,
|
||||||
// Accessors never capture so they can't be multimorphic
|
LambdaName::only_receiver(name),
|
||||||
LambdaName::from_non_multimorphic(name),
|
|
||||||
function_type,
|
function_type,
|
||||||
arguments,
|
arguments,
|
||||||
*loc_body,
|
*loc_body,
|
||||||
|
@ -4636,9 +4632,9 @@ pub fn with_hole<'a>(
|
||||||
specialized_structure_sym,
|
specialized_structure_sym,
|
||||||
stmt,
|
stmt,
|
||||||
// This is only hit if somehow this field is an alias
|
// This is only hit if somehow this field is an alias
|
||||||
// to an ability member, but ability members can't capture, so
|
// to an ability member, and ability members specialize to
|
||||||
// it must be necessary non-multimorphic
|
// exactly one receiver
|
||||||
LambdaName::from_non_multimorphic(structure),
|
LambdaName::only_receiver(structure),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4743,9 +4739,7 @@ pub fn with_hole<'a>(
|
||||||
env,
|
env,
|
||||||
procs,
|
procs,
|
||||||
fn_var,
|
fn_var,
|
||||||
// THEORY: calls to a known name can never be multimorphic, because they
|
LambdaName::only_receiver(proc_name),
|
||||||
// only have one receiver
|
|
||||||
LambdaName::from_non_multimorphic(proc_name),
|
|
||||||
loc_args,
|
loc_args,
|
||||||
layout_cache,
|
layout_cache,
|
||||||
assigned,
|
assigned,
|
||||||
|
@ -4760,8 +4754,7 @@ pub fn with_hole<'a>(
|
||||||
env,
|
env,
|
||||||
procs,
|
procs,
|
||||||
fn_var,
|
fn_var,
|
||||||
// Ability members never capture, can't be multimorphic
|
LambdaName::only_receiver(specialization_proc_name),
|
||||||
LambdaName::from_non_multimorphic(specialization_proc_name),
|
|
||||||
loc_args,
|
loc_args,
|
||||||
layout_cache,
|
layout_cache,
|
||||||
assigned,
|
assigned,
|
||||||
|
@ -4899,7 +4892,7 @@ pub fn with_hole<'a>(
|
||||||
let resolved_proc = match resolved_proc {
|
let resolved_proc = match resolved_proc {
|
||||||
Resolved::Specialization(symbol) => {
|
Resolved::Specialization(symbol) => {
|
||||||
// Ability members never capture, they cannot be multimorphic
|
// Ability members never capture, they cannot be multimorphic
|
||||||
LambdaName::from_non_multimorphic(symbol)
|
LambdaName::only_receiver(symbol)
|
||||||
}
|
}
|
||||||
Resolved::NeedsGenerated => {
|
Resolved::NeedsGenerated => {
|
||||||
todo_abilities!("Generate impls for structural types")
|
todo_abilities!("Generate impls for structural types")
|
||||||
|
@ -5696,7 +5689,7 @@ fn tag_union_to_function<'a>(
|
||||||
});
|
});
|
||||||
|
|
||||||
// Lambda does not capture anything, can't be multimorphic
|
// Lambda does not capture anything, can't be multimorphic
|
||||||
let lambda_name = LambdaName::from_non_multimorphic(proc_symbol);
|
let lambda_name = LambdaName::only_receiver(proc_symbol);
|
||||||
|
|
||||||
let inserted = procs.insert_anonymous(
|
let inserted = procs.insert_anonymous(
|
||||||
env,
|
env,
|
||||||
|
@ -7191,12 +7184,7 @@ where
|
||||||
// specialized, and wrap the original in a function pointer.
|
// specialized, and wrap the original in a function pointer.
|
||||||
let mut result = result;
|
let mut result = result;
|
||||||
for (_, (variable, left)) in needed_specializations_of_left {
|
for (_, (variable, left)) in needed_specializations_of_left {
|
||||||
add_needed_external(
|
add_needed_external(procs, env, variable, LambdaName::thunk(right));
|
||||||
procs,
|
|
||||||
env,
|
|
||||||
variable,
|
|
||||||
LambdaName::from_non_multimorphic(right),
|
|
||||||
);
|
|
||||||
|
|
||||||
let res_layout =
|
let res_layout =
|
||||||
layout_cache.from_var(env.arena, variable, env.subs, env.multimorphic_names);
|
layout_cache.from_var(env.arena, variable, env.subs, env.multimorphic_names);
|
||||||
|
@ -7208,12 +7196,7 @@ where
|
||||||
} else if env.is_imported_symbol(right) {
|
} else if env.is_imported_symbol(right) {
|
||||||
// if this is an imported symbol, then we must make sure it is
|
// if this is an imported symbol, then we must make sure it is
|
||||||
// specialized, and wrap the original in a function pointer.
|
// specialized, and wrap the original in a function pointer.
|
||||||
add_needed_external(
|
add_needed_external(procs, env, variable, LambdaName::only_receiver(right));
|
||||||
procs,
|
|
||||||
env,
|
|
||||||
variable,
|
|
||||||
LambdaName::from_non_multimorphic(right),
|
|
||||||
);
|
|
||||||
|
|
||||||
// then we must construct its closure; since imported symbols have no closure, we use the empty struct
|
// then we must construct its closure; since imported symbols have no closure, we use the empty struct
|
||||||
let_empty_struct(left, env.arena.alloc(result))
|
let_empty_struct(left, env.arena.alloc(result))
|
||||||
|
|
|
@ -915,11 +915,6 @@ impl LambdaName {
|
||||||
matches!(self.0, LambdaNameInner::Multimorphic { .. })
|
matches!(self.0, LambdaNameInner::Multimorphic { .. })
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline(always)]
|
|
||||||
pub fn from_non_multimorphic(name: Symbol) -> Self {
|
|
||||||
Self(LambdaNameInner::Name(name))
|
|
||||||
}
|
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn thunk(name: Symbol) -> Self {
|
pub fn thunk(name: Symbol) -> Self {
|
||||||
Self(LambdaNameInner::Name(name))
|
Self(LambdaNameInner::Name(name))
|
||||||
|
@ -3436,7 +3431,7 @@ mod test {
|
||||||
#[test]
|
#[test]
|
||||||
fn width_and_alignment_union_empty_struct() {
|
fn width_and_alignment_union_empty_struct() {
|
||||||
let lambda_set = LambdaSet {
|
let lambda_set = LambdaSet {
|
||||||
set: &[(LambdaName::from_non_multimorphic(Symbol::LIST_MAP), &[])],
|
set: &[(LambdaName::only_receiver(Symbol::LIST_MAP), &[])],
|
||||||
representation: &Layout::UNIT,
|
representation: &Layout::UNIT,
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue