No longer causing a panic when globals are set to null in JS

This commit is contained in:
Johnathan Sharratt
2023-03-10 16:44:54 +11:00
parent 981962a902
commit 1dfddf81c0

View File

@@ -70,19 +70,19 @@ impl Global {
let ty = self.handle.ty; let ty = self.handle.ty;
let raw = match ty.ty { let raw = match ty.ty {
Type::I32 => RawValue { Type::I32 => RawValue {
i32: value.as_f64().unwrap() as _, i32: value.as_f64().unwrap_or_default() as _,
}, },
Type::I64 => RawValue { Type::I64 => RawValue {
i64: value.as_f64().unwrap() as _, i64: value.as_f64().unwrap_or_default() as _,
}, },
Type::F32 => RawValue { Type::F32 => RawValue {
f32: value.as_f64().unwrap() as _, f32: value.as_f64().unwrap_or_default() as _,
}, },
Type::F64 => RawValue { Type::F64 => RawValue {
f64: value.as_f64().unwrap(), f64: value.as_f64().unwrap_or_default(),
}, },
Type::V128 => RawValue { Type::V128 => RawValue {
u128: value.as_f64().unwrap() as _, u128: value.as_f64().unwrap_or_default() as _,
}, },
Type::FuncRef => { Type::FuncRef => {
unimplemented!(); unimplemented!();