Changeset 6e8bd43 for src/Parser
- Timestamp:
- Mar 16, 2017, 7:41:45 AM (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:
- 64b6913, 68fe077a
- Parents:
- 905eca1
- Location:
- src/Parser
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified src/Parser/DeclarationNode.cc ¶
r905eca1 r6e8bd43 10 10 // Created On : Sat May 16 12:34:05 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Mar 15 2 2:31:36201713 // Update Count : 9 8312 // Last Modified On : Wed Mar 15 23:36:49 2017 13 // Update Count : 997 14 14 // 15 15 … … 33 33 34 34 // These must remain in the same order as the corresponding DeclarationNode enumerations. 35 const char * DeclarationNode:: storageClassNames[] = { "extern", "static", "auto", "register", "_Thread_local", "NoStorageClassNames" };36 const char * DeclarationNode:: funcSpecifierNames[] = { "inline", "fortran", "_Noreturn", "NoFunctionSpecifierNames" };35 const char * DeclarationNode::StorageClasses::Names[] = { "extern", "static", "auto", "register", "_Thread_local", "NoStorageClassNames" }; 36 const char * DeclarationNode::FuncSpecifiers::Names[] = { "inline", "fortran", "_Noreturn", "NoFunctionSpecifierNames" }; 37 37 const char * DeclarationNode::basicTypeNames[] = { "void", "_Bool", "char", "int", "float", "double", "long double", "NoBasicTypeNames" }; 38 38 const char * DeclarationNode::complexTypeNames[] = { "_Complex", "_Imaginary", "NoComplexTypeNames" }; … … 115 115 } 116 116 117 void DeclarationNode::print_StorageClass( std::ostream & output, StorageClasses storageClasses ) {118 if ( storageClasses.val != 0 ) { // storage classes ?119 for ( unsigned int i = 0; i < DeclarationNode::NumStorageClass; i += 1 ) {120 if ( storageClasses[i] ) {121 output << DeclarationNode::storageClassNames[i] << ' ';122 } // if123 } // for124 } // if125 } // print_StorageClass126 127 void DeclarationNode::print_FuncSpec( std::ostream & output, DeclarationNode::FuncSpecifiers funcSpec ) {128 if ( funcSpec.val != 0 ) { // function specifiers ?129 for ( unsigned int i = 0; i < DeclarationNode::NumFuncSpecifier; i += 1 ) {130 if ( funcSpec[i] ) {131 output << DeclarationNode::funcSpecifierNames[i] << ' ';132 } // if133 } // for134 } // if135 } // print_FuncSpec136 137 117 void DeclarationNode::print( std::ostream &os, int indent ) const { 138 118 os << string( indent, ' ' ); … … 147 127 } // if 148 128 149 print_StorageClass( os, storageClasses );150 print_FuncSpec( os, funcSpecs );129 storageClasses.print( os ); 130 funcSpecs.print( os ); 151 131 152 132 if ( type ) { … … 461 441 for ( unsigned int i = 0; i < Type::NumTypeQualifier; i += 1 ) { // find duplicates 462 442 if ( qsrc[i] && qdst[i] ) { 463 appendError( error, string( "duplicate " ) + Type::Qualifier Names[i] );443 appendError( error, string( "duplicate " ) + Type::Qualifiers::Names[i] ); 464 444 } // if 465 445 } // for … … 471 451 for ( unsigned int i = 0; i < NumFuncSpecifier; i += 1 ) { // find duplicates 472 452 if ( funcSpecs[i] && src->funcSpecs[i] ) { 473 appendError( error, string( "duplicate " ) + DeclarationNode::funcSpecifierNames[i] );453 appendError( error, string( "duplicate " ) + FuncSpecifiers::Names[i] ); 474 454 } // if 475 455 } // for 476 456 } // if 477 457 478 if ( storageClasses. val != 0 && src->storageClasses.val != 0) { // any reason to check ?458 if ( storageClasses.any() && src->storageClasses.any() ) { // any reason to check ? 479 459 if ( (storageClasses.val & src->storageClasses.val ) != 0 ) { // duplicates ? 480 460 for ( unsigned int i = 0; i < NumStorageClass; i += 1 ) { // find duplicates 481 461 if ( storageClasses[i] && src->storageClasses[i] ) { 482 appendError( error, string( "duplicate " ) + storageClassNames[i] );462 appendError( error, string( "duplicate " ) + StorageClasses::Names[i] ); 483 463 } // if 484 464 } // for 485 465 // src is the new item being added and has a single bit 486 466 } else if ( ! src->storageClasses.is_threadlocal ) { // conflict ? 487 appendError( error, string( "conflicting " ) + storageClassNames[ffs( storageClasses.val ) - 1] +488 " & " + storageClassNames[ffs( src->storageClasses.val ) - 1] );467 appendError( error, string( "conflicting " ) + StorageClasses::Names[ffs( storageClasses.val ) - 1] + 468 " & " + StorageClasses::Names[ffs( src->storageClasses.val ) - 1] ); 489 469 src->storageClasses.val = 0; // FIX to preserve invariant of one basic storage specifier 490 470 } // if -
TabularUnified src/Parser/ParseNode.h ¶
r905eca1 r6e8bd43 10 10 // Created On : Sat May 16 13:28:16 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Mar 15 2 2:17:50201713 // Update Count : 7 6212 // Last Modified On : Wed Mar 15 23:31:02 2017 13 // Update Count : 770 14 14 // 15 15 … … 205 205 enum { Extern = 1 << 0, Static = 1 << 1, Auto = 1 << 2, Register = 1 << 3, Threadlocal = 1 << 4, NumStorageClass = 5 }; 206 206 union StorageClasses { 207 static const char * Names[]; 207 208 unsigned int val; 208 209 struct { … … 213 214 bool is_threadlocal : 1; 214 215 }; 216 215 217 StorageClasses() : val( 0 ) {} 216 218 StorageClasses( unsigned int val ) : val( val ) {} 217 219 bool operator[]( unsigned int i ) const { return val & (1 << i); } 220 bool any() const { return val != 0; } 221 void print( std::ostream & os ) const { 222 if ( (*this).any() ) { // any storage classes ? 223 for ( unsigned int i = 0; i < NumStorageClass; i += 1 ) { 224 if ( (*this)[i] ) { 225 os << StorageClasses::Names[i] << ' '; 226 } // if 227 } // for 228 } // if 229 } 218 230 }; // StorageClasses 219 231 220 232 enum { Inline = 1 << 0, Noreturn = 1 << 1, Fortran = 1 << 2, NumFuncSpecifier = 3 }; 221 233 union FuncSpecifiers { 234 static const char * Names[]; 222 235 unsigned int val; 223 236 struct { … … 229 242 FuncSpecifiers( unsigned int val ) : val( val ) {} 230 243 bool operator[]( unsigned int i ) const { return val & (1 << i); } 244 bool any() const { return val != 0; } 245 void print( std::ostream & os ) const { 246 if ( (*this).any() ) { // any function specifiers ? 247 for ( unsigned int i = 0; i < NumFuncSpecifier; i += 1 ) { 248 if ( (*this)[i] ) { 249 os << FuncSpecifiers::Names[i] << ' '; 250 } // if 251 } // for 252 } // if 253 } 231 254 }; // FuncSpecifiers 232 255 … … 239 262 enum BuiltinType { Valist, Zero, One, NoBuiltinType }; 240 263 241 static const char * storageClassNames[];242 static const char * funcSpecifierNames[];243 264 static const char * basicTypeNames[]; 244 265 static const char * complexTypeNames[]; … … 348 369 349 370 StorageClasses storageClasses; 350 static void print_StorageClass( std::ostream & output, StorageClasses storageClasses );351 352 371 FuncSpecifiers funcSpecs; 353 static void print_FuncSpec( std::ostream & output, FuncSpecifiers funcSpecs );354 372 355 373 ExpressionNode * bitfieldWidth; -
TabularUnified src/Parser/TypeData.cc ¶
r905eca1 r6e8bd43 10 10 // Created On : Sat May 16 15:12:51 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Mar 15 22: 22:29201713 // Update Count : 55 512 // Last Modified On : Wed Mar 15 22:53:04 2017 13 // Update Count : 557 14 14 // 15 15 … … 227 227 void TypeData::print( ostream &os, int indent ) const { 228 228 for ( int i = 0; i < Type::NumTypeQualifier; i += 1 ) { 229 if ( qualifiers[i] ) os << Type::Qualifier Names[ i ] << ' ';229 if ( qualifiers[i] ) os << Type::Qualifiers::Names[ i ] << ' '; 230 230 } // for 231 231
Note: See TracChangeset
for help on using the changeset viewer.