1 /* Interface definitions for Fortran symbol manager 2 Copyright (C) 1995, 1996 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 #ifndef GCC_F_SYMBOL_H 23 #define GCC_F_SYMBOL_H 24 25 /* The main symbol type. */ 26 27 typedef struct _ffesymbol_ *ffesymbol; 28 29 /* State of understanding about what the symbol represents. */ 30 31 enum _ffesymbol_state_ 32 { 33 /* See ffesymbol_state_is_exec() macro below when making changes. */ 34 FFESYMBOL_stateNONE, /* Never before seen. */ 35 FFESYMBOL_stateSEEN, /* Seen before exec transition and not yet 36 understood (info not filled in, etc). */ 37 FFESYMBOL_stateUNCERTAIN, /* Almost understood (info partly filled in). */ 38 FFESYMBOL_stateUNDERSTOOD, /* Fully understood (info filled in). */ 39 FFESYMBOL_state 40 }; 41 typedef enum _ffesymbol_state_ ffesymbolState; 42 #define ffesymbolState_f "" 43 44 /* Attributes. Symbols acquire attributes while their state is SEEN. 45 These attributes are basically ignored once the symbol becomes 46 UNDERSTOOD. */ 47 48 typedef long int ffesymbolAttrs;/* Holds set of attributes. */ 49 #define ffesymbolAttrs_f "l" 50 51 enum _ffesymbol_attr_ 52 { 53 #define DEFATTR(ATTR,ATTRS,NAME) ATTR, 54 #include "symbol.def" 55 #undef DEFATTR 56 FFESYMBOL_attr 57 }; /* A given attribute. */ 58 typedef enum _ffesymbol_attr_ ffesymbolAttr; 59 #define ffesymbolAttr_f "" 60 61 #define FFESYMBOL_attrsetNONE 0 62 #define FFESYMBOL_attrsetALL (((ffesymbolAttrs) 1 << FFESYMBOL_attr) - 1) 63 64 /* This is just for avoiding complaining about, e.g., "I = IABS(3)", that 65 IABS doesn't meet the requirements for a user-defined symbol name as 66 a result of, say, --symbol-case-lower, if IABS turns out to indeed be 67 a reference to the intrinsic IABS (in which case it's a Fortran keyword 68 like CALL) and not a user-defined name. */ 69 70 enum _ffesymbol_checkstate_ 71 { 72 FFESYMBOL_checkstateNONE_, /* Not checked/never necessary to check. */ 73 FFESYMBOL_checkstateINHIBITED_, /* Bad name, but inhibited. */ 74 FFESYMBOL_checkstatePENDING_, /* Bad name, might be intrinsic. */ 75 FFESYMBOL_checkstateCHECKED_, /* Ok name, intrinsic, or bad name 76 reported. */ 77 FFESYMBOL_checkstate_ 78 }; 79 typedef enum _ffesymbol_checkstate_ ffesymbolCheckState_; 80 #define ffesymbolCheckState_f_ "" 81 82 #include "bld.h" 83 #include "com.h" 84 #include "equiv.h" 85 #include "global.h" 86 #include "info.h" 87 #include "intrin.h" 88 #include "lex.h" 89 #include "malloc.h" 90 #include "name.h" 91 #include "storag.h" 92 #include "target.h" 93 #include "top.h" 94 #include "where.h" 95 96 struct _ffesymbol_ 97 { 98 ffename name; 99 ffename other_space_name; /* For dual-space objects. */ 100 ffeglobal global; /* In filewide name space. */ 101 ffesymbolAttrs attrs; /* What kind of symbol am I? */ 102 ffesymbolState state; /* What state am I in? */ 103 ffeinfo info; /* Info filled in when _stateUNDERSTOOD. */ 104 ffebld dims; /* Dimension list expression. */ 105 ffebld extents; /* Extents list expression. */ 106 ffebld dim_syms; /* List of SYMTERs of all symbols in dims. */ 107 ffebld array_size; /* Size as an expression involving some of 108 dims. */ 109 ffebld init; /* Initialization expression or expr list or 110 PARAMETER value. */ 111 ffebld accretion; /* Initializations seen so far for 112 array/substr. */ 113 ffetargetOffset accretes; /* # inits needed to fill entire array. */ 114 ffebld dummy_args; /* For functions, subroutines, and entry 115 points. */ 116 ffebld namelist; /* List of symbols in NML. */ 117 ffebld common_list; /* List of entities in BCB/NCB. */ 118 ffebld sfunc_expr; /* SFN's expression. */ 119 ffebldListBottom list_bottom; /* For BCB, NCB, NML. */ 120 ffesymbol common; /* Who is my containing COMMON area? */ 121 ffeequiv equiv; /* Who have I been equivalenced with? */ 122 ffestorag storage; /* Where am I in relation to my outside 123 world? */ 124 #ifdef FFECOM_symbolHOOK 125 ffecomSymbol hook; /* Whatever the compiler/backend wants! */ 126 #endif 127 ffesymbol sfa_dummy_parent; /* "X" outside sfunc "CIRC(X) = 3.14 * X". */ 128 ffesymbol func_result; /* FUN sym's corresponding RES sym, & vice 129 versa. */ 130 ffetargetIntegerDefault value; /* IMMEDIATE (DATA impdo) value. */ 131 ffesymbolCheckState_ check_state; /* Valid name? */ 132 ffelexToken check_token; /* checkstatePENDING_ only. */ 133 int max_entry_num; /* For detecting dummy arg listed twice/IMPDO 134 iterator nesting violation; also for id of 135 sfunc dummy arg. */ 136 int num_entries; /* Number of entry points in which this 137 symbol appears as a dummy arg; helps 138 determine whether arg might not be passed, 139 for example. */ 140 ffeintrinGen generic; /* Generic intrinsic id, if any. */ 141 ffeintrinSpec specific; /* Specific intrinsic id, if any. */ 142 ffeintrinImp implementation;/* Implementation id, if any. */ 143 bool is_save; /* SAVE flag set for this symbol (see also 144 ffe_is_saveall()). */ 145 bool is_init; /* INIT flag set for this symbol. */ 146 bool do_iter; /* Is currently a DO-loop iter (can't be 147 changed in loop). */ 148 bool reported; /* (Debug) TRUE if the latest version has 149 been reported. */ 150 bool have_old; /* TRUE if old copy of this symbol saved 151 away. */ 152 bool explicit_where; /* TRUE if INTRINSIC/EXTERNAL explicit. */ 153 bool namelisted; /* TRUE if in NAMELIST (needs static alloc). */ 154 bool assigned; /* TRUE if ever ASSIGNed to. */ 155 }; 156 157 #define ffesymbol_accretes(s) ((s)->accretes) 158 #define ffesymbol_accretion(s) ((s)->accretion) 159 #define ffesymbol_arraysize(s) ((s)->array_size) 160 #define ffesymbol_assigned(s) ((s)->assigned) 161 #define ffesymbol_attr(s,a) ((s)->attrs & ((ffesymbolAttrs) 1 << (a))) 162 #define ffesymbol_attrs(s) ((s)->attrs) 163 const char *ffesymbol_attrs_string (ffesymbolAttrs attrs); 164 #define ffesymbol_basictype(s) ffeinfo_basictype((s)->info) 165 void ffesymbol_check (ffesymbol s, ffelexToken t, bool maybe_intrin); 166 #define ffesymbol_common(s) ((s)->common) 167 #define ffesymbol_commonlist(s) ((s)->common_list) 168 ffesymbol ffesymbol_declare_blockdataunit (ffelexToken t, ffewhereLine wl, 169 ffewhereColumn wc); 170 ffesymbol ffesymbol_declare_cblock (ffelexToken t, ffewhereLine wl, 171 ffewhereColumn wc); 172 ffesymbol ffesymbol_declare_funcnotresunit (ffelexToken t); 173 ffesymbol ffesymbol_declare_funcresult (ffelexToken t); 174 ffesymbol ffesymbol_declare_funcunit (ffelexToken t); 175 ffesymbol ffesymbol_declare_local (ffelexToken t, bool maybe_intrin); 176 ffesymbol ffesymbol_declare_programunit (ffelexToken t, ffewhereLine wl, 177 ffewhereColumn wc); 178 ffesymbol ffesymbol_declare_sfdummy (ffelexToken t); 179 ffesymbol ffesymbol_declare_subrunit (ffelexToken t); 180 #define ffesymbol_dims(s) ((s)->dims) 181 #define ffesymbol_dim_syms(s) ((s)->dim_syms) 182 void ffesymbol_drive (ffesymbol (*fn) (ffesymbol)); 183 void ffesymbol_drive_sfnames (ffesymbol (*fn) (ffesymbol)); 184 #define ffesymbol_dummyargs(s) ((s)->dummy_args) 185 void ffesymbol_error (ffesymbol s, ffelexToken t); 186 #define ffesymbol_equiv(s) ((s)->equiv) 187 #define ffesymbol_explicitwhere(s) ((s)->explicit_where) 188 #define ffesymbol_extents(s) ((s)->extents) 189 #define ffesymbol_first_token(s) ((s)->name == NULL ? NULL \ 190 : ffename_first_token((s)->name)) 191 #define ffesymbol_funcresult(s) ((s)->func_result) 192 #define ffesymbol_generic(s) ((s)->generic) 193 #define ffesymbol_global(s) ((s)->global) 194 #define ffesymbol_hook(s) ((s)->hook) 195 #define ffesymbol_implementation(s) ((s)->implementation) 196 #define ffesymbol_info(s) ((s)->info) 197 #define ffesymbol_init(s) ((s)->init) 198 void ffesymbol_init_0 (void); 199 void ffesymbol_init_1 (void); 200 void ffesymbol_init_2 (void); 201 void ffesymbol_init_3 (void); 202 void ffesymbol_init_4 (void); 203 #define ffesymbol_is_doiter(s) ((s)->do_iter) 204 #define ffesymbol_is_dualspace(s) ((s)->other_space_name != NULL) 205 #define ffesymbol_is_f2c(s) (ffe_is_f2c()) 206 #define ffesymbol_is_init(s) ((s)->is_init) 207 #define ffesymbol_is_reported(s) ((s)->reported) 208 #define ffesymbol_is_save(s) ((s)->is_save) 209 #define ffesymbol_is_specable(s) ffesymbol_state_is_specable(s->state) 210 #define ffesymbol_kindtype(s) ffeinfo_kindtype((s)->info) 211 #define ffesymbol_kind(s) ffeinfo_kind((s)->info) 212 ffesymbol ffesymbol_lookup_local (ffelexToken t); 213 #define ffesymbol_maxentrynum(s) ((s)->max_entry_num) 214 #define ffesymbol_name(s) ((s)->name) 215 #define ffesymbol_namelist(s) ((s)->namelist) 216 #define ffesymbol_namelisted(s) ((s)->namelisted) 217 #define ffesymbol_numentries(s) ((s)->num_entries) 218 #define ffesymbol_ptr_to_commonlist(s) (&(s)->common_list) 219 #define ffesymbol_ptr_to_listbottom(s) (&(s)->list_bottom) 220 #define ffesymbol_ptr_to_namelist(s) (&(s)->namelist) 221 #define ffesymbol_rank(s) ffeinfo_rank((s)->info) 222 void ffesymbol_reference (ffesymbol s, ffelexToken t, bool explicit); 223 void ffesymbol_resolve_intrin (ffesymbol s); 224 void ffesymbol_retract (bool retract); 225 bool ffesymbol_retractable (void); 226 #define ffesymbol_set_accretes(s,a) ((s)->accretes = (a)) 227 #define ffesymbol_set_accretion(s,a) ((s)->accretion = (a)) 228 #define ffesymbol_set_arraysize(s,a) ((s)->array_size = (a)) 229 #define ffesymbol_set_assigned(s,a) ((s)->assigned = (a)) 230 #define ffesymbol_set_attr(s,a) ((s)->attrs |= ((ffesymbolAttrs) 1 << (a))) 231 #define ffesymbol_set_attrs(s,a) ((s)->attrs = (a)) 232 #define ffesymbol_set_common(s,c) ((s)->common = (c)) 233 #define ffesymbol_set_commonlist(s,c) ((s)->common_list = (c)) 234 #define ffesymbol_set_dims(s,d) ((s)->dims = (d)) 235 #define ffesymbol_set_dim_syms(s,d) ((s)->dim_syms = (d)) 236 #define ffesymbol_set_dummyargs(s,d) ((s)->dummy_args = (d)) 237 #define ffesymbol_set_equiv(s,e) ((s)->equiv = (e)) 238 #define ffesymbol_set_explicitwhere(s,e) ((s)->explicit_where = (e)) 239 #define ffesymbol_set_extents(s,e) ((s)->extents = (e)) 240 #define ffesymbol_set_funcresult(s,f) ((s)->func_result = (f)) 241 #define ffesymbol_set_generic(s,g) ((s)->generic = (g)) 242 #define ffesymbol_set_global(s,g) ((s)->global = (g)) 243 #define ffesymbol_set_hook(s,h) ((s)->hook = (h)) 244 #define ffesymbol_set_implementation(s,im) ((s)->implementation = (im)) 245 #define ffesymbol_set_init(s,i) ((s)->init = (i)) 246 #define ffesymbol_set_info(s,i) ((s)->info = (i)) 247 #define ffesymbol_set_is_doiter(s,f) ((s)->do_iter = (f)) 248 #define ffesymbol_set_is_init(s,in) ((s)->is_init = (in)) 249 #define ffesymbol_set_is_save(s,sa) ((s)->is_save = (sa)) 250 #define ffesymbol_set_maxentrynum(s,m) ((s)->max_entry_num = (m)) 251 #define ffesymbol_set_namelist(s,n) ((s)->namelist = (n)) 252 #define ffesymbol_set_namelisted(s,n) ((s)->namelisted = (n)) 253 #define ffesymbol_set_numentries(s,n) ((s)->num_entries = (n)) 254 void ffesymbol_set_retractable (mallocPool pool); 255 #define ffesymbol_set_sfexpr(s,e) ((s)->sfunc_expr = (e)) 256 #define ffesymbol_set_specific(s,sp) ((s)->specific = (sp)) 257 #define ffesymbol_set_state(s,st) ((s)->state = (st)) 258 #define ffesymbol_set_storage(s,st) ((s)->storage = (st)) 259 #define ffesymbol_set_value(s,v) ((s)->value = (v)) 260 #define ffesymbol_sfdummyparent(s) ((s)->sfa_dummy_parent) 261 #define ffesymbol_sfexpr(s) ((s)->sfunc_expr) 262 void ffesymbol_signal_change (ffesymbol s); 263 #define ffesymbol_signal_unreported(s) ((s)->reported = FALSE) 264 #define ffesymbol_size(s) ffeinfo_size((s)->info) 265 #define ffesymbol_specific(s) ((s)->specific) 266 #define ffesymbol_state(s) ((s)->state) 267 #define ffesymbol_state_is_specable(s) ((s) <= FFESYMBOL_stateSEEN) 268 const char *ffesymbol_state_string (ffesymbolState state); 269 #define ffesymbol_storage(s) ((s)->storage) 270 void ffesymbol_terminate_0 (void); 271 void ffesymbol_terminate_1 (void); 272 void ffesymbol_terminate_2 (void); 273 void ffesymbol_terminate_3 (void); 274 void ffesymbol_terminate_4 (void); 275 #define ffesymbol_text(s) (((s)->name == NULL) ? "<->" : ffename_text((s)->name)) 276 void ffesymbol_update_init (ffesymbol s); 277 void ffesymbol_update_save (ffesymbol s); 278 #define ffesymbol_value(s) ((s)->value) 279 #define ffesymbol_where(s) ffeinfo_where((s)->info) 280 #define ffesymbol_where_column(s) (((s)->name == NULL) \ 281 ? ffewhere_column_unknown() : ffename_where_column((s)->name)) 282 #define ffesymbol_where_filename(s) \ 283 ffewhere_line_filename(ffesymbol_where_line(s)) 284 #define ffesymbol_where_filelinenum(s) \ 285 ffewhere_line_filelinenum(ffesymbol_where_line(s)) 286 #define ffesymbol_where_line(s) (((s)->name == NULL) ? ffewhere_line_unknown() \ 287 : ffename_where_line((s)->name)) 288 289 #endif /* ! GCC_F_SYMBOL_H */ 290