Ignore:
Timestamp:
Nov 9, 2016, 2:10:00 PM (6 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
aaron-thesis, arm-eh, 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, resolv-new, with_gc
Children:
141b786
Parents:
b3b2077
git-author:
Rob Schluntz <rschlunt@…> (11/09/16 14:09:29)
git-committer:
Rob Schluntz <rschlunt@…> (11/09/16 14:10:00)
Message:

refactor VarExprReplacer? and reuse it in TupleAssignExpr?

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/TupleExpr.cc

    rb3b2077 r23bb1b9  
    1919#include "Declaration.h"
    2020#include "Tuples/Tuples.h"
     21#include "VarExprReplacer.h"
    2122
    2223TupleExpr::TupleExpr( const std::list< Expression * > & exprs, Expression *_aname ) : Expression( _aname ), exprs( exprs ) {
     
    9192}
    9293
    93 TupleAssignExpr::TupleAssignExpr( const TupleAssignExpr &other ) : Expression( other ), tempDecls( other.tempDecls ) /* temporary */ {
     94TupleAssignExpr::TupleAssignExpr( const TupleAssignExpr &other ) : Expression( other ) {
    9495        cloneAll( other.assigns, assigns );
    95         // xxx - clone needs to go into assigns and replace tempDecls
     96        cloneAll( other.tempDecls, tempDecls );
     97
     98        // clone needs to go into assigns and replace tempDecls
     99        VarExprReplacer::DeclMap declMap;
     100        std::list< ObjectDecl * >::const_iterator origit = other.tempDecls.begin();
     101        for ( ObjectDecl * temp : tempDecls ) {
     102                assert( origit != other.tempDecls.end() );
     103                ObjectDecl * origTemp = *origit++;
     104                assert( origTemp );
     105                assert( temp->get_name() == origTemp->get_name() );
     106                declMap[ origTemp ] = temp;
     107        }
     108        if ( ! declMap.empty() ) {
     109                VarExprReplacer replacer( declMap );
     110                for ( Expression * assn : assigns ) {
     111                        assn->accept( replacer );
     112                }
     113        }
    96114}
    97115
Note: See TracChangeset for help on using the changeset viewer.