diff --git a/compiler/load/src/file.rs b/compiler/load/src/file.rs index b0b69907af..43ff46c454 100644 --- a/compiler/load/src/file.rs +++ b/compiler/load/src/file.rs @@ -91,6 +91,76 @@ enum Msg<'a> { }, } +#[derive(Debug)] +struct State<'a> { + pub root_id: ModuleId, + pub src_dir: PathBuf, + pub exposed_types: SubsByModule, + + pub can_problems: Vec, + pub headers_parsed: MutSet, + pub type_problems: Vec, + + /// This is the "final" list of IdentIds, after canonicalization and constraint gen + /// have completed for a given module. + pub constrained_ident_ids: MutMap, + + /// From now on, these will be used by multiple threads; time to make an Arc>! + pub arc_modules: Arc>, + + pub ident_ids_by_module: Arc>, + + /// All the dependent modules we've already begun loading - + /// meaning we should never kick off another load_module on them! + pub loading_started: MutSet, + + pub declarations_by_id: MutMap>, + + pub exposed_symbols_by_module: MutMap>, + + /// Modules which are waiting for certain headers to be parsed + pub waiting_for_headers: MutMap>, + + // When the key ModuleId gets solved, iterate through each of the given modules + // a,d remove that ModuleId from the appropriate waiting_for_headers entry. + // If the relevant module's waiting_for_headers entry is now empty, canonicalize the module. + pub header_listeners: MutMap>, + + pub unparsed_modules: MutMap>, + + // Modules which are waiting for certain deps to be solved + pub waiting_for_solve: MutMap>, + + // When the key ModuleId gets solved, iterate through each of the given modules + // and remove that ModuleId from the appropriate waiting_for_solve entry. + // If the relevant module's waiting_for_solve entry is now empty, solve the module. + pub solve_listeners: MutMap>, + + #[allow(clippy::type_complexity)] + pub unsolved_modules: + MutMap, MutSet, Constraint, VarStore)>, +} + +#[derive(Debug)] +enum BuildTask<'a, 'b> { + LoadModule { + module_name: ModuleName, + module_ids: SharedModules<'a, 'b>, + }, + ParseAndConstrain { + header: ModuleHeader<'a>, + mode: Mode, + module_ids: ModuleIds, + dep_idents: IdentIdsByModule, + exposed_symbols: MutSet, + }, +} + +enum WorkerMsg { + Shutdown, + TaskAdded, +} + #[derive(Debug)] pub enum LoadingProblem { FileProblem { @@ -216,76 +286,6 @@ fn enqueue_task<'a, 'b>( Ok(()) } -#[derive(Debug)] -struct State<'a> { - pub root_id: ModuleId, - pub src_dir: PathBuf, - pub exposed_types: SubsByModule, - - pub can_problems: Vec, - pub headers_parsed: MutSet, - pub type_problems: Vec, - - /// This is the "final" list of IdentIds, after canonicalization and constraint gen - /// have completed for a given module. - pub constrained_ident_ids: MutMap, - - /// From now on, these will be used by multiple threads; time to make an Arc>! - pub arc_modules: Arc>, - - pub ident_ids_by_module: Arc>, - - /// All the dependent modules we've already begun loading - - /// meaning we should never kick off another load_module on them! - pub loading_started: MutSet, - - pub declarations_by_id: MutMap>, - - pub exposed_symbols_by_module: MutMap>, - - /// Modules which are waiting for certain headers to be parsed - pub waiting_for_headers: MutMap>, - - // When the key ModuleId gets solved, iterate through each of the given modules - // a,d remove that ModuleId from the appropriate waiting_for_headers entry. - // If the relevant module's waiting_for_headers entry is now empty, canonicalize the module. - pub header_listeners: MutMap>, - - pub unparsed_modules: MutMap>, - - // Modules which are waiting for certain deps to be solved - pub waiting_for_solve: MutMap>, - - // When the key ModuleId gets solved, iterate through each of the given modules - // and remove that ModuleId from the appropriate waiting_for_solve entry. - // If the relevant module's waiting_for_solve entry is now empty, solve the module. - pub solve_listeners: MutMap>, - - #[allow(clippy::type_complexity)] - pub unsolved_modules: - MutMap, MutSet, Constraint, VarStore)>, -} - -#[derive(Debug)] -enum BuildTask<'a, 'b> { - LoadModule { - module_name: ModuleName, - module_ids: SharedModules<'a, 'b>, - }, - ParseAndConstrain { - header: ModuleHeader<'a>, - mode: Mode, - module_ids: ModuleIds, - dep_idents: IdentIdsByModule, - exposed_symbols: MutSet, - }, -} - -enum WorkerMsg { - Shutdown, - TaskAdded, -} - fn load_deps<'a>( arena: &'a Bump, root_id: ModuleId,