Changeset c0aa336 for src/SynTree/Type.h


Ignore:
Timestamp:
Feb 6, 2017, 4:19:41 PM (7 years ago)
Author:
Peter A. Buhr <pabuhr@…>
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:
b4d65c7
Parents:
a362f97
Message:

third attempt at gcc attributes

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/Type.h

    ra362f97 rc0aa336  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Jul 13 11:46:54 2016
    13 // Update Count     : 23
     12// Last Modified On : Thu Feb  2 17:43:01 2017
     13// Update Count     : 33
    1414//
    1515
     
    2525  public:
    2626        struct Qualifiers {
    27                 Qualifiers(): isConst( false ), isVolatile( false ), isRestrict( false ), isLvalue( false ), isAtomic( false ), isAttribute( false ) {}
    28                 Qualifiers( bool isConst, bool isVolatile, bool isRestrict, bool isLvalue, bool isAtomic, bool isAttribute ): isConst( isConst ), isVolatile( isVolatile ), isRestrict( isRestrict ), isLvalue( isLvalue ), isAtomic( isAtomic ), isAttribute( isAttribute ) {}
     27                Qualifiers(): isConst( false ), isVolatile( false ), isRestrict( false ), isLvalue( false ), isAtomic( false ) {}
     28                Qualifiers( bool isConst, bool isVolatile, bool isRestrict, bool isLvalue, bool isAtomic ): isConst( isConst ), isVolatile( isVolatile ), isRestrict( isRestrict ), isLvalue( isLvalue ), isAtomic( isAtomic ) {}
    2929
    3030                Qualifiers &operator&=( const Qualifiers &other );
     
    4545                bool isLvalue;
    4646                bool isAtomic;
    47                 bool isAttribute;
    4847        };
    4948
    50         Type( const Qualifiers &tq );
     49        Type( const Qualifiers &tq, const std::list< Attribute * > & attributes );
    5150        Type( const Type &other );
    5251        virtual ~Type();
     
    5857        bool get_isLvalue() { return tq.isLvalue; }
    5958        bool get_isAtomic() { return tq.isAtomic; }
    60         bool get_isAttribute() { return tq.isAttribute; }
    6159        void set_isConst( bool newValue ) { tq.isConst = newValue; }
    6260        void set_isVolatile( bool newValue ) { tq.isVolatile = newValue; }
     
    6462        void set_isLvalue( bool newValue ) { tq.isLvalue = newValue; }
    6563        void set_isAtomic( bool newValue ) { tq.isAtomic = newValue; }
    66         void set_isAttribute( bool newValue ) { tq.isAttribute = newValue; }
    6764
    6865        typedef std::list<TypeDecl *> ForallList;
    6966        ForallList& get_forall() { return forall; }
     67
     68        std::list< Attribute * >& get_attributes() { return attributes; }
     69        const std::list< Attribute * >& get_attributes() const { return attributes; }
    7070
    7171        /// How many elemental types are represented by this type
     
    8383        Qualifiers tq;
    8484        ForallList forall;
     85        std::list< Attribute * > attributes;
    8586};
    8687
     
    8990class VoidType : public Type {
    9091  public:
    91         VoidType( const Type::Qualifiers &tq );
     92        VoidType( const Type::Qualifiers &tq, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
    9293
    9394        virtual unsigned size() const { return 0; };
     
    129130        static const char *typeNames[];                                         // string names for basic types, MUST MATCH with Kind
    130131
    131         BasicType( const Type::Qualifiers &tq, Kind bt );
     132        BasicType( const Type::Qualifiers &tq, Kind bt, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
    132133
    133134        Kind get_kind() { return kind; }
     
    146147class PointerType : public Type {
    147148  public:
    148         PointerType( const Type::Qualifiers &tq, Type *base );
    149         PointerType( const Type::Qualifiers &tq, Type *base, Expression *dimension, bool isVarLen, bool isStatic );
     149        PointerType( const Type::Qualifiers &tq, Type *base, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
     150        PointerType( const Type::Qualifiers &tq, Type *base, Expression *dimension, bool isVarLen, bool isStatic, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
    150151        PointerType( const PointerType& );
    151152        virtual ~PointerType();
     
    175176class ArrayType : public Type {
    176177  public:
    177         ArrayType( const Type::Qualifiers &tq, Type *base, Expression *dimension, bool isVarLen, bool isStatic );
     178        ArrayType( const Type::Qualifiers &tq, Type *base, Expression *dimension, bool isVarLen, bool isStatic, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
    178179        ArrayType( const ArrayType& );
    179180        virtual ~ArrayType();
     
    203204class FunctionType : public Type {
    204205  public:
    205         FunctionType( const Type::Qualifiers &tq, bool isVarArgs );
     206        FunctionType( const Type::Qualifiers &tq, bool isVarArgs, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
    206207        FunctionType( const FunctionType& );
    207208        virtual ~FunctionType();
     
    231232class ReferenceToType : public Type {
    232233  public:
    233         ReferenceToType( const Type::Qualifiers &tq, const std::string &name );
     234        ReferenceToType( const Type::Qualifiers &tq, const std::string &name, const std::list< Attribute * > & attributes );
    234235        ReferenceToType( const ReferenceToType &other );
    235236        virtual ~ReferenceToType();
     
    253254        typedef ReferenceToType Parent;
    254255  public:
    255         StructInstType( const Type::Qualifiers &tq, const std::string &name ) : Parent( tq, name ), baseStruct( 0 ) {}
    256         StructInstType( const Type::Qualifiers &tq, StructDecl * baseStruct );
     256        StructInstType( const Type::Qualifiers &tq, const std::string &name, const std::list< Attribute * > & attributes = std::list< Attribute * >()  ) : Parent( tq, name, attributes ), baseStruct( 0 ) {}
     257        StructInstType( const Type::Qualifiers &tq, StructDecl * baseStruct, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
    257258        StructInstType( const StructInstType &other ) : Parent( other ), baseStruct( other.baseStruct ) {}
    258259
     
    285286        typedef ReferenceToType Parent;
    286287  public:
    287         UnionInstType( const Type::Qualifiers &tq, const std::string &name ) : Parent( tq, name ), baseUnion( 0 ) {}
     288        UnionInstType( const Type::Qualifiers &tq, const std::string &name, const std::list< Attribute * > & attributes = std::list< Attribute * >()  ) : Parent( tq, name, attributes ), baseUnion( 0 ) {}
     289        UnionInstType( const Type::Qualifiers &tq, UnionDecl * baseUnion, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
    288290        UnionInstType( const UnionInstType &other ) : Parent( other ), baseUnion( other.baseUnion ) {}
    289291
    290292        UnionDecl *get_baseUnion() const { return baseUnion; }
    291         void set_baseUnion( UnionDecl *newValue ) { baseUnion = newValue; }
     293        void set_baseUnion( UnionDecl * newValue ) { baseUnion = newValue; }
    292294
    293295        /// Accesses generic parameters of base union (NULL if none such)
    294         std::list<TypeDecl*> * get_baseParameters();
     296        std::list< TypeDecl * > * get_baseParameters();
    295297
    296298        virtual bool isComplete() const;
     
    316318        typedef ReferenceToType Parent;
    317319  public:
    318         EnumInstType( const Type::Qualifiers &tq, const std::string &name ) : Parent( tq, name ) {}
    319         EnumInstType( const EnumInstType &other ) : Parent( other ) {}
    320 
    321         // xxx - enum inst does not currently contain a pointer to base, this should be fixed.
    322         // virtual bool isComplete() const { return baseEnum()->hasBody(); }
     320        EnumInstType( const Type::Qualifiers &tq, const std::string &name, const std::list< Attribute * > & attributes = std::list< Attribute * >()  ) : Parent( tq, name, attributes ) {}
     321        EnumInstType( const Type::Qualifiers &tq, EnumDecl * baseEnum, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
     322        EnumInstType( const EnumInstType &other ) : Parent( other ), baseEnum( other.baseEnum ) {}
     323
     324        EnumDecl *get_baseEnum() const { return baseEnum; }
     325        void set_baseEnum( EnumDecl *newValue ) { baseEnum = newValue; }
     326
     327        virtual bool isComplete() const;
    323328
    324329        virtual EnumInstType *clone() const { return new EnumInstType( *this ); }
     
    327332  private:
    328333        virtual std::string typeString() const;
     334
     335        // this decl is not "owned" by the union inst; it is merely a pointer to elsewhere in the tree,
     336        // where the union used in this type is actually defined
     337        EnumDecl *baseEnum = nullptr;
    329338};
    330339
     
    332341        typedef ReferenceToType Parent;
    333342  public:
    334         TraitInstType( const Type::Qualifiers &tq, const std::string &name ) : Parent( tq, name ) {}
     343        TraitInstType( const Type::Qualifiers &tq, const std::string &name, const std::list< Attribute * > & attributes = std::list< Attribute * >()  ) : Parent( tq, name, attributes ) {}
    335344        TraitInstType( const TraitInstType &other );
    336345        ~TraitInstType();
     
    354363        typedef ReferenceToType Parent;
    355364  public:
    356         TypeInstType( const Type::Qualifiers &tq, const std::string &name, TypeDecl *baseType );
    357         TypeInstType( const Type::Qualifiers &tq, const std::string &name, bool isFtype );
     365        TypeInstType( const Type::Qualifiers &tq, const std::string &name, TypeDecl *baseType, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
     366        TypeInstType( const Type::Qualifiers &tq, const std::string &name, bool isFtype, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
    358367        TypeInstType( const TypeInstType &other );
    359368        ~TypeInstType();
     
    380389class TupleType : public Type {
    381390  public:
    382         TupleType( const Type::Qualifiers &tq, const std::list< Type * > & types = std::list< Type * >() );
     391        TupleType( const Type::Qualifiers &tq, const std::list< Type * > & types = std::list< Type * >(), const std::list< Attribute * > & attributes = std::list< Attribute * >() );
    383392        TupleType( const TupleType& );
    384393        virtual ~TupleType();
     
    410419class TypeofType : public Type {
    411420  public:
    412         TypeofType( const Type::Qualifiers &tq, Expression *expr );
     421        TypeofType( const Type::Qualifiers &tq, Expression *expr, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
    413422        TypeofType( const TypeofType& );
    414423        virtual ~TypeofType();
     
    429438class AttrType : public Type {
    430439  public:
    431         AttrType( const Type::Qualifiers &tq, const std::string &name, Expression *expr );
    432         AttrType( const Type::Qualifiers &tq, const std::string &name, Type *type );
     440        AttrType( const Type::Qualifiers &tq, const std::string &name, Expression *expr, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
     441        AttrType( const Type::Qualifiers &tq, const std::string &name, Type *type, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
    433442        AttrType( const AttrType& );
    434443        virtual ~AttrType();
     
    460469  public:
    461470        VarArgsType();
    462         VarArgsType( Type::Qualifiers tq );
     471        VarArgsType( Type::Qualifiers tq, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
    463472
    464473        virtual bool isComplete() const{ return true; } // xxx - is this right?
     
    474483  public:
    475484        ZeroType();
    476         ZeroType( Type::Qualifiers tq );
     485        ZeroType( Type::Qualifiers tq, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
    477486
    478487        virtual ZeroType *clone() const { return new ZeroType( *this ); }
     
    486495  public:
    487496        OneType();
    488         OneType( Type::Qualifiers tq );
     497        OneType( Type::Qualifiers tq, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
    489498
    490499        virtual OneType *clone() const { return new OneType( *this ); }
Note: See TracChangeset for help on using the changeset viewer.