mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 13:29:12 +00:00
Move src_dir into LoadStart
This commit is contained in:
parent
1364f1e518
commit
a6d99aa357
9 changed files with 38 additions and 41 deletions
|
@ -1067,7 +1067,7 @@ pub fn load_and_typecheck_str<'a>(
|
|||
arena: &'a Bump,
|
||||
filename: PathBuf,
|
||||
source: &'a str,
|
||||
src_dir: &Path,
|
||||
src_dir: PathBuf,
|
||||
exposed_types: ExposedByModule,
|
||||
target_info: TargetInfo,
|
||||
render: RenderTarget,
|
||||
|
@ -1075,7 +1075,7 @@ pub fn load_and_typecheck_str<'a>(
|
|||
) -> Result<LoadedModule, LoadingProblem<'a>> {
|
||||
use LoadResult::*;
|
||||
|
||||
let load_start = LoadStart::from_str(arena, filename, source)?;
|
||||
let load_start = LoadStart::from_str(arena, filename, source, src_dir)?;
|
||||
|
||||
// this function is used specifically in the case
|
||||
// where we want to regenerate the cached data
|
||||
|
@ -1084,7 +1084,6 @@ pub fn load_and_typecheck_str<'a>(
|
|||
match load(
|
||||
arena,
|
||||
load_start,
|
||||
src_dir,
|
||||
exposed_types,
|
||||
Phase::SolveTypes,
|
||||
target_info,
|
||||
|
@ -1108,11 +1107,13 @@ pub struct LoadStart<'a> {
|
|||
ident_ids_by_module: SharedIdentIdsByModule,
|
||||
root_id: ModuleId,
|
||||
root_msg: Msg<'a>,
|
||||
src_dir: PathBuf,
|
||||
}
|
||||
|
||||
impl<'a> LoadStart<'a> {
|
||||
pub fn from_path(
|
||||
arena: &'a Bump,
|
||||
mut src_dir: PathBuf,
|
||||
filename: PathBuf,
|
||||
render: RenderTarget,
|
||||
) -> Result<Self, LoadingProblem<'a>> {
|
||||
|
@ -1166,6 +1167,7 @@ impl<'a> LoadStart<'a> {
|
|||
Ok(LoadStart {
|
||||
arc_modules,
|
||||
ident_ids_by_module,
|
||||
src_dir,
|
||||
root_id,
|
||||
root_msg,
|
||||
})
|
||||
|
@ -1175,6 +1177,7 @@ impl<'a> LoadStart<'a> {
|
|||
arena: &'a Bump,
|
||||
filename: PathBuf,
|
||||
src: &'a str,
|
||||
src_dir: PathBuf,
|
||||
) -> Result<Self, LoadingProblem<'a>> {
|
||||
let arc_modules = Arc::new(Mutex::new(PackageModuleIds::default()));
|
||||
let root_exposed_ident_ids = IdentIds::exposed_builtins(0);
|
||||
|
@ -1196,6 +1199,7 @@ impl<'a> LoadStart<'a> {
|
|||
|
||||
Ok(LoadStart {
|
||||
arc_modules,
|
||||
src_dir,
|
||||
ident_ids_by_module,
|
||||
root_id,
|
||||
root_msg,
|
||||
|
@ -1269,7 +1273,6 @@ pub enum Threading {
|
|||
pub fn load<'a>(
|
||||
arena: &'a Bump,
|
||||
load_start: LoadStart<'a>,
|
||||
src_dir: &Path,
|
||||
exposed_types: ExposedByModule,
|
||||
goal_phase: Phase,
|
||||
target_info: TargetInfo,
|
||||
|
@ -1305,7 +1308,6 @@ pub fn load<'a>(
|
|||
Threads::Single => load_single_threaded(
|
||||
arena,
|
||||
load_start,
|
||||
src_dir,
|
||||
exposed_types,
|
||||
goal_phase,
|
||||
target_info,
|
||||
|
@ -1315,7 +1317,6 @@ pub fn load<'a>(
|
|||
Threads::Many(threads) => load_multi_threaded(
|
||||
arena,
|
||||
load_start,
|
||||
src_dir,
|
||||
exposed_types,
|
||||
goal_phase,
|
||||
target_info,
|
||||
|
@ -1331,7 +1332,6 @@ pub fn load<'a>(
|
|||
pub fn load_single_threaded<'a>(
|
||||
arena: &'a Bump,
|
||||
load_start: LoadStart<'a>,
|
||||
src_dir: &Path,
|
||||
exposed_types: ExposedByModule,
|
||||
goal_phase: Phase,
|
||||
target_info: TargetInfo,
|
||||
|
@ -1343,6 +1343,7 @@ pub fn load_single_threaded<'a>(
|
|||
ident_ids_by_module,
|
||||
root_id,
|
||||
root_msg,
|
||||
src_dir,
|
||||
..
|
||||
} = load_start;
|
||||
|
||||
|
@ -1394,7 +1395,7 @@ pub fn load_single_threaded<'a>(
|
|||
stealers,
|
||||
&worker_msg_rx,
|
||||
&msg_tx,
|
||||
src_dir,
|
||||
&src_dir,
|
||||
target_info,
|
||||
);
|
||||
|
||||
|
@ -1532,7 +1533,6 @@ fn state_thread_step<'a>(
|
|||
fn load_multi_threaded<'a>(
|
||||
arena: &'a Bump,
|
||||
load_start: LoadStart<'a>,
|
||||
src_dir: &Path,
|
||||
exposed_types: ExposedByModule,
|
||||
goal_phase: Phase,
|
||||
target_info: TargetInfo,
|
||||
|
@ -1545,6 +1545,7 @@ fn load_multi_threaded<'a>(
|
|||
ident_ids_by_module,
|
||||
root_id,
|
||||
root_msg,
|
||||
src_dir,
|
||||
..
|
||||
} = load_start;
|
||||
|
||||
|
@ -1622,8 +1623,9 @@ fn load_multi_threaded<'a>(
|
|||
|
||||
// We only want to move a *reference* to the main task queue's
|
||||
// injector in the thread, not the injector itself
|
||||
// (since other threads need to reference it too).
|
||||
// (since other threads need to reference it too). Same with src_dir.
|
||||
let injector = &injector;
|
||||
let src_dir = &src_dir;
|
||||
|
||||
// Record this thread's handle so the main thread can join it later.
|
||||
let res_join_handle = thread_scope
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue