Changeset 6e49f18 for src/CodeGen


Ignore:
Timestamp:
Sep 27, 2017, 11:11:30 PM (8 years ago)
Author:
Peter A. Buhr <pabuhr@…>
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:
f802e46
Parents:
a6c5d7c (diff), fa16264 (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 plg2:software/cfa/cfa-cc

Location:
src/CodeGen
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/CodeGenerator.cc

    ra6c5d7c r6e49f18  
    540540                extension( nameExpr );
    541541                OperatorInfo opInfo;
    542                 if ( operatorLookup( nameExpr->get_name(), opInfo ) ) {
    543                         assert( opInfo.type == OT_CONSTANT );
    544                         output << opInfo.symbol;
     542                if ( operatorLookup( nameExpr->name, opInfo ) ) {
     543                        if ( opInfo.type == OT_CONSTANT ) {
     544                                output << opInfo.symbol;
     545                        } else {
     546                                output << opInfo.outputName;
     547                        }
    545548                } else {
    546549                        output << nameExpr->get_name();
     
    943946                output << ";";
    944947        }
     948        void CodeGenerator::postvisit( CatchStmt * stmt ) {
     949                assertf( ! genC, "Catch statements should not reach code generation." );
     950
     951                output << ((stmt->get_kind() == CatchStmt::Terminate) ?
     952                "catch" : "catchResume");
     953                output << "( ";
     954                stmt->decl->accept( *visitor );
     955                output << " ) ";
     956
     957                if( stmt->cond ) {
     958                        output << "if/when(?) (";
     959                        stmt->cond->accept( *visitor );
     960                        output << ") ";
     961                }
     962                stmt->body->accept( *visitor );
     963        }
     964
     965        void CodeGenerator::postvisit( WaitForStmt * stmt ) {
     966                assertf( ! genC, "Waitfor statements should not reach code generation." );
     967
     968                bool first = true;
     969                for( auto & clause : stmt->clauses ) {
     970                        if(first) { output << "or "; first = false; }
     971                        if( clause.condition ) {
     972                                output << "when(";
     973                                stmt->timeout.condition->accept( *visitor );
     974                                output << ") ";
     975                        }
     976                        output << "waitfor(";
     977                        clause.target.function->accept( *visitor );
     978                        for( Expression * expr : clause.target.arguments ) {
     979                                output << ",";
     980                                expr->accept( *visitor );
     981                        }
     982                        output << ") ";
     983                        clause.statement->accept( *visitor );
     984                }
     985
     986                if( stmt->timeout.statement ) {
     987                        output << "or ";
     988                        if( stmt->timeout.condition ) {
     989                                output << "when(";
     990                                stmt->timeout.condition->accept( *visitor );
     991                                output << ") ";
     992                        }
     993                        output << "timeout(";
     994                        stmt->timeout.time->accept( *visitor );
     995                        output << ") ";
     996                        stmt->timeout.statement->accept( *visitor );
     997                }
     998
     999                if( stmt->orelse.statement ) {
     1000                        output << "or ";
     1001                        if( stmt->orelse.condition ) {
     1002                                output << "when(";
     1003                                stmt->orelse.condition->accept( *visitor );
     1004                                output << ")";
     1005                        }
     1006                        output << "else ";
     1007                        stmt->orelse.statement->accept( *visitor );
     1008                }
     1009        }
     1010
    9451011
    9461012        void CodeGenerator::postvisit( WhileStmt * whileStmt ) {
  • src/CodeGen/CodeGenerator.h

    ra6c5d7c r6e49f18  
    100100                void postvisit( ReturnStmt * );
    101101                void postvisit( ThrowStmt * );
     102                void postvisit( CatchStmt * );
     103                void postvisit( WaitForStmt * );
    102104                void postvisit( WhileStmt * );
    103105                void postvisit( ForStmt * );
Note: See TracChangeset for help on using the changeset viewer.