Changeset 33a25f9 for src/Common


Ignore:
Timestamp:
Sep 16, 2017, 8:52:23 AM (8 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:
5f782f7
Parents:
c0714bf
Message:

Remove visitor feature from Indexer

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/Common/PassVisitor.impl.h

    rc0714bf r33a25f9  
    293293//------------------------------------------------------------------------------------------------------------------------------------------------------------------------
    294294
     295// A NOTE ON THE ORDER OF TRAVERSAL
     296//
     297// Types and typedefs have their base types visited before they are added to the type table.  This is ok, since there is
     298// no such thing as a recursive type or typedef.
     299//
     300//             typedef struct { T *x; } T; // never allowed
     301//
     302// for structs/unions, it is possible to have recursion, so the decl should be added as if it's incomplete to begin, the
     303// members are traversed, and then the complete type should be added (assuming the type is completed by this particular
     304// declaration).
     305//
     306//             struct T { struct T *x; }; // allowed
     307//
     308// It is important to add the complete type to the symbol table *after* the members/base has been traversed, since that
     309// traversal may modify the definition of the type and these modifications should be visible when the symbol table is
     310// queried later in this pass.
     311//
     312// TODO: figure out whether recursive contexts are sensible/possible/reasonable.
    295313
    296314//--------------------------------------------------------------------------
     
    450468        indexerAddEnum( node );
    451469
    452         // unlike structs, contexts, and unions, enums inject their members into the global scope
     470        // unlike structs, traits, and unions, enums inject their members into the global scope
    453471        maybeAccept( node->parameters, *this );
    454472        maybeAccept( node->members   , *this );
     
    514532        }
    515533
     534        // see A NOTE ON THE ORDER OF TRAVERSAL, above
     535        // note that assertions come after the type is added to the symtab, since they are not part of the type proper
     536        // and may depend on the type itself
    516537        indexerAddType( node );
    517538
     
    533554        }
    534555
     556        // see A NOTE ON THE ORDER OF TRAVERSAL, above
     557        // note that assertions come after the type is added to the symtab, since they are not part of the type proper
     558        // and may depend on the type itself
    535559        indexerAddType( node );
    536560
     
    659683void PassVisitor< pass_type >::visit( IfStmt * node ) {
    660684        VISIT_START( node );
    661 
    662         visitExpression( node->condition );
    663         node->thenPart = visitStatement( node->thenPart );
    664         node->elsePart = visitStatement( node->elsePart );
    665 
     685        {
     686                // if statements introduce a level of scope (for the initialization)
     687                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
     688                acceptAll( node->get_initialization(), *this );
     689                visitExpression( node->condition );
     690                node->thenPart = visitStatement( node->thenPart );
     691                node->elsePart = visitStatement( node->elsePart );
     692        }
    666693        VISIT_END( node );
    667694}
     
    671698        MUTATE_START( node );
    672699        {
    673                 auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
     700                // if statements introduce a level of scope (for the initialization)
     701                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
     702                maybeMutateRef( node->get_initialization(), *this );
    674703                node->condition = mutateExpression( node->condition );
    675704                node->thenPart  = mutateStatement ( node->thenPart  );
     
    707736        VISIT_START( node );
    708737        {
     738                // for statements introduce a level of scope (for the initialization)
    709739                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    710740                maybeAccept( node->initialization, *this );
     
    720750        MUTATE_START( node );
    721751        {
     752                // for statements introduce a level of scope (for the initialization)
    722753                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    723754                maybeMutateRef( node->initialization, *this );
     
    848879        VISIT_START( node );
    849880        {
     881                // catch statements introduce a level of scope (for the caught exception)
    850882                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    851883                maybeAccept( node->decl, *this );
     
    860892        MUTATE_START( node );
    861893        {
     894                // catch statements introduce a level of scope (for the caught exception)
    862895                auto guard = makeFuncGuard( [this]() { indexerScopeEnter(); }, [this]() { indexerScopeLeave(); } );
    863896                maybeMutateRef( node->decl, *this );
Note: See TracChangeset for help on using the changeset viewer.