Changeset eb779d5


Ignore:
Timestamp:
Oct 9, 2023, 12:55:09 PM (7 months ago)
Author:
caparsons <caparson@…>
Branches:
master
Children:
26dfce5
Parents:
0d49efb
Message:

Implemented corun statement

Location:
src
Files:
2 added
14 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Convert.cpp

    r0d49efb reb779d5  
    650650        }
    651651
     652    const ast::Stmt * visit( const ast::CorunStmt * node ) override final {
     653        // There is no old-AST CorunStmt, so this should never be called.
     654                assert( !node );
     655                return nullptr;
     656        }
     657
    652658        TypeSubstitution * convertTypeSubstitution(const ast::TypeSubstitution * src) {
    653659
  • src/AST/Fwd.hpp

    r0d49efb reb779d5  
    6767class ImplicitCtorDtorStmt;
    6868class MutexStmt;
     69class CorunStmt;
    6970
    7071class Expr;
  • src/AST/Node.cpp

    r0d49efb reb779d5  
    192192template class ast::ptr_base< ast::MutexStmt, ast::Node::ref_type::weak >;
    193193template class ast::ptr_base< ast::MutexStmt, ast::Node::ref_type::strong >;
     194template class ast::ptr_base< ast::CorunStmt, ast::Node::ref_type::weak >;
     195template class ast::ptr_base< ast::CorunStmt, ast::Node::ref_type::strong >;
    194196template class ast::ptr_base< ast::Expr, ast::Node::ref_type::weak >;
    195197template class ast::ptr_base< ast::Expr, ast::Node::ref_type::strong >;
  • src/AST/Pass.hpp

    r0d49efb reb779d5  
    171171        const ast::Stmt *             visit( const ast::ImplicitCtorDtorStmt * ) override final;
    172172        const ast::Stmt *             visit( const ast::MutexStmt            * ) override final;
     173    const ast::Stmt *             visit( const ast::CorunStmt            * ) override final;
    173174        const ast::Expr *             visit( const ast::ApplicationExpr      * ) override final;
    174175        const ast::Expr *             visit( const ast::UntypedExpr          * ) override final;
  • src/AST/Pass.impl.hpp

    r0d49efb reb779d5  
    11211121
    11221122//--------------------------------------------------------------------------
     1123// CorunStmt
     1124template< typename core_t >
     1125const ast::Stmt * ast::Pass< core_t >::visit( const ast::CorunStmt * node ) {
     1126        VISIT_START( node );
     1127
     1128        if ( __visit_children() ) {
     1129                maybe_accept( node, &CorunStmt::stmt );
     1130        }
     1131
     1132        VISIT_END( Stmt, node );
     1133}
     1134
     1135//--------------------------------------------------------------------------
    11231136// ApplicationExpr
    11241137template< typename core_t >
  • src/AST/Print.cpp

    r0d49efb reb779d5  
    922922        }
    923923
     924    virtual const ast::Stmt * visit( const ast::CorunStmt * node ) override final {
     925                os << "Corun Statement" << endl;
     926                os << indent << "... with Statement: ";
     927                ++indent;
     928                safe_print( node->stmt );
     929                --indent;
     930                os << endl;
     931
     932                return node;
     933        }
     934
    924935        virtual const ast::Expr * visit( const ast::ApplicationExpr * node ) override final {
    925936                ++indent;
  • src/AST/Stmt.hpp

    r0d49efb reb779d5  
    532532};
    533533
     534// Corun Statement
     535class CorunStmt final : public Stmt {
     536  public:
     537        ptr<Stmt> stmt;
     538
     539        CorunStmt( const CodeLocation & loc, const Stmt * stmt, const std::vector<Label> && labels = {} )
     540                : Stmt(loc, std::move(labels)), stmt(stmt) {}
     541
     542        const Stmt * accept( Visitor & v ) const override { return v.visit( this ); }
     543  private:
     544        CorunStmt * clone() const override { return new CorunStmt{ *this }; }
     545        MUTATE_FRIEND
     546};
     547
    534548} // namespace ast
    535549
  • src/AST/Visitor.hpp

    r0d49efb reb779d5  
    5959    virtual const ast::Stmt *             visit( const ast::ImplicitCtorDtorStmt * ) = 0;
    6060    virtual const ast::Stmt *             visit( const ast::MutexStmt            * ) = 0;
     61    virtual const ast::Stmt *             visit( const ast::CorunStmt            * ) = 0;
    6162    virtual const ast::Expr *             visit( const ast::ApplicationExpr      * ) = 0;
    6263    virtual const ast::Expr *             visit( const ast::UntypedExpr          * ) = 0;
  • src/Common/CodeLocationTools.cpp

    r0d49efb reb779d5  
    137137    macro(ImplicitCtorDtorStmt, Stmt) \
    138138    macro(MutexStmt, Stmt) \
     139    macro(CorunStmt, Stmt) \
    139140    macro(ApplicationExpr, Expr) \
    140141    macro(UntypedExpr, Expr) \
  • src/Concurrency/module.mk

    r0d49efb reb779d5  
    1818        Concurrency/Actors.cpp \
    1919        Concurrency/Actors.hpp \
     20        Concurrency/Corun.cpp \
     21        Concurrency/Corun.hpp \
    2022        Concurrency/KeywordsNew.cpp \
    2123        Concurrency/Keywords.cc \
  • src/Parser/StatementNode.cc

    r0d49efb reb779d5  
    498498} // build_mutex
    499499
     500ast::Stmt * build_corun( const CodeLocation & location, StatementNode * stmt ) {
     501        ast::Stmt * body = maybeMoveBuild( stmt );
     502        return new ast::CorunStmt( location, body );
     503} // build_corun
     504
    500505// Local Variables: //
    501506// tab-width: 4 //
  • src/Parser/StatementNode.h

    r0d49efb reb779d5  
    105105ast::Stmt * build_with( const CodeLocation &, ExpressionNode * exprs, StatementNode * stmt );
    106106ast::Stmt * build_mutex( const CodeLocation &, ExpressionNode * exprs, StatementNode * stmt );
     107ast::Stmt * build_corun( const CodeLocation &, StatementNode * stmt );
  • src/Parser/parser.yy

    r0d49efb reb779d5  
    17211721corun_statement:
    17221722        CORUN statement
    1723                 { SemanticError( yylloc, "corun statement is currently unimplemented." ); $$ = nullptr; }
     1723                { $$ = new StatementNode( build_corun( yylloc, $2 ) ); }
    17241724        ;
    17251725
  • src/main.cc

    r0d49efb reb779d5  
    4646#include "Common/utility.h"                 // for deleteAll, filter, printAll
    4747#include "Concurrency/Actors.hpp"           // for implementActors
     48#include "Concurrency/Corun.hpp"            // for implementCorun
    4849#include "Concurrency/Keywords.h"           // for implementMutex, implement...
    4950#include "Concurrency/Waitfor.h"            // for generateWaitfor
     
    345346                PASS( "Implement Concurrent Keywords", Concurrency::implementKeywords, transUnit );
    346347                PASS( "Fix Unique Ids", Validate::fixUniqueIds, transUnit );
     348        PASS( "Implement Corun", Concurrency::implementCorun, transUnit );
    347349                PASS( "Hoist Control Declarations", ControlStruct::hoistControlDecls, transUnit );
    348350
Note: See TracChangeset for help on using the changeset viewer.