Make repr private and accessible only via the interner

This commit is contained in:
Ayaz Hafiz 2023-05-11 10:12:18 -05:00
parent 107c6b0777
commit 457cdabc5c
No known key found for this signature in database
GPG key ID: 0E2A37416A25EF58
30 changed files with 294 additions and 288 deletions

View file

@ -344,7 +344,7 @@ fn from_can_pattern_help<'a>(
StrLiteral(v) => Ok(Pattern::StrLiteral(v.clone())),
SingleQuote(var, _, c, _) => {
let layout = layout_cache.from_var(env.arena, *var, env.subs);
match layout.map(|l| layout_cache.get_in(l).repr) {
match layout.map(|l| layout_cache.get_repr(l)) {
Ok(LayoutRepr::Builtin(Builtin::Int(width))) => {
Ok(Pattern::IntLiteral((*c as i128).to_ne_bytes(), width))
}
@ -583,12 +583,11 @@ fn from_can_pattern_help<'a>(
// problems down the line because we hash layouts and an unrolled
// version is not the same as the minimal version.
let whole_var_layout = layout_cache.from_var(env.arena, *whole_var, env.subs);
let layout = match whole_var_layout
.map(|l| layout_cache.interner.chase_recursive(l).repr)
{
Ok(LayoutRepr::Union(ul)) => ul,
_ => internal_error!(),
};
let layout =
match whole_var_layout.map(|l| layout_cache.interner.chase_recursive(l)) {
Ok(LayoutRepr::Union(ul)) => ul,
_ => internal_error!(),
};
use WrappedVariant::*;
match variant {
@ -1552,7 +1551,7 @@ fn store_tag_pattern<'a>(
for (index, (argument, arg_layout)) in arguments.iter().enumerate().rev() {
let mut arg_layout = *arg_layout;
if let LayoutRepr::RecursivePointer(_) = layout_cache.get_in(arg_layout).repr {
if let LayoutRepr::RecursivePointer(_) = layout_cache.get_repr(arg_layout) {
// TODO(recursive-layouts): fix after disjoint rec ptrs
arg_layout = layout_cache.put_in_no_semantic(LayoutRepr::Union(union_layout));
}
@ -1630,7 +1629,7 @@ fn store_newtype_pattern<'a>(
for (index, (argument, arg_layout)) in arguments.iter().enumerate().rev() {
let mut arg_layout = *arg_layout;
if let LayoutRepr::RecursivePointer(_) = layout_cache.get_in(arg_layout).repr {
if let LayoutRepr::RecursivePointer(_) = layout_cache.get_repr(arg_layout) {
arg_layout = layout;
}