Beispiel #1
0
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)
Beispiel #2
0
 def pop_f64(self):
     val = self.pop_numeric()
     try:
         val = struct.unpack('>d', struct.pack('>q', val))[0]
     except struct.error:
         val = struct.unpack('>d', struct.pack('>Q', val))[0]
     return float64(val)
Beispiel #3
0
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)
Beispiel #4
0
def f64_const(vm, args):
    vm.push_f64(float64(args))
Beispiel #5
0
def f64_promote_f32(vm, _):
    vm.push_f64(float64(vm.pop_f32()))
Beispiel #6
0
def f64_convert_i64u(vm, _):
    vm.push_f64(float64(vm.pop_u64()))
Beispiel #7
0
def f64_convert_i64s(vm, _):
    vm.push_f64(float64(vm.pop_s64()))
Beispiel #8
0
def f64_convert_i32u(vm, _):
    vm.push_f64(float64(vm.pop_u32()))
Beispiel #9
0
def f64_convert_i32s(vm, _):
    vm.push_f64(float64(vm.pop_s32()))