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