mirror of
https://github.com/roc-lang/roc.git
synced 2025-10-02 16:21:11 +00:00
Boxed skeleton
This commit is contained in:
parent
7be0349eee
commit
09f01ba193
8 changed files with 31 additions and 1 deletions
|
@ -972,6 +972,7 @@ fn layout_spec(builder: &mut FuncDefBuilder, layout: &Layout) -> Result<TypeId>
|
|||
} => worst_case_type(builder),
|
||||
},
|
||||
RecursivePointer => worst_case_type(builder),
|
||||
Boxed(_) => worst_case_type(builder),
|
||||
Closure(_, lambda_set, _) => layout_spec(builder, &lambda_set.runtime_representation()),
|
||||
}
|
||||
}
|
||||
|
|
|
@ -44,6 +44,8 @@ pub enum Layout<'a> {
|
|||
Union(UnionLayout<'a>),
|
||||
RecursivePointer,
|
||||
|
||||
Boxed(&'a Layout<'a>),
|
||||
|
||||
/// A function. The types of its arguments, then the type of its return value.
|
||||
Closure(&'a [Layout<'a>], LambdaSet<'a>, &'a Layout<'a>),
|
||||
}
|
||||
|
@ -588,6 +590,7 @@ impl<'a> Layout<'a> {
|
|||
// We cannot memcpy pointers, because then we would have the same pointer in multiple places!
|
||||
false
|
||||
}
|
||||
Boxed(_) => false,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -639,6 +642,7 @@ impl<'a> Layout<'a> {
|
|||
}
|
||||
Closure(_, lambda_set, _) => lambda_set.stack_size(pointer_size),
|
||||
RecursivePointer => pointer_size,
|
||||
Boxed(_) => pointer_size,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -669,6 +673,7 @@ impl<'a> Layout<'a> {
|
|||
}
|
||||
Layout::Builtin(builtin) => builtin.alignment_bytes(pointer_size),
|
||||
Layout::RecursivePointer => pointer_size,
|
||||
Layout::Boxed(_) => pointer_size,
|
||||
Layout::Closure(_, captured, _) => {
|
||||
pointer_size.max(captured.alignment_bytes(pointer_size))
|
||||
}
|
||||
|
@ -690,6 +695,7 @@ impl<'a> Layout<'a> {
|
|||
}
|
||||
|
||||
RecursivePointer => true,
|
||||
Boxed(_) => true,
|
||||
|
||||
Builtin(List(_)) | Builtin(Str) => true,
|
||||
|
||||
|
@ -722,6 +728,7 @@ impl<'a> Layout<'a> {
|
|||
}
|
||||
}
|
||||
RecursivePointer => true,
|
||||
Boxed(inner) => inner.contains_refcounted(),
|
||||
Closure(_, closure_layout, _) => closure_layout.contains_refcounted(),
|
||||
}
|
||||
}
|
||||
|
@ -746,6 +753,7 @@ impl<'a> Layout<'a> {
|
|||
}
|
||||
Union(union_layout) => union_layout.to_doc(alloc, parens),
|
||||
RecursivePointer => alloc.text("*self"),
|
||||
Boxed(_) => alloc.text("unbox"),
|
||||
Closure(args, closure_layout, result) => {
|
||||
let args_doc = args.iter().map(|x| x.to_doc(alloc, Parens::InFunction));
|
||||
|
||||
|
|
|
@ -246,7 +246,12 @@ fn insert_reset<'a>(
|
|||
}
|
||||
|
||||
let reset_expr = Expr::Reset(x);
|
||||
stmt = env.arena.alloc(Stmt::Let(w, reset_expr, layout, stmt));
|
||||
|
||||
const I64: Layout<'static> = Layout::Builtin(crate::layout::Builtin::Int64);
|
||||
|
||||
stmt = env
|
||||
.arena
|
||||
.alloc(Stmt::Let(w, reset_expr, Layout::Boxed(&I64), stmt));
|
||||
|
||||
for (symbol, expr, expr_layout) in stack.into_iter().rev() {
|
||||
stmt = env
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue