def build(self): self.blocks = [] self.methods = [] self.actions = [] self.app_call_registrations = [] for block in self.cfg: start_ln = block[0].lineno for index, instr in enumerate(block): if instr.lineno != start_ln: self.cfg.split_block(block, index) self._extra_instr = [] new_method_blks = [] for blk in self.cfg: type = get_block_type(blk) if type == BlockType.MAKE_FUNCTION: new_method_blks.append(blk) elif type == BlockType.IMPORT_ITEM: new_module = Module.ImportFromBlock(blk, self.path) if new_module: for method in new_module.methods: self.methods.append(method) for method in new_module.local_methods: self.methods.append(method) self._extra_instr = self._extra_instr + new_module.extra_instructions elif type == BlockType.UNKNOWN: self._extra_instr.append(blk) elif type == BlockType.CALL_FUNCTION: self._extra_instr.append(blk) elif type == BlockType.ACTION_REG: self.actions.append(BoaAction(blk)) elif type == BlockType.MAKE_CLASS: pass elif type == BlockType.APPCALL_REG: self.app_call_registrations.append(BoaAppcall(blk)) # else: # logger.info("Block type not used:: %s " % type) for m in new_method_blks: new_method = BoaMethod(self, m, self.module_name, self._extra_instr) # if self.to_import == ['*'] or new_method.name in self.to_import: # print("IMPORTING NEW METHOD %s to module %s " % (new_method.name, self.module_name)) self.methods.append(new_method)
def build(self): self.blocks = [] self.methods = [] self.actions = [] self.app_call_registrations = [] for block in self.cfg: start_ln = block[0].lineno for index, instr in enumerate(block): if instr.lineno != start_ln: self.cfg.split_block(block, index) self._extra_instr = [] new_method_blks = [] for blk in self.cfg: type = get_block_type(blk) if type == BlockType.MAKE_FUNCTION: new_method_blks.append(blk) elif type == BlockType.IMPORT_ITEM: new_module = Module.ImportFromBlock(blk, self.path) if new_module: for method in new_module.methods: if not self.has_method(method.full_name): self.methods.append(method) for method in new_module.local_methods: self.methods.append(method) self._extra_instr = self._extra_instr + new_module.extra_instructions elif type == BlockType.UNKNOWN: self._extra_instr.append(blk) elif type == BlockType.CALL_FUNCTION: self._extra_instr.append(blk) elif type == BlockType.ACTION_REG: self.actions.append(BoaAction(blk)) elif type == BlockType.MAKE_CLASS: pass elif type == BlockType.APPCALL_REG: self.app_call_registrations.append(BoaAppcall(blk)) for m in new_method_blks: new_method = BoaMethod(self, m, self.module_name, self._extra_instr) if not self.has_method(new_method.full_name): self.methods.append(new_method)
def build(self): self.blocks = [] self.methods = [] self.actions = [] self.app_call_registrations = [] for block in self.cfg: start_ln = block[0].lineno for index, instr in enumerate(block): if instr.lineno != start_ln: self.cfg.split_block(block, index) self._extra_instr = [] new_method_blks = [] has_annotation = False block_count = 0 # for blk in self.cfg: while block_count < len(self.cfg): blk = self.cfg[block_count] type = get_block_type(blk) method = () if type == BlockType.ABI_ANNOTATION: has_annotation = True block_count = block_count + 1 next_blk = self.cfg[block_count] method = (blk, next_blk) blk = next_blk type = get_block_type(blk) else: has_annotation = False method = (None, blk) if type == BlockType.MAKE_FUNCTION: new_method_blks.append(method) elif type == BlockType.IMPORT_ITEM: new_module = Module.ImportFromBlock(blk, self.path) if new_module: for method in new_module.methods: if not self.has_method(method.full_name): self.methods.append(method) for method in new_module.local_methods: self.methods.append(method) self._extra_instr = self._extra_instr + new_module.extra_instructions elif type == BlockType.UNKNOWN: self._extra_instr.append(blk) elif type == BlockType.CALL_FUNCTION: self._extra_instr.append(blk) elif type == BlockType.ACTION_REG: self.actions.append(BoaAction(blk)) elif type == BlockType.MAKE_CLASS: pass elif type == BlockType.APPCALL_REG: self.app_call_registrations.append(BoaAppcall(blk)) block_count = block_count + 1 for m in new_method_blks: new_method = BoaMethod(self, m[1], m[0], self.module_name, self._extra_instr) if not self.has_method(new_method.full_name): self.methods.append(new_method)