Changes in / [9b443c7f:f2e40a9f]


Ignore:
Location:
src
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/DeclarationNode.cc

    r9b443c7f rf2e40a9f  
    1010// Created On       : Sat May 16 12:34:05 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Mar 14 14:45:52 2017
    13 // Update Count     : 973
     12// Last Modified On : Tue Mar 14 22:42:54 2017
     13// Update Count     : 974
    1414//
    1515
     
    118118void DeclarationNode::print_StorageClass( std::ostream & output, StorageClasses storageClasses ) {
    119119        if ( storageClasses.val != 0 ) {                                        // storage classes ?
    120                 for ( unsigned int i = 0; i < DeclarationNode::NoStorageClass; i += 1 ) {
     120                for ( unsigned int i = 0; i < DeclarationNode::NumStorageClass; i += 1 ) {
    121121                        if ( storageClasses[i] ) {
    122122                                output << DeclarationNode::storageClassNames[i] << ' ';
     
    128128void DeclarationNode::print_FuncSpec( std::ostream & output, DeclarationNode::FuncSpecifiers funcSpec ) {
    129129        if ( funcSpec.val != 0 ) {                                                      // function specifiers ?
    130                 for ( unsigned int i = 0; i < DeclarationNode::NoFuncSpecifier; i += 1 ) {
     130                for ( unsigned int i = 0; i < DeclarationNode::NumFuncSpecifier; i += 1 ) {
    131131                        if ( funcSpec[i] ) {
    132132                                output << DeclarationNode::funcSpecifierNames[i] << ' ';
     
    460460
    461461        if ( (qsrc.val & qdst.val) != 0 ) {                                     // duplicates ?
    462                 for ( unsigned int i = 0; i < NoTypeQualifier; i += 1 ) { // find duplicates
     462                for ( unsigned int i = 0; i < NumTypeQualifier; i += 1 ) { // find duplicates
    463463                        if ( qsrc[i] && qdst[i] ) {
    464464                                appendError( error, string( "duplicate " ) + DeclarationNode::typeQualifierNames[i] );
     
    470470void DeclarationNode::checkSpecifiers( DeclarationNode * src ) {
    471471        if ( (funcSpecs.val & src->funcSpecs.val) != 0 ) {                // duplicates ?
    472                 for ( unsigned int i = 0; i < NoFuncSpecifier; i += 1 ) { // find duplicates
     472                for ( unsigned int i = 0; i < NumFuncSpecifier; i += 1 ) { // find duplicates
    473473                        if ( funcSpecs[i] && src->funcSpecs[i] ) {
    474474                                appendError( error, string( "duplicate " ) + DeclarationNode::funcSpecifierNames[i] );
     
    479479        if ( storageClasses.val != 0 && src->storageClasses.val != 0 ) { // any reason to check ?
    480480                if ( (storageClasses.val & src->storageClasses.val ) != 0 ) { // duplicates ?
    481                         for ( unsigned int i = 0; i < NoStorageClass; i += 1 ) { // find duplicates
     481                        for ( unsigned int i = 0; i < NumStorageClass; i += 1 ) { // find duplicates
    482482                                if ( storageClasses[i] && src->storageClasses[i] ) {
    483483                                        appendError( error, string( "duplicate " ) + storageClassNames[i] );
  • src/Parser/ParseNode.h

    r9b443c7f rf2e40a9f  
    1010// Created On       : Sat May 16 13:28:16 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Mar 14 16:53:19 2017
    13 // Update Count     : 757
     12// Last Modified On : Tue Mar 14 22:41:37 2017
     13// Update Count     : 758
    1414//
    1515
     
    203203        // These must remain in the same order as the corresponding DeclarationNode names.
    204204
    205         enum { Extern = 1 << 0, Static = 1 << 1, Auto = 1 << 2, Register = 1 << 3, Threadlocal = 1 << 4, NoStorageClass = 5 };
     205        enum { Extern = 1 << 0, Static = 1 << 1, Auto = 1 << 2, Register = 1 << 3, Threadlocal = 1 << 4, NumStorageClass = 5 };
    206206        union StorageClasses {
    207207                unsigned int val;
     
    218218        }; // StorageClasses
    219219
    220         enum { Inline = 1 << 0, Noreturn = 1 << 1, Fortran = 1 << 2, NoFuncSpecifier = 3 };
     220        enum { Inline = 1 << 0, Noreturn = 1 << 1, Fortran = 1 << 2, NumFuncSpecifier = 3 };
    221221        union FuncSpecifiers {
    222222                unsigned int val;
     
    231231        }; // FuncSpecifiers
    232232
    233         enum { Const = 1 << 0, Restrict = 1 << 1, Volatile = 1 << 2, Lvalue = 1 << 3, Mutex = 1 << 4, Atomic = 1 << 5, NoTypeQualifier = 6 };
     233        enum { Const = 1 << 0, Restrict = 1 << 1, Volatile = 1 << 2, Lvalue = 1 << 3, Mutex = 1 << 4, Atomic = 1 << 5, NumTypeQualifier = 6 };
    234234        union TypeQualifiers {
    235235                unsigned int val;
  • src/Parser/TypeData.cc

    r9b443c7f rf2e40a9f  
    1010// Created On       : Sat May 16 15:12:51 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Mar 14 15:01:44 2017
    13 // Update Count     : 548
     12// Last Modified On : Tue Mar 14 22:43:20 2017
     13// Update Count     : 549
    1414//
    1515
     
    226226
    227227void TypeData::print( ostream &os, int indent ) const {
    228         for ( int i = 0; i < DeclarationNode::NoTypeQualifier; i += 1 ) {
     228        for ( int i = 0; i < DeclarationNode::NumTypeQualifier; i += 1 ) {
    229229                if ( typeQualifiers[i] ) os << DeclarationNode::typeQualifierNames[ i ] << ' ';
    230230        } // for
  • src/SymTab/Autogen.h

    r9b443c7f rf2e40a9f  
    1010// Created On       : Sun May 17 21:53:34 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Mar  6 23:33:01 2017
    13 // Update Count     : 4
     12// Last Modified On : Tue Mar 14 23:13:28 2017
     13// Update Count     : 7
    1414//
    1515
     
    5858                        assert( type );
    5959                        Type * castType = type->clone();
    60                         castType->get_qualifiers() -= Type::Qualifiers(true, true, true, false, true, false);
     60//                      castType->get_qualifiers() -= Type::Qualifiers(true, true, true, false, true, false);
     61                        castType->get_qualifiers() -= Type::Qualifiers( Type::Const | Type::Volatile | Type::Restrict | Type::Atomic );
    6162                        castType->set_isLvalue( true ); // xxx - might not need this
    6263                        dstParam = new CastExpr( dstParam, new PointerType( Type::Qualifiers(), castType ) );
  • src/SymTab/Validate.cc

    r9b443c7f rf2e40a9f  
    1010// Created On       : Sun May 17 21:50:04 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Mar  7 07:51:36 2017
    13 // Update Count     : 349
     12// Last Modified On : Tue Mar 14 23:30:27 2017
     13// Update Count     : 350
    1414//
    1515
     
    323323                        ObjectDecl * obj = dynamic_cast< ObjectDecl * >( *i );
    324324                        assert( obj );
    325                         obj->set_type( new EnumInstType( Type::Qualifiers( true, false, false, false, false, false ), enumDecl->get_name() ) );
     325                        obj->set_type( new EnumInstType( Type::Qualifiers( Type::Const ), enumDecl->get_name() ) );
    326326                } // for
    327327                Parent::visit( enumDecl );
  • src/SynTree/Type.cc

    r9b443c7f rf2e40a9f  
    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 : Wed Mar 15 21:22:16 2017
     13// Update Count     : 15
    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 }
     61const char * Type::QualifierNames[] = { "const", "restrict", "volatile", "lvalue", "mutex", "_Atomic", "NoTypeQualifierNames" };
    7862
    7963void Type::print( std::ostream &os, int indent ) const {
  • src/SynTree/Type.h

    r9b443c7f rf2e40a9f  
    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 : Wed Mar 15 21:28:09 2017
     13// Update Count     : 85
    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        static const char * QualifierNames[];
     27
     28        enum { Const = 1 << 0, Restrict = 1 << 1, Volatile = 1 << 2, Lvalue = 1 << 3, Mutex = 1 << 4, Atomic = 1 << 5, NumTypeQualifier = 6 };
     29        union Qualifiers {
     30                enum { Mask = ~(Restrict | Lvalue) };
     31                unsigned int val;
     32                struct {
     33                        bool isConst : 1;
     34                        bool isRestrict : 1;
     35                        bool isVolatile : 1;
     36                        bool isLvalue : 1;
     37                        bool isMutex : 1;
     38                        bool isAtomic : 1;
     39                };
     40                Qualifiers() : val( 0 ) {}
     41                Qualifiers( unsigned int val ) : val( val ) {}
     42                bool operator[]( unsigned int i ) const { return val & (1 << i); }
     43                bool any() const { return val != 0; }
     44                bool operator==( const Qualifiers other ) const {
     45                        return (val & Mask) == (other.val & Mask);
     46                }
     47                bool operator!=( const Qualifiers other ) const {
     48                        return (val & Mask) != (other.val & Mask);
     49                }
     50                bool operator<=( const Qualifiers other ) const {
     51                        return isConst <= other.isConst && isVolatile <= other.isVolatile &&
     52                                isMutex == other.isMutex && isAtomic == other.isAtomic;
     53                }
     54                bool operator>=( const Qualifiers other ) const {
     55                        return isConst >= other.isConst && isVolatile >= other.isVolatile &&
     56                                isMutex == other.isMutex && isAtomic == other.isAtomic;
     57                }
     58                bool operator<( const Qualifiers other ) const {
     59                        return *this != other && *this <= other;
     60                }
     61                bool operator>( const Qualifiers other ) const {
     62                        return *this != other && *this >= other;
     63                }
     64                Qualifiers operator&=( const Type::Qualifiers other ) {
     65                        val &= other.val; return *this;
     66                }
     67                Qualifiers operator+=( const Qualifiers other ) {
     68                        val |= other.val; return *this;
     69                }
     70                Qualifiers operator-=( const Qualifiers other ) {
     71                        val &= ~other.val; return *this;
     72                }
     73                Qualifiers operator+( const Qualifiers other ) const {
     74                        Qualifiers q = other;
     75                        q += *this;
     76                        return q;
     77                }
     78                void print( std::ostream & os, int indent = 0 ) const {
     79                        if ( (*this).any() ) {                                          // any type qualifiers ?
     80                                for ( unsigned int i = 0; i < NumTypeQualifier; i += 1 ) {
     81                                        if ( (*this)[i] ) {
     82                                                os << QualifierNames[i] << ' ';
     83                                        } // if
     84                                } // for
     85                        } // if
     86                }
     87        }; // Qualifiers
     88
     89        Type( const Qualifiers & tq, const std::list< Attribute * > & attributes );
     90        Type( const Type & other );
    5291        virtual ~Type();
    5392
    54         Qualifiers &get_qualifiers() { return tq; }
     93        Qualifiers & get_qualifiers() { return tq; }
    5594        bool get_isConst() { return tq.isConst; }
    5695        bool get_isVolatile() { return tq.isVolatile; }
     
    78117
    79118        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;
     119        virtual void accept( Visitor & v ) = 0;
     120        virtual Type *acceptMutator( Mutator & m ) = 0;
     121        virtual void print( std::ostream & os, int indent = 0 ) const;
    83122  private:
    84123        Qualifiers tq;
     
    91130class VoidType : public Type {
    92131  public:
    93         VoidType( const Type::Qualifiers &tq, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
     132        VoidType( const Type::Qualifiers & tq, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
    94133
    95134        virtual unsigned size() const { return 0; };
     
    97136
    98137        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;
     138        virtual void accept( Visitor & v ) { v.visit( this ); }
     139        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
     140        virtual void print( std::ostream & os, int indent = 0 ) const;
    102141};
    103142
     
    131170        static const char *typeNames[];                                         // string names for basic types, MUST MATCH with Kind
    132171
    133         BasicType( const Type::Qualifiers &tq, Kind bt, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
     172        BasicType( const Type::Qualifiers & tq, Kind bt, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
    134173
    135174        Kind get_kind() { return kind; }
     
    137176
    138177        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;
     178        virtual void accept( Visitor & v ) { v.visit( this ); }
     179        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
     180        virtual void print( std::ostream & os, int indent = 0 ) const;
    142181
    143182        bool isInteger() const;
     
    148187class PointerType : public Type {
    149188  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 * >() );
     189        PointerType( const Type::Qualifiers & tq, Type *base, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
     190        PointerType( const Type::Qualifiers & tq, Type *base, Expression *dimension, bool isVarLen, bool isStatic, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
    152191        PointerType( const PointerType& );
    153192        virtual ~PointerType();
     
    163202
    164203        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;
     204        virtual void accept( Visitor & v ) { v.visit( this ); }
     205        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
     206        virtual void print( std::ostream & os, int indent = 0 ) const;
    168207  private:
    169208        Type *base;
     
    177216class ArrayType : public Type {
    178217  public:
    179         ArrayType( const Type::Qualifiers &tq, Type *base, Expression *dimension, bool isVarLen, bool isStatic, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
     218        ArrayType( const Type::Qualifiers & tq, Type *base, Expression *dimension, bool isVarLen, bool isStatic, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
    180219        ArrayType( const ArrayType& );
    181220        virtual ~ArrayType();
     
    193232
    194233        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;
     234        virtual void accept( Visitor & v ) { v.visit( this ); }
     235        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
     236        virtual void print( std::ostream & os, int indent = 0 ) const;
    198237  private:
    199238        Type *base;
     
    205244class FunctionType : public Type {
    206245  public:
    207         FunctionType( const Type::Qualifiers &tq, bool isVarArgs, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
     246        FunctionType( const Type::Qualifiers & tq, bool isVarArgs, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
    208247        FunctionType( const FunctionType& );
    209248        virtual ~FunctionType();
     
    216255
    217256        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;
     257        virtual void accept( Visitor & v ) { v.visit( this ); }
     258        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
     259        virtual void print( std::ostream & os, int indent = 0 ) const;
    221260  private:
    222261        std::list<DeclarationWithType*> returnVals;
     
    232271class ReferenceToType : public Type {
    233272  public:
    234         ReferenceToType( const Type::Qualifiers &tq, const std::string &name, const std::list< Attribute * > & attributes );
    235         ReferenceToType( const ReferenceToType &other );
     273        ReferenceToType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes );
     274        ReferenceToType( const ReferenceToType & other );
    236275        virtual ~ReferenceToType();
    237276
    238         const std::string &get_name() const { return name; }
     277        const std::string & get_name() const { return name; }
    239278        void set_name( std::string newValue ) { name = newValue; }
    240279        std::list< Expression* >& get_parameters() { return parameters; }
     
    243282
    244283        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;
     284        virtual void accept( Visitor & v ) = 0;
     285        virtual Type *acceptMutator( Mutator & m ) = 0;
     286        virtual void print( std::ostream & os, int indent = 0 ) const;
    248287  protected:
    249288        virtual std::string typeString() const = 0;
     
    257296        typedef ReferenceToType Parent;
    258297  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 ) {}
     298        StructInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >()  ) : Parent( tq, name, attributes ), baseStruct( 0 ) {}
     299        StructInstType( const Type::Qualifiers & tq, StructDecl * baseStruct, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
     300        StructInstType( const StructInstType & other ) : Parent( other ), baseStruct( other.baseStruct ) {}
    262301
    263302        StructDecl *get_baseStruct() const { return baseStruct; }
     
    271310        /// Looks up the members of this struct named "name" and places them into "foundDecls".
    272311        /// Clones declarations into "foundDecls", caller responsible for freeing
    273         void lookup( const std::string &name, std::list< Declaration* > &foundDecls ) const;
     312        void lookup( const std::string & name, std::list< Declaration* > & foundDecls ) const;
    274313
    275314        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;
     315        virtual void accept( Visitor & v ) { v.visit( this ); }
     316        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
     317
     318        virtual void print( std::ostream & os, int indent = 0 ) const;
    280319  private:
    281320        virtual std::string typeString() const;
     
    289328        typedef ReferenceToType Parent;
    290329  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 ) {}
     330        UnionInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >()  ) : Parent( tq, name, attributes ), baseUnion( 0 ) {}
     331        UnionInstType( const Type::Qualifiers & tq, UnionDecl * baseUnion, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
     332        UnionInstType( const UnionInstType & other ) : Parent( other ), baseUnion( other.baseUnion ) {}
    294333
    295334        UnionDecl *get_baseUnion() const { return baseUnion; }
     
    303342        /// looks up the members of this union named "name" and places them into "foundDecls"
    304343        /// Clones declarations into "foundDecls", caller responsible for freeing
    305         void lookup( const std::string &name, std::list< Declaration* > &foundDecls ) const;
     344        void lookup( const std::string & name, std::list< Declaration* > & foundDecls ) const;
    306345
    307346        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;
     347        virtual void accept( Visitor & v ) { v.visit( this ); }
     348        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
     349
     350        virtual void print( std::ostream & os, int indent = 0 ) const;
    312351  private:
    313352        virtual std::string typeString() const;
     
    321360        typedef ReferenceToType Parent;
    322361  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 ) {}
     362        EnumInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >()  ) : Parent( tq, name, attributes ) {}
     363        EnumInstType( const Type::Qualifiers & tq, EnumDecl * baseEnum, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
     364        EnumInstType( const EnumInstType & other ) : Parent( other ), baseEnum( other.baseEnum ) {}
    326365
    327366        EnumDecl *get_baseEnum() const { return baseEnum; }
     
    331370
    332371        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 ); }
     372        virtual void accept( Visitor & v ) { v.visit( this ); }
     373        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
    335374  private:
    336375        virtual std::string typeString() const;
     
    344383        typedef ReferenceToType Parent;
    345384  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 );
     385        TraitInstType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes = std::list< Attribute * >()  ) : Parent( tq, name, attributes ) {}
     386        TraitInstType( const TraitInstType & other );
    348387        ~TraitInstType();
    349388
     
    353392
    354393        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 ); }
     394        virtual void accept( Visitor & v ) { v.visit( this ); }
     395        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
    357396  private:
    358397        virtual std::string typeString() const;
     
    366405        typedef ReferenceToType Parent;
    367406  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 );
     407        TypeInstType( const Type::Qualifiers & tq, const std::string & name, TypeDecl *baseType, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
     408        TypeInstType( const Type::Qualifiers & tq, const std::string & name, bool isFtype, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
     409        TypeInstType( const TypeInstType & other );
    371410        ~TypeInstType();
    372411
     
    379418
    380419        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;
     420        virtual void accept( Visitor & v ) { v.visit( this ); }
     421        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
     422        virtual void print( std::ostream & os, int indent = 0 ) const;
    384423  private:
    385424        virtual std::string typeString() const;
     
    392431class TupleType : public Type {
    393432  public:
    394         TupleType( const Type::Qualifiers &tq, const std::list< Type * > & types = std::list< Type * >(), const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
     433        TupleType( const Type::Qualifiers & tq, const std::list< Type * > & types = std::list< Type * >(), const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
    395434        TupleType( const TupleType& );
    396435        virtual ~TupleType();
     
    413452
    414453        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;
     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;
    418457  private:
    419458        std::list<Type*> types;
     
    422461class TypeofType : public Type {
    423462  public:
    424         TypeofType( const Type::Qualifiers &tq, Expression *expr, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
     463        TypeofType( const Type::Qualifiers & tq, Expression *expr, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
    425464        TypeofType( const TypeofType& );
    426465        virtual ~TypeofType();
     
    432471
    433472        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;
     473        virtual void accept( Visitor & v ) { v.visit( this ); }
     474        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
     475        virtual void print( std::ostream & os, int indent = 0 ) const;
    437476  private:
    438477        Expression *expr;
     
    441480class AttrType : public Type {
    442481  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 * >()  );
     482        AttrType( const Type::Qualifiers & tq, const std::string & name, Expression *expr, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
     483        AttrType( const Type::Qualifiers & tq, const std::string & name, Type *type, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
    445484        AttrType( const AttrType& );
    446485        virtual ~AttrType();
    447486
    448         const std::string &get_name() const { return name; }
    449         void set_name( const std::string &newValue ) { name = newValue; }
     487        const std::string & get_name() const { return name; }
     488        void set_name( const std::string & newValue ) { name = newValue; }
    450489        Expression *get_expr() const { return expr; }
    451490        void set_expr( Expression *newValue ) { expr = newValue; }
     
    458497
    459498        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;
     499        virtual void accept( Visitor & v ) { v.visit( this ); }
     500        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
     501        virtual void print( std::ostream & os, int indent = 0 ) const;
    463502  private:
    464503        std::string name;
     
    477516
    478517        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;
     518        virtual void accept( Visitor & v ) { v.visit( this ); }
     519        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
     520        virtual void print( std::ostream & os, int indent = 0 ) const;
    482521};
    483522
     
    489528
    490529        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;
     530        virtual void accept( Visitor & v ) { v.visit( this ); }
     531        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
     532        virtual void print( std::ostream & os, int indent = 0 ) const;
    494533};
    495534
     
    501540
    502541        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 }
     542        virtual void accept( Visitor & v ) { v.visit( this ); }
     543        virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
     544        virtual void print( std::ostream & os, int indent = 0 ) const;
     545};
    582546
    583547std::ostream & operator<<( std::ostream & out, const Type * type );
  • src/Tuples/TupleAssignment.cc

    r9b443c7f rf2e40a9f  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Mar  6 23:40:14 2017
    13 // Update Count     : 5
     12// Last Modified On : Wed Mar 15 08:00:44 2017
     13// Update Count     : 6
    1414//
    1515
     
    199199                                Type * type = InitTweak::getPointerBase( castType );
    200200                                assert( type );
    201                                 type->get_qualifiers() -= Type::Qualifiers(true, true, true, false, true, false);
     201                                type->get_qualifiers() -= Type::Qualifiers( Type::Const | Type::Volatile | Type::Restrict | Type::Atomic );
    202202                                type->set_isLvalue( true ); // xxx - might not need this
    203203                                expr = new CastExpr( expr, castType );
  • src/Tuples/TupleExpansion.cc

    r9b443c7f rf2e40a9f  
    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:43:56 2017
    13 // Update Count     : 12
     12// Last Modified On : Wed Mar 15 07:58:00 2017
     13// Update Count     : 14
    1414//
    1515
     
    305305        Type * makeTupleType( const std::list< Expression * > & exprs ) {
    306306                // produce the TupleType which aggregates the types of the exprs
    307                 TupleType *tupleType = new TupleType( Type::Qualifiers(true, true, true, true, true, true) );
     307                TupleType *tupleType = new TupleType( Type::Qualifiers( Type::Const | Type::Volatile | Type::Restrict | Type::Lvalue | Type::Atomic | Type::Mutex ) );
    308308                Type::Qualifiers &qualifiers = tupleType->get_qualifiers();
    309309                for ( Expression * expr : exprs ) {
Note: See TracChangeset for help on using the changeset viewer.