00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036 #include "proj.h"
00037 #include "info.h"
00038 #include "target.h"
00039 #include "type.h"
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052
00053
00054
00055
00056
00057
00058 static const char *const ffeinfo_basictype_string_[]
00059 =
00060 {
00061 #define FFEINFO_BASICTYPE(KWD,LNAM,SNAM) SNAM,
00062 #include "info-b.def"
00063 #undef FFEINFO_BASICTYPE
00064 };
00065 static const char *const ffeinfo_kind_message_[]
00066 =
00067 {
00068 #define FFEINFO_KIND(kwd,msgid,snam) msgid,
00069 #include "info-k.def"
00070 #undef FFEINFO_KIND
00071 };
00072 static const char *const ffeinfo_kind_string_[]
00073 =
00074 {
00075 #define FFEINFO_KIND(KWD,LNAM,SNAM) SNAM,
00076 #include "info-k.def"
00077 #undef FFEINFO_KIND
00078 };
00079 static ffeinfoBasictype ffeinfo_combine_[FFEINFO_basictype][FFEINFO_basictype];
00080 static const char *const ffeinfo_kindtype_string_[]
00081 =
00082 {
00083 "",
00084 "1",
00085 "2",
00086 "3",
00087 "4",
00088 "5",
00089 "6",
00090 "7",
00091 "8",
00092 "*",
00093 };
00094 static const char *const ffeinfo_where_string_[]
00095 =
00096 {
00097 #define FFEINFO_WHERE(KWD,LNAM,SNAM) SNAM,
00098 #include "info-w.def"
00099 #undef FFEINFO_WHERE
00100 };
00101 static ffetype ffeinfo_types_[FFEINFO_basictype][FFEINFO_kindtype];
00102
00103
00104
00105
00106
00107
00108
00109
00110
00111
00112
00113
00114
00115
00116 ffeinfoBasictype
00117 ffeinfo_basictype_combine (ffeinfoBasictype l, ffeinfoBasictype r)
00118 {
00119 assert (l < FFEINFO_basictype);
00120 assert (r < FFEINFO_basictype);
00121 return ffeinfo_combine_[l][r];
00122 }
00123
00124
00125
00126
00127
00128
00129
00130
00131 const char *
00132 ffeinfo_basictype_string (ffeinfoBasictype basictype)
00133 {
00134 if (basictype >= ARRAY_SIZE (ffeinfo_basictype_string_))
00135 return "?\?\?";
00136 return ffeinfo_basictype_string_[basictype];
00137 }
00138
00139
00140
00141
00142
00143 void
00144 ffeinfo_init_0 ()
00145 {
00146 ffeinfoBasictype i;
00147 ffeinfoBasictype j;
00148
00149 assert (FFEINFO_basictype == ARRAY_SIZE (ffeinfo_basictype_string_));
00150 assert (FFEINFO_kind == ARRAY_SIZE (ffeinfo_kind_message_));
00151 assert (FFEINFO_kind == ARRAY_SIZE (ffeinfo_kind_string_));
00152 assert (FFEINFO_kindtype == ARRAY_SIZE (ffeinfo_kindtype_string_));
00153 assert (FFEINFO_where == ARRAY_SIZE (ffeinfo_where_string_));
00154
00155
00156
00157 for (i = 0; i < FFEINFO_basictype; ++i)
00158 for (j = 0; j < FFEINFO_basictype; ++j)
00159 if ((i == FFEINFO_basictypeANY) || (j == FFEINFO_basictypeANY))
00160 ffeinfo_combine_[i][j] = FFEINFO_basictypeANY;
00161 else
00162 ffeinfo_combine_[i][j] = FFEINFO_basictypeNONE;
00163
00164 #define same(bt) ffeinfo_combine_[bt][bt] = bt
00165 #define use2(bt1,bt2) ffeinfo_combine_[bt1][bt2] \
00166 = ffeinfo_combine_[bt2][bt1] = bt2
00167
00168 same (FFEINFO_basictypeINTEGER);
00169 same (FFEINFO_basictypeLOGICAL);
00170 same (FFEINFO_basictypeREAL);
00171 same (FFEINFO_basictypeCOMPLEX);
00172 same (FFEINFO_basictypeCHARACTER);
00173 use2 (FFEINFO_basictypeINTEGER, FFEINFO_basictypeREAL);
00174 use2 (FFEINFO_basictypeINTEGER, FFEINFO_basictypeCOMPLEX);
00175 use2 (FFEINFO_basictypeREAL, FFEINFO_basictypeCOMPLEX);
00176
00177 #undef same
00178 #undef use2
00179 }
00180
00181
00182
00183
00184
00185
00186
00187
00188 const char *
00189 ffeinfo_kind_message (ffeinfoKind kind)
00190 {
00191 if (kind >= ARRAY_SIZE (ffeinfo_kind_message_))
00192 return "?\?\?";
00193 return ffeinfo_kind_message_[kind];
00194 }
00195
00196
00197
00198
00199
00200
00201
00202
00203 const char *
00204 ffeinfo_kind_string (ffeinfoKind kind)
00205 {
00206 if (kind >= ARRAY_SIZE (ffeinfo_kind_string_))
00207 return "?\?\?";
00208 return ffeinfo_kind_string_[kind];
00209 }
00210
00211 ffeinfoKindtype
00212 ffeinfo_kindtype_max(ffeinfoBasictype bt,
00213 ffeinfoKindtype k1,
00214 ffeinfoKindtype k2)
00215 {
00216 if ((bt == FFEINFO_basictypeANY)
00217 || (k1 == FFEINFO_kindtypeANY)
00218 || (k2 == FFEINFO_kindtypeANY))
00219 return FFEINFO_kindtypeANY;
00220
00221 if (ffetype_size (ffeinfo_types_[bt][k1])
00222 > ffetype_size (ffeinfo_types_[bt][k2]))
00223 return k1;
00224 return k2;
00225 }
00226
00227
00228
00229
00230
00231
00232
00233
00234 const char *
00235 ffeinfo_kindtype_string (ffeinfoKindtype kind_type)
00236 {
00237 if (kind_type >= ARRAY_SIZE (ffeinfo_kindtype_string_))
00238 return "?\?\?";
00239 return ffeinfo_kindtype_string_[kind_type];
00240 }
00241
00242 void
00243 ffeinfo_set_type (ffeinfoBasictype basictype, ffeinfoKindtype kindtype,
00244 ffetype type)
00245 {
00246 assert (basictype < FFEINFO_basictype);
00247 assert (kindtype < FFEINFO_kindtype);
00248 assert (ffeinfo_types_[basictype][kindtype] == NULL);
00249
00250 ffeinfo_types_[basictype][kindtype] = type;
00251 }
00252
00253 ffetype
00254 ffeinfo_type (ffeinfoBasictype basictype, ffeinfoKindtype kindtype)
00255 {
00256 assert (basictype < FFEINFO_basictype);
00257 assert (kindtype < FFEINFO_kindtype);
00258
00259 return ffeinfo_types_[basictype][kindtype];
00260 }
00261
00262
00263
00264
00265
00266
00267
00268
00269 const char *
00270 ffeinfo_where_string (ffeinfoWhere where)
00271 {
00272 if (where >= ARRAY_SIZE (ffeinfo_where_string_))
00273 return "?\?\?";
00274 return ffeinfo_where_string_[where];
00275 }
00276
00277
00278
00279
00280
00281
00282
00283
00284
00285 #ifndef __GNUC__
00286 ffeinfo
00287 ffeinfo_new (ffeinfoBasictype basictype, ffeinfoKindtype kindtype,
00288 ffeinfoRank rank, ffeinfoKind kind, ffeinfoWhere where,
00289 ffetargetCharacterSize size)
00290 {
00291 ffeinfo i;
00292
00293 i.basictype = basictype;
00294 i.kindtype = kindtype;
00295 i.rank = rank;
00296 i.size = size;
00297 i.kind = kind;
00298 i.where = where;
00299 i.size = size;
00300
00301 return i;
00302 }
00303 #endif