Changeset f6e6a55 for src/AST/Print.cpp


Ignore:
Timestamp:
Apr 20, 2022, 3:00:11 PM (2 years ago)
Author:
Andrew Beach <ajbeach@…>
Branches:
ADT, ast-experimental, master, pthread-emulation, qualifiedEnum
Children:
4c530a5
Parents:
2686bc7
Message:

Added ast::WaitForClause? and changed ast::WaitForStmt? to use it. This simplified a lot of the internal code.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Print.cpp

    r2686bc7 rf6e6a55  
    760760                indent += 2;
    761761                for( const auto & clause : node->clauses ) {
    762                         os << indent-1 << "target function: ";
    763                         safe_print( clause.target.func );
    764 
    765                         if ( ! clause.target.args.empty() ) {
    766                                 os << endl << indent-1 << "... with arguments:" << endl;
    767                                 for( const ast::Expr * arg : clause.target.args ) {
    768                                         arg->accept( *this );
    769                                 }
     762                        clause->accept( *this );
     763                }
     764
     765                if ( node->timeout_time ) {
     766                        os << indent-1 << "timeout of:" << endl;
     767                        node->timeout_time->accept( *this );
     768
     769                        if ( node->timeout_stmt ) {
     770                                os << indent-1 << "... with statment:" << endl;
     771                                node->timeout_stmt->accept( *this );
    770772                        }
    771773
    772                         if ( clause.stmt ) {
    773                                 os << indent-1 << "... with statment:" << endl;
    774                                 clause.stmt->accept( *this );
     774                        if ( node->timeout_cond ) {
     775                                os << indent-1 << "... with condition:" << endl;
     776                                node->timeout_cond->accept( *this );
    775777                        }
    776 
    777                         if ( clause.cond ) {
     778                }
     779
     780                if ( node->else_stmt ) {
     781                        os << indent-1 << "else:" << endl;
     782                        node->else_stmt->accept( *this );
     783
     784                        if ( node->else_cond ) {
    778785                                os << indent-1 << "... with condition:" << endl;
    779                                 clause.cond->accept( *this );
     786                                node->else_cond->accept( *this );
    780787                        }
    781788                }
    782789
    783                 if ( node->timeout.time ) {
    784                         os << indent-1 << "timeout of:" << endl;
    785                         node->timeout.time->accept( *this );
    786 
    787                         if ( node->timeout.stmt ) {
    788                                 os << indent-1 << "... with statment:" << endl;
    789                                 node->timeout.stmt->accept( *this );
     790                return node;
     791        }
     792
     793        virtual const ast::WaitForClause * visit( const ast::WaitForClause * node ) override final {
     794                os << indent-1 << "target function: ";
     795                safe_print( node->target_func );
     796
     797                if ( !node->target_args.empty() ) {
     798                        os << endl << indent-1 << "... with arguments:" << endl;
     799                        for( const ast::Expr * arg : node->target_args ) {
     800                                arg->accept( *this );
    790801                        }
    791 
    792                         if ( node->timeout.cond ) {
    793                                 os << indent-1 << "... with condition:" << endl;
    794                                 node->timeout.cond->accept( *this );
    795                         }
    796                 }
    797 
    798                 if ( node->orElse.stmt ) {
    799                         os << indent-1 << "else:" << endl;
    800                         node->orElse.stmt->accept( *this );
    801 
    802                         if ( node->orElse.cond ) {
    803                                 os << indent-1 << "... with condition:" << endl;
    804                                 node->orElse.cond->accept( *this );
    805                         }
    806                 }
    807                 indent -= 2;
     802                }
     803
     804                if ( node->stmt ) {
     805                        os << indent-1 << "... with statment:" << endl;
     806                        node->stmt->accept( *this );
     807                }
     808
     809                if ( node->cond ) {
     810                        os << indent-1 << "... with condition:" << endl;
     811                        node->cond->accept( *this );
     812                }
    808813
    809814                return node;
Note: See TracChangeset for help on using the changeset viewer.