Exemple #1
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")
Exemple #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)
Exemple #3
0
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))
Exemple #4
0
def i64_const(vm, args):
    vm.push_s64(int64(args))
Exemple #5
0
def i64_extend_32s(vm, _):
    vm.push_s64(int64(int32(vm.pop_s64())))
Exemple #6
0
def i64_extend_16s(vm, _):
    vm.push_s64(int64(int16(vm.pop_s64())))
Exemple #7
0
def i64_extend_8s(vm, _):
    vm.push_s64(int64(int8(vm.pop_s64())))
Exemple #8
0
def i64_extend_i32s(vm, _):
    vm.push_s64(int64(vm.pop_s32()))
Exemple #9
0
 def pop_s64(self) -> int64:
     return int64(self.pop_numeric())
Exemple #10
0
def i64_load_32s(vm, mem_arg):
    val = read_u32(vm, mem_arg)
    vm.push_s64(int64(int32(val)))
Exemple #11
0
def i64_load_16s(vm, mem_arg):
    val = read_u16(vm, mem_arg)
    vm.push_s64(int64(int16(val)))
Exemple #12
0
def i64_load_8s(vm, mem_arg):
    val = read_u8(vm, mem_arg)
    vm.push_s64(int64(int8(val)))