Changeset 61255ad for src/SynTree


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

Add WithStmt? SynTree? node

Location:
src/SynTree
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • 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.