Changes in src/SynTree/VarExprReplacer.cc [ea6332d:7543dec]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/VarExprReplacer.cc
rea6332d r7543dec 22 22 VarExprReplacer::VarExprReplacer( const DeclMap & declMap, bool debug ) : declMap( declMap ), debug( debug ) {} 23 23 24 // replace variable with new node from decl map 25 void VarExprReplacer::visit( VariableExpr * varExpr ) { 26 // xxx - assertions and parameters aren't accounted for in this... (i.e. they aren't inserted into the map when it's made, only DeclStmts are) 27 if ( declMap.count( varExpr->get_var() ) ) { 28 if ( debug ) { 29 std::cerr << "replacing variable reference: " << (void*)varExpr->get_var() << " " << varExpr->get_var() << " with " << (void*)declMap.at( varExpr->get_var() ) << " " << declMap.at( varExpr->get_var() ) << std::endl; 30 } 31 varExpr->set_var( declMap.at( varExpr->get_var() ) ); 24 VarExprReplacer::~VarExprReplacer() { 25 for ( auto p : declMap ) { 26 delete p.second; 32 27 } 33 28 } 29 30 // replace variable with new node from decl map 31 Expression * VarExprReplacer::mutate( VariableExpr * varExpr ) { 32 // xxx - assertions and parameters aren't accounted for in this... (i.e. they aren't inserted into the map when it's made, only DeclStmts are) 33 if ( declMap.count( varExpr->var ) ) { 34 Expression * expr = declMap.at( varExpr->var ); 35 if ( debug ) { 36 std::cerr << "replacing variable reference: " << (void*)varExpr->var << " " << varExpr->var << " with " << (void*)expr << " " << expr << std::endl; 37 } 38 delete varExpr; 39 return expr->clone(); 40 } 41 return varExpr; 42 }
Note: See TracChangeset
for help on using the changeset viewer.