Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/CodeGenerator.cc

    r2b7bf59 rab4bff5  
    287287        void CodeGenerator::postvisit( TypeDecl * typeDecl ) {
    288288                assertf( ! genC, "TypeDecls should not reach code generation." );
    289                 output << typeDecl->genTypeString() << " " << typeDecl->get_name();
    290                 if ( typeDecl->get_kind() != TypeDecl::Any && typeDecl->get_sized() ) {
    291                         output << " | sized(" << typeDecl->get_name() << ")";
    292                 }
    293                 if ( ! typeDecl->get_assertions().empty() ) {
     289                output << typeDecl->genTypeString() << " " << typeDecl->name;
     290                if ( typeDecl->get_kind() != TypeDecl::Any && typeDecl->sized ) {
     291                        output << " | sized(" << typeDecl->name << ")";
     292                }
     293                if ( ! typeDecl->assertions.empty() ) {
    294294                        output << " | { ";
    295                         genCommaList( typeDecl->get_assertions().begin(), typeDecl->get_assertions().end() );
     295                        for ( DeclarationWithType * assert :  typeDecl->assertions ) {
     296                                assert->accept( *visitor );
     297                                output << "; ";
     298                        }
    296299                        output << " }";
    297300                }
     
    946949                output << ";";
    947950        }
     951        void CodeGenerator::postvisit( CatchStmt * stmt ) {
     952                assertf( ! genC, "Catch statements should not reach code generation." );
     953
     954                output << ((stmt->get_kind() == CatchStmt::Terminate) ?
     955                "catch" : "catchResume");
     956                output << "( ";
     957                stmt->decl->accept( *visitor );
     958                output << " ) ";
     959
     960                if( stmt->cond ) {
     961                        output << "if/when(?) (";
     962                        stmt->cond->accept( *visitor );
     963                        output << ") ";
     964                }
     965                stmt->body->accept( *visitor );
     966        }
     967
     968        void CodeGenerator::postvisit( WaitForStmt * stmt ) {
     969                assertf( ! genC, "Waitfor statements should not reach code generation." );
     970
     971                bool first = true;
     972                for( auto & clause : stmt->clauses ) {
     973                        if(first) { output << "or "; first = false; }
     974                        if( clause.condition ) {
     975                                output << "when(";
     976                                stmt->timeout.condition->accept( *visitor );
     977                                output << ") ";
     978                        }
     979                        output << "waitfor(";
     980                        clause.target.function->accept( *visitor );
     981                        for( Expression * expr : clause.target.arguments ) {
     982                                output << ",";
     983                                expr->accept( *visitor );
     984                        }
     985                        output << ") ";
     986                        clause.statement->accept( *visitor );
     987                }
     988
     989                if( stmt->timeout.statement ) {
     990                        output << "or ";
     991                        if( stmt->timeout.condition ) {
     992                                output << "when(";
     993                                stmt->timeout.condition->accept( *visitor );
     994                                output << ") ";
     995                        }
     996                        output << "timeout(";
     997                        stmt->timeout.time->accept( *visitor );
     998                        output << ") ";
     999                        stmt->timeout.statement->accept( *visitor );
     1000                }
     1001
     1002                if( stmt->orelse.statement ) {
     1003                        output << "or ";
     1004                        if( stmt->orelse.condition ) {
     1005                                output << "when(";
     1006                                stmt->orelse.condition->accept( *visitor );
     1007                                output << ")";
     1008                        }
     1009                        output << "else ";
     1010                        stmt->orelse.statement->accept( *visitor );
     1011                }
     1012        }
     1013
    9481014
    9491015        void CodeGenerator::postvisit( WhileStmt * whileStmt ) {
     
    10241090        }
    10251091} // namespace CodeGen
     1092
     1093
     1094unsigned Indenter::tabsize = 2;
    10261095
    10271096std::ostream & operator<<( std::ostream & out, const BaseSyntaxNode * node ) {
Note: See TracChangeset for help on using the changeset viewer.