Exemple #1
0
def trunc_sat(vm, args):
    if args == 0:  # i32.trunc_sat_f32_s
        v = __trunc_sat_s(vm.pop_f32(), 32)
        vm.push_s32(int32(v))
    elif args == 1:  # i32.trunc_sat_f32_u
        v = __trunc_sat_u(vm.pop_f32(), 32)
        vm.push_u32(uint32(v))
    elif args == 2:  # i32.trunc_sat_f64_s
        v = __trunc_sat_s(vm.pop_f64(), 32)
        vm.push_s32(int32(v))
    elif args == 3:  # i32.trunc_sat_f64_u
        v = __trunc_sat_u(vm.pop_f64(), 32)
        vm.push_u32(uint32(v))
    elif args == 4:  # i64.trunc_sat_f32_s
        v = __trunc_sat_s(vm.pop_f32(), 64)
        vm.push_s64(v)
    elif args == 5:  # i64.trunc_sat_f32_u
        v = __trunc_sat_u(vm.pop_f32(), 64)
        vm.push_u64(v)
    elif args == 6:  # i64.trunc_sat_f64_s
        v = __trunc_sat_s(vm.pop_f64(), 64)
        vm.push_s64(v)
    elif args == 7:  # i64.trunc_sat_f64_u
        v = __trunc_sat_u(vm.pop_f64(), 64)
        vm.push_u64(v)
    else:
        raise Exception("unreachable")
Exemple #2
0
def i32_trunc_f64s(vm, _):
    f = math.trunc(vm.pop_f64())
    if f > __MaxInt32 or f < __MinInt32:
        raise ErrIntOverflow
    if math.isnan(f):
        raise ErrConvertToInt
    vm.push_s32(int32(f))
Exemple #3
0
 def pop_s32(self):
     return int32(self.pop_u64())
Exemple #4
0
def i32_const(vm, args):
    vm.push_s32(int32(args))
Exemple #5
0
def i64_extend_32s(vm, _):
    vm.push_s64(int64(int32(vm.pop_s64())))
Exemple #6
0
def i32_extend_16s(vm, _):
    vm.push_s32(int32(int16(vm.pop_s32())))
Exemple #7
0
def i32_extend_8s(vm, _):
    vm.push_s32(int32(int8(vm.pop_s32())))