mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-02 16:21:11 +00:00
preparations for specializing
This commit is contained in:
parent
03d9a8821b
commit
37e0523557
1 changed files with 24 additions and 11 deletions
|
@ -51,7 +51,12 @@ pub enum Phase {
|
||||||
}
|
}
|
||||||
|
|
||||||
/// NOTE keep up to date manually, from ParseAndGenerateConstraints to the highest phase we support
|
/// NOTE keep up to date manually, from ParseAndGenerateConstraints to the highest phase we support
|
||||||
const PHASES: [Phase; 2] = [Phase::ParseAndGenerateConstraints, Phase::SolveTypes];
|
const PHASES: [Phase; 4] = [
|
||||||
|
Phase::ParseAndGenerateConstraints,
|
||||||
|
Phase::SolveTypes,
|
||||||
|
Phase::FindSpecializations,
|
||||||
|
Phase::MakeSpecializations,
|
||||||
|
];
|
||||||
|
|
||||||
#[derive(Default, Debug)]
|
#[derive(Default, Debug)]
|
||||||
struct Dependencies {
|
struct Dependencies {
|
||||||
|
@ -336,7 +341,7 @@ enum Msg<'a> {
|
||||||
var_store: VarStore,
|
var_store: VarStore,
|
||||||
module_timing: ModuleTiming,
|
module_timing: ModuleTiming,
|
||||||
},
|
},
|
||||||
Solved {
|
SolvedTypes {
|
||||||
src: &'a str,
|
src: &'a str,
|
||||||
module_id: ModuleId,
|
module_id: ModuleId,
|
||||||
ident_ids: IdentIds,
|
ident_ids: IdentIds,
|
||||||
|
@ -345,13 +350,13 @@ enum Msg<'a> {
|
||||||
decls: Vec<Declaration>,
|
decls: Vec<Declaration>,
|
||||||
module_timing: ModuleTiming,
|
module_timing: ModuleTiming,
|
||||||
},
|
},
|
||||||
Finished {
|
FinishedAllTypeChecking {
|
||||||
solved_subs: Solved<Subs>,
|
solved_subs: Solved<Subs>,
|
||||||
problems: Vec<solve::TypeError>,
|
problems: Vec<solve::TypeError>,
|
||||||
exposed_vars_by_symbol: Vec<(Symbol, Variable)>,
|
exposed_vars_by_symbol: Vec<(Symbol, Variable)>,
|
||||||
src: &'a str,
|
src: &'a str,
|
||||||
},
|
},
|
||||||
PendingSpecializationsDone {
|
FoundSpecializations {
|
||||||
module_id: ModuleId,
|
module_id: ModuleId,
|
||||||
ident_ids: IdentIds,
|
ident_ids: IdentIds,
|
||||||
layout_cache: LayoutCache<'a>,
|
layout_cache: LayoutCache<'a>,
|
||||||
|
@ -360,6 +365,8 @@ enum Msg<'a> {
|
||||||
solved_subs: Solved<Subs>,
|
solved_subs: Solved<Subs>,
|
||||||
finished_info: FinishedInfo<'a>,
|
finished_info: FinishedInfo<'a>,
|
||||||
},
|
},
|
||||||
|
MadeSpecializations {},
|
||||||
|
FinishedAllSpecialization {},
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug)]
|
#[derive(Debug)]
|
||||||
|
@ -789,7 +796,7 @@ pub fn load(
|
||||||
// and processing those messages will in turn queue up more messages.
|
// and processing those messages will in turn queue up more messages.
|
||||||
for msg in msg_rx.iter() {
|
for msg in msg_rx.iter() {
|
||||||
match msg {
|
match msg {
|
||||||
Msg::Finished {
|
Msg::FinishedAllTypeChecking {
|
||||||
solved_subs,
|
solved_subs,
|
||||||
problems,
|
problems,
|
||||||
exposed_vars_by_symbol,
|
exposed_vars_by_symbol,
|
||||||
|
@ -925,7 +932,7 @@ fn update<'a>(
|
||||||
|
|
||||||
Ok(state)
|
Ok(state)
|
||||||
}
|
}
|
||||||
Solved {
|
SolvedTypes {
|
||||||
src,
|
src,
|
||||||
module_id,
|
module_id,
|
||||||
ident_ids,
|
ident_ids,
|
||||||
|
@ -962,7 +969,7 @@ fn update<'a>(
|
||||||
state.timings.insert(module_id, module_timing);
|
state.timings.insert(module_id, module_timing);
|
||||||
|
|
||||||
msg_tx
|
msg_tx
|
||||||
.send(Msg::Finished {
|
.send(Msg::FinishedAllTypeChecking {
|
||||||
solved_subs,
|
solved_subs,
|
||||||
problems: solved_module.problems,
|
problems: solved_module.problems,
|
||||||
exposed_vars_by_symbol: solved_module.exposed_vars_by_symbol,
|
exposed_vars_by_symbol: solved_module.exposed_vars_by_symbol,
|
||||||
|
@ -995,10 +1002,16 @@ fn update<'a>(
|
||||||
|
|
||||||
Ok(state)
|
Ok(state)
|
||||||
}
|
}
|
||||||
PendingSpecializationsDone { .. } => {
|
FoundSpecializations { .. } => {
|
||||||
todo!();
|
todo!();
|
||||||
}
|
}
|
||||||
Msg::Finished { .. } => {
|
MadeSpecializations { .. } => {
|
||||||
|
todo!();
|
||||||
|
}
|
||||||
|
Msg::FinishedAllTypeChecking { .. } => {
|
||||||
|
unreachable!();
|
||||||
|
}
|
||||||
|
Msg::FinishedAllSpecialization { .. } => {
|
||||||
unreachable!();
|
unreachable!();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1414,7 +1427,7 @@ fn run_solve<'a>(
|
||||||
module_timing.solve = solve_end.duration_since(constrain_end).unwrap();
|
module_timing.solve = solve_end.duration_since(constrain_end).unwrap();
|
||||||
|
|
||||||
// Send the subs to the main thread for processing,
|
// Send the subs to the main thread for processing,
|
||||||
Msg::Solved {
|
Msg::SolvedTypes {
|
||||||
src,
|
src,
|
||||||
module_id,
|
module_id,
|
||||||
solved_subs,
|
solved_subs,
|
||||||
|
@ -1638,7 +1651,7 @@ fn build_pending_specializations<'a>(
|
||||||
|
|
||||||
let problems = mono_env.problems.to_vec();
|
let problems = mono_env.problems.to_vec();
|
||||||
|
|
||||||
Msg::PendingSpecializationsDone {
|
Msg::FoundSpecializations {
|
||||||
module_id: home,
|
module_id: home,
|
||||||
solved_subs: roc_types::solved_types::Solved(subs),
|
solved_subs: roc_types::solved_types::Solved(subs),
|
||||||
ident_ids,
|
ident_ids,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue