Ignore:
Timestamp:
Oct 2, 2017, 5:52:43 PM (7 years ago)
Author:
Rob Schluntz <rschlunt@…>
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:
3096ec1
Parents:
93fe7141
Message:

Convert ResolveTypeof? to PassVisitor?

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/ResolveTypeof.cc

    r93fe7141 r9d79f93  
    1818#include <cassert>               // for assert
    1919
     20#include "Common/PassVisitor.h"  // for PassVisitor
    2021#include "Resolver.h"            // for resolveInVoidContext
    2122#include "SynTree/Expression.h"  // for Expression
     
    4142        }
    4243
    43         class ResolveTypeof : public Mutator {
     44        class ResolveTypeof : public WithShortCircuiting {
    4445          public:
    4546                ResolveTypeof( const SymTab::Indexer &indexer ) : indexer( indexer ) {}
    46                 Type *mutate( TypeofType *typeofType );
     47                void premutate( TypeofType *typeofType );
     48                Type * postmutate( TypeofType *typeofType );
    4749
    4850          private:
     
    5052        };
    5153
    52         Type *resolveTypeof( Type *type, const SymTab::Indexer &indexer ) {
    53                 ResolveTypeof mutator( indexer );
     54        Type * resolveTypeof( Type *type, const SymTab::Indexer &indexer ) {
     55                PassVisitor<ResolveTypeof> mutator( indexer );
    5456                return type->acceptMutator( mutator );
    5557        }
    5658
    57         Type *ResolveTypeof::mutate( TypeofType *typeofType ) {
     59        void ResolveTypeof::premutate( TypeofType * ) {
     60                visit_children = false;
     61        }
     62
     63        Type * ResolveTypeof::postmutate( TypeofType *typeofType ) {
    5864#if 0
    59                 std::cout << "resolving typeof: ";
    60                 typeofType->print( std::cout );
    61                 std::cout << std::endl;
     65                std::cerr << "resolving typeof: ";
     66                typeofType->print( std::cerr );
     67                std::cerr << std::endl;
    6268#endif
    63                 if ( typeofType->get_expr() ) {
    64                         Expression *newExpr = resolveInVoidContext( typeofType->get_expr(), indexer );
    65                         assert( newExpr->result && ! newExpr->get_result()->isVoid() );
    66                         Type *newType = newExpr->get_result();
    67                         newExpr->set_result( nullptr );
     69                if ( typeofType->expr ) {
     70                        Expression * newExpr = resolveInVoidContext( typeofType->expr, indexer );
     71                        assert( newExpr->result && ! newExpr->result->isVoid() );
     72                        Type * newType = newExpr->result;
     73                        newExpr->result = nullptr;
    6874                        delete typeofType;
    6975                        delete newExpr;
Note: See TracChangeset for help on using the changeset viewer.