Ignore:
Timestamp:
Feb 22, 2017, 2:42:11 PM (9 years ago)
Author:
Aaron Moss <a3moss@…>
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:
131dbb3, 692de479
Parents:
0788b739 (diff), fc39193 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/ResolvExpr/Resolver.cc

    r0788b739 r396ee0a  
    8686                Resolver resolver;
    8787                acceptAll( translationUnit, resolver );
    88 #if 0
    89                 resolver.print( cerr );
    90                 for ( std::list< Declaration * >::iterator i = translationUnit.begin(); i != translationUnit.end(); ++i ) {
    91                         (*i)->print( std::cerr );
    92                         (*i)->accept( resolver );
    93                 } // for
    94 #endif
    9588        }
    9689
     
    309302        }
    310303
    311         template< typename SwitchClass >
    312         void handleSwitchStmt( SwitchClass *switchStmt, SymTab::Indexer &visitor ) {
     304        void Resolver::visit( SwitchStmt *switchStmt ) {
     305                ValueGuard< Type * > oldInitContext( initContext );
    313306                Expression *newExpr;
    314                 newExpr = findIntegralExpression( switchStmt->get_condition(), visitor );
     307                newExpr = findIntegralExpression( switchStmt->get_condition(), *this );
    315308                delete switchStmt->get_condition();
    316309                switchStmt->set_condition( newExpr );
    317310
    318                 visitor.Visitor::visit( switchStmt );
    319         }
    320 
    321         void Resolver::visit( SwitchStmt *switchStmt ) {
    322                 handleSwitchStmt( switchStmt, *this );
     311                initContext = newExpr->get_result();
     312                Parent::visit( switchStmt );
    323313        }
    324314
    325315        void Resolver::visit( CaseStmt *caseStmt ) {
     316                if ( caseStmt->get_condition() ) {
     317                        assert( initContext );
     318                        CastExpr * castExpr = new CastExpr( caseStmt->get_condition(), initContext->clone() );
     319                        Expression * newExpr = findSingleExpression( castExpr, *this );
     320                        castExpr = safe_dynamic_cast< CastExpr * >( newExpr );
     321                        caseStmt->set_condition( castExpr->get_arg() );
     322                        castExpr->set_arg( nullptr );
     323                        delete castExpr;
     324                }
    326325                Parent::visit( caseStmt );
    327326        }
Note: See TracChangeset for help on using the changeset viewer.