def do_while_loops(self):
        """A list of do while loops (:class:`.DoWhileLoop`) that the function contains.

        The returned list can be indexed by either positions (0, 1, ...) or
        identification of do while loop. Example:

        .. code-block:: python

            # Returns the first do while loop:
            function.do_while_loops[0]
            # Returns the while loop corresponding to the given string:
            function.do_while_loops['do while(1)']

        When there is no such item, it raises ``IndexError``.
        """
        self._parse_function_body()
        return IdentifiedObjectList(self._do_while_loops)
    def for_loops(self):
        """A list of for loops (:class:`.ForLoop`) that the function contains.

        The returned list can be indexed by either positions (0, 1, ...) or
        identification of for loop. Example:

        .. code-block:: python

            # Returns the first for loop:
            function.for_loops[0]
            # Returns the for loop corresponding to the given string:
            function.for_loops['for(int i=0; i<10; i++)']

        When there is no such item, it raises ``IndexError``.
        """
        self._parse_function_body()
        return IdentifiedObjectList(self._for_loops)
    def labels(self):
        """A list of labels (:class:`.Label`) that the function
        contains.

        The returned list can be indexed by either positions (0, 1, ...) or
        identification of label. Example:

        .. code-block:: python

            # Returns the first label:
            function.labels[0]
            # Returns the label corresponding to the given string:
            function.labels['xyz']

        When there is no such item, it raises ``IndexError``.
        """
        self._parse_function_body()
        return IdentifiedObjectList(self._labels)
    def goto_stmts(self):
        """A list of goto statements (:class:`.GotoStmt`) that the function
        contains.

        The returned list can be indexed by either positions (0, 1, ...) or
        identification of goto statement. Example:

        .. code-block:: python

            # Returns the first goto statement:
            function.goto_stmts[0]
            # Returns the goto statement corresponding to the given string:
            function.goto_stmts['goto xyz']

        When there is no such item, it raises ``IndexError``.
        """
        self._parse_function_body()
        return IdentifiedObjectList(self._goto_stmts)
    def var_def_stmts(self):
        """A list of var definition statements (:class:`.VarDefStmt`)
        that the function contains.

        The returned list can be indexed by either positions (0, 1, ...) or
        identification of var definition statement. Example:

        .. code-block:: python

            # Returns the first var definition:
            function.var_def_stmts[0]
            # Returns the var definition corresponding to the given string:
            function.var_def_stmts['int a = 5']

        When there is no such item, it raises ``IndexError``.
        """
        self._parse_function_body()
        return IdentifiedObjectList(self._var_def_stmts)
    def assignments(self):
        """A list of assignments (:class:`.AssignOpExpr`,
        :class:`.CompoundAssignOpExpr`) that the function contains.

        The returned list can be indexed by either positions (0, 1, ...) or
        identification of assignment. Example:

        .. code-block:: python

            # Returns the first assignment:
            function.assignments[0]
            # Returns the assignment corresponding to the given string:
            function.assignments['a = 4']

        When there is no such item, it raises ``IndexError``.
        """
        self._parse_function_body()
        return IdentifiedObjectList(self._assignments)
示例#7
0
 def test_modify_key_works_as_expected(self):
     self.assertEqual(IdentifiedObjectList.modify_key(self, 'a b   c'),
                      'abc')
示例#8
0
 def setUp(self):
     self.items = IdentifiedObjectList([])