1 /* Array and structure constructors
2 Copyright (C) 2009, 2010
3 Free Software Foundation, Inc.
5 This file is part of GCC.
7 GCC is free software; you can redistribute it and/or modify it under
8 the terms of the GNU General Public License as published by the Free
9 Software Foundation; either version 3, or (at your option) any later
12 GCC is distributed in the hope that it will be useful, but WITHOUT ANY
13 WARRANTY; without even the implied warranty of MERCHANTABILITY or
14 FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
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/>. */
21 #ifndef GFC_CONSTRUCTOR_H
22 #define GFC_CONSTRUCTOR_H
24 /* Get a new constructor structure. */
25 gfc_constructor
*gfc_constructor_get (void);
27 gfc_constructor_base
gfc_constructor_get_base (void);
29 /* Copy a constructor structure. */
30 gfc_constructor_base
gfc_constructor_copy (gfc_constructor_base base
);
33 /* Free a gfc_constructor structure. */
34 void gfc_constructor_free (gfc_constructor_base base
);
37 /* Given an constructor structure, append the expression node onto
38 the constructor. Returns the constructor node appended. */
39 gfc_constructor
*gfc_constructor_append (gfc_constructor_base
*base
,
42 gfc_constructor
*gfc_constructor_append_expr (gfc_constructor_base
*base
,
43 gfc_expr
*e
, locus
*where
);
46 /* Given an constructor structure, place the expression node at position.
47 Returns the constructor node inserted. */
48 gfc_constructor
*gfc_constructor_insert (gfc_constructor_base
*base
,
49 gfc_constructor
*c
, int n
);
51 gfc_constructor
*gfc_constructor_insert_expr (gfc_constructor_base
*base
,
52 gfc_expr
*e
, locus
*where
,
55 /* Given an array constructor expression and an element number (starting
56 at zero), return a pointer to the array element. NULL is returned if
57 the size of the array has been exceeded. The expression node returned
58 remains a part of the array and should not be freed. */
60 gfc_constructor
*gfc_constructor_lookup (gfc_constructor_base base
, int n
);
62 /* Convenience function. Same as ...
63 gfc_constructor *c = gfc_constructor_lookup (base, n);
64 gfc_expr *e = c ? c->expr : NULL;
66 gfc_expr
*gfc_constructor_lookup_expr (gfc_constructor_base base
, int n
);
69 int gfc_constructor_expr_foreach (gfc_constructor
*ctor
, int(*)(gfc_expr
*));
72 void gfc_constructor_swap (gfc_constructor
*ctor
, int n
, int m
);
76 /* Get the first constructor node in the constructure structure.
77 Returns NULL if there is no such expression. */
78 gfc_constructor
*gfc_constructor_first (gfc_constructor_base base
);
80 /* Get the next constructor node in the constructure structure.
81 Returns NULL if there is no next expression. */
82 gfc_constructor
*gfc_constructor_next (gfc_constructor
*ctor
);
84 gfc_constructor
*gfc_constructor_advance (gfc_constructor
*ctor
, int n
);
86 #endif /* GFC_CONSTRUCTOR_H */