Changeset 946bcca for src/Parser
- Timestamp:
- Mar 17, 2017, 1:14:44 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:
- 14a33790, 7c70089, 89d129c
- Parents:
- b2f5082 (diff), 615a096 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Location:
- src/Parser
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified src/Parser/DeclarationNode.cc ¶
rb2f5082 r946bcca 10 10 // Created On : Sat May 16 12:34:05 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Mar 16 09:10:57201713 // Update Count : 10 0712 // Last Modified On : Fri Mar 17 08:46:05 2017 13 // Update Count : 1017 14 14 // 15 15 … … 19 19 #include <algorithm> 20 20 #include <cassert> 21 #include <strings.h> // ffs22 21 23 22 #include "TypeData.h" … … 243 242 244 243 DeclarationNode * DeclarationNode::newAggregate( Aggregate kind, const string * name, ExpressionNode * actuals, DeclarationNode * fields, bool body ) { 244 assert( name ); 245 245 DeclarationNode * newnode = new DeclarationNode; 246 246 newnode->type = new TypeData( TypeData::Aggregate ); 247 247 newnode->type->aggregate.kind = kind; 248 if ( name ) { 249 newnode->type->aggregate.name = name; 250 } else { // anonymous aggregate ? 251 newnode->type->aggregate.name = new string( anonymous.newName() ); 252 } // if 248 newnode->type->aggregate.name = name; 253 249 newnode->type->aggregate.actuals = actuals; 254 250 newnode->type->aggregate.fields = fields; … … 258 254 259 255 DeclarationNode * DeclarationNode::newEnum( string * name, DeclarationNode * constants, bool body ) { 256 assert( name ); 260 257 DeclarationNode * newnode = new DeclarationNode; 261 258 newnode->type = new TypeData( TypeData::Enum ); 262 if ( name ) { 263 newnode->type->enumeration.name = name; 264 } else { // anonymous aggregate ? 265 newnode->type->enumeration.name = new string( anonymous.newName() ); 266 } // if 259 newnode->type->enumeration.name = name; 267 260 newnode->type->enumeration.constants = constants; 268 261 newnode->type->enumeration.body = body; … … 436 429 const Type::Qualifiers qsrc = src->qualifiers, qdst = dst->qualifiers; // optimization 437 430 438 if ( (qsrc .val & qdst.val) != 0 ) {// duplicates ?431 if ( (qsrc & qdst).any() ) { // duplicates ? 439 432 for ( unsigned int i = 0; i < Type::NumTypeQualifier; i += 1 ) { // find duplicates 440 433 if ( qsrc[i] && qdst[i] ) { 441 appendError( error, string( "duplicate " ) + Type::Qualifiers ::Names[i] );434 appendError( error, string( "duplicate " ) + Type::QualifiersNames[i] ); 442 435 } // if 443 436 } // for … … 446 439 447 440 void DeclarationNode::checkSpecifiers( DeclarationNode * src ) { 448 if ( (funcSpecs .val & src->funcSpecs.val) != 0 ) {// duplicates ?441 if ( (funcSpecs & src->funcSpecs).any() ) { // duplicates ? 449 442 for ( unsigned int i = 0; i < Type::NumFuncSpecifier; i += 1 ) { // find duplicates 450 443 if ( funcSpecs[i] && src->funcSpecs[i] ) { 451 appendError( error, string( "duplicate " ) + Type::FuncSpecifiers ::Names[i] );444 appendError( error, string( "duplicate " ) + Type::FuncSpecifiersNames[i] ); 452 445 } // if 453 446 } // for … … 455 448 456 449 if ( storageClasses.any() && src->storageClasses.any() ) { // any reason to check ? 457 if ( (storageClasses .val & src->storageClasses.val ) != 0) { // duplicates ?450 if ( (storageClasses & src->storageClasses ).any() ) { // duplicates ? 458 451 for ( unsigned int i = 0; i < Type::NumStorageClass; i += 1 ) { // find duplicates 459 452 if ( storageClasses[i] && src->storageClasses[i] ) { 460 appendError( error, string( "duplicate " ) + Type::StorageClasses ::Names[i] );453 appendError( error, string( "duplicate " ) + Type::StorageClassesNames[i] ); 461 454 } // if 462 455 } // for 463 456 // src is the new item being added and has a single bit 464 457 } else if ( ! src->storageClasses.is_threadlocal ) { // conflict ? 465 appendError( error, string( "conflicting " ) + Type::StorageClasses ::Names[ffs( storageClasses.val ) - 1] +466 " & " + Type::StorageClasses ::Names[ffs( src->storageClasses.val ) - 1] );467 src->storageClasses. val = 0; // FIX to preserve invariant of one basic storage specifier458 appendError( error, string( "conflicting " ) + Type::StorageClassesNames[storageClasses.ffs()] + 459 " & " + Type::StorageClassesNames[src->storageClasses.ffs()] ); 460 src->storageClasses.reset(); // FIX to preserve invariant of one basic storage specifier 468 461 } // if 469 462 } // if … … 473 466 474 467 DeclarationNode * DeclarationNode::copySpecifiers( DeclarationNode * q ) { 475 funcSpecs .val |= q->funcSpecs.val;476 storageClasses .val |= q->storageClasses.val;468 funcSpecs |= q->funcSpecs; 469 storageClasses |= q->storageClasses; 477 470 478 471 for ( Attribute *attr: reverseIterate( q->attributes ) ) { … … 497 490 src = nullptr; 498 491 } else { 499 dst->qualifiers += src->qualifiers;492 dst->qualifiers |= src->qualifiers; 500 493 } // if 501 494 } // addQualifiersToType … … 555 548 switch ( dst->kind ) { 556 549 case TypeData::Unknown: 557 src->qualifiers += dst->qualifiers;550 src->qualifiers |= dst->qualifiers; 558 551 dst = src; 559 552 src = nullptr; 560 553 break; 561 554 case TypeData::Basic: 562 dst->qualifiers += src->qualifiers;555 dst->qualifiers |= src->qualifiers; 563 556 if ( src->kind != TypeData::Unknown ) { 564 557 assert( src->kind == TypeData::Basic ); … … 596 589 dst->base->aggInst.params = maybeClone( src->aggregate.actuals ); 597 590 } // if 598 dst->base->qualifiers += src->qualifiers;591 dst->base->qualifiers |= src->qualifiers; 599 592 src = nullptr; 600 593 break; … … 628 621 type->aggInst.hoistType = o->type->enumeration.body; 629 622 } // if 630 type->qualifiers += o->type->qualifiers;623 type->qualifiers |= o->type->qualifiers; 631 624 } else { 632 625 type = o->type; … … 784 777 p->type->base->aggInst.params = maybeClone( type->aggregate.actuals ); 785 778 } // if 786 p->type->base->qualifiers += type->qualifiers;779 p->type->base->qualifiers |= type->qualifiers; 787 780 break; 788 781 … … 821 814 lastArray->base->aggInst.params = maybeClone( type->aggregate.actuals ); 822 815 } // if 823 lastArray->base->qualifiers += type->qualifiers;816 lastArray->base->qualifiers |= type->qualifiers; 824 817 break; 825 818 default: -
TabularUnified src/Parser/TypeData.cc ¶
rb2f5082 r946bcca 10 10 // Created On : Sat May 16 15:12:51 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Mar 16 08:32:42201713 // Update Count : 5 5912 // Last Modified On : Fri Mar 17 08:46:10 2017 13 // Update Count : 560 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::Qualifiers ::Names[ i ] << ' ';229 if ( qualifiers[i] ) os << Type::QualifiersNames[ i ] << ' '; 230 230 } // for 231 231 -
TabularUnified src/Parser/lex.ll ¶
rb2f5082 r946bcca 10 10 * Created On : Sat Sep 22 08:58:10 2001 11 11 * Last Modified By : Peter A. Buhr 12 * Last Modified On : Thu Mar 9 21:38:26201713 * Update Count : 50 512 * Last Modified On : Mon Mar 13 08:36:17 2017 13 * Update Count : 506 14 14 */ 15 15 … … 313 313 314 314 /* punctuation */ 315 "@" { ASCIIOP_RETURN(); } 315 316 "[" { ASCIIOP_RETURN(); } 316 317 "]" { ASCIIOP_RETURN(); } -
TabularUnified src/Parser/parser.yy ¶
rb2f5082 r946bcca 10 10 // Created On : Sat Sep 1 20:22:55 2001 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Thu Mar 16 08:36:17201713 // Update Count : 231 012 // Last Modified On : Thu Mar 16 12:57:03 2017 13 // Update Count : 2316 14 14 // 15 15 … … 1612 1612 aggregate_type: // struct, union 1613 1613 aggregate_key attribute_list_opt '{' field_declaration_list '}' 1614 { $$ = DeclarationNode::newAggregate( $1, n ullptr, nullptr, $4, true )->addQualifiers( $2 ); }1614 { $$ = DeclarationNode::newAggregate( $1, new string( DeclarationNode::anonymous.newName() ), nullptr, $4, true )->addQualifiers( $2 ); } 1615 1615 | aggregate_key attribute_list_opt no_attr_identifier_or_type_name 1616 1616 { typedefTable.makeTypedef( *$3 ); } … … 1618 1618 { $$ = DeclarationNode::newAggregate( $1, $3, nullptr, $6, true )->addQualifiers( $2 ); } 1619 1619 | aggregate_key attribute_list_opt '(' type_name_list ')' '{' field_declaration_list '}' // CFA 1620 { $$ = DeclarationNode::newAggregate( $1, n ullptr, $4, $7, false )->addQualifiers( $2 ); }1620 { $$ = DeclarationNode::newAggregate( $1, new string( DeclarationNode::anonymous.newName() ), $4, $7, false )->addQualifiers( $2 ); } 1621 1621 | aggregate_type_nobody 1622 1622 ; … … 1688 1688 // empty 1689 1689 { $$ = DeclarationNode::newName( 0 ); /* XXX */ } // CFA, no field name 1690 // '@' // empty1691 // { $$ = DeclarationNode::newName( 0 ); /* XXX */} // CFA, no field name1690 // '@' 1691 // { $$ = DeclarationNode::newName( new string( DeclarationNode::anonymous.newName() ) ); } // CFA, no field name 1692 1692 | bit_subrange_size // no field name 1693 1693 { $$ = DeclarationNode::newBitfield( $1 ); } … … 1715 1715 enum_type: // enum 1716 1716 ENUM attribute_list_opt '{' enumerator_list comma_opt '}' 1717 { $$ = DeclarationNode::newEnum( n ullptr, $4, true )->addQualifiers( $2 ); }1717 { $$ = DeclarationNode::newEnum( new string( DeclarationNode::anonymous.newName() ), $4, true )->addQualifiers( $2 ); } 1718 1718 | ENUM attribute_list_opt no_attr_identifier_or_type_name 1719 1719 { typedefTable.makeTypedef( *$3 ); }
Note: See TracChangeset
for help on using the changeset viewer.