Changes in src/GenPoly/Box.cpp [23a0e576:be4335b]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/GenPoly/Box.cpp
r23a0e576 rbe4335b 366 366 367 367 /// Passes extra layout arguments for sized polymorphic type parameters. 368 voidpassTypeVars(368 ast::vector<ast::Expr>::iterator passTypeVars( 369 369 ast::ApplicationExpr * expr, 370 ast::vector<ast::Expr> & extraArgs,371 370 ast::FunctionType const * funcType ); 372 371 /// Wraps a function application with a new temporary for the … … 388 387 /// parameter list. arg should point into expr's argument list. 389 388 void boxParams( 390 ast::ApplicationExpr * expr,391 ast:: Type const * polyRetType,389 ast::ApplicationExpr const * expr, 390 ast::vector<ast::Expr>::iterator arg, 392 391 ast::FunctionType const * function, 393 392 const TypeVarMap & typeVars ); … … 396 395 void addInferredParams( 397 396 ast::ApplicationExpr * expr, 398 ast::vector<ast::Expr> & extraArgs,397 ast::vector<ast::Expr>::iterator arg, 399 398 ast::FunctionType const * functionType, 400 399 const TypeVarMap & typeVars ); … … 637 636 ast::Expr const * ret = expr; 638 637 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 639 642 TypeVarMap exprTypeVars; 640 643 makeTypeVarMap( function, exprTypeVars ); … … 659 662 } 660 663 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 ); 667 673 passAdapters( mutExpr, function, exprTypeVars ); 668 674 … … 760 766 } 761 767 762 voidCallAdapter::passTypeVars(768 ast::vector<ast::Expr>::iterator CallAdapter::passTypeVars( 763 769 ast::ApplicationExpr * expr, 764 ast::vector<ast::Expr> & extraArgs,765 770 ast::FunctionType const * function ) { 766 771 assert( typeSubs ); 772 ast::vector<ast::Expr>::iterator arg = expr->args.begin(); 767 773 // Pass size/align for type variables. 768 774 for ( ast::ptr<ast::TypeInstType> const & typeVar : function->forall ) { … … 774 780 toString( typeSubs ).c_str(), typeVar->typeString().c_str() ); 775 781 } 776 extraArgs.emplace_back(782 arg = expr->args.insert( arg, 777 783 new ast::SizeofExpr( expr->location, ast::deepCopy( concrete ) ) ); 778 extraArgs.emplace_back( 784 arg++; 785 arg = expr->args.insert( arg, 779 786 new ast::AlignofExpr( expr->location, ast::deepCopy( concrete ) ) ); 780 } 787 arg++; 788 } 789 return arg; 781 790 } 782 791 … … 904 913 905 914 void CallAdapter::boxParams( 906 ast::ApplicationExpr * expr,907 ast:: Type const * polyRetType,915 ast::ApplicationExpr const * expr, 916 ast::vector<ast::Expr>::iterator arg, 908 917 ast::FunctionType const * function, 909 918 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 914 919 for ( auto param : function->params ) { 915 920 assertf( arg != expr->args.end(), … … 923 928 void CallAdapter::addInferredParams( 924 929 ast::ApplicationExpr * expr, 925 ast::vector<ast::Expr> & extraArgs,930 ast::vector<ast::Expr>::iterator arg, 926 931 ast::FunctionType const * functionType, 927 932 TypeVarMap const & typeVars ) { 933 ast::vector<ast::Expr>::iterator cur = arg; 928 934 for ( auto assertion : functionType->assertions ) { 929 935 auto inferParam = expr->inferred.inferParams().find( … … 934 940 ast::ptr<ast::Expr> newExpr = ast::deepCopy( inferParam->second.expr ); 935 941 boxParam( newExpr, assertion->result, typeVars ); 936 extraArgs.emplace_back( newExpr.release() ); 942 cur = expr->args.insert( cur, newExpr.release() ); 943 ++cur; 937 944 } 938 945 }
Note: See TracChangeset
for help on using the changeset viewer.