mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-25 04:52:32 +00:00
Split out work.rs into its own crate
This commit is contained in:
parent
41ea2bfbc7
commit
4042fd8d52
8 changed files with 78 additions and 4 deletions
10
Cargo.lock
generated
10
Cargo.lock
generated
|
@ -2801,6 +2801,7 @@ dependencies = [
|
|||
"roc_tracing",
|
||||
"roc_types",
|
||||
"roc_unify",
|
||||
"roc_work",
|
||||
"tempfile",
|
||||
"ven_pretty",
|
||||
]
|
||||
|
@ -3216,6 +3217,15 @@ dependencies = [
|
|||
"roc_error_macros",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "roc_work"
|
||||
version = "0.0.1"
|
||||
dependencies = [
|
||||
"roc_collections",
|
||||
"roc_error_macros",
|
||||
"roc_module",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "rustc-demangle"
|
||||
version = "0.1.23"
|
||||
|
|
|
@ -10,6 +10,7 @@ version.workspace = true
|
|||
[dependencies]
|
||||
roc_builtins = { path = "../builtins" }
|
||||
roc_can = { path = "../can" }
|
||||
roc_work = { path = "../work" }
|
||||
roc_checkmate = { path = "../checkmate" }
|
||||
roc_collections = { path = "../collections" }
|
||||
roc_constrain = { path = "../constrain" }
|
||||
|
|
|
@ -81,8 +81,8 @@ use {
|
|||
roc_packaging::https::{PackageMetadata, Problem},
|
||||
};
|
||||
|
||||
pub use crate::work::Phase;
|
||||
use crate::work::{DepCycle, Dependencies};
|
||||
pub use roc_work::Phase;
|
||||
use roc_work::{DepCycle, Dependencies};
|
||||
|
||||
#[cfg(target_family = "wasm")]
|
||||
use crate::wasm_instant::{Duration, Instant};
|
||||
|
@ -150,7 +150,8 @@ fn start_phase<'a>(
|
|||
) -> Vec<BuildTask<'a>> {
|
||||
// we blindly assume all dependencies are met
|
||||
|
||||
use crate::work::PrepareStartPhase::*;
|
||||
use roc_work::PrepareStartPhase::*;
|
||||
|
||||
match state.dependencies.prepare_start_phase(module_id, phase) {
|
||||
Continue => {
|
||||
// fall through
|
||||
|
|
|
@ -8,7 +8,6 @@ pub mod docs;
|
|||
pub mod file;
|
||||
pub mod module;
|
||||
mod module_cache;
|
||||
mod work;
|
||||
|
||||
#[cfg(target_family = "wasm")]
|
||||
mod wasm_instant;
|
||||
|
|
13
crates/compiler/work/Cargo.toml
Normal file
13
crates/compiler/work/Cargo.toml
Normal file
|
@ -0,0 +1,13 @@
|
|||
[package]
|
||||
name = "roc_work"
|
||||
description = "This is used in loading."
|
||||
|
||||
authors.workspace = true
|
||||
edition.workspace = true
|
||||
license.workspace = true
|
||||
version.workspace = true
|
||||
|
||||
[dependencies]
|
||||
roc_collections = { path = "../collections" }
|
||||
roc_module = { path = "../module" }
|
||||
roc_error_macros = { path = "../../error_macros" }
|
3
crates/compiler/work/src/lib.rs
Normal file
3
crates/compiler/work/src/lib.rs
Normal file
|
@ -0,0 +1,3 @@
|
|||
mod work;
|
||||
|
||||
pub use work::*;
|
47
crates/compiler/work/src/worker.rs
Normal file
47
crates/compiler/work/src/worker.rs
Normal file
|
@ -0,0 +1,47 @@
|
|||
use crate::work::Dependencies;
|
||||
|
||||
/// This is a trait so that we can implement both a single-threaded and a multithreaded version.
|
||||
/// We *need* a single-threaded version for wasm, but it's also desirable in tests.
|
||||
///
|
||||
/// The general design here is "mutex granularity" - basically, try to have a mutex around each
|
||||
/// individual piece of global state, and lock it for as little time as possible.
|
||||
pub trait Worker<'global, Event, ModuleId> {
|
||||
fn enqueue_event(&mut self, event: Event);
|
||||
fn with_deps(&mut self, func: impl FnMut(&mut Dependencies<'global, ModuleId>));
|
||||
// fn with_module_names(&mut self, func: impl FnMut(MutMap<ModuleId, PQModuleName<'a>>));
|
||||
|
||||
// /// Phases
|
||||
// fn with_headers(&mut self, func: impl FnMut(MutMap<ModuleId, ModuleHeader<'a>>));
|
||||
// fn with_parsed(&mut self, func: impl FnMut(MutMap<ModuleId, ParsedModule<'a>>));
|
||||
// fn with_aliases(&mut self, func: impl FnMut(MutMap<ModuleId, MutMap<Symbol, (bool, Alias)>>));
|
||||
// fn with_pending_abilities(&mut self, func: impl FnMut(MutMap<ModuleId, PendingAbilitiesStore>));
|
||||
// fn with_constrained(&mut self, func: impl FnMut(MutMap<ModuleId, ConstrainedModule>));
|
||||
// fn with_typechecked(&mut self, func: impl FnMut(MutMap<ModuleId, TypeCheckedModule<'a>>));
|
||||
// fn with_checked(&mut self, func: impl FnMut(MutMap<ModuleId, CheckedModule>));
|
||||
// fn with_found_specializations(
|
||||
// &mut self,
|
||||
// func: impl FnMut(MutMap<ModuleId, FoundSpecializationsModule<'a>>),
|
||||
// );
|
||||
// fn with_late_specializations(
|
||||
// &mut self,
|
||||
// func: impl FnMut(MutMap<ModuleId, LateSpecializationsModule<'a>>),
|
||||
// );
|
||||
// fn with_external_specializations_requested(
|
||||
// &mut self,
|
||||
// func: impl FnMut(MutMap<ModuleId, Vec<ExternalSpecializations<'a>>>),
|
||||
// );
|
||||
|
||||
// /// Various information
|
||||
// fn with_imports(&mut self, func: impl FnMut(MutMap<ModuleId, MutSet<ModuleId>>));
|
||||
// fn with_exposes(&mut self, func: impl FnMut(MutMap<ModuleId, Vec<(Symbol, Variable)>>));
|
||||
// fn with_exposed_imports(&mut self, func: impl FnMut(MutMap<ModuleId, MutMap<Symbol, Region>>));
|
||||
// fn with_top_level_thunks(&mut self, func: impl FnMut(MutMap<ModuleId, MutSet<Symbol>>));
|
||||
// fn with_documentation(&mut self, func: impl FnMut(VecMap<ModuleId, ModuleDocumentation>));
|
||||
// fn with_can_problems(
|
||||
// &mut self,
|
||||
// func: impl FnMut(MutMap<ModuleId, Vec<roc_problem::can::Problem>>),
|
||||
// );
|
||||
// fn with_type_problems(&mut self, func: impl FnMut(MutMap<ModuleId, Vec<TypeError>>));
|
||||
|
||||
// fn with_sources(&mut self, func: impl FnMut(MutMap<ModuleId, (PathBuf, &'a str)>));
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue