mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 21:39:07 +00:00
newlines
This commit is contained in:
parent
b4f65ad8cf
commit
b0a4dd3e52
1 changed files with 10 additions and 0 deletions
|
@ -204,6 +204,7 @@ pub fn refcount_reset_proc_body<'a>(
|
||||||
Layout::Union(u) => u,
|
Layout::Union(u) => u,
|
||||||
_ => unimplemented!("Reset is only implemented for UnionLayout"),
|
_ => unimplemented!("Reset is only implemented for UnionLayout"),
|
||||||
};
|
};
|
||||||
|
|
||||||
// Whenever we recurse into a child layout we will want to Decrement
|
// Whenever we recurse into a child layout we will want to Decrement
|
||||||
ctx.op = HelperOp::Dec;
|
ctx.op = HelperOp::Dec;
|
||||||
ctx.recursive_union = Some(union_layout);
|
ctx.recursive_union = Some(union_layout);
|
||||||
|
@ -212,6 +213,7 @@ pub fn refcount_reset_proc_body<'a>(
|
||||||
// Reset structure is unique. Decrement its children and return a pointer to the allocation.
|
// Reset structure is unique. Decrement its children and return a pointer to the allocation.
|
||||||
let then_stmt = {
|
let then_stmt = {
|
||||||
use UnionLayout::*;
|
use UnionLayout::*;
|
||||||
|
|
||||||
let tag_layouts;
|
let tag_layouts;
|
||||||
let mut null_id = None;
|
let mut null_id = None;
|
||||||
match union_layout {
|
match union_layout {
|
||||||
|
@ -239,7 +241,9 @@ pub fn refcount_reset_proc_body<'a>(
|
||||||
tag_layouts = root.arena.alloc([other_fields]);
|
tag_layouts = root.arena.alloc([other_fields]);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let tag_id_layout = union_layout.tag_id_layout();
|
let tag_id_layout = union_layout.tag_id_layout();
|
||||||
|
|
||||||
let tag_id_sym = root.create_symbol(ident_ids, "tag_id");
|
let tag_id_sym = root.create_symbol(ident_ids, "tag_id");
|
||||||
let tag_id_stmt = |next| {
|
let tag_id_stmt = |next| {
|
||||||
Stmt::Let(
|
Stmt::Let(
|
||||||
|
@ -252,6 +256,7 @@ pub fn refcount_reset_proc_body<'a>(
|
||||||
next,
|
next,
|
||||||
)
|
)
|
||||||
};
|
};
|
||||||
|
|
||||||
let rc_contents_stmt = refcount_union_contents(
|
let rc_contents_stmt = refcount_union_contents(
|
||||||
root,
|
root,
|
||||||
ident_ids,
|
ident_ids,
|
||||||
|
@ -265,11 +270,13 @@ pub fn refcount_reset_proc_body<'a>(
|
||||||
tag_id_layout,
|
tag_id_layout,
|
||||||
Stmt::Ret(addr),
|
Stmt::Ret(addr),
|
||||||
);
|
);
|
||||||
|
|
||||||
tag_id_stmt(root.arena.alloc(
|
tag_id_stmt(root.arena.alloc(
|
||||||
//
|
//
|
||||||
rc_contents_stmt,
|
rc_contents_stmt,
|
||||||
))
|
))
|
||||||
};
|
};
|
||||||
|
|
||||||
// Reset structure is not unique. Decrement it and return a NULL pointer.
|
// Reset structure is not unique. Decrement it and return a NULL pointer.
|
||||||
let else_stmt = {
|
let else_stmt = {
|
||||||
let decrement_unit = root.create_symbol(ident_ids, "decrement_unit");
|
let decrement_unit = root.create_symbol(ident_ids, "decrement_unit");
|
||||||
|
@ -283,14 +290,17 @@ pub fn refcount_reset_proc_body<'a>(
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let decrement_stmt = |next| Stmt::Let(decrement_unit, decrement_expr, LAYOUT_UNIT, next);
|
let decrement_stmt = |next| Stmt::Let(decrement_unit, decrement_expr, LAYOUT_UNIT, next);
|
||||||
|
|
||||||
// Zero
|
// Zero
|
||||||
let zero = root.create_symbol(ident_ids, "zero");
|
let zero = root.create_symbol(ident_ids, "zero");
|
||||||
let zero_expr = Expr::Literal(Literal::Int(0i128.to_ne_bytes()));
|
let zero_expr = Expr::Literal(Literal::Int(0i128.to_ne_bytes()));
|
||||||
let zero_stmt = |next| Stmt::Let(zero, zero_expr, root.layout_isize, next);
|
let zero_stmt = |next| Stmt::Let(zero, zero_expr, root.layout_isize, next);
|
||||||
|
|
||||||
// Null pointer with union layout
|
// Null pointer with union layout
|
||||||
let null = root.create_symbol(ident_ids, "null");
|
let null = root.create_symbol(ident_ids, "null");
|
||||||
let null_stmt =
|
let null_stmt =
|
||||||
|next| let_lowlevel(root.arena, root.layout_isize, null, PtrCast, &[zero], next);
|
|next| let_lowlevel(root.arena, root.layout_isize, null, PtrCast, &[zero], next);
|
||||||
|
|
||||||
decrement_stmt(root.arena.alloc(
|
decrement_stmt(root.arena.alloc(
|
||||||
//
|
//
|
||||||
zero_stmt(root.arena.alloc(
|
zero_stmt(root.arena.alloc(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue