Changeset e116db3
- Timestamp:
- Aug 15, 2022, 5:29:20 PM (16 months ago)
- Branches:
- ADT, ast-experimental, master, pthread-emulation
- Children:
- 17c6edeb, 3ce3fb9, 4fee301
- Parents:
- d93ea1d
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Tuples/TupleExpansionNew.cpp
rd93ea1d re116db3 10 10 // Created On : Mon Aug 23 15:36:09 2021 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Mon Jul 29 14:06:00 202213 // Update Count : 212 // Last Modified On : Mon Aug 15 17:00:00 2022 13 // Update Count : 3 14 14 // 15 15 … … 100 100 } 101 101 102 struct TupleAssignExpander { 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<> { 103 107 ast::Expr const * postvisit( ast::TupleAssignExpr const * expr ) { 104 108 // Just move the env on the new top level expression. … … 106 110 &ast::TupleAssignExpr::env, expr->env.get() ); 107 111 } 108 }; 109 110 struct TupleTypeReplacer : 111 public ast::WithGuards, 112 public ast::WithVisitorRef<TupleTypeReplacer>, 113 public ast::WithDeclsToAdd<> { 112 114 113 void previsit( ast::ParseNode const * node ) { 115 114 GuardValue( location ) = &node->location; … … 185 184 return newType; 186 185 } 187 private: 188 ScopedMap< int, ast::StructDecl const * > typeMap; 189 CodeLocation const * location = nullptr; 190 }; 191 192 struct TupleIndexExpander { 186 193 187 ast::Expr const * postvisit( ast::TupleIndexExpr const * expr ) { 194 188 CodeLocation const & location = expr->location; … … 221 215 return memberExpr; 222 216 } 217 private: 218 ScopedMap< int, ast::StructDecl const * > typeMap; 219 CodeLocation const * location = nullptr; 223 220 }; 224 221 … … 275 272 276 273 void expandTuples( ast::TranslationUnit & 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 ); 274 // These can't just be combined simply (there might be a way with work). 275 ast::Pass<TupleMainExpander>::run( translationUnit ); 281 276 ast::Pass<TupleExprExpander>::run( translationUnit ); 282 277 }
Note: See TracChangeset
for help on using the changeset viewer.