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 );
00115 virtual CNode* GetRange();
00120 Decl_t Direction() { return direction; }
00125 void Direction( Decl_t d ) { direction = d; }
00130 void Lval( int aLval ) { lval = aLval; }
00135 int Lval() { return lval; }
00140 void IsArray( int v ) { isArray = v; }
00145 int IsArray() { return isArray; }
00150 int IndicesRangeValid();
00156 void ConstrainTypes( list<Decl_t>& aTypes ) {
00157 list<Decl_t> types(aTypes);
00158
00159 list<Decl_t>::iterator ptr;
00160 for( ptr = aTypes.begin(); ptr != aTypes.end(); ++ptr ) {
00161 CDecl::GetMembers( *ptr, types );
00162 }
00163 if( typeConstraints.size() == 0 ) {
00164 MASSERT( !constrained );
00165 set_union( types.begin(), types.end(),
00166 typeConstraints.begin(), typeConstraints.end(),
00167 inserter( typeConstraints,
00168 typeConstraints.begin() ) );
00169 } else {
00170 set_intersection( types.begin(), types.end(),
00171 typeConstraints.begin(), typeConstraints.end(),
00172 inserter( typeConstraints,
00173 typeConstraints.begin() ) );
00174 }
00175 constrained = TRUE;
00176 }
00182 int IsTypeValid( Decl_t t ) {
00183 if( !constrained ) {
00184 MASSERT( typeConstraints.size() == 0 );
00185 return TRUE;
00186 }
00187 list<Decl_t> searchList;
00188 CDecl::GetMembers( t, searchList );
00189 list<Decl_t>::iterator ptr;
00190 if( typeConstraints.count( t ) != 0 ) {
00191 return TRUE;
00192 }
00193 for( ptr = searchList.begin();
00194 ptr != searchList.end(); ++ptr ) {
00195 if( typeConstraints.count( *ptr ) != 0 ) {
00196 return TRUE;
00197 }
00198 }
00199 return FALSE;
00200 }
00205 virtual void Dump( FILE* f );
00206 private:
00210 void SetRange( CNode* ) { MASSERT( FALSE ); }
00211 CFref( const CFref& );
00212 };
00213
00214 #endif // CFREF_HPP