Changeset d9fa60a for src/GenPoly/Box.cc


Ignore:
Timestamp:
Nov 16, 2016, 4:37:50 PM (7 years ago)
Author:
Rob Schluntz <rschlunt@…>
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
Message:

moved substituion into MemberExpr? constructor, change generated tuple structs to generic structs, tuples containing type variables almost works

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/GenPoly/Box.cc

    r33a7b6d rd9fa60a  
    9898                        void passArgTypeVars( ApplicationExpr *appExpr, Type *parmType, Type *argBaseType, std::list< Expression *>::iterator &arg, const TyVarMap &exprTyVars, std::set< std::string > &seenTypes );
    9999                        /// 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 );
    101101                        /// wraps a function application with a new temporary for the out-parameter return value
    102102                        Expression *addRetParam( ApplicationExpr *appExpr, FunctionType *function, Type *retType, std::list< Expression *>::iterator &arg );
     
    107107                        Type *replaceWithConcrete( ApplicationExpr *appExpr, Type *type, bool doClone = true );
    108108                        /// 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 );
    110110                        Expression *applyAdapter( ApplicationExpr *appExpr, FunctionType *function, std::list< Expression *>::iterator &arg, const TyVarMap &exprTyVars );
    111111                        void boxParam( Type *formal, Expression *&arg, const TyVarMap &exprTyVars );
     
    769769                }
    770770
    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 ) {
    772772                        // pass size/align for type variables
    773773                        for ( TyVarMap::const_iterator tyParm = exprTyVars.begin(); tyParm != exprTyVars.end(); ++tyParm ) {
     
    818818
    819819                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 
    827820                        // Create temporary to hold return value of polymorphic function and produce that temporary as a result
    828821                        // using a comma expression.  Possibly change comma expression into statement expression "{}" for multiple
    829822                        // return values.
     823                        assert( retType );
    830824                        ObjectDecl *newObj = makeTemporary( retType->clone() );
    831825                        Expression *paramExpr = new VariableExpr( newObj );
     
    843837                        appExpr->set_env( 0 );
    844838                        return commaExpr;
    845                         // } // if
    846                         // return appExpr;
    847839                }
    848840
     
    878870                }
    879871
    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 ) {
    881873                        assert( env );
    882874                        Type *concrete = replaceWithConcrete( appExpr, dynType );
     
    12881280                        TyVarMap exprTyVars( (TypeDecl::Kind)-1 );
    12891281                        makeTyVarMap( function, exprTyVars );
    1290                         ReferenceToType *concRetType = dynamic_cast< ReferenceToType* >( appExpr->get_result() ); // xxx - is concRetType a good name?
    12911282                        ReferenceToType *dynRetType = isDynRet( function, exprTyVars );
     1283                        Type *concRetType = appExpr->get_result();// ?: dynRetType; // xxx - is concRetType a good name?
    12921284
    12931285                        if ( dynRetType ) {
     
    15891581                        // move polymorphic return type to parameter list
    15901582                        if ( isDynRet( funcType ) ) {
    1591                                 DeclarationWithType *ret = funcType->get_returnVals().front();
     1583                                ObjectDecl *ret = safe_dynamic_cast< ObjectDecl* >( funcType->get_returnVals().front() );
    15921584                                ret->set_type( new PointerType( Type::Qualifiers(), ret->get_type() ) );
    15931585                                funcType->get_parameters().push_front( ret );
    15941586                                funcType->get_returnVals().pop_front();
     1587                                ret->set_init( nullptr ); // xxx - memory leak?
    15951588                        }
    15961589
Note: See TracChangeset for help on using the changeset viewer.