00001
00002 #ifndef _VARIABLE_SYMBOL_H
00003 #define _VARIABLE_SYMBOL_H
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
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049
00050
00051
00052 #ifdef POLARIS_GNU_PRAGMAS
00053 #pragma interface
00054 #endif
00055
00056 #ifndef _SYMBOL_H
00057 #include "Symbol.h"
00058 #endif
00059
00060 #include "../SharedDims.h"
00061
00062 class VariableSymbol : public Symbol {
00063 friend class CommonBlock;
00064 friend class PostPass;
00065
00066 protected:
00067 Type _type;
00068 unsigned _formal:1, _saved:1, _initial_value:1, _global:1, _allocatable:1;
00069 Equivalence *_equivalence;
00070 ArrayDims _dim;
00071 SharedDims _shared_dim;
00072 CommonBlock *_common;
00073 virtual void _dims(ArrayDims *);
00074
00075 Expression *_shared_expr;
00076
00077
00078
00079 Symbol *_gsa_base_symbol;
00080
00081
00082
00083 public:
00084 VariableSymbol(const char *name,
00085 const Type & type,
00086 FORMAL_BOOL formal,
00087 SAVED_BOOL saved,
00088 ArrayBounds * bounds1 = 0,
00089 ArrayBounds * bounds2 = 0,
00090 ArrayBounds * bounds3 = 0,
00091 ArrayBounds * bounds4 = 0,
00092 ArrayBounds * bounds5 = 0,
00093 ArrayBounds * bounds6 = 0,
00094 ArrayBounds * bounds7 = 0);
00095
00096
00097
00098
00099
00100
00101
00102
00103
00104
00105
00106
00107
00108
00109
00110 VariableSymbol(const char *name,
00111 const Type & type,
00112 FORMAL_BOOL formal,
00113 SAVED_BOOL saved,
00114 GLOBAL_BOOL global,
00115 ArrayBounds * bounds1 = 0,
00116 ArrayBounds * bounds2 = 0,
00117 ArrayBounds * bounds3 = 0,
00118 ArrayBounds * bounds4 = 0,
00119 ArrayBounds * bounds5 = 0,
00120 ArrayBounds * bounds6 = 0,
00121 ArrayBounds * bounds7 = 0);
00122
00123 VariableSymbol(const char *name,
00124 const Type & type,
00125 FORMAL_BOOL formal,
00126 SAVED_BOOL saved,
00127 GLOBAL_BOOL global,
00128 ArrayDims * dims);
00129
00130 VariableSymbol(const char *name,
00131 const Type & type,
00132 ALLOC_BOOL allocatable,
00133 FORMAL_BOOL formal,
00134 SAVED_BOOL saved,
00135 ArrayBounds * bounds1 = 0,
00136 ArrayBounds * bounds2 = 0,
00137 ArrayBounds * bounds3 = 0,
00138 ArrayBounds * bounds4 = 0,
00139 ArrayBounds * bounds5 = 0,
00140 ArrayBounds * bounds6 = 0,
00141 ArrayBounds * bounds7 = 0);
00142
00143 VariableSymbol(const char *name,
00144 const Type & type,
00145 ALLOC_BOOL allocatable,
00146 FORMAL_BOOL formal,
00147 SAVED_BOOL saved,
00148 GLOBAL_BOOL global,
00149 ArrayBounds * bounds1 = 0,
00150 ArrayBounds * bounds2 = 0,
00151 ArrayBounds * bounds3 = 0,
00152 ArrayBounds * bounds4 = 0,
00153 ArrayBounds * bounds5 = 0,
00154 ArrayBounds * bounds6 = 0,
00155 ArrayBounds * bounds7 = 0);
00156
00157 VariableSymbol(const char *name,
00158 const Type & type,
00159 ALLOC_BOOL allocatable,
00160 FORMAL_BOOL formal,
00161 SAVED_BOOL saved,
00162 GLOBAL_BOOL global,
00163 ArrayDims * dims);
00164
00165 VariableSymbol(const VariableSymbol & vsym);
00166
00167 VariableSymbol & operator = (const VariableSymbol & vsym);
00168
00169 bool is_gsa_symbol() const;
00170
00171
00172 Symbol & gsa_base_symbol() const ;
00173
00174
00175 void gsa_base_symbol( Symbol & base_ptr );
00176
00177
00178 virtual Symbol *clone() const;
00179
00180
00181
00182 virtual Symbol *clone_all() const;
00183
00184
00185
00186 virtual ~VariableSymbol();
00187
00188 virtual const Type & type() const;
00189 virtual void type(const Type & type);
00190
00191 virtual Equivalence *equivalence_ref() const;
00192 virtual void equivalence(Equivalence & e, int byte_base);
00193 virtual void clear_equivalence();
00194
00195 virtual const ArrayDims & dim() const;
00196 virtual ArrayDims & dim() ;
00197
00198 virtual const SharedDims & shared_dim() const;
00199 virtual SharedDims & shared_dim() ;
00200
00201 virtual INITIAL_BOOL initial_value() const;
00202 virtual void initial_value(INITIAL_BOOL ourbool);
00203
00204 virtual ALLOC_BOOL allocatable() const;
00205 virtual void allocatable(ALLOC_BOOL ourbool);
00206
00207 virtual FORMAL_BOOL formal() const;
00208 virtual void formal(FORMAL_BOOL ourbool);
00209
00210 virtual SAVED_BOOL saved() const;
00211 virtual void saved(SAVED_BOOL ourbool);
00212
00213 virtual GLOBAL_BOOL global() const;
00214 virtual void global(GLOBAL_BOOL ourbool);
00215
00216 virtual const CommonBlock *common_ref() const;
00217 virtual CommonBlock *common_ref() ;
00218
00219 virtual void common(CommonBlock & cb, int index);
00220
00221
00222
00223
00224
00225
00226
00227
00228
00229
00230 virtual void shared_expr(Expression *shared);
00231
00232
00233 virtual void set_to_private();
00234
00235 virtual Expression *shared_expr() const;
00236
00237
00238
00239
00240
00241 virtual void clear_common();
00242
00243 virtual int is_scalar() const;
00244
00245 virtual int is_array() const;
00246
00247 virtual int is_shared() const;
00248
00249 virtual int is_pointer() const;
00250
00251 virtual int size() const;
00252
00253
00254 virtual void print(ostream & o) const;
00255
00256
00257 virtual void fill_in(const BinRep & binstr,
00258 ExprTable & exprs,
00259 const Dictionary<VoidPtrDef>&stmts,
00260 const Dictionary<VoidPtrDef>&commons,
00261 const Dictionary<VoidPtrDef>&equivalences);
00262
00263
00264 int structures_OK() const;
00265
00266
00267
00268
00269 virtual void exchange_convert( VDL &vdl );
00270
00271
00272 virtual void relink_dptrs(ProgramUnit & p);
00273
00274
00275
00276 };
00277
00278 inline
00279 VariableSymbol::VariableSymbol(const VariableSymbol &vsym)
00280 : Symbol(vsym._tag, VARIABLE_CLASS)
00281 {
00282 *this = vsym;
00283 }
00284
00285 inline int
00286 VariableSymbol::is_pointer() const
00287 {
00288 return 0;
00289 }
00290
00291 inline void
00292 VariableSymbol::_dims (ArrayDims * dims)
00293 {
00294 _dim = *dims;
00295 }
00296
00297 inline bool
00298 VariableSymbol::is_gsa_symbol( ) const
00299 {
00300 if (_gsa_base_symbol)
00301 return true;
00302 else
00303 return false;
00304 }
00305
00306 inline Symbol &
00307 VariableSymbol::gsa_base_symbol() const
00308 {
00309 return *_gsa_base_symbol;
00310 }
00311
00312 inline void
00313 VariableSymbol::gsa_base_symbol( Symbol & base_ptr )
00314 {
00315 _gsa_base_symbol = &base_ptr;
00316 }
00317 #endif