Changes in src/ResolvExpr/RenameVars.cc [c6b4432:f76dd1a]
- File:
-
- 1 edited
-
src/ResolvExpr/RenameVars.cc (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/RenameVars.cc
rc6b4432 rf76dd1a 21 21 #include "AST/Pass.hpp" 22 22 #include "AST/Type.hpp" 23 #include "Common/PassVisitor.h" 23 24 #include "Common/ScopedMap.h" 24 25 #include "Common/SemanticError.h" // for SemanticError 25 26 #include "RenameVars.h" 27 #include "SynTree/Declaration.h" // for DeclarationWithType, TypeDecl, Dec... 28 #include "SynTree/Expression.h" // for Expression 29 #include "SynTree/Type.h" // for Type, TypeInstType, TraitInstType 30 #include "SynTree/Visitor.h" // for acceptAll, maybeAccept 26 31 27 32 #include "AST/Copy.hpp" … … 44 49 } 45 50 51 void rename( TypeInstType * type ) { 52 auto it = nameMap.find( type->name ); 53 if ( it != nameMap.end() ) { 54 type->name = it->second; 55 } 56 } 57 46 58 void nextUsage() { 47 59 ++next_usage_id; 60 } 61 62 void openLevel( Type * type ) { 63 if ( ! type->forall.empty() ) { 64 nameMap.beginScope(); 65 // renames all "forall" type names to `_${level}_${name}' 66 for ( auto td : type->forall ) { 67 std::ostringstream output; 68 output << "_" << resetCount << "_" << level << "_" << td->name; 69 std::string newname( output.str() ); 70 nameMap[ td->get_name() ] = newname; 71 td->name = newname; 72 // ditto for assertion names, the next level in 73 level++; 74 } 75 } 76 } 77 78 void closeLevel( Type * type ) { 79 if ( !type->forall.empty() ) { 80 nameMap.endScope(); 81 } 48 82 } 49 83 … … 101 135 RenamingData renaming; 102 136 137 struct RenameVars_old { 138 void previsit( TypeInstType * instType ) { 139 renaming.openLevel( (Type*)instType ); 140 renaming.rename( instType ); 141 } 142 void previsit( Type * type ) { 143 renaming.openLevel( type ); 144 } 145 void postvisit( Type * type ) { 146 renaming.closeLevel( type ); 147 } 148 }; 149 103 150 struct RenameVars_new : public ast::PureVisitor /*: public ast::WithForallSubstitutor*/ { 104 151 RenameMode mode; … … 130 177 131 178 } // namespace 179 180 void renameTyVars( Type * t ) { 181 PassVisitor<RenameVars_old> renamer; 182 t->accept( renamer ); 183 } 132 184 133 185 const ast::Type * renameTyVars( const ast::Type * t, RenameMode mode, bool reset ) {
Note:
See TracChangeset
for help on using the changeset viewer.