Changes in / [41b24c8:e61207e7]
- Files:
-
- 2 deleted
- 8 edited
-
libcfa/src/concurrency/coroutine.hfa (modified) (1 diff)
-
src/AST/Convert.cpp (modified) (2 diffs)
-
src/AST/Decl.hpp (modified) (15 diffs)
-
src/AST/Expr.hpp (modified) (24 diffs)
-
src/AST/Init.hpp (modified) (6 diffs)
-
src/AST/Pass.impl.hpp (modified) (1 diff)
-
src/AST/Stmt.hpp (modified) (24 diffs)
-
src/AST/Type.hpp (modified) (22 diffs)
-
src/AST/TypeSubstitution.cpp (deleted)
-
src/AST/TypeSubstitution.hpp (deleted)
Legend:
- Unmodified
- Added
- Removed
-
libcfa/src/concurrency/coroutine.hfa
r41b24c8 re61207e7 49 49 50 50 forall(dtype T | is_coroutine(T)) 51 static inline T &resume(T & cor);51 static inline void resume(T & cor); 52 52 53 53 forall(dtype T | is_coroutine(T)) -
src/AST/Convert.cpp
r41b24c8 re61207e7 135 135 decl->parent = parent; 136 136 decl->body = old->body; 137 decl->param s = params;137 decl->parameters = params; 138 138 decl->members = members; 139 139 decl->extension = old->extension; … … 592 592 593 593 } 594 595 virtual void visit( AttrExpr * ) override final {596 597 assert( 0 );598 }599 594 }; 600 595 -
src/AST/Decl.hpp
r41b24c8 re61207e7 30 30 #include "Parser/ParseNode.h" // for DeclarationNode::Aggregate 31 31 32 // Must be included in *all* AST classes; should be #undef'd at the end of the file33 #define MUTATE_FRIEND template<typename node_t> friend node_t * mutate(const node_t * node);34 35 32 namespace ast { 36 33 … … 58 55 private: 59 56 Decl * clone() const override = 0; 60 MUTATE_FRIEND61 57 }; 62 58 … … 91 87 private: 92 88 DeclWithType * clone() const override = 0; 93 MUTATE_FRIEND94 89 }; 95 90 … … 113 108 private: 114 109 ObjectDecl * clone() const override { return new ObjectDecl{ *this }; } 115 MUTATE_FRIEND 110 111 /// Must be copied in ALL derived classes 112 template<typename node_t> 113 friend node_t * mutate(const node_t * node); 116 114 }; 117 115 … … 137 135 private: 138 136 FunctionDecl * clone() const override { return new FunctionDecl( *this ); } 139 MUTATE_FRIEND 137 138 /// Must be copied in ALL derived classes 139 template<typename node_t> 140 friend node_t * mutate(const node_t * node); 140 141 }; 141 142 … … 156 157 private: 157 158 NamedTypeDecl* clone() const override = 0; 158 MUTATE_FRIEND159 159 }; 160 160 … … 198 198 private: 199 199 TypeDecl * clone() const override { return new TypeDecl{ *this }; } 200 MUTATE_FRIEND 200 201 /// Must be copied in ALL derived classes 202 template<typename node_t> 203 friend node_t * mutate(const node_t * node); 201 204 }; 202 205 … … 213 216 private: 214 217 TypedefDecl * clone() const override { return new TypedefDecl{ *this }; } 215 MUTATE_FRIEND 218 219 /// Must be copied in ALL derived classes 220 template<typename node_t> 221 friend node_t * mutate(const node_t * node); 216 222 }; 217 223 … … 232 238 AggregateDecl* set_body( bool b ) { body = b; return this; } 233 239 234 private:235 AggregateDecl * clone() const override = 0;236 MUTATE_FRIEND237 238 240 protected: 239 241 /// Produces a name for the kind of aggregate … … 258 260 private: 259 261 StructDecl * clone() const override { return new StructDecl{ *this }; } 260 MUTATE_FRIEND 262 263 /// Must be copied in ALL derived classes 264 template<typename node_t> 265 friend node_t * mutate(const node_t * node); 261 266 262 267 std::string typeString() const override { return "struct"; } … … 273 278 private: 274 279 UnionDecl * clone() const override { return new UnionDecl{ *this }; } 275 MUTATE_FRIEND 280 281 /// Must be copied in ALL derived classes 282 template<typename node_t> 283 friend node_t * mutate(const node_t * node); 276 284 277 285 std::string typeString() const override { return "union"; } … … 291 299 private: 292 300 EnumDecl * clone() const override { return new EnumDecl{ *this }; } 293 MUTATE_FRIEND 301 302 /// Must be copied in ALL derived classes 303 template<typename node_t> 304 friend node_t * mutate(const node_t * node); 294 305 295 306 std::string typeString() const override { return "enum"; } … … 309 320 private: 310 321 TraitDecl * clone() const override { return new TraitDecl{ *this }; } 311 MUTATE_FRIEND 322 323 /// Must be copied in ALL derived classes 324 template<typename node_t> 325 friend node_t * mutate(const node_t * node); 312 326 313 327 std::string typeString() const override { return "trait"; } … … 324 338 private: 325 339 AsmDecl *clone() const override { return new AsmDecl( *this ); } 326 MUTATE_FRIEND 340 341 /// Must be copied in ALL derived classes 342 template<typename node_t> 343 friend node_t * mutate(const node_t * node); 327 344 }; 328 345 … … 338 355 private: 339 356 StaticAssertDecl * clone() const override { return new StaticAssertDecl( *this ); } 340 MUTATE_FRIEND 357 358 /// Must be copied in ALL derived classes 359 template<typename node_t> 360 friend node_t * mutate(const node_t * node); 341 361 }; 342 362 343 363 } 344 345 #undef MUTATE_FRIEND346 364 347 365 // Local Variables: // -
src/AST/Expr.hpp
r41b24c8 re61207e7 27 27 #include "Visitor.hpp" 28 28 29 // Must be included in *all* AST classes; should be #undef'd at the end of the file30 #define MUTATE_FRIEND template<typename node_t> friend auto mutate(const node_t * node);31 32 29 namespace ast { 33 30 … … 130 127 private: 131 128 Expr * clone() const override = 0; 132 MUTATE_FRIEND133 129 }; 134 130 … … 145 141 private: 146 142 ApplicationExpr * clone() const override { return new ApplicationExpr{ *this }; } 147 MUTATE_FRIEND148 143 }; 149 144 … … 165 160 private: 166 161 UntypedExpr * clone() const override { return new UntypedExpr{ *this }; } 167 MUTATE_FRIEND168 162 }; 169 163 … … 179 173 private: 180 174 NameExpr * clone() const override { return new NameExpr{ *this }; } 181 MUTATE_FRIEND182 175 }; 183 176 … … 192 185 private: 193 186 AddressExpr * clone() const override { return new AddressExpr{ *this }; } 194 MUTATE_FRIEND195 187 }; 196 188 … … 206 198 private: 207 199 LabelAddressExpr * clone() const override { return new LabelAddressExpr{ *this }; } 208 MUTATE_FRIEND209 200 }; 210 201 … … 226 217 private: 227 218 CastExpr * clone() const override { return new CastExpr{ *this }; } 228 MUTATE_FRIEND229 219 }; 230 220 … … 244 234 private: 245 235 KeywordCastExpr * clone() const override { return new KeywordCastExpr{ *this }; } 246 MUTATE_FRIEND247 236 }; 248 237 … … 258 247 private: 259 248 VirtualCastExpr * clone() const override { return new VirtualCastExpr{ *this }; } 260 MUTATE_FRIEND261 249 }; 262 250 … … 273 261 private: 274 262 UntypedMemberExpr * clone() const override { return new UntypedMemberExpr{ *this }; } 275 MUTATE_FRIEND276 263 }; 277 264 … … 287 274 private: 288 275 MemberExpr * clone() const override { return new MemberExpr{ *this }; } 289 MUTATE_FRIEND290 276 }; 291 277 … … 303 289 private: 304 290 VariableExpr * clone() const override { return new VariableExpr{ *this }; } 305 MUTATE_FRIEND306 291 }; 307 292 … … 347 332 private: 348 333 ConstantExpr * clone() const override { return new ConstantExpr{ *this }; } 349 MUTATE_FRIEND350 334 }; 351 335 … … 363 347 private: 364 348 SizeofExpr * clone() const override { return new SizeofExpr{ *this }; } 365 MUTATE_FRIEND366 349 }; 367 350 … … 379 362 private: 380 363 AlignofExpr * clone() const override { return new AlignofExpr{ *this }; } 381 MUTATE_FRIEND382 364 }; 383 365 … … 394 376 private: 395 377 UntypedOffsetofExpr * clone() const override { return new UntypedOffsetofExpr{ *this }; } 396 MUTATE_FRIEND397 378 }; 398 379 … … 408 389 private: 409 390 OffsetofExpr * clone() const override { return new OffsetofExpr{ *this }; } 410 MUTATE_FRIEND411 391 }; 412 392 … … 421 401 private: 422 402 OffsetPackExpr * clone() const override { return new OffsetPackExpr{ *this }; } 423 MUTATE_FRIEND424 403 }; 425 404 … … 439 418 private: 440 419 LogicalExpr * clone() const override { return new LogicalExpr{ *this }; } 441 MUTATE_FRIEND442 420 }; 443 421 … … 455 433 private: 456 434 ConditionalExpr * clone() const override { return new ConditionalExpr{ *this }; } 457 MUTATE_FRIEND458 435 }; 459 436 … … 470 447 private: 471 448 CommaExpr * clone() const override { return new CommaExpr{ *this }; } 472 MUTATE_FRIEND473 449 }; 474 450 … … 483 459 private: 484 460 TypeExpr * clone() const override { return new TypeExpr{ *this }; } 485 MUTATE_FRIEND486 461 }; 487 462 … … 495 470 496 471 } 497 498 #undef MUTATE_FRIEND499 472 500 473 // Local Variables: // -
src/AST/Init.hpp
r41b24c8 re61207e7 23 23 #include "Visitor.hpp" 24 24 25 // Must be included in *all* AST classes; should be #undef'd at the end of the file26 #define MUTATE_FRIEND template<typename node_t> friend node_t * mutate(const node_t * node);27 28 25 namespace ast { 29 26 … … 43 40 private: 44 41 Designation* clone() const override { return new Designation{ *this }; } 45 MUTATE_FRIEND46 42 }; 47 43 … … 59 55 private: 60 56 Init * clone() const override = 0; 61 MUTATE_FRIEND62 57 }; 63 58 … … 74 69 private: 75 70 SingleInit * clone() const override { return new SingleInit{ *this }; } 76 MUTATE_FRIEND 71 72 /// Must be copied in ALL derived classes 73 template<typename node_t> 74 friend node_t * mutate(const node_t * node); 77 75 }; 78 76 … … 99 97 private: 100 98 ListInit * clone() const override { return new ListInit{ *this }; } 101 MUTATE_FRIEND 99 100 /// Must be copied in ALL derived classes 101 template<typename node_t> 102 friend node_t * mutate(const node_t * node); 102 103 }; 103 104 … … 119 120 private: 120 121 ConstructorInit * clone() const override { return new ConstructorInit{ *this }; } 121 MUTATE_FRIEND 122 123 /// Must be copied in ALL derived classes 124 template<typename node_t> 125 friend node_t * mutate(const node_t * node); 122 126 }; 123 127 124 128 } 125 126 #undef MUTATE_FRIEND127 129 128 130 // Local Variables: // -
src/AST/Pass.impl.hpp
r41b24c8 re61207e7 19 19 #include <type_traits> 20 20 #include <unordered_map> 21 22 #include "AST/TypeSubstitution.hpp"23 21 24 22 #define VISIT_START( node ) \ -
src/AST/Stmt.hpp
r41b24c8 re61207e7 26 26 #include "Common/CodeLocation.h" 27 27 28 // Must be included in *all* AST classes; should be #undef'd at the end of the file29 #define MUTATE_FRIEND template<typename node_t> friend auto mutate(const node_t * node);30 31 28 namespace ast { 32 29 … … 38 35 std::vector<Label> labels; 39 36 40 Stmt( const CodeLocation & loc, std::vector<Label>&& labels = {} )37 Stmt( const CodeLocation& loc, std::vector<Label>&& labels = {} ) 41 38 : ParseNode(loc), labels(std::move(labels)) {} 42 39 43 40 Stmt(const Stmt& o) : ParseNode(o), labels(o.labels) {} 44 41 45 const Stmt * accept( Visitor & v ) const override = 0; 46 private: 47 Stmt * clone() const override = 0; 48 MUTATE_FRIEND 42 const Stmt* accept( Visitor& v ) const override = 0; 43 private: 44 Stmt* clone() const override = 0; 49 45 }; 50 46 … … 54 50 std::list<ptr<Stmt>> kids; 55 51 56 CompoundStmt(const CodeLocation & loc, std::list<ptr<Stmt>>&& ks = {} )52 CompoundStmt(const CodeLocation& loc, std::list<ptr<Stmt>>&& ks = {} ) 57 53 : Stmt(loc), kids(std::move(ks)) {} 58 54 … … 60 56 CompoundStmt( CompoundStmt&& o ) = default; 61 57 62 void push_back( Stmt * s ) { kids.emplace_back( s ); } 63 void push_front( Stmt * s ) { kids.emplace_front( s ); } 64 65 const CompoundStmt * accept( Visitor & v ) const override { return v.visit( this ); } 66 private: 67 CompoundStmt * clone() const override { return new CompoundStmt{ *this }; } 68 MUTATE_FRIEND 58 void push_back( Stmt* s ) { kids.emplace_back( s ); } 59 void push_front( Stmt* s ) { kids.emplace_front( s ); } 60 61 const CompoundStmt* accept( Visitor& v ) const override { return v.visit( this ); } 62 private: 63 CompoundStmt* clone() const override { return new CompoundStmt{ *this }; } 64 65 /// Must be copied in ALL derived classes 66 template<typename node_t> 67 friend node_t * mutate(const node_t * node); 69 68 }; 70 69 … … 72 71 class NullStmt final : public Stmt { 73 72 public: 74 NullStmt( const CodeLocation & loc, std::vector<Label>&& labels = {} )73 NullStmt( const CodeLocation& loc, std::vector<Label>&& labels = {} ) 75 74 : Stmt(loc, std::move(labels)) {} 76 75 77 const NullStmt * accept( Visitor & v ) const override { return v.visit( this ); } 78 private: 79 NullStmt * clone() const override { return new NullStmt{ *this }; } 80 MUTATE_FRIEND 76 const NullStmt* accept( Visitor& v ) const override { return v.visit( this ); } 77 private: 78 NullStmt* clone() const override { return new NullStmt{ *this }; } 79 80 /// Must be copied in ALL derived classes 81 template<typename node_t> 82 friend node_t * mutate(const node_t * node); 81 83 }; 82 84 … … 88 90 ExprStmt( const CodeLocation & loc, const Expr * e ) : Stmt(loc), expr(e) {} 89 91 90 const Stmt * accept( Visitor & v ) const override { return v.visit( this ); }92 const Stmt * accept( Visitor& v ) const override { return v.visit( this ); } 91 93 private: 92 94 ExprStmt * clone() const override { return new ExprStmt{ *this }; } 93 MUTATE_FRIEND 95 96 /// Must be copied in ALL derived classes 97 template<typename node_t> 98 friend node_t * mutate(const node_t * node); 94 99 }; 95 100 … … 102 107 std::vector<Label> gotoLabels; 103 108 104 AsmStmt( const CodeLocation & loc, bool isVolatile, const Expr * instruction,105 std::vector<ptr<Expr>> && output, std::vector<ptr<Expr>>&& input,106 std::vector<ptr<ConstantExpr>> && clobber, std::vector<Label>&& gotoLabels,107 std::vector<Label> && labels = {})109 AsmStmt( const CodeLocation& loc, bool isVolatile, const Expr * instruction, 110 std::vector<ptr<Expr>>&& output, std::vector<ptr<Expr>>&& input, 111 std::vector<ptr<ConstantExpr>>&& clobber, std::vector<Label>&& gotoLabels, 112 std::vector<Label>&& labels = {}) 108 113 : Stmt(loc, std::move(labels)), isVolatile(isVolatile), instruction(instruction), 109 114 output(std::move(output)), input(std::move(input)), clobber(std::move(clobber)), 110 115 gotoLabels(std::move(gotoLabels)) {} 111 116 112 const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } 113 private: 114 AsmStmt * clone() const override { return new AsmStmt{ *this }; } 115 MUTATE_FRIEND 117 const Stmt* accept( Visitor& v ) const override { return v.visit( this ); } 118 private: 119 AsmStmt* clone() const override { return new AsmStmt{ *this }; } 120 121 /// Must be copied in ALL derived classes 122 template<typename node_t> 123 friend node_t * mutate(const node_t * node); 116 124 }; 117 125 … … 120 128 std::string directive; 121 129 122 DirectiveStmt( const CodeLocation & loc, const std::string & directive,123 std::vector<Label> && labels = {} )130 DirectiveStmt( const CodeLocation& loc, const std::string & directive, 131 std::vector<Label>&& labels = {} ) 124 132 : Stmt(loc, std::move(labels)), directive(directive) {} 125 133 126 const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } 127 private: 128 DirectiveStmt * clone() const override { return new DirectiveStmt{ *this }; } 129 MUTATE_FRIEND 134 const Stmt* accept( Visitor& v ) const override { return v.visit( this ); } 135 private: 136 DirectiveStmt* clone() const override { return new DirectiveStmt{ *this }; } 137 138 /// Must be copied in ALL derived classes 139 template<typename node_t> 140 friend node_t * mutate(const node_t * node); 130 141 }; 131 142 … … 137 148 std::vector<ptr<Stmt>> inits; 138 149 139 IfStmt( const CodeLocation & loc, const Expr * cond, const Stmt* thenPart,140 Stmt * const elsePart, std::vector<ptr<Stmt>> && inits,141 std::vector<Label> && labels = {} )150 IfStmt( const CodeLocation& loc, const Expr* cond, const Stmt* thenPart, 151 Stmt * const elsePart, std::vector<ptr<Stmt>>&& inits, 152 std::vector<Label>&& labels = {} ) 142 153 : Stmt(loc, std::move(labels)), cond(cond), thenPart(thenPart), elsePart(elsePart), 143 154 inits(std::move(inits)) {} 144 155 145 const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } 146 private: 147 IfStmt * clone() const override { return new IfStmt{ *this }; } 148 MUTATE_FRIEND 156 const Stmt* accept( Visitor& v ) const override { return v.visit( this ); } 157 private: 158 IfStmt* clone() const override { return new IfStmt{ *this }; } 159 160 /// Must be copied in ALL derived classes 161 template<typename node_t> 162 friend node_t * mutate(const node_t * node); 149 163 }; 150 164 … … 154 168 std::vector<ptr<Stmt>> stmts; 155 169 156 SwitchStmt( const CodeLocation & loc, const Expr * cond, std::vector<ptr<Stmt>>&& stmts,157 std::vector<Label> && labels = {} )170 SwitchStmt( const CodeLocation& loc, const Expr* cond, std::vector<ptr<Stmt>>&& stmts, 171 std::vector<Label>&& labels = {} ) 158 172 : Stmt(loc, std::move(labels)), cond(cond), stmts(std::move(stmts)) {} 159 173 160 const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } 161 private: 162 SwitchStmt * clone() const override { return new SwitchStmt{ *this }; } 163 MUTATE_FRIEND 174 const Stmt* accept( Visitor& v ) const override { return v.visit( this ); } 175 private: 176 SwitchStmt* clone() const override { return new SwitchStmt{ *this }; } 177 178 /// Must be copied in ALL derived classes 179 template<typename node_t> 180 friend node_t * mutate(const node_t * node); 164 181 }; 165 182 … … 169 186 std::vector<ptr<Stmt>> stmts; 170 187 171 CaseStmt( const CodeLocation & loc, const Expr * cond, std::vector<ptr<Stmt>>&& stmts,172 std::vector<Label>&& labels = {} )173 : Stmt(loc, std::move(labels)), cond(cond), stmts(std::move(stmts)) {}188 CaseStmt( const CodeLocation& loc, const Expr* cond, std::vector<ptr<Stmt>>&& stmts, 189 std::vector<Label>&& labels = {} ) 190 : Stmt(loc, std::move(labels)), cond(cond), stmts(std::move(stmts)) {} 174 191 175 192 bool isDefault() { return !cond; } 176 193 177 const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } 178 private: 179 CaseStmt * clone() const override { return new CaseStmt{ *this }; } 180 MUTATE_FRIEND 194 const Stmt* accept( Visitor& v ) const override { return v.visit( this ); } 195 private: 196 CaseStmt* clone() const override { return new CaseStmt{ *this }; } 197 198 /// Must be copied in ALL derived classes 199 template<typename node_t> 200 friend node_t * mutate(const node_t * node); 181 201 }; 182 202 … … 188 208 bool isDoWhile; 189 209 190 WhileStmt( const CodeLocation & loc, const Expr * cond, const Stmt* body,191 std::vector<ptr<Stmt>> && inits, bool isDoWhile = false, std::vector<Label>&& labels = {} )210 WhileStmt( const CodeLocation& loc, const Expr* cond, const Stmt* body, 211 std::vector<ptr<Stmt>>&& inits, bool isDoWhile = false, std::vector<Label>&& labels = {} ) 192 212 : Stmt(loc, std::move(labels)), cond(cond), body(body), inits(std::move(inits)), 193 213 isDoWhile(isDoWhile) {} 194 214 195 const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } 196 private: 197 WhileStmt * clone() const override { return new WhileStmt{ *this }; } 198 MUTATE_FRIEND 215 const Stmt* accept( Visitor& v ) const override { return v.visit( this ); } 216 private: 217 WhileStmt* clone() const override { return new WhileStmt{ *this }; } 218 219 /// Must be copied in ALL derived classes 220 template<typename node_t> 221 friend node_t * mutate(const node_t * node); 199 222 }; 200 223 … … 206 229 ptr<Stmt> body; 207 230 208 ForStmt( const CodeLocation & loc, std::vector<ptr<Stmt>> && inits, const Expr* cond,209 const Expr * inc, const Stmt * body, std::vector<Label>&& labels = {} )231 ForStmt( const CodeLocation& loc, std::vector<ptr<Stmt>>&& inits, const Expr* cond, 232 const Expr* inc, const Stmt* body, std::vector<Label>&& labels = {} ) 210 233 : Stmt(loc, std::move(labels)), inits(std::move(inits)), cond(cond), inc(inc), 211 234 body(body) {} 212 235 213 const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } 214 private: 215 ForStmt * clone() const override { return new ForStmt{ *this }; } 216 MUTATE_FRIEND 236 const Stmt* accept( Visitor& v ) const override { return v.visit( this ); } 237 private: 238 ForStmt* clone() const override { return new ForStmt{ *this }; } 239 240 /// Must be copied in ALL derived classes 241 template<typename node_t> 242 friend node_t * mutate(const node_t * node); 217 243 }; 218 244 … … 227 253 Kind kind; 228 254 229 BranchStmt( const CodeLocation & loc, Kind kind, Label target,230 std::vector<Label> && labels = {} );231 BranchStmt( const CodeLocation & loc, const Expr* computedTarget,232 std::vector<Label> && labels = {} )255 BranchStmt( const CodeLocation& loc, Kind kind, Label target, 256 std::vector<Label>&& labels = {} ); 257 BranchStmt( const CodeLocation& loc, const Expr* computedTarget, 258 std::vector<Label>&& labels = {} ) 233 259 : Stmt(loc, std::move(labels)), originalTarget(loc), target(loc), 234 260 computedTarget(computedTarget), kind(Goto) {} … … 236 262 const char * kindName() { return kindNames[kind]; } 237 263 238 const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } 239 private: 240 BranchStmt * clone() const override { return new BranchStmt{ *this }; } 241 MUTATE_FRIEND 264 const Stmt* accept( Visitor& v ) const override { return v.visit( this ); } 265 private: 266 BranchStmt* clone() const override { return new BranchStmt{ *this }; } 267 268 /// Must be copied in ALL derived classes 269 template<typename node_t> 270 friend node_t * mutate(const node_t * node); 242 271 243 272 static const char * kindNames[kindEnd]; … … 248 277 ptr<Expr> expr; 249 278 250 ReturnStmt( const CodeLocation & loc, const Expr * expr, std::vector<Label>&& labels = {} )279 ReturnStmt( const CodeLocation& loc, const Expr* expr, std::vector<Label>&& labels = {} ) 251 280 : Stmt(loc, std::move(labels)), expr(expr) {} 252 281 253 const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } 254 private: 255 ReturnStmt * clone() const override { return new ReturnStmt{ *this }; } 256 MUTATE_FRIEND 282 const Stmt* accept( Visitor& v ) const override { return v.visit( this ); } 283 private: 284 ReturnStmt* clone() const override { return new ReturnStmt{ *this }; } 285 286 /// Must be copied in ALL derived classes 287 template<typename node_t> 288 friend node_t * mutate(const node_t * node); 257 289 }; 258 290 … … 265 297 Kind kind; 266 298 267 ThrowStmt( const CodeLocation & loc, Kind kind, const Expr * expr, const Expr* target,268 std::vector<Label> && labels = {} )299 ThrowStmt( const CodeLocation& loc, Kind kind, const Expr* expr, const Expr* target, 300 std::vector<Label>&& labels = {} ) 269 301 : Stmt(loc, std::move(labels)), expr(expr), target(target), kind(kind) {} 270 302 271 const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } 272 private: 273 ThrowStmt * clone() const override { return new ThrowStmt{ *this }; } 274 MUTATE_FRIEND 303 const Stmt* accept( Visitor& v ) const override { return v.visit( this ); } 304 private: 305 ThrowStmt* clone() const override { return new ThrowStmt{ *this }; } 306 307 /// Must be copied in ALL derived classes 308 template<typename node_t> 309 friend node_t * mutate(const node_t * node); 275 310 }; 276 311 … … 281 316 ptr<FinallyStmt> finally; 282 317 283 TryStmt( const CodeLocation & loc, const CompoundStmt* body,284 std::vector<ptr<CatchStmt>> && handlers, const FinallyStmt* finally,285 std::vector<Label> && labels = {} )318 TryStmt( const CodeLocation& loc, const CompoundStmt* body, 319 std::vector<ptr<CatchStmt>>&& handlers, const FinallyStmt* finally, 320 std::vector<Label>&& labels = {} ) 286 321 : Stmt(loc, std::move(labels)), body(body), handlers(std::move(handlers)), finally(finally) {} 287 322 288 const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } 289 private: 290 TryStmt * clone() const override { return new TryStmt{ *this }; } 291 MUTATE_FRIEND 323 const Stmt* accept( Visitor& v ) const override { return v.visit( this ); } 324 private: 325 TryStmt* clone() const override { return new TryStmt{ *this }; } 326 327 /// Must be copied in ALL derived classes 328 template<typename node_t> 329 friend node_t * mutate(const node_t * node); 292 330 }; 293 331 … … 301 339 Kind kind; 302 340 303 CatchStmt( const CodeLocation & loc, Kind kind, const Decl * decl, const Expr* cond,304 const Stmt * body, std::vector<Label>&& labels = {} )341 CatchStmt( const CodeLocation& loc, Kind kind, const Decl* decl, const Expr* cond, 342 const Stmt* body, std::vector<Label>&& labels = {} ) 305 343 : Stmt(loc, std::move(labels)), decl(decl), cond(cond), body(body), kind(kind) {} 306 344 307 const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } 308 private: 309 CatchStmt * clone() const override { return new CatchStmt{ *this }; } 310 MUTATE_FRIEND 345 const Stmt* accept( Visitor& v ) const override { return v.visit( this ); } 346 private: 347 CatchStmt* clone() const override { return new CatchStmt{ *this }; } 348 349 /// Must be copied in ALL derived classes 350 template<typename node_t> 351 friend node_t * mutate(const node_t * node); 311 352 }; 312 353 … … 315 356 ptr<CompoundStmt> body; 316 357 317 FinallyStmt( const CodeLocation & loc, const CompoundStmt* body,318 std::vector<Label> && labels = {} )358 FinallyStmt( const CodeLocation& loc, const CompoundStmt* body, 359 std::vector<Label>&& labels = {} ) 319 360 : Stmt(loc, std::move(labels)), body(body) {} 320 361 321 const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } 322 private: 323 FinallyStmt * clone() const override { return new FinallyStmt{ *this }; } 324 MUTATE_FRIEND 362 const Stmt* accept( Visitor& v ) const override { return v.visit( this ); } 363 private: 364 FinallyStmt* clone() const override { return new FinallyStmt{ *this }; } 365 366 /// Must be copied in ALL derived classes 367 template<typename node_t> 368 friend node_t * mutate(const node_t * node); 325 369 }; 326 370 … … 353 397 OrElse orElse; 354 398 355 WaitForStmt( const CodeLocation & loc, std::vector<Label>&& labels = {} )399 WaitForStmt( const CodeLocation& loc, std::vector<Label>&& labels = {} ) 356 400 : Stmt(loc, std::move(labels)) {} 357 401 358 const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } 359 private: 360 WaitForStmt * clone() const override { return new WaitForStmt{ *this }; } 361 MUTATE_FRIEND 402 const Stmt* accept( Visitor& v ) const override { return v.visit( this ); } 403 private: 404 WaitForStmt* clone() const override { return new WaitForStmt{ *this }; } 405 406 /// Must be copied in ALL derived classes 407 template<typename node_t> 408 friend node_t * mutate(const node_t * node); 362 409 }; 363 410 … … 367 414 ptr<Stmt> stmt; 368 415 369 WithStmt( const CodeLocation & loc, std::vector<ptr<Expr>> && exprs, const Stmt* stmt,370 std::vector<Label> && labels = {} )416 WithStmt( const CodeLocation& loc, std::vector<ptr<Expr>>&& exprs, const Stmt* stmt, 417 std::vector<Label>&& labels = {} ) 371 418 : Stmt(loc, std::move(labels)), exprs(std::move(exprs)), stmt(stmt) {} 372 419 373 const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } 374 private: 375 WithStmt * clone() const override { return new WithStmt{ *this }; } 376 MUTATE_FRIEND 420 const Stmt* accept( Visitor& v ) const override { return v.visit( this ); } 421 private: 422 WithStmt* clone() const override { return new WithStmt{ *this }; } 423 424 /// Must be copied in ALL derived classes 425 template<typename node_t> 426 friend node_t * mutate(const node_t * node); 377 427 }; 378 428 … … 381 431 ptr<Decl> decl; 382 432 383 DeclStmt( const CodeLocation & loc, const Decl * decl, std::vector<Label>&& labels = {} )433 DeclStmt( const CodeLocation& loc, const Decl* decl, std::vector<Label>&& labels = {} ) 384 434 : Stmt(loc, std::move(labels)), decl(decl) {} 385 435 386 const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } 387 private: 388 DeclStmt * clone() const override { return new DeclStmt{ *this }; } 389 MUTATE_FRIEND 436 const Stmt* accept( Visitor& v ) const override { return v.visit( this ); } 437 private: 438 DeclStmt* clone() const override { return new DeclStmt{ *this }; } 439 440 /// Must be copied in ALL derived classes 441 template<typename node_t> 442 friend node_t * mutate(const node_t * node); 390 443 }; 391 444 … … 394 447 readonly<Stmt> callStmt; 395 448 396 ImplicitCtorDtorStmt( const CodeLocation & loc, const Stmt* callStmt,397 std::vector<Label> && labels = {} )449 ImplicitCtorDtorStmt( const CodeLocation& loc, const Stmt* callStmt, 450 std::vector<Label>&& labels = {} ) 398 451 : Stmt(loc, std::move(labels)), callStmt(callStmt) {} 399 452 400 const Stmt * accept( Visitor & v ) const override { return v.visit( this ); } 401 private: 402 ImplicitCtorDtorStmt * clone() const override { return new ImplicitCtorDtorStmt{ *this }; } 403 MUTATE_FRIEND 453 const Stmt* accept( Visitor& v ) const override { return v.visit( this ); } 454 private: 455 ImplicitCtorDtorStmt* clone() const override { return new ImplicitCtorDtorStmt{ *this }; } 456 457 /// Must be copied in ALL derived classes 458 template<typename node_t> 459 friend node_t * mutate(const node_t * node); 404 460 }; 405 461 406 462 } 407 408 #undef MUTATE_FRIEND409 463 410 464 // Local Variables: // -
src/AST/Type.hpp
r41b24c8 re61207e7 29 29 #include "Visitor.hpp" 30 30 31 // Must be included in *all* AST classes; should be #undef'd at the end of the file32 #define MUTATE_FRIEND template<typename node_t> friend auto mutate(const node_t * node);33 34 31 namespace ast { 35 32 … … 73 70 private: 74 71 virtual Type * clone() const override = 0; 75 MUTATE_FRIEND76 72 }; 77 73 … … 88 84 private: 89 85 VoidType * clone() const override { return new VoidType{ *this }; } 90 MUTATE_FRIEND91 86 }; 92 87 … … 151 146 private: 152 147 BasicType * clone() const override { return new BasicType{ *this }; } 153 MUTATE_FRIEND154 148 }; 155 149 … … 182 176 private: 183 177 PointerType * clone() const override { return new PointerType{ *this }; } 184 MUTATE_FRIEND185 178 }; 186 179 … … 204 197 private: 205 198 ArrayType * clone() const override { return new ArrayType{ *this }; } 206 MUTATE_FRIEND207 199 }; 208 200 … … 224 216 private: 225 217 ReferenceType * clone() const override { return new ReferenceType{ *this }; } 226 MUTATE_FRIEND227 218 }; 228 219 … … 239 230 private: 240 231 QualifiedType * clone() const override { return new QualifiedType{ *this }; } 241 MUTATE_FRIEND242 232 }; 243 233 … … 255 245 private: 256 246 virtual ParameterizedType * clone() const override = 0; 257 MUTATE_FRIEND258 247 }; 259 248 … … 285 274 private: 286 275 FunctionType * clone() const override { return new FunctionType{ *this }; } 287 MUTATE_FRIEND288 276 }; 289 277 … … 307 295 private: 308 296 virtual ReferenceToType * clone() const override = 0; 309 MUTATE_FRIEND310 297 311 298 protected: … … 332 319 private: 333 320 StructInstType * clone() const override { return new StructInstType{ *this }; } 334 MUTATE_FRIEND335 321 336 322 std::string typeString() const override { return "struct"; } … … 355 341 private: 356 342 UnionInstType * clone() const override { return new UnionInstType{ *this }; } 357 MUTATE_FRIEND358 343 359 344 std::string typeString() const override { return "union"; } … … 378 363 private: 379 364 EnumInstType * clone() const override { return new EnumInstType{ *this }; } 380 MUTATE_FRIEND381 365 382 366 std::string typeString() const override { return "enum"; } … … 402 386 private: 403 387 TraitInstType * clone() const override { return new TraitInstType{ *this }; } 404 MUTATE_FRIEND405 388 406 389 std::string typeString() const override { return "trait"; } … … 431 414 private: 432 415 TypeInstType * clone() const override { return new TypeInstType{ *this }; } 433 MUTATE_FRIEND434 416 435 417 std::string typeString() const override { return "type"; } … … 460 442 private: 461 443 TupleType * clone() const override { return new TupleType{ *this }; } 462 MUTATE_FRIEND463 444 }; 464 445 … … 475 456 private: 476 457 TypeofType * clone() const override { return new TypeofType{ *this }; } 477 MUTATE_FRIEND478 458 }; 479 459 … … 486 466 private: 487 467 VarArgsType * clone() const override { return new VarArgsType{ *this }; } 488 MUTATE_FRIEND489 468 }; 490 469 … … 497 476 private: 498 477 ZeroType * clone() const override { return new ZeroType{ *this }; } 499 MUTATE_FRIEND500 478 }; 501 479 … … 508 486 private: 509 487 OneType * clone() const override { return new OneType{ *this }; } 510 MUTATE_FRIEND511 488 }; 512 489 … … 519 496 private: 520 497 GlobalScopeType * clone() const override { return new GlobalScopeType{ *this }; } 521 MUTATE_FRIEND522 498 }; 523 499 524 500 } 525 526 #undef MUTATE_FRIEND527 501 528 502 // Local Variables: //
Note:
See TracChangeset
for help on using the changeset viewer.