cranelift: Add bmask to interpreter

This commit is contained in:
Afonso Bordado
2021-09-14 14:58:08 +01:00
parent 3ee180420e
commit 9a95ce75f1
5 changed files with 291 additions and 6 deletions

View File

@@ -277,11 +277,11 @@ impl Value for DataValue {
(DataValue::I64(n), types::I128) => DataValue::I128(n as i128),
(DataValue::B(b), t) if t.is_bool() => DataValue::B(b),
(DataValue::B(b), t) if t.is_int() => {
let val = if b {
// Bools are represented in memory as all 1's
(1i128 << t.bits()) - 1
} else {
0
// Bools are represented in memory as all 1's
let val = match (b, t) {
(true, types::I128) => -1,
(true, t) => (1i128 << t.bits()) - 1,
_ => 0,
};
DataValue::int(val, t)?
}