mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-30 23:31:12 +00:00
mono: Update Str refcount helpers to account for capacity field
This commit is contained in:
parent
a9e0ff6b4b
commit
e4829b5b85
1 changed files with 9 additions and 9 deletions
|
@ -345,29 +345,29 @@ fn refcount_str<'a>(
|
||||||
let string = Symbol::ARG_1;
|
let string = Symbol::ARG_1;
|
||||||
let layout_isize = root.layout_isize;
|
let layout_isize = root.layout_isize;
|
||||||
|
|
||||||
// Get the string length as a signed int
|
// Get the last word as a signed int
|
||||||
let len = root.create_symbol(ident_ids, "len");
|
let last_word = root.create_symbol(ident_ids, "last_word");
|
||||||
let len_expr = Expr::StructAtIndex {
|
let last_word_expr = Expr::StructAtIndex {
|
||||||
index: 1,
|
index: 2,
|
||||||
field_layouts: root.arena.alloc([LAYOUT_PTR, layout_isize]),
|
field_layouts: root.arena.alloc([LAYOUT_PTR, layout_isize]),
|
||||||
structure: string,
|
structure: string,
|
||||||
};
|
};
|
||||||
let len_stmt = |next| Stmt::Let(len, len_expr, layout_isize, next);
|
let last_word_stmt = |next| Stmt::Let(last_word, last_word_expr, layout_isize, 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(0));
|
let zero_expr = Expr::Literal(Literal::Int(0));
|
||||||
let zero_stmt = |next| Stmt::Let(zero, zero_expr, layout_isize, next);
|
let zero_stmt = |next| Stmt::Let(zero, zero_expr, layout_isize, next);
|
||||||
|
|
||||||
// is_big_str = (len >= 0);
|
// is_big_str = (last_word >= 0);
|
||||||
// Treat len as isize so that the small string flag is the same as the sign bit
|
// Treat last word as isize so that the small string flag is the same as the sign bit
|
||||||
let is_big_str = root.create_symbol(ident_ids, "is_big_str");
|
let is_big_str = root.create_symbol(ident_ids, "is_big_str");
|
||||||
let is_big_str_expr = Expr::Call(Call {
|
let is_big_str_expr = Expr::Call(Call {
|
||||||
call_type: CallType::LowLevel {
|
call_type: CallType::LowLevel {
|
||||||
op: LowLevel::NumGte,
|
op: LowLevel::NumGte,
|
||||||
update_mode: UpdateModeId::BACKEND_DUMMY,
|
update_mode: UpdateModeId::BACKEND_DUMMY,
|
||||||
},
|
},
|
||||||
arguments: root.arena.alloc([len, zero]),
|
arguments: root.arena.alloc([last_word, zero]),
|
||||||
});
|
});
|
||||||
let is_big_str_stmt = |next| Stmt::Let(is_big_str, is_big_str_expr, LAYOUT_BOOL, next);
|
let is_big_str_stmt = |next| Stmt::Let(is_big_str, is_big_str_expr, LAYOUT_BOOL, next);
|
||||||
|
|
||||||
|
@ -422,7 +422,7 @@ fn refcount_str<'a>(
|
||||||
};
|
};
|
||||||
|
|
||||||
// Combine the statements in sequence
|
// Combine the statements in sequence
|
||||||
len_stmt(root.arena.alloc(
|
last_word_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