Changeset 550446f


Ignore:
Timestamp:
Jan 8, 2025, 4:30:50 PM (8 months ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
master
Children:
454aab2, 5a894e12
Parents:
f32448e
Message:

Added some code to the code generator for printing try statements in intermediate states.

Location:
src/CodeGen
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/CodeGenerator.cpp

    rf32448e r550446f  
    11301130}
    11311131
     1132void CodeGenerator::postvisit( ast::TryStmt const * stmt ) {
     1133        assertf( !options.genC, "TryStmt should not reach code generation." );
     1134
     1135        output << "try ";
     1136        stmt->body->accept( *visitor );
     1137        for ( ast::ptr<ast::CatchClause> const & handler : stmt->handlers ) {
     1138                handler->accept( *visitor );
     1139        }
     1140        if ( stmt->finally ) stmt->finally->accept( *visitor );
     1141}
     1142
    11321143void CodeGenerator::postvisit( ast::CatchClause const * stmt ) {
    11331144        assertf( !options.genC, "CatchClause should not reach code generation." );
    11341145
    1135         output << ((stmt->kind == ast::Terminate) ? "catch" : "catchResume");
     1146        output << ((stmt->kind == ast::Terminate) ? " catch " : " catchResume ");
    11361147        output << "( ";
    11371148        stmt->decl->accept( *visitor );
     
    11421153        output << " ) ";
    11431154        stmt->body->accept( *visitor );
     1155}
     1156
     1157void CodeGenerator::postvisit( ast::FinallyClause const * clause ) {
     1158        assertf( !options.genC, "FinallyClause should not reach code generation." );
     1159
     1160        output << " finally ";
     1161        clause->body->accept( *visitor );
    11441162}
    11451163
  • src/CodeGen/CodeGenerator.hpp

    rf32448e r550446f  
    106106        void postvisit( ast::ReturnStmt const * );
    107107        void postvisit( ast::ThrowStmt const * );
     108        void postvisit( ast::TryStmt const * );
    108109        void postvisit( ast::CatchClause const * );
     110        void postvisit( ast::FinallyClause const * );
    109111        void postvisit( ast::WaitForStmt const * );
    110112        void postvisit( ast::WithStmt const * );
Note: See TracChangeset for help on using the changeset viewer.