def __trunc_sat_s(z, n): if math.isnan(z): return 0 min_value = -(int64(1) << (n - 1)) max_value = (int64(1) << (n - 1)) - 1 if z == -math.inf: return min_value if math.isinf(z): return max_value x = math.trunc(z) if x < float64(min_value): return min_value elif x >= float64(max_value): return max_value else: return int64(x)
def __trunc_sat_u(z, n): if math.isnan(z): return 0 if z == -math.inf: return 0 max_value = (uint64(1) << n) - 1 if math.isinf(z): return max_value x = math.trunc(z) if x < 0: return 0 elif x >= float64(max_value): return max_value else: return uint64(x)
def pop_f64(self): val = self.pop_u64() val = struct.unpack('>d', struct.pack('>q', val))[0] return float64(val)
def f64_const(vm, args): vm.push_f64(float64(args))
def f64_promote_f32(vm, _): vm.push_f64(float64(vm.pop_f32()))
def f64_convert_i64u(vm, _): vm.push_f64(float64(vm.pop_u64()))
def f64_convert_i64s(vm, _): vm.push_f64(float64(vm.pop_s64()))
def f64_convert_i32u(vm, _): vm.push_f64(float64(vm.pop_u32()))
def f64_convert_i32s(vm, _): vm.push_f64(float64(vm.pop_s32()))