Ignore:
Timestamp:
Jun 1, 2017, 4:26:50 PM (7 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
676cc8c
Parents:
3fb9a83
Message:

Refactored PassVisitor? to properly support env and statements to add

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/InitTweak/FixInit.cc

    r3fb9a83 r134322e  
    2020#include <unordered_map>
    2121#include <unordered_set>
     22
    2223#include "InitTweak.h"
    2324#include "GenInit.h"
    2425#include "FixInit.h"
    2526#include "FixGlobalInit.h"
     27#include "CodeGen/GenType.h"  // for warning/error messages
     28#include "Common/PassVisitor.h"
     29#include "GenPoly/DeclMutator.h"
     30#include "GenPoly/PolyMutator.h"
    2631#include "ResolvExpr/Resolver.h"
    2732#include "ResolvExpr/typeops.h"
     33#include "SymTab/Autogen.h"
     34#include "SymTab/Indexer.h"
     35#include "SynTree/AddStmtVisitor.h"
     36#include "SynTree/Attribute.h"
    2837#include "SynTree/Declaration.h"
    29 #include "SynTree/Type.h"
    3038#include "SynTree/Expression.h"
    31 #include "SynTree/Attribute.h"
    32 #include "SynTree/Statement.h"
    3339#include "SynTree/Initializer.h"
    3440#include "SynTree/Mutator.h"
    35 #include "SymTab/Indexer.h"
    36 #include "SymTab/Autogen.h"
    37 #include "GenPoly/PolyMutator.h"
    38 #include "GenPoly/DeclMutator.h"
    39 #include "SynTree/AddStmtVisitor.h"
    40 #include "CodeGen/GenType.h"  // for warning/error messages
     41#include "SynTree/Statement.h"
     42#include "SynTree/Type.h"
    4143#include "Tuples/Tuples.h"
    4244
     
    5456                typedef std::unordered_map< int, int > UnqCount;
    5557
    56                 class InsertImplicitCalls final : public GenPoly::PolyMutator {
     58                class InsertImplicitCalls {
    5759                public:
    5860                        /// wrap function application expressions as ImplicitCopyCtorExpr nodes so that it is easy to identify which
     
    6163
    6264                        InsertImplicitCalls( EnvMap & envMap ) : envMap( envMap ) {}
    63                         typedef GenPoly::PolyMutator Parent;
    64                         using Parent::mutate;
    65                         virtual Expression * mutate( ApplicationExpr * appExpr ) override;
    66                         virtual Expression * mutate( StmtExpr * stmtExpr ) override;
     65
     66                        Expression * postmutate( ApplicationExpr * appExpr );
     67                        void premutate( StmtExpr * stmtExpr );
    6768
    6869                        // collects environments for relevant nodes
    6970                        EnvMap & envMap;
     71                        TypeSubstitution * env; //Magically populated by the PassVisitor
    7072                };
    7173
     
    300302        namespace {
    301303                void InsertImplicitCalls::insert( std::list< Declaration * > & translationUnit, EnvMap & envMap ) {
    302                         InsertImplicitCalls inserter( envMap );
     304                        PassVisitor<InsertImplicitCalls> inserter( envMap );
    303305                        mutateAll( translationUnit, inserter );
    304306                }
     
    350352                }
    351353
    352                 Expression * InsertImplicitCalls::mutate( ApplicationExpr * appExpr ) {
    353                         appExpr = dynamic_cast< ApplicationExpr * >( Parent::mutate( appExpr ) );
     354                Expression * InsertImplicitCalls::postmutate( ApplicationExpr * appExpr ) {
    354355                        assert( appExpr );
    355356
     
    393394                }
    394395
    395                 Expression * InsertImplicitCalls::mutate( StmtExpr * stmtExpr ) {
     396                void InsertImplicitCalls::premutate( StmtExpr * stmtExpr ) {
    396397                        assert( env );
    397398                        envMap[stmtExpr] = env;
    398                         return Parent::mutate( stmtExpr );
    399399                }
    400400
Note: See TracChangeset for help on using the changeset viewer.