Changes in / [26238c1:1cb758f2]


Ignore:
Location:
src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/Common/PassVisitor.h

    r26238c1 r1cb758f2  
    7575        virtual void visit( CatchStmt *catchStmt ) override final;
    7676        virtual void visit( FinallyStmt *finallyStmt ) override final;
    77         virtual void visit( WaitForStmt *waitforStmt ) override final;
    7877        virtual void visit( NullStmt *nullStmt ) override final;
    7978        virtual void visit( DeclStmt *declStmt ) override final;
     
    160159        virtual Statement* mutate( ReturnStmt *returnStmt ) override final;
    161160        virtual Statement* mutate( ThrowStmt *throwStmt ) override final;
    162         virtual Statement* mutate( TryStmt *tryStmt ) override final;
     161        virtual Statement* mutate( TryStmt *returnStmt ) override final;
    163162        virtual Statement* mutate( CatchStmt *catchStmt ) override final;
    164         virtual Statement* mutate( FinallyStmt *finallyStmt ) override final;
    165         virtual Statement* mutate( WaitForStmt *waitforStmt ) override final;
     163        virtual Statement* mutate( FinallyStmt *catchStmt ) override final;
    166164        virtual NullStmt* mutate( NullStmt *nullStmt ) override final;
    167165        virtual Statement* mutate( DeclStmt *declStmt ) override final;
  • src/Common/PassVisitor.impl.h

    r26238c1 r1cb758f2  
    541541}
    542542
    543 //--------------------------------------------------------------------------
    544 // FinallyStmt
    545543template< typename pass_type >
    546544void PassVisitor< pass_type >::visit( FinallyStmt * node ) {
     
    549547
    550548template< typename pass_type >
    551 Statement * PassVisitor< pass_type >::mutate( FinallyStmt * node ) {
    552         MUTATE_BODY( Statement, node );
    553 }
    554 
    555 //--------------------------------------------------------------------------
    556 // WaitForStmt
    557 template< typename pass_type >
    558 void PassVisitor< pass_type >::visit( WaitForStmt * node ) {
    559         VISIT_BODY( node );
    560 }
    561 
    562 template< typename pass_type >
    563 Statement * PassVisitor< pass_type >::mutate( WaitForStmt * node ) {
    564         MUTATE_BODY( Statement, node );
    565 }
    566 
    567 //--------------------------------------------------------------------------
    568 // NullStmt
    569 template< typename pass_type >
    570549void PassVisitor< pass_type >::visit( NullStmt * node ) {
    571550        VISIT_BODY( node );
     
    573552
    574553template< typename pass_type >
    575 NullStmt * PassVisitor< pass_type >::mutate( NullStmt * node ) {
    576         MUTATE_BODY( NullStmt, node );
    577 }
    578 
    579 //--------------------------------------------------------------------------
    580 // DeclStmt
    581 template< typename pass_type >
    582554void PassVisitor< pass_type >::visit( DeclStmt * node ) {
    583555        VISIT_BODY( node );
     
    585557
    586558template< typename pass_type >
    587 Statement * PassVisitor< pass_type >::mutate( DeclStmt * node ) {
    588         MUTATE_BODY( Statement, node );
    589 }
    590 
    591 //--------------------------------------------------------------------------
    592 // ImplicitCtorDtorStmt
    593 template< typename pass_type >
    594559void PassVisitor< pass_type >::visit( ImplicitCtorDtorStmt * node ) {
    595560        VISIT_BODY( node );
     
    597562
    598563template< typename pass_type >
    599 Statement * PassVisitor< pass_type >::mutate( ImplicitCtorDtorStmt * node ) {
    600         MUTATE_BODY( Statement, node );
    601 }
    602 
    603 //--------------------------------------------------------------------------
    604 // ApplicationExpr
    605 template< typename pass_type >
    606564void PassVisitor< pass_type >::visit( ApplicationExpr * node ) {
    607565        VISIT_BODY( node );
    608 }
    609 
    610 template< typename pass_type >
    611 Expression * PassVisitor< pass_type >::mutate( ApplicationExpr * node ) {
    612         MUTATE_BODY( Expression, node );
    613566}
    614567
     
    991944
    992945template< typename pass_type >
     946Statement * PassVisitor< pass_type >::mutate( FinallyStmt * node ) {
     947        MUTATE_BODY( Statement, node );
     948}
     949
     950template< typename pass_type >
     951NullStmt * PassVisitor< pass_type >::mutate( NullStmt * node ) {
     952        MUTATE_BODY( NullStmt, node );
     953}
     954
     955template< typename pass_type >
     956Statement * PassVisitor< pass_type >::mutate( DeclStmt * node ) {
     957        MUTATE_BODY( Statement, node );
     958}
     959
     960template< typename pass_type >
     961Statement * PassVisitor< pass_type >::mutate( ImplicitCtorDtorStmt * node ) {
     962        MUTATE_BODY( Statement, node );
     963}
     964
     965template< typename pass_type >
     966Expression * PassVisitor< pass_type >::mutate( ApplicationExpr * node ) {
     967        MUTATE_BODY( Expression, node );
     968}
     969
     970template< typename pass_type >
    993971Expression * PassVisitor< pass_type >::mutate( NameExpr * node ) {
    994972        MUTATE_BODY( Expression, node );
  • src/Concurrency/Keywords.cc

    r26238c1 r1cb758f2  
    1919#include <string>                  // for string, operator==
    2020
    21 #include "Common/PassVisitor.h"    // for PassVisitor
    2221#include "Common/SemanticError.h"  // for SemanticError
    2322#include "Common/utility.h"        // for deleteAll, map_range
     
    4746
    4847        //=============================================================================================
    49         // Pass declarations
     48        // Visitors declaration
    5049        //=============================================================================================
    5150
     
    5958        //                                           static inline NewField_t * getter_name( MyType * this ) { return &this->newField; }
    6059        //
    61         class ConcurrentSueKeyword : public WithDeclsToAdd {
     60        class ConcurrentSueKeyword : public Visitor {
     61          protected:
     62            template< typename Visitor >
     63            friend void SymTab::acceptAndAdd( std::list< Declaration * > &translationUnit, Visitor &visitor );
    6264          public:
    6365
     
    6769                virtual ~ConcurrentSueKeyword() {}
    6870
    69                 void postvisit( StructDecl * decl );
     71                using Visitor::visit;
     72                virtual void visit( StructDecl * decl ) override final;
    7073
    7174                void handle( StructDecl * );
     
    8386                bool needs_main;
    8487
     88                std::list< Declaration * > declsToAdd, declsToAddAfter;
    8589                StructDecl* type_decl = nullptr;
    8690        };
     
    113117
    114118                static void implement( std::list< Declaration * > & translationUnit ) {
    115                         PassVisitor< ThreadKeyword > impl;
    116                         acceptAll( translationUnit, impl );
     119                        ThreadKeyword impl;
     120                        SymTab::acceptAndAdd( translationUnit, impl );
    117121                }
    118122        };
     
    144148
    145149                static void implement( std::list< Declaration * > & translationUnit ) {
    146                         PassVisitor< CoroutineKeyword > impl;
    147                         acceptAll( translationUnit, impl );
     150                        CoroutineKeyword impl;
     151                        SymTab::acceptAndAdd( translationUnit, impl );
    148152                }
    149153        };
     
    175179
    176180                static void implement( std::list< Declaration * > & translationUnit ) {
    177                         PassVisitor< MonitorKeyword > impl;
    178                         acceptAll( translationUnit, impl );
     181                        MonitorKeyword impl;
     182                        SymTab::acceptAndAdd( translationUnit, impl );
    179183                }
    180184        };
     
    188192        // }                                                               }
    189193        //
    190         class MutexKeyword final {
     194        class MutexKeyword final : public Visitor {
    191195          public:
    192196
    193                 void postvisit( FunctionDecl * decl );
    194                 void postvisit(   StructDecl * decl );
     197                using Visitor::visit;
     198                virtual void visit( FunctionDecl * decl ) override final;
     199                virtual void visit(   StructDecl * decl ) override final;
    195200
    196201                std::list<DeclarationWithType*> findMutexArgs( FunctionDecl* );
     
    199204
    200205                static void implement( std::list< Declaration * > & translationUnit ) {
    201                         PassVisitor< MutexKeyword > impl;
     206                        MutexKeyword impl;
    202207                        acceptAll( translationUnit, impl );
    203208                }
     
    225230        // }                                                               }
    226231        //
    227         class ThreadStarter final {
     232        class ThreadStarter final : public Visitor {
    228233          public:
    229234
    230                 void postvisit( FunctionDecl * decl );
     235                using Visitor::visit;
     236                virtual void visit( FunctionDecl * decl ) override final;
    231237
    232238                void addStartStatement( FunctionDecl * decl, DeclarationWithType * param );
    233239
    234240                static void implement( std::list< Declaration * > & translationUnit ) {
    235                         PassVisitor< ThreadStarter > impl;
     241                        ThreadStarter impl;
    236242                        acceptAll( translationUnit, impl );
    237243                }
     
    258264        // Generic keyword implementation
    259265        //=============================================================================================
    260         void ConcurrentSueKeyword::postvisit(StructDecl * decl) {
     266        void ConcurrentSueKeyword::visit(StructDecl * decl) {
     267                Visitor::visit(decl);
    261268                if( decl->get_name() == type_name && decl->has_body() ) {
    262269                        assert( !type_decl );
     
    346353                }
    347354
    348                 declsToAddBefore.push_back( forward );
    349                 if( needs_main ) declsToAddBefore.push_back( main_decl );
    350                 declsToAddBefore.push_back( get_decl );
     355                declsToAdd.push_back( forward );
     356                if( needs_main ) declsToAdd.push_back( main_decl );
     357                declsToAdd.push_back( get_decl );
    351358
    352359                return get_decl;
     
    398405        //=============================================================================================
    399406
    400         void MutexKeyword::postvisit(FunctionDecl* decl) {
     407        void MutexKeyword::visit(FunctionDecl* decl) {
     408                Visitor::visit(decl);
    401409
    402410                std::list<DeclarationWithType*> mutexArgs = findMutexArgs( decl );
     
    416424        }
    417425
    418         void MutexKeyword::postvisit(StructDecl* decl) {
     426        void MutexKeyword::visit(StructDecl* decl) {
     427                Visitor::visit(decl);
    419428
    420429                if( decl->get_name() == "monitor_desc" ) {
     
    523532        // General entry routine
    524533        //=============================================================================================
    525         void ThreadStarter::postvisit(FunctionDecl * decl) {
     534        void ThreadStarter::visit(FunctionDecl * decl) {
     535                Visitor::visit(decl);
     536
    526537                if( ! CodeGen::isConstructor(decl->get_name()) ) return;
    527538
  • src/Parser/StatementNode.cc

    r26238c1 r1cb758f2  
    212212        WaitForStmt::Target target;
    213213        target.function = maybeBuild<Expression>( targetExpr );
    214 
    215         ExpressionNode * next = dynamic_cast<ExpressionNode *>( targetExpr->get_next() );
    216         targetExpr->set_next( nullptr );
    217         buildMoveList< Expression >( next, target.arguments );
    218 
     214        buildMoveList< Expression >( targetExpr, target.arguments );
    219215        delete targetExpr;
    220216
     
    230226WaitForStmt * build_waitfor( ExpressionNode * targetExpr, StatementNode * stmt, ExpressionNode * when, WaitForStmt * node ) {
    231227        WaitForStmt::Target target;
     228
    232229        target.function = maybeBuild<Expression>( targetExpr );
    233 
    234         ExpressionNode * next = dynamic_cast<ExpressionNode *>( targetExpr->get_next() );
    235         targetExpr->set_next( nullptr );
    236         buildMoveList< Expression >( next, target.arguments );
    237 
     230        buildMoveList< Expression >( targetExpr, target.arguments );
    238231        delete targetExpr;
    239232
Note: See TracChangeset for help on using the changeset viewer.