mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 13:29:12 +00:00
Make collections::soa use the soa
crate
This commit is contained in:
parent
44d00e1f13
commit
e589923ae8
6 changed files with 59 additions and 244 deletions
|
@ -5,7 +5,7 @@ use std::sync::Arc;
|
|||
use crate::abilities::SpecializationId;
|
||||
use crate::exhaustive::{ExhaustiveContext, SketchedRows};
|
||||
use crate::expected::{Expected, PExpected};
|
||||
use roc_collections::soa::{EitherIndex, Index, Slice};
|
||||
use roc_collections::soa::{index_push_new, slice_extend_new, EitherIndex, Index, Slice};
|
||||
use roc_module::ident::TagName;
|
||||
use roc_module::symbol::{ModuleId, Symbol};
|
||||
use roc_region::all::{Loc, Region};
|
||||
|
@ -205,11 +205,11 @@ impl Constraints {
|
|||
}
|
||||
|
||||
pub fn push_expected_type(&mut self, expected: Expected<TypeOrVar>) -> ExpectedTypeIndex {
|
||||
Index::push_new(&mut self.expectations, expected)
|
||||
index_push_new(&mut self.expectations, expected)
|
||||
}
|
||||
|
||||
pub fn push_pat_expected_type(&mut self, expected: PExpected<TypeOrVar>) -> PExpectedTypeIndex {
|
||||
Index::push_new(&mut self.pattern_expectations, expected)
|
||||
index_push_new(&mut self.pattern_expectations, expected)
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
|
@ -229,7 +229,7 @@ impl Constraints {
|
|||
Category::List => Self::CATEGORY_LIST,
|
||||
Category::Str => Self::CATEGORY_STR,
|
||||
Category::Character => Self::CATEGORY_CHARACTER,
|
||||
other => Index::push_new(&mut self.categories, other),
|
||||
other => index_push_new(&mut self.categories, other),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -247,7 +247,7 @@ impl Constraints {
|
|||
PatternCategory::Int => Self::PCATEGORY_INT,
|
||||
PatternCategory::Float => Self::PCATEGORY_FLOAT,
|
||||
PatternCategory::Character => Self::PCATEGORY_CHARACTER,
|
||||
other => Index::push_new(&mut self.pattern_categories, other),
|
||||
other => index_push_new(&mut self.pattern_categories, other),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -320,7 +320,7 @@ impl Constraints {
|
|||
category: PatternCategory,
|
||||
region: Region,
|
||||
) -> Constraint {
|
||||
let category_index = Index::push_new(&mut self.pattern_categories, category);
|
||||
let category_index = index_push_new(&mut self.pattern_categories, category);
|
||||
|
||||
Constraint::PatternPresence(type_index, expected_index, category_index, region)
|
||||
}
|
||||
|
@ -337,7 +337,7 @@ impl Constraints {
|
|||
category: PatternCategory,
|
||||
region: Region,
|
||||
) -> Constraint {
|
||||
let category_index = Index::push_new(&mut self.pattern_categories, category);
|
||||
let category_index = index_push_new(&mut self.pattern_categories, category);
|
||||
|
||||
let includes_tag = IncludesTag {
|
||||
type_index,
|
||||
|
@ -347,7 +347,7 @@ impl Constraints {
|
|||
region,
|
||||
};
|
||||
|
||||
let includes_tag_index = Index::push_new(&mut self.includes_tags, includes_tag);
|
||||
let includes_tag_index = index_push_new(&mut self.includes_tags, includes_tag);
|
||||
|
||||
Constraint::IncludesTag(includes_tag_index)
|
||||
}
|
||||
|
@ -614,7 +614,7 @@ impl Constraints {
|
|||
filename: &'static str,
|
||||
line_number: u32,
|
||||
) -> Constraint {
|
||||
let string_index = Index::push_new(&mut self.strings, filename);
|
||||
let string_index = index_push_new(&mut self.strings, filename);
|
||||
|
||||
Constraint::Store(type_index, variable, string_index, line_number)
|
||||
}
|
||||
|
@ -632,19 +632,19 @@ impl Constraints {
|
|||
exhaustive: ExhaustiveMark,
|
||||
) -> Constraint {
|
||||
let real_var = Self::push_type_variable(real_var);
|
||||
let sketched_rows = Index::push_new(&mut self.sketched_rows, sketched_rows);
|
||||
let sketched_rows = index_push_new(&mut self.sketched_rows, sketched_rows);
|
||||
|
||||
let equality = match category_and_expectation {
|
||||
Ok((category, expected)) => {
|
||||
let category = Index::push_new(&mut self.categories, category);
|
||||
let category = index_push_new(&mut self.categories, category);
|
||||
let equality = Eq(real_var, expected, category, real_region);
|
||||
let equality = Index::push_new(&mut self.eq, equality);
|
||||
let equality = index_push_new(&mut self.eq, equality);
|
||||
Ok(equality)
|
||||
}
|
||||
Err((category, expected)) => {
|
||||
let category = Index::push_new(&mut self.pattern_categories, category);
|
||||
let category = index_push_new(&mut self.pattern_categories, category);
|
||||
let equality = PatternEq(real_var, expected, category, real_region);
|
||||
let equality = Index::push_new(&mut self.pattern_eq, equality);
|
||||
let equality = index_push_new(&mut self.pattern_eq, equality);
|
||||
Err(equality)
|
||||
}
|
||||
};
|
||||
|
@ -662,18 +662,18 @@ impl Constraints {
|
|||
I: IntoIterator<Item = (Symbol, Region)>,
|
||||
I1: IntoIterator<Item = Region>,
|
||||
{
|
||||
let def_names = Slice::extend_new(&mut self.loc_symbols, loc_symbols);
|
||||
let def_names = slice_extend_new(&mut self.loc_symbols, loc_symbols);
|
||||
|
||||
// we add a dummy symbol to these regions, so we can store the data in the loc_symbols vec
|
||||
let it = expr_regions.into_iter().map(|r| (Symbol::ATTR_ATTR, r));
|
||||
let expr_regions = Slice::extend_new(&mut self.loc_symbols, it);
|
||||
let expr_regions = slice_extend_new(&mut self.loc_symbols, it);
|
||||
let expr_regions = Slice::new(expr_regions.start() as _, expr_regions.len() as _);
|
||||
|
||||
let cycle = Cycle {
|
||||
def_names,
|
||||
expr_regions,
|
||||
};
|
||||
let cycle_index = Index::push_new(&mut self.cycles, cycle);
|
||||
let cycle_index = index_push_new(&mut self.cycles, cycle);
|
||||
|
||||
Constraint::CheckCycle(cycle_index, cycle_mark)
|
||||
}
|
||||
|
|
|
@ -12,7 +12,7 @@ use crate::pattern::{canonicalize_pattern, BindingsFromPattern, Pattern, PermitS
|
|||
use crate::procedure::{QualifiedReference, References};
|
||||
use crate::scope::{Scope, SymbolLookup};
|
||||
use crate::traverse::{walk_expr, Visitor};
|
||||
use roc_collections::soa::Index;
|
||||
use roc_collections::soa::{index_push_new, Index};
|
||||
use roc_collections::{SendMap, VecMap, VecSet};
|
||||
use roc_error_macros::internal_error;
|
||||
use roc_module::called_via::CalledVia;
|
||||
|
@ -2850,7 +2850,7 @@ impl Declarations {
|
|||
|
||||
let loc_function_def = Loc::at(loc_closure_data.region, function_def);
|
||||
|
||||
let function_def_index = Index::push_new(&mut self.function_bodies, loc_function_def);
|
||||
let function_def_index = index_push_new(&mut self.function_bodies, loc_function_def);
|
||||
|
||||
let tag = match loc_closure_data.value.recursive {
|
||||
Recursive::NotRecursive | Recursive::Recursive => {
|
||||
|
@ -2901,7 +2901,7 @@ impl Declarations {
|
|||
|
||||
let loc_function_def = Loc::at(loc_closure_data.region, function_def);
|
||||
|
||||
let function_def_index = Index::push_new(&mut self.function_bodies, loc_function_def);
|
||||
let function_def_index = index_push_new(&mut self.function_bodies, loc_function_def);
|
||||
|
||||
if let Some(annotation) = host_annotation {
|
||||
self.host_exposed_annotations
|
||||
|
@ -3007,7 +3007,7 @@ impl Declarations {
|
|||
pattern_vars,
|
||||
};
|
||||
|
||||
let destructure_def_index = Index::push_new(&mut self.destructs, destruct_def);
|
||||
let destructure_def_index = index_push_new(&mut self.destructs, destruct_def);
|
||||
|
||||
self.declarations
|
||||
.push(DeclarationTag::Destructure(destructure_def_index));
|
||||
|
@ -3079,7 +3079,7 @@ impl Declarations {
|
|||
let loc_function_def = Loc::at(def.loc_expr.region, function_def);
|
||||
|
||||
let function_def_index =
|
||||
Index::push_new(&mut self.function_bodies, loc_function_def);
|
||||
index_push_new(&mut self.function_bodies, loc_function_def);
|
||||
|
||||
self.declarations[index] = DeclarationTag::Function(function_def_index);
|
||||
self.expressions[index] = *closure_data.loc_body;
|
||||
|
@ -3131,7 +3131,7 @@ impl Declarations {
|
|||
let loc_function_def = Loc::at(region, function_def);
|
||||
|
||||
let function_def_index =
|
||||
Index::push_new(&mut self.function_bodies, loc_function_def);
|
||||
index_push_new(&mut self.function_bodies, loc_function_def);
|
||||
|
||||
if let Some(annotation) = &mut self.annotations[index] {
|
||||
annotation.convert_to_fn(new_args_len, var_store);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue