Changes in src/AST/Expr.hpp [f3cc5b6:87701b6]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/AST/Expr.hpp
rf3cc5b6 r87701b6 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_FRIEND 133 }; 134 135 /// The application of a function to a set of parameters. 129 }; 130 131 /// The application of a function to a set of parameters. 136 132 /// Post-resolver form of `UntypedExpr` 137 133 class ApplicationExpr final : public Expr { … … 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 … … 218 209 GeneratedFlag isGenerated; 219 210 220 CastExpr( const CodeLocation & loc, const Expr * a, const Type * to, 211 CastExpr( const CodeLocation & loc, const Expr * a, const Type * to, 221 212 GeneratedFlag g = GeneratedCast ) : Expr( loc, to ), arg( a ), isGenerated( g ) {} 222 213 /// Cast-to-void … … 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 … … 311 296 unsigned long long ival; 312 297 double dval; 313 298 314 299 Val( unsigned long long i ) : ival( i ) {} 315 300 Val( double d ) : dval( d ) {} … … 318 303 std::string rep; 319 304 320 ConstantExpr( 305 ConstantExpr( 321 306 const CodeLocation & loc, const Type * ty, const std::string & r, unsigned long long v ) 322 307 : Expr( loc, ty ), val( v ), rep( r ) {} 323 308 ConstantExpr( const CodeLocation & loc, const Type * ty, const std::string & r, double v ) 324 309 : Expr( loc, ty ), val( v ), rep( r ) {} 325 310 326 311 /// Gets the value of this constant as an integer 327 312 long long int intValue() const; … … 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 … … 464 441 ptr<Expr> arg2; 465 442 466 CommaExpr( const CodeLocation & loc, const Expr * a1, const Expr * a2 ) 443 CommaExpr( const CodeLocation & loc, const Expr * a1, const Expr * a2 ) 467 444 : Expr( loc ), arg1( a1 ), arg2( a2 ) {} 468 445 … … 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 … … 491 466 public: 492 467 ptr<Expr> inout; 493 ptr<Expr> constraint; 494 }; 495 496 //================================================================================================= 497 /// This disgusting and giant piece of boiler-plate is here to solve a cyclic dependency 498 /// remove only if there is a better solution 499 /// The problem is that ast::ptr< ... > uses increment/decrement which won't work well with 500 /// forward declarations 501 inline void increment( const class Expr * node, Node::ref_type ref ) { node->increment(ref); } 502 inline void decrement( const class Expr * node, Node::ref_type ref ) { node->decrement(ref); } 503 inline void increment( const class ApplicationExpr * node, Node::ref_type ref ) { node->increment(ref); } 504 inline void decrement( const class ApplicationExpr * node, Node::ref_type ref ) { node->decrement(ref); } 505 inline void increment( const class UntypedExpr * node, Node::ref_type ref ) { node->increment(ref); } 506 inline void decrement( const class UntypedExpr * node, Node::ref_type ref ) { node->decrement(ref); } 507 inline void increment( const class NameExpr * node, Node::ref_type ref ) { node->increment(ref); } 508 inline void decrement( const class NameExpr * node, Node::ref_type ref ) { node->decrement(ref); } 509 inline void increment( const class AddressExpr * node, Node::ref_type ref ) { node->increment(ref); } 510 inline void decrement( const class AddressExpr * node, Node::ref_type ref ) { node->decrement(ref); } 511 inline void increment( const class LabelAddressExpr * node, Node::ref_type ref ) { node->increment(ref); } 512 inline void decrement( const class LabelAddressExpr * node, Node::ref_type ref ) { node->decrement(ref); } 513 inline void increment( const class CastExpr * node, Node::ref_type ref ) { node->increment(ref); } 514 inline void decrement( const class CastExpr * node, Node::ref_type ref ) { node->decrement(ref); } 515 inline void increment( const class KeywordCastExpr * node, Node::ref_type ref ) { node->increment(ref); } 516 inline void decrement( const class KeywordCastExpr * node, Node::ref_type ref ) { node->decrement(ref); } 517 inline void increment( const class VirtualCastExpr * node, Node::ref_type ref ) { node->increment(ref); } 518 inline void decrement( const class VirtualCastExpr * node, Node::ref_type ref ) { node->decrement(ref); } 519 inline void increment( const class MemberExpr * node, Node::ref_type ref ) { node->increment(ref); } 520 inline void decrement( const class MemberExpr * node, Node::ref_type ref ) { node->decrement(ref); } 521 inline void increment( const class UntypedMemberExpr * node, Node::ref_type ref ) { node->increment(ref); } 522 inline void decrement( const class UntypedMemberExpr * node, Node::ref_type ref ) { node->decrement(ref); } 523 inline void increment( const class VariableExpr * node, Node::ref_type ref ) { node->increment(ref); } 524 inline void decrement( const class VariableExpr * node, Node::ref_type ref ) { node->decrement(ref); } 525 inline void increment( const class ConstantExpr * node, Node::ref_type ref ) { node->increment(ref); } 526 inline void decrement( const class ConstantExpr * node, Node::ref_type ref ) { node->decrement(ref); } 527 inline void increment( const class SizeofExpr * node, Node::ref_type ref ) { node->increment(ref); } 528 inline void decrement( const class SizeofExpr * node, Node::ref_type ref ) { node->decrement(ref); } 529 inline void increment( const class AlignofExpr * node, Node::ref_type ref ) { node->increment(ref); } 530 inline void decrement( const class AlignofExpr * node, Node::ref_type ref ) { node->decrement(ref); } 531 inline void increment( const class UntypedOffsetofExpr * node, Node::ref_type ref ) { node->increment(ref); } 532 inline void decrement( const class UntypedOffsetofExpr * node, Node::ref_type ref ) { node->decrement(ref); } 533 inline void increment( const class OffsetofExpr * node, Node::ref_type ref ) { node->increment(ref); } 534 inline void decrement( const class OffsetofExpr * node, Node::ref_type ref ) { node->decrement(ref); } 535 inline void increment( const class OffsetPackExpr * node, Node::ref_type ref ) { node->increment(ref); } 536 inline void decrement( const class OffsetPackExpr * node, Node::ref_type ref ) { node->decrement(ref); } 537 inline void increment( const class LogicalExpr * node, Node::ref_type ref ) { node->increment(ref); } 538 inline void decrement( const class LogicalExpr * node, Node::ref_type ref ) { node->decrement(ref); } 539 inline void increment( const class ConditionalExpr * node, Node::ref_type ref ) { node->increment(ref); } 540 inline void decrement( const class ConditionalExpr * node, Node::ref_type ref ) { node->decrement(ref); } 541 inline void increment( const class CommaExpr * node, Node::ref_type ref ) { node->increment(ref); } 542 inline void decrement( const class CommaExpr * node, Node::ref_type ref ) { node->decrement(ref); } 543 inline void increment( const class TypeExpr * node, Node::ref_type ref ) { node->increment(ref); } 544 inline void decrement( const class TypeExpr * node, Node::ref_type ref ) { node->decrement(ref); } 545 inline void increment( const class AsmExpr * node, Node::ref_type ref ) { node->increment(ref); } 546 inline void decrement( const class AsmExpr * node, Node::ref_type ref ) { node->decrement(ref); } 547 // inline void increment( const class ImplicitCopyCtorExpr * node, Node::ref_type ref ) { node->increment(ref); } 548 // inline void decrement( const class ImplicitCopyCtorExpr * node, Node::ref_type ref ) { node->decrement(ref); } 549 // inline void increment( const class ConstructorExpr * node, Node::ref_type ref ) { node->increment(ref); } 550 // inline void decrement( const class ConstructorExpr * node, Node::ref_type ref ) { node->decrement(ref); } 551 // inline void increment( const class CompoundLiteralExpr * node, Node::ref_type ref ) { node->increment(ref); } 552 // inline void decrement( const class CompoundLiteralExpr * node, Node::ref_type ref ) { node->decrement(ref); } 553 // inline void increment( const class UntypedValofExpr * node, Node::ref_type ref ) { node->increment(ref); } 554 // inline void decrement( const class UntypedValofExpr * node, Node::ref_type ref ) { node->decrement(ref); } 555 // inline void increment( const class RangeExpr * node, Node::ref_type ref ) { node->increment(ref); } 556 // inline void decrement( const class RangeExpr * node, Node::ref_type ref ) { node->decrement(ref); } 557 // inline void increment( const class UntypedTupleExpr * node, Node::ref_type ref ) { node->increment(ref); } 558 // inline void decrement( const class UntypedTupleExpr * node, Node::ref_type ref ) { node->decrement(ref); } 559 // inline void increment( const class TupleExpr * node, Node::ref_type ref ) { node->increment(ref); } 560 // inline void decrement( const class TupleExpr * node, Node::ref_type ref ) { node->decrement(ref); } 561 // inline void increment( const class TupleIndexExpr * node, Node::ref_type ref ) { node->increment(ref); } 562 // inline void decrement( const class TupleIndexExpr * node, Node::ref_type ref ) { node->decrement(ref); } 563 // inline void increment( const class TupleAssignExpr * node, Node::ref_type ref ) { node->increment(ref); } 564 // inline void decrement( const class TupleAssignExpr * node, Node::ref_type ref ) { node->decrement(ref); } 565 // inline void increment( const class StmtExpr * node, Node::ref_type ref ) { node->increment(ref); } 566 // inline void decrement( const class StmtExpr * node, Node::ref_type ref ) { node->decrement(ref); } 567 // inline void increment( const class UniqueExpr * node, Node::ref_type ref ) { node->increment(ref); } 568 // inline void decrement( const class UniqueExpr * node, Node::ref_type ref ) { node->decrement(ref); } 569 // inline void increment( const class UntypedInitExpr * node, Node::ref_type ref ) { node->increment(ref); } 570 // inline void decrement( const class UntypedInitExpr * node, Node::ref_type ref ) { node->decrement(ref); } 571 // inline void increment( const class InitExpr * node, Node::ref_type ref ) { node->increment(ref); } 572 // inline void decrement( const class InitExpr * node, Node::ref_type ref ) { node->decrement(ref); } 573 // inline void increment( const class DeletedExpr * node, Node::ref_type ref ) { node->increment(ref); } 574 // inline void decrement( const class DeletedExpr * node, Node::ref_type ref ) { node->decrement(ref); } 575 // inline void increment( const class DefaultArgExpr * node, Node::ref_type ref ) { node->increment(ref); } 576 // inline void decrement( const class DefaultArgExpr * node, Node::ref_type ref ) { node->decrement(ref); } 577 // inline void increment( const class GenericExpr * node, Node::ref_type ref ) { node->increment(ref); } 578 // inline void decrement( const class GenericExpr * node, Node::ref_type ref ) { node->decrement(ref); } 468 ptr<Expr> constraint; 469 }; 470 579 471 } 580 581 #undef MUTATE_FRIEND582 472 583 473 // Local Variables: //
Note: See TracChangeset
for help on using the changeset viewer.