00001 #ifndef COMPOSITE_LITERAL_HH
00002 #define COMPOSITE_LITERAL_HH
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014 #include "tyvis/LValue.hh"
00015 #include "tyvis/UniversalInteger.hh"
00016
00017 class TyvisVarArgs;
00018 class CompositeTypeInfo;
00019 class SubElementFactory;
00020 class ArrayTypeInfo;
00021 class RecordTypeInfo;
00022 class ScalarTypeInfo;
00023
00024 class CompositeLiteral : public LValue {
00025 public:
00026 CompositeLiteral();
00027 CompositeLiteral( const CompositeTypeInfo &initTypeInfo );
00028
00029 CompositeLiteral( const TypeInfo &initTypeInfo,
00030 const RValue &initValue );
00031
00032 CompositeLiteral( const CompositeTypeInfo &initTypeInfo,
00033 TyvisVarArgs &initValue );
00034
00035 CompositeLiteral( TyvisVarArgs &initValue );
00036
00037
00038 CompositeLiteral( const SubElementFactory &subElementFactory );
00039 CompositeLiteral( const ArrayTypeInfo &typeInfo,
00040 const string &initValue );
00041 CompositeLiteral( const ArrayTypeInfo &typeInfo,
00042 const RValue &initValue );
00043 CompositeLiteral( const CompositeLiteral &that );
00044
00050 CompositeLiteral( CompositeLiteral &that,
00051 const ScalarTypeInfo &sliceSpecifier );
00052
00053 ~CompositeLiteral();
00054
00055 int getIntValue() const;
00056 LONG getInt64Value() const;
00057 double getDoubleValue() const;
00058
00059 bool isScalarType() const { return false; }
00060 bool isCompositeType() const { return true; }
00061
00062 RValue &operator=( const RValue &that );
00063 CompositeLiteral &operator=( const CompositeLiteral &that );
00064
00065 bool operator==( const RValue & ) const;
00066 bool operator!= (const RValue & ) const;
00067 bool operator> (const RValue &) const;
00068 bool operator>= (const RValue &) const;
00069 bool operator< (const RValue &) const;
00070 bool operator<= (const RValue &) const;
00071
00072 const TypeInfo &getTypeInfo() const;
00073 const TypeInfo &getElementTypeInfo( const RValue &index = defaultIndex() ) const;
00074 const ScalarTypeInfo &getIndexTypeInfo( const RValue &index = defaultIndex() ) const;
00075
00076 const RValue &operator[]( int index ) const;
00077 RValue &operator[]( int index );
00078 const RValue &operator[]( const RValue &index ) const;
00079 RValue &operator[]( const RValue &index );
00080
00081 RValue &getField( int index );
00082 const RValue &getField( int index ) const;
00083 const RValue &getField( const RValue &index ) const;
00084 RValue &getField( const RValue &index );
00085
00089 void append( const RValue &newElement );
00090
00091 Value vhdlPlus( const RValue & ) const;
00092 Value vhdlMinus( const RValue & ) const;
00093 Value vhdlMultiply( const RValue & ) const;
00094 Value vhdlDivide( const RValue & ) const;
00095 Value vhdlMod( const RValue & ) const;
00096 Value vhdlRem( const RValue & ) const;
00097 Value vhdlPow( const RValue & ) const;
00098 Value vhdlAnd( const RValue &rhs) const;
00099 Value vhdlOr( const RValue &rhs) const;
00100 Value vhdlNand( const RValue &rhs) const;
00101 Value vhdlNor( const RValue &rhs) const;
00102 Value vhdlXor( const RValue &rhs) const;
00103 Value vhdlXnor( const RValue &rhs) const;
00104 Value vhdlNot() const;
00105 Value vhdlSll( const RValue &rhs ) const;
00106 Value vhdlSrl( const RValue &rhs ) const;
00107 Value vhdlSla( const RValue &rhs ) const;
00108 Value vhdlSra( const RValue &rhs ) const;
00109 Value vhdlRol( const RValue &rhs ) const;
00110 Value vhdlRor( const RValue &rhs ) const;
00111 Value vhdlConcatenate( const RValue &rhs ) const;
00112
00113 const RValue &readVal() const;
00114 RValue &readVal();
00115
00116 bool isPhysicalType() const { return false; }
00117 const string &getUnit() const;
00118 LONG getValue() const;
00119 int getUnits() const;
00120 const EnumerationLiteral &vhdlEqual( const RValue & ) const;
00121 const EnumerationLiteral &vhdlNotEqual( const RValue & ) const;
00122 const EnumerationLiteral &vhdlGreaterThan( const RValue & ) const;
00123 const EnumerationLiteral &vhdlGreaterThanEqual( const RValue & ) const;
00124 const EnumerationLiteral &vhdlLessThan( const RValue & ) const;
00125 const EnumerationLiteral &vhdlLessThanEqual( const RValue & ) const;
00126
00127 RValue &all();
00128 const RValue &all() const;
00129 void updateVal( const RValue & );
00130
00131 SignalNetinfo &addToFanOut( VHDLKernel * );
00132
00133 SignalNetinfo &addChild( SignalNetinfo &, VHDLKernel * );
00134
00136
00137 Value left( const RValue ¶m = defaultIndex() ) const;
00138 Value right( const RValue ¶m = defaultIndex() ) const;
00139 Value high( const RValue ¶m = defaultIndex() ) const;
00140 Value low( const RValue ¶m = defaultIndex() ) const;
00141 const ScalarTypeInfo &range( const RValue &index = defaultIndex() ) const;
00142 const ScalarTypeInfo &reverse_range( const RValue &index = defaultIndex() ) const;
00143 Value length( const RValue &index = defaultIndex() ) const;
00144 Value ascending( const RValue &index = defaultIndex() ) const;
00146
00147 protected:
00152 void append( RValue *newElement );
00153
00158 void shiftLogical( int shiftAmount );
00159
00160 static const UniversalInteger &defaultIndex();
00161
00162 private:
00168 const ScalarTypeInfo &CompositeLiteral::divineIndexTypeInfo() const;
00169
00174 int storageIndex( int elementIndex ) const;
00175
00176 void cloneElements( const vector<RValue *> &thatElements );
00177
00178 static void buildElements( const CompositeTypeInfo &arrayTypeInfo,
00179 vector<RValue *> &elements,
00180 const SubElementFactory *subElementFactory,
00181 int numElements = -1 );
00182
00186 void destroyElements();
00187
00192 void insertElements( const string &initElements );
00193
00197 void insertElements( const RValue &initElements );
00198
00207 void sliceElements( CompositeLiteral &that );
00208
00209 static CompositeTypeInfo *buildSliceTypeInfo( CompositeLiteral &that,
00210 const ScalarTypeInfo &sliceSpecifier );
00211
00212 const CompositeTypeInfo *myTypeInfo;
00218 mutable const ScalarTypeInfo *indexTypeInfo;
00219
00221 vector<RValue *> myElements;
00222 bool deleteMembers;
00223 const SubElementFactory *myFactory;
00224
00229 Value bitOperation( const RValue &rhs,
00230 Value (EnumerationLiteral::*operation)(const RValue &) const
00231 ) const;
00232 };
00233
00234 #endif