Changeset fea7ca7


Ignore:
Timestamp:
Apr 29, 2016, 12:26:50 PM (8 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
d8ba086
Parents:
a0fdbd5
Message:

Account for lvalue returning functions in FixCopyCtor?, removed ConditionalExpr?, CommaExpr?, Logical Expr mutates from Specialize, added before box debug flag

Location:
src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/GenPoly/Box.cc

    ra0fdbd5 rfea7ca7  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Rob Schluntz
    12 // Last Modified On : Mon Apr 18 13:22:15 2016
     12// Last Modified On : Fri Apr 29 12:16:11 2016
    1313// Update Count     : 295
    1414//
     
    911911                                } else if ( arg->get_results().front()->get_isLvalue() ) {
    912912                                        // VariableExpr and MemberExpr are lvalues; need to check this isn't coming from the second arg of a comma expression though (not an lvalue)
     913                                        // xxx - need to test that this code is still reachable
    913914                                        if ( CommaExpr *commaArg = dynamic_cast< CommaExpr* >( arg ) ) {
    914915                                                commaArg->set_arg2( new AddressExpr( commaArg->get_arg2() ) );
     
    13461347                                } // if
    13471348                        } // if
     1349                        // isPolyType check needs to happen before mutating addrExpr arg, so pull it forward
     1350                        // out of the if condition.
     1351                        bool polytype = isPolyType( addrExpr->get_arg()->get_results().front(), scopeTyVars, env );
    13481352                        addrExpr->set_arg( mutateExpression( addrExpr->get_arg() ) );
    1349                         if ( isPolyType( addrExpr->get_arg()->get_results().front(), scopeTyVars, env ) || needs ) {
     1353                        if ( polytype || needs ) {
    13501354                                Expression *ret = addrExpr->get_arg();
    13511355                                delete ret->get_results().front();
  • src/GenPoly/Specialize.cc

    ra0fdbd5 rfea7ca7  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Rob Schluntz
    12 // Last Modified On : Wed Jan 20 13:00:00 2016
     12// Last Modified On : Thu Apr 28 15:17:45 2016
    1313// Update Count     : 24
    1414//
     
    4141                virtual Expression * mutate( AddressExpr *castExpr );
    4242                virtual Expression * mutate( CastExpr *castExpr );
    43                 virtual Expression * mutate( LogicalExpr *logicalExpr );
    44                 virtual Expression * mutate( ConditionalExpr *conditionalExpr );
    45                 virtual Expression * mutate( CommaExpr *commaExpr );
     43                // virtual Expression * mutate( LogicalExpr *logicalExpr );
     44                // virtual Expression * mutate( ConditionalExpr *conditionalExpr );
     45                // virtual Expression * mutate( CommaExpr *commaExpr );
    4646
    4747          private:
     
    212212        }
    213213
    214         Expression * Specialize::mutate( LogicalExpr *logicalExpr ) {
    215                 return logicalExpr;
    216         }
    217 
    218         Expression * Specialize::mutate( ConditionalExpr *condExpr ) {
    219                 return condExpr;
    220         }
    221 
    222         Expression * Specialize::mutate( CommaExpr *commaExpr ) {
    223                 return commaExpr;
    224         }
     214        // Removing these for now. Richard put these in for some reason, but it's not clear why.
     215        // In particular, copy constructors produce a comma expression, and with this code the parts
     216        // of that comma expression are not specialized, which causes problems.
     217
     218        // Expression * Specialize::mutate( LogicalExpr *logicalExpr ) {
     219        //      return logicalExpr;
     220        // }
     221
     222        // Expression * Specialize::mutate( ConditionalExpr *condExpr ) {
     223        //      return condExpr;
     224        // }
     225
     226        // Expression * Specialize::mutate( CommaExpr *commaExpr ) {
     227        //      return commaExpr;
     228        // }
    225229} // namespace GenPoly
    226230
  • src/InitTweak/FixInit.cc

    ra0fdbd5 rfea7ca7  
    1010// Created On       : Wed Jan 13 16:29:30 2016
    1111// Last Modified By : Rob Schluntz
    12 // Last Modified On : Thu Apr 28 12:25:14 2016
     12// Last Modified On : Fri Apr 29 12:25:40 2016
    1313// Update Count     : 30
    1414//
     
    231231                callExpr->set_env( impCpCtorExpr->get_env()->clone() );
    232232                for ( Type * result : appExpr->get_results() ) {
    233                         ObjectDecl * ret = new ObjectDecl( retNamer.newName(), DeclarationNode::NoStorageClass, LinkageSpec::C, 0, result->clone(), 0 );
     233                        result = result->clone();
     234                        impCpCtorExpr->get_env()->apply( result );
     235                        ObjectDecl * ret = new ObjectDecl( retNamer.newName(), DeclarationNode::NoStorageClass, LinkageSpec::C, 0, result, 0 );
    234236                        ret->get_type()->set_isConst( false );
    235237                        impCpCtorExpr->get_returnDecls().push_back( ret );
     
    285287                        // add that onto the assignment expression so that later steps have the necessary information
    286288                        assign->add_result( returnDecl->get_type()->clone() );
    287                         // return new CommaExpr( assign, new VariableExpr( returnDecl ) );
    288                         return assign;
     289
     290                        Expression * retExpr = new CommaExpr( assign, new VariableExpr( returnDecl ) );
     291                        if ( callExpr->get_results().front()->get_isLvalue() ) {
     292                                // lvalue returning functions are funny. Lvalue.cc inserts a *? in front of any
     293                                // lvalue returning non-intrinsic function. Add an AddressExpr to the call to negate
     294                                // the derefence and change the type of the return temporary from T to T* to properly
     295                                // capture the return value. Then dereference the result of the comma expression, since
     296                                // the lvalue returning call was originally wrapped with an AddressExpr.
     297                                // Effectively, this turns
     298                                //   lvalue T f();
     299                                //   &*f()
     300                                // into
     301                                //   T * tmp_cp_retN;
     302                                //   tmp_cp_ret_N = &*(tmp_cp_ret_N = &*f(), tmp_cp_ret);
     303                                // which work out in terms of types, but is pretty messy. It would be nice to find a better way.
     304                                assign->get_args().back() = new AddressExpr( assign->get_args().back() );
     305
     306                                Type * resultType = returnDecl->get_type()->clone();
     307                                returnDecl->set_type( new PointerType( Type::Qualifiers(), returnDecl->get_type() ) );
     308                                UntypedExpr * deref = new UntypedExpr( new NameExpr( "*?" ) );
     309                                deref->get_args().push_back( retExpr );
     310                                deref->add_result( resultType );
     311                                retExpr = deref;
     312                        }
     313                        return retExpr;
    289314                } else {
    290315                        return callExpr;
  • src/main.cc

    ra0fdbd5 rfea7ca7  
    1010// Created On       : Fri May 15 23:12:02 2015
    1111// Last Modified By : Rob Schluntz
    12 // Last Modified On : Thu Apr 28 12:24:46 2016
     12// Last Modified On : Fri Apr 29 12:02:21 2016
    1313// Update Count     : 200
    1414//
     
    6161        astp = false,
    6262        bresolvep = false,
     63        bboxp = false,
    6364        ctorinitp = false,
    6465        exprp = false,
     
    7677        codegenp = false;
    7778
    78 enum { Ast, Bresolver, CtorInitFix, Expr, ExprAlt, Grammar, LibCFA, Nopreamble, Parse, Prototypes, Resolver, Symbol, Tree, Validate, };
     79enum { Ast, Bbox, Bresolver, CtorInitFix, Expr, ExprAlt, Grammar, LibCFA, Nopreamble, Parse, Prototypes, Resolver, Symbol, Tree, Validate, };
    7980
    8081static struct option long_opts[] = {
    8182        { "ast", no_argument, 0, Ast },
     83        { "before-box", no_argument, 0, Bbox },
    8284        { "before-resolver", no_argument, 0, Bresolver },
    8385        { "ctorinitfix", no_argument, 0, CtorInitFix },
     
    105107
    106108        int c;
    107         while ( (c = getopt_long( argc, argv, "abcefFglnpqrstvyzD:", long_opts, &long_index )) != -1 ) {
     109        while ( (c = getopt_long( argc, argv, "abBcefFglnpqrstvyzD:", long_opts, &long_index )) != -1 ) {
    108110                switch ( c ) {
    109111                  case Ast:
     
    115117                        bresolvep = true;
    116118                        break;
    117                         case CtorInitFix:
    118                         case 'c':
     119                  case 'B':                                                                             // print before resolver steps
     120                        bboxp = true;
     121                        break;
     122                  case CtorInitFix:
     123                  case 'c':
    119124                        ctorinitp = true;
    120125                        break;
     
    292297                OPTPRINT( "convertLvalue" )
    293298                GenPoly::convertLvalue( translationUnit );
     299
     300                if ( bboxp ) {
     301                        dump( translationUnit );
     302                        return 0;
     303                }
    294304                OPTPRINT( "box" )
    295305                GenPoly::box( translationUnit );
Note: See TracChangeset for help on using the changeset viewer.