Go to the documentation of this file.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 #ifndef CFREF_HPP
00032 #define CFREF_HPP
00033
00034 #include <stdio.h>
00035 #include <set>
00036 #include <list>
00037 #include <algorithm>
00038 #include "glue.h"
00039 #include "cnode.h"
00040 #include "cdecl.h"
00041
00042
00043 class CNode;
00044
00051 class CFref : public CDecl
00052 {
00053 private:
00054 CDecl* decl;
00055 Decl_t direction;
00056 int constrained;
00057 set<Decl_t> typeConstraints;
00058 CNode* msb;
00059 CNode* lsb;
00060 int lval;
00061
00062 int isArray;
00063 int lsbVolatile;
00064 int msbVolatile;
00065 int lsbConstant;
00066 int msbConstant;
00067 int isInconsistant;
00068
00069 int currentDirection;
00070
00071 int refCount;
00072 public:
00078 CFref( CSymbol* symbol, Coord_t* aLoc );
00084 virtual CDecl* Clone( CObstack* heap ) { MASSERT(FALSE); }
00089 void SetDecl( CDecl* aDecl );
00094 CDecl* GetDecl( void );
00100 void SetRangeInfo( int isArray, CNode* range );
00105 CNode* GetMsb( void );
00110 CNode* GetLsb( void );
00114 void DisableWidthInferencing() { isInconsistant = TRUE; }
00120 virtual int IsWidthConstant( void );
00126 virtual int IsWidthVolatile( void );
00131 virtual int IsWidthEvaluateable( void );
00136 virtual INT32 GetWidth( void );
00141 virtual CNode* GetRange();
00146 Decl_t Direction() { return direction; }
00151 void Direction( Decl_t d ) { direction = d; }
00156 void Lval( int aLval ) { lval = aLval; }
00161 int Lval() { return lval; }
00166 void IsArray( int v ) { isArray = v; }
00171 int IsArray() { return isArray; }
00176 int IndicesRangeValid();
00182 void ConstrainTypes( list<Decl_t>& aTypes ) {
00183 list<Decl_t> types(aTypes);
00184
00185 list<Decl_t>::iterator ptr;
00186 for( ptr = aTypes.begin(); ptr != aTypes.end(); ++ptr ) {
00187 CDecl::GetMembers( *ptr, types );
00188 }
00189 if( typeConstraints.size() == 0 ) {
00190 MASSERT( !constrained );
00191 set_union( types.begin(), types.end(),
00192 typeConstraints.begin(), typeConstraints.end(),
00193 inserter( typeConstraints,
00194 typeConstraints.begin() ) );
00195 } else {
00196 set_intersection( types.begin(), types.end(),
00197 typeConstraints.begin(), typeConstraints.end(),
00198 inserter( typeConstraints,
00199 typeConstraints.begin() ) );
00200 }
00201 constrained = TRUE;
00202 }
00208 int IsTypeValid( Decl_t t ) {
00209 if( !constrained ) {
00210 MASSERT( typeConstraints.size() == 0 );
00211 return TRUE;
00212 }
00213 list<Decl_t> searchList;
00214 CDecl::GetMembers( t, searchList );
00215 list<Decl_t>::iterator ptr;
00216 if( typeConstraints.count( t ) != 0 ) {
00217 return TRUE;
00218 }
00219 for( ptr = searchList.begin();
00220 ptr != searchList.end(); ++ptr ) {
00221 if( typeConstraints.count( *ptr ) != 0 ) {
00222 return TRUE;
00223 }
00224 }
00225 return FALSE;
00226 }
00231 virtual void Dump( FILE* f );
00232 private:
00236 void SetRange( CNode* ) { MASSERT( FALSE ); }
00237 CFref( const CFref& );
00238 };
00239
00240 #endif // CFREF_HPP