Ignore:
Timestamp:
Nov 9, 2017, 1:01:14 PM (4 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
arm-eh, cleanup-dtors, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr
Children:
96fc67b
Parents:
049ead9
git-author:
Rob Schluntz <rschlunt@…> (11/08/17 16:40:12)
git-committer:
Rob Schluntz <rschlunt@…> (11/09/17 13:01:14)
Message:

Modify VarExprReplacer? to replace VariableExpr? with arbitrary expression

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/VarExprReplacer.h

    r049ead9 r7543dec  
    2424
    2525/// Visitor that replaces the declarations that VariableExprs refer to, according to the supplied mapping
    26 class VarExprReplacer : public Visitor {
     26class VarExprReplacer : public Mutator {
    2727public:
    28         typedef std::map< DeclarationWithType *, DeclarationWithType * > DeclMap;
     28        typedef std::map< DeclarationWithType *, Expression * > DeclMap;
    2929private:
    3030        const DeclMap & declMap;
     
    3232public:
    3333        VarExprReplacer( const DeclMap & declMap, bool debug = false );
     34        ~VarExprReplacer();
    3435
    3536        // replace variable with new node from decl map
    36         virtual void visit( VariableExpr * varExpr );
     37        virtual Expression * mutate( VariableExpr * varExpr );
    3738
    38         static void replace( BaseSyntaxNode * node, const DeclMap & declMap, bool debug = false ) {
     39        template<typename Node>
     40        static void replace( Node *& node, const DeclMap & declMap, bool debug = false ) {
    3941                VarExprReplacer replacer( declMap, debug );
    40                 maybeAccept( node, replacer );
     42                node = maybeMutate( node, replacer );
    4143        }
    4244};
Note: See TracChangeset for help on using the changeset viewer.