Changeset d9fa60a for src/GenPoly/Box.cc
- Timestamp:
- Nov 16, 2016, 4:37:50 PM (7 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, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 186fd86
- Parents:
- 33a7b6d
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/GenPoly/Box.cc
r33a7b6d rd9fa60a 98 98 void passArgTypeVars( ApplicationExpr *appExpr, Type *parmType, Type *argBaseType, std::list< Expression *>::iterator &arg, const TyVarMap &exprTyVars, std::set< std::string > &seenTypes ); 99 99 /// passes extra type parameters into a polymorphic function application 100 void passTypeVars( ApplicationExpr *appExpr, ReferenceToType *polyRetType, std::list< Expression *>::iterator &arg, const TyVarMap &exprTyVars );100 void passTypeVars( ApplicationExpr *appExpr, Type *polyRetType, std::list< Expression *>::iterator &arg, const TyVarMap &exprTyVars ); 101 101 /// wraps a function application with a new temporary for the out-parameter return value 102 102 Expression *addRetParam( ApplicationExpr *appExpr, FunctionType *function, Type *retType, std::list< Expression *>::iterator &arg ); … … 107 107 Type *replaceWithConcrete( ApplicationExpr *appExpr, Type *type, bool doClone = true ); 108 108 /// wraps a function application returning a polymorphic type with a new temporary for the out-parameter return value 109 Expression *addDynRetParam( ApplicationExpr *appExpr, FunctionType *function, ReferenceToType *polyType, std::list< Expression *>::iterator &arg );109 Expression *addDynRetParam( ApplicationExpr *appExpr, FunctionType *function, Type *polyType, std::list< Expression *>::iterator &arg ); 110 110 Expression *applyAdapter( ApplicationExpr *appExpr, FunctionType *function, std::list< Expression *>::iterator &arg, const TyVarMap &exprTyVars ); 111 111 void boxParam( Type *formal, Expression *&arg, const TyVarMap &exprTyVars ); … … 769 769 } 770 770 771 void Pass1::passTypeVars( ApplicationExpr *appExpr, ReferenceToType *polyRetType, std::list< Expression *>::iterator &arg, const TyVarMap &exprTyVars ) {771 void Pass1::passTypeVars( ApplicationExpr *appExpr, Type *polyRetType, std::list< Expression *>::iterator &arg, const TyVarMap &exprTyVars ) { 772 772 // pass size/align for type variables 773 773 for ( TyVarMap::const_iterator tyParm = exprTyVars.begin(); tyParm != exprTyVars.end(); ++tyParm ) { … … 818 818 819 819 Expression *Pass1::addRetParam( ApplicationExpr *appExpr, FunctionType *function, Type *retType, std::list< Expression *>::iterator &arg ) { 820 // ***** Code Removal ***** After introducing a temporary variable for all return expressions, the following code appears superfluous.821 // if ( useRetval ) {822 // assert( retval );823 // arg = appExpr->get_args().insert( arg, new VariableExpr( retval ) );824 // arg++;825 // } else {826 827 820 // Create temporary to hold return value of polymorphic function and produce that temporary as a result 828 821 // using a comma expression. Possibly change comma expression into statement expression "{}" for multiple 829 822 // return values. 823 assert( retType ); 830 824 ObjectDecl *newObj = makeTemporary( retType->clone() ); 831 825 Expression *paramExpr = new VariableExpr( newObj ); … … 843 837 appExpr->set_env( 0 ); 844 838 return commaExpr; 845 // } // if846 // return appExpr;847 839 } 848 840 … … 878 870 } 879 871 880 Expression *Pass1::addDynRetParam( ApplicationExpr *appExpr, FunctionType *function, ReferenceToType *dynType, std::list< Expression *>::iterator &arg ) {872 Expression *Pass1::addDynRetParam( ApplicationExpr *appExpr, FunctionType *function, Type *dynType, std::list< Expression *>::iterator &arg ) { 881 873 assert( env ); 882 874 Type *concrete = replaceWithConcrete( appExpr, dynType ); … … 1288 1280 TyVarMap exprTyVars( (TypeDecl::Kind)-1 ); 1289 1281 makeTyVarMap( function, exprTyVars ); 1290 ReferenceToType *concRetType = dynamic_cast< ReferenceToType* >( appExpr->get_result() ); // xxx - is concRetType a good name?1291 1282 ReferenceToType *dynRetType = isDynRet( function, exprTyVars ); 1283 Type *concRetType = appExpr->get_result();// ?: dynRetType; // xxx - is concRetType a good name? 1292 1284 1293 1285 if ( dynRetType ) { … … 1589 1581 // move polymorphic return type to parameter list 1590 1582 if ( isDynRet( funcType ) ) { 1591 DeclarationWithType *ret = funcType->get_returnVals().front();1583 ObjectDecl *ret = safe_dynamic_cast< ObjectDecl* >( funcType->get_returnVals().front() ); 1592 1584 ret->set_type( new PointerType( Type::Qualifiers(), ret->get_type() ) ); 1593 1585 funcType->get_parameters().push_front( ret ); 1594 1586 funcType->get_returnVals().pop_front(); 1587 ret->set_init( nullptr ); // xxx - memory leak? 1595 1588 } 1596 1589
Note: See TracChangeset
for help on using the changeset viewer.