1 /* Implementation of Fortran type abstraction
2 Copyright (C) 1995 Free Software Foundation, Inc.
3 Contributed by James Craig Burley.
5 This file is part of GNU Fortran.
7 GNU Fortran 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 2, or (at your option)
12 GNU Fortran 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 GNU Fortran; see the file COPYING. If not, write to
19 the Free Software Foundation, 59 Temple Place - Suite 330, Boston, MA
27 /* Look up a type given its base type and kind value. */
30 ffetype_lookup_kind (ffetype base_type
, int kind
)
32 if ((base_type
->kinds_
== NULL
)
34 || (((size_t) kind
) >= ARRAY_SIZE (base_type
->kinds_
->type_
)))
37 return base_type
->kinds_
->type_
[kind
];
41 ffetype_lookup_star (ffetype base_type
, int star
)
43 if ((base_type
->stars_
== NULL
)
45 || (((size_t) star
) >= ARRAY_SIZE (base_type
->stars_
->type_
)))
48 return base_type
->stars_
->type_
[star
];
56 type
= (ffetype
) malloc_new_kp (malloc_pool_image (), "ffetype",
68 ffetype_set_kind (ffetype base_type
, int kind
, ffetype type
)
70 assert (kind
< (int) sizeof (*(base_type
->kinds_
)));
72 if (base_type
->kinds_
== NULL
)
77 = (ffetype_indexes_
) malloc_new_kp (malloc_pool_image (),
78 "ffetype_indexes_[kinds]",
79 sizeof (*(base_type
->kinds_
)));
80 for (i
= 0; ((size_t) i
) < ARRAY_SIZE (base_type
->kinds_
->type_
); ++i
)
81 base_type
->kinds_
->type_
[i
] = NULL
;
84 assert (base_type
->kinds_
->type_
[kind
] == NULL
);
86 base_type
->kinds_
->type_
[kind
] = type
;
90 ffetype_set_star (ffetype base_type
, int star
, ffetype type
)
92 if (base_type
->stars_
== NULL
)
97 = (ffetype_indexes_
) malloc_new_kp (malloc_pool_image (),
98 "ffetype_indexes_[stars]",
99 sizeof (*(base_type
->stars_
)));
100 for (i
= 0; ((size_t) i
) < ARRAY_SIZE (base_type
->stars_
->type_
); ++i
)
101 base_type
->stars_
->type_
[i
] = NULL
;
104 assert (base_type
->stars_
->type_
[star
] == NULL
);
106 base_type
->stars_
->type_
[star
] = type
;