mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 13:29:12 +00:00
Get multimorphic lambda captures working
This commit is contained in:
parent
88618c098d
commit
8be230695b
9 changed files with 458 additions and 423 deletions
|
@ -29,12 +29,11 @@ use roc_module::symbol::{
|
|||
IdentIds, IdentIdsByModule, Interns, ModuleId, ModuleIds, PQModuleName, PackageModuleIds,
|
||||
PackageQualified, Symbol,
|
||||
};
|
||||
use roc_mono::fresh_multimorphic_symbol;
|
||||
use roc_mono::ir::{
|
||||
CapturedSymbols, EntryPoint, ExternalSpecializations, PartialProc, Proc, ProcLayout, Procs,
|
||||
ProcsBase, UpdateModeIds,
|
||||
};
|
||||
use roc_mono::layout::{LambdaName, Layout, LayoutCache, LayoutProblem};
|
||||
use roc_mono::layout::{LambdaName, Layout, LayoutCache, LayoutProblem, MultimorphicNames};
|
||||
use roc_parse::ast::{self, Defs, ExtractSpaces, Spaced, StrLiteral, TypeAnnotation};
|
||||
use roc_parse::header::{ExposedName, ImportsEntry, PackageEntry, PlatformHeader, To, TypedIdent};
|
||||
use roc_parse::header::{HeaderFor, ModuleNameEnum, PackageName};
|
||||
|
@ -429,6 +428,7 @@ fn start_phase<'a>(
|
|||
exposed_to_host: state.exposed_to_host.clone(),
|
||||
abilities_store,
|
||||
derived_symbols,
|
||||
multimorphic_names: state.multimorphic_names.clone(),
|
||||
}
|
||||
}
|
||||
Phase::MakeSpecializations => {
|
||||
|
@ -498,6 +498,7 @@ fn start_phase<'a>(
|
|||
module_timing,
|
||||
world_abilities: state.world_abilities.clone_ref(),
|
||||
derived_symbols,
|
||||
multimorphic_names: state.multimorphic_names.clone(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -827,6 +828,8 @@ struct State<'a> {
|
|||
|
||||
pub render: RenderTarget,
|
||||
|
||||
pub multimorphic_names: MultimorphicNames,
|
||||
|
||||
/// All abilities across all modules.
|
||||
pub world_abilities: WorldAbilities,
|
||||
|
||||
|
@ -877,6 +880,7 @@ impl<'a> State<'a> {
|
|||
layout_caches: std::vec::Vec::with_capacity(number_of_workers),
|
||||
cached_subs: Arc::new(Mutex::new(cached_subs)),
|
||||
render,
|
||||
multimorphic_names: MultimorphicNames::default(),
|
||||
make_specializations_pass: MakeSpecializationsPass::Pass(1),
|
||||
world_abilities: Default::default(),
|
||||
}
|
||||
|
@ -1001,6 +1005,7 @@ enum BuildTask<'a> {
|
|||
exposed_to_host: ExposedToHost,
|
||||
abilities_store: AbilitiesStore,
|
||||
derived_symbols: GlobalDerivedSymbols,
|
||||
multimorphic_names: MultimorphicNames,
|
||||
},
|
||||
MakeSpecializations {
|
||||
module_id: ModuleId,
|
||||
|
@ -1012,6 +1017,7 @@ enum BuildTask<'a> {
|
|||
module_timing: ModuleTiming,
|
||||
world_abilities: WorldAbilities,
|
||||
derived_symbols: GlobalDerivedSymbols,
|
||||
multimorphic_names: MultimorphicNames,
|
||||
},
|
||||
}
|
||||
|
||||
|
@ -4413,6 +4419,7 @@ fn make_specializations<'a>(
|
|||
target_info: TargetInfo,
|
||||
world_abilities: WorldAbilities,
|
||||
derived_symbols: GlobalDerivedSymbols,
|
||||
mut multimorphic_names: MultimorphicNames,
|
||||
) -> Msg<'a> {
|
||||
let make_specializations_start = SystemTime::now();
|
||||
let mut update_mode_ids = UpdateModeIds::new();
|
||||
|
@ -4428,6 +4435,7 @@ fn make_specializations<'a>(
|
|||
call_specialization_counter: 1,
|
||||
abilities: AbilitiesView::World(world_abilities),
|
||||
derived_symbols: &derived_symbols,
|
||||
multimorphic_names: &mut multimorphic_names,
|
||||
};
|
||||
|
||||
let mut procs = Procs::new_in(arena);
|
||||
|
@ -4491,6 +4499,7 @@ fn build_pending_specializations<'a>(
|
|||
exposed_to_host: ExposedToHost, // TODO remove
|
||||
abilities_store: AbilitiesStore,
|
||||
derived_symbols: GlobalDerivedSymbols,
|
||||
mut multimorphic_names: MultimorphicNames,
|
||||
) -> Msg<'a> {
|
||||
let find_specializations_start = SystemTime::now();
|
||||
|
||||
|
@ -4520,6 +4529,7 @@ fn build_pending_specializations<'a>(
|
|||
// do we need a global view.
|
||||
abilities: AbilitiesView::Module(&abilities_store),
|
||||
derived_symbols: &derived_symbols,
|
||||
multimorphic_names: &mut multimorphic_names,
|
||||
};
|
||||
|
||||
// Add modules' decls to Procs
|
||||
|
@ -4550,7 +4560,7 @@ fn build_pending_specializations<'a>(
|
|||
mono_env.arena,
|
||||
expr_var,
|
||||
mono_env.subs,
|
||||
fresh_multimorphic_symbol!(mono_env),
|
||||
mono_env.multimorphic_names,
|
||||
);
|
||||
|
||||
// cannot specialize when e.g. main's type contains type variables
|
||||
|
@ -4614,7 +4624,7 @@ fn build_pending_specializations<'a>(
|
|||
mono_env.arena,
|
||||
expr_var,
|
||||
mono_env.subs,
|
||||
fresh_multimorphic_symbol!(mono_env),
|
||||
mono_env.multimorphic_names,
|
||||
);
|
||||
|
||||
// cannot specialize when e.g. main's type contains type variables
|
||||
|
@ -4696,7 +4706,7 @@ fn build_pending_specializations<'a>(
|
|||
mono_env.arena,
|
||||
expr_var,
|
||||
mono_env.subs,
|
||||
fresh_multimorphic_symbol!(mono_env),
|
||||
mono_env.multimorphic_names,
|
||||
);
|
||||
|
||||
// cannot specialize when e.g. main's type contains type variables
|
||||
|
@ -4760,7 +4770,7 @@ fn build_pending_specializations<'a>(
|
|||
mono_env.arena,
|
||||
expr_var,
|
||||
mono_env.subs,
|
||||
fresh_multimorphic_symbol!(mono_env),
|
||||
mono_env.multimorphic_names,
|
||||
);
|
||||
|
||||
// cannot specialize when e.g. main's type contains type variables
|
||||
|
@ -4914,6 +4924,7 @@ fn run_task<'a>(
|
|||
exposed_to_host,
|
||||
abilities_store,
|
||||
derived_symbols,
|
||||
multimorphic_names,
|
||||
} => Ok(build_pending_specializations(
|
||||
arena,
|
||||
solved_subs,
|
||||
|
@ -4927,6 +4938,7 @@ fn run_task<'a>(
|
|||
exposed_to_host,
|
||||
abilities_store,
|
||||
derived_symbols,
|
||||
multimorphic_names,
|
||||
)),
|
||||
MakeSpecializations {
|
||||
module_id,
|
||||
|
@ -4938,6 +4950,7 @@ fn run_task<'a>(
|
|||
module_timing,
|
||||
world_abilities,
|
||||
derived_symbols,
|
||||
multimorphic_names,
|
||||
} => Ok(make_specializations(
|
||||
arena,
|
||||
module_id,
|
||||
|
@ -4950,6 +4963,7 @@ fn run_task<'a>(
|
|||
target_info,
|
||||
world_abilities,
|
||||
derived_symbols,
|
||||
multimorphic_names,
|
||||
)),
|
||||
}?;
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue