Changes in / [f2e40a9f:9b443c7f]


Ignore:
Location:
src
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/DeclarationNode.cc

    rf2e40a9f r9b443c7f  
    1010// Created On       : Sat May 16 12:34:05 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Mar 14 22:42:54 2017
    13 // Update Count     : 974
     12// Last Modified On : Tue Mar 14 14:45:52 2017
     13// Update Count     : 973
    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::NumStorageClass; i += 1 ) {
     120                for ( unsigned int i = 0; i < DeclarationNode::NoStorageClass; 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::NumFuncSpecifier; i += 1 ) {
     130                for ( unsigned int i = 0; i < DeclarationNode::NoFuncSpecifier; 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 < NumTypeQualifier; i += 1 ) { // find duplicates
     462                for ( unsigned int i = 0; i < NoTypeQualifier; 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 < NumFuncSpecifier; i += 1 ) { // find duplicates
     472                for ( unsigned int i = 0; i < NoFuncSpecifier; 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 < NumStorageClass; i += 1 ) { // find duplicates
     481                        for ( unsigned int i = 0; i < NoStorageClass; i += 1 ) { // find duplicates
    482482                                if ( storageClasses[i] && src->storageClasses[i] ) {
    483483                                        appendError( error, string( "duplicate " ) + storageClassNames[i] );
  • src/Parser/ParseNode.h

    rf2e40a9f r9b443c7f  
    1010// Created On       : Sat May 16 13:28:16 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Mar 14 22:41:37 2017
    13 // Update Count     : 758
     12// Last Modified On : Tue Mar 14 16:53:19 2017
     13// Update Count     : 757
    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, NumStorageClass = 5 };
     205        enum { Extern = 1 << 0, Static = 1 << 1, Auto = 1 << 2, Register = 1 << 3, Threadlocal = 1 << 4, NoStorageClass = 5 };
    206206        union StorageClasses {
    207207                unsigned int val;
     
    218218        }; // StorageClasses
    219219
    220         enum { Inline = 1 << 0, Noreturn = 1 << 1, Fortran = 1 << 2, NumFuncSpecifier = 3 };
     220        enum { Inline = 1 << 0, Noreturn = 1 << 1, Fortran = 1 << 2, NoFuncSpecifier = 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, NumTypeQualifier = 6 };
     233        enum { Const = 1 << 0, Restrict = 1 << 1, Volatile = 1 << 2, Lvalue = 1 << 3, Mutex = 1 << 4, Atomic = 1 << 5, NoTypeQualifier = 6 };
    234234        union TypeQualifiers {
    235235                unsigned int val;
  • src/Parser/TypeData.cc

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

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

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

    rf2e40a9f r9b443c7f  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Mar 15 21:22:16 2017
    13 // Update Count     : 15
     12// Last Modified On : Thu Feb  2 11:26:24 2017
     13// Update Count     : 12
    1414//
    1515
     
    5959}
    6060
    61 const char * Type::QualifierNames[] = { "const", "restrict", "volatile", "lvalue", "mutex", "_Atomic", "NoTypeQualifierNames" };
     61void 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}
    6278
    6379void Type::print( std::ostream &os, int indent ) const {
  • src/SynTree/Type.h

    rf2e40a9f r9b443c7f  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Mar 15 21:28:09 2017
    13 // Update Count     : 85
     12// Last Modified On : Wed Mar  1 09:11:45 2017
     13// Update Count     : 41
    1414//
    1515
     
    2424class Type : public BaseSyntaxNode {
    2525  public:
    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 );
     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 );
    9152        virtual ~Type();
    9253
    93         Qualifiers & get_qualifiers() { return tq; }
     54        Qualifiers &get_qualifiers() { return tq; }
    9455        bool get_isConst() { return tq.isConst; }
    9556        bool get_isVolatile() { return tq.isVolatile; }
     
    11778
    11879        virtual Type *clone() const = 0;
    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;
     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;
    12283  private:
    12384        Qualifiers tq;
     
    13091class VoidType : public Type {
    13192  public:
    132         VoidType( const Type::Qualifiers & tq, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
     93        VoidType( const Type::Qualifiers &tq, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
    13394
    13495        virtual unsigned size() const { return 0; };
     
    13697
    13798        virtual VoidType *clone() const { return new VoidType( *this ); }
    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;
     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;
    141102};
    142103
     
    170131        static const char *typeNames[];                                         // string names for basic types, MUST MATCH with Kind
    171132
    172         BasicType( const Type::Qualifiers & tq, Kind bt, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
     133        BasicType( const Type::Qualifiers &tq, Kind bt, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
    173134
    174135        Kind get_kind() { return kind; }
     
    176137
    177138        virtual BasicType *clone() const { return new BasicType( *this ); }
    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;
     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;
    181142
    182143        bool isInteger() const;
     
    187148class PointerType : public Type {
    188149  public:
    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 * >() );
     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 * >() );
    191152        PointerType( const PointerType& );
    192153        virtual ~PointerType();
     
    202163
    203164        virtual PointerType *clone() const { return new PointerType( *this ); }
    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;
     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;
    207168  private:
    208169        Type *base;
     
    216177class ArrayType : public Type {
    217178  public:
    218         ArrayType( const Type::Qualifiers & tq, Type *base, Expression *dimension, bool isVarLen, bool isStatic, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
     179        ArrayType( const Type::Qualifiers &tq, Type *base, Expression *dimension, bool isVarLen, bool isStatic, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
    219180        ArrayType( const ArrayType& );
    220181        virtual ~ArrayType();
     
    232193
    233194        virtual ArrayType *clone() const { return new ArrayType( *this ); }
    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;
     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;
    237198  private:
    238199        Type *base;
     
    244205class FunctionType : public Type {
    245206  public:
    246         FunctionType( const Type::Qualifiers & tq, bool isVarArgs, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
     207        FunctionType( const Type::Qualifiers &tq, bool isVarArgs, const std::list< Attribute * > & attributes = std::list< Attribute * >() );
    247208        FunctionType( const FunctionType& );
    248209        virtual ~FunctionType();
     
    255216
    256217        virtual FunctionType *clone() const { return new FunctionType( *this ); }
    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;
     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;
    260221  private:
    261222        std::list<DeclarationWithType*> returnVals;
     
    271232class ReferenceToType : public Type {
    272233  public:
    273         ReferenceToType( const Type::Qualifiers & tq, const std::string & name, const std::list< Attribute * > & attributes );
    274         ReferenceToType( const ReferenceToType & other );
     234        ReferenceToType( const Type::Qualifiers &tq, const std::string &name, const std::list< Attribute * > & attributes );
     235        ReferenceToType( const ReferenceToType &other );
    275236        virtual ~ReferenceToType();
    276237
    277         const std::string & get_name() const { return name; }
     238        const std::string &get_name() const { return name; }
    278239        void set_name( std::string newValue ) { name = newValue; }
    279240        std::list< Expression* >& get_parameters() { return parameters; }
     
    282243
    283244        virtual ReferenceToType *clone() const = 0;
    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;
     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;
    287248  protected:
    288249        virtual std::string typeString() const = 0;
     
    296257        typedef ReferenceToType Parent;
    297258  public:
    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 ) {}
     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 ) {}
    301262
    302263        StructDecl *get_baseStruct() const { return baseStruct; }
     
    310271        /// Looks up the members of this struct named "name" and places them into "foundDecls".
    311272        /// Clones declarations into "foundDecls", caller responsible for freeing
    312         void lookup( const std::string & name, std::list< Declaration* > & foundDecls ) const;
     273        void lookup( const std::string &name, std::list< Declaration* > &foundDecls ) const;
    313274
    314275        virtual StructInstType *clone() const { return new StructInstType( *this ); }
    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;
     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;
    319280  private:
    320281        virtual std::string typeString() const;
     
    328289        typedef ReferenceToType Parent;
    329290  public:
    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 ) {}
     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 ) {}
    333294
    334295        UnionDecl *get_baseUnion() const { return baseUnion; }
     
    342303        /// looks up the members of this union named "name" and places them into "foundDecls"
    343304        /// Clones declarations into "foundDecls", caller responsible for freeing
    344         void lookup( const std::string & name, std::list< Declaration* > & foundDecls ) const;
     305        void lookup( const std::string &name, std::list< Declaration* > &foundDecls ) const;
    345306
    346307        virtual UnionInstType *clone() const { return new UnionInstType( *this ); }
    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;
     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;
    351312  private:
    352313        virtual std::string typeString() const;
     
    360321        typedef ReferenceToType Parent;
    361322  public:
    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 ) {}
     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 ) {}
    365326
    366327        EnumDecl *get_baseEnum() const { return baseEnum; }
     
    370331
    371332        virtual EnumInstType *clone() const { return new EnumInstType( *this ); }
    372         virtual void accept( Visitor & v ) { v.visit( this ); }
    373         virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
     333        virtual void accept( Visitor &v ) { v.visit( this ); }
     334        virtual Type *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    374335  private:
    375336        virtual std::string typeString() const;
     
    383344        typedef ReferenceToType Parent;
    384345  public:
    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 );
     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 );
    387348        ~TraitInstType();
    388349
     
    392353
    393354        virtual TraitInstType *clone() const { return new TraitInstType( *this ); }
    394         virtual void accept( Visitor & v ) { v.visit( this ); }
    395         virtual Type *acceptMutator( Mutator & m ) { return m.mutate( this ); }
     355        virtual void accept( Visitor &v ) { v.visit( this ); }
     356        virtual Type *acceptMutator( Mutator &m ) { return m.mutate( this ); }
    396357  private:
    397358        virtual std::string typeString() const;
     
    405366        typedef ReferenceToType Parent;
    406367  public:
    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 );
     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 );
    410371        ~TypeInstType();
    411372
     
    418379
    419380        virtual TypeInstType *clone() const { return new TypeInstType( *this ); }
    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;
     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;
    423384  private:
    424385        virtual std::string typeString() const;
     
    431392class TupleType : public Type {
    432393  public:
    433         TupleType( const Type::Qualifiers & tq, const std::list< Type * > & types = std::list< Type * >(), const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
     394        TupleType( const Type::Qualifiers &tq, const std::list< Type * > & types = std::list< Type * >(), const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
    434395        TupleType( const TupleType& );
    435396        virtual ~TupleType();
     
    452413
    453414        virtual TupleType *clone() const { return new TupleType( *this ); }
    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;
     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;
    457418  private:
    458419        std::list<Type*> types;
     
    461422class TypeofType : public Type {
    462423  public:
    463         TypeofType( const Type::Qualifiers & tq, Expression *expr, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
     424        TypeofType( const Type::Qualifiers &tq, Expression *expr, const std::list< Attribute * > & attributes = std::list< Attribute * >()  );
    464425        TypeofType( const TypeofType& );
    465426        virtual ~TypeofType();
     
    471432
    472433        virtual TypeofType *clone() const { return new TypeofType( *this ); }
    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;
     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;
    476437  private:
    477438        Expression *expr;
     
    480441class AttrType : public Type {
    481442  public:
    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 * >()  );
     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 * >()  );
    484445        AttrType( const AttrType& );
    485446        virtual ~AttrType();
    486447
    487         const std::string & get_name() const { return name; }
    488         void set_name( const std::string & newValue ) { name = newValue; }
     448        const std::string &get_name() const { return name; }
     449        void set_name( const std::string &newValue ) { name = newValue; }
    489450        Expression *get_expr() const { return expr; }
    490451        void set_expr( Expression *newValue ) { expr = newValue; }
     
    497458
    498459        virtual AttrType *clone() const { return new AttrType( *this ); }
    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;
     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;
    502463  private:
    503464        std::string name;
     
    516477
    517478        virtual VarArgsType *clone() const { return new VarArgsType( *this ); }
    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;
     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;
    521482};
    522483
     
    528489
    529490        virtual ZeroType *clone() const { return new ZeroType( *this ); }
    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;
     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;
    533494};
    534495
     
    540501
    541502        virtual OneType *clone() const { return new OneType( *this ); }
    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 };
     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
     508inline 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
     518inline 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
     528inline 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
     537inline Type::Qualifiers Type::Qualifiers::operator+( const Type::Qualifiers &other ) {
     538        Qualifiers q = other;
     539        q += *this;
     540        return q;
     541}
     542
     543inline 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
     551inline 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
     559inline 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
     567inline 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
     575inline bool Type::Qualifiers::operator<( const Type::Qualifiers &other ) {
     576        return operator!=( other ) && operator<=( other );
     577}
     578
     579inline bool Type::Qualifiers::operator>( const Type::Qualifiers &other ) {
     580        return operator!=( other ) && operator>=( other );
     581}
    546582
    547583std::ostream & operator<<( std::ostream & out, const Type * type );
  • src/Tuples/TupleAssignment.cc

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

    rf2e40a9f r9b443c7f  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Mar 15 07:58:00 2017
    13 // Update Count     : 14
     12// Last Modified On : Tue Mar  7 07:43:56 2017
     13// Update Count     : 12
    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( Type::Const | Type::Volatile | Type::Restrict | Type::Lvalue | Type::Atomic | Type::Mutex ) );
     307                TupleType *tupleType = new TupleType( Type::Qualifiers(true, true, true, true, true, true) );
    308308                Type::Qualifiers &qualifiers = tupleType->get_qualifiers();
    309309                for ( Expression * expr : exprs ) {
Note: See TracChangeset for help on using the changeset viewer.