Changeset 246c245 for src/AST/Type.hpp


Ignore:
Timestamp:
May 16, 2019, 6:51:18 PM (5 years ago)
Author:
Aaron Moss <a3moss@…>
Branches:
ADT, arm-eh, ast-experimental, cleanup-dtors, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
8ff178d, d66e7b7
Parents:
9b4f329 (diff), 6f8e87d (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.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Type.hpp

    r9b4f329 r246c245  
    3030
    3131// Must be included in *all* AST classes; should be #undef'd at the end of the file
    32 #define MUTATE_FRIEND template<typename node_t> friend auto mutate(const node_t * node);
     32#define MUTATE_FRIEND template<typename node_t> friend node_t * mutate(const node_t * node);
    3333
    3434namespace ast {
     
    3737public:
    3838        CV::Qualifiers qualifiers;
    39        
     39
    4040        Type( CV::Qualifiers q = {} ) : qualifiers(q) {}
    4141
     
    8080public:
    8181        VoidType( CV::Qualifiers q = {} ) : Type( q ) {}
    82        
     82
    8383        unsigned size() const override { return 0; }
    8484        bool isVoid() const override { return true; }
     
    171171
    172172        PointerType( const Type * b, CV::Qualifiers q = {} ) : Type(q), base(b), dimension() {}
    173         PointerType( const Type * b, const Expr * d, LengthFlag vl, DimensionFlag s, 
     173        PointerType( const Type * b, const Expr * d, LengthFlag vl, DimensionFlag s,
    174174                CV::Qualifiers q = {} ) : Type(q), base(b), dimension(d), isVarLen(vl), isStatic(s) {}
    175175
     
    193193        DimensionFlag isStatic;
    194194
    195         ArrayType( const Type * b, const Expr * d, LengthFlag vl, DimensionFlag s, 
     195        ArrayType( const Type * b, const Expr * d, LengthFlag vl, DimensionFlag s,
    196196                CV::Qualifiers q = {} ) : Type(q), base(b), dimension(d), isVarLen(vl), isStatic(s) {}
    197197
     
    233233        ptr<Type> child;
    234234
    235         QualifiedType( const Type * p, const Type * c, CV::Qualifiers q = {} ) 
     235        QualifiedType( const Type * p, const Type * c, CV::Qualifiers q = {} )
    236236        : Type(q), parent(p), child(c) {}
    237237
     
    249249        ForallList forall;
    250250
    251         ParameterizedType( ForallList&& fs = {}, CV::Qualifiers q = {} ) 
     251        ParameterizedType( ForallList&& fs = {}, CV::Qualifiers q = {} )
    252252        : Type(q), forall(std::move(fs)) {}
    253253        ParameterizedType( CV::Qualifiers q ) : Type(q), forall() {}
     
    267267        std::vector<ptr<DeclWithType>> params;
    268268
    269         /// Does the function accept a variable number of arguments following the arguments specified 
     269        /// Does the function accept a variable number of arguments following the arguments specified
    270270        /// in the parameters list.
    271271        /// This could be because of
     
    296296        bool hoistType = false;
    297297
    298         ReferenceToType( const std::string& n, CV::Qualifiers q = {}, 
     298        ReferenceToType( const std::string& n, CV::Qualifiers q = {},
    299299                std::vector<ptr<Attribute>> && as = {} )
    300300        : ParameterizedType(q), params(), attributes(std::move(as)), name(n) {}
     
    319319        readonly<StructDecl> base;
    320320
    321         StructInstType( const std::string& n, CV::Qualifiers q = {}, 
     321        StructInstType( const std::string& n, CV::Qualifiers q = {},
    322322                std::vector<ptr<Attribute>> && as = {} )
    323323        : ReferenceToType( n, q, std::move(as) ), base() {}
    324         StructInstType( const StructDecl * b, CV::Qualifiers q = {}, 
     324        StructInstType( const StructDecl * b, CV::Qualifiers q = {},
    325325                std::vector<ptr<Attribute>> && as = {} );
    326        
     326
    327327        bool isComplete() const override;
    328328
     
    342342        readonly<UnionDecl> base;
    343343
    344         UnionInstType( const std::string& n, CV::Qualifiers q = {}, 
     344        UnionInstType( const std::string& n, CV::Qualifiers q = {},
    345345                std::vector<ptr<Attribute>> && as = {} )
    346346        : ReferenceToType( n, q, std::move(as) ), base() {}
    347         UnionInstType( const UnionDecl * b, CV::Qualifiers q = {}, 
     347        UnionInstType( const UnionDecl * b, CV::Qualifiers q = {},
    348348                std::vector<ptr<Attribute>> && as = {} );
    349        
     349
    350350        bool isComplete() const override;
    351351
     
    365365        readonly<EnumDecl> base;
    366366
    367         EnumInstType( const std::string& n, CV::Qualifiers q = {}, 
     367        EnumInstType( const std::string& n, CV::Qualifiers q = {},
    368368                std::vector<ptr<Attribute>> && as = {} )
    369369        : ReferenceToType( n, q, std::move(as) ), base() {}
    370         EnumInstType( const EnumDecl * b, CV::Qualifiers q = {}, 
     370        EnumInstType( const EnumDecl * b, CV::Qualifiers q = {},
    371371                std::vector<ptr<Attribute>> && as = {} );
    372        
     372
    373373        bool isComplete() const override;
    374374
     
    388388        readonly<TraitDecl> base;
    389389
    390         TraitInstType( const std::string& n, CV::Qualifiers q = {}, 
     390        TraitInstType( const std::string& n, CV::Qualifiers q = {},
    391391                std::vector<ptr<Attribute>> && as = {} )
    392392        : ReferenceToType( n, q, std::move(as) ), base() {}
    393         TraitInstType( const TraitDecl * b, CV::Qualifiers q = {}, 
     393        TraitInstType( const TraitDecl * b, CV::Qualifiers q = {},
    394394                std::vector<ptr<Attribute>> && as = {} );
    395        
     395
    396396        // not meaningful for TraitInstType
    397397        bool isComplete() const override { assert(false); }
     
    413413        TypeVar::Kind kind;
    414414
    415         TypeInstType( const std::string& n, const TypeDecl * b, CV::Qualifiers q = {}, 
     415        TypeInstType( const std::string& n, const TypeDecl * b, CV::Qualifiers q = {},
    416416                std::vector<ptr<Attribute>> && as = {} )
    417417        : ReferenceToType( n, q, std::move(as) ), base( b ), kind( b->kind ) {}
    418         TypeInstType( const std::string& n, TypeVar::Kind k, CV::Qualifiers q = {}, 
     418        TypeInstType( const std::string& n, TypeVar::Kind k, CV::Qualifiers q = {},
    419419                std::vector<ptr<Attribute>> && as = {} )
    420420        : ReferenceToType( n, q, std::move(as) ), base(), kind( k ) {}
     
    448448        iterator begin() const { return types.begin(); }
    449449        iterator end() const { return types.end(); }
    450        
     450
    451451        unsigned size() const override { return types.size(); }
    452452
    453453        const Type * getComponent( unsigned i ) override {
    454                 assertf( i < size(), "TupleType::getComponent: index %d must be less than size %d", 
     454                assertf( i < size(), "TupleType::getComponent: index %d must be less than size %d",
    455455                        i, size() );
    456456                return *(begin()+i);
     
    469469        enum Kind { Typeof, Basetypeof } kind;
    470470
    471         TypeofType( const Expr * e, Kind k = Typeof, CV::Qualifiers q = {} ) 
     471        TypeofType( const Expr * e, Kind k = Typeof, CV::Qualifiers q = {} )
    472472        : Type(q), expr(e), kind(k) {}
    473473
     
    482482public:
    483483        VarArgsType( CV::Qualifiers q = {} ) : Type( q ) {}
    484        
     484
    485485        const Type * accept( Visitor & v ) const override { return v.visit( this ); }
    486486private:
     
    493493public:
    494494        ZeroType( CV::Qualifiers q = {} ) : Type( q ) {}
    495        
     495
    496496        const Type * accept( Visitor & v ) const override { return v.visit( this ); }
    497497private:
     
    521521        MUTATE_FRIEND
    522522};
    523 
    524 //=================================================================================================
    525 /// This disgusting and giant piece of boiler-plate is here to solve a cyclic dependency
    526 /// remove only if there is a better solution.
    527 /// The problem is that ast::ptr< ... > uses increment/decrement which won't work well with
    528 /// forward declarations
    529 inline void increment( const class Type * node, Node::ref_type ref ) { node->increment( ref ); }
    530 inline void decrement( const class Type * node, Node::ref_type ref ) { node->decrement( ref ); }
    531 inline void increment( const class VoidType * node, Node::ref_type ref ) { node->increment( ref ); }
    532 inline void decrement( const class VoidType * node, Node::ref_type ref ) { node->decrement( ref ); }
    533 inline void increment( const class BasicType * node, Node::ref_type ref ) { node->increment( ref ); }
    534 inline void decrement( const class BasicType * node, Node::ref_type ref ) { node->decrement( ref ); }
    535 inline void increment( const class PointerType * node, Node::ref_type ref ) { node->increment( ref ); }
    536 inline void decrement( const class PointerType * node, Node::ref_type ref ) { node->decrement( ref ); }
    537 inline void increment( const class ArrayType * node, Node::ref_type ref ) { node->increment( ref ); }
    538 inline void decrement( const class ArrayType * node, Node::ref_type ref ) { node->decrement( ref ); }
    539 inline void increment( const class ReferenceType * node, Node::ref_type ref ) { node->increment( ref ); }
    540 inline void decrement( const class ReferenceType * node, Node::ref_type ref ) { node->decrement( ref ); }
    541 inline void increment( const class QualifiedType * node, Node::ref_type ref ) { node->increment( ref ); }
    542 inline void decrement( const class QualifiedType * node, Node::ref_type ref ) { node->decrement( ref ); }
    543 inline void increment( const class FunctionType * node, Node::ref_type ref ) { node->increment( ref ); }
    544 inline void decrement( const class FunctionType * node, Node::ref_type ref ) { node->decrement( ref ); }
    545 inline void increment( const class ReferenceToType * node, Node::ref_type ref ) { node->increment( ref ); }
    546 inline void decrement( const class ReferenceToType * node, Node::ref_type ref ) { node->decrement( ref ); }
    547 inline void increment( const class StructInstType * node, Node::ref_type ref ) { node->increment( ref ); }
    548 inline void decrement( const class StructInstType * node, Node::ref_type ref ) { node->decrement( ref ); }
    549 inline void increment( const class UnionInstType * node, Node::ref_type ref ) { node->increment( ref ); }
    550 inline void decrement( const class UnionInstType * node, Node::ref_type ref ) { node->decrement( ref ); }
    551 inline void increment( const class EnumInstType * node, Node::ref_type ref ) { node->increment( ref ); }
    552 inline void decrement( const class EnumInstType * node, Node::ref_type ref ) { node->decrement( ref ); }
    553 inline void increment( const class TraitInstType * node, Node::ref_type ref ) { node->increment( ref ); }
    554 inline void decrement( const class TraitInstType * node, Node::ref_type ref ) { node->decrement( ref ); }
    555 inline void increment( const class TypeInstType * node, Node::ref_type ref ) { node->increment( ref ); }
    556 inline void decrement( const class TypeInstType * node, Node::ref_type ref ) { node->decrement( ref ); }
    557 inline void increment( const class TupleType * node, Node::ref_type ref ) { node->increment( ref ); }
    558 inline void decrement( const class TupleType * node, Node::ref_type ref ) { node->decrement( ref ); }
    559 inline void increment( const class TypeofType * node, Node::ref_type ref ) { node->increment( ref ); }
    560 inline void decrement( const class TypeofType * node, Node::ref_type ref ) { node->decrement( ref ); }
    561 inline void increment( const class VarArgsType * node, Node::ref_type ref ) { node->increment( ref ); }
    562 inline void decrement( const class VarArgsType * node, Node::ref_type ref ) { node->decrement( ref ); }
    563 inline void increment( const class ZeroType * node, Node::ref_type ref ) { node->increment( ref ); }
    564 inline void decrement( const class ZeroType * node, Node::ref_type ref ) { node->decrement( ref ); }
    565 inline void increment( const class OneType * node, Node::ref_type ref ) { node->increment( ref ); }
    566 inline void decrement( const class OneType * node, Node::ref_type ref ) { node->decrement( ref ); }
    567 inline void increment( const class GlobalScopeType * node, Node::ref_type ref ) { node->increment( ref ); }
    568 inline void decrement( const class GlobalScopeType * node, Node::ref_type ref ) { node->decrement( ref ); }
    569523
    570524}
Note: See TracChangeset for help on using the changeset viewer.