decoder.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:bytecode_simplifier 作者: extremecoders-re 项目源码 文件源码
def decode_at(self, offset):
        assert offset < len(self.insBytes)

        opcode = self.insBytes[offset]

        if opcode == dis.opmap['EXTENDED_ARG']:
            raise Exception('EXTENDED_ARG not yet implemented')

        # Invalid instruction
        if opcode not in dis.opmap.values():
            return Instruction(-1, None, 1)

        if opcode < dis.HAVE_ARGUMENT:
            return Instruction(opcode, None, 1)

        if opcode >= dis.HAVE_ARGUMENT:
            arg = (self.insBytes[offset + 2] << 8) | self.insBytes[offset + 1]
            return Instruction(opcode, arg, 3)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号