Changeset cd7ef0b for src/SynTree/Expression.h
- Timestamp:
- Aug 10, 2017, 3:39:11 PM (8 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 38d70ab
- Parents:
- 275f4b4 (diff), e1780a2 (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
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/Expression.h
r275f4b4 rcd7ef0b 10 10 // Created On : Mon May 18 07:44:20 2015 11 11 // Last Modified By : Andrew Beach 12 // Last Modified On : Mon Jul 24 16:27:00 201713 // Update Count : 4 312 // Last Modified On : Fri Aug 8 11:54:00 2017 13 // Update Count : 44 14 14 // 15 15 … … 29 29 class Expression : public BaseSyntaxNode{ 30 30 public: 31 Type * result; 32 TypeSubstitution * env; 33 Expression * argName; // if expression is used as an argument, it can be "designated" by this name 34 bool extension = false; 35 31 36 Expression( Expression * _aname = nullptr ); 32 37 Expression( const Expression & other ); … … 49 54 virtual Expression * acceptMutator( Mutator & m ) = 0; 50 55 virtual void print( std::ostream & os, int indent = 0 ) const; 51 protected:52 Type * result;53 TypeSubstitution * env;54 Expression * argName; // if expression is used as an argument, it can be "designated" by this name55 bool extension = false;56 56 }; 57 57 … … 79 79 class ApplicationExpr : public Expression { 80 80 public: 81 Expression * function; 82 81 83 ApplicationExpr( Expression * function, const std::list<Expression *> & args = std::list< Expression * >() ); 82 84 ApplicationExpr( const ApplicationExpr & other ); … … 92 94 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 93 95 virtual void print( std::ostream & os, int indent = 0 ) const; 96 94 97 private: 95 Expression * function;96 98 std::list<Expression *> args; 97 99 InferredParams inferParams; … … 103 105 class UntypedExpr : public Expression { 104 106 public: 107 Expression * function; 108 std::list<Expression*> args; 109 105 110 UntypedExpr( Expression * function, const std::list<Expression *> & args = std::list< Expression * >(), Expression *_aname = nullptr ); 106 111 UntypedExpr( const UntypedExpr & other ); … … 123 128 virtual void print( std::ostream & os, int indent = 0 ) const; 124 129 virtual void printArgs(std::ostream & os, int indent = 0) const; 125 private:126 Expression * function;127 std::list<Expression*> args;128 130 }; 129 131 … … 131 133 class NameExpr : public Expression { 132 134 public: 135 std::string name; 136 133 137 NameExpr( std::string name, Expression *_aname = nullptr ); 134 138 NameExpr( const NameExpr & other ); … … 142 146 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 143 147 virtual void print( std::ostream & os, int indent = 0 ) const; 144 private:145 std::string name;146 148 }; 147 149 … … 152 154 class AddressExpr : public Expression { 153 155 public: 156 Expression * arg; 157 154 158 AddressExpr( Expression * arg, Expression *_aname = nullptr ); 155 159 AddressExpr( const AddressExpr & other ); … … 163 167 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 164 168 virtual void print( std::ostream & os, int indent = 0 ) const; 165 private:166 Expression * arg;167 169 }; 168 170 … … 170 172 class LabelAddressExpr : public Expression { 171 173 public: 174 Expression * arg; 175 172 176 LabelAddressExpr( Expression * arg ); 173 177 LabelAddressExpr( const LabelAddressExpr & other ); … … 181 185 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 182 186 virtual void print( std::ostream & os, int indent = 0 ) const; 183 private:184 Expression * arg;185 187 }; 186 188 … … 188 190 class CastExpr : public Expression { 189 191 public: 192 Expression * arg; 193 190 194 CastExpr( Expression * arg, Expression *_aname = nullptr ); 191 195 CastExpr( Expression * arg, Type * toType, Expression *_aname = nullptr ); … … 200 204 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 201 205 virtual void print( std::ostream & os, int indent = 0 ) const; 202 private:203 Expression * arg;204 206 }; 205 207 … … 207 209 class VirtualCastExpr : public Expression { 208 210 public: 211 Expression * arg; 212 209 213 VirtualCastExpr( Expression * arg, Type * toType ); 210 214 VirtualCastExpr( const VirtualCastExpr & other ); … … 218 222 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 219 223 virtual void print( std::ostream & os, int indent = 0 ) const; 220 private:221 Expression * arg;222 224 }; 223 225 … … 225 227 class UntypedMemberExpr : public Expression { 226 228 public: 229 Expression * member; 230 Expression * aggregate; 231 227 232 UntypedMemberExpr( Expression * member, Expression * aggregate, Expression *_aname = nullptr ); 228 233 UntypedMemberExpr( const UntypedMemberExpr & other ); … … 238 243 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 239 244 virtual void print( std::ostream & os, int indent = 0 ) const; 240 private:241 Expression * member;242 Expression * aggregate;243 245 }; 244 246 … … 247 249 class MemberExpr : public Expression { 248 250 public: 251 DeclarationWithType * member; 252 Expression * aggregate; 253 249 254 MemberExpr( DeclarationWithType * member, Expression * aggregate, Expression *_aname = nullptr ); 250 255 MemberExpr( const MemberExpr & other ); … … 260 265 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 261 266 virtual void print( std::ostream & os, int indent = 0 ) const; 262 private:263 DeclarationWithType * member;264 Expression * aggregate;265 267 }; 266 268 … … 269 271 class VariableExpr : public Expression { 270 272 public: 273 DeclarationWithType * var; 274 271 275 VariableExpr( DeclarationWithType * var, Expression *_aname = nullptr ); 272 276 VariableExpr( const VariableExpr & other ); … … 280 284 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 281 285 virtual void print( std::ostream & os, int indent = 0 ) const; 282 private:283 DeclarationWithType * var;284 286 }; 285 287 … … 287 289 class ConstantExpr : public Expression { 288 290 public: 291 Constant constant; 292 289 293 ConstantExpr( Constant constant, Expression *_aname = nullptr ); 290 294 ConstantExpr( const ConstantExpr & other ); … … 298 302 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 299 303 virtual void print( std::ostream & os, int indent = 0 ) const; 300 private:301 Constant constant;302 304 }; 303 305 … … 305 307 class SizeofExpr : public Expression { 306 308 public: 309 Expression * expr; 310 Type * type; 311 bool isType; 312 307 313 SizeofExpr( Expression * expr, Expression *_aname = nullptr ); 308 314 SizeofExpr( const SizeofExpr & other ); … … 321 327 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 322 328 virtual void print( std::ostream & os, int indent = 0 ) const; 323 private: 329 }; 330 331 /// AlignofExpr represents an alignof expression 332 class AlignofExpr : public Expression { 333 public: 324 334 Expression * expr; 325 335 Type * type; 326 336 bool isType; 327 }; 328 329 /// AlignofExpr represents an alignof expression 330 class AlignofExpr : public Expression { 331 public: 337 332 338 AlignofExpr( Expression * expr, Expression *_aname = nullptr ); 333 339 AlignofExpr( const AlignofExpr & other ); … … 346 352 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 347 353 virtual void print( std::ostream & os, int indent = 0 ) const; 348 private:349 Expression * expr;350 Type * type;351 bool isType;352 354 }; 353 355 … … 355 357 class UntypedOffsetofExpr : public Expression { 356 358 public: 359 Type * type; 360 std::string member; 361 357 362 UntypedOffsetofExpr( Type * type, const std::string & member, Expression *_aname = nullptr ); 358 363 UntypedOffsetofExpr( const UntypedOffsetofExpr & other ); … … 368 373 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 369 374 virtual void print( std::ostream & os, int indent = 0 ) const; 370 private:371 Type * type;372 std::string member;373 375 }; 374 376 … … 376 378 class OffsetofExpr : public Expression { 377 379 public: 380 Type * type; 381 DeclarationWithType * member; 382 378 383 OffsetofExpr( Type * type, DeclarationWithType * member, Expression *_aname = nullptr ); 379 384 OffsetofExpr( const OffsetofExpr & other ); … … 389 394 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 390 395 virtual void print( std::ostream & os, int indent = 0 ) const; 391 private:392 Type * type;393 DeclarationWithType * member;394 396 }; 395 397 … … 397 399 class OffsetPackExpr : public Expression { 398 400 public: 401 StructInstType * type; 402 399 403 OffsetPackExpr( StructInstType * type_, Expression * aname_ = 0 ); 400 404 OffsetPackExpr( const OffsetPackExpr & other ); … … 407 411 virtual void accept( Visitor & v ) { v.visit( this ); } 408 412 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 409 410 virtual void print( std::ostream & os, int indent = 0 ) const; 411 412 private: 413 StructInstType * type; 413 virtual void print( std::ostream & os, int indent = 0 ) const; 414 414 }; 415 415 … … 417 417 class AttrExpr : public Expression { 418 418 public: 419 Expression * attr; 420 Expression * expr; 421 Type * type; 422 bool isType; 423 419 424 AttrExpr(Expression * attr, Expression * expr, Expression *_aname = nullptr ); 420 425 AttrExpr( const AttrExpr & other ); … … 435 440 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 436 441 virtual void print( std::ostream & os, int indent = 0 ) const; 437 private:438 Expression * attr;439 Expression * expr;440 Type * type;441 bool isType;442 442 }; 443 443 … … 445 445 class LogicalExpr : public Expression { 446 446 public: 447 Expression * arg1; 448 Expression * arg2; 449 447 450 LogicalExpr( Expression * arg1, Expression * arg2, bool andp = true, Expression *_aname = nullptr ); 448 451 LogicalExpr( const LogicalExpr & other ); … … 459 462 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 460 463 virtual void print( std::ostream & os, int indent = 0 ) const; 464 461 465 private: 466 bool isAnd; 467 }; 468 469 /// ConditionalExpr represents the three-argument conditional ( p ? a : b ) 470 class ConditionalExpr : public Expression { 471 public: 462 472 Expression * arg1; 463 473 Expression * arg2; 464 bool isAnd; 465 }; 466 467 /// ConditionalExpr represents the three-argument conditional ( p ? a : b ) 468 class ConditionalExpr : public Expression { 469 public: 474 Expression * arg3; 475 470 476 ConditionalExpr( Expression * arg1, Expression * arg2, Expression * arg3, Expression *_aname = nullptr ); 471 477 ConditionalExpr( const ConditionalExpr & other ); … … 483 489 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 484 490 virtual void print( std::ostream & os, int indent = 0 ) const; 485 private: 491 }; 492 493 /// CommaExpr represents the sequence operator ( a, b ) 494 class CommaExpr : public Expression { 495 public: 486 496 Expression * arg1; 487 497 Expression * arg2; 488 Expression * arg3; 489 }; 490 491 /// CommaExpr represents the sequence operator ( a, b ) 492 class CommaExpr : public Expression { 493 public: 498 494 499 CommaExpr( Expression * arg1, Expression * arg2, Expression *_aname = nullptr ); 495 500 CommaExpr( const CommaExpr & other ); … … 505 510 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 506 511 virtual void print( std::ostream & os, int indent = 0 ) const; 507 private:508 Expression * arg1;509 Expression * arg2;510 512 }; 511 513 … … 513 515 class TypeExpr : public Expression { 514 516 public: 517 Type * type; 518 515 519 TypeExpr( Type * type ); 516 520 TypeExpr( const TypeExpr & other ); … … 524 528 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 525 529 virtual void print( std::ostream & os, int indent = 0 ) const; 526 private:527 Type * type;528 530 }; 529 531 … … 531 533 class AsmExpr : public Expression { 532 534 public: 535 Expression * inout; 536 ConstantExpr * constraint; 537 Expression * operand; 538 533 539 AsmExpr( Expression * inout, ConstantExpr * constraint, Expression * operand ) : inout( inout ), constraint( constraint ), operand( operand ) {} 534 540 AsmExpr( const AsmExpr & other ); … … 548 554 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 549 555 virtual void print( std::ostream & os, int indent = 0 ) const; 550 private: 556 551 557 // https://gcc.gnu.org/onlinedocs/gcc-4.7.1/gcc/Machine-Constraints.html#Machine-Constraints 552 Expression * inout;553 ConstantExpr * constraint;554 Expression * operand;555 558 }; 556 559 … … 559 562 class ImplicitCopyCtorExpr : public Expression { 560 563 public: 561 ImplicitCopyCtorExpr( ApplicationExpr * callExpr );562 ImplicitCopyCtorExpr( const ImplicitCopyCtorExpr & other );563 virtual ~ImplicitCopyCtorExpr();564 565 ApplicationExpr * get_callExpr() const { return callExpr; }566 void set_callExpr( ApplicationExpr * newValue ) { callExpr = newValue; }567 568 std::list< ObjectDecl * > & get_tempDecls() { return tempDecls; }569 std::list< ObjectDecl * > & get_returnDecls() { return returnDecls; }570 std::list< Expression * > & get_dtors() { return dtors; }571 572 virtual ImplicitCopyCtorExpr * clone() const { return new ImplicitCopyCtorExpr( * this ); }573 virtual void accept( Visitor & v ) { v.visit( this ); }574 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); }575 virtual void print( std::ostream & os, int indent = 0 ) const;576 private:577 564 ApplicationExpr * callExpr; 578 565 std::list< ObjectDecl * > tempDecls; 579 566 std::list< ObjectDecl * > returnDecls; 580 567 std::list< Expression * > dtors; 568 569 ImplicitCopyCtorExpr( ApplicationExpr * callExpr ); 570 ImplicitCopyCtorExpr( const ImplicitCopyCtorExpr & other ); 571 virtual ~ImplicitCopyCtorExpr(); 572 573 ApplicationExpr * get_callExpr() const { return callExpr; } 574 void set_callExpr( ApplicationExpr * newValue ) { callExpr = newValue; } 575 576 std::list< ObjectDecl * > & get_tempDecls() { return tempDecls; } 577 std::list< ObjectDecl * > & get_returnDecls() { return returnDecls; } 578 std::list< Expression * > & get_dtors() { return dtors; } 579 580 virtual ImplicitCopyCtorExpr * clone() const { return new ImplicitCopyCtorExpr( * this ); } 581 virtual void accept( Visitor & v ) { v.visit( this ); } 582 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 583 virtual void print( std::ostream & os, int indent = 0 ) const; 581 584 }; 582 585 … … 584 587 class ConstructorExpr : public Expression { 585 588 public: 589 Expression * callExpr; 590 586 591 ConstructorExpr( Expression * callExpr ); 587 592 ConstructorExpr( const ConstructorExpr & other ); … … 595 600 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 596 601 virtual void print( std::ostream & os, int indent = 0 ) const; 597 private:598 Expression * callExpr;599 602 }; 600 603 … … 602 605 class CompoundLiteralExpr : public Expression { 603 606 public: 607 Initializer * initializer; 608 604 609 CompoundLiteralExpr( Type * type, Initializer * initializer ); 605 610 CompoundLiteralExpr( const CompoundLiteralExpr & other ); … … 613 618 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 614 619 virtual void print( std::ostream & os, int indent = 0 ) const; 615 private:616 Initializer * initializer;617 620 }; 618 621 … … 620 623 class RangeExpr : public Expression { 621 624 public: 625 Expression * low, * high; 626 622 627 RangeExpr( Expression * low, Expression * high ); 623 628 RangeExpr( const RangeExpr & other ); … … 632 637 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 633 638 virtual void print( std::ostream & os, int indent = 0 ) const; 634 private:635 Expression * low, * high;636 639 }; 637 640 … … 639 642 class UntypedTupleExpr : public Expression { 640 643 public: 644 std::list<Expression*> exprs; 645 641 646 UntypedTupleExpr( const std::list< Expression * > & exprs, Expression *_aname = nullptr ); 642 647 UntypedTupleExpr( const UntypedTupleExpr & other ); … … 649 654 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 650 655 virtual void print( std::ostream & os, int indent = 0 ) const; 651 private:652 std::list<Expression*> exprs;653 656 }; 654 657 … … 656 659 class TupleExpr : public Expression { 657 660 public: 661 std::list<Expression*> exprs; 662 658 663 TupleExpr( const std::list< Expression * > & exprs, Expression *_aname = nullptr ); 659 664 TupleExpr( const TupleExpr & other ); … … 666 671 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 667 672 virtual void print( std::ostream & os, int indent = 0 ) const; 668 private:669 std::list<Expression*> exprs;670 673 }; 671 674 … … 673 676 class TupleIndexExpr : public Expression { 674 677 public: 678 Expression * tuple; 679 unsigned int index; 680 675 681 TupleIndexExpr( Expression * tuple, unsigned int index ); 676 682 TupleIndexExpr( const TupleIndexExpr & other ); … … 686 692 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 687 693 virtual void print( std::ostream & os, int indent = 0 ) const; 688 private:689 Expression * tuple;690 unsigned int index;691 694 }; 692 695 … … 694 697 class TupleAssignExpr : public Expression { 695 698 public: 699 StmtExpr * stmtExpr = nullptr; 700 696 701 TupleAssignExpr( const std::list< Expression * > & assigns, const std::list< ObjectDecl * > & tempDecls, Expression * _aname = nullptr ); 697 702 TupleAssignExpr( const TupleAssignExpr & other ); … … 705 710 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 706 711 virtual void print( std::ostream & os, int indent = 0 ) const; 707 private:708 StmtExpr * stmtExpr = nullptr;709 712 }; 710 713 … … 712 715 class StmtExpr : public Expression { 713 716 public: 717 CompoundStmt * statements; 718 std::list< ObjectDecl * > returnDecls; // return variable(s) for stmt expression 719 std::list< Expression * > dtors; // destructor(s) for return variable(s) 720 714 721 StmtExpr( CompoundStmt * statements ); 715 722 StmtExpr( const StmtExpr & other ); … … 726 733 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 727 734 virtual void print( std::ostream & os, int indent = 0 ) const; 728 private:729 CompoundStmt * statements;730 std::list< ObjectDecl * > returnDecls; // return variable(s) for stmt expression731 std::list< Expression * > dtors; // destructor(s) for return variable(s)732 735 }; 733 736 734 737 class UniqueExpr : public Expression { 735 738 public: 739 Expression * expr; 740 ObjectDecl * object; 741 VariableExpr * var; 742 736 743 UniqueExpr( Expression * expr, long long idVal = -1 ); 737 744 UniqueExpr( const UniqueExpr & other ); … … 753 760 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 754 761 virtual void print( std::ostream & os, int indent = 0 ) const; 762 755 763 private: 756 Expression * expr;757 ObjectDecl * object;758 VariableExpr * var;759 764 int id; 760 765 static long long count; … … 773 778 class UntypedInitExpr : public Expression { 774 779 public: 780 Expression * expr; 781 std::list<InitAlternative> initAlts; 782 775 783 UntypedInitExpr( Expression * expr, const std::list<InitAlternative> & initAlts ); 776 784 UntypedInitExpr( const UntypedInitExpr & other ); … … 786 794 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 787 795 virtual void print( std::ostream & os, int indent = 0 ) const; 788 private:789 Expression * expr;790 std::list<InitAlternative> initAlts;791 796 }; 792 797 793 798 class InitExpr : public Expression { 794 799 public: 800 Expression * expr; 801 Designation * designation; 802 795 803 InitExpr( Expression * expr, Designation * designation ); 796 804 InitExpr( const InitExpr & other ); … … 807 815 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 808 816 virtual void print( std::ostream & os, int indent = 0 ) const; 809 private:810 Expression * expr;811 Designation * designation;812 817 }; 813 818
Note:
See TracChangeset
for help on using the changeset viewer.