Changeset 61255ad


Ignore:
Timestamp:
Nov 30, 2017, 3:58:26 PM (4 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, deferred_resn, demangler, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, resolv-new, with_gc
Children:
a378ca7
Parents:
4429b04
Message:

Add WithStmt? SynTree? node

Location:
src
Files:
9 edited

Legend:

Unmodified
Added
Removed
  • src/Common/PassVisitor.h

    r4429b04 r61255ad  
    8181        virtual void visit( FinallyStmt * finallyStmt ) override final;
    8282        virtual void visit( WaitForStmt * waitforStmt ) override final;
     83        virtual void visit( WithStmt * withStmt ) override final;
    8384        virtual void visit( NullStmt * nullStmt ) override final;
    8485        virtual void visit( DeclStmt * declStmt ) override final;
     
    172173        virtual Statement * mutate( FinallyStmt * finallyStmt ) override final;
    173174        virtual Statement * mutate( WaitForStmt * waitforStmt ) override final;
     175        virtual Statement * mutate( WithStmt * withStmt ) override final;
    174176        virtual NullStmt * mutate( NullStmt * nullStmt ) override final;
    175177        virtual Statement * mutate( DeclStmt * declStmt ) override final;
  • src/Common/PassVisitor.impl.h

    r4429b04 r61255ad  
    988988// NullStmt
    989989template< typename pass_type >
     990void PassVisitor< pass_type >::visit( WithStmt * node ) {
     991        VISIT_BODY( node );
     992}
     993
     994template< typename pass_type >
     995Statement * PassVisitor< pass_type >::mutate( WithStmt * node ) {
     996        MUTATE_BODY( Statement, node );
     997}
     998
     999//--------------------------------------------------------------------------
     1000// NullStmt
     1001template< typename pass_type >
    9901002void PassVisitor< pass_type >::visit( NullStmt * node ) {
    9911003        VISIT_BODY( node );
  • src/SynTree/Mutator.cc

    r4429b04 r61255ad  
    203203}
    204204
     205Statement * Mutator::mutate( WithStmt * withStmt ) {
     206        mutateAll( withStmt->exprs, *this );
     207        withStmt->stmt = maybeMutate( withStmt->stmt, *this );
     208        return withStmt;
     209}
     210
    205211NullStmt * Mutator::mutate( NullStmt *nullStmt ) {
    206212        return nullStmt;
  • src/SynTree/Mutator.h

    r4429b04 r61255ad  
    5050        virtual Statement * mutate( FinallyStmt * catchStmt );
    5151        virtual Statement * mutate( WaitForStmt * waitforStmt );
     52        virtual Statement * mutate( WithStmt * withStmt );
    5253        virtual NullStmt * mutate( NullStmt * nullStmt );
    5354        virtual Statement * mutate( DeclStmt * declStmt );
  • src/SynTree/Statement.cc

    r4429b04 r61255ad  
    455455}
    456456
     457
     458WithStmt::WithStmt( const std::list< Expression * > & exprs, Statement * stmt ) : Statement( std::list<Label>() ), exprs( exprs ), stmt( stmt ) {}
     459WithStmt::WithStmt( const WithStmt & other ) : Statement( other ), stmt( maybeClone( other.stmt ) ) {
     460        cloneAll( other.exprs, exprs );
     461}
     462WithStmt::~WithStmt() {
     463        deleteAll( exprs );
     464        delete stmt;
     465}
     466
     467void WithStmt::print( std::ostream & os, Indenter indent ) const {
     468        os << "With statement" << endl;
     469        os << indent << "... with statement:" << endl << indent+1;
     470        stmt->print( os, indent+1 );
     471}
     472
     473
    457474NullStmt::NullStmt( std::list<Label> labels ) : Statement( labels ) {}
    458475NullStmt::NullStmt() : Statement( std::list<Label>() ) {}
  • src/SynTree/Statement.h

    r4429b04 r61255ad  
    432432};
    433433
     434class WithStmt : public Statement {
     435public:
     436        std::list< Expression * > exprs;
     437        Statement * stmt;
     438
     439        WithStmt( const std::list< Expression * > & exprs, Statement * stmt );
     440        WithStmt( const WithStmt & other );
     441        virtual ~WithStmt();
     442
     443        virtual WithStmt * clone() const override { return new WithStmt( *this ); }
     444        virtual void accept( Visitor & v ) override { v.visit( this ); }
     445        virtual Statement * acceptMutator( Mutator & m )  override { return m.mutate( this ); }
     446        virtual void print( std::ostream & os, Indenter indent = {} ) const override;
     447};
     448
    434449
    435450// represents a declaration that occurs as part of a compound statement
  • src/SynTree/SynTree.h

    r4429b04 r61255ad  
    5555class FinallyStmt;
    5656class WaitForStmt;
     57class WithStmt;
    5758class NullStmt;
    5859class DeclStmt;
  • src/SynTree/Visitor.cc

    r4429b04 r61255ad  
    174174}
    175175
    176 void Visitor::visit( __attribute__((unused)) NullStmt *nullStmt ) {
     176void Visitor::visit( WithStmt * withStmt ) {
     177        acceptAll( withStmt->exprs, *this );
     178        maybeAccept( withStmt->stmt, *this );
     179}
     180
     181void Visitor::visit( NullStmt * ) {
    177182}
    178183
  • src/SynTree/Visitor.h

    r4429b04 r61255ad  
    5252        virtual void visit( FinallyStmt * finallyStmt );
    5353        virtual void visit( WaitForStmt * waitforStmt );
     54        virtual void visit( WithStmt * withStmt );
    5455        virtual void visit( NullStmt * nullStmt );
    5556        virtual void visit( DeclStmt * declStmt );
Note: See TracChangeset for help on using the changeset viewer.