Beispiel #1
0
def lreturn(frame):
    value = frame.stack.pop()
    logger.debug("To be returned {0}".format(value))
    jassert_long(value)
    frame.ret = value
    frame.has_result = True
    frame.pc = len(frame.code) + 1
Beispiel #2
0
def lxor(frame):
    value2 = frame.stack.pop()
    value1 = frame.stack.pop()
    jassert_long(value1)
    jassert_long(value2)
    result = value1[1] ^ value2[1]
    result = cut_to_long(result)
    frame.stack.append(("long", result))
Beispiel #3
0
def op_0x83(frame):  # lxor
    value2 = frame.stack.pop()
    value1 = frame.stack.pop()
    jassert_long(value1)
    jassert_long(value2)
    result = value1[1] ^ value2[1]
    result = cut_to_long(result)
    frame.stack.append(("long", result))
Beispiel #4
0
def l2i(frame):
    value = frame.stack.pop()
    jassert_long(value)
    data = struct.pack(">q", value[1])
    data = data[4:]
    result = struct.unpack(">i", data)[0]
    jassert_int(result)
    frame.stack.append(result)
Beispiel #5
0
def op_0x79(frame):  # lshl
    value2 = frame.stack.pop()
    value1 = frame.stack.pop()
    jassert_int(value2)
    jassert_long(value1)
    value2 &= 0b111111
    result = value1[1] << value2
    result = ("long", cut_to_long(result))
    jassert_long(result)
    frame.stack.append(result)
Beispiel #6
0
def lshr(frame):
    value2 = frame.stack.pop()
    value1 = frame.stack.pop()
    jassert_int(value2)
    jassert_long(value1)
    value2 &= 0b111111
    result = value1[1] >> value2
    result = ("long", cut_to_long(result))
    jassert_long(result)
    frame.stack.append(result)
Beispiel #7
0
def lcmpl(frame):
    value2 = frame.stack.pop()
    value1 = frame.stack.pop()
    jassert_long(value1)
    jassert_long(value2)
    if value1[1] > value2[1]:
        frame.stack.append(1)
    elif value1[1] == value2[1]:
        frame.stack.append(0)
    else:
        frame.stack.append(-1)
Beispiel #8
0
def op_0x94(frame):  # lcmpl
    value2 = frame.stack.pop()
    value1 = frame.stack.pop()
    jassert_long(value1)
    jassert_long(value2)
    if value1[1] > value2[1]:
        frame.stack.append(1)
    elif value1[1] == value2[1]:
        frame.stack.append(0)
    else:
        frame.stack.append(-1)
Beispiel #9
0
def op_0x71(frame):  # lrem
    value2 = frame.stack.pop()
    value1 = frame.stack.pop()
    jassert_long(value1)
    jassert_long(value2)
    if value2[1] == 0:
        frame.vm.raise_exception(frame, "java/lang/ArithmeticException")
        return
    result = value1[1] % value2[1]
    result = cut_to_long(result)
    frame.stack.append(("long", result))
Beispiel #10
0
def lrem(frame):
    value2 = frame.stack.pop()
    value1 = frame.stack.pop()
    jassert_long(value1)
    jassert_long(value2)
    if value2[1] == 0:
        frame.vm.raise_exception(frame, "java/lang/ArithmeticException")
        return
    result = value1[1] % value2[1]
    result = cut_to_long(result)
    frame.stack.append(("long", result))
Beispiel #11
0
def cut_to_long(value):
    if -9223372036854775808 <= value <= 9223372036854775807:
        return long(value)
    if value & FLAG64:
        value &= 0xFFFFFFFFFFFFFFFF
        value ^= 0xFFFFFFFFFFFFFFFF
        value += 1
        value *= -1
    else:
        value &= 0xFFFFFFFFFFFFFFFF
    jassert_long(("long", value))
    return long(value)
Beispiel #12
0
def cut_to_long(value):
    if -9223372036854775808 <= value <= 9223372036854775807:
        return long(value)
    if value & FLAG64:
        value &= 0xFFFFFFFFFFFFFFFF
        value ^= 0xFFFFFFFFFFFFFFFF
        value += 1
        value *= -1
    else:
        value &= 0xFFFFFFFFFFFFFFFF
    jassert_long(("long", value))
    return long(value)
Beispiel #13
0
def lushr(frame):
    value2 = frame.stack.pop()
    value1 = frame.stack.pop()
    jassert_long(value1)
    jassert_int(value2)
    value2 &= 0b111111
    data = struct.pack(">q", value1[1])
    result = struct.unpack(">Q", data)[0]
    result >>= value2
    data = struct.pack(">Q", result)
    result = struct.unpack(">q", data)[0]
    result = ("long", cut_to_long(result))
    jassert_long(result)
    frame.stack.append(result)
Beispiel #14
0
def ldiv(frame):
    value2 = frame.stack.pop()
    value1 = frame.stack.pop()
    jassert_long(value1)
    jassert_long(value2)
    if value2[1] == 0:
        frame.vm.raise_exception(frame, "java/lang/ArithmeticException")
        return
    result = abs(value1[1]) / abs(value2[1])
    if (value1[1] < 0 and value2[1] > 0) or (value1[1] > 0 and value2[1] < 0):
        result *= -1
    #result = long(float(value1[1]) / value2[1]) - this will overflow
    result = cut_to_long(result)
    frame.stack.append(("long", long(result)))
Beispiel #15
0
def op_0x6d(frame):  # ldiv
    value2 = frame.stack.pop()
    value1 = frame.stack.pop()
    jassert_long(value1)
    jassert_long(value2)
    if value2[1] == 0:
        frame.vm.raise_exception(frame, "java/lang/ArithmeticException")
        return
    result = abs(value1[1]) / abs(value2[1])
    if (value1[1] < 0 and value2[1] > 0) or (value1[1] > 0 and value2[1] < 0):
        result *= -1
    #result = long(float(value1[1]) / value2[1]) - this will overflow
    result = cut_to_long(result)
    frame.stack.append(("long", long(result)))
Beispiel #16
0
def op_0x8f(frame):  # d2l
    value = frame.stack.pop()
    jassert_double(value)
    if value[1] is None:
        frame.stack.append(("long", 0))
    else:
        min_value = long(-1 * math.pow(2, 63))
        max_value = long(math.pow(2, 63) - 1)
        if value[1] < min_value:
            result = min_value
        elif value[1] > max_value:
            result = max_value
        else:
            result = long(value[1])
        jassert_long(("long", result))
        frame.stack.append(("long", result))
Beispiel #17
0
def f2l(frame):
    value = frame.stack.pop()
    jassert_float(value)
    if value[1] is None:
        frame.stack.append(("long", 0))
    else:
        min_value = long(-1 * math.pow(2, 63))
        max_value = long(math.pow(2, 63) - 1)
        if value[1] < min_value:
            result = min_value
        elif value[1] > max_value:
            result = max_value
        else:
            result = long(value[1])
        jassert_long(("long", result))
        frame.stack.append(("long", result))
Beispiel #18
0
def lastore(frame):
    value = frame.stack.pop()
    index = frame.stack.pop()
    ref = frame.stack.pop()
    jassert_long(value)
    jassert_int(index)
    if ref is None:
        frame.vm.raise_exception(frame, "java/lang/NullPointerException")
        return
    jassert_ref(ref)
    array = frame.vm.heap[ref[1]]
    jassert_array(array)
    values = array.values
    if index < 0 or index >= len(values):
        frame.vm.raise_exception(frame,
                                 "java/lang/ArrayIndexOutOfBoundsException")
        return
    values[index] = value
Beispiel #19
0
def lastore(frame):
    value = frame.stack.pop()
    index = frame.stack.pop()
    ref = frame.stack.pop()
    jassert_long(value)
    jassert_int(index)
    if ref is None:
        frame.vm.raise_exception(frame, "java/lang/NullPointerException")
        return
    jassert_ref(ref)
    array = frame.vm.heap[ref[1]]
    jassert_array(array)
    values = array.values
    if index < 0 or index >= len(values):
        frame.vm.raise_exception(frame,
                                 "java/lang/ArrayIndexOutOfBoundsException")
        return
    values[index] = value
Beispiel #20
0
def lor(frame):
    value2 = frame.stack.pop()
    value1 = frame.stack.pop()
    jassert_long(value2)
    jassert_long(value1)
    result = value1[1] | value2[1]
    result = ("long", cut_to_int(result))
    jassert_long(result)
    frame.stack.append(result)
Beispiel #21
0
def op_0x7f(frame):  # land
    value2 = frame.stack.pop()
    value1 = frame.stack.pop()
    jassert_long(value2)
    jassert_long(value1)
    result = value1[1] & value2[1]
    result = ("long", cut_to_int(result))
    jassert_long(result)
    frame.stack.append(result)
Beispiel #22
0
def op_0x40(frame):  # lstore_1
    value = frame.stack.pop()
    jassert_long(value)
    frame.args[1] = value
Beispiel #23
0
def op_0x37(frame):  # lstore
    index = ord(frame.code[frame.pc])
    frame.pc += 1
    value = frame.stack.pop()
    jassert_long(value)
    frame.args[index] = value
Beispiel #24
0
def op_0x3f(frame):  # lstore_0
    value = frame.stack.pop()
    jassert_long(value)
    frame.args[0] = value
Beispiel #25
0
def op_0x20(frame):  # lload_2
    value = frame.args[2]
    jassert_long(value)
    frame.stack.append(value)
Beispiel #26
0
def op_0x21(frame):  # lload_3
    value = frame.args[3]
    jassert_long(value)
    frame.stack.append(value)
Beispiel #27
0
def lload(frame):
    index = ord(frame.code[frame.pc])
    frame.pc += 1
    value = frame.args[index]
    jassert_long(value)
    frame.stack.append(value)
Beispiel #28
0
def op_0x1f(frame):  # lload_1
    value = frame.args[1]
    jassert_long(value)
    frame.stack.append(value)
Beispiel #29
0
def lneg(frame):
    value = frame.stack.pop()
    jassert_long(value)
    result = value[1] * -1
    result = cut_to_long(result)
    frame.stack.append(("long", long(result)))
Beispiel #30
0
def op_0x16(frame):  # lload
    index = ord(frame.code[frame.pc])
    frame.pc += 1
    value = frame.args[index]
    jassert_long(value)
    frame.stack.append(value)
Beispiel #31
0
def op_0x75(frame):  # lneg
    value = frame.stack.pop()
    jassert_long(value)
    result = value[1] * -1
    result = cut_to_long(result)
    frame.stack.append(("long", long(result)))
Beispiel #32
0
def l2d(frame):
    value = frame.stack.pop()
    jassert_long(value)
    result = ("double", float(value[1]))
    frame.stack.append(result)
Beispiel #33
0
def lstore_3(frame):
    value = frame.stack.pop()
    jassert_long(value)
    frame.args[3] = value
Beispiel #34
0
def lstore(frame):
    index = ord(frame.code[frame.pc])
    frame.pc += 1
    value = frame.stack.pop()
    jassert_long(value)
    frame.args[index] = value
Beispiel #35
0
def lload_3(frame):
    value = frame.args[3]
    jassert_long(value)
    frame.stack.append(value)
Beispiel #36
0
def op_0x41(frame):  # lstore_2
    value = frame.stack.pop()
    jassert_long(value)
    frame.args[2] = value
Beispiel #37
0
def op_0x1e(frame):  # lload_0
    value = frame.args[0]
    jassert_long(value)
    frame.stack.append(value)
Beispiel #38
0
def op_0x42(frame):  # lstore_3
    value = frame.stack.pop()
    jassert_long(value)
    frame.args[3] = value
Beispiel #39
0
def op_0x89(frame):  # l2f
    value = frame.stack.pop()
    jassert_long(value)
    result = ("float", float(value[1]))
    frame.stack.append(result)