mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-28 14:24:45 +00:00
Merge remote-tracking branch 'origin/trunk' into records-soa
This commit is contained in:
commit
b4a0881b4d
2 changed files with 131 additions and 84 deletions
|
@ -1210,128 +1210,81 @@ fn instantiate_rigids_help(
|
|||
// will not repeat this work or crawl this variable again.
|
||||
match content {
|
||||
Structure(flat_type) => {
|
||||
let new_flat_type = match flat_type {
|
||||
Apply(symbol, args) => {
|
||||
let args = args
|
||||
.into_iter()
|
||||
.map(|var| instantiate_rigids_help(subs, max_rank, pools, var))
|
||||
.collect();
|
||||
|
||||
Apply(symbol, args)
|
||||
match flat_type {
|
||||
Apply(_, args) => {
|
||||
for var in args.into_iter() {
|
||||
instantiate_rigids_help(subs, max_rank, pools, var);
|
||||
}
|
||||
}
|
||||
|
||||
Func(arg_vars, closure_var, ret_var) => {
|
||||
let new_ret_var = instantiate_rigids_help(subs, max_rank, pools, ret_var);
|
||||
let new_closure_var =
|
||||
instantiate_rigids_help(subs, max_rank, pools, closure_var);
|
||||
let arg_vars = arg_vars
|
||||
.into_iter()
|
||||
.map(|var| instantiate_rigids_help(subs, max_rank, pools, var))
|
||||
.collect();
|
||||
instantiate_rigids_help(subs, max_rank, pools, ret_var);
|
||||
instantiate_rigids_help(subs, max_rank, pools, closure_var);
|
||||
|
||||
Func(arg_vars, new_closure_var, new_ret_var)
|
||||
for var in arg_vars.into_iter() {
|
||||
instantiate_rigids_help(subs, max_rank, pools, var);
|
||||
}
|
||||
}
|
||||
|
||||
same @ EmptyRecord | same @ EmptyTagUnion | same @ Erroneous(_) => same,
|
||||
EmptyRecord | EmptyTagUnion | Erroneous(_) => {}
|
||||
|
||||
Record(fields, ext_var) => {
|
||||
for var in fields.iter_variables() {
|
||||
instantiate_rigids_help(subs, max_rank, pools, *var);
|
||||
}
|
||||
|
||||
Record(
|
||||
fields,
|
||||
instantiate_rigids_help(subs, max_rank, pools, ext_var),
|
||||
)
|
||||
instantiate_rigids_help(subs, max_rank, pools, ext_var);
|
||||
}
|
||||
|
||||
TagUnion(tags, ext_var) => {
|
||||
let mut new_tags = MutMap::default();
|
||||
|
||||
for (tag, vars) in tags {
|
||||
let new_vars: Vec<Variable> = vars
|
||||
.into_iter()
|
||||
.map(|var| instantiate_rigids_help(subs, max_rank, pools, var))
|
||||
.collect();
|
||||
new_tags.insert(tag, new_vars);
|
||||
for (_, vars) in tags {
|
||||
for var in vars.into_iter() {
|
||||
instantiate_rigids_help(subs, max_rank, pools, var);
|
||||
}
|
||||
}
|
||||
|
||||
TagUnion(
|
||||
new_tags,
|
||||
instantiate_rigids_help(subs, max_rank, pools, ext_var),
|
||||
)
|
||||
instantiate_rigids_help(subs, max_rank, pools, ext_var);
|
||||
}
|
||||
|
||||
FunctionOrTagUnion(tag_name, symbol, ext_var) => FunctionOrTagUnion(
|
||||
tag_name,
|
||||
symbol,
|
||||
instantiate_rigids_help(subs, max_rank, pools, ext_var),
|
||||
),
|
||||
FunctionOrTagUnion(_tag_name, _symbol, ext_var) => {
|
||||
instantiate_rigids_help(subs, max_rank, pools, ext_var);
|
||||
}
|
||||
|
||||
RecursiveTagUnion(rec_var, tags, ext_var) => {
|
||||
let mut new_tags = MutMap::default();
|
||||
instantiate_rigids_help(subs, max_rank, pools, rec_var);
|
||||
|
||||
let new_rec_var = instantiate_rigids_help(subs, max_rank, pools, rec_var);
|
||||
|
||||
for (tag, vars) in tags {
|
||||
let new_vars: Vec<Variable> = vars
|
||||
.into_iter()
|
||||
.map(|var| instantiate_rigids_help(subs, max_rank, pools, var))
|
||||
.collect();
|
||||
new_tags.insert(tag, new_vars);
|
||||
for (_, vars) in tags {
|
||||
for var in vars.into_iter() {
|
||||
instantiate_rigids_help(subs, max_rank, pools, var);
|
||||
}
|
||||
}
|
||||
|
||||
RecursiveTagUnion(
|
||||
new_rec_var,
|
||||
new_tags,
|
||||
instantiate_rigids_help(subs, max_rank, pools, ext_var),
|
||||
)
|
||||
instantiate_rigids_help(subs, max_rank, pools, ext_var);
|
||||
}
|
||||
};
|
||||
|
||||
subs.set(copy, make_descriptor(Structure(new_flat_type)));
|
||||
|
||||
copy
|
||||
}
|
||||
|
||||
FlexVar(_) | Error => copy,
|
||||
FlexVar(_) | Error => {}
|
||||
|
||||
RecursionVar {
|
||||
opt_name,
|
||||
structure,
|
||||
} => {
|
||||
let new_structure = instantiate_rigids_help(subs, max_rank, pools, structure);
|
||||
|
||||
subs.set(
|
||||
copy,
|
||||
make_descriptor(RecursionVar {
|
||||
opt_name,
|
||||
structure: new_structure,
|
||||
}),
|
||||
);
|
||||
|
||||
copy
|
||||
RecursionVar { structure, .. } => {
|
||||
instantiate_rigids_help(subs, max_rank, pools, structure);
|
||||
}
|
||||
|
||||
RigidVar(name) => {
|
||||
// what it's all about: convert the rigid var into a flex var
|
||||
subs.set(copy, make_descriptor(FlexVar(Some(name))));
|
||||
|
||||
copy
|
||||
}
|
||||
|
||||
Alias(symbol, args, real_type_var) => {
|
||||
let new_args = args
|
||||
.into_iter()
|
||||
.map(|(name, var)| (name, instantiate_rigids_help(subs, max_rank, pools, var)))
|
||||
.collect();
|
||||
let new_real_type_var = instantiate_rigids_help(subs, max_rank, pools, real_type_var);
|
||||
let new_content = Alias(symbol, new_args, new_real_type_var);
|
||||
Alias(_, args, real_type_var) => {
|
||||
for (_, var) in args.into_iter() {
|
||||
instantiate_rigids_help(subs, max_rank, pools, var);
|
||||
}
|
||||
|
||||
subs.set(copy, make_descriptor(new_content));
|
||||
|
||||
copy
|
||||
instantiate_rigids_help(subs, max_rank, pools, real_type_var);
|
||||
}
|
||||
}
|
||||
|
||||
var
|
||||
}
|
||||
|
||||
fn deep_copy_var(subs: &mut Subs, rank: Rank, pools: &mut Pools, var: Variable) -> Variable {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue