(self, indent=0, pos_to_node=None, pos_to_addr=None, addr_to_pos=None)
return ''.join(mapper(self.c_repr_chunks(indent)))
Creates the C reperesentation of the code and displays it by
        constructing a large string. This function is called by each program function that needs to be decompiled.
        The map_pos_to_node and map_pos_to_addr act as position maps for the location of each variable and statment to be
        tracked for later GUI operations. The map_pos_to_addr also contains expressions that are nested inside of
        statments.

        :param indent:  # of indents (int)
        :param pos_to_nodemap_pos_to_ast:
        :return:
Creates the C reperesentation of the code and displays it by
        constructing a large string. This function is called by each program function that needs to be decompiled.
        The map_pos_to_node and map_pos_to_addr act as position maps for the location of each variable and statment to be
        tracked for later GUI operations. The map_pos_to_addr also contains expressions that are nested inside of
        statments.
Creates the C reperesentation of the code and displays it by constructing a large string . This function is called by each program function that needs to be decompiled . The map_pos_to_node and map_pos_to_addr act as position maps for the location of each variable and statment to be tracked for later GUI operations . The map_pos_to_addr also contains expressions that are nested inside of statments .
def c_repr(self, indent=0, pos_to_node=None, pos_to_addr=None, addr_to_pos=None):
        """
        Creates the C reperesentation of the code and displays it by
        constructing a large string. This function is called by each program function that needs to be decompiled.
        The map_pos_to_node and map_pos_to_addr act as position maps for the location of each variable and statment to be
        tracked for later GUI operations. The map_pos_to_addr also contains expressions that are nested inside of
        statments.

        :param indent:  # of indents (int)
        :param pos_to_nodemap_pos_to_ast:
        :return:
        """

        pending_stmt_comments = dict(self.codegen.stmt_comments)
        pending_expr_comments = dict(self.codegen.expr_comments)

        def mapper(chunks):
            # start all positions at beginning of document
            pos = 0

            last_insn_addr = None

            # track all Function Calls for highlighting
            used_func_calls = set()

            # track all variables so we can tell if this is a declaration or not
            used_vars = set()

            # get each string and object representation of the chunks
            for s, obj in chunks:
                # filter out anything that is not a statement or expression object
                if isinstance(obj, (CStatement, CExpression)):
                    # only add statements/expressions that can be address tracked into map_pos_to_addr
                    if hasattr(obj, 'tags') and obj.tags is not None and 'ins_addr' in obj.tags:
                        if isinstance(obj, CVariable) and obj not in used_vars:
                            used_vars.add(obj)
                        else:
                            last_insn_addr = obj.tags['ins_addr']

                            # all valid statements and expressions should be added to map_pos_to_addr and
                            # tracked for instruction mapping from disassembly
                            if pos_to_addr is not None:
                                pos_to_addr.add_mapping(pos, len(s), obj)
                            if addr_to_pos is not None:
                                addr_to_pos.add_mapping(obj.tags['ins_addr'], pos)

                    # add all variables, constants, and function calls to map_pos_to_node for highlighting
                    if isinstance(obj, (CVariable, CConstant, CStructField)):
                        if pos_to_node is not None:
                            pos_to_node.add_mapping(pos, len(s), obj)
                    elif isinstance(obj, CFunctionCall):
                        if obj not in used_func_calls:
                            used_func_calls.add(obj)
                            if pos_to_node is not None:
                                pos_to_node.add_mapping(pos, len(s), obj)

                # add (), {}, and [] to mapping for highlighting as well as the full functions name
                elif isinstance(obj, (CClosingObject, CFunction)):
                    if s is None:
                        continue

                    if pos_to_node is not None:
                        pos_to_node.add_mapping(pos, len(s), obj)

                if s.endswith('\n'):
                    text = pending_stmt_comments.pop(last_insn_addr, None)
                    if text is not None:
                        todo = '  // ' + text
                        pos += len(s) - 1
                        yield s[:-1]
                        pos += len(todo)
                        yield todo
                        s = '\n'

                pos += len(s)
                yield s

                if isinstance(obj, CExpression):
                    text = pending_expr_comments.pop(last_insn_addr, None)
                    if text is not None:
                        todo = ' /*' + text + '*/ '
                        pos += len(todo)
                        yield todo

            if pending_expr_comments or pending_stmt_comments:
                yield '// Orphaned comments\n'
                for text in pending_stmt_comments.values():
                    yield '// ' + text + '\n'
                for text in pending_expr_comments.values():
                    yield '/* ' + text + '*/\n'

        # A special note about this line:
        # Polymorphism allows that the c_repr_chunks() call will be called
        # by the CFunction class, which will then call each statement within it and construct
        # the chunks that get printed in qccode_edit in angr-management.
        return ''.join(mapper(self.c_repr_chunks(indent)))
def c_repr ( self , indent = 0 , pos_to_node = None , pos_to_addr = None , addr_to_pos = None ) : pending_stmt_comments = dict ( self . codegen . stmt_comments ) pending_expr_comments = dict ( self . codegen . expr_comments ) def mapper ( chunks ) : # start all positions at beginning of document pos = 0 last_insn_addr = None # track all Function Calls for highlighting used_func_calls = set ( ) # track all variables so we can tell if this is a declaration or not used_vars = set ( ) # get each string and object representation of the chunks for s , obj in chunks : # filter out anything that is not a statement or expression object if isinstance ( obj , ( CStatement , CExpression ) ) : # only add statements/expressions that can be address tracked into map_pos_to_addr if hasattr ( obj , 'tags' ) and obj . tags is not None and 'ins_addr' in obj . tags : if isinstance ( obj , CVariable ) and obj not in used_vars : used_vars . add ( obj ) else : last_insn_addr = obj . tags [ 'ins_addr' ] # all valid statements and expressions should be added to map_pos_to_addr and # tracked for instruction mapping from disassembly if pos_to_addr is not None : pos_to_addr . add_mapping ( pos , len ( s ) , obj ) if addr_to_pos is not None : addr_to_pos . add_mapping ( obj . tags [ 'ins_addr' ] , pos ) # add all variables, constants, and function calls to map_pos_to_node for highlighting if isinstance ( obj , ( CVariable , CConstant , CStructField ) ) : if pos_to_node is not None : pos_to_node . add_mapping ( pos , len ( s ) , obj ) elif isinstance ( obj , CFunctionCall ) : if obj not in used_func_calls : used_func_calls . add ( obj ) if pos_to_node is not None : pos_to_node . add_mapping ( pos , len ( s ) , obj ) # add (), {}, and [] to mapping for highlighting as well as the full functions name elif isinstance ( obj , ( CClosingObject , CFunction ) ) : if s is None : continue if pos_to_node is not None : pos_to_node . add_mapping ( pos , len ( s ) , obj ) if s . endswith ( '\n' ) : text = pending_stmt_comments . pop ( last_insn_addr , None ) if text is not None : todo = '  // ' + text pos += len ( s ) - 1 yield s [ : - 1 ] pos += len ( todo ) yield todo s = '\n' pos += len ( s ) yield s if isinstance ( obj , CExpression ) : text = pending_expr_comments . pop ( last_insn_addr , None ) if text is not None : todo = ' /*' + text + '*/ ' pos += len ( todo ) yield todo if pending_expr_comments or pending_stmt_comments : yield '// Orphaned comments\n' for text in pending_stmt_comments . values ( ) : yield '// ' + text + '\n' for text in pending_expr_comments . values ( ) : yield '/* ' + text + '*/\n' # A special note about this line: # Polymorphism allows that the c_repr_chunks() call will be called # by the CFunction class, which will then call each statement within it and construct # the chunks that get printed in qccode_edit in angr-management. return '' . join ( mapper ( self . c_repr_chunks ( indent ) ) )