Changes in / [e61a35e:4da6a6c]


Ignore:
Location:
src/Parser
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/Parser/DeclarationNode.cc

    re61a35e r4da6a6c  
    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 10:19:38 2017
     13// Update Count     : 964
    1414//
    1515
     
    202202
    203203
    204 DeclarationNode * DeclarationNode::newStorageClass( StorageClasses sc ) {
     204DeclarationNode * DeclarationNode::newStorageClass( DeclarationNode::StorageClasses sc ) {
    205205        DeclarationNode * newnode = new DeclarationNode;
    206206        newnode->storageClasses = sc;
     
    208208} // DeclarationNode::newStorageClass
    209209
    210 DeclarationNode * DeclarationNode::newFuncSpecifier( FuncSpecifiers fs ) {
     210DeclarationNode * DeclarationNode::newFuncSpecifier( DeclarationNode::FuncSpecifiers fs ) {
    211211        DeclarationNode * newnode = new DeclarationNode;
    212212        newnode->funcSpecs = fs;
     
    214214} // DeclarationNode::newFuncSpecifier
    215215
    216 DeclarationNode * DeclarationNode::newTypeQualifier( TypeQualifiers tq ) {
     216DeclarationNode * DeclarationNode::newTypeQualifier( TypeQualifier tq ) {
    217217        DeclarationNode * newnode = new DeclarationNode;
    218218        newnode->type = new TypeData();
    219         newnode->type->typeQualifiers = tq;
     219        newnode->type->typeQualifiers[ tq ] = true;
    220220        return newnode;
    221221} // DeclarationNode::newQualifier
     
    457457
    458458void DeclarationNode::checkQualifiers( const TypeData * src, const TypeData * dst ) {
    459         const TypeQualifiers qsrc = src->typeQualifiers, qdst = dst->typeQualifiers; // optimization
    460 
    461         if ( (qsrc.val & qdst.val) != 0 ) {                                     // duplicates ?
     459        const TypeData::TypeQualifiers qsrc = src->typeQualifiers, qdst = dst->typeQualifiers; // optimization
     460
     461        if ( (qsrc & qdst).any() ) {                                            // duplicates ?
    462462                for ( unsigned int i = 0; i < NoTypeQualifier; i += 1 ) { // find duplicates
    463463                        if ( qsrc[i] && qdst[i] ) {
     
    520520                src = nullptr;
    521521        } else {
    522                 dst->typeQualifiers.val |= src->typeQualifiers.val;
     522                dst->typeQualifiers |= src->typeQualifiers;
    523523        } // if
    524524} // addQualifiersToType
     
    578578                switch ( dst->kind ) {
    579579                  case TypeData::Unknown:
    580                         src->typeQualifiers.val |= dst->typeQualifiers.val;
     580                        src->typeQualifiers |= dst->typeQualifiers;
    581581                        dst = src;
    582582                        src = nullptr;
    583583                        break;
    584584                  case TypeData::Basic:
    585                         dst->typeQualifiers.val |= src->typeQualifiers.val;
     585                        dst->typeQualifiers |= src->typeQualifiers;
    586586                        if ( src->kind != TypeData::Unknown ) {
    587587                                assert( src->kind == TypeData::Basic );
     
    619619                                        dst->base->aggInst.params = maybeClone( src->aggregate.actuals );
    620620                                } // if
    621                                 dst->base->typeQualifiers.val |= src->typeQualifiers.val;
     621                                dst->base->typeQualifiers |= src->typeQualifiers;
    622622                                src = nullptr;
    623623                                break;
     
    651651                                                type->aggInst.hoistType = o->type->enumeration.body;
    652652                                        } // if
    653                                         type->typeQualifiers.val |= o->type->typeQualifiers.val;
     653                                        type->typeQualifiers |= o->type->typeQualifiers;
    654654                                } else {
    655655                                        type = o->type;
     
    807807                                        p->type->base->aggInst.params = maybeClone( type->aggregate.actuals );
    808808                                } // if
    809                                 p->type->base->typeQualifiers.val |= type->typeQualifiers.val;
     809                                p->type->base->typeQualifiers |= type->typeQualifiers;
    810810                                break;
    811811
     
    844844                                        lastArray->base->aggInst.params = maybeClone( type->aggregate.actuals );
    845845                                } // if
    846                                 lastArray->base->typeQualifiers.val |= type->typeQualifiers.val;
     846                                lastArray->base->typeQualifiers |= type->typeQualifiers;
    847847                                break;
    848848                          default:
  • src/Parser/ParseNode.h

    re61a35e r4da6a6c  
    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 11:05:05 2017
     13// Update Count     : 752
    1414//
    1515
     
    1919#include <string>
    2020#include <list>
     21#include <bitset>
    2122#include <iterator>
    2223#include <memory>
     
    231232        }; // FuncSpecifiers
    232233
    233         enum { Const = 1 << 0, Restrict = 1 << 1, Volatile = 1 << 2, Lvalue = 1 << 3, Mutex = 1 << 4, Atomic = 1 << 5, NoTypeQualifier = 6 };
    234         union TypeQualifiers {
    235                 unsigned int val;
    236                 struct {
    237                         bool is_const : 1;
    238                         bool is_restrict : 1;
    239                         bool is_volatile : 1;
    240                         bool is_lvalue : 1;
    241                         bool is_mutex : 1;
    242                         bool is_atomic : 1;
    243                 };
    244                 TypeQualifiers() : val( 0 ) {}
    245                 TypeQualifiers( unsigned int val ) : val( val ) {}
    246                 bool operator[]( unsigned int i ) const { return val & (1 << i); }
    247         }; // TypeQualifiers
    248 
     234        enum TypeQualifier { Const, Restrict, Volatile, Lvalue, Mutex, Atomic, NoTypeQualifier };
    249235        enum BasicType { Void, Bool, Char, Int, Float, Double, LongDouble, NoBasicType };
    250236        enum ComplexType { Complex, Imaginary, NoComplexType };
     
    268254        static DeclarationNode * newStorageClass( StorageClasses );
    269255        static DeclarationNode * newFuncSpecifier( FuncSpecifiers );
    270         static DeclarationNode * newTypeQualifier( TypeQualifiers );
     256        static DeclarationNode * newTypeQualifier( TypeQualifier );
    271257        static DeclarationNode * newBasicType( BasicType );
    272258        static DeclarationNode * newComplexType( ComplexType );
  • src/Parser/TypeData.cc

    re61a35e r4da6a6c  
    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  7 08:08:21 2017
     13// Update Count     : 538
    1414//
    1515
     
    2626using namespace std;
    2727
    28 TypeData::TypeData( Kind k ) : kind( k ), base( nullptr ), forall( nullptr ) /*, PTR1( (void*)(0xdeadbeefdeadbeef)), PTR2( (void*)(0xdeadbeefdeadbeef) ) */ {
     28TypeData::TypeData( Kind k ) : kind( k ), base( nullptr ), forall( nullptr ) {
    2929        switch ( kind ) {
    3030          case Unknown:
     
    5050                function.newStyle = false;
    5151                break;
    52                 // Enum is an Aggregate, so both structures are initialized together.
    53           case Enum:
    54                 // enumeration = new Enumeration_t;
    55                 enumeration.name = nullptr;
    56                 enumeration.constants = nullptr;
    57                 enumeration.body = false;
    5852          case Aggregate:
    5953                // aggregate = new Aggregate_t;
     
    6963                aggInst.params = nullptr;
    7064                aggInst.hoistType = false;;
     65                break;
     66          case Enum:
     67                // enumeration = new Enumeration_t;
     68                enumeration.name = nullptr;
     69                enumeration.constants = nullptr;
     70                enumeration.body = false;
    7171                break;
    7272          case Symbolic:
     
    494494Type::Qualifiers buildQualifiers( const TypeData * td ) {
    495495        Type::Qualifiers q;
    496         q.isConst = td->typeQualifiers.is_const;
    497         q.isVolatile = td->typeQualifiers.is_volatile;
    498         q.isRestrict = td->typeQualifiers.is_restrict;
    499         q.isLvalue = td->typeQualifiers.is_lvalue;
    500         q.isAtomic = td->typeQualifiers.is_atomic;
     496        q.isConst = td->typeQualifiers[ DeclarationNode::Const ];
     497        q.isVolatile = td->typeQualifiers[ DeclarationNode::Volatile ];
     498        q.isRestrict = td->typeQualifiers[ DeclarationNode::Restrict ];
     499        q.isLvalue = td->typeQualifiers[ DeclarationNode::Lvalue ];
     500        q.isAtomic = td->typeQualifiers[ DeclarationNode::Atomic ];;
    501501        return q;
    502502} // buildQualifiers
  • src/Parser/TypeData.h

    re61a35e r4da6a6c  
    1010// Created On       : Sat May 16 15:18:36 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Mar 14 16:51:26 2017
    13 // Update Count     : 181
     12// Last Modified On : Wed Mar  8 22:28:33 2017
     13// Update Count     : 174
    1414//
    1515
    1616#ifndef TYPEDATA_H
    1717#define TYPEDATA_H
     18
     19#include <bitset>
    1820
    1921#include "ParseNode.h"
     
    7577        DeclarationNode::BuiltinType builtintype = DeclarationNode::NoBuiltinType;
    7678
    77         DeclarationNode::TypeQualifiers typeQualifiers;
     79        typedef std::bitset< DeclarationNode::NoTypeQualifier > TypeQualifiers;
     80        TypeQualifiers typeQualifiers;
    7881        DeclarationNode * forall;
    7982
Note: See TracChangeset for help on using the changeset viewer.