Ignore:
Timestamp:
Aug 15, 2022, 5:29:20 PM (4 months ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
master, pthread-emulation
Children:
17c6edeb, 3ce3fb9, 4fee301
Parents:
d93ea1d
Message:

Combined some sub-passes in Tuple Expansion, two less tree traversals now have to be preformed.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Tuples/TupleExpansionNew.cpp

    rd93ea1d re116db3  
    1010// Created On       : Mon Aug 23 15:36:09 2021
    1111// Last Modified By : Andrew Beach
    12 // Last Modified On : Mon Jul 29 14:06:00 2022
    13 // Update Count     : 2
     12// Last Modified On : Mon Aug 15 17:00:00 2022
     13// Update Count     : 3
    1414//
    1515
     
    100100}
    101101
    102 struct TupleAssignExpander {
     102/// Replaces Tuple Assign & Index Expressions, and Tuple Types.
     103struct TupleMainExpander :
     104                public ast::WithGuards,
     105                public ast::WithVisitorRef<TupleMainExpander>,
     106                public ast::WithDeclsToAdd<> {
    103107        ast::Expr const * postvisit( ast::TupleAssignExpr const * expr ) {
    104108                // Just move the env on the new top level expression.
     
    106110                        &ast::TupleAssignExpr::env, expr->env.get() );
    107111        }
    108 };
    109 
    110 struct TupleTypeReplacer :
    111                 public ast::WithGuards,
    112                 public ast::WithVisitorRef<TupleTypeReplacer>,
    113                 public ast::WithDeclsToAdd<> {
     112
    114113        void previsit( ast::ParseNode const * node ) {
    115114                GuardValue( location ) = &node->location;
     
    185184                return newType;
    186185        }
    187 private:
    188         ScopedMap< int, ast::StructDecl const * > typeMap;
    189         CodeLocation const * location = nullptr;
    190 };
    191 
    192 struct TupleIndexExpander {
     186
    193187        ast::Expr const * postvisit( ast::TupleIndexExpr const * expr ) {
    194188                CodeLocation const & location = expr->location;
     
    221215                return memberExpr;
    222216        }
     217private:
     218        ScopedMap< int, ast::StructDecl const * > typeMap;
     219        CodeLocation const * location = nullptr;
    223220};
    224221
     
    275272
    276273void 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 );
    281276        ast::Pass<TupleExprExpander>::run( translationUnit );
    282277}
Note: See TracChangeset for help on using the changeset viewer.