- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/Tuples/TupleExpansionNew.cpp
rce1d721 re9e9f56 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 : Tue Sep 20 16:17:00 2022 13 // Update Count : 4 14 14 // 15 15 … … 100 100 } 101 101 102 struct TupleAssignExpander { 102 /// Replaces Tuple Assign & Index Expressions, and Tuple Types. 103 struct TupleMainExpander final : 104 public ast::WithCodeLocation, 105 public ast::WithDeclsToAdd<>, 106 public ast::WithGuards, 107 public ast::WithVisitorRef<TupleMainExpander> { 103 108 ast::Expr const * postvisit( ast::TupleAssignExpr const * expr ) { 104 109 // Just move the env on the new top level expression. … … 106 111 &ast::TupleAssignExpr::env, expr->env.get() ); 107 112 } 108 }; 109 110 struct TupleTypeReplacer : 111 public ast::WithGuards, 112 public ast::WithVisitorRef<TupleTypeReplacer>, 113 public ast::WithDeclsToAdd<> { 114 void previsit( ast::ParseNode const * node ) { 115 GuardValue( location ) = &node->location; 116 } 117 118 void previsit( ast::CompoundStmt const * stmt ) { 119 previsit( (ast::ParseNode const *)stmt ); 113 114 void previsit( ast::CompoundStmt const * ) { 120 115 GuardScope( typeMap ); 121 116 } … … 185 180 return newType; 186 181 } 187 private: 188 ScopedMap< int, ast::StructDecl const * > typeMap; 189 CodeLocation const * location = nullptr; 190 }; 191 192 struct TupleIndexExpander { 182 193 183 ast::Expr const * postvisit( ast::TupleIndexExpr const * expr ) { 194 184 CodeLocation const & location = expr->location; … … 221 211 return memberExpr; 222 212 } 213 private: 214 ScopedMap< int, ast::StructDecl const * > typeMap; 223 215 }; 224 216 … … 257 249 } 258 250 259 struct TupleExprExpander {251 struct TupleExprExpander final { 260 252 ast::Expr const * postvisit( ast::TupleExpr const * expr ) { 261 253 return replaceTupleExpr( expr->location, … … 275 267 276 268 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 ); 269 // These can't just be combined simply (there might be a way with work). 270 ast::Pass<TupleMainExpander>::run( translationUnit ); 281 271 ast::Pass<TupleExprExpander>::run( translationUnit ); 282 272 }
Note:
See TracChangeset
for help on using the changeset viewer.