Changeset 9236060 for src/SynTree/Type.h


Ignore:
Timestamp:
Aug 14, 2017, 2:03:39 PM (7 years ago)
Author:
Rob Schluntz <rschlunt@…>
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:
74b007ba
Parents:
fd344aa (diff), 54cd58b (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' into references

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/Type.h

    rfd344aa r9236060  
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Mar 23 16:16:36 2017
    13 // Update Count     : 149
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Wed Aug  9 14:25:00 2017
     13// Update Count     : 152
    1414//
    1515
    16 #ifndef TYPE_H
    17 #define TYPE_H
     16#pragma once
    1817
    1918#include "BaseSyntaxNode.h"
     
    128127        }; // Qualifiers
    129128
     129        typedef std::list<TypeDecl *> ForallList;
     130
     131        Qualifiers tq;
     132        ForallList forall;
     133        std::list< Attribute * > attributes;
     134
    130135        Type( const Qualifiers & tq, const std::list< Attribute * > & attributes );
    131136        Type( const Type & other );
     
    146151        void set_atomic( bool newValue ) { tq.is_atomic = newValue; }
    147152
    148         typedef std::list<TypeDecl *> ForallList;
    149153        ForallList& get_forall() { return forall; }
    150154
     
    172176        virtual Type *acceptMutator( Mutator & m ) = 0;
    173177        virtual void print( std::ostream & os, int indent = 0 ) const;
    174   private:
    175         Qualifiers tq;
    176         ForallList forall;
    177         std::list< Attribute * > attributes;
    178 };
    179 
    180 extern Type::Qualifiers emptyQualifiers;                                // no qualifiers on constants
     178};
     179
     180extern const Type::FuncSpecifiers noFuncSpecifiers;
     181extern const Type::StorageClasses noStorageClasses;
     182extern const Type::Qualifiers noQualifiers;                     // no qualifiers on constants
    181183
    182184class VoidType : public Type {
     
    218220                LongDoubleImaginary,
    219221                NUMBER_OF_BASIC_TYPES
    220         };
     222        } kind;
    221223
    222224        static const char *typeNames[];                                         // string names for basic types, MUST MATCH with Kind
     
    233235
    234236        bool isInteger() const;
    235   private:
    236         Kind kind;
    237237};
    238238
    239239class PointerType : public Type {
    240240  public:
     241        Type *base;
     242
     243        // In C99, pointer types can be qualified in many ways e.g., int f( int a[ static 3 ] )
     244        Expression *dimension;
     245        bool isVarLen;
     246        bool isStatic;
     247
    241248        PointerType( const Type::Qualifiers & tq, Type *base, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
    242249        PointerType( const Type::Qualifiers & tq, Type *base, Expression *dimension, bool isVarLen, bool isStatic, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
     
    261268        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
    262269        virtual void print( std::ostream & os, int indent = 0 ) const;
    263   private:
     270};
     271
     272class ArrayType : public Type {
     273  public:
    264274        Type *base;
    265 
    266         // In C99, pointer types can be qualified in many ways e.g., int f( int a[ static 3 ] )
    267275        Expression *dimension;
    268276        bool isVarLen;
    269277        bool isStatic;
    270 };
    271 
    272 class ArrayType : public Type {
    273   public:
     278
    274279        ArrayType( const Type::Qualifiers & tq, Type *base, Expression *dimension, bool isVarLen, bool isStatic, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
    275280        ArrayType( const ArrayType& );
     
    291296        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
    292297        virtual void print( std::ostream & os, int indent = 0 ) const;
    293   private:
    294         Type *base;
    295         Expression *dimension;
    296         bool isVarLen;
    297         bool isStatic;
    298298};
    299299
    300300class ReferenceType : public Type {
    301301public:
     302        Type *base;
     303
    302304        ReferenceType( const Type::Qualifiers & tq, Type *base, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
    303305        ReferenceType( const ReferenceType & );
     
    313315        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
    314316        virtual void print( std::ostream & os, int indent = 0 ) const;
    315 private:
    316         Type *base;
    317317};
    318318
    319319class FunctionType : public Type {
    320320  public:
     321        std::list<DeclarationWithType*> returnVals;
     322        std::list<DeclarationWithType*> parameters;
     323
     324        // Does the function accept a variable number of arguments following the arguments specified in the parameters list.
     325        // This could be because of
     326        // - an ellipsis in a prototype declaration
     327        // - an unprototyped declaration
     328        bool isVarArgs;
     329
    321330        FunctionType( const Type::Qualifiers & tq, bool isVarArgs, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
    322331        FunctionType( const FunctionType& );
     
    333342        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
    334343        virtual void print( std::ostream & os, int indent = 0 ) const;
    335   private:
    336         std::list<DeclarationWithType*> returnVals;
    337         std::list<DeclarationWithType*> parameters;
    338 
    339         // Does the function accept a variable number of arguments following the arguments specified in the parameters list.
    340         // This could be because of
    341         // - an ellipsis in a prototype declaration
    342         // - an unprototyped declaration
    343         bool isVarArgs;
    344344};
    345345
    346346class ReferenceToType : public Type {
    347347  public:
     348        std::list< Expression* > parameters;
     349        std::string name;
     350        bool hoistType;
     351
    348352        ReferenceToType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes );
    349353        ReferenceToType( const ReferenceToType & other );
     
    364368  protected:
    365369        virtual std::string typeString() const = 0;
    366         std::list< Expression* > parameters;
    367         std::string name;
    368   private:
    369         bool hoistType;
    370370};
    371371
     
    373373        typedef ReferenceToType Parent;
    374374  public:
     375        // this decl is not "owned" by the struct inst; it is merely a pointer to elsewhere in the tree,
     376        // where the structure used in this type is actually defined
     377        StructDecl *baseStruct;
     378
    375379        StructInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >()  ) : Parent( tq, name, attributes ), baseStruct( 0 ) {}
    376380        StructInstType( const Type::Qualifiers & tq, StructDecl * baseStruct, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
     
    396400  private:
    397401        virtual std::string typeString() const;
    398 
    399         // this decl is not "owned" by the struct inst; it is merely a pointer to elsewhere in the tree,
    400         // where the structure used in this type is actually defined
    401         StructDecl *baseStruct;
    402402};
    403403
     
    405405        typedef ReferenceToType Parent;
    406406  public:
     407        // this decl is not "owned" by the union inst; it is merely a pointer to elsewhere in the tree,
     408        // where the union used in this type is actually defined
     409        UnionDecl *baseUnion;
     410
    407411        UnionInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >()  ) : Parent( tq, name, attributes ), baseUnion( 0 ) {}
    408412        UnionInstType( const Type::Qualifiers & tq, UnionDecl * baseUnion, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
     
    428432  private:
    429433        virtual std::string typeString() const;
    430 
     434};
     435
     436class EnumInstType : public ReferenceToType {
     437        typedef ReferenceToType Parent;
     438  public:
    431439        // this decl is not "owned" by the union inst; it is merely a pointer to elsewhere in the tree,
    432440        // where the union used in this type is actually defined
    433         UnionDecl *baseUnion;
    434 };
    435 
    436 class EnumInstType : public ReferenceToType {
    437         typedef ReferenceToType Parent;
    438   public:
     441        EnumDecl *baseEnum = nullptr;
     442
    439443        EnumInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >()  ) : Parent( tq, name, attributes ) {}
    440444        EnumInstType( const Type::Qualifiers & tq, EnumDecl * baseEnum, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
     
    451455  private:
    452456        virtual std::string typeString() const;
    453 
    454         // this decl is not "owned" by the union inst; it is merely a pointer to elsewhere in the tree,
    455         // where the union used in this type is actually defined
    456         EnumDecl *baseEnum = nullptr;
    457457};
    458458
     
    460460        typedef ReferenceToType Parent;
    461461  public:
     462        // this member is filled in by the validate pass, which instantiates the members of the correponding
     463        // aggregate with the actual type parameters specified for this use of the context
     464        std::list< Declaration* > members;
     465
    462466        TraitInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >()  ) : Parent( tq, name, attributes ) {}
    463467        TraitInstType( const TraitInstType & other );
     
    473477  private:
    474478        virtual std::string typeString() const;
    475 
    476         // this member is filled in by the validate pass, which instantiates the members of the correponding
    477         // aggregate with the actual type parameters specified for this use of the context
    478         std::list< Declaration* > members;
    479479};
    480480
     
    482482        typedef ReferenceToType Parent;
    483483  public:
     484        // this decl is not "owned" by the type inst; it is merely a pointer to elsewhere in the tree,
     485        // where the type used here is actually defined
     486        TypeDecl *baseType;
     487        bool isFtype;
     488
    484489        TypeInstType( const Type::Qualifiers & tq, const std::string & name, TypeDecl *baseType, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
    485490        TypeInstType( const Type::Qualifiers & tq, const std::string & name, bool isFtype, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
     
    500505  private:
    501506        virtual std::string typeString() const;
    502         // this decl is not "owned" by the type inst; it is merely a pointer to elsewhere in the tree,
    503         // where the type used here is actually defined
    504         TypeDecl *baseType;
    505         bool isFtype;
    506507};
    507508
    508509class TupleType : public Type {
    509510  public:
     511        std::list<Type *> types;
     512        std::list<Declaration *> members;
     513
    510514        TupleType( const Type::Qualifiers & tq, const std::list< Type * > & types, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
    511515        TupleType( const TupleType& );
     
    536540        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
    537541        virtual void print( std::ostream & os, int indent = 0 ) const;
    538   private:
    539         std::list<Type *> types;
    540         std::list<Declaration *> members;
    541542};
    542543
    543544class TypeofType : public Type {
    544545  public:
     546        Expression *expr;
     547
    545548        TypeofType( const Type::Qualifiers & tq, Expression *expr, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
    546549        TypeofType( const TypeofType& );
     
    556559        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
    557560        virtual void print( std::ostream & os, int indent = 0 ) const;
    558   private:
     561};
     562
     563class AttrType : public Type {
     564  public:
     565        std::string name;
    559566        Expression *expr;
    560 };
    561 
    562 class AttrType : public Type {
    563   public:
     567        Type *type;
     568        bool isType;
     569
    564570        AttrType( const Type::Qualifiers & tq, const std::string & name, Expression *expr, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
    565571        AttrType( const Type::Qualifiers & tq, const std::string & name, Type *type, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
     
    582588        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
    583589        virtual void print( std::ostream & os, int indent = 0 ) const;
    584   private:
    585         std::string name;
    586         Expression *expr;
    587         Type *type;
    588         bool isType;
    589590};
    590591
     
    628629
    629630std::ostream & operator<<( std::ostream & out, const Type * type );
    630 
    631 #endif // TYPE_H
    632631
    633632// Local Variables: //
Note: See TracChangeset for help on using the changeset viewer.