Changeset 6cebfef for src/SynTree


Ignore:
Timestamp:
Aug 13, 2021, 3:58:19 PM (3 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/SynTree
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • src/SynTree/Mutator.h

    rc9f9d4f r6cebfef  
    5858        virtual Statement * mutate( DeclStmt * declStmt ) = 0;
    5959        virtual Statement * mutate( ImplicitCtorDtorStmt * impCtorDtorStmt ) = 0;
     60        virtual Statement * mutate( MutexStmt * mutexStmt ) = 0;
    6061
    6162        virtual Expression * mutate( ApplicationExpr * applicationExpr ) = 0;
  • src/SynTree/Statement.cc

    rc9f9d4f r6cebfef  
    565565}
    566566
     567MutexStmt::MutexStmt( Statement * stmt, std::list<Expression *> mutexObjs )
     568        : Statement(), stmt( stmt ), mutexObjs( mutexObjs ) { }
     569
     570MutexStmt::MutexStmt( const MutexStmt & other ) : Statement( other ), stmt( maybeClone( other.stmt ) ) {
     571        cloneAll( other.mutexObjs, mutexObjs );
     572}
     573
     574MutexStmt::~MutexStmt() {
     575        deleteAll( mutexObjs );
     576        delete stmt;
     577}
     578
     579void MutexStmt::print( std::ostream & os, Indenter indent ) const {
     580        os << "Mutex Statement" << endl;
     581        os << indent << "... with Expressions: " << endl;
     582        for (auto * obj : mutexObjs) {
     583                os << indent+1;
     584                obj->print( os, indent+1);
     585                os << endl;
     586        }
     587        os << indent << "... with Statement: " << endl << indent+1;
     588        stmt->print( os, indent+1 );
     589}
     590
    567591// Local Variables: //
    568592// tab-width: 4 //
  • src/SynTree/Statement.h

    rc9f9d4f r6cebfef  
    535535};
    536536
     537class MutexStmt : public Statement {
     538  public:
     539        Statement * stmt;
     540        std::list<Expression *> mutexObjs; // list of mutex objects to acquire
     541
     542        MutexStmt( Statement * stmt, std::list<Expression *> mutexObjs );
     543        MutexStmt( const MutexStmt & other );
     544        virtual ~MutexStmt();
     545
     546        virtual MutexStmt * clone() const override { return new MutexStmt( *this ); }
     547        virtual void accept( Visitor & v ) override { v.visit( this ); }
     548        virtual void accept( Visitor & v ) const override { v.visit( this ); }
     549        virtual Statement * acceptMutator( Mutator & m )  override { return m.mutate( this ); }
     550        virtual void print( std::ostream & os, Indenter indent = {} ) const override;
     551};
     552
    537553// Local Variables: //
    538554// tab-width: 4 //
  • src/SynTree/SynTree.h

    rc9f9d4f r6cebfef  
    6262class NullStmt;
    6363class ImplicitCtorDtorStmt;
     64class MutexStmt;
    6465
    6566class Expression;
  • src/SynTree/Visitor.h

    rc9f9d4f r6cebfef  
    9292        virtual void visit( ImplicitCtorDtorStmt * node ) { visit( const_cast<const ImplicitCtorDtorStmt *>(node) ); }
    9393        virtual void visit( const ImplicitCtorDtorStmt * impCtorDtorStmt ) = 0;
     94        virtual void visit( MutexStmt * node ) { visit( const_cast<const MutexStmt *>(node) ); }
     95        virtual void visit( const MutexStmt * mutexStmt ) = 0;
    9496
    9597        virtual void visit( ApplicationExpr * node ) { visit( const_cast<const ApplicationExpr *>(node) ); }
Note: See TracChangeset for help on using the changeset viewer.