simplify GeneratedInfo

This commit is contained in:
Folkert 2022-04-09 12:23:18 +02:00
parent c93805ea87
commit c9b29c773f
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C

View file

@ -75,19 +75,17 @@ fn validate_generate_with<'a>(
} }
#[derive(Debug)] #[derive(Debug)]
enum GeneratedInfo<'a> { enum GeneratedInfo {
Hosted { Hosted {
effect_symbol: Symbol, effect_symbol: Symbol,
generated_functions: HostedGeneratedFunctions, generated_functions: HostedGeneratedFunctions,
}, },
Builtin { Builtin,
generated_functions: &'a [Symbol],
},
NotSpecial, NotSpecial,
} }
impl<'a> GeneratedInfo<'a> { impl GeneratedInfo {
fn from_header_for( fn from_header_for<'a>(
env: &mut Env, env: &mut Env,
scope: &mut Scope, scope: &mut Scope,
var_store: &mut VarStore, var_store: &mut VarStore,
@ -140,9 +138,10 @@ impl<'a> GeneratedInfo<'a> {
generated_functions, generated_functions,
} }
} }
HeaderFor::Builtin { generates_with } => GeneratedInfo::Builtin { HeaderFor::Builtin { generates_with } => {
generated_functions: generates_with, debug_assert!(generates_with.is_empty());
}, GeneratedInfo::Builtin
}
_ => GeneratedInfo::NotSpecial, _ => GeneratedInfo::NotSpecial,
} }
} }
@ -395,9 +394,7 @@ pub fn canonicalize_module_defs<'a>(
// we just assume they are hosted functions (meant to be provided by the platform) // we just assume they are hosted functions (meant to be provided by the platform)
if has_no_implementation(&def.loc_expr.value) { if has_no_implementation(&def.loc_expr.value) {
match generated_info { match generated_info {
GeneratedInfo::Builtin { GeneratedInfo::Builtin => {
generated_functions: _,
} => {
let symbol = def.pattern_vars.iter().next().unwrap().0; let symbol = def.pattern_vars.iter().next().unwrap().0;
match crate::builtins::builtin_defs_map(*symbol, var_store) { match crate::builtins::builtin_defs_map(*symbol, var_store) {
None => { None => {