Changeset 65cdc1e for src/SynTree/Type.h


Ignore:
Timestamp:
Aug 9, 2017, 3:21:58 PM (4 years ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, demangler, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, resolv-new, with_gc
Children:
0ec9229
Parents:
cbce272
Message:

Syntax Nodes give public access to the fields with effective public access.X

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/Type.h

    rcbce272 r65cdc1e  
    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 : Sat Jul 22 09:53:29 2017
    13 // Update Count     : 151
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Wed Aug  9 14:25:00 2017
     13// Update Count     : 152
    1414//
    1515
     
    127127        }; // Qualifiers
    128128
     129        typedef std::list<TypeDecl *> ForallList;
     130
     131        Qualifiers tq;
     132        ForallList forall;
     133        std::list< Attribute * > attributes;
     134
    129135        Type( const Qualifiers & tq, const std::list< Attribute * > & attributes );
    130136        Type( const Type & other );
     
    145151        void set_atomic( bool newValue ) { tq.is_atomic = newValue; }
    146152
    147         typedef std::list<TypeDecl *> ForallList;
    148153        ForallList& get_forall() { return forall; }
    149154
     
    165170        virtual Type *acceptMutator( Mutator & m ) = 0;
    166171        virtual void print( std::ostream & os, int indent = 0 ) const;
    167   private:
    168         Qualifiers tq;
    169         ForallList forall;
    170         std::list< Attribute * > attributes;
    171 };
    172 
    173 extern Type::Qualifiers noQualifiers;                           // no qualifiers on constants
     172};
     173
     174extern const Type::FuncSpecifiers noFuncSpecifiers;
     175extern const Type::StorageClasses noStorageClasses;
     176extern const Type::Qualifiers noQualifiers;                     // no qualifiers on constants
    174177
    175178class VoidType : public Type {
     
    211214                LongDoubleImaginary,
    212215                NUMBER_OF_BASIC_TYPES
    213         };
     216        } kind;
    214217
    215218        static const char *typeNames[];                                         // string names for basic types, MUST MATCH with Kind
     
    226229
    227230        bool isInteger() const;
    228   private:
    229         Kind kind;
    230231};
    231232
    232233class PointerType : public Type {
    233234  public:
     235        Type *base;
     236
     237        // In C99, pointer types can be qualified in many ways e.g., int f( int a[ static 3 ] )
     238        Expression *dimension;
     239        bool isVarLen;
     240        bool isStatic;
     241
    234242        PointerType( const Type::Qualifiers & tq, Type *base, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
    235243        PointerType( const Type::Qualifiers & tq, Type *base, Expression *dimension, bool isVarLen, bool isStatic, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
     
    252260        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
    253261        virtual void print( std::ostream & os, int indent = 0 ) const;
    254   private:
     262};
     263
     264class ArrayType : public Type {
     265  public:
    255266        Type *base;
    256 
    257         // In C99, pointer types can be qualified in many ways e.g., int f( int a[ static 3 ] )
    258267        Expression *dimension;
    259268        bool isVarLen;
    260269        bool isStatic;
    261 };
    262 
    263 class ArrayType : public Type {
    264   public:
     270
    265271        ArrayType( const Type::Qualifiers & tq, Type *base, Expression *dimension, bool isVarLen, bool isStatic, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
    266272        ArrayType( const ArrayType& );
     
    282288        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
    283289        virtual void print( std::ostream & os, int indent = 0 ) const;
    284   private:
    285         Type *base;
    286         Expression *dimension;
    287         bool isVarLen;
    288         bool isStatic;
    289290};
    290291
    291292class FunctionType : public Type {
    292293  public:
     294        std::list<DeclarationWithType*> returnVals;
     295        std::list<DeclarationWithType*> parameters;
     296
     297        // Does the function accept a variable number of arguments following the arguments specified in the parameters list.
     298        // This could be because of
     299        // - an ellipsis in a prototype declaration
     300        // - an unprototyped declaration
     301        bool isVarArgs;
     302
    293303        FunctionType( const Type::Qualifiers & tq, bool isVarArgs, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
    294304        FunctionType( const FunctionType& );
     
    305315        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
    306316        virtual void print( std::ostream & os, int indent = 0 ) const;
    307   private:
    308         std::list<DeclarationWithType*> returnVals;
    309         std::list<DeclarationWithType*> parameters;
    310 
    311         // Does the function accept a variable number of arguments following the arguments specified in the parameters list.
    312         // This could be because of
    313         // - an ellipsis in a prototype declaration
    314         // - an unprototyped declaration
    315         bool isVarArgs;
    316317};
    317318
    318319class ReferenceToType : public Type {
    319320  public:
     321        std::list< Expression* > parameters;
     322        std::string name;
     323        bool hoistType;
     324
    320325        ReferenceToType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes );
    321326        ReferenceToType( const ReferenceToType & other );
     
    336341  protected:
    337342        virtual std::string typeString() const = 0;
    338         std::list< Expression* > parameters;
    339         std::string name;
    340   private:
    341         bool hoistType;
    342343};
    343344
     
    345346        typedef ReferenceToType Parent;
    346347  public:
     348        // this decl is not "owned" by the struct inst; it is merely a pointer to elsewhere in the tree,
     349        // where the structure used in this type is actually defined
     350        StructDecl *baseStruct;
     351
    347352        StructInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >()  ) : Parent( tq, name, attributes ), baseStruct( 0 ) {}
    348353        StructInstType( const Type::Qualifiers & tq, StructDecl * baseStruct, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
     
    368373  private:
    369374        virtual std::string typeString() const;
    370 
    371         // this decl is not "owned" by the struct inst; it is merely a pointer to elsewhere in the tree,
    372         // where the structure used in this type is actually defined
    373         StructDecl *baseStruct;
    374375};
    375376
     
    377378        typedef ReferenceToType Parent;
    378379  public:
     380        // this decl is not "owned" by the union inst; it is merely a pointer to elsewhere in the tree,
     381        // where the union used in this type is actually defined
     382        UnionDecl *baseUnion;
     383
    379384        UnionInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >()  ) : Parent( tq, name, attributes ), baseUnion( 0 ) {}
    380385        UnionInstType( const Type::Qualifiers & tq, UnionDecl * baseUnion, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
     
    400405  private:
    401406        virtual std::string typeString() const;
    402 
     407};
     408
     409class EnumInstType : public ReferenceToType {
     410        typedef ReferenceToType Parent;
     411  public:
    403412        // this decl is not "owned" by the union inst; it is merely a pointer to elsewhere in the tree,
    404413        // where the union used in this type is actually defined
    405         UnionDecl *baseUnion;
    406 };
    407 
    408 class EnumInstType : public ReferenceToType {
    409         typedef ReferenceToType Parent;
    410   public:
     414        EnumDecl *baseEnum = nullptr;
     415
    411416        EnumInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >()  ) : Parent( tq, name, attributes ) {}
    412417        EnumInstType( const Type::Qualifiers & tq, EnumDecl * baseEnum, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
     
    423428  private:
    424429        virtual std::string typeString() const;
    425 
    426         // this decl is not "owned" by the union inst; it is merely a pointer to elsewhere in the tree,
    427         // where the union used in this type is actually defined
    428         EnumDecl *baseEnum = nullptr;
    429430};
    430431
     
    432433        typedef ReferenceToType Parent;
    433434  public:
     435        // this member is filled in by the validate pass, which instantiates the members of the correponding
     436        // aggregate with the actual type parameters specified for this use of the context
     437        std::list< Declaration* > members;
     438
    434439        TraitInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >()  ) : Parent( tq, name, attributes ) {}
    435440        TraitInstType( const TraitInstType & other );
     
    445450  private:
    446451        virtual std::string typeString() const;
    447 
    448         // this member is filled in by the validate pass, which instantiates the members of the correponding
    449         // aggregate with the actual type parameters specified for this use of the context
    450         std::list< Declaration* > members;
    451452};
    452453
     
    454455        typedef ReferenceToType Parent;
    455456  public:
     457        // this decl is not "owned" by the type inst; it is merely a pointer to elsewhere in the tree,
     458        // where the type used here is actually defined
     459        TypeDecl *baseType;
     460        bool isFtype;
     461
    456462        TypeInstType( const Type::Qualifiers & tq, const std::string & name, TypeDecl *baseType, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
    457463        TypeInstType( const Type::Qualifiers & tq, const std::string & name, bool isFtype, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
     
    472478  private:
    473479        virtual std::string typeString() const;
    474         // this decl is not "owned" by the type inst; it is merely a pointer to elsewhere in the tree,
    475         // where the type used here is actually defined
    476         TypeDecl *baseType;
    477         bool isFtype;
    478480};
    479481
    480482class TupleType : public Type {
    481483  public:
     484        std::list<Type *> types;
     485        std::list<Declaration *> members;
     486
    482487        TupleType( const Type::Qualifiers & tq, const std::list< Type * > & types, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
    483488        TupleType( const TupleType& );
     
    508513        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
    509514        virtual void print( std::ostream & os, int indent = 0 ) const;
    510   private:
    511         std::list<Type *> types;
    512         std::list<Declaration *> members;
    513515};
    514516
    515517class TypeofType : public Type {
    516518  public:
     519        Expression *expr;
     520
    517521        TypeofType( const Type::Qualifiers & tq, Expression *expr, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
    518522        TypeofType( const TypeofType& );
     
    528532        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
    529533        virtual void print( std::ostream & os, int indent = 0 ) const;
    530   private:
     534};
     535
     536class AttrType : public Type {
     537  public:
     538        std::string name;
    531539        Expression *expr;
    532 };
    533 
    534 class AttrType : public Type {
    535   public:
     540        Type *type;
     541        bool isType;
     542
    536543        AttrType( const Type::Qualifiers & tq, const std::string & name, Expression *expr, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
    537544        AttrType( const Type::Qualifiers & tq, const std::string & name, Type *type, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
     
    554561        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
    555562        virtual void print( std::ostream & os, int indent = 0 ) const;
    556   private:
    557         std::string name;
    558         Expression *expr;
    559         Type *type;
    560         bool isType;
    561563};
    562564
Note: See TracChangeset for help on using the changeset viewer.