Changes in / [a22d148:d63746f]


Ignore:
Location:
src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/GenPoly/Box.cpp

    ra22d148 rd63746f  
    366366
    367367        /// Passes extra layout arguments for sized polymorphic type parameters.
    368         void passTypeVars(
     368        ast::vector<ast::Expr>::iterator passTypeVars(
    369369                ast::ApplicationExpr * expr,
    370                 ast::vector<ast::Expr> & extraArgs,
    371370                ast::FunctionType const * funcType );
    372371        /// Wraps a function application with a new temporary for the
     
    388387        /// parameter list. arg should point into expr's argument list.
    389388        void boxParams(
    390                 ast::ApplicationExpr * expr,
    391                 ast::Type const * polyRetType,
     389                ast::ApplicationExpr const * expr,
     390                ast::vector<ast::Expr>::iterator arg,
    392391                ast::FunctionType const * function,
    393392                const TypeVarMap & typeVars );
     
    396395        void addInferredParams(
    397396                ast::ApplicationExpr * expr,
    398                 ast::vector<ast::Expr> & extraArgs,
     397                ast::vector<ast::Expr>::iterator arg,
    399398                ast::FunctionType const * functionType,
    400399                const TypeVarMap & typeVars );
     
    637636        ast::Expr const * ret = expr;
    638637
     638        // TODO: This entire section should probably be refactored to do less
     639        // pushing to the front/middle of a vector.
     640        ptrdiff_t initArgCount = mutExpr->args.size();
     641
    639642        TypeVarMap exprTypeVars;
    640643        makeTypeVarMap( function, exprTypeVars );
     
    659662        }
    660663
    661         ast::vector<ast::Expr> prependArgs;
    662         passTypeVars( mutExpr, prependArgs, function );
    663         addInferredParams( mutExpr, prependArgs, function, exprTypeVars );
    664 
    665         boxParams( mutExpr, dynRetType, function, exprTypeVars );
    666         spliceBegin( mutExpr->args, prependArgs );
     664        assert( typeSubs );
     665        ast::vector<ast::Expr>::iterator argIt =
     666                passTypeVars( mutExpr, function );
     667        addInferredParams( mutExpr, argIt, function, exprTypeVars );
     668
     669        argIt = mutExpr->args.begin();
     670        std::advance( argIt, ( mutExpr->args.size() - initArgCount ) );
     671
     672        boxParams( mutExpr, argIt, function, exprTypeVars );
    667673        passAdapters( mutExpr, function, exprTypeVars );
    668674
     
    760766}
    761767
    762 void CallAdapter::passTypeVars(
     768ast::vector<ast::Expr>::iterator CallAdapter::passTypeVars(
    763769                ast::ApplicationExpr * expr,
    764                 ast::vector<ast::Expr> & extraArgs,
    765770                ast::FunctionType const * function ) {
    766771        assert( typeSubs );
     772        ast::vector<ast::Expr>::iterator arg = expr->args.begin();
    767773        // Pass size/align for type variables.
    768774        for ( ast::ptr<ast::TypeInstType> const & typeVar : function->forall ) {
     
    774780                                                   toString( typeSubs ).c_str(), typeVar->typeString().c_str() );
    775781                }
    776                 extraArgs.emplace_back(
     782                arg = expr->args.insert( arg,
    777783                        new ast::SizeofExpr( expr->location, ast::deepCopy( concrete ) ) );
    778                 extraArgs.emplace_back(
     784                arg++;
     785                arg = expr->args.insert( arg,
    779786                        new ast::AlignofExpr( expr->location, ast::deepCopy( concrete ) ) );
    780         }
     787                arg++;
     788        }
     789        return arg;
    781790}
    782791
     
    904913
    905914void CallAdapter::boxParams(
    906                 ast::ApplicationExpr * expr,
    907                 ast::Type const * polyRetType,
     915                ast::ApplicationExpr const * expr,
     916                ast::vector<ast::Expr>::iterator arg,
    908917                ast::FunctionType const * function,
    909918                const TypeVarMap & typeVars ) {
    910         // Start at the beginning, but the return argument may have been added.
    911         auto arg = expr->args.begin();
    912         if ( polyRetType ) ++arg;
    913 
    914919        for ( auto param : function->params ) {
    915920                assertf( arg != expr->args.end(),
     
    923928void CallAdapter::addInferredParams(
    924929                ast::ApplicationExpr * expr,
    925                 ast::vector<ast::Expr> & extraArgs,
     930                ast::vector<ast::Expr>::iterator arg,
    926931                ast::FunctionType const * functionType,
    927932                TypeVarMap const & typeVars ) {
     933        ast::vector<ast::Expr>::iterator cur = arg;
    928934        for ( auto assertion : functionType->assertions ) {
    929935                auto inferParam = expr->inferred.inferParams().find(
     
    934940                ast::ptr<ast::Expr> newExpr = ast::deepCopy( inferParam->second.expr );
    935941                boxParam( newExpr, assertion->result, typeVars );
    936                 extraArgs.emplace_back( newExpr.release() );
     942                cur = expr->args.insert( cur, newExpr.release() );
     943                ++cur;
    937944        }
    938945}
  • src/main.cc

    ra22d148 rd63746f  
    181181
    182182static void _Signal(struct sigaction & act, int sig, int flags ) {
    183         sigemptyset( &act.sa_mask );
    184183        act.sa_flags = flags;
    185184
Note: See TracChangeset for help on using the changeset viewer.