Changeset 90152a4 for src/SynTree/Expression.h
- Timestamp:
- Aug 27, 2018, 4:40:34 PM (7 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, cleanup-dtors, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- b7c89aa
- Parents:
- f9feab8 (diff), 305581d (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
rf9feab8 r90152a4 41 41 ParamEntry( UniqueId decl, Type * actualType, Type * formalType, Expression* expr ): decl( decl ), actualType( actualType ), formalType( formalType ), expr( expr ), inferParams( new InferredParams ) {} 42 42 ParamEntry( const ParamEntry & other ); 43 ParamEntry( ParamEntry && other ); 43 44 ~ParamEntry(); 44 45 ParamEntry & operator=( const ParamEntry & other ); 46 ParamEntry & operator=( ParamEntry && other ); 45 47 46 48 UniqueId decl; … … 74 76 InferredParams & get_inferParams() { return inferParams; } 75 77 78 // move other's inferParams to this 79 void spliceInferParams( Expression * other ); 80 76 81 virtual Expression * clone() const override = 0; 77 82 virtual void accept( Visitor & v ) override = 0; … … 188 193 public: 189 194 Expression * arg; 190 191 CastExpr( Expression * arg ); 192 CastExpr( Expression * arg, Type * toType ); 195 bool isGenerated = true; // whether this cast appeared in the source program 196 197 CastExpr( Expression * arg, bool isGenerated = true ); 198 CastExpr( Expression * arg, Type * toType, bool isGenerated = true ); 199 CastExpr( Expression * arg, void * ) = delete; // prevent accidentally passing pointers for isGenerated in the first constructor 193 200 CastExpr( const CastExpr & other ); 194 201 virtual ~CastExpr(); … … 198 205 199 206 virtual CastExpr * clone() const { return new CastExpr( * this ); } 207 virtual void accept( Visitor & v ) { v.visit( this ); } 208 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 209 virtual void print( std::ostream & os, Indenter indent = {} ) const; 210 }; 211 212 /// KeywordCastExpr represents a cast to 'keyword types', e.g. (thread &)t 213 class KeywordCastExpr : public Expression { 214 public: 215 Expression * arg; 216 enum Target { 217 Coroutine, Thread, Monitor, NUMBER_OF_TARGETS 218 } target; 219 220 KeywordCastExpr( Expression * arg, Target target ); 221 KeywordCastExpr( const KeywordCastExpr & other ); 222 virtual ~KeywordCastExpr(); 223 224 const std::string & targetString() const; 225 226 virtual KeywordCastExpr * clone() const { return new KeywordCastExpr( * this ); } 200 227 virtual void accept( Visitor & v ) { v.visit( this ); } 201 228 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } … … 295 322 296 323 Constant * get_constant() { return & constant; } 324 const Constant * get_constant() const { return & constant; } 297 325 void set_constant( const Constant & newValue ) { constant = newValue; } 326 327 long long int intValue() const; 298 328 299 329 virtual ConstantExpr * clone() const { return new ConstantExpr( * this ); } … … 725 755 StmtExpr * set_statements( CompoundStmt * newValue ) { statements = newValue; return this; } 726 756 757 // call to set the result type of this StmtExpr based on its body 758 void computeResult(); 759 727 760 std::list< ObjectDecl * > & get_returnDecls() { return returnDecls; } 728 761 std::list< Expression * > & get_dtors() { return dtors; } … … 816 849 }; 817 850 851 /// expression that contains a deleted identifier - should never make it past the resolver. 852 class DeletedExpr : public Expression { 853 public: 854 Expression * expr; 855 BaseSyntaxNode * deleteStmt; 856 857 DeletedExpr( Expression * expr, BaseSyntaxNode * deleteStmt ); 858 DeletedExpr( const DeletedExpr & other ); 859 ~DeletedExpr(); 860 861 virtual DeletedExpr * clone() const { return new DeletedExpr( * this ); } 862 virtual void accept( Visitor & v ) { v.visit( this ); } 863 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 864 virtual void print( std::ostream & os, Indenter indent = {} ) const; 865 }; 866 867 /// expression wrapping the use of a default argument - should never make it past the resolver. 868 class DefaultArgExpr : public Expression { 869 public: 870 Expression * expr; 871 872 DefaultArgExpr( Expression * expr ); 873 DefaultArgExpr( const DefaultArgExpr & other ); 874 ~DefaultArgExpr(); 875 876 virtual DefaultArgExpr * clone() const { return new DefaultArgExpr( * this ); } 877 virtual void accept( Visitor & v ) { v.visit( this ); } 878 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 879 virtual void print( std::ostream & os, Indenter indent = {} ) const; 880 }; 881 882 /// C11 _Generic expression 883 class GenericExpr : public Expression { 884 public: 885 struct Association { 886 Type * type = nullptr; 887 Expression * expr = nullptr; 888 bool isDefault = false; 889 890 Association( Type * type, Expression * expr ); 891 Association( Expression * expr ); 892 Association( const Association & other ); 893 Association & operator=( const Association & other ) = delete; // at the moment this isn't used, and I don't want to implement it 894 ~Association(); 895 }; 896 897 Expression * control; 898 std::list<Association> associations; 899 900 GenericExpr( Expression * control, const std::list<Association> & assoc ); 901 GenericExpr( const GenericExpr & other ); 902 virtual ~GenericExpr(); 903 904 virtual GenericExpr * clone() const { return new GenericExpr( * this ); } 905 virtual void accept( Visitor & v ) { v.visit( this ); } 906 virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } 907 virtual void print( std::ostream & os, Indenter indent = {} ) const; 908 }; 909 818 910 // Local Variables: // 819 911 // tab-width: 4 //
Note:
See TracChangeset
for help on using the changeset viewer.