Changeset 334801b


Ignore:
Timestamp:
Jun 8, 2023, 3:42:52 PM (18 months ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
ast-experimental, master
Children:
148f836e
Parents:
918e4165
Message:

Simplify one of the Pass::visit methods for CompoundStmt?. It repeats two lines to move the conditional code into different if clauses.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Pass.impl.hpp

    r918e4165 r334801b  
    761761
    762762        if ( __visit_children() ) {
    763                 // Do not enter (or leave) a new scope if atFunctionTop. Remember to save the result.
    764                 auto guard1 = makeFuncGuard( [this, enterScope = !this->atFunctionTop]() {
    765                         if ( enterScope ) {
    766                                 __pass::symtab::enter(core, 0);
    767                         }
    768                 }, [this, leaveScope = !this->atFunctionTop]() {
    769                         if ( leaveScope ) {
    770                                 __pass::symtab::leave(core, 0);
    771                         }
    772                 });
    773                 ValueGuard< bool > guard2( atFunctionTop );
    774                 atFunctionTop = false;
    775                 guard_scope guard3 { *this };
    776                 maybe_accept( node, &CompoundStmt::kids );
     763                // Do not enter (or leave) a new symbol table scope if atFunctionTop.
     764                // But always enter (and leave) a new general scope.
     765                if ( atFunctionTop ) {
     766                        ValueGuard< bool > guard1( atFunctionTop );
     767                        atFunctionTop = false;
     768                        guard_scope guard2( *this );
     769                        maybe_accept( node, &CompoundStmt::kids );
     770                } else {
     771                        guard_symtab guard1( *this );
     772                        guard_scope guard2( *this );
     773                        maybe_accept( node, &CompoundStmt::kids );
     774                }
    777775        }
    778776
Note: See TracChangeset for help on using the changeset viewer.