Changeset fae6f21


Ignore:
Timestamp:
Nov 8, 2017, 3:37:29 PM (6 years ago)
Author:
Aaron Moss <a3moss@…>
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:
78315272
Parents:
76a395a
Message:

Fix bugs in resolver refactor with tuples/varargs

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/AlternativeFinder.cc

    r76a395a rfae6f21  
    632632                        std::vector<ArgPack> finalResults{};  /// list of completed tuples
    633633                        // start tuples
    634                         for ( ArgPack& result : results ) { result.beginTuple(); }
     634                        for ( ArgPack& result : results ) {
     635                                result.beginTuple();
     636
     637                                // use rest of exploded tuple if present
     638                                while ( result.nextExpl < result.expls.size() ) {
     639                                        const Alternative& actual = result.expls[result.nextExpl];
     640                                        result.env.addActual( actual.env, result.openVars );
     641                                        result.withArg( actual.expr );
     642                                        ++result.nextExpl;
     643                                }
     644                        }
    635645                        // iterate until all results completed
    636646                        while ( ! results.empty() ) {
     
    760770                                        // add argument
    761771                                        aResult.withArg( aActual.expr, actual.cost );
    762                                         if ( exploded.size() == 1 ) {
    763                                                 // argument consumed
    764                                                 ++aResult.nextArg;
    765                                         } else {
     772                                        ++aResult.nextArg;
     773                                        if ( exploded.size() > 1 ) {
    766774                                                // other parts of tuple left over
    767775                                                aResult.expls = std::move( exploded );
     
    815823                std::vector<ArgPack> finalResults{};
    816824                if ( funcType->get_isVarArgs() ) {
     825                        for ( ArgPack& result : results ) {
     826                                // use rest of exploded tuple if present
     827                                while ( result.nextExpl < result.expls.size() ) {
     828                                        const Alternative& actual = result.expls[result.nextExpl];
     829                                        result.env.addActual( actual.env, result.openVars );
     830                                        result.withArg( actual.expr );
     831                                        ++result.nextExpl;
     832                                }
     833                        }
     834
    817835                        while ( ! results.empty() ) {
    818836                                // build combinations for all remaining arguments
     
    852870                        // filter out results that don't use all the arguments
    853871                        for ( ArgPack& result : results ) {
    854                                 if ( result.nextArg >= args.size() ) {
     872                                if ( result.nextExpl >= result.expls.size() && result.nextArg >= args.size() ) {
    855873                                        finalResults.push_back( std::move(result) );
    856874                                }
Note: See TracChangeset for help on using the changeset viewer.