Changes in / [9b443c7f:f2e40a9f]
- Location:
- src
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/DeclarationNode.cc
r9b443c7f rf2e40a9f 10 10 // Created On : Sat May 16 12:34:05 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Mar 14 14:45:52201713 // Update Count : 97 312 // Last Modified On : Tue Mar 14 22:42:54 2017 13 // Update Count : 974 14 14 // 15 15 … … 118 118 void DeclarationNode::print_StorageClass( std::ostream & output, StorageClasses storageClasses ) { 119 119 if ( storageClasses.val != 0 ) { // storage classes ? 120 for ( unsigned int i = 0; i < DeclarationNode::N oStorageClass; i += 1 ) {120 for ( unsigned int i = 0; i < DeclarationNode::NumStorageClass; i += 1 ) { 121 121 if ( storageClasses[i] ) { 122 122 output << DeclarationNode::storageClassNames[i] << ' '; … … 128 128 void DeclarationNode::print_FuncSpec( std::ostream & output, DeclarationNode::FuncSpecifiers funcSpec ) { 129 129 if ( funcSpec.val != 0 ) { // function specifiers ? 130 for ( unsigned int i = 0; i < DeclarationNode::N oFuncSpecifier; i += 1 ) {130 for ( unsigned int i = 0; i < DeclarationNode::NumFuncSpecifier; i += 1 ) { 131 131 if ( funcSpec[i] ) { 132 132 output << DeclarationNode::funcSpecifierNames[i] << ' '; … … 460 460 461 461 if ( (qsrc.val & qdst.val) != 0 ) { // duplicates ? 462 for ( unsigned int i = 0; i < N oTypeQualifier; i += 1 ) { // find duplicates462 for ( unsigned int i = 0; i < NumTypeQualifier; i += 1 ) { // find duplicates 463 463 if ( qsrc[i] && qdst[i] ) { 464 464 appendError( error, string( "duplicate " ) + DeclarationNode::typeQualifierNames[i] ); … … 470 470 void DeclarationNode::checkSpecifiers( DeclarationNode * src ) { 471 471 if ( (funcSpecs.val & src->funcSpecs.val) != 0 ) { // duplicates ? 472 for ( unsigned int i = 0; i < N oFuncSpecifier; i += 1 ) { // find duplicates472 for ( unsigned int i = 0; i < NumFuncSpecifier; i += 1 ) { // find duplicates 473 473 if ( funcSpecs[i] && src->funcSpecs[i] ) { 474 474 appendError( error, string( "duplicate " ) + DeclarationNode::funcSpecifierNames[i] ); … … 479 479 if ( storageClasses.val != 0 && src->storageClasses.val != 0 ) { // any reason to check ? 480 480 if ( (storageClasses.val & src->storageClasses.val ) != 0 ) { // duplicates ? 481 for ( unsigned int i = 0; i < N oStorageClass; i += 1 ) { // find duplicates481 for ( unsigned int i = 0; i < NumStorageClass; i += 1 ) { // find duplicates 482 482 if ( storageClasses[i] && src->storageClasses[i] ) { 483 483 appendError( error, string( "duplicate " ) + storageClassNames[i] ); -
src/Parser/ParseNode.h
r9b443c7f rf2e40a9f 10 10 // Created On : Sat May 16 13:28:16 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Mar 14 16:53:19201713 // Update Count : 75 712 // Last Modified On : Tue Mar 14 22:41:37 2017 13 // Update Count : 758 14 14 // 15 15 … … 203 203 // These must remain in the same order as the corresponding DeclarationNode names. 204 204 205 enum { Extern = 1 << 0, Static = 1 << 1, Auto = 1 << 2, Register = 1 << 3, Threadlocal = 1 << 4, N oStorageClass = 5 };205 enum { Extern = 1 << 0, Static = 1 << 1, Auto = 1 << 2, Register = 1 << 3, Threadlocal = 1 << 4, NumStorageClass = 5 }; 206 206 union StorageClasses { 207 207 unsigned int val; … … 218 218 }; // StorageClasses 219 219 220 enum { Inline = 1 << 0, Noreturn = 1 << 1, Fortran = 1 << 2, N oFuncSpecifier = 3 };220 enum { Inline = 1 << 0, Noreturn = 1 << 1, Fortran = 1 << 2, NumFuncSpecifier = 3 }; 221 221 union FuncSpecifiers { 222 222 unsigned int val; … … 231 231 }; // FuncSpecifiers 232 232 233 enum { Const = 1 << 0, Restrict = 1 << 1, Volatile = 1 << 2, Lvalue = 1 << 3, Mutex = 1 << 4, Atomic = 1 << 5, N oTypeQualifier = 6 };233 enum { Const = 1 << 0, Restrict = 1 << 1, Volatile = 1 << 2, Lvalue = 1 << 3, Mutex = 1 << 4, Atomic = 1 << 5, NumTypeQualifier = 6 }; 234 234 union TypeQualifiers { 235 235 unsigned int val; -
src/Parser/TypeData.cc
r9b443c7f rf2e40a9f 10 10 // Created On : Sat May 16 15:12:51 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Mar 14 15:01:44201713 // Update Count : 54 812 // Last Modified On : Tue Mar 14 22:43:20 2017 13 // Update Count : 549 14 14 // 15 15 … … 226 226 227 227 void TypeData::print( ostream &os, int indent ) const { 228 for ( int i = 0; i < DeclarationNode::N oTypeQualifier; i += 1 ) {228 for ( int i = 0; i < DeclarationNode::NumTypeQualifier; i += 1 ) { 229 229 if ( typeQualifiers[i] ) os << DeclarationNode::typeQualifierNames[ i ] << ' '; 230 230 } // for -
src/SymTab/Autogen.h
r9b443c7f rf2e40a9f 10 10 // Created On : Sun May 17 21:53:34 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Mar 6 23:33:01201713 // Update Count : 412 // Last Modified On : Tue Mar 14 23:13:28 2017 13 // Update Count : 7 14 14 // 15 15 … … 58 58 assert( type ); 59 59 Type * castType = type->clone(); 60 castType->get_qualifiers() -= Type::Qualifiers(true, true, true, false, true, false); 60 // castType->get_qualifiers() -= Type::Qualifiers(true, true, true, false, true, false); 61 castType->get_qualifiers() -= Type::Qualifiers( Type::Const | Type::Volatile | Type::Restrict | Type::Atomic ); 61 62 castType->set_isLvalue( true ); // xxx - might not need this 62 63 dstParam = new CastExpr( dstParam, new PointerType( Type::Qualifiers(), castType ) ); -
src/SymTab/Validate.cc
r9b443c7f rf2e40a9f 10 10 // Created On : Sun May 17 21:50:04 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Mar 7 07:51:36201713 // Update Count : 3 4912 // Last Modified On : Tue Mar 14 23:30:27 2017 13 // Update Count : 350 14 14 // 15 15 … … 323 323 ObjectDecl * obj = dynamic_cast< ObjectDecl * >( *i ); 324 324 assert( obj ); 325 obj->set_type( new EnumInstType( Type::Qualifiers( true, false, false, false, false, false), enumDecl->get_name() ) );325 obj->set_type( new EnumInstType( Type::Qualifiers( Type::Const ), enumDecl->get_name() ) ); 326 326 } // for 327 327 Parent::visit( enumDecl ); -
src/SynTree/Type.cc
r9b443c7f rf2e40a9f 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Feb 2 11:26:24201713 // Update Count : 1 212 // Last Modified On : Wed Mar 15 21:22:16 2017 13 // Update Count : 15 14 14 // 15 15 … … 59 59 } 60 60 61 void Type::Qualifiers::print( std::ostream &os, int indent ) const { 62 if ( isConst ) { 63 os << "const "; 64 } // if 65 if ( isVolatile ) { 66 os << "volatile "; 67 } // if 68 if ( isRestrict ) { 69 os << "restrict "; 70 } // if 71 if ( isLvalue ) { 72 os << "lvalue "; 73 } // if 74 if ( isAtomic ) { 75 os << "_Atomic "; 76 } // if 77 } 61 const char * Type::QualifierNames[] = { "const", "restrict", "volatile", "lvalue", "mutex", "_Atomic", "NoTypeQualifierNames" }; 78 62 79 63 void Type::print( std::ostream &os, int indent ) const { -
src/SynTree/Type.h
r9b443c7f rf2e40a9f 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Mar 1 09:11:45201713 // Update Count : 4112 // Last Modified On : Wed Mar 15 21:28:09 2017 13 // Update Count : 85 14 14 // 15 15 … … 24 24 class Type : public BaseSyntaxNode { 25 25 public: 26 struct Qualifiers { 27 Qualifiers(): isConst( false ), isVolatile( false ), isRestrict( false ), isLvalue( false ), isAtomic( false ), isMutex( false ) {} 28 Qualifiers( bool isConst, bool isVolatile, bool isRestrict, bool isLvalue, bool isAtomic, bool isMutex ): isConst( isConst ), isVolatile( isVolatile ), isRestrict( isRestrict ), isLvalue( isLvalue ), isAtomic( isAtomic ), isMutex( isMutex ) {} 29 30 Qualifiers &operator&=( const Qualifiers &other ); 31 Qualifiers &operator+=( const Qualifiers &other ); 32 Qualifiers &operator-=( const Qualifiers &other ); 33 Qualifiers operator+( const Type::Qualifiers &other ); 34 bool operator==( const Qualifiers &other ); 35 bool operator!=( const Qualifiers &other ); 36 bool operator<=( const Qualifiers &other ); 37 bool operator>=( const Qualifiers &other ); 38 bool operator<( const Qualifiers &other ); 39 bool operator>( const Qualifiers &other ); 40 void print( std::ostream &os, int indent = 0 ) const; 41 42 bool isConst; 43 bool isVolatile; 44 bool isRestrict; 45 bool isLvalue; 46 bool isAtomic; 47 bool isMutex; 48 }; 49 50 Type( const Qualifiers &tq, const std::list< Attribute * > & attributes ); 51 Type( const Type &other ); 26 static const char * QualifierNames[]; 27 28 enum { Const = 1 << 0, Restrict = 1 << 1, Volatile = 1 << 2, Lvalue = 1 << 3, Mutex = 1 << 4, Atomic = 1 << 5, NumTypeQualifier = 6 }; 29 union Qualifiers { 30 enum { Mask = ~(Restrict | Lvalue) }; 31 unsigned int val; 32 struct { 33 bool isConst : 1; 34 bool isRestrict : 1; 35 bool isVolatile : 1; 36 bool isLvalue : 1; 37 bool isMutex : 1; 38 bool isAtomic : 1; 39 }; 40 Qualifiers() : val( 0 ) {} 41 Qualifiers( unsigned int val ) : val( val ) {} 42 bool operator[]( unsigned int i ) const { return val & (1 << i); } 43 bool any() const { return val != 0; } 44 bool operator==( const Qualifiers other ) const { 45 return (val & Mask) == (other.val & Mask); 46 } 47 bool operator!=( const Qualifiers other ) const { 48 return (val & Mask) != (other.val & Mask); 49 } 50 bool operator<=( const Qualifiers other ) const { 51 return isConst <= other.isConst && isVolatile <= other.isVolatile && 52 isMutex == other.isMutex && isAtomic == other.isAtomic; 53 } 54 bool operator>=( const Qualifiers other ) const { 55 return isConst >= other.isConst && isVolatile >= other.isVolatile && 56 isMutex == other.isMutex && isAtomic == other.isAtomic; 57 } 58 bool operator<( const Qualifiers other ) const { 59 return *this != other && *this <= other; 60 } 61 bool operator>( const Qualifiers other ) const { 62 return *this != other && *this >= other; 63 } 64 Qualifiers operator&=( const Type::Qualifiers other ) { 65 val &= other.val; return *this; 66 } 67 Qualifiers operator+=( const Qualifiers other ) { 68 val |= other.val; return *this; 69 } 70 Qualifiers operator-=( const Qualifiers other ) { 71 val &= ~other.val; return *this; 72 } 73 Qualifiers operator+( const Qualifiers other ) const { 74 Qualifiers q = other; 75 q += *this; 76 return q; 77 } 78 void print( std::ostream & os, int indent = 0 ) const { 79 if ( (*this).any() ) { // any type qualifiers ? 80 for ( unsigned int i = 0; i < NumTypeQualifier; i += 1 ) { 81 if ( (*this)[i] ) { 82 os << QualifierNames[i] << ' '; 83 } // if 84 } // for 85 } // if 86 } 87 }; // Qualifiers 88 89 Type( const Qualifiers & tq, const std::list< Attribute * > & attributes ); 90 Type( const Type & other ); 52 91 virtual ~Type(); 53 92 54 Qualifiers & get_qualifiers() { return tq; }93 Qualifiers & get_qualifiers() { return tq; } 55 94 bool get_isConst() { return tq.isConst; } 56 95 bool get_isVolatile() { return tq.isVolatile; } … … 78 117 79 118 virtual Type *clone() const = 0; 80 virtual void accept( Visitor & v ) = 0;81 virtual Type *acceptMutator( Mutator & m ) = 0;82 virtual void print( std::ostream & os, int indent = 0 ) const;119 virtual void accept( Visitor & v ) = 0; 120 virtual Type *acceptMutator( Mutator & m ) = 0; 121 virtual void print( std::ostream & os, int indent = 0 ) const; 83 122 private: 84 123 Qualifiers tq; … … 91 130 class VoidType : public Type { 92 131 public: 93 VoidType( const Type::Qualifiers & tq, const std::list< Attribute * > & attributes = std::list< Attribute * >() );132 VoidType( const Type::Qualifiers & tq, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 94 133 95 134 virtual unsigned size() const { return 0; }; … … 97 136 98 137 virtual VoidType *clone() const { return new VoidType( *this ); } 99 virtual void accept( Visitor & v ) { v.visit( this ); }100 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }101 virtual void print( std::ostream & os, int indent = 0 ) const;138 virtual void accept( Visitor & v ) { v.visit( this ); } 139 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); } 140 virtual void print( std::ostream & os, int indent = 0 ) const; 102 141 }; 103 142 … … 131 170 static const char *typeNames[]; // string names for basic types, MUST MATCH with Kind 132 171 133 BasicType( const Type::Qualifiers & tq, Kind bt, const std::list< Attribute * > & attributes = std::list< Attribute * >() );172 BasicType( const Type::Qualifiers & tq, Kind bt, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 134 173 135 174 Kind get_kind() { return kind; } … … 137 176 138 177 virtual BasicType *clone() const { return new BasicType( *this ); } 139 virtual void accept( Visitor & v ) { v.visit( this ); }140 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }141 virtual void print( std::ostream & os, int indent = 0 ) const;178 virtual void accept( Visitor & v ) { v.visit( this ); } 179 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); } 180 virtual void print( std::ostream & os, int indent = 0 ) const; 142 181 143 182 bool isInteger() const; … … 148 187 class PointerType : public Type { 149 188 public: 150 PointerType( const Type::Qualifiers & tq, Type *base, const std::list< Attribute * > & attributes = std::list< Attribute * >() );151 PointerType( const Type::Qualifiers & tq, Type *base, Expression *dimension, bool isVarLen, bool isStatic, const std::list< Attribute * > & attributes = std::list< Attribute * >() );189 PointerType( const Type::Qualifiers & tq, Type *base, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 190 PointerType( const Type::Qualifiers & tq, Type *base, Expression *dimension, bool isVarLen, bool isStatic, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 152 191 PointerType( const PointerType& ); 153 192 virtual ~PointerType(); … … 163 202 164 203 virtual PointerType *clone() const { return new PointerType( *this ); } 165 virtual void accept( Visitor & v ) { v.visit( this ); }166 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }167 virtual void print( std::ostream & os, int indent = 0 ) const;204 virtual void accept( Visitor & v ) { v.visit( this ); } 205 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); } 206 virtual void print( std::ostream & os, int indent = 0 ) const; 168 207 private: 169 208 Type *base; … … 177 216 class ArrayType : public Type { 178 217 public: 179 ArrayType( const Type::Qualifiers & tq, Type *base, Expression *dimension, bool isVarLen, bool isStatic, const std::list< Attribute * > & attributes = std::list< Attribute * >() );218 ArrayType( const Type::Qualifiers & tq, Type *base, Expression *dimension, bool isVarLen, bool isStatic, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 180 219 ArrayType( const ArrayType& ); 181 220 virtual ~ArrayType(); … … 193 232 194 233 virtual ArrayType *clone() const { return new ArrayType( *this ); } 195 virtual void accept( Visitor & v ) { v.visit( this ); }196 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }197 virtual void print( std::ostream & os, int indent = 0 ) const;234 virtual void accept( Visitor & v ) { v.visit( this ); } 235 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); } 236 virtual void print( std::ostream & os, int indent = 0 ) const; 198 237 private: 199 238 Type *base; … … 205 244 class FunctionType : public Type { 206 245 public: 207 FunctionType( const Type::Qualifiers & tq, bool isVarArgs, const std::list< Attribute * > & attributes = std::list< Attribute * >() );246 FunctionType( const Type::Qualifiers & tq, bool isVarArgs, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 208 247 FunctionType( const FunctionType& ); 209 248 virtual ~FunctionType(); … … 216 255 217 256 virtual FunctionType *clone() const { return new FunctionType( *this ); } 218 virtual void accept( Visitor & v ) { v.visit( this ); }219 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }220 virtual void print( std::ostream & os, int indent = 0 ) const;257 virtual void accept( Visitor & v ) { v.visit( this ); } 258 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); } 259 virtual void print( std::ostream & os, int indent = 0 ) const; 221 260 private: 222 261 std::list<DeclarationWithType*> returnVals; … … 232 271 class ReferenceToType : public Type { 233 272 public: 234 ReferenceToType( const Type::Qualifiers & tq, const std::string &name, const std::list< Attribute * > & attributes );235 ReferenceToType( const ReferenceToType & other );273 ReferenceToType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes ); 274 ReferenceToType( const ReferenceToType & other ); 236 275 virtual ~ReferenceToType(); 237 276 238 const std::string & get_name() const { return name; }277 const std::string & get_name() const { return name; } 239 278 void set_name( std::string newValue ) { name = newValue; } 240 279 std::list< Expression* >& get_parameters() { return parameters; } … … 243 282 244 283 virtual ReferenceToType *clone() const = 0; 245 virtual void accept( Visitor & v ) = 0;246 virtual Type *acceptMutator( Mutator & m ) = 0;247 virtual void print( std::ostream & os, int indent = 0 ) const;284 virtual void accept( Visitor & v ) = 0; 285 virtual Type *acceptMutator( Mutator & m ) = 0; 286 virtual void print( std::ostream & os, int indent = 0 ) const; 248 287 protected: 249 288 virtual std::string typeString() const = 0; … … 257 296 typedef ReferenceToType Parent; 258 297 public: 259 StructInstType( const Type::Qualifiers & tq, const std::string &name, const std::list< Attribute * > & attributes = std::list< Attribute * >() ) : Parent( tq, name, attributes ), baseStruct( 0 ) {}260 StructInstType( const Type::Qualifiers & tq, StructDecl * baseStruct, const std::list< Attribute * > & attributes = std::list< Attribute * >() );261 StructInstType( const StructInstType & other ) : Parent( other ), baseStruct( other.baseStruct ) {}298 StructInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >() ) : Parent( tq, name, attributes ), baseStruct( 0 ) {} 299 StructInstType( const Type::Qualifiers & tq, StructDecl * baseStruct, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 300 StructInstType( const StructInstType & other ) : Parent( other ), baseStruct( other.baseStruct ) {} 262 301 263 302 StructDecl *get_baseStruct() const { return baseStruct; } … … 271 310 /// Looks up the members of this struct named "name" and places them into "foundDecls". 272 311 /// Clones declarations into "foundDecls", caller responsible for freeing 273 void lookup( const std::string & name, std::list< Declaration* > &foundDecls ) const;312 void lookup( const std::string & name, std::list< Declaration* > & foundDecls ) const; 274 313 275 314 virtual StructInstType *clone() const { return new StructInstType( *this ); } 276 virtual void accept( Visitor & v ) { v.visit( this ); }277 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }278 279 virtual void print( std::ostream & os, int indent = 0 ) const;315 virtual void accept( Visitor & v ) { v.visit( this ); } 316 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); } 317 318 virtual void print( std::ostream & os, int indent = 0 ) const; 280 319 private: 281 320 virtual std::string typeString() const; … … 289 328 typedef ReferenceToType Parent; 290 329 public: 291 UnionInstType( const Type::Qualifiers & tq, const std::string &name, const std::list< Attribute * > & attributes = std::list< Attribute * >() ) : Parent( tq, name, attributes ), baseUnion( 0 ) {}292 UnionInstType( const Type::Qualifiers & tq, UnionDecl * baseUnion, const std::list< Attribute * > & attributes = std::list< Attribute * >() );293 UnionInstType( const UnionInstType & other ) : Parent( other ), baseUnion( other.baseUnion ) {}330 UnionInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >() ) : Parent( tq, name, attributes ), baseUnion( 0 ) {} 331 UnionInstType( const Type::Qualifiers & tq, UnionDecl * baseUnion, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 332 UnionInstType( const UnionInstType & other ) : Parent( other ), baseUnion( other.baseUnion ) {} 294 333 295 334 UnionDecl *get_baseUnion() const { return baseUnion; } … … 303 342 /// looks up the members of this union named "name" and places them into "foundDecls" 304 343 /// Clones declarations into "foundDecls", caller responsible for freeing 305 void lookup( const std::string & name, std::list< Declaration* > &foundDecls ) const;344 void lookup( const std::string & name, std::list< Declaration* > & foundDecls ) const; 306 345 307 346 virtual UnionInstType *clone() const { return new UnionInstType( *this ); } 308 virtual void accept( Visitor & v ) { v.visit( this ); }309 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }310 311 virtual void print( std::ostream & os, int indent = 0 ) const;347 virtual void accept( Visitor & v ) { v.visit( this ); } 348 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); } 349 350 virtual void print( std::ostream & os, int indent = 0 ) const; 312 351 private: 313 352 virtual std::string typeString() const; … … 321 360 typedef ReferenceToType Parent; 322 361 public: 323 EnumInstType( const Type::Qualifiers & tq, const std::string &name, const std::list< Attribute * > & attributes = std::list< Attribute * >() ) : Parent( tq, name, attributes ) {}324 EnumInstType( const Type::Qualifiers & tq, EnumDecl * baseEnum, const std::list< Attribute * > & attributes = std::list< Attribute * >() );325 EnumInstType( const EnumInstType & other ) : Parent( other ), baseEnum( other.baseEnum ) {}362 EnumInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >() ) : Parent( tq, name, attributes ) {} 363 EnumInstType( const Type::Qualifiers & tq, EnumDecl * baseEnum, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 364 EnumInstType( const EnumInstType & other ) : Parent( other ), baseEnum( other.baseEnum ) {} 326 365 327 366 EnumDecl *get_baseEnum() const { return baseEnum; } … … 331 370 332 371 virtual EnumInstType *clone() const { return new EnumInstType( *this ); } 333 virtual void accept( Visitor & v ) { v.visit( this ); }334 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }372 virtual void accept( Visitor & v ) { v.visit( this ); } 373 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); } 335 374 private: 336 375 virtual std::string typeString() const; … … 344 383 typedef ReferenceToType Parent; 345 384 public: 346 TraitInstType( const Type::Qualifiers & tq, const std::string &name, const std::list< Attribute * > & attributes = std::list< Attribute * >() ) : Parent( tq, name, attributes ) {}347 TraitInstType( const TraitInstType & other );385 TraitInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >() ) : Parent( tq, name, attributes ) {} 386 TraitInstType( const TraitInstType & other ); 348 387 ~TraitInstType(); 349 388 … … 353 392 354 393 virtual TraitInstType *clone() const { return new TraitInstType( *this ); } 355 virtual void accept( Visitor & v ) { v.visit( this ); }356 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }394 virtual void accept( Visitor & v ) { v.visit( this ); } 395 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); } 357 396 private: 358 397 virtual std::string typeString() const; … … 366 405 typedef ReferenceToType Parent; 367 406 public: 368 TypeInstType( const Type::Qualifiers & tq, const std::string &name, TypeDecl *baseType, const std::list< Attribute * > & attributes = std::list< Attribute * >() );369 TypeInstType( const Type::Qualifiers & tq, const std::string &name, bool isFtype, const std::list< Attribute * > & attributes = std::list< Attribute * >() );370 TypeInstType( const TypeInstType & other );407 TypeInstType( const Type::Qualifiers & tq, const std::string & name, TypeDecl *baseType, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 408 TypeInstType( const Type::Qualifiers & tq, const std::string & name, bool isFtype, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 409 TypeInstType( const TypeInstType & other ); 371 410 ~TypeInstType(); 372 411 … … 379 418 380 419 virtual TypeInstType *clone() const { return new TypeInstType( *this ); } 381 virtual void accept( Visitor & v ) { v.visit( this ); }382 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }383 virtual void print( std::ostream & os, int indent = 0 ) const;420 virtual void accept( Visitor & v ) { v.visit( this ); } 421 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); } 422 virtual void print( std::ostream & os, int indent = 0 ) const; 384 423 private: 385 424 virtual std::string typeString() const; … … 392 431 class TupleType : public Type { 393 432 public: 394 TupleType( const Type::Qualifiers & tq, const std::list< Type * > & types = std::list< Type * >(), const std::list< Attribute * > & attributes = std::list< Attribute * >() );433 TupleType( const Type::Qualifiers & tq, const std::list< Type * > & types = std::list< Type * >(), const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 395 434 TupleType( const TupleType& ); 396 435 virtual ~TupleType(); … … 413 452 414 453 virtual TupleType *clone() const { return new TupleType( *this ); } 415 virtual void accept( Visitor & v ) { v.visit( this ); }416 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }417 virtual void print( std::ostream & os, int indent = 0 ) const;454 virtual void accept( Visitor & v ) { v.visit( this ); } 455 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); } 456 virtual void print( std::ostream & os, int indent = 0 ) const; 418 457 private: 419 458 std::list<Type*> types; … … 422 461 class TypeofType : public Type { 423 462 public: 424 TypeofType( const Type::Qualifiers & tq, Expression *expr, const std::list< Attribute * > & attributes = std::list< Attribute * >() );463 TypeofType( const Type::Qualifiers & tq, Expression *expr, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 425 464 TypeofType( const TypeofType& ); 426 465 virtual ~TypeofType(); … … 432 471 433 472 virtual TypeofType *clone() const { return new TypeofType( *this ); } 434 virtual void accept( Visitor & v ) { v.visit( this ); }435 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }436 virtual void print( std::ostream & os, int indent = 0 ) const;473 virtual void accept( Visitor & v ) { v.visit( this ); } 474 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); } 475 virtual void print( std::ostream & os, int indent = 0 ) const; 437 476 private: 438 477 Expression *expr; … … 441 480 class AttrType : public Type { 442 481 public: 443 AttrType( const Type::Qualifiers & tq, const std::string &name, Expression *expr, const std::list< Attribute * > & attributes = std::list< Attribute * >() );444 AttrType( const Type::Qualifiers & tq, const std::string &name, Type *type, const std::list< Attribute * > & attributes = std::list< Attribute * >() );482 AttrType( const Type::Qualifiers & tq, const std::string & name, Expression *expr, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 483 AttrType( const Type::Qualifiers & tq, const std::string & name, Type *type, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 445 484 AttrType( const AttrType& ); 446 485 virtual ~AttrType(); 447 486 448 const std::string & get_name() const { return name; }449 void set_name( const std::string & newValue ) { name = newValue; }487 const std::string & get_name() const { return name; } 488 void set_name( const std::string & newValue ) { name = newValue; } 450 489 Expression *get_expr() const { return expr; } 451 490 void set_expr( Expression *newValue ) { expr = newValue; } … … 458 497 459 498 virtual AttrType *clone() const { return new AttrType( *this ); } 460 virtual void accept( Visitor & v ) { v.visit( this ); }461 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }462 virtual void print( std::ostream & os, int indent = 0 ) const;499 virtual void accept( Visitor & v ) { v.visit( this ); } 500 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); } 501 virtual void print( std::ostream & os, int indent = 0 ) const; 463 502 private: 464 503 std::string name; … … 477 516 478 517 virtual VarArgsType *clone() const { return new VarArgsType( *this ); } 479 virtual void accept( Visitor & v ) { v.visit( this ); }480 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }481 virtual void print( std::ostream & os, int indent = 0 ) const;518 virtual void accept( Visitor & v ) { v.visit( this ); } 519 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); } 520 virtual void print( std::ostream & os, int indent = 0 ) const; 482 521 }; 483 522 … … 489 528 490 529 virtual ZeroType *clone() const { return new ZeroType( *this ); } 491 virtual void accept( Visitor & v ) { v.visit( this ); }492 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }493 virtual void print( std::ostream & os, int indent = 0 ) const;530 virtual void accept( Visitor & v ) { v.visit( this ); } 531 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); } 532 virtual void print( std::ostream & os, int indent = 0 ) const; 494 533 }; 495 534 … … 501 540 502 541 virtual OneType *clone() const { return new OneType( *this ); } 503 virtual void accept( Visitor &v ) { v.visit( this ); } 504 virtual Type *acceptMutator( Mutator &m ) { return m.mutate( this ); } 505 virtual void print( std::ostream &os, int indent = 0 ) const; 506 }; 507 508 inline Type::Qualifiers &Type::Qualifiers::operator&=( const Type::Qualifiers &other ) { 509 isConst &= other.isConst; 510 isVolatile &= other.isVolatile; 511 isRestrict &= other.isRestrict; 512 isLvalue &= other.isLvalue; 513 isAtomic &= other.isAtomic; 514 isMutex &= other.isMutex; 515 return *this; 516 } 517 518 inline Type::Qualifiers &Type::Qualifiers::operator+=( const Type::Qualifiers &other ) { 519 isConst |= other.isConst; 520 isVolatile |= other.isVolatile; 521 isRestrict |= other.isRestrict; 522 isLvalue |= other.isLvalue; 523 isAtomic |= other.isAtomic; 524 isMutex |= other.isMutex; 525 return *this; 526 } 527 528 inline Type::Qualifiers &Type::Qualifiers::operator-=( const Type::Qualifiers &other ) { 529 if ( other.isConst ) isConst = 0; 530 if ( other.isVolatile ) isVolatile = 0; 531 if ( other.isRestrict ) isRestrict = 0; 532 if ( other.isAtomic ) isAtomic = 0; 533 if ( other.isMutex ) isMutex = 0; 534 return *this; 535 } 536 537 inline Type::Qualifiers Type::Qualifiers::operator+( const Type::Qualifiers &other ) { 538 Qualifiers q = other; 539 q += *this; 540 return q; 541 } 542 543 inline bool Type::Qualifiers::operator==( const Qualifiers &other ) { 544 return isConst == other.isConst 545 && isVolatile == other.isVolatile 546 // && isRestrict == other.isRestrict 547 // && isLvalue == other.isLvalue 548 && isAtomic == other.isAtomic; 549 } 550 551 inline bool Type::Qualifiers::operator!=( const Qualifiers &other ) { 552 return isConst != other.isConst 553 || isVolatile != other.isVolatile 554 // || isRestrict != other.isRestrict 555 // || isLvalue != other.isLvalue 556 || isAtomic != other.isAtomic; 557 } 558 559 inline bool Type::Qualifiers::operator<=( const Type::Qualifiers &other ) { 560 return isConst <= other.isConst 561 && isVolatile <= other.isVolatile 562 // && isRestrict <= other.isRestrict 563 // && isLvalue >= other.isLvalue 564 && isAtomic == other.isAtomic; 565 } 566 567 inline bool Type::Qualifiers::operator>=( const Type::Qualifiers &other ) { 568 return isConst >= other.isConst 569 && isVolatile >= other.isVolatile 570 // && isRestrict >= other.isRestrict 571 // && isLvalue <= other.isLvalue 572 && isAtomic == other.isAtomic; 573 } 574 575 inline bool Type::Qualifiers::operator<( const Type::Qualifiers &other ) { 576 return operator!=( other ) && operator<=( other ); 577 } 578 579 inline bool Type::Qualifiers::operator>( const Type::Qualifiers &other ) { 580 return operator!=( other ) && operator>=( other ); 581 } 542 virtual void accept( Visitor & v ) { v.visit( this ); } 543 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); } 544 virtual void print( std::ostream & os, int indent = 0 ) const; 545 }; 582 546 583 547 std::ostream & operator<<( std::ostream & out, const Type * type ); -
src/Tuples/TupleAssignment.cc
r9b443c7f rf2e40a9f 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Mar 6 23:40:14 201713 // Update Count : 512 // Last Modified On : Wed Mar 15 08:00:44 2017 13 // Update Count : 6 14 14 // 15 15 … … 199 199 Type * type = InitTweak::getPointerBase( castType ); 200 200 assert( type ); 201 type->get_qualifiers() -= Type::Qualifiers( true, true, true, false, true, false);201 type->get_qualifiers() -= Type::Qualifiers( Type::Const | Type::Volatile | Type::Restrict | Type::Atomic ); 202 202 type->set_isLvalue( true ); // xxx - might not need this 203 203 expr = new CastExpr( expr, castType ); -
src/Tuples/TupleExpansion.cc
r9b443c7f rf2e40a9f 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Mar 7 07:43:56201713 // Update Count : 1 212 // Last Modified On : Wed Mar 15 07:58:00 2017 13 // Update Count : 14 14 14 // 15 15 … … 305 305 Type * makeTupleType( const std::list< Expression * > & exprs ) { 306 306 // produce the TupleType which aggregates the types of the exprs 307 TupleType *tupleType = new TupleType( Type::Qualifiers( true, true, true, true, true, true) );307 TupleType *tupleType = new TupleType( Type::Qualifiers( Type::Const | Type::Volatile | Type::Restrict | Type::Lvalue | Type::Atomic | Type::Mutex ) ); 308 308 Type::Qualifiers &qualifiers = tupleType->get_qualifiers(); 309 309 for ( Expression * expr : exprs ) {
Note:
See TracChangeset
for help on using the changeset viewer.