dma: bump man page date
[dragonfly.git] / contrib / gcc-4.4 / gcc / tree-iterator.h
blob98f0cf80c491f51708996fc70727a25ceeedc123
1 /* Iterator routines for manipulating GENERIC and GIMPLE tree statements.
2 Copyright (C) 2003, 2004, 2007 Free Software Foundation, Inc.
3 Contributed by Andrew MacLeod <amacleod@redhat.com>
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation; either version 3, or (at your option)
10 any later version.
12 GCC is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
17 You should have received a copy of the GNU General Public License
18 along with GCC; see the file COPYING3. If not see
19 <http://www.gnu.org/licenses/>. */
22 /* This file is dependent upon the implementation of tree's. It provides an
23 abstract interface to the tree objects such that if all tree creation and
24 manipulations are done through this interface, we can easily change the
25 implementation of tree's, and not impact other code. */
27 #ifndef GCC_TREE_ITERATOR_H
28 #define GCC_TREE_ITERATOR_H 1
30 /* Iterator object for GENERIC or GIMPLE TREE statements. */
32 typedef struct {
33 struct tree_statement_list_node *ptr;
34 tree container;
35 } tree_stmt_iterator;
37 static inline tree_stmt_iterator
38 tsi_start (tree t)
40 tree_stmt_iterator i;
42 i.ptr = STATEMENT_LIST_HEAD (t);
43 i.container = t;
45 return i;
48 static inline tree_stmt_iterator
49 tsi_last (tree t)
51 tree_stmt_iterator i;
53 i.ptr = STATEMENT_LIST_TAIL (t);
54 i.container = t;
56 return i;
59 static inline bool
60 tsi_end_p (tree_stmt_iterator i)
62 return i.ptr == NULL;
65 static inline bool
66 tsi_one_before_end_p (tree_stmt_iterator i)
68 return i.ptr != NULL && i.ptr->next == NULL;
71 static inline void
72 tsi_next (tree_stmt_iterator *i)
74 i->ptr = i->ptr->next;
77 static inline void
78 tsi_prev (tree_stmt_iterator *i)
80 i->ptr = i->ptr->prev;
83 static inline tree *
84 tsi_stmt_ptr (tree_stmt_iterator i)
86 return &i.ptr->stmt;
89 static inline tree
90 tsi_stmt (tree_stmt_iterator i)
92 return i.ptr->stmt;
95 enum tsi_iterator_update
97 TSI_NEW_STMT, /* Only valid when single statement is added, move
98 iterator to it. */
99 TSI_SAME_STMT, /* Leave the iterator at the same statement. */
100 TSI_CHAIN_START, /* Only valid when chain of statements is added, move
101 iterator to the first statement in the chain. */
102 TSI_CHAIN_END, /* Only valid when chain of statements is added, move
103 iterator to the last statement in the chain. */
104 TSI_CONTINUE_LINKING /* Move iterator to whatever position is suitable for
105 linking other statements/chains of statements in
106 the same direction. */
109 extern void tsi_link_before (tree_stmt_iterator *, tree,
110 enum tsi_iterator_update);
111 extern void tsi_link_after (tree_stmt_iterator *, tree,
112 enum tsi_iterator_update);
114 void tsi_delink (tree_stmt_iterator *);
116 tree tsi_split_statement_list_after (const tree_stmt_iterator *);
117 tree tsi_split_statement_list_before (tree_stmt_iterator *);
119 void append_to_statement_list (tree, tree *);
120 void append_to_statement_list_force (tree, tree *);
122 #endif /* GCC_TREE_ITERATOR_H */