Mention KTR_IFQ and KTR_IF_START
[dragonfly.git] / contrib / gcc-3.4 / gcc / f / type.c
1 /* Implementation of Fortran type abstraction
2    Copyright (C) 1995 Free Software Foundation, Inc.
3    Contributed by James Craig Burley.
4
5 This file is part of GNU Fortran.
6
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.
11
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.
16
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.  */
21
22 #include "proj.h"
23 #include "type.h"
24 #include "malloc.h"
25 \f
26
27 /* Look up a type given its base type and kind value.  */
28
29 ffetype
30 ffetype_lookup_kind (ffetype base_type, int kind)
31 {
32   if ((base_type->kinds_ == NULL)
33       || (kind < 0)
34       || (((size_t) kind) >= ARRAY_SIZE (base_type->kinds_->type_)))
35     return NULL;
36
37   return base_type->kinds_->type_[kind];
38 }
39
40 ffetype
41 ffetype_lookup_star (ffetype base_type, int star)
42 {
43   if ((base_type->stars_ == NULL)
44       || (star < 0)
45       || (((size_t) star) >= ARRAY_SIZE (base_type->stars_->type_)))
46     return NULL;
47
48   return base_type->stars_->type_[star];
49 }
50
51 ffetype
52 ffetype_new (void)
53 {
54   ffetype type;
55
56   type = malloc_new_kp (malloc_pool_image (), "ffetype", sizeof (*type));
57   type->kinds_ = NULL;
58   type->stars_ = NULL;
59   type->alignment_ = 0;
60   type->modulo_ = 0;
61   type->size_ = 0;
62
63   return type;
64 }
65
66 void
67 ffetype_set_kind (ffetype base_type, int kind, ffetype type)
68 {
69   assert (kind < (int) sizeof (*(base_type->kinds_)));
70
71   if (base_type->kinds_ == NULL)
72     {
73       int i;
74
75       base_type->kinds_
76         = malloc_new_kp (malloc_pool_image (), "ffetype_indexes_[kinds]",
77                          sizeof (*(base_type->kinds_)));
78       for (i = 0; ((size_t) i) < ARRAY_SIZE (base_type->kinds_->type_); ++i)
79         base_type->kinds_->type_[i] = NULL;
80     }
81
82   assert (base_type->kinds_->type_[kind] == NULL);
83
84   base_type->kinds_->type_[kind] = type;
85 }
86
87 void
88 ffetype_set_star (ffetype base_type, int star, ffetype type)
89 {
90   if (base_type->stars_ == NULL)
91     {
92       int i;
93
94       base_type->stars_
95         = malloc_new_kp (malloc_pool_image (), "ffetype_indexes_[stars]",
96                          sizeof (*(base_type->stars_)));
97       for (i = 0; ((size_t) i) < ARRAY_SIZE (base_type->stars_->type_); ++i)
98         base_type->stars_->type_[i] = NULL;
99     }
100
101   assert (base_type->stars_->type_[star] == NULL);
102
103   base_type->stars_->type_[star] = type;
104 }