Changeset 8cb149f for src/AST/Stmt.hpp
- Timestamp:
- Feb 2, 2022, 2:50:46 PM (4 years ago)
- Branches:
- ADT, ast-experimental, enum, forall-pointer-decay, master, pthread-emulation, qualifiedEnum
- Children:
- 21a99cc
- Parents:
- 4de48c5 (diff), 4e7171f (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)links above to see all the changes relative to each parent. - File:
-
- 1 edited
-
src/AST/Stmt.hpp (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Stmt.hpp
r4de48c5 r8cb149f 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 ); }
Note:
See TracChangeset
for help on using the changeset viewer.