mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-02 00:01:16 +00:00
rename
This commit is contained in:
parent
8837eb2c19
commit
e40e4ae846
2 changed files with 14 additions and 14 deletions
|
@ -28,7 +28,7 @@ use roc_types::types::LambdaSet;
|
||||||
use roc_types::types::{Alias, Type};
|
use roc_types::types::{Alias, Type};
|
||||||
use std::collections::HashMap;
|
use std::collections::HashMap;
|
||||||
use std::fmt::Debug;
|
use std::fmt::Debug;
|
||||||
use ven_graph::{strongly_connected_components, topological_sort};
|
use ven_graph::topological_sort;
|
||||||
|
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
pub struct Def {
|
pub struct Def {
|
||||||
|
@ -143,7 +143,7 @@ fn sort_type_defs_before_introduction(
|
||||||
|
|
||||||
let all_successors_with_self = |symbol: &Symbol| referenced_symbols[symbol].iter().copied();
|
let all_successors_with_self = |symbol: &Symbol| referenced_symbols[symbol].iter().copied();
|
||||||
|
|
||||||
strongly_connected_components(&defined_symbols, all_successors_with_self)
|
ven_graph::strongly_connected_components(&defined_symbols, all_successors_with_self)
|
||||||
};
|
};
|
||||||
|
|
||||||
// then sort the strongly connected components
|
// then sort the strongly connected components
|
||||||
|
@ -925,7 +925,7 @@ impl DefIds {
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
pub fn sort_can_defs_improved(
|
pub fn sort_can_defs(
|
||||||
env: &mut Env<'_>,
|
env: &mut Env<'_>,
|
||||||
defs: CanDefs,
|
defs: CanDefs,
|
||||||
mut output: Output,
|
mut output: Output,
|
||||||
|
@ -950,7 +950,7 @@ pub fn sort_can_defs_improved(
|
||||||
|
|
||||||
// groups are in reversed order
|
// groups are in reversed order
|
||||||
for group in groups.into_iter().rev() {
|
for group in groups.into_iter().rev() {
|
||||||
group_to_declaration_improved(
|
group_to_declaration(
|
||||||
&def_ids,
|
&def_ids,
|
||||||
&group,
|
&group,
|
||||||
&env.closures,
|
&env.closures,
|
||||||
|
@ -976,7 +976,7 @@ pub fn sort_can_defs_improved(
|
||||||
//
|
//
|
||||||
// foo = if b then foo else bar
|
// foo = if b then foo else bar
|
||||||
|
|
||||||
let sccs = strongly_connected_components_improved(
|
let sccs = strongly_connected_components(
|
||||||
def_ids.length as usize,
|
def_ids.length as usize,
|
||||||
&def_ids.references,
|
&def_ids.references,
|
||||||
&nodes_in_cycle,
|
&nodes_in_cycle,
|
||||||
|
@ -1086,7 +1086,7 @@ pub fn sort_can_defs_improved(
|
||||||
for group_id in sorted_group.iter().rev() {
|
for group_id in sorted_group.iter().rev() {
|
||||||
let group = &groups[*group_id];
|
let group = &groups[*group_id];
|
||||||
|
|
||||||
group_to_declaration_improved(
|
group_to_declaration(
|
||||||
&def_ids,
|
&def_ids,
|
||||||
group,
|
group,
|
||||||
&env.closures,
|
&env.closures,
|
||||||
|
@ -1108,7 +1108,7 @@ pub fn sort_can_defs_improved(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn strongly_connected_components_improved(
|
fn strongly_connected_components(
|
||||||
length: usize,
|
length: usize,
|
||||||
bitvec: &bitvec::vec::BitVec<u8>,
|
bitvec: &bitvec::vec::BitVec<u8>,
|
||||||
group: &[u32],
|
group: &[u32],
|
||||||
|
@ -1213,7 +1213,7 @@ fn recurse_onto(length: usize, bitvec: &bitvec::vec::BitVec<u8>, v: usize, param
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn group_to_declaration_improved(
|
fn group_to_declaration(
|
||||||
def_ids: &DefIds,
|
def_ids: &DefIds,
|
||||||
group: &[u32],
|
group: &[u32],
|
||||||
closures: &MutMap<Symbol, References>,
|
closures: &MutMap<Symbol, References>,
|
||||||
|
@ -1231,8 +1231,7 @@ fn group_to_declaration_improved(
|
||||||
// for a definition, so every definition is only inserted (thus typechecked and emitted) once
|
// for a definition, so every definition is only inserted (thus typechecked and emitted) once
|
||||||
let mut seen_pattern_regions: Vec<Region> = Vec::with_capacity(2);
|
let mut seen_pattern_regions: Vec<Region> = Vec::with_capacity(2);
|
||||||
|
|
||||||
let sccs =
|
let sccs = strongly_connected_components(def_ids.length as usize, &def_ids.references, group);
|
||||||
strongly_connected_components_improved(def_ids.length as usize, &def_ids.references, group);
|
|
||||||
|
|
||||||
for cycle in sccs {
|
for cycle in sccs {
|
||||||
if cycle.len() == 1 {
|
if cycle.len() == 1 {
|
||||||
|
@ -1874,7 +1873,7 @@ pub fn can_defs_with_return<'a>(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
let (can_defs, output) = sort_can_defs_improved(env, unsorted, output);
|
let (can_defs, output) = sort_can_defs(env, unsorted, output);
|
||||||
|
|
||||||
match can_defs {
|
match can_defs {
|
||||||
Ok(decls) => {
|
Ok(decls) => {
|
||||||
|
@ -2209,7 +2208,8 @@ fn correct_mutual_recursive_type_alias<'a>(
|
||||||
// TODO investigate should this be in a loop?
|
// TODO investigate should this be in a loop?
|
||||||
let defined_symbols: Vec<Symbol> = original_aliases.keys().copied().collect();
|
let defined_symbols: Vec<Symbol> = original_aliases.keys().copied().collect();
|
||||||
|
|
||||||
let cycles = strongly_connected_components(&defined_symbols, all_successors_with_self);
|
let cycles =
|
||||||
|
ven_graph::strongly_connected_components(&defined_symbols, all_successors_with_self);
|
||||||
let mut solved_aliases = ImMap::default();
|
let mut solved_aliases = ImMap::default();
|
||||||
|
|
||||||
for cycle in cycles {
|
for cycle in cycles {
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
use crate::abilities::AbilitiesStore;
|
use crate::abilities::AbilitiesStore;
|
||||||
use crate::def::{canonicalize_defs, sort_can_defs_improved, Declaration, Def};
|
use crate::def::{canonicalize_defs, sort_can_defs, Declaration, Def};
|
||||||
use crate::effect_module::HostedGeneratedFunctions;
|
use crate::effect_module::HostedGeneratedFunctions;
|
||||||
use crate::env::Env;
|
use crate::env::Env;
|
||||||
use crate::expr::{ClosureData, Expr, Output};
|
use crate::expr::{ClosureData, Expr, Output};
|
||||||
|
@ -361,7 +361,7 @@ pub fn canonicalize_module_defs<'a>(
|
||||||
..Default::default()
|
..Default::default()
|
||||||
};
|
};
|
||||||
|
|
||||||
let sorted = sort_can_defs_improved(&mut env, defs, new_output);
|
let sorted = sort_can_defs(&mut env, defs, new_output);
|
||||||
|
|
||||||
match sorted {
|
match sorted {
|
||||||
(Ok(mut declarations), output) => {
|
(Ok(mut declarations), output) => {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue