Changes in / [e61a35e:4da6a6c]
- Location:
- src/Parser
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/DeclarationNode.cc
re61a35e r4da6a6c 10 10 // Created On : Sat May 16 12:34:05 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Mar 14 1 4:45:52201713 // Update Count : 9 7312 // Last Modified On : Tue Mar 14 10:19:38 2017 13 // Update Count : 964 14 14 // 15 15 … … 202 202 203 203 204 DeclarationNode * DeclarationNode::newStorageClass( StorageClasses sc ) {204 DeclarationNode * DeclarationNode::newStorageClass( DeclarationNode::StorageClasses sc ) { 205 205 DeclarationNode * newnode = new DeclarationNode; 206 206 newnode->storageClasses = sc; … … 208 208 } // DeclarationNode::newStorageClass 209 209 210 DeclarationNode * DeclarationNode::newFuncSpecifier( FuncSpecifiers fs ) {210 DeclarationNode * DeclarationNode::newFuncSpecifier( DeclarationNode::FuncSpecifiers fs ) { 211 211 DeclarationNode * newnode = new DeclarationNode; 212 212 newnode->funcSpecs = fs; … … 214 214 } // DeclarationNode::newFuncSpecifier 215 215 216 DeclarationNode * DeclarationNode::newTypeQualifier( TypeQualifier stq ) {216 DeclarationNode * DeclarationNode::newTypeQualifier( TypeQualifier tq ) { 217 217 DeclarationNode * newnode = new DeclarationNode; 218 218 newnode->type = new TypeData(); 219 newnode->type->typeQualifiers = tq;219 newnode->type->typeQualifiers[ tq ] = true; 220 220 return newnode; 221 221 } // DeclarationNode::newQualifier … … 457 457 458 458 void DeclarationNode::checkQualifiers( const TypeData * src, const TypeData * dst ) { 459 const Type Qualifiers qsrc = src->typeQualifiers, qdst = dst->typeQualifiers; // optimization460 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 ? 462 462 for ( unsigned int i = 0; i < NoTypeQualifier; i += 1 ) { // find duplicates 463 463 if ( qsrc[i] && qdst[i] ) { … … 520 520 src = nullptr; 521 521 } else { 522 dst->typeQualifiers .val |= src->typeQualifiers.val;522 dst->typeQualifiers |= src->typeQualifiers; 523 523 } // if 524 524 } // addQualifiersToType … … 578 578 switch ( dst->kind ) { 579 579 case TypeData::Unknown: 580 src->typeQualifiers .val |= dst->typeQualifiers.val;580 src->typeQualifiers |= dst->typeQualifiers; 581 581 dst = src; 582 582 src = nullptr; 583 583 break; 584 584 case TypeData::Basic: 585 dst->typeQualifiers .val |= src->typeQualifiers.val;585 dst->typeQualifiers |= src->typeQualifiers; 586 586 if ( src->kind != TypeData::Unknown ) { 587 587 assert( src->kind == TypeData::Basic ); … … 619 619 dst->base->aggInst.params = maybeClone( src->aggregate.actuals ); 620 620 } // if 621 dst->base->typeQualifiers .val |= src->typeQualifiers.val;621 dst->base->typeQualifiers |= src->typeQualifiers; 622 622 src = nullptr; 623 623 break; … … 651 651 type->aggInst.hoistType = o->type->enumeration.body; 652 652 } // if 653 type->typeQualifiers .val |= o->type->typeQualifiers.val;653 type->typeQualifiers |= o->type->typeQualifiers; 654 654 } else { 655 655 type = o->type; … … 807 807 p->type->base->aggInst.params = maybeClone( type->aggregate.actuals ); 808 808 } // if 809 p->type->base->typeQualifiers .val |= type->typeQualifiers.val;809 p->type->base->typeQualifiers |= type->typeQualifiers; 810 810 break; 811 811 … … 844 844 lastArray->base->aggInst.params = maybeClone( type->aggregate.actuals ); 845 845 } // if 846 lastArray->base->typeQualifiers .val |= type->typeQualifiers.val;846 lastArray->base->typeQualifiers |= type->typeQualifiers; 847 847 break; 848 848 default: -
src/Parser/ParseNode.h
re61a35e r4da6a6c 10 10 // Created On : Sat May 16 13:28:16 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Mar 14 1 6:53:19201713 // Update Count : 75 712 // Last Modified On : Tue Mar 14 11:05:05 2017 13 // Update Count : 752 14 14 // 15 15 … … 19 19 #include <string> 20 20 #include <list> 21 #include <bitset> 21 22 #include <iterator> 22 23 #include <memory> … … 231 232 }; // FuncSpecifiers 232 233 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 }; 249 235 enum BasicType { Void, Bool, Char, Int, Float, Double, LongDouble, NoBasicType }; 250 236 enum ComplexType { Complex, Imaginary, NoComplexType }; … … 268 254 static DeclarationNode * newStorageClass( StorageClasses ); 269 255 static DeclarationNode * newFuncSpecifier( FuncSpecifiers ); 270 static DeclarationNode * newTypeQualifier( TypeQualifier s);256 static DeclarationNode * newTypeQualifier( TypeQualifier ); 271 257 static DeclarationNode * newBasicType( BasicType ); 272 258 static DeclarationNode * newComplexType( ComplexType ); -
src/Parser/TypeData.cc
re61a35e r4da6a6c 10 10 // Created On : Sat May 16 15:12:51 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Mar 14 15:01:44201713 // Update Count : 5 4812 // Last Modified On : Tue Mar 7 08:08:21 2017 13 // Update Count : 538 14 14 // 15 15 … … 26 26 using namespace std; 27 27 28 TypeData::TypeData( Kind k ) : kind( k ), base( nullptr ), forall( nullptr ) /*, PTR1( (void*)(0xdeadbeefdeadbeef)), PTR2( (void*)(0xdeadbeefdeadbeef) ) */{28 TypeData::TypeData( Kind k ) : kind( k ), base( nullptr ), forall( nullptr ) { 29 29 switch ( kind ) { 30 30 case Unknown: … … 50 50 function.newStyle = false; 51 51 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;58 52 case Aggregate: 59 53 // aggregate = new Aggregate_t; … … 69 63 aggInst.params = nullptr; 70 64 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; 71 71 break; 72 72 case Symbolic: … … 494 494 Type::Qualifiers buildQualifiers( const TypeData * td ) { 495 495 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 ];; 501 501 return q; 502 502 } // buildQualifiers -
src/Parser/TypeData.h
re61a35e r4da6a6c 10 10 // Created On : Sat May 16 15:18:36 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Mar 14 16:51:26201713 // Update Count : 1 8112 // Last Modified On : Wed Mar 8 22:28:33 2017 13 // Update Count : 174 14 14 // 15 15 16 16 #ifndef TYPEDATA_H 17 17 #define TYPEDATA_H 18 19 #include <bitset> 18 20 19 21 #include "ParseNode.h" … … 75 77 DeclarationNode::BuiltinType builtintype = DeclarationNode::NoBuiltinType; 76 78 77 DeclarationNode::TypeQualifiers typeQualifiers; 79 typedef std::bitset< DeclarationNode::NoTypeQualifier > TypeQualifiers; 80 TypeQualifiers typeQualifiers; 78 81 DeclarationNode * forall; 79 82
Note: See TracChangeset
for help on using the changeset viewer.