mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-29 14:54:47 +00:00
make some of References' fields private
This commit is contained in:
parent
8b144c446d
commit
e740bbe529
6 changed files with 27 additions and 20 deletions
|
@ -125,7 +125,7 @@ impl IntroducedVariables {
|
||||||
self.lambda_sets.extend(other.lambda_sets.iter().copied());
|
self.lambda_sets.extend(other.lambda_sets.iter().copied());
|
||||||
self.inferred.extend(other.inferred.iter().copied());
|
self.inferred.extend(other.inferred.iter().copied());
|
||||||
self.host_exposed_aliases
|
self.host_exposed_aliases
|
||||||
.extend(other.host_exposed_aliases.clone());
|
.extend(other.host_exposed_aliases.iter().map(|(k, v)| (*k, *v)));
|
||||||
|
|
||||||
self.named.extend(other.named.iter().cloned());
|
self.named.extend(other.named.iter().cloned());
|
||||||
self.able.extend(other.able.iter().cloned());
|
self.able.extend(other.able.iter().cloned());
|
||||||
|
|
|
@ -334,8 +334,7 @@ pub fn canonicalize_defs<'a>(
|
||||||
|
|
||||||
// Record all the annotation's references in output.references.lookups
|
// Record all the annotation's references in output.references.lookups
|
||||||
for symbol in can_ann.references {
|
for symbol in can_ann.references {
|
||||||
output.references.type_lookups.insert(symbol);
|
output.references.insert_type_lookup(symbol);
|
||||||
output.references.referenced_type_defs.insert(symbol);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let mut can_vars: Vec<Loc<(Lowercase, Variable)>> = Vec::with_capacity(vars.len());
|
let mut can_vars: Vec<Loc<(Lowercase, Variable)>> = Vec::with_capacity(vars.len());
|
||||||
|
@ -445,8 +444,7 @@ pub fn canonicalize_defs<'a>(
|
||||||
|
|
||||||
// Record all the annotation's references in output.references.lookups
|
// Record all the annotation's references in output.references.lookups
|
||||||
for symbol in member_annot.references {
|
for symbol in member_annot.references {
|
||||||
output.references.type_lookups.insert(symbol);
|
output.references.insert_type_lookup(symbol);
|
||||||
output.references.referenced_type_defs.insert(symbol);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
let name_region = member.name.region;
|
let name_region = member.name.region;
|
||||||
|
@ -1162,8 +1160,7 @@ fn canonicalize_pending_value_def<'a>(
|
||||||
// Record all the annotation's references in output.references.lookups
|
// Record all the annotation's references in output.references.lookups
|
||||||
|
|
||||||
for symbol in type_annotation.references.iter() {
|
for symbol in type_annotation.references.iter() {
|
||||||
output.references.type_lookups.insert(*symbol);
|
output.references.insert_type_lookup(*symbol);
|
||||||
output.references.referenced_type_defs.insert(*symbol);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
add_annotation_aliases(&type_annotation, aliases);
|
add_annotation_aliases(&type_annotation, aliases);
|
||||||
|
@ -1282,8 +1279,7 @@ fn canonicalize_pending_value_def<'a>(
|
||||||
|
|
||||||
// Record all the annotation's references in output.references.lookups
|
// Record all the annotation's references in output.references.lookups
|
||||||
for symbol in type_annotation.references.iter() {
|
for symbol in type_annotation.references.iter() {
|
||||||
output.references.type_lookups.insert(*symbol);
|
output.references.insert_type_lookup(*symbol);
|
||||||
output.references.referenced_type_defs.insert(*symbol);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
add_annotation_aliases(&type_annotation, aliases);
|
add_annotation_aliases(&type_annotation, aliases);
|
||||||
|
|
|
@ -487,8 +487,7 @@ pub fn canonicalize_expr<'a>(
|
||||||
}
|
}
|
||||||
Ok((name, opaque_def)) => {
|
Ok((name, opaque_def)) => {
|
||||||
let argument = Box::new(args.pop().unwrap());
|
let argument = Box::new(args.pop().unwrap());
|
||||||
output.references.referenced_type_defs.insert(name);
|
output.references.insert_type_lookup(name);
|
||||||
output.references.type_lookups.insert(name);
|
|
||||||
|
|
||||||
let (type_arguments, lambda_set_variables, specialized_def_type) =
|
let (type_arguments, lambda_set_variables, specialized_def_type) =
|
||||||
freshen_opaque_def(var_store, opaque_def);
|
freshen_opaque_def(var_store, opaque_def);
|
||||||
|
@ -685,7 +684,7 @@ pub fn canonicalize_expr<'a>(
|
||||||
// filter out aliases
|
// filter out aliases
|
||||||
debug_assert!(captured_symbols
|
debug_assert!(captured_symbols
|
||||||
.iter()
|
.iter()
|
||||||
.all(|s| !output.references.referenced_type_defs.contains(s)));
|
.all(|s| !output.references.references_type_def(*s)));
|
||||||
// captured_symbols.retain(|s| !output.references.referenced_type_defs.contains(s));
|
// captured_symbols.retain(|s| !output.references.referenced_type_defs.contains(s));
|
||||||
|
|
||||||
// filter out functions that don't close over anything
|
// filter out functions that don't close over anything
|
||||||
|
|
|
@ -329,8 +329,8 @@ pub fn canonicalize_module_defs<'a>(
|
||||||
let mut referenced_types = VecSet::default();
|
let mut referenced_types = VecSet::default();
|
||||||
|
|
||||||
// Gather up all the symbols that were referenced across all the defs' lookups.
|
// Gather up all the symbols that were referenced across all the defs' lookups.
|
||||||
referenced_values.extend(output.references.value_lookups);
|
referenced_values.extend(output.references.value_lookups.iter().copied());
|
||||||
referenced_types.extend(output.references.type_lookups);
|
referenced_types.extend(output.references.type_lookups().copied());
|
||||||
|
|
||||||
// Gather up all the symbols that were referenced across all the defs' calls.
|
// Gather up all the symbols that were referenced across all the defs' calls.
|
||||||
referenced_values.extend(output.references.calls);
|
referenced_values.extend(output.references.calls);
|
||||||
|
@ -528,8 +528,8 @@ pub fn canonicalize_module_defs<'a>(
|
||||||
}
|
}
|
||||||
|
|
||||||
// Incorporate any remaining output.lookups entries into references.
|
// Incorporate any remaining output.lookups entries into references.
|
||||||
referenced_values.extend(output.references.value_lookups);
|
referenced_values.extend(output.references.value_lookups.iter().copied());
|
||||||
referenced_types.extend(output.references.type_lookups);
|
referenced_types.extend(output.references.type_lookups().copied());
|
||||||
|
|
||||||
// Incorporate any remaining output.calls entries into references.
|
// Incorporate any remaining output.calls entries into references.
|
||||||
referenced_values.extend(output.references.calls);
|
referenced_values.extend(output.references.calls);
|
||||||
|
|
|
@ -318,8 +318,7 @@ pub fn canonicalize_pattern<'a>(
|
||||||
let (type_arguments, lambda_set_variables, specialized_def_type) =
|
let (type_arguments, lambda_set_variables, specialized_def_type) =
|
||||||
freshen_opaque_def(var_store, opaque_def);
|
freshen_opaque_def(var_store, opaque_def);
|
||||||
|
|
||||||
output.references.referenced_type_defs.insert(opaque);
|
output.references.insert_type_lookup(opaque);
|
||||||
output.references.type_lookups.insert(opaque);
|
|
||||||
|
|
||||||
Pattern::UnwrappedOpaque {
|
Pattern::UnwrappedOpaque {
|
||||||
whole_var: var_store.fresh(),
|
whole_var: var_store.fresh(),
|
||||||
|
|
|
@ -45,10 +45,10 @@ impl Procedure {
|
||||||
#[derive(Clone, Debug, Default, PartialEq)]
|
#[derive(Clone, Debug, Default, PartialEq)]
|
||||||
pub struct References {
|
pub struct References {
|
||||||
pub bound_symbols: VecSet<Symbol>,
|
pub bound_symbols: VecSet<Symbol>,
|
||||||
pub type_lookups: VecSet<Symbol>,
|
type_lookups: VecSet<Symbol>,
|
||||||
pub value_lookups: VecSet<Symbol>,
|
pub value_lookups: VecSet<Symbol>,
|
||||||
/// Aliases or opaque types referenced
|
/// Aliases or opaque types referenced
|
||||||
pub referenced_type_defs: VecSet<Symbol>,
|
referenced_type_defs: VecSet<Symbol>,
|
||||||
pub calls: VecSet<Symbol>,
|
pub calls: VecSet<Symbol>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -75,4 +75,17 @@ impl References {
|
||||||
pub fn has_type_lookup(&self, symbol: Symbol) -> bool {
|
pub fn has_type_lookup(&self, symbol: Symbol) -> bool {
|
||||||
self.type_lookups.contains(&symbol)
|
self.type_lookups.contains(&symbol)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn references_type_def(&self, symbol: Symbol) -> bool {
|
||||||
|
self.referenced_type_defs.contains(&symbol)
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn insert_type_lookup(&mut self, symbol: Symbol) {
|
||||||
|
self.type_lookups.insert(symbol);
|
||||||
|
self.referenced_type_defs.insert(symbol);
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn type_lookups(&self) -> impl Iterator<Item = &Symbol> {
|
||||||
|
self.type_lookups.iter()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue