Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Tuples/TupleExpansionNew.cpp

    re116db3 rce1d721  
    1010// Created On       : Mon Aug 23 15:36:09 2021
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Mon Aug 15 17:00:00 2022
    13 // Update Count     : 3
     12// Last Modified On : Mon Jul 29 14:06:00 2022
     13// Update Count     : 2
    1414//
    1515
     
    100100}
    101101
    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<> {
     102struct TupleAssignExpander {
    107103        ast::Expr const * postvisit( ast::TupleAssignExpr const * expr ) {
    108104                // Just move the env on the new top level expression.
     
    110106                        &ast::TupleAssignExpr::env, expr->env.get() );
    111107        }
    112 
     108};
     109
     110struct TupleTypeReplacer :
     111                public ast::WithGuards,
     112                public ast::WithVisitorRef<TupleTypeReplacer>,
     113                public ast::WithDeclsToAdd<> {
    113114        void previsit( ast::ParseNode const * node ) {
    114115                GuardValue( location ) = &node->location;
     
    184185                return newType;
    185186        }
    186 
     187private:
     188        ScopedMap< int, ast::StructDecl const * > typeMap;
     189        CodeLocation const * location = nullptr;
     190};
     191
     192struct TupleIndexExpander {
    187193        ast::Expr const * postvisit( ast::TupleIndexExpr const * expr ) {
    188194                CodeLocation const & location = expr->location;
     
    215221                return memberExpr;
    216222        }
    217 private:
    218         ScopedMap< int, ast::StructDecl const * > typeMap;
    219         CodeLocation const * location = nullptr;
    220223};
    221224
     
    272275
    273276void 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 );
    276281        ast::Pass<TupleExprExpander>::run( translationUnit );
    277282}
Note: See TracChangeset for help on using the changeset viewer.