(self, variable_manager, global_variables, block, stmt_idx, stmt, expr)
Link atoms (AIL expressions) in the given expression to corresponding variables identified previously.

        :param variable_manager:    Variable manager of the function.
        :param ailment.Block block: AIL block.
        :param int stmt_idx:        ID of the statement.
        :param stmt:                The AIL statement that `expr` belongs to.
        :param expr:                The AIl expression to work on.
        :return:                    None
Link atoms (AIL expressions) in the given expression to corresponding variables identified previously.
Link atoms ( AIL expressions ) in the given expression to corresponding variables identified previously .
def _link_variables_on_expr(self, variable_manager, global_variables, block, stmt_idx, stmt, expr):
        """
        Link atoms (AIL expressions) in the given expression to corresponding variables identified previously.

        :param variable_manager:    Variable manager of the function.
        :param ailment.Block block: AIL block.
        :param int stmt_idx:        ID of the statement.
        :param stmt:                The AIL statement that `expr` belongs to.
        :param expr:                The AIl expression to work on.
        :return:                    None
        """

        if type(expr) is ailment.Expr.Register:
            # find a register variable
            reg_vars = variable_manager.find_variables_by_atom(block.addr, stmt_idx, expr)
            final_reg_vars = set()
            if len(reg_vars) > 1:
                # take phi variables
                for reg_var in reg_vars:
                    if variable_manager.is_phi_variable(reg_var[0]):
                        final_reg_vars.add(reg_var)
            else:
                final_reg_vars = reg_vars
            if len(final_reg_vars) == 1:
                reg_var, offset = next(iter(final_reg_vars))
                expr.variable = reg_var
                expr.variable_offset = offset

        elif type(expr) is ailment.Expr.Load:
            variables = variable_manager.find_variables_by_atom(block.addr, stmt_idx, expr)
            if len(variables) == 0:
                # this is a local variable
                self._link_variables_on_expr(variable_manager, global_variables, block, stmt_idx, stmt, expr.addr)
                if 'reference_variable' in expr.addr.tags and expr.addr.reference_variable is not None:
                    # copy over the variable to this expr since the variable on a constant is supposed to be a
                    # reference variable.
                    expr.variable = expr.addr.reference_variable
                    expr.variable_offset = expr.addr.reference_variable_offset
            else:
                if len(variables) > 1:
                    l.error("More than one variable are available for atom %s. Consider fixing it using phi nodes.",
                            expr
                            )
                var, offset = next(iter(variables))
                expr.variable = var
                expr.variable_offset = offset

        elif type(expr) is ailment.Expr.BinaryOp:
            variables = variable_manager.find_variables_by_atom(block.addr, stmt_idx, expr)
            if len(variables) == 1:
                var, offset = next(iter(variables))
                expr.variable = var
                expr.variable_offset = offset
            else:
                self._link_variables_on_expr(
                    variable_manager, global_variables, block, stmt_idx, stmt, expr.operands[0])
                self._link_variables_on_expr(
                    variable_manager, global_variables, block, stmt_idx, stmt, expr.operands[1])

        elif type(expr) is ailment.Expr.UnaryOp:
            variables = variable_manager.find_variables_by_atom(block.addr, stmt_idx, expr)
            if len(variables) == 1:
                var, offset = next(iter(variables))
                expr.variable = var
                expr.variable_offset = offset
            else:
                self._link_variables_on_expr(variable_manager, global_variables, block, stmt_idx, stmt, expr.operands)

        elif type(expr) is ailment.Expr.Convert:
            self._link_variables_on_expr(variable_manager, global_variables, block, stmt_idx, stmt, expr.operand)

        elif type(expr) is ailment.Expr.ITE:
            variables = variable_manager.find_variables_by_atom(block.addr, stmt_idx, expr)
            if len(variables) == 1:
                var, offset = next(iter(variables))
                expr.variable = var
                expr.variable_offset = offset
            else:
                self._link_variables_on_expr(variable_manager, global_variables, block, stmt_idx, stmt,
                                             expr.cond)
                self._link_variables_on_expr(variable_manager, global_variables, block, stmt_idx, stmt,
                                             expr.iftrue)
                self._link_variables_on_expr(variable_manager, global_variables, block, stmt_idx, stmt,
                                             expr.iftrue)

        elif isinstance(expr, ailment.Expr.BasePointerOffset):
            variables = variable_manager.find_variables_by_atom(block.addr, stmt_idx, expr)
            if len(variables) == 1:
                var, offset = next(iter(variables))
                expr.variable = var
                expr.variable_offset = offset

        elif isinstance(expr, ailment.Expr.Const):
            # global variable?
            variables = global_variables.get_global_variables(expr.value)
            if variables:
                var = next(iter(variables))
                expr.tags['reference_variable'] = var
                expr.tags['reference_variable_offset'] = None
                expr.variable = var
                expr.variable_offset = None

        elif isinstance(expr, ailment.Stmt.Call):
            self._link_variables_on_call(variable_manager, global_variables, block, stmt_idx, expr, is_expr=True)
def _link_variables_on_expr ( self , variable_manager , global_variables , block , stmt_idx , stmt , expr ) : if type ( expr ) is ailment . Expr . Register : # find a register variable reg_vars = variable_manager . find_variables_by_atom ( block . addr , stmt_idx , expr ) final_reg_vars = set ( ) if len ( reg_vars ) > 1 : # take phi variables for reg_var in reg_vars : if variable_manager . is_phi_variable ( reg_var [ 0 ] ) : final_reg_vars . add ( reg_var ) else : final_reg_vars = reg_vars if len ( final_reg_vars ) == 1 : reg_var , offset = next ( iter ( final_reg_vars ) ) expr . variable = reg_var expr . variable_offset = offset elif type ( expr ) is ailment . Expr . Load : variables = variable_manager . find_variables_by_atom ( block . addr , stmt_idx , expr ) if len ( variables ) == 0 : # this is a local variable self . _link_variables_on_expr ( variable_manager , global_variables , block , stmt_idx , stmt , expr . addr ) if 'reference_variable' in expr . addr . tags and expr . addr . reference_variable is not None : # copy over the variable to this expr since the variable on a constant is supposed to be a # reference variable. expr . variable = expr . addr . reference_variable expr . variable_offset = expr . addr . reference_variable_offset else : if len ( variables ) > 1 : l . error ( "More than one variable are available for atom %s. Consider fixing it using phi nodes." , expr ) var , offset = next ( iter ( variables ) ) expr . variable = var expr . variable_offset = offset elif type ( expr ) is ailment . Expr . BinaryOp : variables = variable_manager . find_variables_by_atom ( block . addr , stmt_idx , expr ) if len ( variables ) == 1 : var , offset = next ( iter ( variables ) ) expr . variable = var expr . variable_offset = offset else : self . _link_variables_on_expr ( variable_manager , global_variables , block , stmt_idx , stmt , expr . operands [ 0 ] ) self . _link_variables_on_expr ( variable_manager , global_variables , block , stmt_idx , stmt , expr . operands [ 1 ] ) elif type ( expr ) is ailment . Expr . UnaryOp : variables = variable_manager . find_variables_by_atom ( block . addr , stmt_idx , expr ) if len ( variables ) == 1 : var , offset = next ( iter ( variables ) ) expr . variable = var expr . variable_offset = offset else : self . _link_variables_on_expr ( variable_manager , global_variables , block , stmt_idx , stmt , expr . operands ) elif type ( expr ) is ailment . Expr . Convert : self . _link_variables_on_expr ( variable_manager , global_variables , block , stmt_idx , stmt , expr . operand ) elif type ( expr ) is ailment . Expr . ITE : variables = variable_manager . find_variables_by_atom ( block . addr , stmt_idx , expr ) if len ( variables ) == 1 : var , offset = next ( iter ( variables ) ) expr . variable = var expr . variable_offset = offset else : self . _link_variables_on_expr ( variable_manager , global_variables , block , stmt_idx , stmt , expr . cond ) self . _link_variables_on_expr ( variable_manager , global_variables , block , stmt_idx , stmt , expr . iftrue ) self . _link_variables_on_expr ( variable_manager , global_variables , block , stmt_idx , stmt , expr . iftrue ) elif isinstance ( expr , ailment . Expr . BasePointerOffset ) : variables = variable_manager . find_variables_by_atom ( block . addr , stmt_idx , expr ) if len ( variables ) == 1 : var , offset = next ( iter ( variables ) ) expr . variable = var expr . variable_offset = offset elif isinstance ( expr , ailment . Expr . Const ) : # global variable? variables = global_variables . get_global_variables ( expr . value ) if variables : var = next ( iter ( variables ) ) expr . tags [ 'reference_variable' ] = var expr . tags [ 'reference_variable_offset' ] = None expr . variable = var expr . variable_offset = None elif isinstance ( expr , ailment . Stmt . Call ) : self . _link_variables_on_call ( variable_manager , global_variables , block , stmt_idx , expr , is_expr = True )