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 i64_trunc_f64s(vm, _): f = math.trunc(vm.pop_f64()) if f >= __MaxInt64 or f < __MinInt64: raise ErrIntOverflow if math.isnan(f): raise ErrConvertToInt vm.push_s64(int64(f))
def pop_s64(self) -> int64: return int64(self.pop_u64())
def i64_const(vm, args): vm.push_s64(int64(args))
def i64_extend_32s(vm, _): vm.push_s64(int64(int32(vm.pop_s64())))
def i64_extend_16s(vm, _): vm.push_s64(int64(int16(vm.pop_s64())))
def i64_extend_8s(vm, _): vm.push_s64(int64(int8(vm.pop_s64())))
def i64_extend_i32s(vm, _): vm.push_s64(int64(vm.pop_s32()))