mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 13:29:12 +00:00
Updates for making soa
no_std
This commit is contained in:
parent
178bc469e6
commit
44d00e1f13
21 changed files with 164 additions and 151 deletions
|
@ -683,7 +683,7 @@ impl IAbilitiesStore<Pending> {
|
|||
}
|
||||
|
||||
mod serialize {
|
||||
use roc_collections::{MutMap, VecMap};
|
||||
use roc_collections::{soa::slice_extend_new, MutMap, VecMap};
|
||||
use roc_module::symbol::Symbol;
|
||||
use roc_region::all::Region;
|
||||
use roc_serialize::bytes;
|
||||
|
@ -1034,11 +1034,11 @@ mod serialize {
|
|||
specialization_lambda_sets,
|
||||
} in spec_info
|
||||
{
|
||||
let regions = SubsSlice::extend_new(
|
||||
let regions = slice_extend_new(
|
||||
&mut spec_lambda_sets_regions,
|
||||
specialization_lambda_sets.keys().copied(),
|
||||
);
|
||||
let vars = SubsSlice::extend_new(
|
||||
let vars = slice_extend_new(
|
||||
&mut spec_lambda_sets_vars,
|
||||
specialization_lambda_sets.values().copied(),
|
||||
);
|
||||
|
@ -1168,11 +1168,11 @@ mod serialize {
|
|||
symbol,
|
||||
specialization_lambda_sets,
|
||||
}) => {
|
||||
let regions = SubsSlice::extend_new(
|
||||
let regions = slice_extend_new(
|
||||
&mut spec_lambda_sets_regions,
|
||||
specialization_lambda_sets.keys().copied(),
|
||||
);
|
||||
let vars = SubsSlice::extend_new(
|
||||
let vars = slice_extend_new(
|
||||
&mut spec_lambda_sets_vars,
|
||||
specialization_lambda_sets.values().copied(),
|
||||
);
|
||||
|
|
|
@ -5,6 +5,7 @@ use crate::{
|
|||
},
|
||||
pattern::{DestructType, ListPatterns, Pattern, RecordDestruct, TupleDestruct},
|
||||
};
|
||||
use roc_collections::soa::{index_push_new, slice_extend_new};
|
||||
use roc_module::{
|
||||
ident::{Lowercase, TagName},
|
||||
symbol::Symbol,
|
||||
|
@ -12,7 +13,7 @@ use roc_module::{
|
|||
use roc_types::{
|
||||
subs::{
|
||||
self, AliasVariables, Descriptor, GetSubsSlice, OptVariable, RecordFields, Subs, SubsIndex,
|
||||
SubsSlice, TupleElems, UnionLambdas, UnionTags, Variable, VariableSubsSlice,
|
||||
SubsSlice, TupleElems, UnionLambdas, UnionTags, Variable,
|
||||
},
|
||||
types::{RecordField, Uls},
|
||||
};
|
||||
|
@ -155,12 +156,12 @@ impl<'a> CopyEnv for AcrossSubs<'a> {
|
|||
|
||||
#[inline(always)]
|
||||
fn clone_name(&mut self, name: SubsIndex<Lowercase>) -> SubsIndex<Lowercase> {
|
||||
SubsIndex::push_new(&mut self.target.field_names, self.source[name].clone())
|
||||
index_push_new(&mut self.target.field_names, self.source[name].clone())
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn clone_field_names(&mut self, field_names: SubsSlice<Lowercase>) -> SubsSlice<Lowercase> {
|
||||
SubsSlice::extend_new(
|
||||
slice_extend_new(
|
||||
&mut self.target.field_names,
|
||||
self.source.get_subs_slice(field_names).iter().cloned(),
|
||||
)
|
||||
|
@ -171,7 +172,7 @@ impl<'a> CopyEnv for AcrossSubs<'a> {
|
|||
&mut self,
|
||||
tuple_elem_indices: SubsSlice<usize>,
|
||||
) -> SubsSlice<usize> {
|
||||
SubsSlice::extend_new(
|
||||
slice_extend_new(
|
||||
&mut self.target.tuple_elem_indices,
|
||||
self.source
|
||||
.get_subs_slice(tuple_elem_indices)
|
||||
|
@ -182,7 +183,7 @@ impl<'a> CopyEnv for AcrossSubs<'a> {
|
|||
|
||||
#[inline(always)]
|
||||
fn clone_tag_names(&mut self, tag_names: SubsSlice<TagName>) -> SubsSlice<TagName> {
|
||||
SubsSlice::extend_new(
|
||||
slice_extend_new(
|
||||
&mut self.target.tag_names,
|
||||
self.source.get_subs_slice(tag_names).iter().cloned(),
|
||||
)
|
||||
|
@ -190,7 +191,7 @@ impl<'a> CopyEnv for AcrossSubs<'a> {
|
|||
|
||||
#[inline(always)]
|
||||
fn clone_lambda_names(&mut self, lambda_names: SubsSlice<Symbol>) -> SubsSlice<Symbol> {
|
||||
SubsSlice::extend_new(
|
||||
slice_extend_new(
|
||||
&mut self.target.symbol_names,
|
||||
self.source.get_subs_slice(lambda_names).iter().cloned(),
|
||||
)
|
||||
|
@ -201,7 +202,7 @@ impl<'a> CopyEnv for AcrossSubs<'a> {
|
|||
&mut self,
|
||||
record_fields: SubsSlice<RecordField<()>>,
|
||||
) -> SubsSlice<RecordField<()>> {
|
||||
SubsSlice::extend_new(
|
||||
slice_extend_new(
|
||||
&mut self.target.record_fields,
|
||||
self.source.get_subs_slice(record_fields).iter().copied(),
|
||||
)
|
||||
|
@ -919,8 +920,7 @@ fn deep_copy_type_vars<C: CopyEnv>(
|
|||
|
||||
macro_rules! clone_var_slice {
|
||||
($slice:expr) => {{
|
||||
let new_arguments =
|
||||
VariableSubsSlice::reserve_into_subs(env.target(), $slice.len());
|
||||
let new_arguments = env.target().reserve_into_vars($slice.len());
|
||||
for (target_index, var_index) in (new_arguments.indices()).zip($slice) {
|
||||
let var = env.source()[var_index];
|
||||
let copy_var = env.get_copy(var).into_variable().unwrap_or(var);
|
||||
|
@ -994,9 +994,9 @@ fn deep_copy_type_vars<C: CopyEnv>(
|
|||
let new_fields = {
|
||||
RecordFields {
|
||||
length: fields.length,
|
||||
field_names_start: new_field_names.start,
|
||||
variables_start: new_variables.start,
|
||||
field_types_start: new_record_fields.start,
|
||||
field_names_start: new_field_names.start(),
|
||||
variables_start: new_variables.start(),
|
||||
field_types_start: new_record_fields.start(),
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1015,8 +1015,8 @@ fn deep_copy_type_vars<C: CopyEnv>(
|
|||
let new_elems = {
|
||||
TupleElems {
|
||||
length: elems.length,
|
||||
variables_start: new_variables.start,
|
||||
elem_index_start: new_elem_indices.start,
|
||||
variables_start: new_variables.start(),
|
||||
elem_index_start: new_elem_indices.start(),
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -1032,8 +1032,7 @@ fn deep_copy_type_vars<C: CopyEnv>(
|
|||
}
|
||||
|
||||
perform_clone!({
|
||||
let new_variable_slices =
|
||||
SubsSlice::reserve_variable_slices(env.target(), tags.len());
|
||||
let new_variable_slices = env.target().reserve_variable_slices(tags.len());
|
||||
let it = (new_variable_slices.indices()).zip(tags.variables());
|
||||
for (target_index, index) in it {
|
||||
let slice = env.source()[index];
|
||||
|
@ -1058,8 +1057,7 @@ fn deep_copy_type_vars<C: CopyEnv>(
|
|||
}
|
||||
|
||||
perform_clone!({
|
||||
let new_variable_slices =
|
||||
SubsSlice::reserve_variable_slices(env.target(), tags.len());
|
||||
let new_variable_slices = env.target().reserve_variable_slices(tags.len());
|
||||
let it = (new_variable_slices.indices()).zip(tags.variables());
|
||||
for (target_index, index) in it {
|
||||
let slice = env.source()[index];
|
||||
|
@ -1109,7 +1107,7 @@ fn deep_copy_type_vars<C: CopyEnv>(
|
|||
perform_clone!({
|
||||
let new_variables = clone_var_slice!(arguments.all_variables());
|
||||
let new_arguments = AliasVariables {
|
||||
variables_start: new_variables.start,
|
||||
variables_start: new_variables.start(),
|
||||
..arguments
|
||||
};
|
||||
|
||||
|
@ -1135,8 +1133,7 @@ fn deep_copy_type_vars<C: CopyEnv>(
|
|||
let new_ambient_function = descend_var!(ambient_function);
|
||||
|
||||
perform_clone!({
|
||||
let new_variable_slices =
|
||||
SubsSlice::reserve_variable_slices(env.target(), solved.len());
|
||||
let new_variable_slices = env.target().reserve_variable_slices(solved.len());
|
||||
let it = (new_variable_slices.indices()).zip(solved.variables());
|
||||
for (target_index, index) in it {
|
||||
let slice = env.source()[index];
|
||||
|
@ -1150,8 +1147,7 @@ fn deep_copy_type_vars<C: CopyEnv>(
|
|||
let new_solved =
|
||||
UnionLambdas::from_slices(new_solved_labels, new_variable_slices);
|
||||
|
||||
let new_unspecialized =
|
||||
SubsSlice::reserve_uls_slice(env.target(), unspecialized.len());
|
||||
let new_unspecialized = env.target().reserve_uls_slice(unspecialized.len());
|
||||
for (target_index, uls_index) in
|
||||
(new_unspecialized.into_iter()).zip(unspecialized.into_iter())
|
||||
{
|
||||
|
@ -1192,13 +1188,14 @@ mod test {
|
|||
};
|
||||
|
||||
use super::{deep_copy_expr_across_subs, deep_copy_type_vars};
|
||||
use roc_collections::soa::{index_push_new, slice_extend_new};
|
||||
use roc_error_macros::internal_error;
|
||||
use roc_module::{ident::TagName, symbol::Symbol};
|
||||
use roc_region::all::Loc;
|
||||
use roc_types::{
|
||||
subs::{
|
||||
self, Content, Content::*, Descriptor, FlatType, GetSubsSlice, Mark, OptVariable, Rank,
|
||||
Subs, SubsIndex, SubsSlice, Variable,
|
||||
Subs, Variable,
|
||||
},
|
||||
types::Uls,
|
||||
};
|
||||
|
@ -1217,7 +1214,7 @@ mod test {
|
|||
fn copy_flex_var() {
|
||||
let mut subs = Subs::new();
|
||||
|
||||
let field_name = SubsIndex::push_new(&mut subs.field_names, "a".into());
|
||||
let field_name = index_push_new(&mut subs.field_names, "a".into());
|
||||
let var = new_var(&mut subs, FlexVar(Some(field_name)));
|
||||
|
||||
let mut copied = vec![];
|
||||
|
@ -1238,7 +1235,7 @@ mod test {
|
|||
fn copy_rigid_var() {
|
||||
let mut subs = Subs::new();
|
||||
|
||||
let field_name = SubsIndex::push_new(&mut subs.field_names, "a".into());
|
||||
let field_name = index_push_new(&mut subs.field_names, "a".into());
|
||||
let var = new_var(&mut subs, RigidVar(field_name));
|
||||
|
||||
let mut copied = vec![];
|
||||
|
@ -1259,8 +1256,8 @@ mod test {
|
|||
fn copy_flex_able_var() {
|
||||
let mut subs = Subs::new();
|
||||
|
||||
let field_name = SubsIndex::push_new(&mut subs.field_names, "a".into());
|
||||
let abilities = SubsSlice::extend_new(&mut subs.symbol_names, [Symbol::UNDERSCORE]);
|
||||
let field_name = index_push_new(&mut subs.field_names, "a".into());
|
||||
let abilities = slice_extend_new(&mut subs.symbol_names, [Symbol::UNDERSCORE]);
|
||||
let var = new_var(&mut subs, FlexAbleVar(Some(field_name), abilities));
|
||||
|
||||
let mut copied = vec![];
|
||||
|
@ -1282,8 +1279,8 @@ mod test {
|
|||
fn copy_rigid_able_var() {
|
||||
let mut subs = Subs::new();
|
||||
|
||||
let field_name = SubsIndex::push_new(&mut subs.field_names, "a".into());
|
||||
let abilities = SubsSlice::extend_new(&mut subs.symbol_names, [Symbol::UNDERSCORE]);
|
||||
let field_name = index_push_new(&mut subs.field_names, "a".into());
|
||||
let abilities = slice_extend_new(&mut subs.symbol_names, [Symbol::UNDERSCORE]);
|
||||
let var = new_var(&mut subs, RigidAbleVar(field_name, abilities));
|
||||
|
||||
let mut copied = vec![];
|
||||
|
@ -1304,8 +1301,8 @@ mod test {
|
|||
fn copy_deep_expr() {
|
||||
let mut subs = Subs::new();
|
||||
|
||||
let a = SubsIndex::push_new(&mut subs.field_names, "a".into());
|
||||
let b = SubsIndex::push_new(&mut subs.field_names, "b".into());
|
||||
let a = index_push_new(&mut subs.field_names, "a".into());
|
||||
let b = index_push_new(&mut subs.field_names, "b".into());
|
||||
let var1 = new_var(&mut subs, FlexVar(Some(a)));
|
||||
let var2 = new_var(&mut subs, FlexVar(Some(b)));
|
||||
|
||||
|
@ -1390,8 +1387,8 @@ mod test {
|
|||
let mut source = Subs::new();
|
||||
let mut target = Subs::new();
|
||||
|
||||
let a = SubsIndex::push_new(&mut source.field_names, "a".into());
|
||||
let b = SubsIndex::push_new(&mut source.field_names, "b".into());
|
||||
let a = index_push_new(&mut source.field_names, "a".into());
|
||||
let b = index_push_new(&mut source.field_names, "b".into());
|
||||
let var1 = new_var(&mut source, FlexVar(Some(a)));
|
||||
let var2 = new_var(&mut source, FlexVar(Some(b)));
|
||||
|
||||
|
@ -1472,7 +1469,7 @@ mod test {
|
|||
let mut target = Subs::new();
|
||||
|
||||
let a = new_var(&mut source, FlexVar(None));
|
||||
let uls = SubsSlice::extend_new(
|
||||
let uls = slice_extend_new(
|
||||
&mut source.unspecialized_lambda_sets,
|
||||
vec![Uls(a, Symbol::UNDERSCORE, 3)],
|
||||
);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue