Changeset 24d6572 for src/SynTree
- Timestamp:
- Jun 12, 2023, 2:45:32 PM (2 years ago)
- Branches:
- ast-experimental, master
- Children:
- 62d62db
- Parents:
- 34b4268 (diff), 251ce80 (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. - Location:
- src/SynTree
- Files:
-
- 6 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/AggregateDecl.cc
r34b4268 r24d6572 19 19 20 20 #include "Attribute.h" // for Attribute 21 #include "Common/Eval.h" // for eval 21 22 #include "Common/utility.h" // for printAll, cloneAll, deleteAll 22 23 #include "Declaration.h" // for AggregateDecl, TypeDecl, Declaration -
src/SynTree/ApplicationExpr.cc
r34b4268 r24d6572 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // ApplicationExpr.cc .cc--7 // ApplicationExpr.cc -- 8 8 // 9 9 // Author : Richard C. Bilson … … 26 26 #include "Expression.h" // for ParamEntry, ApplicationExpr, Expression 27 27 #include "InitTweak/InitTweak.h" // for getFunction 28 #include "ResolvExpr/ typeops.h"// for extractResultType28 #include "ResolvExpr/Unify.h" // for extractResultType 29 29 #include "Type.h" // for Type, PointerType, FunctionType 30 30 -
src/SynTree/BasicType.cc
r34b4268 r24d6572 29 29 } 30 30 31 bool BasicType::isWholeNumber() const {32 return kind == Bool ||33 kind ==Char ||34 kind == SignedChar ||35 kind == UnsignedChar ||36 kind == ShortSignedInt ||37 kind == ShortUnsignedInt ||38 kind == SignedInt ||39 kind == UnsignedInt ||40 kind == LongSignedInt ||41 kind == LongUnsignedInt ||42 kind == LongLongSignedInt ||43 kind ==LongLongUnsignedInt ||44 kind == SignedInt128 ||45 kind == UnsignedInt128;46 }47 48 31 bool BasicType::isInteger() const { 49 32 return kind <= UnsignedInt128; -
src/SynTree/FunctionDecl.cc
r34b4268 r24d6572 87 87 } // if 88 88 89 if ( !withExprs.empty() ) { 90 os << indent << "... with clause" << std::endl; 91 os << indent + 1; 92 printAll( withExprs, os, indent + 1 ); 93 } 94 89 95 if ( statements ) { 90 96 os << indent << "... with body" << endl << indent+1; -
src/SynTree/Type.cc
r34b4268 r24d6572 16 16 17 17 #include "Attribute.h" // for Attribute 18 #include "Common/ToString.hpp" // for toCString 18 19 #include "Common/utility.h" // for cloneAll, deleteAll, printAll 19 20 #include "InitTweak/InitTweak.h" // for getPointerBase … … 105 106 int Type::referenceDepth() const { return 0; } 106 107 108 AggregateDecl * Type::getAggr() const { 109 assertf( false, "Non-aggregate type: %s", toCString( this ) ); 110 } 111 107 112 TypeSubstitution Type::genericSubstitution() const { assertf( false, "Non-aggregate type: %s", toCString( this ) ); } 108 113 -
src/SynTree/Type.h
r34b4268 r24d6572 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Andrew Beach12 // Last Modified On : Wed Jul 14 15:40:00 202113 // Update Count : 17 111 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sun Feb 19 22:37:10 2023 13 // Update Count : 176 14 14 // 15 15 … … 23 23 24 24 #include "BaseSyntaxNode.h" // for BaseSyntaxNode 25 #include "Common/ utility.h"// for operator+25 #include "Common/Iterate.hpp"// for operator+ 26 26 #include "Mutator.h" // for Mutator 27 27 #include "SynTree.h" // for AST nodes … … 124 124 bool operator!=( Qualifiers other ) const { return (val & Mask) != (other.val & Mask); } 125 125 bool operator<=( Qualifiers other ) const { 126 return is_const <= other.is_const // Any non-const converts to const without cost127 && is_volatile <= other.is_volatile //Any non-volatile converts to volatile without cost128 && is_mutex >= other.is_mutex //Any mutex converts to non-mutex without cost129 && is_atomic == other.is_atomic; //No conversion from atomic to non atomic is free126 return is_const <= other.is_const // Any non-const converts to const without cost 127 && is_volatile <= other.is_volatile // Any non-volatile converts to volatile without cost 128 && is_mutex >= other.is_mutex // Any mutex converts to non-mutex without cost 129 && is_atomic == other.is_atomic; // No conversion from atomic to non atomic is free 130 130 } 131 131 bool operator<( Qualifiers other ) const { return *this != other && *this <= other; } … … 185 185 virtual bool isComplete() const { return true; } 186 186 187 virtual AggregateDecl * getAggr() const { assertf( false, "Non-aggregate type: %s", toCString( this ) ); }187 virtual AggregateDecl * getAggr() const; 188 188 189 189 virtual TypeSubstitution genericSubstitution() const; 190 190 191 virtual Type * clone() const = 0;191 virtual Type * clone() const = 0; 192 192 virtual void accept( Visitor & v ) = 0; 193 193 virtual void accept( Visitor & v ) const = 0; 194 virtual Type * acceptMutator( Mutator & m ) = 0;194 virtual Type * acceptMutator( Mutator & m ) = 0; 195 195 virtual void print( std::ostream & os, Indenter indent = {} ) const; 196 196 }; … … 207 207 virtual bool isComplete() const override { return false; } 208 208 209 virtual VoidType * clone() const override { return new VoidType( *this ); }210 virtual void accept( Visitor & v ) override { v.visit( this ); } 211 virtual void accept( Visitor & v ) const override { v.visit( this ); } 212 virtual Type * acceptMutator( Mutator & m ) override { return m.mutate( this ); }209 virtual VoidType * clone() const override { return new VoidType( *this ); } 210 virtual void accept( Visitor & v ) override { v.visit( this ); } 211 virtual void accept( Visitor & v ) const override { v.visit( this ); } 212 virtual Type * acceptMutator( Mutator & m ) override { return m.mutate( this ); } 213 213 virtual void print( std::ostream & os, Indenter indent = {} ) const override; 214 214 }; … … 259 259 // GENERATED END 260 260 261 static const char * typeNames[];// string names for basic types, MUST MATCH with Kind261 static const char * typeNames[]; // string names for basic types, MUST MATCH with Kind 262 262 263 263 BasicType( const Type::Qualifiers & tq, Kind bt, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); … … 266 266 void set_kind( Kind newValue ) { kind = newValue; } 267 267 268 virtual BasicType *clone() const override { return new BasicType( *this ); } 269 virtual void accept( Visitor & v ) override { v.visit( this ); } 270 virtual void accept( Visitor & v ) const override { v.visit( this ); } 271 virtual Type *acceptMutator( Mutator & m ) override { return m.mutate( this ); } 272 virtual void print( std::ostream & os, Indenter indent = {} ) const override; 273 bool isWholeNumber() const; 268 virtual BasicType * clone() const override { return new BasicType( *this ); } 269 virtual void accept( Visitor & v ) override { v.visit( this ); } 270 virtual void accept( Visitor & v ) const override { v.visit( this ); } 271 virtual Type * acceptMutator( Mutator & m ) override { return m.mutate( this ); } 272 virtual void print( std::ostream & os, Indenter indent = {} ) const override; 274 273 bool isInteger() const; 275 274 }; … … 280 279 281 280 // In C99, pointer types can be qualified in many ways e.g., int f( int a[ static 3 ] ) 282 Expression * dimension;281 Expression * dimension; 283 282 bool isVarLen; 284 283 bool isStatic; 285 284 286 PointerType( const Type::Qualifiers & tq, Type * base, const std::list< Attribute * > & attributes = std::list< Attribute * >() );287 PointerType( const Type::Qualifiers & tq, Type * base, Expression *dimension, bool isVarLen, bool isStatic, const std::list< Attribute * > & attributes = std::list< Attribute * >() );285 PointerType( const Type::Qualifiers & tq, Type * base, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 286 PointerType( const Type::Qualifiers & tq, Type * base, Expression * dimension, bool isVarLen, bool isStatic, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 288 287 PointerType( const PointerType& ); 289 288 virtual ~PointerType(); 290 289 291 Type * get_base() { return base; }292 void set_base( Type * newValue ) { base = newValue; }293 Expression * get_dimension() { return dimension; }294 void set_dimension( Expression * newValue ) { dimension = newValue; }290 Type * get_base() { return base; } 291 void set_base( Type * newValue ) { base = newValue; } 292 Expression * get_dimension() { return dimension; } 293 void set_dimension( Expression * newValue ) { dimension = newValue; } 295 294 bool get_isVarLen() { return isVarLen; } 296 295 void set_isVarLen( bool newValue ) { isVarLen = newValue; } … … 302 301 virtual bool isComplete() const override { return ! isVarLen; } 303 302 304 virtual PointerType * clone() const override { return new PointerType( *this ); }305 virtual void accept( Visitor & v ) override { v.visit( this ); } 306 virtual void accept( Visitor & v ) const override { v.visit( this ); } 307 virtual Type * acceptMutator( Mutator & m ) override { return m.mutate( this ); }303 virtual PointerType * clone() const override { return new PointerType( * this ); } 304 virtual void accept( Visitor & v ) override { v.visit( this ); } 305 virtual void accept( Visitor & v ) const override { v.visit( this ); } 306 virtual Type * acceptMutator( Mutator & m ) override { return m.mutate( this ); } 308 307 virtual void print( std::ostream & os, Indenter indent = {} ) const override; 309 308 }; … … 311 310 class ArrayType : public Type { 312 311 public: 313 Type * base;314 Expression * dimension;312 Type * base; 313 Expression * dimension; 315 314 bool isVarLen; 316 315 bool isStatic; 317 316 318 ArrayType( const Type::Qualifiers & tq, Type * base, Expression *dimension, bool isVarLen, bool isStatic, const std::list< Attribute * > & attributes = std::list< Attribute * >() );317 ArrayType( const Type::Qualifiers & tq, Type * base, Expression * dimension, bool isVarLen, bool isStatic, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 319 318 ArrayType( const ArrayType& ); 320 319 virtual ~ArrayType(); 321 320 322 Type * get_base() { return base; }323 void set_base( Type * newValue ) { base = newValue; }324 Expression * get_dimension() { return dimension; }325 void set_dimension( Expression * newValue ) { dimension = newValue; }321 Type * get_base() { return base; } 322 void set_base( Type * newValue ) { base = newValue; } 323 Expression * get_dimension() { return dimension; } 324 void set_dimension( Expression * newValue ) { dimension = newValue; } 326 325 bool get_isVarLen() { return isVarLen; } 327 326 void set_isVarLen( bool newValue ) { isVarLen = newValue; } … … 334 333 virtual bool isComplete() const override { return dimension || isVarLen; } 335 334 336 virtual ArrayType * clone() const override { return new ArrayType( *this ); }337 virtual void accept( Visitor & v ) override { v.visit( this ); } 338 virtual void accept( Visitor & v ) const override { v.visit( this ); } 339 virtual Type * acceptMutator( Mutator & m ) override { return m.mutate( this ); }335 virtual ArrayType * clone() const override { return new ArrayType( *this ); } 336 virtual void accept( Visitor & v ) override { v.visit( this ); } 337 virtual void accept( Visitor & v ) const override { v.visit( this ); } 338 virtual Type * acceptMutator( Mutator & m ) override { return m.mutate( this ); } 340 339 virtual void print( std::ostream & os, Indenter indent = {} ) const override; 341 340 }; … … 349 348 virtual ~QualifiedType(); 350 349 351 virtual QualifiedType * clone() const override { return new QualifiedType( *this ); }352 virtual void accept( Visitor & v ) override { v.visit( this ); } 353 virtual void accept( Visitor & v ) const override { v.visit( this ); } 354 virtual Type * acceptMutator( Mutator & m ) override { return m.mutate( this ); }350 virtual QualifiedType * clone() const override { return new QualifiedType( *this ); } 351 virtual void accept( Visitor & v ) override { v.visit( this ); } 352 virtual void accept( Visitor & v ) const override { v.visit( this ); } 353 virtual Type * acceptMutator( Mutator & m ) override { return m.mutate( this ); } 355 354 virtual void print( std::ostream & os, Indenter indent = {} ) const override; 356 355 }; … … 358 357 class ReferenceType : public Type { 359 358 public: 360 Type * base;361 362 ReferenceType( const Type::Qualifiers & tq, Type * base, const std::list< Attribute * > & attributes = std::list< Attribute * >() );359 Type * base; 360 361 ReferenceType( const Type::Qualifiers & tq, Type * base, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 363 362 ReferenceType( const ReferenceType & ); 364 363 virtual ~ReferenceType(); 365 364 366 Type * get_base() { return base; }367 void set_base( Type * newValue ) { base = newValue; }365 Type * get_base() { return base; } 366 void set_base( Type * newValue ) { base = newValue; } 368 367 369 368 virtual int referenceDepth() const override; … … 376 375 virtual TypeSubstitution genericSubstitution() const override; 377 376 378 virtual ReferenceType * clone() const override { return new ReferenceType( *this ); }379 virtual void accept( Visitor & v ) override { v.visit( this ); } 380 virtual void accept( Visitor & v ) const override { v.visit( this ); } 381 virtual Type * acceptMutator( Mutator & m ) override { return m.mutate( this ); }377 virtual ReferenceType * clone() const override { return new ReferenceType( *this ); } 378 virtual void accept( Visitor & v ) override { v.visit( this ); } 379 virtual void accept( Visitor & v ) const override { v.visit( this ); } 380 virtual Type * acceptMutator( Mutator & m ) override { return m.mutate( this ); } 382 381 virtual void print( std::ostream & os, Indenter indent = {} ) const override; 383 382 }; … … 406 405 bool isUnprototyped() const { return isVarArgs && parameters.size() == 0; } 407 406 408 virtual FunctionType * clone() const override { return new FunctionType( *this ); }409 virtual void accept( Visitor & v ) override { v.visit( this ); } 410 virtual void accept( Visitor & v ) const override { v.visit( this ); } 411 virtual Type * acceptMutator( Mutator & m ) override { return m.mutate( this ); }407 virtual FunctionType * clone() const override { return new FunctionType( *this ); } 408 virtual void accept( Visitor & v ) override { v.visit( this ); } 409 virtual void accept( Visitor & v ) const override { v.visit( this ); } 410 virtual Type * acceptMutator( Mutator & m ) override { return m.mutate( this ); } 412 411 virtual void print( std::ostream & os, Indenter indent = {} ) const override; 413 412 }; … … 415 414 class ReferenceToType : public Type { 416 415 public: 417 std::list< Expression * > parameters;416 std::list< Expression * > parameters; 418 417 std::string name; 419 418 bool hoistType; … … 429 428 void set_hoistType( bool newValue ) { hoistType = newValue; } 430 429 431 virtual ReferenceToType * clone() const override = 0;430 virtual ReferenceToType * clone() const override = 0; 432 431 virtual void accept( Visitor & v ) override = 0; 433 virtual Type * acceptMutator( Mutator & m ) override = 0;432 virtual Type * acceptMutator( Mutator & m ) override = 0; 434 433 virtual void print( std::ostream & os, Indenter indent = {} ) const override; 435 434 … … 444 443 // this decl is not "owned" by the struct inst; it is merely a pointer to elsewhere in the tree, 445 444 // where the structure used in this type is actually defined 446 StructDecl * baseStruct;445 StructDecl * baseStruct; 447 446 448 447 StructInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >() ) : Parent( tq, name, attributes ), baseStruct( 0 ) {} … … 450 449 StructInstType( const StructInstType & other ) : Parent( other ), baseStruct( other.baseStruct ) {} 451 450 452 StructDecl * get_baseStruct() const { return baseStruct; }453 void set_baseStruct( StructDecl * newValue ) { baseStruct = newValue; }451 StructDecl * get_baseStruct() const { return baseStruct; } 452 void set_baseStruct( StructDecl * newValue ) { baseStruct = newValue; } 454 453 455 454 /// Accesses generic parameters of base struct (NULL if none such) … … 467 466 void lookup( const std::string & name, std::list< Declaration* > & foundDecls ) const override; 468 467 469 virtual StructInstType * clone() const override { return new StructInstType( *this ); }470 virtual void accept( Visitor & v ) override { v.visit( this ); } 471 virtual void accept( Visitor & v ) const override { v.visit( this ); } 472 virtual Type * acceptMutator( Mutator & m ) override { return m.mutate( this ); }468 virtual StructInstType * clone() const override { return new StructInstType( *this ); } 469 virtual void accept( Visitor & v ) override { v.visit( this ); } 470 virtual void accept( Visitor & v ) const override { v.visit( this ); } 471 virtual Type * acceptMutator( Mutator & m ) override { return m.mutate( this ); } 473 472 474 473 virtual void print( std::ostream & os, Indenter indent = {} ) const override; … … 482 481 // this decl is not "owned" by the union inst; it is merely a pointer to elsewhere in the tree, 483 482 // where the union used in this type is actually defined 484 UnionDecl * baseUnion;483 UnionDecl * baseUnion; 485 484 486 485 UnionInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >() ) : Parent( tq, name, attributes ), baseUnion( 0 ) {} … … 488 487 UnionInstType( const UnionInstType & other ) : Parent( other ), baseUnion( other.baseUnion ) {} 489 488 490 UnionDecl * get_baseUnion() const { return baseUnion; }489 UnionDecl * get_baseUnion() const { return baseUnion; } 491 490 void set_baseUnion( UnionDecl * newValue ) { baseUnion = newValue; } 492 491 … … 505 504 void lookup( const std::string & name, std::list< Declaration* > & foundDecls ) const override; 506 505 507 virtual UnionInstType * clone() const override { return new UnionInstType( *this ); }508 virtual void accept( Visitor & v ) override { v.visit( this ); } 509 virtual void accept( Visitor & v ) const override { v.visit( this ); } 510 virtual Type * acceptMutator( Mutator & m ) override { return m.mutate( this ); }506 virtual UnionInstType * clone() const override { return new UnionInstType( *this ); } 507 virtual void accept( Visitor & v ) override { v.visit( this ); } 508 virtual void accept( Visitor & v ) const override { v.visit( this ); } 509 virtual Type * acceptMutator( Mutator & m ) override { return m.mutate( this ); } 511 510 512 511 virtual void print( std::ostream & os, Indenter indent = {} ) const override; … … 520 519 // this decl is not "owned" by the enum inst; it is merely a pointer to elsewhere in the tree, 521 520 // where the enum used in this type is actually defined 522 EnumDecl * baseEnum = nullptr;521 EnumDecl * baseEnum = nullptr; 523 522 524 523 EnumInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >() ) : Parent( tq, name, attributes ) {} … … 526 525 EnumInstType( const EnumInstType & other ) : Parent( other ), baseEnum( other.baseEnum ) {} 527 526 528 EnumDecl * get_baseEnum() const { return baseEnum; }529 void set_baseEnum( EnumDecl * newValue ) { baseEnum = newValue; }527 EnumDecl * get_baseEnum() const { return baseEnum; } 528 void set_baseEnum( EnumDecl * newValue ) { baseEnum = newValue; } 530 529 531 530 virtual bool isComplete() const override; … … 533 532 virtual AggregateDecl * getAggr() const override; 534 533 535 virtual EnumInstType * clone() const override { return new EnumInstType( *this ); }536 virtual void accept( Visitor & v ) override { v.visit( this ); } 537 virtual void accept( Visitor & v ) const override { v.visit( this ); } 538 virtual Type * acceptMutator( Mutator & m ) override { return m.mutate( this ); }534 virtual EnumInstType * clone() const override { return new EnumInstType( *this ); } 535 virtual void accept( Visitor & v ) override { v.visit( this ); } 536 virtual void accept( Visitor & v ) const override { v.visit( this ); } 537 virtual Type * acceptMutator( Mutator & m ) override { return m.mutate( this ); } 539 538 540 539 virtual void print( std::ostream & os, Indenter indent = {} ) const override; … … 557 556 virtual bool isComplete() const override; 558 557 559 virtual TraitInstType * clone() const override { return new TraitInstType( *this ); }560 virtual void accept( Visitor & v ) override { v.visit( this ); } 561 virtual void accept( Visitor & v ) const override { v.visit( this ); } 562 virtual Type * acceptMutator( Mutator & m ) override { return m.mutate( this ); }558 virtual TraitInstType * clone() const override { return new TraitInstType( *this ); } 559 virtual void accept( Visitor & v ) override { v.visit( this ); } 560 virtual void accept( Visitor & v ) const override { v.visit( this ); } 561 virtual Type * acceptMutator( Mutator & m ) override { return m.mutate( this ); } 563 562 private: 564 563 virtual std::string typeString() const override; … … 570 569 // this decl is not "owned" by the type inst; it is merely a pointer to elsewhere in the tree, 571 570 // where the type used here is actually defined 572 TypeDecl * baseType;571 TypeDecl * baseType; 573 572 bool isFtype; 574 573 575 TypeInstType( const Type::Qualifiers & tq, const std::string & name, TypeDecl * baseType, const std::list< Attribute * > & attributes = std::list< Attribute * >() );574 TypeInstType( const Type::Qualifiers & tq, const std::string & name, TypeDecl * baseType, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 576 575 TypeInstType( const Type::Qualifiers & tq, const std::string & name, bool isFtype, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 577 576 TypeInstType( const TypeInstType & other ); 578 577 ~TypeInstType(); 579 578 580 TypeDecl * get_baseType() const { return baseType; }581 void set_baseType( TypeDecl * newValue );579 TypeDecl * get_baseType() const { return baseType; } 580 void set_baseType( TypeDecl * newValue ); 582 581 bool get_isFtype() const { return isFtype; } 583 582 void set_isFtype( bool newValue ) { isFtype = newValue; } … … 585 584 virtual bool isComplete() const override; 586 585 587 virtual TypeInstType * clone() const override { return new TypeInstType( *this ); }588 virtual void accept( Visitor & v ) override { v.visit( this ); } 589 virtual void accept( Visitor & v ) const override { v.visit( this ); } 590 virtual Type * acceptMutator( Mutator & m ) override { return m.mutate( this ); }586 virtual TypeInstType * clone() const override { return new TypeInstType( *this ); } 587 virtual void accept( Visitor & v ) override { v.visit( this ); } 588 virtual void accept( Visitor & v ) const override { v.visit( this ); } 589 virtual Type * acceptMutator( Mutator & m ) override { return m.mutate( this ); } 591 590 virtual void print( std::ostream & os, Indenter indent = {} ) const override; 592 591 private: … … 623 622 // virtual bool isComplete() const override { return true; } // xxx - not sure if this is right, might need to recursively check complete-ness 624 623 625 virtual TupleType * clone() const override { return new TupleType( *this ); }626 virtual void accept( Visitor & v ) override { v.visit( this ); } 627 virtual void accept( Visitor & v ) const override { v.visit( this ); } 628 virtual Type * acceptMutator( Mutator & m ) override { return m.mutate( this ); }624 virtual TupleType * clone() const override { return new TupleType( *this ); } 625 virtual void accept( Visitor & v ) override { v.visit( this ); } 626 virtual void accept( Visitor & v ) const override { v.visit( this ); } 627 virtual Type * acceptMutator( Mutator & m ) override { return m.mutate( this ); } 629 628 virtual void print( std::ostream & os, Indenter indent = {} ) const override; 630 629 }; … … 632 631 class TypeofType : public Type { 633 632 public: 634 Expression * expr;///< expression to take the type of635 bool is_basetypeof; 636 637 TypeofType( const Type::Qualifiers & tq, Expression * expr, const std::list< Attribute * > & attributes = std::list< Attribute * >() );638 TypeofType( const Type::Qualifiers & tq, Expression * expr, bool is_basetypeof,633 Expression * expr; ///< expression to take the type of 634 bool is_basetypeof; ///< true iff is basetypeof type 635 636 TypeofType( const Type::Qualifiers & tq, Expression * expr, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 637 TypeofType( const Type::Qualifiers & tq, Expression * expr, bool is_basetypeof, 639 638 const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 640 639 TypeofType( const TypeofType& ); 641 640 virtual ~TypeofType(); 642 641 643 Expression * get_expr() const { return expr; }644 void set_expr( Expression * newValue ) { expr = newValue; }642 Expression * get_expr() const { return expr; } 643 void set_expr( Expression * newValue ) { expr = newValue; } 645 644 646 645 virtual bool isComplete() const override { assert( false ); return false; } 647 646 648 virtual TypeofType * clone() const override { return new TypeofType( *this ); }649 virtual void accept( Visitor & v ) override { v.visit( this ); } 650 virtual void accept( Visitor & v ) const override { v.visit( this ); } 651 virtual Type * acceptMutator( Mutator & m ) override { return m.mutate( this ); }647 virtual TypeofType * clone() const override { return new TypeofType( *this ); } 648 virtual void accept( Visitor & v ) override { v.visit( this ); } 649 virtual void accept( Visitor & v ) const override { v.visit( this ); } 650 virtual Type * acceptMutator( Mutator & m ) override { return m.mutate( this ); } 652 651 virtual void print( std::ostream & os, Indenter indent = {} ) const override; 653 652 }; … … 655 654 class VTableType : public Type { 656 655 public: 657 Type * base;658 659 VTableType( const Type::Qualifiers & tq, Type * base,656 Type * base; 657 658 VTableType( const Type::Qualifiers & tq, Type * base, 660 659 const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 661 660 VTableType( const VTableType & ); 662 661 virtual ~VTableType(); 663 662 664 Type * get_base() { return base; }665 void set_base( Type * newValue ) { base = newValue; }666 667 virtual VTableType * clone() const override { return new VTableType( *this ); }668 virtual void accept( Visitor & v ) override { v.visit( this ); } 669 virtual void accept( Visitor & v ) const override { v.visit( this ); } 670 virtual Type * acceptMutator( Mutator & m ) override { return m.mutate( this ); }663 Type * get_base() { return base; } 664 void set_base( Type * newValue ) { base = newValue; } 665 666 virtual VTableType * clone() const override { return new VTableType( *this ); } 667 virtual void accept( Visitor & v ) override { v.visit( this ); } 668 virtual void accept( Visitor & v ) const override { v.visit( this ); } 669 virtual Type * acceptMutator( Mutator & m ) override { return m.mutate( this ); } 671 670 virtual void print( std::ostream & os, Indenter indent = {} ) const override; 672 671 }; … … 675 674 public: 676 675 std::string name; 677 Expression * expr;678 Type * type;676 Expression * expr; 677 Type * type; 679 678 bool isType; 680 679 681 AttrType( const Type::Qualifiers & tq, const std::string & name, Expression * expr, const std::list< Attribute * > & attributes = std::list< Attribute * >() );682 AttrType( const Type::Qualifiers & tq, const std::string & name, Type * type, const std::list< Attribute * > & attributes = std::list< Attribute * >() );680 AttrType( const Type::Qualifiers & tq, const std::string & name, Expression * expr, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 681 AttrType( const Type::Qualifiers & tq, const std::string & name, Type * type, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 683 682 AttrType( const AttrType& ); 684 683 virtual ~AttrType(); … … 686 685 const std::string & get_name() const { return name; } 687 686 void set_name( const std::string & newValue ) { name = newValue; } 688 Expression * get_expr() const { return expr; }689 void set_expr( Expression * newValue ) { expr = newValue; }690 Type * get_type() const { return type; }691 void set_type( Type * newValue ) { type = newValue; }687 Expression * get_expr() const { return expr; } 688 void set_expr( Expression * newValue ) { expr = newValue; } 689 Type * get_type() const { return type; } 690 void set_type( Type * newValue ) { type = newValue; } 692 691 bool get_isType() const { return isType; } 693 692 void set_isType( bool newValue ) { isType = newValue; } … … 695 694 virtual bool isComplete() const override { assert( false ); } // xxx - not sure what to do here 696 695 697 virtual AttrType * clone() const override { return new AttrType( *this ); }698 virtual void accept( Visitor & v ) override { v.visit( this ); } 699 virtual void accept( Visitor & v ) const override { v.visit( this ); } 700 virtual Type * acceptMutator( Mutator & m ) override { return m.mutate( this ); }696 virtual AttrType * clone() const override { return new AttrType( *this ); } 697 virtual void accept( Visitor & v ) override { v.visit( this ); } 698 virtual void accept( Visitor & v ) const override { v.visit( this ); } 699 virtual Type * acceptMutator( Mutator & m ) override { return m.mutate( this ); } 701 700 virtual void print( std::ostream & os, Indenter indent = {} ) const override; 702 701 }; … … 710 709 virtual bool isComplete() const override{ return true; } // xxx - is this right? 711 710 712 virtual VarArgsType * clone() const override { return new VarArgsType( *this ); }713 virtual void accept( Visitor & v ) override { v.visit( this ); } 714 virtual void accept( Visitor & v ) const override { v.visit( this ); } 715 virtual Type * acceptMutator( Mutator & m ) override { return m.mutate( this ); }711 virtual VarArgsType * clone() const override { return new VarArgsType( *this ); } 712 virtual void accept( Visitor & v ) override { v.visit( this ); } 713 virtual void accept( Visitor & v ) const override { v.visit( this ); } 714 virtual Type * acceptMutator( Mutator & m ) override { return m.mutate( this ); } 716 715 virtual void print( std::ostream & os, Indenter indent = {} ) const override; 717 716 }; … … 723 722 ZeroType( Type::Qualifiers tq, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 724 723 725 virtual ZeroType * clone() const override { return new ZeroType( *this ); }726 virtual void accept( Visitor & v ) override { v.visit( this ); } 727 virtual void accept( Visitor & v ) const override { v.visit( this ); } 728 virtual Type * acceptMutator( Mutator & m ) override { return m.mutate( this ); }724 virtual ZeroType * clone() const override { return new ZeroType( *this ); } 725 virtual void accept( Visitor & v ) override { v.visit( this ); } 726 virtual void accept( Visitor & v ) const override { v.visit( this ); } 727 virtual Type * acceptMutator( Mutator & m ) override { return m.mutate( this ); } 729 728 virtual void print( std::ostream & os, Indenter indent = {} ) const override; 730 729 }; … … 736 735 OneType( Type::Qualifiers tq, const std::list< Attribute * > & attributes = std::list< Attribute * >() ); 737 736 738 virtual OneType * clone() const override { return new OneType( *this ); }739 virtual void accept( Visitor & v ) override { v.visit( this ); } 740 virtual void accept( Visitor & v ) const override { v.visit( this ); } 741 virtual Type * acceptMutator( Mutator & m ) override { return m.mutate( this ); }737 virtual OneType * clone() const override { return new OneType( *this ); } 738 virtual void accept( Visitor & v ) override { v.visit( this ); } 739 virtual void accept( Visitor & v ) const override { v.visit( this ); } 740 virtual Type * acceptMutator( Mutator & m ) override { return m.mutate( this ); } 742 741 virtual void print( std::ostream & os, Indenter indent = {} ) const override; 743 742 }; … … 747 746 GlobalScopeType(); 748 747 749 virtual GlobalScopeType * clone() const override { return new GlobalScopeType( *this ); }750 virtual void accept( Visitor & v ) override { v.visit( this ); } 751 virtual void accept( Visitor & v ) const override { v.visit( this ); } 752 virtual Type * acceptMutator( Mutator & m ) override { return m.mutate( this ); }748 virtual GlobalScopeType * clone() const override { return new GlobalScopeType( *this ); } 749 virtual void accept( Visitor & v ) override { v.visit( this ); } 750 virtual void accept( Visitor & v ) const override { v.visit( this ); } 751 virtual Type * acceptMutator( Mutator & m ) override { return m.mutate( this ); } 753 752 virtual void print( std::ostream & os, Indenter indent = {} ) const override; 754 753 };
Note:
See TracChangeset
for help on using the changeset viewer.