Changeset e496303
- Timestamp:
- Mar 14, 2017, 4:57:43 PM (8 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- e61a35e
- Parents:
- 08d5507b
- Location:
- src/Parser
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Parser/DeclarationNode.cc
r08d5507b re496303 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 0:19:38201713 // Update Count : 9 6412 // Last Modified On : Tue Mar 14 14:45:52 2017 13 // Update Count : 973 14 14 // 15 15 … … 202 202 203 203 204 DeclarationNode * DeclarationNode::newStorageClass( DeclarationNode::StorageClasses sc ) {204 DeclarationNode * DeclarationNode::newStorageClass( StorageClasses sc ) { 205 205 DeclarationNode * newnode = new DeclarationNode; 206 206 newnode->storageClasses = sc; … … 208 208 } // DeclarationNode::newStorageClass 209 209 210 DeclarationNode * DeclarationNode::newFuncSpecifier( DeclarationNode::FuncSpecifiers fs ) {210 DeclarationNode * DeclarationNode::newFuncSpecifier( FuncSpecifiers fs ) { 211 211 DeclarationNode * newnode = new DeclarationNode; 212 212 newnode->funcSpecs = fs; … … 214 214 } // DeclarationNode::newFuncSpecifier 215 215 216 DeclarationNode * DeclarationNode::newTypeQualifier( TypeQualifier tq ) {216 DeclarationNode * DeclarationNode::newTypeQualifier( TypeQualifiers tq ) { 217 217 DeclarationNode * newnode = new DeclarationNode; 218 218 newnode->type = new TypeData(); 219 newnode->type->typeQualifiers [ tq ] = true;219 newnode->type->typeQualifiers = tq; 220 220 return newnode; 221 221 } // DeclarationNode::newQualifier … … 457 457 458 458 void DeclarationNode::checkQualifiers( const TypeData * src, const TypeData * dst ) { 459 const Type Data::TypeQualifiers qsrc = src->typeQualifiers, qdst = dst->typeQualifiers; // optimization460 461 if ( (qsrc & qdst).any() ) {// duplicates ?459 const TypeQualifiers qsrc = src->typeQualifiers, qdst = dst->typeQualifiers; // optimization 460 461 if ( (qsrc.val & qdst.val) != 0 ) { // 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 |= src->typeQualifiers;522 dst->typeQualifiers.val |= src->typeQualifiers.val; 523 523 } // if 524 524 } // addQualifiersToType … … 578 578 switch ( dst->kind ) { 579 579 case TypeData::Unknown: 580 src->typeQualifiers |= dst->typeQualifiers;580 src->typeQualifiers.val |= dst->typeQualifiers.val; 581 581 dst = src; 582 582 src = nullptr; 583 583 break; 584 584 case TypeData::Basic: 585 dst->typeQualifiers |= src->typeQualifiers;585 dst->typeQualifiers.val |= src->typeQualifiers.val; 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 |= src->typeQualifiers;621 dst->base->typeQualifiers.val |= src->typeQualifiers.val; 622 622 src = nullptr; 623 623 break; … … 651 651 type->aggInst.hoistType = o->type->enumeration.body; 652 652 } // if 653 type->typeQualifiers |= o->type->typeQualifiers;653 type->typeQualifiers.val |= o->type->typeQualifiers.val; 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 |= type->typeQualifiers;809 p->type->base->typeQualifiers.val |= type->typeQualifiers.val; 810 810 break; 811 811 … … 844 844 lastArray->base->aggInst.params = maybeClone( type->aggregate.actuals ); 845 845 } // if 846 lastArray->base->typeQualifiers |= type->typeQualifiers;846 lastArray->base->typeQualifiers.val |= type->typeQualifiers.val; 847 847 break; 848 848 default: -
src/Parser/ParseNode.h
r08d5507b re496303 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 1:05:05201713 // Update Count : 75 212 // Last Modified On : Tue Mar 14 16:53:19 2017 13 // Update Count : 757 14 14 // 15 15 … … 19 19 #include <string> 20 20 #include <list> 21 #include <bitset>22 21 #include <iterator> 23 22 #include <memory> … … 232 231 }; // FuncSpecifiers 233 232 234 enum TypeQualifier { Const, Restrict, Volatile, Lvalue, Mutex, Atomic, NoTypeQualifier }; 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 235 249 enum BasicType { Void, Bool, Char, Int, Float, Double, LongDouble, NoBasicType }; 236 250 enum ComplexType { Complex, Imaginary, NoComplexType }; … … 254 268 static DeclarationNode * newStorageClass( StorageClasses ); 255 269 static DeclarationNode * newFuncSpecifier( FuncSpecifiers ); 256 static DeclarationNode * newTypeQualifier( TypeQualifier );270 static DeclarationNode * newTypeQualifier( TypeQualifiers ); 257 271 static DeclarationNode * newBasicType( BasicType ); 258 272 static DeclarationNode * newComplexType( ComplexType ); -
src/Parser/TypeData.cc
r08d5507b re496303 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 7 08:08:21201713 // Update Count : 5 3812 // Last Modified On : Tue Mar 14 15:01:44 2017 13 // Update Count : 548 14 14 // 15 15 … … 26 26 using namespace std; 27 27 28 TypeData::TypeData( Kind k ) : kind( k ), base( nullptr ), forall( nullptr ) {28 TypeData::TypeData( Kind k ) : kind( k ), base( nullptr ), forall( nullptr ) /*, PTR1( (void*)(0xdeadbeefdeadbeef)), PTR2( (void*)(0xdeadbeefdeadbeef) ) */ { 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; 52 58 case Aggregate: 53 59 // aggregate = new Aggregate_t; … … 63 69 aggInst.params = nullptr; 64 70 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 [ 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 ];;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; 501 501 return q; 502 502 } // buildQualifiers -
src/Parser/TypeData.h
r08d5507b re496303 10 10 // Created On : Sat May 16 15:18:36 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Mar 8 22:28:33201713 // Update Count : 1 7412 // Last Modified On : Tue Mar 14 16:51:26 2017 13 // Update Count : 181 14 14 // 15 15 16 16 #ifndef TYPEDATA_H 17 17 #define TYPEDATA_H 18 19 #include <bitset>20 18 21 19 #include "ParseNode.h" … … 77 75 DeclarationNode::BuiltinType builtintype = DeclarationNode::NoBuiltinType; 78 76 79 typedef std::bitset< DeclarationNode::NoTypeQualifier > TypeQualifiers; 80 TypeQualifiers typeQualifiers; 77 DeclarationNode::TypeQualifiers typeQualifiers; 81 78 DeclarationNode * forall; 82 79
Note: See TracChangeset
for help on using the changeset viewer.