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 );
00116 virtual int IsWidthConstant( void );
00122 virtual int IsWidthVolatile( void );
00127 virtual int IsWidthEvaluateable( void );
00132 virtual INT32 GetWidth( void );
00137 virtual CNode* GetRange();
00142 Decl_t Direction() { return direction; }
00147 void Direction( Decl_t d ) { direction = d; }
00152 void Lval( int aLval ) { lval = aLval; }
00157 int Lval() { return lval; }
00162 void IsArray( int v ) { isArray = v; }
00167 int IsArray() { return isArray; }
00172 int IndicesRangeValid();
00178 void ConstrainTypes( list<Decl_t>& aTypes ) {
00179 list<Decl_t> types(aTypes);
00180
00181 list<Decl_t>::iterator ptr;
00182 for( ptr = aTypes.begin(); ptr != aTypes.end(); ++ptr ) {
00183 CDecl::GetMembers( *ptr, types );
00184 }
00185 if( typeConstraints.size() == 0 ) {
00186 MASSERT( !constrained );
00187 set_union( types.begin(), types.end(),
00188 typeConstraints.begin(), typeConstraints.end(),
00189 inserter( typeConstraints,
00190 typeConstraints.begin() ) );
00191 } else {
00192 set_intersection( types.begin(), types.end(),
00193 typeConstraints.begin(), typeConstraints.end(),
00194 inserter( typeConstraints,
00195 typeConstraints.begin() ) );
00196 }
00197 constrained = TRUE;
00198 }
00204 int IsTypeValid( Decl_t t ) {
00205 if( !constrained ) {
00206 MASSERT( typeConstraints.size() == 0 );
00207 return TRUE;
00208 }
00209 list<Decl_t> searchList;
00210 CDecl::GetMembers( t, searchList );
00211 list<Decl_t>::iterator ptr;
00212 if( typeConstraints.count( t ) != 0 ) {
00213 return TRUE;
00214 }
00215 for( ptr = searchList.begin();
00216 ptr != searchList.end(); ++ptr ) {
00217 if( typeConstraints.count( *ptr ) != 0 ) {
00218 return TRUE;
00219 }
00220 }
00221 return FALSE;
00222 }
00227 virtual void Dump( FILE* f );
00228 private:
00232 void SetRange( CNode* ) { MASSERT( FALSE ); }
00233 CFref( const CFref& );
00234 };
00235
00236 #endif // CFREF_HPP