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


Python Block.by_id方法代码示例

本文整理汇总了Python中block.Block.by_id方法的典型用法代码示例。如果您正苦于以下问题:Python Block.by_id方法的具体用法?Python Block.by_id怎么用?Python Block.by_id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在block.Block的用法示例。


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

示例1: split_segments

# 需要导入模块: from block import Block [as 别名]
# 或者: from block.Block import by_id [as 别名]
def split_segments():
	blocks_to_identify = []

	for id in range(1, Block.next_id()):
		block = Block.by_id(id)
		if block.branch():
			blocks_to_identify.append(id)

	#segments, included_in, members = identify_structure(blocks_to_identify)
	return _identify_structure(blocks_to_identify)
开发者ID:maczniak,项目名称:game_reverse_engineering,代码行数:12,代码来源:code_blocker.py

示例2: make_revrefs

# 需要导入模块: from block import Block [as 别名]
# 或者: from block.Block import by_id [as 别名]
def make_revrefs():
	revrefs = {}
	for id in range(1, Block.next_id()):
		revrefs[id] = []
	for id in range(1, Block.next_id()):
		block = Block.by_id(id)
		if not block.has_return():
			revrefs[block.passthru().id].append(id)
			if block.branch():
				revrefs[block.branch().id].append(id)
	return revrefs
开发者ID:maczniak,项目名称:game_reverse_engineering,代码行数:13,代码来源:code_blocker.py

示例3: _identify_structure

# 需要导入模块: from block import Block [as 别名]
# 或者: from block.Block import by_id [as 别名]
def _identify_structure(blocks):
	remaining_blocks = blocks[:]
	last_blocks = None
	segments = []
	included_in = {} # for Graphviz
	members = {} # for Graphviz

	while remaining_blocks:
		if remaining_blocks == last_blocks:
			break
		last_blocks = remaining_blocks[:]

		for id in remaining_blocks:
			ret = _identify_block(id)
			if ret[0] == 'NOTHING':
				remaining_blocks.remove(id)
			elif ret[0] == 'BRANCH':
				_new_segment(
					Segment(Segment.BRANCH, id, ret[3],
							passthru = ret[1], branch = ret[2]),
					segments, included_in, members)
				for z in ret[1]:
					if z in remaining_blocks:
						remaining_blocks.remove(z)
				for z in ret[2]:
					if z in remaining_blocks:
						remaining_blocks.remove(z)
				remaining_blocks.remove(id)
			elif ret[0] == 'LOOP' and ret[1] == 'passthru':
				_new_segment(
					Segment(Segment.LOOP, Block.by_id(id).passthru().id,
							Block.by_id(id).branch().id, body = ret[2]),
					segments, included_in, members)
				remaining_blocks.remove(id)
			elif ret[0] == 'LOOP' and ret[1] == 'branch':
				_new_segment(
					Segment(Segment.LOOP, Block.by_id(id).branch().id,
							Block.by_id(id).passthru().id, body = ret[2]),
					segments, included_in, members)
				remaining_blocks.remove(id)
	return segments, included_in, members
开发者ID:maczniak,项目名称:game_reverse_engineering,代码行数:43,代码来源:code_blocker.py

示例4: _travel_path

# 需要导入模块: from block import Block [as 别名]
# 或者: from block.Block import by_id [as 别名]
def _travel_path(origin_id, start_id):
	path = []
	branch_encounted = False
	head = start_id
	while True:
		path.append(head)
		b = Segment.by_id(head)
		if not b:
			b = Block.by_id(head)
		if origin_id == head:
			break
		if b.has_return():
			break
		if b.branch() and not b.branch().has_return():
			branch_encounted = True
			break
		head = b.passthru().id
	return path, branch_encounted
开发者ID:maczniak,项目名称:game_reverse_engineering,代码行数:20,代码来源:code_blocker.py

示例5: _identify_block

# 需要导入模块: from block import Block [as 别名]
# 或者: from block.Block import by_id [as 别名]
def _identify_block(id):
	block = Block.by_id(id)

	left, left_branch = _travel_path(id, block.passthru().id)
	right, right_branch = _travel_path(id, block.branch().id)

	if id == left[len(left) - 1]:
		return ['LOOP', 'passthru', left[1:]]
	if id == right[len(right) - 1]:
		return ['LOOP', 'branch', right[1:]]
	both = set(left) & set(right)
	if len(both) > 0:
		common = None
		for e in left:
			if e in both:
				common = e
				break
		return ['BRANCH', left[:left.index(common)], right[:right.index(common)], common]
	if left_branch or right_branch:
		return ['HAS_BRANCH']
	return ['NOTHING']
开发者ID:maczniak,项目名称:game_reverse_engineering,代码行数:23,代码来源:code_blocker.py

示例6: passthru

# 需要导入模块: from block import Block [as 别名]
# 或者: from block.Block import by_id [as 别名]
	def passthru(self):
		if self._passthru in Segment.idx_tbl:
			return Segment.idx_tbl[self._passthru]
		else:
			return Block.by_id(self._passthru)
开发者ID:maczniak,项目名称:game_reverse_engineering,代码行数:7,代码来源:segment.py

示例7: open

# 需要导入模块: from block import Block [as 别名]
# 或者: from block.Block import by_id [as 别名]
try:
	import pygraphviz
except ImportError:
	DEBUG_GRAPHVIZ = False

f = open('GameMenuRoutine.asm', 'r')
lines = f.readlines()

# part i - split code blocks

code_blocker.split_blocks(lines)
revrefs = code_blocker.make_revrefs()

if 'DEBUG_BLOCK' in globals() and DEBUG_BLOCK:
	for id in range(1, Block.next_id()):
		block = Block.by_id(id)
		print(block.pp())

if 'DEBUG_BLOCK_GRAPHVIZ' in globals() and DEBUG_BLOCK_GRAPHVIZ:
	g = pygraphviz.AGraph()
	
	for id in range(1, Block.next_id()):
		block = Block.by_id(id)
		if block.has_return():
			g.add_node(block.gv())
		else:
			g.add_edge(block.gv(), block.passthru().gv(), dir = 'forward')
		if block.branch():
			g.add_edge(block.gv(), block.branch().gv(), dir = 'forward',
					color = 'blue', style = 'dashed')
开发者ID:maczniak,项目名称:game_reverse_engineering,代码行数:32,代码来源:practice.py


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