mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 21:39:07 +00:00
Propagate layout_cache throughout Env in generating layout
Sets up actually using the LayoutCache to get cached layouts.
This commit is contained in:
parent
459faac064
commit
8b0f7dc82f
3 changed files with 176 additions and 123 deletions
|
@ -10,7 +10,8 @@ use roc_module::ident::TagName;
|
|||
use roc_module::symbol::{Interns, ModuleId, Symbol};
|
||||
use roc_mono::ir::ProcLayout;
|
||||
use roc_mono::layout::{
|
||||
union_sorted_tags_help, Builtin, Layout, LayoutCache, UnionLayout, UnionVariant, WrappedVariant,
|
||||
self, union_sorted_tags_help, Builtin, Layout, LayoutCache, UnionLayout, UnionVariant,
|
||||
WrappedVariant,
|
||||
};
|
||||
use roc_parse::ast::{AssignedField, Collection, Expr, StrLiteral};
|
||||
use roc_region::all::{Loc, Region};
|
||||
|
@ -196,8 +197,12 @@ fn get_tags_vars_and_variant<'a>(
|
|||
|
||||
let vars_of_tag: MutMap<_, _> = tags_vec.iter().cloned().collect();
|
||||
|
||||
let union_variant =
|
||||
union_sorted_tags_help(env.arena, tags_vec, opt_rec_var, env.subs, env.target_info);
|
||||
let union_variant = {
|
||||
let cache = LayoutCache::new(env.target_info);
|
||||
let mut layout_env =
|
||||
layout::Env::from_components(&cache, env.subs, env.arena, env.target_info);
|
||||
union_sorted_tags_help(&mut layout_env, tags_vec, opt_rec_var)
|
||||
};
|
||||
|
||||
(vars_of_tag, union_variant)
|
||||
}
|
||||
|
@ -1195,13 +1200,16 @@ fn byte_to_ast<'a, M: ReplAppMemory>(
|
|||
.map(|(a, b)| (a.clone(), b.to_vec()))
|
||||
.collect();
|
||||
|
||||
let union_variant = union_sorted_tags_help(
|
||||
env.arena,
|
||||
tags_vec,
|
||||
None,
|
||||
env.subs,
|
||||
env.target_info,
|
||||
);
|
||||
let union_variant = {
|
||||
let cache = LayoutCache::new(env.target_info);
|
||||
let mut layout_env = layout::Env::from_components(
|
||||
&cache,
|
||||
env.subs,
|
||||
env.arena,
|
||||
env.target_info,
|
||||
);
|
||||
union_sorted_tags_help(&mut layout_env, tags_vec, None)
|
||||
};
|
||||
|
||||
match union_variant {
|
||||
UnionVariant::ByteUnion(tagnames) => {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue