Changeset 6e8bd43
- 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
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified src/CodeGen/CodeGenerator.cc ¶
r905eca1 r6e8bd43 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Mar 13 23:56:59201713 // Update Count : 47 712 // Last Modified On : Wed Mar 15 23:31:48 2017 13 // Update Count : 479 14 14 // 15 15 … … 134 134 135 135 handleStorageClass( functionDecl ); 136 DeclarationNode::print_FuncSpec( output, functionDecl->get_funcSpec());136 functionDecl->get_funcSpec().print( output ); 137 137 138 138 output << genType( functionDecl->get_functionType(), mangleName( functionDecl ), pretty ); … … 896 896 void CodeGenerator::handleStorageClass( DeclarationWithType * decl ) { 897 897 if ( decl->get_storageClasses().val != 0 ) { 898 DeclarationNode::print_StorageClass( output, decl->get_storageClasses());898 decl->get_storageClasses().print( output ); 899 899 } // if 900 900 } // CodeGenerator::handleStorageClass -
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 -
TabularUnified src/SynTree/FunctionDecl.cc ¶
r905eca1 r6e8bd43 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Mar 7 07:54:58201713 // Update Count : 6812 // Last Modified On : Wed Mar 15 23:33:43 2017 13 // Update Count : 72 14 14 // 15 15 … … 65 65 printAll( get_attributes(), os, indent ); 66 66 67 DeclarationNode::print_StorageClass( os, get_storageClasses());68 DeclarationNode::print_FuncSpec( os, get_funcSpec());67 get_storageClasses().print( os ); 68 get_funcSpec().print( os ); 69 69 70 70 if ( get_type() ) { … … 91 91 // xxx - should printShort print attributes? 92 92 93 DeclarationNode::print_StorageClass( os, get_storageClasses());94 DeclarationNode::print_FuncSpec( os, get_funcSpec());93 get_storageClasses().print( os ); 94 get_funcSpec().print( os ); 95 95 96 96 if ( get_type() ) { -
TabularUnified src/SynTree/NamedTypeDecl.cc ¶
r905eca1 r6e8bd43 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Mar 7 07:39:41 201713 // Update Count : 1 012 // Last Modified On : Wed Mar 15 23:25:41 2017 13 // Update Count : 12 14 14 // 15 15 … … 39 39 os << get_name() << ": "; 40 40 } // if 41 DeclarationNode::print_StorageClass( os, get_storageClasses());41 get_storageClasses().print( os ); 42 42 os << typeString(); 43 43 if ( base ) { … … 61 61 os << get_name() << ": "; 62 62 } // if 63 DeclarationNode::print_StorageClass( os, get_storageClasses());63 get_storageClasses().print( os ); 64 64 os << typeString(); 65 65 if ( base ) { -
TabularUnified src/SynTree/ObjectDecl.cc ¶
r905eca1 r6e8bd43 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Mar 7 07:55:24201713 // Update Count : 5 412 // Last Modified On : Wed Mar 15 23:26:22 2017 13 // Update Count : 57 14 14 // 15 15 … … 47 47 printAll( get_attributes(), os, indent ); 48 48 49 DeclarationNode::print_StorageClass( os, get_storageClasses());49 get_storageClasses().print( os ); 50 50 51 51 if ( get_type() ) { … … 81 81 // xxx - should printShort print attributes? 82 82 83 DeclarationNode::print_StorageClass( os, get_storageClasses());83 get_storageClasses().print( os ); 84 84 85 85 if ( get_type() ) { -
TabularUnified src/SynTree/Type.cc ¶
r905eca1 r6e8bd43 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Mar 15 2 1:22:16201713 // Update Count : 1 512 // Last Modified On : Wed Mar 15 23:14:35 2017 13 // Update Count : 19 14 14 // 15 15 … … 59 59 } 60 60 61 const char * Type::Qualifier Names[] = { "const", "restrict", "volatile", "lvalue", "mutex", "_Atomic", "NoTypeQualifierNames" };61 const char * Type::Qualifiers::Names[] = { "const", "restrict", "volatile", "lvalue", "mutex", "_Atomic" }; 62 62 63 63 void Type::print( std::ostream &os, int indent ) const { -
TabularUnified src/SynTree/Type.h ¶
r905eca1 r6e8bd43 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Mar 15 2 1:28:09201713 // Update Count : 8 512 // Last Modified On : Wed Mar 15 23:28:33 2017 13 // Update Count : 89 14 14 // 15 15 … … 24 24 class Type : public BaseSyntaxNode { 25 25 public: 26 static const char * QualifierNames[];27 28 26 enum { Const = 1 << 0, Restrict = 1 << 1, Volatile = 1 << 2, Lvalue = 1 << 3, Mutex = 1 << 4, Atomic = 1 << 5, NumTypeQualifier = 6 }; 29 27 union Qualifiers { 28 static const char * Names[]; 30 29 enum { Mask = ~(Restrict | Lvalue) }; 31 30 unsigned int val; … … 38 37 bool isAtomic : 1; 39 38 }; 39 40 40 Qualifiers() : val( 0 ) {} 41 41 Qualifiers( unsigned int val ) : val( val ) {} … … 80 80 for ( unsigned int i = 0; i < NumTypeQualifier; i += 1 ) { 81 81 if ( (*this)[i] ) { 82 os << QualifierNames[i] << ' ';82 os << Names[i] << ' '; 83 83 } // if 84 84 } // for
Note: See TracChangeset
for help on using the changeset viewer.