当前位置: 首页>>代码示例>>Python>>正文


Python jassert.jassert_int函数代码示例

本文整理汇总了Python中pyjvm.jassert.jassert_int函数的典型用法代码示例。如果您正苦于以下问题:Python jassert_int函数的具体用法?Python jassert_int怎么用?Python jassert_int使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了jassert_int函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: newarray

def newarray(frame):
    atype = ord(frame.code[frame.pc])
    frame.pc += 1
    count = frame.stack.pop()
    jassert_int(count)
    if count < 0:
        frame.vm.raise_exception(frame, "java/lang/NegativeArraySizeException")
        return
    values = None
    if atype in [10, 5, 8, 9, 4]:  # int, char, byte, short, boolean
        values = [0]*count
    elif atype == 7:  # double
        values = [("double", 0.0)] * count
    elif atype == 6:  # float
        values = [("float", 0.0)] * count
    elif atype == 11:  # long
        values = [("long", 0)] * count
    else:
        raise Exception("Array creation for ATYPE {0} not yet supported"
                        .format(atype))
    prims = {4: "[Z", 5: "[C", 6: "[F", 7: "[D", 8: "[B", 9: "[S",
             10: "[I", 11: "[J"}
    array_class = frame.vm.get_class(prims[atype])
    jarray = JArray(array_class, frame.vm)
    jarray.values = values
    ref = frame.vm.add_to_heap(jarray)
    frame.stack.append(ref)
开发者ID:4toblerone,项目名称:pyjvm,代码行数:27,代码来源:ops_arrays.py

示例2: ireturn

def ireturn(frame):
    value = frame.stack.pop()
    logger.debug("To be returned {0}".format(value))
    jassert_int(value)
    frame.ret = value
    frame.has_result = True
    frame.pc = len(frame.code) + 1
开发者ID:4toblerone,项目名称:pyjvm,代码行数:7,代码来源:ops_ret.py

示例3: i2b

def i2b(frame):
    value = frame.stack.pop()
    jassert_int(value)
    data = struct.pack(">i", value)
    data = data[3]
    result = struct.unpack(">b", data)[0]
    frame.stack.append(result)
开发者ID:4toblerone,项目名称:pyjvm,代码行数:7,代码来源:ops_convert.py

示例4: op_0x60

def op_0x60(frame):  # iadd
    value2 = frame.stack.pop()
    value1 = frame.stack.pop()
    result = value1 + value2
    result = cut_to_int(result)
    jassert_int(result)
    frame.stack.append(result)
开发者ID:googya,项目名称:pyjvm,代码行数:7,代码来源:ops_calc.py

示例5: i2s

def i2s(frame):
    value = frame.stack.pop()
    jassert_int(value)
    data = struct.pack(">i", value)
    data = data[2:]
    result = struct.unpack(">h", data)[0]
    assert type(result) is int
    frame.stack.append(result)
开发者ID:4toblerone,项目名称:pyjvm,代码行数:8,代码来源:ops_convert.py

示例6: l2i

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)
开发者ID:4toblerone,项目名称:pyjvm,代码行数:8,代码来源:ops_convert.py

示例7: op_0x99

def op_0x99(frame):  # if_eq
    byte1 = ord(frame.code[frame.pc])
    byte2 = ord(frame.code[frame.pc + 1])
    frame.pc += 2
    offset = struct.unpack(">h", chr(byte1) + chr(byte2))[0]
    value = frame.stack.pop()
    jassert_int(value)
    if value == 0:
        frame.pc += offset - 2 - 1
开发者ID:googya,项目名称:pyjvm,代码行数:9,代码来源:ops_cond.py

示例8: i2c

def i2c(frame):
    value = frame.stack.pop()
    jassert_int(value)
    data = struct.pack(">i", value)
    data = data[2:]
    result = struct.unpack(">H", data)[0]
    assert type(result) is int
    assert 0 <= result <= int(math.pow(2, 16))
    frame.stack.append(result)
开发者ID:4toblerone,项目名称:pyjvm,代码行数:9,代码来源:ops_convert.py

示例9: lshr

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)
开发者ID:4toblerone,项目名称:pyjvm,代码行数:10,代码来源:ops_shift.py

示例10: op_0x79

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)
开发者ID:googya,项目名称:pyjvm,代码行数:10,代码来源:ops_shift.py

示例11: op_0xa4

def op_0xa4(frame):  # if_icmple
    byte1 = ord(frame.code[frame.pc])
    byte2 = ord(frame.code[frame.pc + 1])
    frame.pc += 2
    offset = struct.unpack(">h", chr(byte1) + chr(byte2))[0]
    value2 = frame.stack.pop()
    value1 = frame.stack.pop()
    jassert_int(value1)
    jassert_int(value2)
    if value1 <= value2:
        frame.pc += offset - 2 - 1
开发者ID:googya,项目名称:pyjvm,代码行数:11,代码来源:ops_cond.py

示例12: cut_to_int

def cut_to_int(value):
    if -2147483648 <= value <= 2147483647:
        return int(value)
    if value & FLAG32:
        value &= 0xFFFFFFFF
        value ^= 0xFFFFFFFF
        value += 1
        value *= -1
    else:
        value &= 0xFFFFFFFF
    jassert_int(value)
    return int(value)
开发者ID:googya,项目名称:pyjvm,代码行数:12,代码来源:ops_calc.py

示例13: lushr

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)
开发者ID:4toblerone,项目名称:pyjvm,代码行数:14,代码来源:ops_shift.py

示例14: f2i

def f2i(frame):
    value = frame.stack.pop()
    jassert_float(value)
    if value[1] is None:
        frame.stack.append(0)
    else:
        if value[1] < -2147483648:  # -1 * math.pow(2, 31)
            result = -2147483648
        elif value[1] > 2147483647:  # math.pow(2, 31) - 1
            result = 2147483647
        else:
            result = int(value[1])
        jassert_int(result)
        frame.stack.append(result)
开发者ID:4toblerone,项目名称:pyjvm,代码行数:14,代码来源:ops_convert.py

示例15: op_0x8e

def op_0x8e(frame):  # d2i
    value = frame.stack.pop()
    jassert_double(value)
    if value[1] is None:
        frame.stack.append(0)
    else:
        if value[1] < -2147483648:  # -1 * math.pow(2, 31)
            result = -2147483648
        elif value[1] > 2147483647:  # math.pow(2, 31) - 1
            result = 2147483647
        else:
            result = int(value[1])
        jassert_int(result)
        frame.stack.append(result)
开发者ID:googya,项目名称:pyjvm,代码行数:14,代码来源:ops_convert.py


注:本文中的pyjvm.jassert.jassert_int函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。