Changeset 271a5d3 for src


Ignore:
Timestamp:
Nov 9, 2022, 12:30:24 PM (18 months ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
ADT, ast-experimental, master
Children:
5ce0659
Parents:
6411b7d
Message:

Cleaning old box pass for easier translation. Cleaned up more loops, particularly with the improved group_iterate.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/GenPoly/Box.cc

    r6411b7d r271a5d3  
    582582                        assert( funcType );
    583583
     584                        // These iterators don't advance in unison.
    584585                        std::list< DeclarationWithType* >::const_iterator fnParm = funcType->get_parameters().begin();
    585586                        std::list< Expression* >::const_iterator fnArg = arg;
     
    855856                        Statement *bodyStmt;
    856857
    857                         Type::ForallList::const_iterator tyArg = realType->forall.begin();
    858                         Type::ForallList::const_iterator tyParam = adapterType->forall.begin();
    859                         Type::ForallList::const_iterator realTyParam = adaptee->forall.begin();
    860                         for ( ; tyParam != adapterType->get_forall().end(); ++tyArg, ++tyParam, ++realTyParam ) {
    861                                 assert( tyArg != realType->get_forall().end() );
    862                                 std::list< DeclarationWithType *>::const_iterator assertArg = (*tyArg)->get_assertions().begin();
    863                                 std::list< DeclarationWithType *>::const_iterator assertParam = (*tyParam)->get_assertions().begin();
    864                                 std::list< DeclarationWithType *>::const_iterator realAssertParam = (*realTyParam)->get_assertions().begin();
    865                                 for ( ; assertParam != (*tyParam)->get_assertions().end(); ++assertArg, ++assertParam, ++realAssertParam ) {
    866                                         assert( assertArg != (*tyArg)->get_assertions().end() );
    867                                         adapteeApp->get_args().push_back( makeAdapterArg( *assertParam, *assertArg, *realAssertParam, tyVars ) );
     858                        for ( auto tys : group_iterate( realType->forall, adapterType->forall, adaptee->forall ) ) {
     859                                TypeDecl * tyArg = std::get<0>( tys );
     860                                TypeDecl * tyParam = std::get<1>( tys );
     861                                TypeDecl * realTyParam = std::get<2>( tys );
     862                                for ( auto asserts : group_iterate( tyArg->assertions, tyParam->assertions, realTyParam->assertions ) ) {
     863                                        DeclarationWithType * assertArg = std::get<0>( asserts );
     864                                        DeclarationWithType * assertParam = std::get<1>( asserts );
     865                                        DeclarationWithType * realAssertParam = std::get<2>( asserts );
     866                                        adapteeApp->args.push_back( makeAdapterArg( assertParam, assertArg, realAssertParam, tyVars ) );
    868867                                } // for
    869868                        } // for
     
    10931092                Expression *Pass1::postmutate( ApplicationExpr *appExpr ) {
    10941093                        // std::cerr << "mutate appExpr: " << InitTweak::getFunctionName( appExpr ) << std::endl;
    1095                         // for ( TyVarMap::iterator i = scopeTyVars.begin(); i != scopeTyVars.end(); ++i ) {
    1096                         //      std::cerr << i->first << " ";
     1094                        // for ( auto tyVar : scopeTyVars ) {
     1095                        //      std::cerr << tyVar.first << " ";
    10971096                        // }
    10981097                        // std::cerr << "\n";
     
    16831682                        bool hasDynamicLayout = false;
    16841683
    1685                         std::list< TypeDecl* >::const_iterator baseParam = baseParams.begin();
    1686                         std::list< Expression* >::const_iterator typeParam = typeParams.begin();
    1687                         for ( ; baseParam != baseParams.end() && typeParam != typeParams.end(); ++baseParam, ++typeParam ) {
     1684                        for ( auto paramPair : group_iterate( baseParams, typeParams ) ) {
     1685                                TypeDecl * baseParam = std::get<0>( paramPair );
     1686                                Expression * typeParam = std::get<1>( paramPair );
    16881687                                // skip non-otype parameters
    1689                                 if ( ! (*baseParam)->isComplete() ) continue;
    1690                                 TypeExpr *typeExpr = dynamic_cast< TypeExpr* >( *typeParam );
     1688                                if ( ! baseParam->isComplete() ) continue;
     1689                                TypeExpr *typeExpr = dynamic_cast< TypeExpr* >( typeParam );
    16911690                                assert( typeExpr && "all otype parameters should be type expressions" );
    16921691
     
    16951694                                if ( isPolyType( type ) ) hasDynamicLayout = true;
    16961695                        }
    1697                         assert( baseParam == baseParams.end() && typeParam == typeParams.end() );
    16981696
    16991697                        return hasDynamicLayout;
     
    18511849                                        // build initializer list for offset array
    18521850                                        std::list< Initializer* > inits;
    1853                                         for ( std::list< Declaration* >::const_iterator member = baseMembers.begin(); member != baseMembers.end(); ++member ) {
    1854                                                 if ( DeclarationWithType *memberDecl = dynamic_cast< DeclarationWithType* >( *member ) ) {
    1855                                                         inits.push_back( new SingleInit( new OffsetofExpr( ty->clone(), memberDecl ) ) );
    1856                                                 } else {
    1857                                                         assertf( false, "Requesting offset of Non-DWT member: %s", toString( *member ).c_str() );
    1858                                                 }
     1851                                        for ( Declaration * const member : baseMembers ) {
     1852                                                DeclarationWithType *memberDecl = dynamic_cast< DeclarationWithType* >( member );
     1853                                                assertf( memberDecl, "Requesting offset of Non-DWT member: %s", toString( member ).c_str() );
     1854                                                inits.push_back( new SingleInit( new OffsetofExpr( ty->clone(), memberDecl ) ) );
    18591855                                        }
    18601856
Note: See TracChangeset for help on using the changeset viewer.