예제 #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)
예제 #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)
예제 #3
0
def wrap_u64(vt, val):
    if vt == ValTypeI32:
        return int32(val)
    elif vt == ValTypeI64:
        return int64(val)
    elif vt == ValTypeF32:
        val = struct.unpack('>f', struct.pack('>l', int64(val)))[0]
        return float32(val)
    elif vt == ValTypeF64:
        val = struct.unpack('>d', struct.pack('>q', int64(val)))[0]
        return float64(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()))