- Timestamp:
- Feb 1, 2022, 8:22:12 PM (4 years ago)
- Branches:
- ADT, ast-experimental, enum, forall-pointer-decay, master, pthread-emulation, qualifiedEnum
- Children:
- fde0a58
- Parents:
- 729c991
- Location:
- src/AST
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Convert.cpp
r729c991 r3b0bc16 9 9 // Author : Thierry Delisle 10 10 // Created On : Thu May 09 15::37::05 2019 11 // Last Modified By : Andrew Beach12 // Last Modified On : Wed Jul 14 16:15:00 202113 // Update Count : 3 711 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Feb 1 16:27:15 2022 13 // Update Count : 39 14 14 // 15 15 … … 393 393 auto stmt = new IfStmt( 394 394 get<Expression>().accept1( node->cond ), 395 get<Statement>().accept1( node->then Part),396 get<Statement>().accept1( node->else Part),395 get<Statement>().accept1( node->then ), 396 get<Statement>().accept1( node->else_ ), 397 397 get<Statement>().acceptL( node->inits ) 398 398 ); … … 419 419 } 420 420 421 const ast::Stmt * visit( const ast::While Stmt * node ) override final {421 const ast::Stmt * visit( const ast::WhileDoStmt * node ) override final { 422 422 if ( inCache( node ) ) return nullptr; 423 423 auto inits = get<Statement>().acceptL( node->inits ); 424 auto stmt = new While Stmt(424 auto stmt = new WhileDoStmt( 425 425 get<Expression>().accept1( node->cond ), 426 426 get<Statement>().accept1( node->body ), … … 1872 1872 old->location, 1873 1873 GET_ACCEPT_1(condition, Expr), 1874 GET_ACCEPT_1(then Part, Stmt),1875 GET_ACCEPT_1(else Part, Stmt),1874 GET_ACCEPT_1(then, Stmt), 1875 GET_ACCEPT_1(else_, Stmt), 1876 1876 GET_ACCEPT_V(initialization, Stmt), 1877 1877 GET_LABELS_V(old->labels) … … 1902 1902 } 1903 1903 1904 virtual void visit( const While Stmt * old ) override final {1904 virtual void visit( const WhileDoStmt * old ) override final { 1905 1905 if ( inCache( old ) ) return; 1906 this->node = new ast::While Stmt(1906 this->node = new ast::WhileDoStmt( 1907 1907 old->location, 1908 1908 GET_ACCEPT_1(condition, Expr), -
src/AST/Fwd.hpp
r729c991 r3b0bc16 10 10 // Created On : Wed May 8 16:05:00 2019 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Mar 12 18:37:39 202113 // Update Count : 412 // Last Modified On : Tue Feb 1 09:08:33 2022 13 // Update Count : 5 14 14 // 15 15 … … 44 44 class DirectiveStmt; 45 45 class IfStmt; 46 class While Stmt;46 class WhileDoStmt; 47 47 class ForStmt; 48 48 class SwitchStmt; -
src/AST/Node.cpp
r729c991 r3b0bc16 10 10 // Created On : Thu May 16 14:16:00 2019 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Mar 12 18:25:06 202113 // Update Count : 212 // Last Modified On : Tue Feb 1 09:09:39 2022 13 // Update Count : 3 14 14 // 15 15 … … 146 146 template class ast::ptr_base< ast::IfStmt, ast::Node::ref_type::weak >; 147 147 template class ast::ptr_base< ast::IfStmt, ast::Node::ref_type::strong >; 148 template class ast::ptr_base< ast::While Stmt, ast::Node::ref_type::weak >;149 template class ast::ptr_base< ast::While Stmt, ast::Node::ref_type::strong >;148 template class ast::ptr_base< ast::WhileDoStmt, ast::Node::ref_type::weak >; 149 template class ast::ptr_base< ast::WhileDoStmt, ast::Node::ref_type::strong >; 150 150 template class ast::ptr_base< ast::ForStmt, ast::Node::ref_type::weak >; 151 151 template class ast::ptr_base< ast::ForStmt, ast::Node::ref_type::strong >; -
src/AST/Pass.hpp
r729c991 r3b0bc16 146 146 const ast::Stmt * visit( const ast::DirectiveStmt * ) override final; 147 147 const ast::Stmt * visit( const ast::IfStmt * ) override final; 148 const ast::Stmt * visit( const ast::While Stmt* ) override final;148 const ast::Stmt * visit( const ast::WhileDoStmt * ) override final; 149 149 const ast::Stmt * visit( const ast::ForStmt * ) override final; 150 150 const ast::Stmt * visit( const ast::SwitchStmt * ) override final; -
src/AST/Pass.impl.hpp
r729c991 r3b0bc16 756 756 maybe_accept( node, &IfStmt::inits ); 757 757 maybe_accept( node, &IfStmt::cond ); 758 maybe_accept_as_compound( node, &IfStmt::then Part);759 maybe_accept_as_compound( node, &IfStmt::else Part);758 maybe_accept_as_compound( node, &IfStmt::then ); 759 maybe_accept_as_compound( node, &IfStmt::else_ ); 760 760 } 761 761 … … 764 764 765 765 //-------------------------------------------------------------------------- 766 // While Stmt767 template< typename core_t > 768 const ast::Stmt * ast::Pass< core_t >::visit( const ast::While Stmt * node ) {766 // WhileDoStmt 767 template< typename core_t > 768 const ast::Stmt * ast::Pass< core_t >::visit( const ast::WhileDoStmt * node ) { 769 769 VISIT_START( node ); 770 770 … … 772 772 // while statements introduce a level of scope (for the initialization) 773 773 guard_symtab guard { *this }; 774 maybe_accept( node, &While Stmt::inits );775 maybe_accept( node, &While Stmt::cond );776 maybe_accept_as_compound( node, &While Stmt::body );774 maybe_accept( node, &WhileDoStmt::inits ); 775 maybe_accept( node, &WhileDoStmt::cond ); 776 maybe_accept_as_compound( node, &WhileDoStmt::body ); 777 777 } 778 778 -
src/AST/Print.cpp
r729c991 r3b0bc16 511 511 ++indent; 512 512 os << indent; 513 safe_print( node->then Part);514 --indent; 515 516 if ( node->else Part!= 0 ) {513 safe_print( node->then ); 514 --indent; 515 516 if ( node->else_ != 0 ) { 517 517 os << indent << "... else:" << endl; 518 518 ++indent; 519 519 os << indent; 520 node->else Part->accept( *this );520 node->else_->accept( *this ); 521 521 --indent; 522 522 } // if … … 524 524 } 525 525 526 virtual const ast::Stmt * visit( const ast::While Stmt * node ) override final {526 virtual const ast::Stmt * visit( const ast::WhileDoStmt * node ) override final { 527 527 if ( node->isDoWhile ) { os << "Do-"; } 528 528 os << "While on condition:" << endl; -
src/AST/Stmt.hpp
r729c991 r3b0bc16 10 10 // Created On : Wed May 8 13:00:00 2019 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Mon Jan 31 22:38:53202213 // Update Count : 1212 // Last Modified On : Tue Feb 1 17:44:46 2022 13 // Update Count : 24 14 14 // 15 15 … … 42 42 : ParseNode(loc), labels(std::move(labels)) {} 43 43 44 Stmt(const Stmt & o) : ParseNode(o), labels(o.labels) {}44 Stmt(const Stmt & o) : ParseNode(o), labels(o.labels) {} 45 45 46 46 const Stmt * accept( Visitor & v ) const override = 0; … … 56 56 57 57 CompoundStmt(const CodeLocation & loc, std::list<ptr<Stmt>> && ks = {}, 58 std::vector<Label> && labels = {} )58 std::vector<Label> && labels = {} ) 59 59 : Stmt(loc, std::move(labels)), kids(std::move(ks)) {} 60 60 61 CompoundStmt( const CompoundStmt & o );62 CompoundStmt( CompoundStmt && o ) = default;61 CompoundStmt( const CompoundStmt & o ); 62 CompoundStmt( CompoundStmt && o ) = default; 63 63 64 64 void push_back( const Stmt * s ) { kids.emplace_back( s ); } … … 88 88 ptr<Expr> expr; 89 89 90 ExprStmt( const CodeLocation & loc, const Expr* e, std::vector<Label>&& labels = {} )90 ExprStmt( const CodeLocation & loc, const Expr* e, std::vector<Label> && labels = {} ) 91 91 : Stmt(loc, std::move(labels)), expr(e) {} 92 92 … … 139 139 public: 140 140 ptr<Expr> cond; 141 ptr<Stmt> then Part;142 ptr<Stmt> else Part;141 ptr<Stmt> then; 142 ptr<Stmt> else_; 143 143 std::vector<ptr<Stmt>> inits; 144 144 145 IfStmt( const CodeLocation & loc, const Expr * cond, const Stmt * then Part,146 const Stmt * else Part= nullptr, std::vector<ptr<Stmt>> && inits = {},145 IfStmt( const CodeLocation & loc, const Expr * cond, const Stmt * then, 146 const Stmt * else_ = nullptr, std::vector<ptr<Stmt>> && inits = {}, 147 147 std::vector<Label> && labels = {} ) 148 : Stmt(loc, std::move(labels)), cond(cond), then Part(thenPart), elsePart(elsePart),148 : Stmt(loc, std::move(labels)), cond(cond), then(then), else_(else_), 149 149 inits(std::move(inits)) {} 150 150 … … 191 191 192 192 // While loop: while (...) ... else ... or do ... while (...) else ...; 193 class While Stmt final : public Stmt {193 class WhileDoStmt final : public Stmt { 194 194 public: 195 195 ptr<Expr> cond; 196 196 ptr<Stmt> body; 197 ptr<Stmt> else Part;197 ptr<Stmt> else_; 198 198 std::vector<ptr<Stmt>> inits; 199 199 bool isDoWhile; 200 200 201 While Stmt( const CodeLocation & loc, const Expr * cond, const Stmt * body,201 WhileDoStmt( const CodeLocation & loc, const Expr * cond, const Stmt * body, 202 202 std::vector<ptr<Stmt>> && inits, bool isDoWhile = false, std::vector<Label> && labels = {} ) 203 : Stmt(loc, std::move(labels)), cond(cond), body(body), inits(std::move(inits)), isDoWhile(isDoWhile) {} 204 205 const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } 206 private: 207 WhileStmt * clone() const override { return new WhileStmt{ *this }; } 203 : Stmt(loc, std::move(labels)), cond(cond), body(body), else_(nullptr), inits(std::move(inits)), isDoWhile(isDoWhile) {} 204 205 WhileDoStmt( const CodeLocation & loc, const Expr * cond, const Stmt * body, const Stmt * else_, 206 std::vector<ptr<Stmt>> && inits, bool isDoWhile = false, std::vector<Label> && labels = {} ) 207 : Stmt(loc, std::move(labels)), cond(cond), body(body), else_(else_), inits(std::move(inits)), isDoWhile(isDoWhile) {} 208 209 const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } 210 private: 211 WhileDoStmt * clone() const override { return new WhileDoStmt{ *this }; } 208 212 MUTATE_FRIEND 209 213 }; … … 216 220 ptr<Expr> inc; 217 221 ptr<Stmt> body; 218 ptr<Stmt> else Part;222 ptr<Stmt> else_; 219 223 220 224 ForStmt( const CodeLocation & loc, std::vector<ptr<Stmt>> && inits, const Expr * cond, 221 const Expr * inc, const Stmt * body, std::vector<Label> && labels = {} ) 222 : Stmt(loc, std::move(labels)), inits(std::move(inits)), cond(cond), inc(inc), body(body) {} 225 const Expr * inc, const Stmt * body, std::vector<Label> && label = {} ) 226 : Stmt(loc, std::move(label)), inits(std::move(inits)), cond(cond), inc(inc), body(body), else_(nullptr) {} 227 228 ForStmt( const CodeLocation & loc, std::vector<ptr<Stmt>> && inits, const Expr * cond, 229 const Expr * inc, const Stmt * body, const Stmt * else_, std::vector<Label> && labels = {} ) 230 : Stmt(loc, std::move(labels)), inits(std::move(inits)), cond(cond), inc(inc), body(body), else_(else_) {} 223 231 224 232 const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } -
src/AST/Visitor.hpp
r729c991 r3b0bc16 10 10 // Created On : Thr May 9 15:28:00 2019 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Mar 12 18:25:07 202113 // Update Count : 112 // Last Modified On : Tue Feb 1 09:09:34 2022 13 // Update Count : 2 14 14 // 15 15 … … 38 38 virtual const ast::Stmt * visit( const ast::DirectiveStmt * ) = 0; 39 39 virtual const ast::Stmt * visit( const ast::IfStmt * ) = 0; 40 virtual const ast::Stmt * visit( const ast::While Stmt* ) = 0;40 virtual const ast::Stmt * visit( const ast::WhileDoStmt * ) = 0; 41 41 virtual const ast::Stmt * visit( const ast::ForStmt * ) = 0; 42 42 virtual const ast::Stmt * visit( const ast::SwitchStmt * ) = 0;
Note:
See TracChangeset
for help on using the changeset viewer.