mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 06:14:46 +00:00
hollow out ConstrainableImports
This commit is contained in:
parent
364bc81dc4
commit
20ae9ff1e3
2 changed files with 43 additions and 64 deletions
|
@ -164,8 +164,7 @@ pub fn constrain_imports(
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct ConstrainableImports {
|
pub struct ConstrainableImports {
|
||||||
pub imported_symbols: Vec<Import>,
|
pub imported_builtins: Vec<Import>,
|
||||||
pub imported_aliases: MutMap<Symbol, Alias>,
|
|
||||||
pub unused_imports: MutMap<ModuleId, Region>,
|
pub unused_imports: MutMap<ModuleId, Region>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -182,7 +181,6 @@ pub fn pre_constrain_imports(
|
||||||
stdlib: &StdLib,
|
stdlib: &StdLib,
|
||||||
) -> ConstrainableImports {
|
) -> ConstrainableImports {
|
||||||
let mut imported_symbols = Vec::with_capacity(references.len());
|
let mut imported_symbols = Vec::with_capacity(references.len());
|
||||||
let mut imported_aliases = MutMap::default();
|
|
||||||
let mut unused_imports = imported_modules; // We'll remove these as we encounter them.
|
let mut unused_imports = imported_modules; // We'll remove these as we encounter them.
|
||||||
|
|
||||||
// Translate referenced symbols into constraints. We do this on the main
|
// Translate referenced symbols into constraints. We do this on the main
|
||||||
|
@ -260,8 +258,7 @@ pub fn pre_constrain_imports(
|
||||||
}
|
}
|
||||||
|
|
||||||
ConstrainableImports {
|
ConstrainableImports {
|
||||||
imported_symbols,
|
imported_builtins: imported_symbols,
|
||||||
imported_aliases,
|
|
||||||
unused_imports,
|
unused_imports,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -729,7 +729,7 @@ enum BuildTask<'a> {
|
||||||
Solve {
|
Solve {
|
||||||
module: Module,
|
module: Module,
|
||||||
ident_ids: IdentIds,
|
ident_ids: IdentIds,
|
||||||
imported_symbols: Vec<Import>,
|
imported_builtins: Vec<Import>,
|
||||||
exposed_for_module: ExposedForModule,
|
exposed_for_module: ExposedForModule,
|
||||||
module_timing: ModuleTiming,
|
module_timing: ModuleTiming,
|
||||||
constraints: Constraints,
|
constraints: Constraints,
|
||||||
|
@ -3054,8 +3054,7 @@ impl<'a> BuildTask<'a> {
|
||||||
// to avoid having to lock the map of exposed types, or to clone it
|
// to avoid having to lock the map of exposed types, or to clone it
|
||||||
// (which would be more expensive for the main thread).
|
// (which would be more expensive for the main thread).
|
||||||
let ConstrainableImports {
|
let ConstrainableImports {
|
||||||
imported_symbols,
|
imported_builtins,
|
||||||
imported_aliases: _, // TODO well then... do we even need those?
|
|
||||||
unused_imports,
|
unused_imports,
|
||||||
} = pre_constrain_imports(
|
} = pre_constrain_imports(
|
||||||
home,
|
home,
|
||||||
|
@ -3069,7 +3068,7 @@ impl<'a> BuildTask<'a> {
|
||||||
Self::Solve {
|
Self::Solve {
|
||||||
module,
|
module,
|
||||||
ident_ids,
|
ident_ids,
|
||||||
imported_symbols,
|
imported_builtins,
|
||||||
exposed_for_module,
|
exposed_for_module,
|
||||||
constraints,
|
constraints,
|
||||||
constraint,
|
constraint,
|
||||||
|
@ -3087,7 +3086,7 @@ fn run_solve<'a>(
|
||||||
module: Module,
|
module: Module,
|
||||||
ident_ids: IdentIds,
|
ident_ids: IdentIds,
|
||||||
mut module_timing: ModuleTiming,
|
mut module_timing: ModuleTiming,
|
||||||
imported_symbols: Vec<Import>,
|
imported_builtins: Vec<Import>,
|
||||||
mut exposed_for_module: ExposedForModule,
|
mut exposed_for_module: ExposedForModule,
|
||||||
mut constraints: Constraints,
|
mut constraints: Constraints,
|
||||||
constraint: ConstraintSoa,
|
constraint: ConstraintSoa,
|
||||||
|
@ -3099,21 +3098,7 @@ fn run_solve<'a>(
|
||||||
// We have more constraining work to do now, so we'll add it to our timings.
|
// We have more constraining work to do now, so we'll add it to our timings.
|
||||||
let constrain_start = SystemTime::now();
|
let constrain_start = SystemTime::now();
|
||||||
|
|
||||||
// only retain symbols that are not provided with a storage subs
|
let (mut rigid_vars, mut def_types) = constrain_imports(imported_builtins, &mut var_store);
|
||||||
let mut imported_symbols = imported_symbols;
|
|
||||||
|
|
||||||
const NEW_TYPES: bool = true;
|
|
||||||
|
|
||||||
if NEW_TYPES {
|
|
||||||
imported_symbols.retain(|k| {
|
|
||||||
!exposed_for_module
|
|
||||||
.imported_symbols
|
|
||||||
.iter()
|
|
||||||
.any(|i| k.loc_symbol.value == *i)
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
let (mut rigid_vars, mut def_types) = constrain_imports(imported_symbols, &mut var_store);
|
|
||||||
|
|
||||||
let constrain_end = SystemTime::now();
|
let constrain_end = SystemTime::now();
|
||||||
|
|
||||||
|
@ -3130,7 +3115,6 @@ fn run_solve<'a>(
|
||||||
|
|
||||||
let mut import_variables = Vec::new();
|
let mut import_variables = Vec::new();
|
||||||
|
|
||||||
if NEW_TYPES {
|
|
||||||
for symbol in exposed_for_module.imported_symbols {
|
for symbol in exposed_for_module.imported_symbols {
|
||||||
match exposed_for_module
|
match exposed_for_module
|
||||||
.exposed_by_module
|
.exposed_by_module
|
||||||
|
@ -3145,8 +3129,7 @@ fn run_solve<'a>(
|
||||||
stored_vars_by_symbol,
|
stored_vars_by_symbol,
|
||||||
storage_subs,
|
storage_subs,
|
||||||
} => {
|
} => {
|
||||||
let variable =
|
let variable = match stored_vars_by_symbol.iter().find(|(s, _)| *s == symbol) {
|
||||||
match stored_vars_by_symbol.iter().find(|(s, _)| *s == symbol) {
|
|
||||||
None => {
|
None => {
|
||||||
// TODO happens for imported types
|
// TODO happens for imported types
|
||||||
continue;
|
continue;
|
||||||
|
@ -3172,7 +3155,6 @@ fn run_solve<'a>(
|
||||||
None => todo!(),
|
None => todo!(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
let actual_constraint =
|
let actual_constraint =
|
||||||
constraints.let_import_constraint(rigid_vars, def_types, constraint, &import_variables);
|
constraints.let_import_constraint(rigid_vars, def_types, constraint, &import_variables);
|
||||||
|
@ -3826,7 +3808,7 @@ fn run_task<'a>(
|
||||||
Solve {
|
Solve {
|
||||||
module,
|
module,
|
||||||
module_timing,
|
module_timing,
|
||||||
imported_symbols,
|
imported_builtins,
|
||||||
exposed_for_module,
|
exposed_for_module,
|
||||||
constraints,
|
constraints,
|
||||||
constraint,
|
constraint,
|
||||||
|
@ -3839,7 +3821,7 @@ fn run_task<'a>(
|
||||||
module,
|
module,
|
||||||
ident_ids,
|
ident_ids,
|
||||||
module_timing,
|
module_timing,
|
||||||
imported_symbols,
|
imported_builtins,
|
||||||
exposed_for_module,
|
exposed_for_module,
|
||||||
constraints,
|
constraints,
|
||||||
constraint,
|
constraint,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue