make calls private

This commit is contained in:
Folkert 2022-04-20 17:43:18 +02:00
parent ab8ac2edad
commit b92c28b237
No known key found for this signature in database
GPG key ID: 1F17F6FFD112B97C
4 changed files with 17 additions and 9 deletions

View file

@ -1642,7 +1642,7 @@ fn closure_recursivity(symbol: Symbol, closures: &MutMap<Symbol, References>) ->
let mut stack = Vec::new();
if let Some(references) = closures.get(&symbol) {
for v in references.calls.iter() {
for v in references.calls() {
stack.push(*v);
}
@ -1658,7 +1658,7 @@ fn closure_recursivity(symbol: Symbol, closures: &MutMap<Symbol, References>) ->
// if it calls any functions
if let Some(nested_references) = closures.get(&nested_symbol) {
// add its called to the stack
for v in nested_references.calls.iter() {
for v in nested_references.calls() {
stack.push(*v);
}
}

View file

@ -517,7 +517,7 @@ pub fn canonicalize_expr<'a>(
let expr = match fn_expr.value {
Var(symbol) => {
output.references.calls.insert(symbol);
output.references.insert_call(symbol);
// we're tail-calling a symbol by name, check if it's the tail-callable symbol
output.tail_call = match &env.tailcallable_symbol {
@ -1102,7 +1102,7 @@ pub fn local_successors_with_duplicates<'a>(
) -> Vec<Symbol> {
let mut answer: Vec<_> = references.value_lookups().copied().collect();
let mut stack: Vec<_> = references.calls.iter().copied().collect();
let mut stack: Vec<_> = references.calls().copied().collect();
let mut seen = Vec::new();
while let Some(symbol) = stack.pop() {
@ -1112,7 +1112,7 @@ pub fn local_successors_with_duplicates<'a>(
if let Some(references) = closures.get(&symbol) {
answer.extend(references.value_lookups().copied());
stack.extend(references.calls.iter().copied());
stack.extend(references.calls().copied());
seen.push(symbol);
}
@ -1720,7 +1720,7 @@ fn flatten_str_lines<'a>(
Interpolated(loc_expr) => {
if is_valid_interpolation(loc_expr.value) {
// Interpolations desugar to Str.concat calls
output.references.calls.insert(Symbol::STR_CONCAT);
output.references.insert_call(Symbol::STR_CONCAT);
if !buf.is_empty() {
segments.push(StrSegment::Plaintext(buf.into()));

View file

@ -333,7 +333,7 @@ pub fn canonicalize_module_defs<'a>(
referenced_types.extend(output.references.type_lookups().copied());
// 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().copied());
// Gather up all the symbols that were referenced from other modules.
referenced_values.extend(env.qualified_value_lookups.iter().copied());
@ -532,7 +532,7 @@ pub fn canonicalize_module_defs<'a>(
referenced_types.extend(output.references.type_lookups().copied());
// Incorporate any remaining output.calls entries into references.
referenced_values.extend(output.references.calls);
referenced_values.extend(output.references.calls().copied());
// Gather up all the symbols that were referenced from other modules.
referenced_values.extend(env.qualified_value_lookups.iter().copied());

View file

@ -49,7 +49,7 @@ pub struct References {
value_lookups: VecSet<Symbol>,
/// Aliases or opaque types referenced
referenced_type_defs: VecSet<Symbol>,
pub calls: VecSet<Symbol>,
calls: VecSet<Symbol>,
}
impl References {
@ -88,6 +88,10 @@ impl References {
self.bound_symbols.insert(symbol);
}
pub fn insert_call(&mut self, symbol: Symbol) {
self.calls.insert(symbol);
}
pub fn remove_value_lookup(&mut self, symbol: &Symbol) {
self.value_lookups.remove(symbol);
}
@ -108,4 +112,8 @@ impl References {
pub fn bound_symbols(&self) -> impl Iterator<Item = &Symbol> {
self.bound_symbols.iter()
}
pub fn calls(&self) -> impl Iterator<Item = &Symbol> {
self.calls.iter()
}
}