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 );
00083 void SetDecl( CDecl* aDecl );
00088 CDecl* GetDecl( void );
00094 void SetRangeInfo( int isArray, CNode* range );
00099 CNode* GetMsb( void );
00104 CNode* GetLsb( void );
00109 virtual CNode* GetRange();
00114 Decl_t Direction() { return direction; }
00119 void Direction( Decl_t d ) { direction = d; }
00124 void Lval( int aLval ) { lval = aLval; }
00129 int Lval() { return lval; }
00134 void IsArray( int v ) { isArray = v; }
00139 int IsArray() { return isArray; }
00144 int IndicesRangeValid();
00150 void ConstrainTypes( list<Decl_t>& aTypes ) {
00151 list<Decl_t> types(aTypes);
00152
00153 list<Decl_t>::iterator ptr;
00154 for( ptr = aTypes.begin(); ptr != aTypes.end(); ++ptr ) {
00155 CDecl::GetMembers( *ptr, types );
00156 }
00157 if( typeConstraints.size() == 0 ) {
00158 MASSERT( !constrained );
00159 set_union( types.begin(), types.end(),
00160 typeConstraints.begin(), typeConstraints.end(),
00161 inserter( typeConstraints,
00162 typeConstraints.begin() ) );
00163 } else {
00164 set_intersection( types.begin(), types.end(),
00165 typeConstraints.begin(), typeConstraints.end(),
00166 inserter( typeConstraints,
00167 typeConstraints.begin() ) );
00168 }
00169 constrained = TRUE;
00170 }
00176 int IsTypeValid( Decl_t t ) {
00177 if( !constrained ) {
00178 MASSERT( typeConstraints.size() == 0 );
00179 return TRUE;
00180 }
00181 list<Decl_t> searchList;
00182 CDecl::GetMembers( t, searchList );
00183 list<Decl_t>::iterator ptr;
00184 if( typeConstraints.count( t ) != 0 ) {
00185 return TRUE;
00186 }
00187 for( ptr = searchList.begin();
00188 ptr != searchList.end(); ++ptr ) {
00189 if( typeConstraints.count( *ptr ) != 0 ) {
00190 return TRUE;
00191 }
00192 }
00193 return FALSE;
00194 }
00199 virtual void Dump( FILE* f );
00200 private:
00204 void SetRange( CNode* ) { MASSERT( FALSE ); }
00205 };
00206
00207 #endif // CFREF_HPP