本文整理汇总了Python中block.Block.set_return方法的典型用法代码示例。如果您正苦于以下问题:Python Block.set_return方法的具体用法?Python Block.set_return怎么用?Python Block.set_return使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类block.Block
的用法示例。
在下文中一共展示了Block.set_return方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: split_blocks
# 需要导入模块: from block import Block [as 别名]
# 或者: from block.Block import set_return [as 别名]
def split_blocks(lines):
block = None
for line in lines:
line = line.strip()
idx = line.find(';') # comment
if idx != -1:
line = line[:idx]
tokens = line.split()
if len(tokens) == 0:
continue
label = inst = None
if tokens[0][-1:] == ':':
label = tokens.pop(0)[:-1]
if len(tokens) > 0:
opcode = tokens.pop(0)
oprands = tokens
inst = Instruction(opcode, oprands)
if label:
if block is None: # the first run
block = Block(label)
else:
block.set_passthru(Block.NEXT_BLOCK)
if len(block.instructions) == 0:
block.relabel(label)
else:
block = Block(label)
elif block is None:
block = Block(label)
if inst and inst.opcode[:1] != '.':
block.append(inst)
if inst.opcode[:1] == 'b': # branch
block.set_branch(inst.oprands[0])
block.set_passthru(Block.NEXT_BLOCK)
block = None
elif inst.opcode == 'jmp': # jump
block.set_passthru(inst.oprands[0])
block = None
elif inst.opcode == 'rts': # return subroutine
block.set_return(True)
block = None