mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-29 14:54:47 +00:00
Wrap layouts in a LayoutRepr
constructor
Part 1 of support semantic layout representations.
This commit is contained in:
parent
c2d2bd4bb9
commit
c3eeb5e2cc
32 changed files with 1254 additions and 1021 deletions
|
@ -1,7 +1,7 @@
|
|||
use crate::ir::{substitute_in_exprs, Env, Expr, Procs, Stmt};
|
||||
use crate::layout::{
|
||||
self, Builtin, InLayout, Layout, LayoutCache, LayoutInterner, LayoutProblem, TagIdIntType,
|
||||
UnionLayout, WrappedVariant,
|
||||
self, Builtin, InLayout, Layout, LayoutCache, LayoutInterner, LayoutProblem, LayoutRepr,
|
||||
TagIdIntType, UnionLayout, WrappedVariant,
|
||||
};
|
||||
use bumpalo::collections::Vec;
|
||||
use roc_builtins::bitcode::{FloatWidth, IntWidth};
|
||||
|
@ -344,8 +344,8 @@ 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)) {
|
||||
Ok(Layout::Builtin(Builtin::Int(width))) => {
|
||||
match layout.map(|l| layout_cache.get_in(l).repr) {
|
||||
Ok(LayoutRepr::Builtin(Builtin::Int(width))) => {
|
||||
Ok(Pattern::IntLiteral((*c as i128).to_ne_bytes(), width))
|
||||
}
|
||||
o => internal_error!("an integer width was expected, but we found {:?}", o),
|
||||
|
@ -583,11 +583,12 @@ 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)) {
|
||||
Ok(Layout::Union(ul)) => ul,
|
||||
_ => internal_error!(),
|
||||
};
|
||||
let layout = match whole_var_layout
|
||||
.map(|l| layout_cache.interner.chase_recursive(l).repr)
|
||||
{
|
||||
Ok(LayoutRepr::Union(ul)) => ul,
|
||||
_ => internal_error!(),
|
||||
};
|
||||
|
||||
use WrappedVariant::*;
|
||||
match variant {
|
||||
|
@ -1551,9 +1552,11 @@ fn store_tag_pattern<'a>(
|
|||
for (index, (argument, arg_layout)) in arguments.iter().enumerate().rev() {
|
||||
let mut arg_layout = *arg_layout;
|
||||
|
||||
if let Layout::RecursivePointer(_) = layout_cache.get_in(arg_layout) {
|
||||
if let LayoutRepr::RecursivePointer(_) = layout_cache.get_in(arg_layout).repr {
|
||||
// TODO(recursive-layouts): fix after disjoint rec ptrs
|
||||
arg_layout = layout_cache.put_in(Layout::Union(union_layout));
|
||||
arg_layout = layout_cache.put_in(Layout {
|
||||
repr: LayoutRepr::Union(union_layout),
|
||||
});
|
||||
}
|
||||
|
||||
let load = Expr::UnionAtIndex {
|
||||
|
@ -1629,7 +1632,7 @@ fn store_newtype_pattern<'a>(
|
|||
for (index, (argument, arg_layout)) in arguments.iter().enumerate().rev() {
|
||||
let mut arg_layout = *arg_layout;
|
||||
|
||||
if let Layout::RecursivePointer(_) = layout_cache.get_in(arg_layout) {
|
||||
if let LayoutRepr::RecursivePointer(_) = layout_cache.get_in(arg_layout).repr {
|
||||
arg_layout = layout;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue