Changeset d807ca28 for src/SynTree
- Timestamp:
- May 25, 2018, 5:01:37 PM (6 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, with_gc
- Children:
- 3ed994e
- Parents:
- 2c88368
- git-author:
- Rob Schluntz <rschlunt@…> (05/25/18 16:59:30)
- git-committer:
- Rob Schluntz <rschlunt@…> (05/25/18 17:01:37)
- Location:
- src/SynTree
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/Expression.cc
r2c88368 rd807ca28 748 748 } 749 749 750 GenericExpr::Association::Association( Type * type, Expression * expr ) : type( type ), expr( expr ), isDefault( false ) {} 751 GenericExpr::Association::Association( Expression * expr ) : type( nullptr ), expr( expr ), isDefault( true ) {} 752 GenericExpr::Association::Association( const Association & other ) : type( maybeClone( other.type ) ), expr( maybeClone( other.expr ) ), isDefault( other.isDefault ) {} 753 GenericExpr::Association::~Association() { 754 delete type; 755 delete expr; 756 } 757 758 GenericExpr::GenericExpr( Expression * control, const std::list<Association> & assoc ) : Expression(), control( control ), associations( assoc ) {} 759 GenericExpr::GenericExpr( const GenericExpr & other ) : Expression(other), control( maybeClone( other.control ) ), associations( other.associations ) { 760 } 761 GenericExpr::~GenericExpr() { 762 delete control; 763 } 764 765 void GenericExpr::print( std::ostream & os, Indenter indent ) const { 766 os << "C11 _Generic Expression" << std::endl << indent+1; 767 control->print( os, indent+1 ); 768 os << std::endl << indent+1 << "... with associations: " << std::endl; 769 for ( const Association & assoc : associations ) { 770 os << indent+1; 771 if (assoc.isDefault) { 772 os << "... default: "; 773 assoc.expr->print( os, indent+1 ); 774 } else { 775 os << "... type: "; 776 assoc.type->print( os, indent+1 ); 777 os << std::endl << indent+1 << "... expression: "; 778 assoc.expr->print( os, indent+1 ); 779 os << std::endl; 780 } 781 os << std::endl; 782 } 783 } 750 784 751 785 // Local Variables: // -
src/SynTree/Expression.h
r2c88368 rd807ca28 865 865 }; 866 866 867 /// C11 _Generic expression 868 class GenericExpr : public Expression { 869 public: 870 struct Association { 871 Type * type = nullptr; 872 Expression * expr = nullptr; 873 bool isDefault = false; 874 875 Association( Type * type, Expression * expr ); 876 Association( Expression * expr ); 877 Association( const Association & other ); 878 Association & operator=( const Association & other ) = delete; // at the moment this isn't used, and I don't want to implement it 879 ~Association(); 880 }; 881 882 Expression * control; 883 std::list<Association> associations; 884 885 GenericExpr( Expression * control, const std::list<Association> & assoc ); 886 GenericExpr( const GenericExpr & other ); 887 virtual ~GenericExpr(); 888 889 virtual GenericExpr * clone() const { return new GenericExpr( * this ); } 890 virtual void accept( Visitor & v ) { v.visit( this ); } 891 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 892 virtual void print( std::ostream & os, Indenter indent = {} ) const; 893 }; 894 867 895 // Local Variables: // 868 896 // tab-width: 4 // -
src/SynTree/Mutator.h
r2c88368 rd807ca28 93 93 virtual Expression * mutate( InitExpr * initExpr ) = 0; 94 94 virtual Expression * mutate( DeletedExpr * delExpr ) = 0; 95 virtual Expression * mutate( GenericExpr * genExpr ) = 0; 95 96 96 97 virtual Type * mutate( VoidType * basicType ) = 0; -
src/SynTree/SynTree.h
r2c88368 rd807ca28 101 101 class InitExpr; 102 102 class DeletedExpr; 103 class GenericExpr; 103 104 104 105 class Type; -
src/SynTree/Visitor.h
r2c88368 rd807ca28 95 95 virtual void visit( InitExpr * initExpr ) = 0; 96 96 virtual void visit( DeletedExpr * delExpr ) = 0; 97 virtual void visit( GenericExpr * genExpr ) = 0; 97 98 98 99 virtual void visit( VoidType * basicType ) = 0;
Note: See TracChangeset
for help on using the changeset viewer.