mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-03 00:24:34 +00:00
store stdlib in a static
This commit is contained in:
parent
26953c0420
commit
82e4ab67b3
1 changed files with 8 additions and 15 deletions
|
@ -73,6 +73,12 @@ macro_rules! log {
|
||||||
($($arg:tt)*) => (if SHOW_MESSAGE_LOG { println!($($arg)*); } else {})
|
($($arg:tt)*) => (if SHOW_MESSAGE_LOG { println!($($arg)*); } else {})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static mut STDLIB: Option<StdLib> = None;
|
||||||
|
|
||||||
|
fn borrow_stdlib() -> &'static StdLib {
|
||||||
|
unsafe { &mut STDLIB }.get_or_insert_with(standard_stdlib)
|
||||||
|
}
|
||||||
|
|
||||||
/// Struct storing various intermediate stages by their ModuleId
|
/// Struct storing various intermediate stages by their ModuleId
|
||||||
#[derive(Debug, Default)]
|
#[derive(Debug, Default)]
|
||||||
struct ModuleCache<'a> {
|
struct ModuleCache<'a> {
|
||||||
|
@ -246,7 +252,6 @@ fn start_phase<'a>(
|
||||||
var_store,
|
var_store,
|
||||||
imported_modules,
|
imported_modules,
|
||||||
&mut state.exposed_types,
|
&mut state.exposed_types,
|
||||||
state.stdlib,
|
|
||||||
dep_idents,
|
dep_idents,
|
||||||
declarations,
|
declarations,
|
||||||
)
|
)
|
||||||
|
@ -565,7 +570,6 @@ struct State<'a> {
|
||||||
pub root_id: ModuleId,
|
pub root_id: ModuleId,
|
||||||
pub platform_data: Option<PlatformData>,
|
pub platform_data: Option<PlatformData>,
|
||||||
pub goal_phase: Phase,
|
pub goal_phase: Phase,
|
||||||
pub stdlib: &'a StdLib,
|
|
||||||
pub exposed_types: ExposedByModule,
|
pub exposed_types: ExposedByModule,
|
||||||
pub output_path: Option<&'a str>,
|
pub output_path: Option<&'a str>,
|
||||||
pub platform_path: PlatformPath<'a>,
|
pub platform_path: PlatformPath<'a>,
|
||||||
|
@ -605,7 +609,6 @@ impl<'a> State<'a> {
|
||||||
root_id: ModuleId,
|
root_id: ModuleId,
|
||||||
target_info: TargetInfo,
|
target_info: TargetInfo,
|
||||||
goal_phase: Phase,
|
goal_phase: Phase,
|
||||||
stdlib: &'a StdLib,
|
|
||||||
exposed_types: ExposedByModule,
|
exposed_types: ExposedByModule,
|
||||||
arc_modules: Arc<Mutex<PackageModuleIds<'a>>>,
|
arc_modules: Arc<Mutex<PackageModuleIds<'a>>>,
|
||||||
ident_ids_by_module: Arc<Mutex<MutMap<ModuleId, IdentIds>>>,
|
ident_ids_by_module: Arc<Mutex<MutMap<ModuleId, IdentIds>>>,
|
||||||
|
@ -617,7 +620,6 @@ impl<'a> State<'a> {
|
||||||
target_info,
|
target_info,
|
||||||
platform_data: None,
|
platform_data: None,
|
||||||
goal_phase,
|
goal_phase,
|
||||||
stdlib,
|
|
||||||
output_path: None,
|
output_path: None,
|
||||||
platform_path: PlatformPath::NotSpecified,
|
platform_path: PlatformPath::NotSpecified,
|
||||||
module_cache: ModuleCache::default(),
|
module_cache: ModuleCache::default(),
|
||||||
|
@ -1032,7 +1034,7 @@ enum LoadResult<'a> {
|
||||||
fn load<'a>(
|
fn load<'a>(
|
||||||
arena: &'a Bump,
|
arena: &'a Bump,
|
||||||
load_start: LoadStart<'a>,
|
load_start: LoadStart<'a>,
|
||||||
stdlib: &'a StdLib,
|
_stdlib: &'a StdLib,
|
||||||
src_dir: &Path,
|
src_dir: &Path,
|
||||||
exposed_types: ExposedByModule,
|
exposed_types: ExposedByModule,
|
||||||
goal_phase: Phase,
|
goal_phase: Phase,
|
||||||
|
@ -1044,7 +1046,6 @@ fn load<'a>(
|
||||||
load_single_threaded(
|
load_single_threaded(
|
||||||
arena,
|
arena,
|
||||||
load_start,
|
load_start,
|
||||||
stdlib,
|
|
||||||
src_dir,
|
src_dir,
|
||||||
exposed_types,
|
exposed_types,
|
||||||
goal_phase,
|
goal_phase,
|
||||||
|
@ -1054,7 +1055,6 @@ fn load<'a>(
|
||||||
load_multi_threaded(
|
load_multi_threaded(
|
||||||
arena,
|
arena,
|
||||||
load_start,
|
load_start,
|
||||||
stdlib,
|
|
||||||
src_dir,
|
src_dir,
|
||||||
exposed_types,
|
exposed_types,
|
||||||
goal_phase,
|
goal_phase,
|
||||||
|
@ -1068,7 +1068,6 @@ fn load<'a>(
|
||||||
fn load_single_threaded<'a>(
|
fn load_single_threaded<'a>(
|
||||||
arena: &'a Bump,
|
arena: &'a Bump,
|
||||||
load_start: LoadStart<'a>,
|
load_start: LoadStart<'a>,
|
||||||
stdlib: &'a StdLib,
|
|
||||||
src_dir: &Path,
|
src_dir: &Path,
|
||||||
exposed_types: ExposedByModule,
|
exposed_types: ExposedByModule,
|
||||||
goal_phase: Phase,
|
goal_phase: Phase,
|
||||||
|
@ -1091,7 +1090,6 @@ fn load_single_threaded<'a>(
|
||||||
root_id,
|
root_id,
|
||||||
target_info,
|
target_info,
|
||||||
goal_phase,
|
goal_phase,
|
||||||
stdlib,
|
|
||||||
exposed_types,
|
exposed_types,
|
||||||
arc_modules,
|
arc_modules,
|
||||||
ident_ids_by_module,
|
ident_ids_by_module,
|
||||||
|
@ -1244,7 +1242,6 @@ fn state_thread_step<'a>(
|
||||||
fn load_multi_threaded<'a>(
|
fn load_multi_threaded<'a>(
|
||||||
arena: &'a Bump,
|
arena: &'a Bump,
|
||||||
load_start: LoadStart<'a>,
|
load_start: LoadStart<'a>,
|
||||||
stdlib: &'a StdLib,
|
|
||||||
src_dir: &Path,
|
src_dir: &Path,
|
||||||
exposed_types: ExposedByModule,
|
exposed_types: ExposedByModule,
|
||||||
goal_phase: Phase,
|
goal_phase: Phase,
|
||||||
|
@ -1261,7 +1258,6 @@ fn load_multi_threaded<'a>(
|
||||||
root_id,
|
root_id,
|
||||||
target_info,
|
target_info,
|
||||||
goal_phase,
|
goal_phase,
|
||||||
stdlib,
|
|
||||||
exposed_types,
|
exposed_types,
|
||||||
arc_modules,
|
arc_modules,
|
||||||
ident_ids_by_module,
|
ident_ids_by_module,
|
||||||
|
@ -3040,7 +3036,6 @@ impl<'a> BuildTask<'a> {
|
||||||
var_store: VarStore,
|
var_store: VarStore,
|
||||||
imported_modules: MutMap<ModuleId, Region>,
|
imported_modules: MutMap<ModuleId, Region>,
|
||||||
exposed_types: &mut ExposedByModule,
|
exposed_types: &mut ExposedByModule,
|
||||||
stdlib: &StdLib,
|
|
||||||
dep_idents: MutMap<ModuleId, IdentIds>,
|
dep_idents: MutMap<ModuleId, IdentIds>,
|
||||||
declarations: Vec<Declaration>,
|
declarations: Vec<Declaration>,
|
||||||
) -> Self {
|
) -> Self {
|
||||||
|
@ -3091,10 +3086,8 @@ fn run_solve<'a>(
|
||||||
// see if there are imported modules from which nothing is actually used
|
// see if there are imported modules from which nothing is actually used
|
||||||
let mut unused_imports = imported_modules;
|
let mut unused_imports = imported_modules;
|
||||||
|
|
||||||
let stdlib = standard_stdlib();
|
|
||||||
|
|
||||||
let (mut rigid_vars, mut def_types) =
|
let (mut rigid_vars, mut def_types) =
|
||||||
constrain_imports(&stdlib, imported_builtins, &mut var_store);
|
constrain_imports(borrow_stdlib(), imported_builtins, &mut var_store);
|
||||||
|
|
||||||
let constrain_end = SystemTime::now();
|
let constrain_end = SystemTime::now();
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue