(self, block, kb)
Link atoms (AIL expressions) in the given block to corresponding variables identified previously.

        :param ailment.Block block: The AIL block to work on.
        :return:                    None
Link atoms (AIL expressions) in the given block to corresponding variables identified previously.
Link atoms ( AIL expressions ) in the given block to corresponding variables identified previously .
def _link_variables_on_block(self, block, kb):
        """
        Link atoms (AIL expressions) in the given block to corresponding variables identified previously.

        :param ailment.Block block: The AIL block to work on.
        :return:                    None
        """

        variable_manager = kb.variables[self.function.addr]
        global_variables = kb.variables['global']

        for stmt_idx, stmt in enumerate(block.statements):
            stmt_type = type(stmt)
            if stmt_type is ailment.Stmt.Store:
                # find a memory variable
                mem_vars = variable_manager.find_variables_by_atom(block.addr, stmt_idx, stmt)
                if len(mem_vars) == 1:
                    stmt.variable, stmt.offset = next(iter(mem_vars))
                else:
                    # check if the dest address is a variable
                    stmt: ailment.Stmt.Store
                    # special handling for constant addresses
                    if isinstance(stmt.addr, ailment.Expr.Const):
                        # global variable?
                        variables = global_variables.get_global_variables(stmt.addr.value)
                        if variables:
                            var = next(iter(variables))
                            stmt.variable = var
                            stmt.offset = 0
                    else:
                        self._link_variables_on_expr(variable_manager, global_variables, block, stmt_idx, stmt,
                                                     stmt.addr)
                self._link_variables_on_expr(variable_manager, global_variables, block, stmt_idx, stmt, stmt.data)

            elif stmt_type is ailment.Stmt.Assignment:
                self._link_variables_on_expr(variable_manager, global_variables, block, stmt_idx, stmt, stmt.dst)
                self._link_variables_on_expr(variable_manager, global_variables, block, stmt_idx, stmt, stmt.src)

            elif stmt_type is ailment.Stmt.ConditionalJump:
                self._link_variables_on_expr(variable_manager, global_variables, block, stmt_idx, stmt, stmt.condition)

            elif stmt_type is ailment.Stmt.Call:
                self._link_variables_on_call(variable_manager, global_variables, block, stmt_idx, stmt, is_expr=False)

            elif stmt_type is ailment.Stmt.Return:
                self._link_variables_on_return(variable_manager, global_variables, block, stmt_idx, stmt)
def _link_variables_on_block ( self , block , kb ) : variable_manager = kb . variables [ self . function . addr ] global_variables = kb . variables [ 'global' ] for stmt_idx , stmt in enumerate ( block . statements ) : stmt_type = type ( stmt ) if stmt_type is ailment . Stmt . Store : # find a memory variable mem_vars = variable_manager . find_variables_by_atom ( block . addr , stmt_idx , stmt ) if len ( mem_vars ) == 1 : stmt . variable , stmt . offset = next ( iter ( mem_vars ) ) else : # check if the dest address is a variable stmt : ailment . Stmt . Store # special handling for constant addresses if isinstance ( stmt . addr , ailment . Expr . Const ) : # global variable? variables = global_variables . get_global_variables ( stmt . addr . value ) if variables : var = next ( iter ( variables ) ) stmt . variable = var stmt . offset = 0 else : self . _link_variables_on_expr ( variable_manager , global_variables , block , stmt_idx , stmt , stmt . addr ) self . _link_variables_on_expr ( variable_manager , global_variables , block , stmt_idx , stmt , stmt . data ) elif stmt_type is ailment . Stmt . Assignment : self . _link_variables_on_expr ( variable_manager , global_variables , block , stmt_idx , stmt , stmt . dst ) self . _link_variables_on_expr ( variable_manager , global_variables , block , stmt_idx , stmt , stmt . src ) elif stmt_type is ailment . Stmt . ConditionalJump : self . _link_variables_on_expr ( variable_manager , global_variables , block , stmt_idx , stmt , stmt . condition ) elif stmt_type is ailment . Stmt . Call : self . _link_variables_on_call ( variable_manager , global_variables , block , stmt_idx , stmt , is_expr = False ) elif stmt_type is ailment . Stmt . Return : self . _link_variables_on_return ( variable_manager , global_variables , block , stmt_idx , stmt )