示例#1
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)
示例#2
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)
示例#3
0
def wrap_u64(vt, val):
    if vt == ValTypeI32:
        return int32(val)
    elif vt == ValTypeI64:
        return int64(val)
    elif vt == ValTypeF32:
        cov_val = struct.unpack('>f', struct.pack('>l', int64(val)))[0]
        if math.isnan(cov_val):
            return float32(val)
        else:
            return float32(cov_val)
    elif vt == ValTypeF64:
        cov_val = struct.unpack('>d', struct.pack('>q', int64(val)))[0]
        if math.isnan(cov_val):
            return float64(val)
        else:
            return float64(cov_val)
    else:
        raise Exception("unreachable")
示例#4
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)
示例#5
0
def f64_const(vm, args):
    vm.push_f64(float64(args))
示例#6
0
def f64_promote_f32(vm, _):
    vm.push_f64(float64(vm.pop_f32()))
示例#7
0
def f64_convert_i64u(vm, _):
    vm.push_f64(float64(vm.pop_u64()))
示例#8
0
def f64_convert_i64s(vm, _):
    vm.push_f64(float64(vm.pop_s64()))
示例#9
0
def f64_convert_i32u(vm, _):
    vm.push_f64(float64(vm.pop_u32()))
示例#10
0
def f64_convert_i32s(vm, _):
    vm.push_f64(float64(vm.pop_s32()))