mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-01 15:51:12 +00:00
Extract load_deps from load
This commit is contained in:
parent
6dd6afbeac
commit
167d7eb719
1 changed files with 29 additions and 13 deletions
|
@ -161,25 +161,14 @@ pub async fn load<'a>(
|
||||||
stdlib: &StdLib,
|
stdlib: &StdLib,
|
||||||
src_dir: PathBuf,
|
src_dir: PathBuf,
|
||||||
filename: PathBuf,
|
filename: PathBuf,
|
||||||
mut exposed_types: SubsByModule,
|
exposed_types: SubsByModule,
|
||||||
) -> Result<LoadedModule, LoadingProblem> {
|
) -> Result<LoadedModule, LoadingProblem> {
|
||||||
use self::MaybeShared::*;
|
use self::MaybeShared::*;
|
||||||
|
|
||||||
let mut type_problems = Vec::new();
|
let (msg_tx, msg_rx): (MsgSender, MsgReceiver) = mpsc::channel(1024);
|
||||||
let mut can_problems = Vec::new();
|
|
||||||
let env = Env {
|
|
||||||
src_dir: src_dir.clone(),
|
|
||||||
};
|
|
||||||
|
|
||||||
let (msg_tx, mut msg_rx): (MsgSender, MsgReceiver) = mpsc::channel(1024);
|
|
||||||
let mut module_ids = ModuleIds::default();
|
let mut module_ids = ModuleIds::default();
|
||||||
let mut root_exposed_ident_ids: IdentIdsByModule = IdentIds::exposed_builtins(0);
|
let mut root_exposed_ident_ids: IdentIdsByModule = IdentIds::exposed_builtins(0);
|
||||||
|
|
||||||
// This is the "final" list of IdentIds, after canonicalization and constraint gen
|
|
||||||
// have completed for a given module.
|
|
||||||
let mut constrained_ident_ids = IdentIds::exposed_builtins(0);
|
|
||||||
let mut headers_parsed = MutSet::default();
|
|
||||||
|
|
||||||
// Load the root module synchronously; we can't proceed until we have its id.
|
// Load the root module synchronously; we can't proceed until we have its id.
|
||||||
let root_id = load_filename(
|
let root_id = load_filename(
|
||||||
filename,
|
filename,
|
||||||
|
@ -187,8 +176,35 @@ pub async fn load<'a>(
|
||||||
Unique(&mut module_ids, &mut root_exposed_ident_ids),
|
Unique(&mut module_ids, &mut root_exposed_ident_ids),
|
||||||
)?;
|
)?;
|
||||||
|
|
||||||
|
load_deps(root_id, msg_tx, msg_rx, stdlib, src_dir, module_ids, root_exposed_ident_ids, exposed_types).await
|
||||||
|
}
|
||||||
|
|
||||||
|
async fn load_deps<'a>(
|
||||||
|
root_id: ModuleId,
|
||||||
|
msg_tx: MsgSender,
|
||||||
|
mut msg_rx: MsgReceiver,
|
||||||
|
stdlib: &StdLib,
|
||||||
|
src_dir: PathBuf,
|
||||||
|
module_ids: ModuleIds,
|
||||||
|
root_exposed_ident_ids: IdentIdsByModule,
|
||||||
|
mut exposed_types: SubsByModule,
|
||||||
|
) -> Result<LoadedModule, LoadingProblem> {
|
||||||
|
use self::MaybeShared::*;
|
||||||
|
|
||||||
|
let mut type_problems = Vec::new();
|
||||||
|
let mut can_problems = Vec::new();
|
||||||
|
let mut headers_parsed = MutSet::default();
|
||||||
|
|
||||||
headers_parsed.insert(root_id);
|
headers_parsed.insert(root_id);
|
||||||
|
|
||||||
|
let env = Env {
|
||||||
|
src_dir: src_dir.clone(),
|
||||||
|
};
|
||||||
|
|
||||||
|
// This is the "final" list of IdentIds, after canonicalization and constraint gen
|
||||||
|
// have completed for a given module.
|
||||||
|
let mut constrained_ident_ids = IdentIds::exposed_builtins(0);
|
||||||
|
|
||||||
// From now on, these will be used by multiple threads; time to make an Arc<Mutex<_>>!
|
// From now on, these will be used by multiple threads; time to make an Arc<Mutex<_>>!
|
||||||
let arc_modules = Arc::new(Mutex::new(module_ids));
|
let arc_modules = Arc::new(Mutex::new(module_ids));
|
||||||
let ident_ids_by_module: Arc<Mutex<IdentIdsByModule>> =
|
let ident_ids_by_module: Arc<Mutex<IdentIdsByModule>> =
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue