Changeset f2e40a9f for src/SynTree
- Timestamp:
- Mar 15, 2017, 9:43:15 PM (8 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 27fed7f1, 738e304
- Parents:
- bf4ac09 (diff), 9b443c7f (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - git-author:
- Peter A. Buhr <pabuhr@…> (03/15/17 21:25:49)
- git-committer:
- Peter A. Buhr <pabuhr@…> (03/15/17 21:43:15)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/Type.h
rbf4ac09 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 15 21:2 3:08201713 // Update Count : 8 412 // 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 26 static const char * QualifierNames[]; 51 27 … … 100 76 return q; 101 77 } 102 void print( std::ostream & os, int indent = 0 ) const {78 void print( std::ostream & os, int indent = 0 ) const { 103 79 if ( (*this).any() ) { // any type qualifiers ? 104 80 for ( unsigned int i = 0; i < NumTypeQualifier; i += 1 ) { … … 111 87 }; // Qualifiers 112 88 113 Type( const Qualifiers & tq, const std::list< Attribute * > & attributes );114 Type( const Type & other );89 Type( const Qualifiers & tq, const std::list< Attribute * > & attributes ); 90 Type( const Type & other ); 115 91 virtual ~Type(); 116 92 117 Qualifiers & get_qualifiers() { return tq; }93 Qualifiers & get_qualifiers() { return tq; } 118 94 bool get_isConst() { return tq.isConst; } 119 95 bool get_isVolatile() { return tq.isVolatile; } … … 141 117 142 118 virtual Type *clone() const = 0; 143 virtual void accept( Visitor & v ) = 0;144 virtual Type *acceptMutator( Mutator & m ) = 0;145 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; 146 122 private: 147 123 Qualifiers tq; … … 154 130 class VoidType : public Type { 155 131 public: 156 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 * >() ); 157 133 158 134 virtual unsigned size() const { return 0; }; … … 160 136 161 137 virtual VoidType *clone() const { return new VoidType( *this ); } 162 virtual void accept( Visitor & v ) { v.visit( this ); }163 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }164 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; 165 141 }; 166 142 … … 194 170 static const char *typeNames[]; // string names for basic types, MUST MATCH with Kind 195 171 196 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 * >() ); 197 173 198 174 Kind get_kind() { return kind; } … … 200 176 201 177 virtual BasicType *clone() const { return new BasicType( *this ); } 202 virtual void accept( Visitor & v ) { v.visit( this ); }203 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }204 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; 205 181 206 182 bool isInteger() const; … … 211 187 class PointerType : public Type { 212 188 public: 213 PointerType( const Type::Qualifiers & tq, Type *base, const std::list< Attribute * > & attributes = std::list< Attribute * >() );214 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 * >() ); 215 191 PointerType( const PointerType& ); 216 192 virtual ~PointerType(); … … 226 202 227 203 virtual PointerType *clone() const { return new PointerType( *this ); } 228 virtual void accept( Visitor & v ) { v.visit( this ); }229 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }230 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; 231 207 private: 232 208 Type *base; … … 240 216 class ArrayType : public Type { 241 217 public: 242 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 * >() ); 243 219 ArrayType( const ArrayType& ); 244 220 virtual ~ArrayType(); … … 256 232 257 233 virtual ArrayType *clone() const { return new ArrayType( *this ); } 258 virtual void accept( Visitor & v ) { v.visit( this ); }259 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }260 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; 261 237 private: 262 238 Type *base; … … 268 244 class FunctionType : public Type { 269 245 public: 270 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 * >() ); 271 247 FunctionType( const FunctionType& ); 272 248 virtual ~FunctionType(); … … 279 255 280 256 virtual FunctionType *clone() const { return new FunctionType( *this ); } 281 virtual void accept( Visitor & v ) { v.visit( this ); }282 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }283 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; 284 260 private: 285 261 std::list<DeclarationWithType*> returnVals; … … 295 271 class ReferenceToType : public Type { 296 272 public: 297 ReferenceToType( const Type::Qualifiers & tq, const std::string &name, const std::list< Attribute * > & attributes );298 ReferenceToType( const ReferenceToType & other );273 ReferenceToType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes ); 274 ReferenceToType( const ReferenceToType & other ); 299 275 virtual ~ReferenceToType(); 300 276 301 const std::string & get_name() const { return name; }277 const std::string & get_name() const { return name; } 302 278 void set_name( std::string newValue ) { name = newValue; } 303 279 std::list< Expression* >& get_parameters() { return parameters; } … … 306 282 307 283 virtual ReferenceToType *clone() const = 0; 308 virtual void accept( Visitor & v ) = 0;309 virtual Type *acceptMutator( Mutator & m ) = 0;310 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; 311 287 protected: 312 288 virtual std::string typeString() const = 0; … … 320 296 typedef ReferenceToType Parent; 321 297 public: 322 StructInstType( const Type::Qualifiers & tq, const std::string &name, const std::list< Attribute * > & attributes = std::list< Attribute * >() ) : Parent( tq, name, attributes ), baseStruct( 0 ) {}323 StructInstType( const Type::Qualifiers & tq, StructDecl * baseStruct, const std::list< Attribute * > & attributes = std::list< Attribute * >() );324 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 ) {} 325 301 326 302 StructDecl *get_baseStruct() const { return baseStruct; } … … 334 310 /// Looks up the members of this struct named "name" and places them into "foundDecls". 335 311 /// Clones declarations into "foundDecls", caller responsible for freeing 336 void lookup( const std::string & name, std::list< Declaration* > &foundDecls ) const;312 void lookup( const std::string & name, std::list< Declaration* > & foundDecls ) const; 337 313 338 314 virtual StructInstType *clone() const { return new StructInstType( *this ); } 339 virtual void accept( Visitor & v ) { v.visit( this ); }340 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }341 342 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; 343 319 private: 344 320 virtual std::string typeString() const; … … 352 328 typedef ReferenceToType Parent; 353 329 public: 354 UnionInstType( const Type::Qualifiers & tq, const std::string &name, const std::list< Attribute * > & attributes = std::list< Attribute * >() ) : Parent( tq, name, attributes ), baseUnion( 0 ) {}355 UnionInstType( const Type::Qualifiers & tq, UnionDecl * baseUnion, const std::list< Attribute * > & attributes = std::list< Attribute * >() );356 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 ) {} 357 333 358 334 UnionDecl *get_baseUnion() const { return baseUnion; } … … 366 342 /// looks up the members of this union named "name" and places them into "foundDecls" 367 343 /// Clones declarations into "foundDecls", caller responsible for freeing 368 void lookup( const std::string & name, std::list< Declaration* > &foundDecls ) const;344 void lookup( const std::string & name, std::list< Declaration* > & foundDecls ) const; 369 345 370 346 virtual UnionInstType *clone() const { return new UnionInstType( *this ); } 371 virtual void accept( Visitor & v ) { v.visit( this ); }372 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }373 374 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; 375 351 private: 376 352 virtual std::string typeString() const; … … 384 360 typedef ReferenceToType Parent; 385 361 public: 386 EnumInstType( const Type::Qualifiers & tq, const std::string &name, const std::list< Attribute * > & attributes = std::list< Attribute * >() ) : Parent( tq, name, attributes ) {}387 EnumInstType( const Type::Qualifiers & tq, EnumDecl * baseEnum, const std::list< Attribute * > & attributes = std::list< Attribute * >() );388 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 ) {} 389 365 390 366 EnumDecl *get_baseEnum() const { return baseEnum; } … … 394 370 395 371 virtual EnumInstType *clone() const { return new EnumInstType( *this ); } 396 virtual void accept( Visitor & v ) { v.visit( this ); }397 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 ); } 398 374 private: 399 375 virtual std::string typeString() const; … … 407 383 typedef ReferenceToType Parent; 408 384 public: 409 TraitInstType( const Type::Qualifiers & tq, const std::string &name, const std::list< Attribute * > & attributes = std::list< Attribute * >() ) : Parent( tq, name, attributes ) {}410 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 ); 411 387 ~TraitInstType(); 412 388 … … 416 392 417 393 virtual TraitInstType *clone() const { return new TraitInstType( *this ); } 418 virtual void accept( Visitor & v ) { v.visit( this ); }419 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 ); } 420 396 private: 421 397 virtual std::string typeString() const; … … 429 405 typedef ReferenceToType Parent; 430 406 public: 431 TypeInstType( const Type::Qualifiers & tq, const std::string &name, TypeDecl *baseType, const std::list< Attribute * > & attributes = std::list< Attribute * >() );432 TypeInstType( const Type::Qualifiers & tq, const std::string &name, bool isFtype, const std::list< Attribute * > & attributes = std::list< Attribute * >() );433 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 ); 434 410 ~TypeInstType(); 435 411 … … 442 418 443 419 virtual TypeInstType *clone() const { return new TypeInstType( *this ); } 444 virtual void accept( Visitor & v ) { v.visit( this ); }445 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }446 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; 447 423 private: 448 424 virtual std::string typeString() const; … … 455 431 class TupleType : public Type { 456 432 public: 457 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 * >() ); 458 434 TupleType( const TupleType& ); 459 435 virtual ~TupleType(); … … 476 452 477 453 virtual TupleType *clone() const { return new TupleType( *this ); } 478 virtual void accept( Visitor & v ) { v.visit( this ); }479 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }480 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; 481 457 private: 482 458 std::list<Type*> types; … … 485 461 class TypeofType : public Type { 486 462 public: 487 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 * >() ); 488 464 TypeofType( const TypeofType& ); 489 465 virtual ~TypeofType(); … … 495 471 496 472 virtual TypeofType *clone() const { return new TypeofType( *this ); } 497 virtual void accept( Visitor & v ) { v.visit( this ); }498 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }499 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; 500 476 private: 501 477 Expression *expr; … … 504 480 class AttrType : public Type { 505 481 public: 506 AttrType( const Type::Qualifiers & tq, const std::string &name, Expression *expr, const std::list< Attribute * > & attributes = std::list< Attribute * >() );507 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 * >() ); 508 484 AttrType( const AttrType& ); 509 485 virtual ~AttrType(); 510 486 511 const std::string & get_name() const { return name; }512 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; } 513 489 Expression *get_expr() const { return expr; } 514 490 void set_expr( Expression *newValue ) { expr = newValue; } … … 521 497 522 498 virtual AttrType *clone() const { return new AttrType( *this ); } 523 virtual void accept( Visitor & v ) { v.visit( this ); }524 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }525 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; 526 502 private: 527 503 std::string name; … … 540 516 541 517 virtual VarArgsType *clone() const { return new VarArgsType( *this ); } 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;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; 545 521 }; 546 522 … … 552 528 553 529 virtual ZeroType *clone() const { return new ZeroType( *this ); } 554 virtual void accept( Visitor & v ) { v.visit( this ); }555 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }556 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; 557 533 }; 558 534 … … 564 540 565 541 virtual OneType *clone() const { return new OneType( *this ); } 566 virtual void accept( Visitor & v ) { v.visit( this ); }567 virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }568 virtual void print( std::ostream & os, int indent = 0 ) const;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; 569 545 }; 570 546
Note: See TracChangeset
for help on using the changeset viewer.