Changes in src/AST/Stmt.hpp [3b0bc16:89a5a1f]
- File:
-
- 1 edited
-
src/AST/Stmt.hpp (modified) (7 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Stmt.hpp
r3b0bc16 r89a5a1f 10 10 // Created On : Wed May 8 13:00:00 2019 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Feb 1 17:44:46202213 // Update Count : 2412 // Last Modified On : Mon Jan 31 22:38:53 2022 13 // Update Count : 12 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 ;142 ptr<Stmt> else _;141 ptr<Stmt> thenPart; 142 ptr<Stmt> elsePart; 143 143 std::vector<ptr<Stmt>> inits; 144 144 145 IfStmt( const CodeLocation & loc, const Expr * cond, const Stmt * then ,146 const Stmt * else _= nullptr, std::vector<ptr<Stmt>> && inits = {},145 IfStmt( const CodeLocation & loc, const Expr * cond, const Stmt * thenPart, 146 const Stmt * elsePart = nullptr, std::vector<ptr<Stmt>> && inits = {}, 147 147 std::vector<Label> && labels = {} ) 148 : Stmt(loc, std::move(labels)), cond(cond), then (then), else_(else_),148 : Stmt(loc, std::move(labels)), cond(cond), thenPart(thenPart), elsePart(elsePart), 149 149 inits(std::move(inits)) {} 150 150 … … 191 191 192 192 // While loop: while (...) ... else ... or do ... while (...) else ...; 193 class While DoStmt final : public Stmt {193 class WhileStmt final : public Stmt { 194 194 public: 195 195 ptr<Expr> cond; 196 196 ptr<Stmt> body; 197 ptr<Stmt> else _;197 ptr<Stmt> elsePart; 198 198 std::vector<ptr<Stmt>> inits; 199 199 bool isDoWhile; 200 200 201 While DoStmt( const CodeLocation & loc, const Expr * cond, const Stmt * body,201 WhileStmt( 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), 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 }; } 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 }; } 212 208 MUTATE_FRIEND 213 209 }; … … 220 216 ptr<Expr> inc; 221 217 ptr<Stmt> body; 222 ptr<Stmt> else _;218 ptr<Stmt> elsePart; 223 219 224 220 ForStmt( const CodeLocation & loc, std::vector<ptr<Stmt>> && inits, const Expr * cond, 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_) {} 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) {} 231 223 232 224 const Stmt * accept( Visitor & v ) const override { return v.visit( this ); }
Note:
See TracChangeset
for help on using the changeset viewer.