mirror of
https://github.com/roc-lang/roc.git
synced 2025-08-04 12:18:19 +00:00
wasm_interp: neater creation of Value from unsigned integers
This commit is contained in:
parent
f7dcd8f421
commit
78fbc75249
2 changed files with 21 additions and 18 deletions
|
@ -721,6 +721,18 @@ impl Value {
|
|||
}
|
||||
}
|
||||
|
||||
impl From<u32> for Value {
|
||||
fn from(x: u32) -> Self {
|
||||
Value::I32(i32::from_ne_bytes(x.to_ne_bytes()))
|
||||
}
|
||||
}
|
||||
|
||||
impl From<u64> for Value {
|
||||
fn from(x: u64) -> Self {
|
||||
Value::I64(i64::from_ne_bytes(x.to_ne_bytes()))
|
||||
}
|
||||
}
|
||||
|
||||
/// Wasm memory alignment for load/store instructions.
|
||||
/// Rust representation matches Wasm encoding.
|
||||
/// It's an error to specify alignment higher than the "natural" alignment of the instruction
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue