Changeset eaa6430
- Timestamp:
- Jun 12, 2018, 11:26:23 AM (6 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, no_list, persistent-indexer, pthread-emulation, qualifiedEnum
- Children:
- 589a70b
- Parents:
- d16cf16
- git-author:
- Rob Schluntz <rschlunt@…> (06/12/18 11:21:45)
- git-committer:
- Rob Schluntz <rschlunt@…> (06/12/18 11:26:23)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SymTab/Validate.cc
rd16cf16 reaa6430 395 395 396 396 void LinkReferenceToTypes::postvisit( EnumInstType *enumInst ) { 397 EnumDecl *st = local_indexer->lookupEnum( enumInst-> get_name());397 EnumDecl *st = local_indexer->lookupEnum( enumInst->name ); 398 398 // it's not a semantic error if the enum is not found, just an implicit forward declaration 399 399 if ( st ) { 400 400 //assert( ! enumInst->get_baseEnum() || enumInst->get_baseEnum()->get_members().empty() || ! st->get_members().empty() ); 401 enumInst-> set_baseEnum( st );402 } // if 403 if ( ! st || st-> get_members().empty() ) {401 enumInst->baseEnum = st; 402 } // if 403 if ( ! st || st->members.empty() ) { 404 404 // use of forward declaration 405 forwardEnums[ enumInst-> get_name()].push_back( enumInst );405 forwardEnums[ enumInst->name ].push_back( enumInst ); 406 406 } // if 407 407 } … … 416 416 417 417 void LinkReferenceToTypes::postvisit( StructInstType *structInst ) { 418 StructDecl *st = local_indexer->lookupStruct( structInst-> get_name());418 StructDecl *st = local_indexer->lookupStruct( structInst->name ); 419 419 // it's not a semantic error if the struct is not found, just an implicit forward declaration 420 420 if ( st ) { 421 421 //assert( ! structInst->get_baseStruct() || structInst->get_baseStruct()->get_members().empty() || ! st->get_members().empty() ); 422 structInst-> set_baseStruct( st );423 } // if 424 if ( ! st || st-> get_members().empty() ) {422 structInst->baseStruct = st; 423 } // if 424 if ( ! st || st->members.empty() ) { 425 425 // use of forward declaration 426 forwardStructs[ structInst-> get_name()].push_back( structInst );426 forwardStructs[ structInst->name ].push_back( structInst ); 427 427 } // if 428 428 checkGenericParameters( structInst ); … … 430 430 431 431 void LinkReferenceToTypes::postvisit( UnionInstType *unionInst ) { 432 UnionDecl *un = local_indexer->lookupUnion( unionInst-> get_name());432 UnionDecl *un = local_indexer->lookupUnion( unionInst->name ); 433 433 // it's not a semantic error if the union is not found, just an implicit forward declaration 434 434 if ( un ) { 435 unionInst-> set_baseUnion( un );436 } // if 437 if ( ! un || un-> get_members().empty() ) {435 unionInst->baseUnion = un; 436 } // if 437 if ( ! un || un->members.empty() ) { 438 438 // use of forward declaration 439 forwardUnions[ unionInst-> get_name()].push_back( unionInst );439 forwardUnions[ unionInst->name ].push_back( unionInst ); 440 440 } // if 441 441 checkGenericParameters( unionInst ); … … 450 450 DeclarationWithType * dwt2 = dynamic_cast<DeclarationWithType *>( d2 ); 451 451 if ( dwt1 && dwt2 ) { 452 if ( dwt1-> get_name() == dwt2->get_name()&& ResolvExpr::typesCompatible( dwt1->get_type(), dwt2->get_type(), SymTab::Indexer() ) ) {452 if ( dwt1->name == dwt2->name && ResolvExpr::typesCompatible( dwt1->get_type(), dwt2->get_type(), SymTab::Indexer() ) ) { 453 453 // std::cerr << "=========== equal:" << std::endl; 454 454 // std::cerr << "d1: " << d1 << std::endl; … … 475 475 template< typename Iterator > 476 476 void expandAssertions( TraitInstType * inst, Iterator out ) { 477 assertf( inst->baseTrait, "Trait instance not linked to base trait: %s", to String( inst ).c_str() );477 assertf( inst->baseTrait, "Trait instance not linked to base trait: %s", toCString( inst ) ); 478 478 std::list< DeclarationWithType * > asserts; 479 479 for ( Declaration * decl : inst->baseTrait->members ) { … … 518 518 519 519 // need to carry over the 'sized' status of each decl in the instance 520 for ( auto p : group_iterate( traitDecl-> get_parameters(), traitInst->get_parameters()) ) {520 for ( auto p : group_iterate( traitDecl->parameters, traitInst->parameters ) ) { 521 521 TypeExpr * expr = dynamic_cast< TypeExpr * >( std::get<1>(p) ); 522 522 if ( ! expr ) { … … 525 525 if ( TypeInstType * inst = dynamic_cast< TypeInstType * >( expr->get_type() ) ) { 526 526 TypeDecl * formalDecl = std::get<0>(p); 527 TypeDecl * instDecl = inst-> get_baseType();527 TypeDecl * instDecl = inst->baseType; 528 528 if ( formalDecl->get_sized() ) instDecl->set_sized( true ); 529 529 } … … 534 534 void LinkReferenceToTypes::postvisit( EnumDecl *enumDecl ) { 535 535 // visit enum members first so that the types of self-referencing members are updated properly 536 if ( ! enumDecl-> get_members().empty() ) {537 ForwardEnumsType::iterator fwds = forwardEnums.find( enumDecl-> get_name());536 if ( ! enumDecl->members.empty() ) { 537 ForwardEnumsType::iterator fwds = forwardEnums.find( enumDecl->name ); 538 538 if ( fwds != forwardEnums.end() ) { 539 539 for ( std::list< EnumInstType * >::iterator inst = fwds->second.begin(); inst != fwds->second.end(); ++inst ) { 540 (*inst )->set_baseEnum( enumDecl );540 (*inst)->baseEnum = enumDecl; 541 541 } // for 542 542 forwardEnums.erase( fwds ); … … 574 574 // visit struct members first so that the types of self-referencing members are updated properly 575 575 // xxx - need to ensure that type parameters match up between forward declarations and definition (most importantly, number of type parameters and their defaults) 576 if ( ! structDecl-> get_members().empty() ) {577 ForwardStructsType::iterator fwds = forwardStructs.find( structDecl-> get_name());576 if ( ! structDecl->members.empty() ) { 577 ForwardStructsType::iterator fwds = forwardStructs.find( structDecl->name ); 578 578 if ( fwds != forwardStructs.end() ) { 579 579 for ( std::list< StructInstType * >::iterator inst = fwds->second.begin(); inst != fwds->second.end(); ++inst ) { 580 (*inst )->set_baseStruct( structDecl );580 (*inst)->baseStruct = structDecl; 581 581 } // for 582 582 forwardStructs.erase( fwds ); … … 586 586 587 587 void LinkReferenceToTypes::postvisit( UnionDecl *unionDecl ) { 588 if ( ! unionDecl-> get_members().empty() ) {589 ForwardUnionsType::iterator fwds = forwardUnions.find( unionDecl-> get_name());588 if ( ! unionDecl->members.empty() ) { 589 ForwardUnionsType::iterator fwds = forwardUnions.find( unionDecl->name ); 590 590 if ( fwds != forwardUnions.end() ) { 591 591 for ( std::list< UnionInstType * >::iterator inst = fwds->second.begin(); inst != fwds->second.end(); ++inst ) { 592 (*inst )->set_baseUnion( unionDecl );592 (*inst)->baseUnion = unionDecl; 593 593 } // for 594 594 forwardUnions.erase( fwds ); … … 600 600 // ensure generic parameter instances are renamed like the base type 601 601 if ( inGeneric && typeInst->baseType ) typeInst->name = typeInst->baseType->name; 602 if ( NamedTypeDecl *namedTypeDecl = local_indexer->lookupType( typeInst-> get_name()) ) {602 if ( NamedTypeDecl *namedTypeDecl = local_indexer->lookupType( typeInst->name ) ) { 603 603 if ( TypeDecl *typeDecl = dynamic_cast< TypeDecl * >( namedTypeDecl ) ) { 604 604 typeInst->set_isFtype( typeDecl->get_kind() == TypeDecl::Ftype );
Note: See TracChangeset
for help on using the changeset viewer.