Changeset 4ffdd63


Ignore:
Timestamp:
Apr 27, 2016, 5:16:22 PM (6 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, ctor, deferred_resn, demangler, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, resolv-new, with_gc
Children:
21ae786
Parents:
c2ce2350
Message:

change FixCopyCtors? to insert comma expressions and UntypedExpr? assignments rather than changing the location of the argument. Remove copyCtors list from ImplicitCopyCtorExpr?

Location:
src
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • src/InitTweak/FixInit.cc

    rc2ce2350 r4ffdd63  
    1010// Created On       : Wed Jan 13 16:29:30 2016
    1111// Last Modified By : Rob Schluntz
    12 // Last Modified On : Tue Apr 26 14:57:13 2016
     12// Last Modified On : Wed Apr 27 17:08:44 2016
    1313// Update Count     : 30
    1414//
     
    216216                        if ( function->get_var()->get_linkage() != LinkageSpec::Intrinsic ) {
    217217                                // replace argument to function call with temporary
    218                                 arg = new VariableExpr( tmp );
     218                                arg = new CommaExpr( cpCtor, new VariableExpr( tmp ) );
    219219                                impCpCtorExpr->get_tempDecls().push_back( tmp );
    220                                 impCpCtorExpr->get_copyCtors().push_back( cpCtor );
    221220                                impCpCtorExpr->get_dtors().push_front( makeCtorDtor( "^?{}", tmp ) );
    222221                        }
     
    232231                callExpr->set_env( impCpCtorExpr->get_env()->clone() );
    233232                for ( Type * result : appExpr->get_results() ) {
    234                         ObjectDecl * ret = new ObjectDecl( retNamer.newName(), DeclarationNode::NoStorageClass, LinkageSpec::C, 0, result->clone(), new SingleInit( callExpr ) );
     233                        ObjectDecl * ret = new ObjectDecl( retNamer.newName(), DeclarationNode::NoStorageClass, LinkageSpec::C, 0, result->clone(), 0 );
    235234                        ret->get_type()->set_isConst( false );
    236235                        impCpCtorExpr->get_returnDecls().push_back( ret );
     
    249248                assert( impCpCtorExpr );
    250249
    251                 std::list< Expression * > & copyCtors = impCpCtorExpr->get_copyCtors();
    252250                std::list< ObjectDecl * > & tempDecls = impCpCtorExpr->get_tempDecls();
    253251                std::list< ObjectDecl * > & returnDecls = impCpCtorExpr->get_returnDecls();
     
    256254                // add all temporary declarations and their constructors
    257255                for ( ObjectDecl * obj : tempDecls ) {
    258                         assert( ! copyCtors.empty() );
    259256                        stmtsToAdd.push_back( new DeclStmt( noLabels, obj ) );
    260                         stmtsToAdd.push_back( new ExprStmt( noLabels, copyCtors.front() ) );
    261                         copyCtors.pop_front();
     257                }
     258                for ( ObjectDecl * obj : returnDecls ) {
     259                        stmtsToAdd.push_back( new DeclStmt( noLabels, obj ) );
    262260                }
    263261
     
    274272
    275273                // xxx - some of these aren't necessary, and can be removed once this is stable
    276                 copyCtors.clear();
    277274                dtors.clear();
    278275                tempDecls.clear();
     
    282279
    283280                if ( returnDecl ) {
    284                         // call is currently attached to first returnDecl
    285                         stmtsToAdd.push_back( new DeclStmt( noLabels, returnDecl ) );
    286                         return new VariableExpr( returnDecl );
     281                        UntypedExpr * assign = new UntypedExpr( new NameExpr( "?=?" ) );
     282                        assign->get_args().push_back( new VariableExpr( returnDecl ) );
     283                        assign->get_args().push_back( callExpr );
     284                        // know the result type of the assignment is the type of the LHS (minus the pointer), so
     285                        // add that onto the assignment expression so that later steps have the necessary information
     286                        assign->add_result( returnDecl->get_type()->clone() );
     287                        // return new CommaExpr( assign, new VariableExpr( returnDecl ) );
     288                        return assign;
    287289                } else {
    288                         // add call expression - if no return values, can call directly
    289                         assert( callExpr );
    290290                        return callExpr;
    291291                }
  • src/SynTree/Expression.cc

    rc2ce2350 r4ffdd63  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Rob Schluntz
    12 // Last Modified On : Tue Apr 26 12:58:05 2016
     12// Last Modified On : Wed Apr 27 17:07:19 2016
    1313// Update Count     : 40
    1414//
     
    473473
    474474ImplicitCopyCtorExpr::ImplicitCopyCtorExpr( const ImplicitCopyCtorExpr & other ) : Expression( other ), callExpr( maybeClone( other.callExpr ) ) {
    475         cloneAll( other.copyCtors, copyCtors );
    476475        cloneAll( other.tempDecls, tempDecls );
    477476        cloneAll( other.returnDecls, returnDecls );
     
    481480ImplicitCopyCtorExpr::~ImplicitCopyCtorExpr() {
    482481        delete callExpr;
    483         deleteAll( copyCtors );
    484482        deleteAll( tempDecls );
    485483        deleteAll( returnDecls );
     
    493491        os << std::endl << std::string( indent, ' ' ) << "with temporaries:" << std::endl;
    494492        printAll(tempDecls, os, indent+2);
    495         os << std::endl << std::string( indent, ' ' ) << "with copyCtors:" << std::endl;
    496         printAll(copyCtors, os, indent+2);
    497493        os << std::endl << std::string( indent, ' ' ) << "with return temporaries:" << std::endl;
    498494        printAll(returnDecls, os, indent+2);
  • src/SynTree/Expression.h

    rc2ce2350 r4ffdd63  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Rob Schluntz
    12 // Last Modified On : Thu Apr 14 15:40:56 2016
     12// Last Modified On : Wed Apr 27 17:06:49 2016
    1313// Update Count     : 21
    1414//
     
    571571        void set_callExpr( ApplicationExpr *newValue ) { callExpr = newValue; }
    572572
    573         std::list< Expression * > & get_copyCtors() { return copyCtors; }
    574         void set_copyCtors( std::list< Expression * > newValue ) { copyCtors = newValue; }
    575 
    576573        std::list< ObjectDecl * > & get_tempDecls() { return tempDecls; }
    577574        void set_tempDecls( std::list< ObjectDecl * > newValue ) { tempDecls = newValue; }
     
    589586  private:
    590587        ApplicationExpr * callExpr;
    591         std::list< Expression * > copyCtors;
    592588        std::list< ObjectDecl * > tempDecls;
    593589        std::list< ObjectDecl * > returnDecls;
  • src/SynTree/Mutator.cc

    rc2ce2350 r4ffdd63  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Rob Schluntz
    12 // Last Modified On : Mon Apr 18 17:29:55 2016
     12// Last Modified On : Wed Apr 27 17:07:29 2016
    1313// Update Count     : 16
    1414//
     
    339339Expression* Mutator::mutate( ImplicitCopyCtorExpr *impCpCtorExpr ) {
    340340        impCpCtorExpr->set_callExpr( maybeMutate( impCpCtorExpr->get_callExpr(), *this ) );
    341         mutateAll( impCpCtorExpr->get_copyCtors(), *this );
    342341        mutateAll( impCpCtorExpr->get_tempDecls(), *this );
    343342        mutateAll( impCpCtorExpr->get_returnDecls(), *this );
  • src/SynTree/Visitor.cc

    rc2ce2350 r4ffdd63  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Rob Schluntz
    12 // Last Modified On : Mon Apr 18 17:30:10 2016
     12// Last Modified On : Wed Apr 27 17:07:40 2016
    1313// Update Count     : 18
    1414//
     
    286286void Visitor::visit( ImplicitCopyCtorExpr *impCpCtorExpr ) {
    287287        maybeAccept( impCpCtorExpr->get_callExpr(), *this );
    288         acceptAll( impCpCtorExpr->get_copyCtors(), *this );
    289288        acceptAll( impCpCtorExpr->get_tempDecls(), *this );
    290289        acceptAll( impCpCtorExpr->get_returnDecls(), *this );
Note: See TracChangeset for help on using the changeset viewer.