Changeset 1fbab5a for src/SynTree


Ignore:
Timestamp:
Mar 16, 2017, 4:50:08 PM (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:
395fc37, 64ac636, ef42b143
Parents:
2f26687a (diff), d6d747d (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

Location:
src/SynTree
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/AggregateDecl.cc

    r2f26687a r1fbab5a  
    1010// Created On       : Sun May 17 23:56:39 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Mar  7 07:31:47 2017
    13 // Update Count     : 19
     12// Last Modified On : Thu Mar 16 07:49:07 2017
     13// Update Count     : 20
    1414//
    1515
     
    2020
    2121
    22 AggregateDecl::AggregateDecl( const std::string &name, const std::list< Attribute * > & attributes ) : Parent( name, DeclarationNode::StorageClasses(), LinkageSpec::Cforall ), body( false ), attributes( attributes ) {
     22AggregateDecl::AggregateDecl( const std::string &name, const std::list< Attribute * > & attributes ) : Parent( name, Type::StorageClasses(), LinkageSpec::Cforall ), body( false ), attributes( attributes ) {
    2323}
    2424
  • src/SynTree/Declaration.cc

    r2f26687a r1fbab5a  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Mar  7 07:31:11 2017
    13 // Update Count     : 23
     12// Last Modified On : Thu Mar 16 07:49:18 2017
     13// Update Count     : 24
    1414//
    1515
     
    2727static IdMapType idMap;
    2828
    29 Declaration::Declaration( const std::string &name, DeclarationNode::StorageClasses scs, LinkageSpec::Spec linkage )
     29Declaration::Declaration( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage )
    3030                : name( name ), storageClasses( scs ), linkage( linkage ), uniqueId( 0 ) {
    3131}
     
    6666
    6767
    68 AsmDecl::AsmDecl( AsmStmt *stmt ) : Declaration( "", DeclarationNode::StorageClasses(), LinkageSpec::C ), stmt( stmt ) {
     68AsmDecl::AsmDecl( AsmStmt *stmt ) : Declaration( "", Type::StorageClasses(), LinkageSpec::C ), stmt( stmt ) {
    6969}
    7070
  • src/SynTree/Declaration.h

    r2f26687a r1fbab5a  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Mar  7 07:40:42 2017
    13 // Update Count     : 113
     12// Last Modified On : Thu Mar 16 08:34:11 2017
     13// Update Count     : 118
    1414//
    1515
     
    2828class Declaration : public BaseSyntaxNode {
    2929  public:
    30         Declaration( const std::string &name, DeclarationNode::StorageClasses scs, LinkageSpec::Spec linkage );
     30        Declaration( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage );
    3131        Declaration( const Declaration &other );
    3232        virtual ~Declaration();
     
    3535        void set_name( std::string newValue ) { name = newValue; }
    3636
    37         DeclarationNode::StorageClasses get_storageClasses() const { return storageClasses; }
     37        Type::StorageClasses get_storageClasses() const { return storageClasses; }
    3838
    3939        LinkageSpec::Spec get_linkage() const { return linkage; }
     
    5656  private:
    5757        std::string name;
    58         DeclarationNode::StorageClasses storageClasses;
     58        Type::StorageClasses storageClasses;
    5959        LinkageSpec::Spec linkage;
    6060        UniqueId uniqueId;
     
    6464class DeclarationWithType : public Declaration {
    6565  public:
    66         DeclarationWithType( const std::string &name, DeclarationNode::StorageClasses scs, LinkageSpec::Spec linkage, const std::list< Attribute * > & attributes, DeclarationNode::FuncSpecifiers fs );
     66        DeclarationWithType( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage, const std::list< Attribute * > & attributes, Type::FuncSpecifiers fs );
    6767        DeclarationWithType( const DeclarationWithType &other );
    6868        virtual ~DeclarationWithType();
     
    8282        const std::list< Attribute * >& get_attributes() const { return attributes; }
    8383
    84         DeclarationNode::FuncSpecifiers get_funcSpec() const { return fs; }
    85         //void set_functionSpecifiers( DeclarationNode::FuncSpecifiers newValue ) { fs = newValue; }
     84        Type::FuncSpecifiers get_funcSpec() const { return fs; }
     85        //void set_functionSpecifiers( Type::FuncSpecifiers newValue ) { fs = newValue; }
    8686
    8787        virtual DeclarationWithType *clone() const = 0;
     
    9898        ConstantExpr *asmName;
    9999        std::list< Attribute * > attributes;
    100         DeclarationNode::FuncSpecifiers fs;
     100        Type::FuncSpecifiers fs;
    101101};
    102102
     
    104104        typedef DeclarationWithType Parent;
    105105  public:
    106         ObjectDecl( const std::string &name, DeclarationNode::StorageClasses scs, LinkageSpec::Spec linkage, Expression *bitfieldWidth, Type *type, Initializer *init,
    107                                 const std::list< Attribute * > attributes = std::list< Attribute * >(), DeclarationNode::FuncSpecifiers fs = DeclarationNode::FuncSpecifiers() );
     106        ObjectDecl( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage, Expression *bitfieldWidth, Type *type, Initializer *init,
     107                                const std::list< Attribute * > attributes = std::list< Attribute * >(), Type::FuncSpecifiers fs = Type::FuncSpecifiers() );
    108108        ObjectDecl( const ObjectDecl &other );
    109109        virtual ~ObjectDecl();
     
    132132        typedef DeclarationWithType Parent;
    133133  public:
    134         FunctionDecl( const std::string &name, DeclarationNode::StorageClasses scs, LinkageSpec::Spec linkage, FunctionType *type, CompoundStmt *statements,
    135                                   const std::list< Attribute * > attributes = std::list< Attribute * >(), DeclarationNode::FuncSpecifiers fs = DeclarationNode::FuncSpecifiers() );
     134        FunctionDecl( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage, FunctionType *type, CompoundStmt *statements,
     135                                  const std::list< Attribute * > attributes = std::list< Attribute * >(), Type::FuncSpecifiers fs = Type::FuncSpecifiers() );
    136136        FunctionDecl( const FunctionDecl &other );
    137137        virtual ~FunctionDecl();
     
    158158        typedef Declaration Parent;
    159159  public:
    160         NamedTypeDecl( const std::string &name, DeclarationNode::StorageClasses scs, Type *type );
     160        NamedTypeDecl( const std::string &name, Type::StorageClasses scs, Type *type );
    161161        NamedTypeDecl( const NamedTypeDecl &other );
    162162        virtual ~NamedTypeDecl();
     
    193193        };
    194194
    195         TypeDecl( const std::string &name, DeclarationNode::StorageClasses scs, Type *type, Kind kind );
     195        TypeDecl( const std::string &name, Type::StorageClasses scs, Type *type, Kind kind );
    196196        TypeDecl( const TypeDecl &other );
    197197
     
    214214        typedef NamedTypeDecl Parent;
    215215  public:
    216         TypedefDecl( const std::string &name, DeclarationNode::StorageClasses scs, Type *type ) : Parent( name, scs, type ) {}
     216        TypedefDecl( const std::string &name, Type::StorageClasses scs, Type *type ) : Parent( name, scs, type ) {}
    217217        TypedefDecl( const TypedefDecl &other ) : Parent( other ) {}
    218218
  • src/SynTree/DeclarationWithType.cc

    r2f26687a r1fbab5a  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Mar  7 07:32:14 2017
    13 // Update Count     : 23
     12// Last Modified On : Thu Mar 16 08:34:35 2017
     13// Update Count     : 25
    1414//
    1515
     
    1919#include "Common/utility.h"
    2020
    21 DeclarationWithType::DeclarationWithType( const std::string &name, DeclarationNode::StorageClasses scs, LinkageSpec::Spec linkage, const std::list< Attribute * > & attributes, DeclarationNode::FuncSpecifiers fs )
     21DeclarationWithType::DeclarationWithType( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage, const std::list< Attribute * > & attributes, Type::FuncSpecifiers fs )
    2222        : Declaration( name, scs, linkage ), asmName( nullptr ), attributes( attributes ), fs( fs ) {
    2323}
  • src/SynTree/FunctionDecl.cc

    r2f26687a r1fbab5a  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Mar  7 07:54:58 2017
    13 // Update Count     : 68
     12// Last Modified On : Thu Mar 16 08:33:41 2017
     13// Update Count     : 74
    1414//
    1515
     
    2626extern bool translation_unit_nomain;
    2727
    28 FunctionDecl::FunctionDecl( const std::string &name, DeclarationNode::StorageClasses scs, LinkageSpec::Spec linkage, FunctionType *type, CompoundStmt *statements, std::list< Attribute * > attributes, DeclarationNode::FuncSpecifiers fs )
     28FunctionDecl::FunctionDecl( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage, FunctionType *type, CompoundStmt *statements, std::list< Attribute * > attributes, Type::FuncSpecifiers fs )
    2929        : Parent( name, scs, linkage, attributes, fs ), type( type ), statements( statements ) {
    3030        // hack forcing the function "main" to have Cforall linkage to replace main even if it is inside an extern
     
    6565        printAll( get_attributes(), os, indent );
    6666
    67         DeclarationNode::print_StorageClass( os, get_storageClasses() );
    68         DeclarationNode::print_FuncSpec( os, get_funcSpec() );
     67        get_storageClasses().print( os );
     68        get_funcSpec().print( os );
    6969
    7070        if ( get_type() ) {
     
    9191        // xxx - should printShort print attributes?
    9292
    93         DeclarationNode::print_StorageClass( os, get_storageClasses() );
    94         DeclarationNode::print_FuncSpec( os, get_funcSpec() );
     93        get_storageClasses().print( os );
     94        get_funcSpec().print( os );
    9595
    9696        if ( get_type() ) {
  • src/SynTree/NamedTypeDecl.cc

    r2f26687a r1fbab5a  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Mar  7 07:39:41 2017
    13 // Update Count     : 10
     12// Last Modified On : Thu Mar 16 07:49:44 2017
     13// Update Count     : 13
    1414//
    1515
     
    1818#include "Common/utility.h"
    1919
    20 NamedTypeDecl::NamedTypeDecl( const std::string &name, DeclarationNode::StorageClasses scs, Type *base )
     20NamedTypeDecl::NamedTypeDecl( const std::string &name, Type::StorageClasses scs, Type *base )
    2121        : Parent( name, scs, LinkageSpec::Cforall ), base( base ) {}
    2222
     
    3939                os << get_name() << ": ";
    4040        } // if
    41         DeclarationNode::print_StorageClass( os, get_storageClasses() );
     41        get_storageClasses().print( os );
    4242        os << typeString();
    4343        if ( base ) {
     
    6161                os << get_name() << ": ";
    6262        } // if
    63         DeclarationNode::print_StorageClass( os, get_storageClasses() );
     63        get_storageClasses().print( os );
    6464        os << typeString();
    6565        if ( base ) {
  • src/SynTree/ObjectDecl.cc

    r2f26687a r1fbab5a  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Mar  7 07:55:24 2017
    13 // Update Count     : 54
     12// Last Modified On : Thu Mar 16 08:34:27 2017
     13// Update Count     : 59
    1414//
    1515
     
    2222#include "Statement.h"
    2323
    24 ObjectDecl::ObjectDecl( const std::string &name, DeclarationNode::StorageClasses scs, LinkageSpec::Spec linkage, Expression *bitfieldWidth, Type *type, Initializer *init, const std::list< Attribute * > attributes, DeclarationNode::FuncSpecifiers fs )
     24ObjectDecl::ObjectDecl( const std::string &name, Type::StorageClasses scs, LinkageSpec::Spec linkage, Expression *bitfieldWidth, Type *type, Initializer *init, const std::list< Attribute * > attributes, Type::FuncSpecifiers fs )
    2525        : Parent( name, scs, linkage, attributes, fs ), type( type ), init( init ), bitfieldWidth( bitfieldWidth ) {
    2626}
     
    4747        printAll( get_attributes(), os, indent );
    4848
    49         DeclarationNode::print_StorageClass( os, get_storageClasses() );
     49        get_storageClasses().print( os );
    5050
    5151        if ( get_type() ) {
     
    8181        // xxx - should printShort print attributes?
    8282
    83         DeclarationNode::print_StorageClass( os, get_storageClasses() );
     83        get_storageClasses().print( os );
    8484
    8585        if ( get_type() ) {
  • src/SynTree/Type.cc

    r2f26687a r1fbab5a  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Thu Feb  2 11:26:24 2017
    13 // Update Count     : 12
     12// Last Modified On : Thu Mar 16 10:25:06 2017
     13// Update Count     : 23
    1414//
    1515
     
    5959}
    6060
    61 void Type::Qualifiers::print( std::ostream &os, int indent ) const {
    62         if ( isConst ) {
    63                 os << "const ";
    64         } // if
    65         if ( isVolatile ) {
    66                 os << "volatile ";
    67         } // if
    68         if ( isRestrict ) {
    69                 os << "restrict ";
    70         } // if
    71         if ( isLvalue ) {
    72                 os << "lvalue ";
    73         } // if
    74         if ( isAtomic ) {
    75                 os << "_Atomic ";
    76         } // if
    77 }
     61// These must remain in the same order as the corresponding bit fields.
     62const char * Type::FuncSpecifiers::Names[] = { "inline", "fortran", "_Noreturn" };
     63const char * Type::StorageClasses::Names[] = { "extern", "static", "auto", "register", "_Thread_local" };
     64const char * Type::Qualifiers::Names[] = { "const", "restrict", "volatile", "lvalue", "mutex", "_Atomic" };
    7865
    7966void Type::print( std::ostream &os, int indent ) const {
     
    8976        } // if
    9077       
    91         tq.print( os, indent );
     78        tq.print( os );
    9279}
    9380
  • src/SynTree/Type.h

    r2f26687a r1fbab5a  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Mar  1 09:11:45 2017
    13 // Update Count     : 41
     12// Last Modified On : Thu Mar 16 12:11:50 2017
     13// Update Count     : 116
    1414//
    1515
     
    2424class Type : public BaseSyntaxNode {
    2525  public:
    26         struct Qualifiers {
    27                 Qualifiers(): isConst( false ), isVolatile( false ), isRestrict( false ), isLvalue( false ), isAtomic( false ), isMutex( false ) {}
    28                 Qualifiers( bool isConst, bool isVolatile, bool isRestrict, bool isLvalue, bool isAtomic, bool isMutex ): isConst( isConst ), isVolatile( isVolatile ), isRestrict( isRestrict ), isLvalue( isLvalue ), isAtomic( isAtomic ), isMutex( isMutex ) {}
    29 
    30                 Qualifiers &operator&=( const Qualifiers &other );
    31                 Qualifiers &operator+=( const Qualifiers &other );
    32                 Qualifiers &operator-=( const Qualifiers &other );
    33                 Qualifiers operator+( const Type::Qualifiers &other );
    34                 bool operator==( const Qualifiers &other );
    35                 bool operator!=( const Qualifiers &other );
    36                 bool operator<=( const Qualifiers &other );
    37                 bool operator>=( const Qualifiers &other );
    38                 bool operator<( const Qualifiers &other );
    39                 bool operator>( const Qualifiers &other );
    40                 void print( std::ostream &os, int indent = 0 ) const;
    41 
    42                 bool isConst;
    43                 bool isVolatile;
    44                 bool isRestrict;
    45                 bool isLvalue;
    46                 bool isAtomic;
    47                 bool isMutex;
    48         };
    49 
    50         Type( const Qualifiers &tq, const std::list< Attribute * > & attributes );
    51         Type( const Type &other );
     26        #define CommonBF( N ) \
     27                bool operator[]( unsigned int i ) const { return val & (1 << i); } \
     28                bool any() const { return val != 0; } \
     29                static const char * Names[]; \
     30                void print( std::ostream & os ) const { \
     31                        if ( (*this).any() ) { \
     32                                for ( unsigned int i = 0; i < N; i += 1 ) { \
     33                                        if ( (*this)[i] ) { \
     34                                                os << Names[i] << ' '; \
     35                                        } \
     36                                } \
     37                        } \
     38                }
     39
     40        // enum must remain in the same order as the corresponding bit fields.
     41
     42        enum { Inline = 1 << 0, Noreturn = 1 << 1, Fortran = 1 << 2, NumFuncSpecifier = 3 };
     43        union FuncSpecifiers {
     44                unsigned int val;
     45                struct {
     46                        bool is_inline : 1;
     47                        bool is_noreturn : 1;
     48                        bool is_fortran : 1;
     49                };
     50                FuncSpecifiers() : val( 0 ) {}
     51                FuncSpecifiers( unsigned int val ) : val( val ) {}
     52                CommonBF( NumFuncSpecifier )
     53        }; // FuncSpecifiers
     54
     55        enum { Extern = 1 << 0, Static = 1 << 1, Auto = 1 << 2, Register = 1 << 3, Threadlocal = 1 << 4, NumStorageClass = 5 };
     56        union StorageClasses {
     57                unsigned int val;
     58                struct {
     59                        bool is_extern : 1;
     60                        bool is_static : 1;
     61                        bool is_auto : 1;
     62                        bool is_register : 1;
     63                        bool is_threadlocal : 1;
     64                };
     65
     66                StorageClasses() : val( 0 ) {}
     67                StorageClasses( unsigned int val ) : val( val ) {}
     68                CommonBF( NumStorageClass )
     69        }; // StorageClasses
     70
     71        enum { Const = 1 << 0, Restrict = 1 << 1, Volatile = 1 << 2, Lvalue = 1 << 3, Mutex = 1 << 4, Atomic = 1 << 5, NumTypeQualifier = 6 };
     72        union Qualifiers {
     73                enum { Mask = ~(Restrict | Lvalue) };
     74                unsigned int val;
     75                struct {
     76                        bool isConst : 1;
     77                        bool isRestrict : 1;
     78                        bool isVolatile : 1;
     79                        bool isLvalue : 1;
     80                        bool isMutex : 1;
     81                        bool isAtomic : 1;
     82                };
     83
     84                Qualifiers() : val( 0 ) {}
     85                Qualifiers( unsigned int val ) : val( val ) {}
     86                bool operator==( Qualifiers other ) const {
     87                        return (val & Mask) == (other.val & Mask);
     88                }
     89                bool operator!=( Qualifiers other ) const {
     90                        return (val & Mask) != (other.val & Mask);
     91                }
     92                bool operator<=( Qualifiers other ) const {
     93                        return isConst <= other.isConst && isVolatile <= other.isVolatile &&
     94                                isMutex == other.isMutex && isAtomic == other.isAtomic;
     95                }
     96                bool operator>=( Qualifiers other ) const {
     97                        return isConst >= other.isConst && isVolatile >= other.isVolatile &&
     98                                isMutex == other.isMutex && isAtomic == other.isAtomic;
     99                }
     100                bool operator<( Qualifiers other ) const {
     101                        return *this != other && *this <= other;
     102                }
     103                bool operator>( Qualifiers other ) const {
     104                        return *this != other && *this >= other;
     105                }
     106                Qualifiers operator&=( Type::Qualifiers other ) {
     107                        val &= other.val; return *this;
     108                }
     109                Qualifiers operator+=( Qualifiers other ) {
     110                        val |= other.val; return *this;
     111                }
     112                Qualifiers operator-=( Qualifiers other ) {
     113                        val &= ~other.val; return *this;
     114                }
     115                Qualifiers operator+( Qualifiers other ) const {
     116                        Qualifiers q = other;
     117                        q += *this;
     118                        return q;
     119                }
     120                CommonBF( NumTypeQualifier )
     121        }; // Qualifiers
     122
     123        Type( const Qualifiers & tq, const std::list< Attribute * > & attributes );
     124        Type( const Type & other );
    52125        virtual ~Type();
    53126
    54         Qualifiers &get_qualifiers() { return tq; }
     127        Qualifiers & get_qualifiers() { return tq; }
    55128        bool get_isConst() { return tq.isConst; }
    56129        bool get_isVolatile() { return tq.isVolatile; }
     
    78151
    79152        virtual Type *clone() const = 0;
    80         virtual void accept( Visitor &v ) = 0;
    81         virtual Type *acceptMutator( Mutator &m ) = 0;
    82         virtual void print( std::ostream &os, int indent = 0 ) const;
     153        virtual void accept( Visitor & v ) = 0;
     154        virtual Type *acceptMutator( Mutator & m ) = 0;
     155        virtual void print( std::ostream & os, int indent = 0 ) const;
    83156  private:
    84157        Qualifiers tq;
     
    91164class VoidType : public Type {
    92165  public:
    93         VoidType( const Type::Qualifiers &tq, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
     166        VoidType( const Type::Qualifiers & tq, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
    94167
    95168        virtual unsigned size() const { return 0; };
     
    97170
    98171        virtual VoidType *clone() const { return new VoidType( *this ); }
    99         virtual void accept( Visitor &v ) { v.visit( this ); }
    100         virtual Type *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    101         virtual void print( std::ostream &os, int indent = 0 ) const;
     172        virtual void accept( Visitor & v ) { v.visit( this ); }
     173        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
     174        virtual void print( std::ostream & os, int indent = 0 ) const;
    102175};
    103176
     
    131204        static const char *typeNames[];                                         // string names for basic types, MUST MATCH with Kind
    132205
    133         BasicType( const Type::Qualifiers &tq, Kind bt, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
     206        BasicType( const Type::Qualifiers & tq, Kind bt, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
    134207
    135208        Kind get_kind() { return kind; }
     
    137210
    138211        virtual BasicType *clone() const { return new BasicType( *this ); }
    139         virtual void accept( Visitor &v ) { v.visit( this ); }
    140         virtual Type *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    141         virtual void print( std::ostream &os, int indent = 0 ) const;
     212        virtual void accept( Visitor & v ) { v.visit( this ); }
     213        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
     214        virtual void print( std::ostream & os, int indent = 0 ) const;
    142215
    143216        bool isInteger() const;
     
    148221class PointerType : public Type {
    149222  public:
    150         PointerType( const Type::Qualifiers &tq, Type *base, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
    151         PointerType( const Type::Qualifiers &tq, Type *base, Expression *dimension, bool isVarLen, bool isStatic, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
     223        PointerType( const Type::Qualifiers & tq, Type *base, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
     224        PointerType( const Type::Qualifiers & tq, Type *base, Expression *dimension, bool isVarLen, bool isStatic, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
    152225        PointerType( const PointerType& );
    153226        virtual ~PointerType();
     
    163236
    164237        virtual PointerType *clone() const { return new PointerType( *this ); }
    165         virtual void accept( Visitor &v ) { v.visit( this ); }
    166         virtual Type *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    167         virtual void print( std::ostream &os, int indent = 0 ) const;
     238        virtual void accept( Visitor & v ) { v.visit( this ); }
     239        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
     240        virtual void print( std::ostream & os, int indent = 0 ) const;
    168241  private:
    169242        Type *base;
     
    177250class ArrayType : public Type {
    178251  public:
    179         ArrayType( const Type::Qualifiers &tq, Type *base, Expression *dimension, bool isVarLen, bool isStatic, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
     252        ArrayType( const Type::Qualifiers & tq, Type *base, Expression *dimension, bool isVarLen, bool isStatic, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
    180253        ArrayType( const ArrayType& );
    181254        virtual ~ArrayType();
     
    193266
    194267        virtual ArrayType *clone() const { return new ArrayType( *this ); }
    195         virtual void accept( Visitor &v ) { v.visit( this ); }
    196         virtual Type *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    197         virtual void print( std::ostream &os, int indent = 0 ) const;
     268        virtual void accept( Visitor & v ) { v.visit( this ); }
     269        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
     270        virtual void print( std::ostream & os, int indent = 0 ) const;
    198271  private:
    199272        Type *base;
     
    205278class FunctionType : public Type {
    206279  public:
    207         FunctionType( const Type::Qualifiers &tq, bool isVarArgs, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
     280        FunctionType( const Type::Qualifiers & tq, bool isVarArgs, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
    208281        FunctionType( const FunctionType& );
    209282        virtual ~FunctionType();
     
    216289
    217290        virtual FunctionType *clone() const { return new FunctionType( *this ); }
    218         virtual void accept( Visitor &v ) { v.visit( this ); }
    219         virtual Type *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    220         virtual void print( std::ostream &os, int indent = 0 ) const;
     291        virtual void accept( Visitor & v ) { v.visit( this ); }
     292        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
     293        virtual void print( std::ostream & os, int indent = 0 ) const;
    221294  private:
    222295        std::list<DeclarationWithType*> returnVals;
     
    232305class ReferenceToType : public Type {
    233306  public:
    234         ReferenceToType( const Type::Qualifiers &tq, const std::string &name, const std::list< Attribute * > & attributes );
    235         ReferenceToType( const ReferenceToType &other );
     307        ReferenceToType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes );
     308        ReferenceToType( const ReferenceToType & other );
    236309        virtual ~ReferenceToType();
    237310
    238         const std::string &get_name() const { return name; }
     311        const std::string & get_name() const { return name; }
    239312        void set_name( std::string newValue ) { name = newValue; }
    240313        std::list< Expression* >& get_parameters() { return parameters; }
     
    243316
    244317        virtual ReferenceToType *clone() const = 0;
    245         virtual void accept( Visitor &v ) = 0;
    246         virtual Type *acceptMutator( Mutator &m ) = 0;
    247         virtual void print( std::ostream &os, int indent = 0 ) const;
     318        virtual void accept( Visitor & v ) = 0;
     319        virtual Type *acceptMutator( Mutator & m ) = 0;
     320        virtual void print( std::ostream & os, int indent = 0 ) const;
    248321  protected:
    249322        virtual std::string typeString() const = 0;
     
    257330        typedef ReferenceToType Parent;
    258331  public:
    259         StructInstType( const Type::Qualifiers &tq, const std::string &name, const std::list< Attribute * > & attributes = std::list< Attribute * >()  ) : Parent( tq, name, attributes ), baseStruct( 0 ) {}
    260         StructInstType( const Type::Qualifiers &tq, StructDecl * baseStruct, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
    261         StructInstType( const StructInstType &other ) : Parent( other ), baseStruct( other.baseStruct ) {}
     332        StructInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >()  ) : Parent( tq, name, attributes ), baseStruct( 0 ) {}
     333        StructInstType( const Type::Qualifiers & tq, StructDecl * baseStruct, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
     334        StructInstType( const StructInstType & other ) : Parent( other ), baseStruct( other.baseStruct ) {}
    262335
    263336        StructDecl *get_baseStruct() const { return baseStruct; }
     
    271344        /// Looks up the members of this struct named "name" and places them into "foundDecls".
    272345        /// Clones declarations into "foundDecls", caller responsible for freeing
    273         void lookup( const std::string &name, std::list< Declaration* > &foundDecls ) const;
     346        void lookup( const std::string & name, std::list< Declaration* > & foundDecls ) const;
    274347
    275348        virtual StructInstType *clone() const { return new StructInstType( *this ); }
    276         virtual void accept( Visitor &v ) { v.visit( this ); }
    277         virtual Type *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    278 
    279         virtual void print( std::ostream &os, int indent = 0 ) const;
     349        virtual void accept( Visitor & v ) { v.visit( this ); }
     350        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
     351
     352        virtual void print( std::ostream & os, int indent = 0 ) const;
    280353  private:
    281354        virtual std::string typeString() const;
     
    289362        typedef ReferenceToType Parent;
    290363  public:
    291         UnionInstType( const Type::Qualifiers &tq, const std::string &name, const std::list< Attribute * > & attributes = std::list< Attribute * >()  ) : Parent( tq, name, attributes ), baseUnion( 0 ) {}
    292         UnionInstType( const Type::Qualifiers &tq, UnionDecl * baseUnion, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
    293         UnionInstType( const UnionInstType &other ) : Parent( other ), baseUnion( other.baseUnion ) {}
     364        UnionInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >()  ) : Parent( tq, name, attributes ), baseUnion( 0 ) {}
     365        UnionInstType( const Type::Qualifiers & tq, UnionDecl * baseUnion, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
     366        UnionInstType( const UnionInstType & other ) : Parent( other ), baseUnion( other.baseUnion ) {}
    294367
    295368        UnionDecl *get_baseUnion() const { return baseUnion; }
     
    303376        /// looks up the members of this union named "name" and places them into "foundDecls"
    304377        /// Clones declarations into "foundDecls", caller responsible for freeing
    305         void lookup( const std::string &name, std::list< Declaration* > &foundDecls ) const;
     378        void lookup( const std::string & name, std::list< Declaration* > & foundDecls ) const;
    306379
    307380        virtual UnionInstType *clone() const { return new UnionInstType( *this ); }
    308         virtual void accept( Visitor &v ) { v.visit( this ); }
    309         virtual Type *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    310 
    311         virtual void print( std::ostream &os, int indent = 0 ) const;
     381        virtual void accept( Visitor & v ) { v.visit( this ); }
     382        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
     383
     384        virtual void print( std::ostream & os, int indent = 0 ) const;
    312385  private:
    313386        virtual std::string typeString() const;
     
    321394        typedef ReferenceToType Parent;
    322395  public:
    323         EnumInstType( const Type::Qualifiers &tq, const std::string &name, const std::list< Attribute * > & attributes = std::list< Attribute * >()  ) : Parent( tq, name, attributes ) {}
    324         EnumInstType( const Type::Qualifiers &tq, EnumDecl * baseEnum, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
    325         EnumInstType( const EnumInstType &other ) : Parent( other ), baseEnum( other.baseEnum ) {}
     396        EnumInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >()  ) : Parent( tq, name, attributes ) {}
     397        EnumInstType( const Type::Qualifiers & tq, EnumDecl * baseEnum, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
     398        EnumInstType( const EnumInstType & other ) : Parent( other ), baseEnum( other.baseEnum ) {}
    326399
    327400        EnumDecl *get_baseEnum() const { return baseEnum; }
     
    331404
    332405        virtual EnumInstType *clone() const { return new EnumInstType( *this ); }
    333         virtual void accept( Visitor &v ) { v.visit( this ); }
    334         virtual Type *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     406        virtual void accept( Visitor & v ) { v.visit( this ); }
     407        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
    335408  private:
    336409        virtual std::string typeString() const;
     
    344417        typedef ReferenceToType Parent;
    345418  public:
    346         TraitInstType( const Type::Qualifiers &tq, const std::string &name, const std::list< Attribute * > & attributes = std::list< Attribute * >()  ) : Parent( tq, name, attributes ) {}
    347         TraitInstType( const TraitInstType &other );
     419        TraitInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >()  ) : Parent( tq, name, attributes ) {}
     420        TraitInstType( const TraitInstType & other );
    348421        ~TraitInstType();
    349422
     
    353426
    354427        virtual TraitInstType *clone() const { return new TraitInstType( *this ); }
    355         virtual void accept( Visitor &v ) { v.visit( this ); }
    356         virtual Type *acceptMutator( Mutator &m ) { return m.mutate( this ); }
     428        virtual void accept( Visitor & v ) { v.visit( this ); }
     429        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
    357430  private:
    358431        virtual std::string typeString() const;
     
    366439        typedef ReferenceToType Parent;
    367440  public:
    368         TypeInstType( const Type::Qualifiers &tq, const std::string &name, TypeDecl *baseType, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
    369         TypeInstType( const Type::Qualifiers &tq, const std::string &name, bool isFtype, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
    370         TypeInstType( const TypeInstType &other );
     441        TypeInstType( const Type::Qualifiers & tq, const std::string & name, TypeDecl *baseType, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
     442        TypeInstType( const Type::Qualifiers & tq, const std::string & name, bool isFtype, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
     443        TypeInstType( const TypeInstType & other );
    371444        ~TypeInstType();
    372445
     
    379452
    380453        virtual TypeInstType *clone() const { return new TypeInstType( *this ); }
    381         virtual void accept( Visitor &v ) { v.visit( this ); }
    382         virtual Type *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    383         virtual void print( std::ostream &os, int indent = 0 ) const;
     454        virtual void accept( Visitor & v ) { v.visit( this ); }
     455        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
     456        virtual void print( std::ostream & os, int indent = 0 ) const;
    384457  private:
    385458        virtual std::string typeString() const;
     
    392465class TupleType : public Type {
    393466  public:
    394         TupleType( const Type::Qualifiers &tq, const std::list< Type * > & types = std::list< Type * >(), const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
     467        TupleType( const Type::Qualifiers & tq, const std::list< Type * > & types = std::list< Type * >(), const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
    395468        TupleType( const TupleType& );
    396469        virtual ~TupleType();
     
    413486
    414487        virtual TupleType *clone() const { return new TupleType( *this ); }
    415         virtual void accept( Visitor &v ) { v.visit( this ); }
    416         virtual Type *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    417         virtual void print( std::ostream &os, int indent = 0 ) const;
     488        virtual void accept( Visitor & v ) { v.visit( this ); }
     489        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
     490        virtual void print( std::ostream & os, int indent = 0 ) const;
    418491  private:
    419492        std::list<Type*> types;
     
    422495class TypeofType : public Type {
    423496  public:
    424         TypeofType( const Type::Qualifiers &tq, Expression *expr, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
     497        TypeofType( const Type::Qualifiers & tq, Expression *expr, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
    425498        TypeofType( const TypeofType& );
    426499        virtual ~TypeofType();
     
    432505
    433506        virtual TypeofType *clone() const { return new TypeofType( *this ); }
    434         virtual void accept( Visitor &v ) { v.visit( this ); }
    435         virtual Type *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    436         virtual void print( std::ostream &os, int indent = 0 ) const;
     507        virtual void accept( Visitor & v ) { v.visit( this ); }
     508        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
     509        virtual void print( std::ostream & os, int indent = 0 ) const;
    437510  private:
    438511        Expression *expr;
     
    441514class AttrType : public Type {
    442515  public:
    443         AttrType( const Type::Qualifiers &tq, const std::string &name, Expression *expr, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
    444         AttrType( const Type::Qualifiers &tq, const std::string &name, Type *type, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
     516        AttrType( const Type::Qualifiers & tq, const std::string & name, Expression *expr, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
     517        AttrType( const Type::Qualifiers & tq, const std::string & name, Type *type, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
    445518        AttrType( const AttrType& );
    446519        virtual ~AttrType();
    447520
    448         const std::string &get_name() const { return name; }
    449         void set_name( const std::string &newValue ) { name = newValue; }
     521        const std::string & get_name() const { return name; }
     522        void set_name( const std::string & newValue ) { name = newValue; }
    450523        Expression *get_expr() const { return expr; }
    451524        void set_expr( Expression *newValue ) { expr = newValue; }
     
    458531
    459532        virtual AttrType *clone() const { return new AttrType( *this ); }
    460         virtual void accept( Visitor &v ) { v.visit( this ); }
    461         virtual Type *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    462         virtual void print( std::ostream &os, int indent = 0 ) const;
     533        virtual void accept( Visitor & v ) { v.visit( this ); }
     534        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
     535        virtual void print( std::ostream & os, int indent = 0 ) const;
    463536  private:
    464537        std::string name;
     
    477550
    478551        virtual VarArgsType *clone() const { return new VarArgsType( *this ); }
    479         virtual void accept( Visitor &v ) { v.visit( this ); }
    480         virtual Type *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    481         virtual void print( std::ostream &os, int indent = 0 ) const;
     552        virtual void accept( Visitor & v ) { v.visit( this ); }
     553        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
     554        virtual void print( std::ostream & os, int indent = 0 ) const;
    482555};
    483556
     
    489562
    490563        virtual ZeroType *clone() const { return new ZeroType( *this ); }
    491         virtual void accept( Visitor &v ) { v.visit( this ); }
    492         virtual Type *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    493         virtual void print( std::ostream &os, int indent = 0 ) const;
     564        virtual void accept( Visitor & v ) { v.visit( this ); }
     565        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
     566        virtual void print( std::ostream & os, int indent = 0 ) const;
    494567};
    495568
     
    501574
    502575        virtual OneType *clone() const { return new OneType( *this ); }
    503         virtual void accept( Visitor &v ) { v.visit( this ); }
    504         virtual Type *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    505         virtual void print( std::ostream &os, int indent = 0 ) const;
    506 };
    507 
    508 inline Type::Qualifiers &Type::Qualifiers::operator&=( const Type::Qualifiers &other ) {
    509         isConst &= other.isConst;
    510         isVolatile &= other.isVolatile;
    511         isRestrict &= other.isRestrict;
    512         isLvalue &= other.isLvalue;
    513         isAtomic &= other.isAtomic;
    514         isMutex &= other.isMutex;
    515         return *this;
    516 }
    517 
    518 inline Type::Qualifiers &Type::Qualifiers::operator+=( const Type::Qualifiers &other ) {
    519         isConst |= other.isConst;
    520         isVolatile |= other.isVolatile;
    521         isRestrict |= other.isRestrict;
    522         isLvalue |= other.isLvalue;
    523         isAtomic |= other.isAtomic;
    524         isMutex |= other.isMutex;
    525         return *this;
    526 }
    527 
    528 inline Type::Qualifiers &Type::Qualifiers::operator-=( const Type::Qualifiers &other ) {
    529         if ( other.isConst ) isConst = 0;
    530         if ( other.isVolatile ) isVolatile = 0;
    531         if ( other.isRestrict ) isRestrict = 0;
    532         if ( other.isAtomic ) isAtomic = 0;
    533         if ( other.isMutex ) isMutex = 0;
    534         return *this;
    535 }
    536 
    537 inline Type::Qualifiers Type::Qualifiers::operator+( const Type::Qualifiers &other ) {
    538         Qualifiers q = other;
    539         q += *this;
    540         return q;
    541 }
    542 
    543 inline bool Type::Qualifiers::operator==( const Qualifiers &other ) {
    544         return isConst == other.isConst
    545                 && isVolatile == other.isVolatile
    546 //              && isRestrict == other.isRestrict
    547 //              && isLvalue == other.isLvalue
    548                 && isAtomic == other.isAtomic;
    549 }
    550 
    551 inline bool Type::Qualifiers::operator!=( const Qualifiers &other ) {
    552         return isConst != other.isConst
    553                 || isVolatile != other.isVolatile
    554 //              || isRestrict != other.isRestrict
    555 //              || isLvalue != other.isLvalue
    556                 || isAtomic != other.isAtomic;
    557 }
    558 
    559 inline bool Type::Qualifiers::operator<=( const Type::Qualifiers &other ) {
    560         return isConst <= other.isConst
    561                 && isVolatile <= other.isVolatile
    562 //              && isRestrict <= other.isRestrict
    563 //              && isLvalue >= other.isLvalue
    564                 && isAtomic == other.isAtomic;
    565 }
    566 
    567 inline bool Type::Qualifiers::operator>=( const Type::Qualifiers &other ) {
    568         return isConst >= other.isConst
    569                 && isVolatile >= other.isVolatile
    570 //              && isRestrict >= other.isRestrict
    571 //              && isLvalue <= other.isLvalue
    572                 && isAtomic == other.isAtomic;
    573 }
    574 
    575 inline bool Type::Qualifiers::operator<( const Type::Qualifiers &other ) {
    576         return operator!=( other ) && operator<=( other );
    577 }
    578 
    579 inline bool Type::Qualifiers::operator>( const Type::Qualifiers &other ) {
    580         return operator!=( other ) && operator>=( other );
    581 }
     576        virtual void accept( Visitor & v ) { v.visit( this ); }
     577        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
     578        virtual void print( std::ostream & os, int indent = 0 ) const;
     579};
    582580
    583581std::ostream & operator<<( std::ostream & out, const Type * type );
  • src/SynTree/TypeDecl.cc

    r2f26687a r1fbab5a  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Mar  7 07:39:09 2017
    13 // Update Count     : 4
     12// Last Modified On : Thu Mar 16 07:49:58 2017
     13// Update Count     : 5
    1414//
    1515
     
    1818#include "Common/utility.h"
    1919
    20 TypeDecl::TypeDecl( const std::string &name, DeclarationNode::StorageClasses scs, Type *type, Kind kind ) : Parent( name, scs, type ), kind( kind ), sized( kind == Any || kind == Ttype ) {
     20TypeDecl::TypeDecl( const std::string &name, Type::StorageClasses scs, Type *type, Kind kind ) : Parent( name, scs, type ), kind( kind ), sized( kind == Any || kind == Ttype ) {
    2121}
    2222
Note: See TracChangeset for help on using the changeset viewer.