Changeset 6cebfef for src/AST


Ignore:
Timestamp:
Aug 13, 2021, 3:58:19 PM (4 years ago)
Author:
caparsons <caparson@…>
Branches:
ADT, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
de52331
Parents:
c9f9d4f
Message:

added mutex stmt monitor

Location:
src/AST
Files:
8 edited

Legend:

Unmodified
Added
Removed
  • src/AST/Convert.cpp

    rc9f9d4f r6cebfef  
    606606        }
    607607
     608        const ast::Stmt * visit( const ast::MutexStmt * node ) override final {
     609                if ( inCache( node ) ) return nullptr;
     610                 auto stmt = new MutexStmt(
     611                        get<Statement>().accept1( node->stmt ),
     612                        get<Expression>().acceptL( node->mutexObjs )
     613                );
     614                return stmtPostamble( stmt, node );
     615        }
     616
    608617        TypeSubstitution * convertTypeSubstitution(const ast::TypeSubstitution * src) {
    609618
     
    21242133        }
    21252134
     2135        virtual void visit( const MutexStmt * old ) override final {
     2136                if ( inCache( old ) ) return;
     2137                this->node = new ast::MutexStmt(
     2138                        old->location,
     2139                        GET_ACCEPT_1(stmt, Stmt),
     2140                        GET_ACCEPT_V(mutexObjs, Expr)
     2141                );
     2142                cache.emplace( old, this->node );
     2143        }
     2144
    21262145        // TypeSubstitution shouldn't exist yet in old.
    21272146        ast::TypeSubstitution * convertTypeSubstitution(const TypeSubstitution * old) {
  • src/AST/Fwd.hpp

    rc9f9d4f r6cebfef  
    6060class NullStmt;
    6161class ImplicitCtorDtorStmt;
     62class MutexStmt;
    6263
    6364class Expr;
  • src/AST/Node.cpp

    rc9f9d4f r6cebfef  
    176176template class ast::ptr_base< ast::ImplicitCtorDtorStmt, ast::Node::ref_type::weak >;
    177177template class ast::ptr_base< ast::ImplicitCtorDtorStmt, ast::Node::ref_type::strong >;
     178template class ast::ptr_base< ast::MutexStmt, ast::Node::ref_type::weak >;
     179template class ast::ptr_base< ast::MutexStmt, ast::Node::ref_type::strong >;
    178180template class ast::ptr_base< ast::Expr, ast::Node::ref_type::weak >;
    179181template class ast::ptr_base< ast::Expr, ast::Node::ref_type::strong >;
  • src/AST/Pass.hpp

    rc9f9d4f r6cebfef  
    162162        const ast::Stmt *             visit( const ast::DeclStmt             * ) override final;
    163163        const ast::Stmt *             visit( const ast::ImplicitCtorDtorStmt * ) override final;
     164        const ast::Stmt *             visit( const ast::MutexStmt            * ) override final;
    164165        const ast::Expr *             visit( const ast::ApplicationExpr      * ) override final;
    165166        const ast::Expr *             visit( const ast::UntypedExpr          * ) override final;
  • src/AST/Pass.impl.hpp

    rc9f9d4f r6cebfef  
    10391039
    10401040//--------------------------------------------------------------------------
     1041// MutexStmt
     1042template< typename core_t >
     1043const ast::Stmt * ast::Pass< core_t >::visit( const ast::MutexStmt * node ) {
     1044        VISIT_START( node );
     1045
     1046        VISIT({
     1047                // mutex statements introduce a level of scope (for the initialization)
     1048                guard_symtab guard { *this };
     1049                maybe_accept( node, &MutexStmt::stmt );
     1050                maybe_accept( node, &MutexStmt::mutexObjs );
     1051        })
     1052
     1053        VISIT_END( Stmt, node );
     1054}
     1055
     1056//--------------------------------------------------------------------------
    10411057// ApplicationExpr
    10421058template< typename core_t >
  • src/AST/Print.cpp

    rc9f9d4f r6cebfef  
    794794                ++indent;
    795795                safe_print( node->callStmt );
     796                --indent;
     797                os << endl;
     798
     799                return node;
     800        }
     801
     802        virtual const ast::Stmt * visit( const ast::MutexStmt * node ) override final {
     803                os << "Mutex Statement" << endl;
     804                os << indent << "... with Mutex Parameters: ";
     805                ++indent;
     806                printAll( node->mutexObjs );
     807                --indent;
     808                os << indent << "... with Statement: ";
     809                ++indent;
     810                safe_print( node->stmt );
    796811                --indent;
    797812                os << endl;
  • src/AST/Stmt.hpp

    rc9f9d4f r6cebfef  
    426426};
    427427
     428/// Mutex Statement
     429class MutexStmt final : public Stmt {
     430public:
     431        ptr<Stmt> stmt;
     432        std::vector<ptr<Expr>> mutexObjs;
     433
     434        MutexStmt( const CodeLocation & loc, const Stmt * stmt,
     435                std::vector<ptr<Expr>> && mutexes, std::vector<Label> && labels = {} )
     436        : Stmt(loc, std::move(labels)), stmt(stmt), mutexObjs(std::move(mutexes)) {}
     437
     438        const Stmt * accept( Visitor & v ) const override { return v.visit( this ); }
     439private:
     440        MutexStmt * clone() const override { return new MutexStmt{ *this }; }
     441        MUTATE_FRIEND
     442};
     443
    428444}
    429445
  • src/AST/Visitor.hpp

    rc9f9d4f r6cebfef  
    5454    virtual const ast::Stmt *             visit( const ast::DeclStmt             * ) = 0;
    5555    virtual const ast::Stmt *             visit( const ast::ImplicitCtorDtorStmt * ) = 0;
     56    virtual const ast::Stmt *             visit( const ast::MutexStmt            * ) = 0;
    5657    virtual const ast::Expr *             visit( const ast::ApplicationExpr      * ) = 0;
    5758    virtual const ast::Expr *             visit( const ast::UntypedExpr          * ) = 0;
Note: See TracChangeset for help on using the changeset viewer.