Changeset 4e06c1e for src/SynTree
- Timestamp:
- Jul 12, 2016, 6:34:10 PM (8 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- e4d3ceb
- Parents:
- 6e4b913
- Location:
- src/SynTree
- Files:
-
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/AddStmtVisitor.cc
r6e4b913 r4e06c1e 9 9 // Author : Rob Schluntz 10 10 // Created On : Wed Jun 22 12:11:17 2016 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Wed Jun 22 12:16:29 201613 // Update Count : 1 111 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Jul 12 17:49:59 2016 13 // Update Count : 12 14 14 // 15 15 … … 75 75 } 76 76 77 void AddStmtVisitor::visit(ChooseStmt *switchStmt) {78 visitStatementList( switchStmt->get_branches() );79 maybeAccept( switchStmt->get_condition(), *this );80 }81 82 77 void AddStmtVisitor::visit(CaseStmt *caseStmt) { 83 78 visitStatementList( caseStmt->get_statements() ); -
src/SynTree/AddStmtVisitor.h
r6e4b913 r4e06c1e 9 9 // Author : Rob Schluntz 10 10 // Created On : Wed Jun 22 12:05:48 2016 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Wed Jun 22 12:12:05201613 // Update Count : 711 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Jul 12 17:50:32 2016 13 // Update Count : 8 14 14 // 15 15 … … 32 32 virtual void visit(ForStmt *forStmt); 33 33 virtual void visit(SwitchStmt *switchStmt); 34 virtual void visit(ChooseStmt *chooseStmt);35 34 virtual void visit(CaseStmt *caseStmt); 36 35 virtual void visit(CatchStmt *catchStmt); -
src/SynTree/Mutator.cc
r6e4b913 r4e06c1e 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Wed Apr 27 17:07:29 201613 // Update Count : 1 611 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Jul 12 17:51:19 2016 13 // Update Count : 17 14 14 // 15 15 … … 130 130 } 131 131 132 Statement *Mutator::mutate( ChooseStmt *switchStmt ) {133 switchStmt->set_condition( maybeMutate( switchStmt->get_condition(), *this ) );134 mutateAll( switchStmt->get_branches(), *this );135 return switchStmt;136 }137 138 Statement *Mutator::mutate( FallthruStmt *fallthruStmt ) {139 return fallthruStmt;140 }141 142 132 Statement *Mutator::mutate( CaseStmt *caseStmt ) { 143 133 caseStmt->set_condition( maybeMutate( caseStmt->get_condition(), *this ) ); -
src/SynTree/Mutator.h
r6e4b913 r4e06c1e 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : T hu Apr 14 15:32:00201613 // Update Count : 1 011 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Jul 12 17:51:43 2016 13 // Update Count : 11 14 14 // 15 15 #include <cassert> … … 42 42 virtual Statement* mutate( ForStmt *forStmt ); 43 43 virtual Statement* mutate( SwitchStmt *switchStmt ); 44 virtual Statement* mutate( ChooseStmt *chooseStmt );45 virtual Statement* mutate( FallthruStmt *fallthruStmt );46 44 virtual Statement* mutate( CaseStmt *caseStmt ); 47 45 virtual Statement* mutate( BranchStmt *branchStmt ); -
src/SynTree/Statement.cc
r6e4b913 r4e06c1e 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : T hu May 12 13:33:18201613 // Update Count : 5 411 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Jul 12 17:52:32 2016 13 // Update Count : 55 14 14 // 15 15 … … 206 206 for ( i = stmts.begin(); i != stmts.end(); i++) 207 207 (*i )->print( os, indent + 4 ); 208 }209 210 //ChooseStmt::ChooseStmt( std::list<Label> labels, Expression *condition, Statement *body ) {}211 ChooseStmt::ChooseStmt( std::list<Label> _labels, Expression * _condition, std::list<Statement *> &_branches ):212 Statement( _labels ), condition( _condition ), branches( _branches ) {213 }214 215 ChooseStmt::ChooseStmt( const ChooseStmt & other ):216 Statement( other ), condition( maybeClone( other.condition ) ) {217 cloneAll( other.branches, branches );218 }219 220 ChooseStmt::~ChooseStmt() {221 delete condition;222 }223 224 void ChooseStmt::add_case( CaseStmt *c ) {}225 226 void ChooseStmt::print( std::ostream &os, int indent ) const {227 os << "Choose on condition: ";228 condition->print( os );229 os << endl;230 231 // branches232 std::list<Statement *>::const_iterator i;233 for ( i = branches.begin(); i != branches.end(); i++)234 (*i )->print( os, indent + 4 );235 236 //for_each( branches.begin(), branches.end(), mem_fun( bind1st(&Statement::print ), os ));237 }238 239 void FallthruStmt::print( std::ostream &os, int indent ) const {240 os << string( indent, ' ' ) << "Fall-through statement" << endl;241 208 } 242 209 -
src/SynTree/Statement.h
r6e4b913 r4e06c1e 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Wed Dec 09 14:09:24 201513 // Update Count : 4 611 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Jul 12 17:53:29 2016 13 // Update Count : 47 14 14 // 15 15 … … 149 149 }; 150 150 151 class ChooseStmt : public Statement {152 public:153 ChooseStmt( std::list<Label> labels, Expression *condition, std::list<Statement *> &branches );154 ChooseStmt( const ChooseStmt &other );155 virtual ~ChooseStmt();156 157 Expression *get_condition() { return condition; }158 void set_condition( Expression *newValue ) { condition = newValue; }159 160 std::list<Statement *>& get_branches() { return branches; }161 void add_case( CaseStmt * );162 163 virtual void accept( Visitor &v ) { v.visit( this ); }164 virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }165 166 virtual ChooseStmt *clone() const { return new ChooseStmt( *this ); }167 virtual void print( std::ostream &os, int indent = 0 ) const;168 private:169 Expression *condition;170 std::list<Statement *> branches; // should be list of CaseStmt171 };172 173 class FallthruStmt : public Statement {174 public:175 FallthruStmt( std::list<Label> labels ) : Statement( labels ) { }176 177 virtual void accept( Visitor &v ) { v.visit( this ); }178 virtual Statement *acceptMutator( Mutator &m ) { return m.mutate( this ); }179 180 virtual FallthruStmt *clone() const { return new FallthruStmt( *this ); }181 virtual void print( std::ostream &os, int indent = 0 ) const;182 };183 184 151 class CaseStmt : public Statement { 185 152 public: -
src/SynTree/SynTree.h
r6e4b913 r4e06c1e 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : T hu Apr 14 15:31:36201613 // Update Count : 511 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Jul 12 17:54:02 2016 13 // Update Count : 6 14 14 // 15 15 … … 45 45 class ForStmt; 46 46 class SwitchStmt; 47 class ChooseStmt;48 class FallthruStmt;49 47 class CaseStmt; 50 48 class BranchStmt; -
src/SynTree/Visitor.cc
r6e4b913 r4e06c1e 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : Wed Apr 27 17:07:40201613 // Update Count : 1 811 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Jul 12 17:54:39 2016 13 // Update Count : 19 14 14 // 15 15 … … 112 112 } 113 113 114 void Visitor::visit( ChooseStmt *switchStmt ) {115 maybeAccept( switchStmt->get_condition(), *this );116 acceptAll( switchStmt->get_branches(), *this );117 }118 119 void Visitor::visit( FallthruStmt *fallthruStmt ) {}120 121 114 void Visitor::visit( CaseStmt *caseStmt ) { 122 115 maybeAccept( caseStmt->get_condition(), *this ); -
src/SynTree/Visitor.h
r6e4b913 r4e06c1e 9 9 // Author : Richard C. Bilson 10 10 // Created On : Mon May 18 07:44:20 2015 11 // Last Modified By : Rob Schluntz12 // Last Modified On : T hu Apr 14 15:30:58201613 // Update Count : 711 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Jul 12 17:55:09 2016 13 // Update Count : 8 14 14 // 15 15 … … 42 42 virtual void visit( ForStmt *forStmt ); 43 43 virtual void visit( SwitchStmt *switchStmt ); 44 virtual void visit( ChooseStmt *switchStmt );45 virtual void visit( FallthruStmt *switchStmt );46 44 virtual void visit( CaseStmt *caseStmt ); 47 45 virtual void visit( BranchStmt *branchStmt );
Note: See TracChangeset
for help on using the changeset viewer.