- File:
-
- 1 edited
-
src/Tuples/TupleExpansionNew.cpp (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/Tuples/TupleExpansionNew.cpp
re116db3 rce1d721 10 10 // Created On : Mon Aug 23 15:36:09 2021 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Mon Aug 15 17:00:00 202213 // Update Count : 312 // Last Modified On : Mon Jul 29 14:06:00 2022 13 // Update Count : 2 14 14 // 15 15 … … 100 100 } 101 101 102 /// Replaces Tuple Assign & Index Expressions, and Tuple Types. 103 struct TupleMainExpander : 104 public ast::WithGuards, 105 public ast::WithVisitorRef<TupleMainExpander>, 106 public ast::WithDeclsToAdd<> { 102 struct TupleAssignExpander { 107 103 ast::Expr const * postvisit( ast::TupleAssignExpr const * expr ) { 108 104 // Just move the env on the new top level expression. … … 110 106 &ast::TupleAssignExpr::env, expr->env.get() ); 111 107 } 112 108 }; 109 110 struct TupleTypeReplacer : 111 public ast::WithGuards, 112 public ast::WithVisitorRef<TupleTypeReplacer>, 113 public ast::WithDeclsToAdd<> { 113 114 void previsit( ast::ParseNode const * node ) { 114 115 GuardValue( location ) = &node->location; … … 184 185 return newType; 185 186 } 186 187 private: 188 ScopedMap< int, ast::StructDecl const * > typeMap; 189 CodeLocation const * location = nullptr; 190 }; 191 192 struct TupleIndexExpander { 187 193 ast::Expr const * postvisit( ast::TupleIndexExpr const * expr ) { 188 194 CodeLocation const & location = expr->location; … … 215 221 return memberExpr; 216 222 } 217 private:218 ScopedMap< int, ast::StructDecl const * > typeMap;219 CodeLocation const * location = nullptr;220 223 }; 221 224 … … 272 275 273 276 void expandTuples( ast::TranslationUnit & translationUnit ) { 274 // These can't just be combined simply (there might be a way with work). 275 ast::Pass<TupleMainExpander>::run( translationUnit ); 277 // These may not have to be seperate passes. 278 ast::Pass<TupleAssignExpander>::run( translationUnit ); 279 ast::Pass<TupleTypeReplacer>::run( translationUnit ); 280 ast::Pass<TupleIndexExpander>::run( translationUnit ); 276 281 ast::Pass<TupleExprExpander>::run( translationUnit ); 277 282 }
Note:
See TracChangeset
for help on using the changeset viewer.