* config/arm/arm.c (is_load_address): Rename to... (arm_memory_load_p) ... this
[official-gcc.git] / gcc / f / type.c
blob7625cbbaa0ea3ac6f4539c76b5d1bd9af581343c
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)
10 any later version.
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
20 02111-1307, USA. */
22 #include "proj.h"
23 #include "type.h"
24 #include "malloc.h"
27 /* Look up a type given its base type and kind value. */
29 ffetype
30 ffetype_lookup_kind (ffetype base_type, int kind)
32 if ((base_type->kinds_ == NULL)
33 || (kind < 0)
34 || (((size_t) kind) >= ARRAY_SIZE (base_type->kinds_->type_)))
35 return NULL;
37 return base_type->kinds_->type_[kind];
40 ffetype
41 ffetype_lookup_star (ffetype base_type, int star)
43 if ((base_type->stars_ == NULL)
44 || (star < 0)
45 || (((size_t) star) >= ARRAY_SIZE (base_type->stars_->type_)))
46 return NULL;
48 return base_type->stars_->type_[star];
51 ffetype
52 ffetype_new (void)
54 ffetype type;
56 type = (ffetype) malloc_new_kp (malloc_pool_image (), "ffetype",
57 sizeof (*type));
58 type->kinds_ = NULL;
59 type->stars_ = NULL;
60 type->alignment_ = 0;
61 type->modulo_ = 0;
62 type->size_ = 0;
64 return type;
67 void
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)
74 int i;
76 base_type->kinds_
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;
89 void
90 ffetype_set_star (ffetype base_type, int star, ffetype type)
92 if (base_type->stars_ == NULL)
94 int i;
96 base_type->stars_
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;