mirror of
https://github.com/roc-lang/roc.git
synced 2025-09-26 21:39:07 +00:00
Update ListLen and ListGetUnsafe to not use Nat
This commit is contained in:
parent
2e72021a74
commit
97f21e65fe
4 changed files with 60 additions and 49 deletions
|
@ -279,6 +279,9 @@ impl<'a> LowLevelCall<'a> {
|
|||
backend
|
||||
.code_builder
|
||||
.i32_load(Align::Bytes4, offset + (4 * Builtin::WRAPPER_LEN));
|
||||
|
||||
// Length is stored as 32 bits in memory, but List.len returns U64
|
||||
backend.code_builder.i64_extend_u_i32();
|
||||
}
|
||||
_ => internal_error!("invalid storage for List"),
|
||||
},
|
||||
|
@ -321,6 +324,7 @@ impl<'a> LowLevelCall<'a> {
|
|||
backend
|
||||
.storage
|
||||
.load_symbols(&mut backend.code_builder, &[index]);
|
||||
backend.code_builder.i32_wrap_i64(); // listGetUnsafe takes a U64, but we do 32-bit indexing on wasm.
|
||||
let elem_size = backend.layout_interner.stack_size(self.ret_layout);
|
||||
backend.code_builder.i32_const(elem_size as i32);
|
||||
backend.code_builder.i32_mul(); // index*size
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue