Ignore:
Timestamp:
Aug 11, 2017, 10:33:37 AM (8 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:
54cd58b0
Parents:
3d4b23fa (diff), 59a75cb (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:/u/cforall/software/cfa/cfa-cc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/Type.h

    r3d4b23fa r0720e049  
    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
     
    166170        virtual Type *acceptMutator( Mutator & m ) = 0;
    167171        virtual void print( std::ostream & os, int indent = 0 ) const;
    168   private:
    169         Qualifiers tq;
    170         ForallList forall;
    171         std::list< Attribute * > attributes;
    172 };
    173 
    174 extern Type::Qualifiers emptyQualifiers;                                // 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
    175177
    176178class VoidType : public Type {
     
    212214                LongDoubleImaginary,
    213215                NUMBER_OF_BASIC_TYPES
    214         };
     216        } kind;
    215217
    216218        static const char *typeNames[];                                         // string names for basic types, MUST MATCH with Kind
     
    227229
    228230        bool isInteger() const;
    229   private:
    230         Kind kind;
    231231};
    232232
    233233class PointerType : public Type {
    234234  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
    235242        PointerType( const Type::Qualifiers & tq, Type *base, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
    236243        PointerType( const Type::Qualifiers & tq, Type *base, Expression *dimension, bool isVarLen, bool isStatic, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
     
    253260        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
    254261        virtual void print( std::ostream & os, int indent = 0 ) const;
    255   private:
     262};
     263
     264class ArrayType : public Type {
     265  public:
    256266        Type *base;
    257 
    258         // In C99, pointer types can be qualified in many ways e.g., int f( int a[ static 3 ] )
    259267        Expression *dimension;
    260268        bool isVarLen;
    261269        bool isStatic;
    262 };
    263 
    264 class ArrayType : public Type {
    265   public:
     270
    266271        ArrayType( const Type::Qualifiers & tq, Type *base, Expression *dimension, bool isVarLen, bool isStatic, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
    267272        ArrayType( const ArrayType& );
     
    283288        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
    284289        virtual void print( std::ostream & os, int indent = 0 ) const;
    285   private:
    286         Type *base;
    287         Expression *dimension;
    288         bool isVarLen;
    289         bool isStatic;
    290290};
    291291
    292292class FunctionType : public Type {
    293293  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
    294303        FunctionType( const Type::Qualifiers & tq, bool isVarArgs, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
    295304        FunctionType( const FunctionType& );
     
    306315        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
    307316        virtual void print( std::ostream & os, int indent = 0 ) const;
    308   private:
    309         std::list<DeclarationWithType*> returnVals;
    310         std::list<DeclarationWithType*> parameters;
    311 
    312         // Does the function accept a variable number of arguments following the arguments specified in the parameters list.
    313         // This could be because of
    314         // - an ellipsis in a prototype declaration
    315         // - an unprototyped declaration
    316         bool isVarArgs;
    317317};
    318318
    319319class ReferenceToType : public Type {
    320320  public:
     321        std::list< Expression* > parameters;
     322        std::string name;
     323        bool hoistType;
     324
    321325        ReferenceToType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes );
    322326        ReferenceToType( const ReferenceToType & other );
     
    337341  protected:
    338342        virtual std::string typeString() const = 0;
    339         std::list< Expression* > parameters;
    340         std::string name;
    341   private:
    342         bool hoistType;
    343343};
    344344
     
    346346        typedef ReferenceToType Parent;
    347347  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
    348352        StructInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >()  ) : Parent( tq, name, attributes ), baseStruct( 0 ) {}
    349353        StructInstType( const Type::Qualifiers & tq, StructDecl * baseStruct, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
     
    369373  private:
    370374        virtual std::string typeString() const;
    371 
    372         // this decl is not "owned" by the struct inst; it is merely a pointer to elsewhere in the tree,
    373         // where the structure used in this type is actually defined
    374         StructDecl *baseStruct;
    375375};
    376376
     
    378378        typedef ReferenceToType Parent;
    379379  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
    380384        UnionInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >()  ) : Parent( tq, name, attributes ), baseUnion( 0 ) {}
    381385        UnionInstType( const Type::Qualifiers & tq, UnionDecl * baseUnion, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
     
    401405  private:
    402406        virtual std::string typeString() const;
    403 
     407};
     408
     409class EnumInstType : public ReferenceToType {
     410        typedef ReferenceToType Parent;
     411  public:
    404412        // this decl is not "owned" by the union inst; it is merely a pointer to elsewhere in the tree,
    405413        // where the union used in this type is actually defined
    406         UnionDecl *baseUnion;
    407 };
    408 
    409 class EnumInstType : public ReferenceToType {
    410         typedef ReferenceToType Parent;
    411   public:
     414        EnumDecl *baseEnum = nullptr;
     415
    412416        EnumInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >()  ) : Parent( tq, name, attributes ) {}
    413417        EnumInstType( const Type::Qualifiers & tq, EnumDecl * baseEnum, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
     
    424428  private:
    425429        virtual std::string typeString() const;
    426 
    427         // this decl is not "owned" by the union inst; it is merely a pointer to elsewhere in the tree,
    428         // where the union used in this type is actually defined
    429         EnumDecl *baseEnum = nullptr;
    430430};
    431431
     
    433433        typedef ReferenceToType Parent;
    434434  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
    435439        TraitInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >()  ) : Parent( tq, name, attributes ) {}
    436440        TraitInstType( const TraitInstType & other );
     
    446450  private:
    447451        virtual std::string typeString() const;
    448 
    449         // this member is filled in by the validate pass, which instantiates the members of the correponding
    450         // aggregate with the actual type parameters specified for this use of the context
    451         std::list< Declaration* > members;
    452452};
    453453
     
    455455        typedef ReferenceToType Parent;
    456456  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
    457462        TypeInstType( const Type::Qualifiers & tq, const std::string & name, TypeDecl *baseType, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
    458463        TypeInstType( const Type::Qualifiers & tq, const std::string & name, bool isFtype, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
     
    473478  private:
    474479        virtual std::string typeString() const;
    475         // this decl is not "owned" by the type inst; it is merely a pointer to elsewhere in the tree,
    476         // where the type used here is actually defined
    477         TypeDecl *baseType;
    478         bool isFtype;
    479480};
    480481
    481482class TupleType : public Type {
    482483  public:
     484        std::list<Type *> types;
     485        std::list<Declaration *> members;
     486
    483487        TupleType( const Type::Qualifiers & tq, const std::list< Type * > & types, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
    484488        TupleType( const TupleType& );
     
    509513        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
    510514        virtual void print( std::ostream & os, int indent = 0 ) const;
    511   private:
    512         std::list<Type *> types;
    513         std::list<Declaration *> members;
    514515};
    515516
    516517class TypeofType : public Type {
    517518  public:
     519        Expression *expr;
     520
    518521        TypeofType( const Type::Qualifiers & tq, Expression *expr, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
    519522        TypeofType( const TypeofType& );
     
    529532        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
    530533        virtual void print( std::ostream & os, int indent = 0 ) const;
    531   private:
     534};
     535
     536class AttrType : public Type {
     537  public:
     538        std::string name;
    532539        Expression *expr;
    533 };
    534 
    535 class AttrType : public Type {
    536   public:
     540        Type *type;
     541        bool isType;
     542
    537543        AttrType( const Type::Qualifiers & tq, const std::string & name, Expression *expr, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
    538544        AttrType( const Type::Qualifiers & tq, const std::string & name, Type *type, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
     
    555561        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
    556562        virtual void print( std::ostream & os, int indent = 0 ) const;
    557   private:
    558         std::string name;
    559         Expression *expr;
    560         Type *type;
    561         bool isType;
    562563};
    563564
     
    601602
    602603std::ostream & operator<<( std::ostream & out, const Type * type );
    603 
    604 #endif // TYPE_H
    605604
    606605// Local Variables: //
Note: See TracChangeset for help on using the changeset viewer.