[0dd3a2f] | 1 | // |
---|
| 2 | // Cforall Version 1.0.0 Copyright (C) 2015 University of Waterloo |
---|
| 3 | // |
---|
| 4 | // The contents of this file are covered under the licence agreement in the |
---|
| 5 | // file "LICENCE" distributed with Cforall. |
---|
| 6 | // |
---|
[3be261a] | 7 | // Expression.h -- |
---|
[0dd3a2f] | 8 | // |
---|
| 9 | // Author : Richard C. Bilson |
---|
| 10 | // Created On : Mon May 18 07:44:20 2015 |
---|
[e04ef3a] | 11 | // Last Modified By : Peter A. Buhr |
---|
[7bf7fb9] | 12 | // Last Modified On : Sat Aug 6 08:52:53 2016 |
---|
| 13 | // Update Count : 35 |
---|
[0dd3a2f] | 14 | // |
---|
[51b7345] | 15 | |
---|
| 16 | #ifndef EXPRESSION_H |
---|
| 17 | #define EXPRESSION_H |
---|
| 18 | |
---|
| 19 | #include <map> |
---|
[8688ce1] | 20 | #include <memory> |
---|
[51b7345] | 21 | #include "SynTree.h" |
---|
| 22 | #include "Visitor.h" |
---|
| 23 | #include "Mutator.h" |
---|
| 24 | #include "Constant.h" |
---|
[db4ecc5] | 25 | #include "Common/UniqueName.h" |
---|
[51b7345] | 26 | |
---|
[47534159] | 27 | /// Expression is the root type for all expressions |
---|
[0dd3a2f] | 28 | class Expression { |
---|
| 29 | public: |
---|
[7bf7fb9] | 30 | Expression( Expression *_aname = nullptr ); |
---|
[0dd3a2f] | 31 | Expression( const Expression &other ); |
---|
| 32 | virtual ~Expression(); |
---|
| 33 | |
---|
[906e24d] | 34 | Type *& get_result() { return result; } |
---|
| 35 | void set_result( Type *newValue ) { result = newValue; } |
---|
| 36 | bool has_result() const { return result != nullptr; } |
---|
[0dd3a2f] | 37 | |
---|
| 38 | TypeSubstitution *get_env() const { return env; } |
---|
| 39 | void set_env( TypeSubstitution *newValue ) { env = newValue; } |
---|
| 40 | Expression *get_argName() const { return argName; } |
---|
| 41 | void set_argName( Expression *name ) { argName = name; } |
---|
[e04ef3a] | 42 | bool get_extension() const { return extension; } |
---|
[8e9cbb2] | 43 | Expression * set_extension( bool exten ) { extension = exten; return this; } |
---|
[0dd3a2f] | 44 | |
---|
| 45 | virtual Expression *clone() const = 0; |
---|
| 46 | virtual void accept( Visitor &v ) = 0; |
---|
| 47 | virtual Expression *acceptMutator( Mutator &m ) = 0; |
---|
| 48 | virtual void print( std::ostream &os, int indent = 0 ) const; |
---|
| 49 | protected: |
---|
[906e24d] | 50 | Type * result; |
---|
[0dd3a2f] | 51 | TypeSubstitution *env; |
---|
| 52 | Expression* argName; // if expression is used as an argument, it can be "designated" by this name |
---|
[e04ef3a] | 53 | bool extension = false; |
---|
[51b7345] | 54 | }; |
---|
| 55 | |
---|
[47534159] | 56 | /// ParamEntry contains the i.d. of a declaration and a type that is derived from that declaration, |
---|
| 57 | /// but subject to decay-to-pointer and type parameter renaming |
---|
[0dd3a2f] | 58 | struct ParamEntry { |
---|
| 59 | ParamEntry(): decl( 0 ), actualType( 0 ), formalType( 0 ), expr( 0 ) {} |
---|
| 60 | ParamEntry( UniqueId decl, Type *actualType, Type *formalType, Expression* expr ): decl( decl ), actualType( actualType ), formalType( formalType ), expr( expr ) {} |
---|
| 61 | ParamEntry( const ParamEntry &other ); |
---|
| 62 | ~ParamEntry(); |
---|
| 63 | ParamEntry &operator=( const ParamEntry &other ); |
---|
| 64 | |
---|
| 65 | UniqueId decl; |
---|
| 66 | Type *actualType; |
---|
| 67 | Type *formalType; |
---|
| 68 | Expression* expr; |
---|
[51b7345] | 69 | }; |
---|
| 70 | |
---|
| 71 | typedef std::map< UniqueId, ParamEntry > InferredParams; |
---|
| 72 | |
---|
[9706554] | 73 | /// ApplicationExpr represents the application of a function to a set of parameters. This is the result of running an |
---|
| 74 | /// UntypedExpr through the expression analyzer. |
---|
[0dd3a2f] | 75 | class ApplicationExpr : public Expression { |
---|
| 76 | public: |
---|
| 77 | ApplicationExpr( Expression *function ); |
---|
| 78 | ApplicationExpr( const ApplicationExpr &other ); |
---|
| 79 | virtual ~ApplicationExpr(); |
---|
| 80 | |
---|
| 81 | Expression *get_function() const { return function; } |
---|
| 82 | void set_function( Expression *newValue ) { function = newValue; } |
---|
| 83 | std::list<Expression *>& get_args() { return args; } |
---|
| 84 | InferredParams &get_inferParams() { return inferParams; } |
---|
| 85 | |
---|
| 86 | virtual ApplicationExpr *clone() const { return new ApplicationExpr( *this ); } |
---|
| 87 | virtual void accept( Visitor &v ) { v.visit( this ); } |
---|
| 88 | virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); } |
---|
| 89 | virtual void print( std::ostream &os, int indent = 0 ) const; |
---|
| 90 | private: |
---|
| 91 | Expression *function; |
---|
| 92 | std::list<Expression *> args; |
---|
| 93 | InferredParams inferParams; |
---|
[51b7345] | 94 | }; |
---|
| 95 | |
---|
[9706554] | 96 | /// UntypedExpr represents the application of a function to a set of parameters, but where the particular overload for |
---|
| 97 | /// the function name has not yet been determined. Most operators are converted into functional form automatically, to |
---|
| 98 | /// permit operator overloading. |
---|
[0dd3a2f] | 99 | class UntypedExpr : public Expression { |
---|
| 100 | public: |
---|
[6eb8948] | 101 | UntypedExpr( Expression *function, const std::list<Expression *> &args = std::list< Expression * >(), Expression *_aname = nullptr ); |
---|
[0dd3a2f] | 102 | UntypedExpr( const UntypedExpr &other ); |
---|
| 103 | virtual ~UntypedExpr(); |
---|
| 104 | |
---|
| 105 | Expression *get_function() const { return function; } |
---|
| 106 | void set_function( Expression *newValue ) { function = newValue; } |
---|
| 107 | |
---|
| 108 | void set_args( std::list<Expression *> &listArgs ) { args = listArgs; } |
---|
| 109 | std::list<Expression*>::iterator begin_args() { return args.begin(); } |
---|
| 110 | std::list<Expression*>::iterator end_args() { return args.end(); } |
---|
| 111 | std::list<Expression*>& get_args() { return args; } |
---|
| 112 | |
---|
[b3b2077] | 113 | static UntypedExpr * createDeref( Expression * arg ); |
---|
| 114 | static UntypedExpr * createAssign( Expression * arg1, Expression * arg2 ); |
---|
| 115 | |
---|
[0dd3a2f] | 116 | virtual UntypedExpr *clone() const { return new UntypedExpr( *this ); } |
---|
| 117 | virtual void accept( Visitor &v ) { v.visit( this ); } |
---|
| 118 | virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); } |
---|
| 119 | virtual void print( std::ostream &os, int indent = 0 ) const; |
---|
| 120 | virtual void printArgs(std::ostream &os, int indent = 0) const; |
---|
| 121 | private: |
---|
| 122 | Expression *function; |
---|
| 123 | std::list<Expression*> args; |
---|
[51b7345] | 124 | }; |
---|
| 125 | |
---|
[47534159] | 126 | /// NameExpr contains a name whose meaning is still not determined |
---|
[0dd3a2f] | 127 | class NameExpr : public Expression { |
---|
| 128 | public: |
---|
[7bf7fb9] | 129 | NameExpr( std::string name, Expression *_aname = nullptr ); |
---|
[0dd3a2f] | 130 | NameExpr( const NameExpr &other ); |
---|
| 131 | virtual ~NameExpr(); |
---|
| 132 | |
---|
[5f2f2d7] | 133 | const std::string &get_name() const { return name; } |
---|
[0dd3a2f] | 134 | void set_name( std::string newValue ) { name = newValue; } |
---|
| 135 | |
---|
| 136 | virtual NameExpr *clone() const { return new NameExpr( *this ); } |
---|
| 137 | virtual void accept( Visitor &v ) { v.visit( this ); } |
---|
| 138 | virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); } |
---|
| 139 | virtual void print( std::ostream &os, int indent = 0 ) const; |
---|
| 140 | private: |
---|
| 141 | std::string name; |
---|
[51b7345] | 142 | }; |
---|
| 143 | |
---|
| 144 | // The following classes are used to represent expression types that cannot be converted into |
---|
| 145 | // function-call format. |
---|
| 146 | |
---|
[47534159] | 147 | /// AddressExpr represents a address-of expression, e.g. &e |
---|
[0dd3a2f] | 148 | class AddressExpr : public Expression { |
---|
| 149 | public: |
---|
[7bf7fb9] | 150 | AddressExpr( Expression *arg, Expression *_aname = nullptr ); |
---|
[0dd3a2f] | 151 | AddressExpr( const AddressExpr &other ); |
---|
| 152 | virtual ~AddressExpr(); |
---|
| 153 | |
---|
| 154 | Expression *get_arg() const { return arg; } |
---|
| 155 | void set_arg(Expression *newValue ) { arg = newValue; } |
---|
| 156 | |
---|
| 157 | virtual AddressExpr *clone() const { return new AddressExpr( *this ); } |
---|
| 158 | virtual void accept( Visitor &v ) { v.visit( this ); } |
---|
| 159 | virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); } |
---|
| 160 | virtual void print( std::ostream &os, int indent = 0 ) const; |
---|
| 161 | private: |
---|
| 162 | Expression *arg; |
---|
[51b7345] | 163 | }; |
---|
| 164 | |
---|
[3be261a] | 165 | // xxx - this doesn't appear to actually be hooked in anywhere. We should use this instead of the "&&"" UntypedExpr hack |
---|
[0dd3a2f] | 166 | class LabelAddressExpr : public Expression { |
---|
| 167 | public: |
---|
| 168 | LabelAddressExpr( Expression *arg ); |
---|
[3be261a] | 169 | LabelAddressExpr( const LabelAddressExpr &other ); |
---|
[0dd3a2f] | 170 | virtual ~LabelAddressExpr(); |
---|
| 171 | |
---|
| 172 | Expression *get_arg() const { return arg; } |
---|
| 173 | void set_arg(Expression *newValue ) { arg = newValue; } |
---|
| 174 | |
---|
| 175 | virtual LabelAddressExpr *clone() const { return new LabelAddressExpr( *this ); } |
---|
| 176 | virtual void accept( Visitor &v ) { v.visit( this ); } |
---|
| 177 | virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); } |
---|
| 178 | virtual void print( std::ostream &os, int indent = 0 ) const; |
---|
| 179 | private: |
---|
| 180 | Expression *arg; |
---|
[51b7345] | 181 | }; |
---|
| 182 | |
---|
[47534159] | 183 | /// CastExpr represents a type cast expression, e.g. (int)e |
---|
[0dd3a2f] | 184 | class CastExpr : public Expression { |
---|
| 185 | public: |
---|
[7bf7fb9] | 186 | CastExpr( Expression *arg, Expression *_aname = nullptr ); |
---|
| 187 | CastExpr( Expression *arg, Type *toType, Expression *_aname = nullptr ); |
---|
[0dd3a2f] | 188 | CastExpr( const CastExpr &other ); |
---|
| 189 | virtual ~CastExpr(); |
---|
| 190 | |
---|
| 191 | Expression *get_arg() const { return arg; } |
---|
| 192 | void set_arg(Expression *newValue ) { arg = newValue; } |
---|
| 193 | |
---|
| 194 | virtual CastExpr *clone() const { return new CastExpr( *this ); } |
---|
| 195 | virtual void accept( Visitor &v ) { v.visit( this ); } |
---|
| 196 | virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); } |
---|
| 197 | virtual void print( std::ostream &os, int indent = 0 ) const; |
---|
| 198 | private: |
---|
| 199 | Expression *arg; |
---|
[51b7345] | 200 | }; |
---|
| 201 | |
---|
[47534159] | 202 | /// UntypedMemberExpr represents a member selection operation, e.g. q.p before processing by the expression analyzer |
---|
[0dd3a2f] | 203 | class UntypedMemberExpr : public Expression { |
---|
| 204 | public: |
---|
[3b58d91] | 205 | UntypedMemberExpr( Expression *member, Expression *aggregate, Expression *_aname = nullptr ); |
---|
[0dd3a2f] | 206 | UntypedMemberExpr( const UntypedMemberExpr &other ); |
---|
| 207 | virtual ~UntypedMemberExpr(); |
---|
| 208 | |
---|
[3b58d91] | 209 | Expression * get_member() const { return member; } |
---|
| 210 | void set_member( Expression * newValue ) { member = newValue; } |
---|
[0dd3a2f] | 211 | Expression *get_aggregate() const { return aggregate; } |
---|
| 212 | void set_aggregate( Expression *newValue ) { aggregate = newValue; } |
---|
| 213 | |
---|
| 214 | virtual UntypedMemberExpr *clone() const { return new UntypedMemberExpr( *this ); } |
---|
| 215 | virtual void accept( Visitor &v ) { v.visit( this ); } |
---|
| 216 | virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); } |
---|
| 217 | virtual void print( std::ostream &os, int indent = 0 ) const; |
---|
| 218 | private: |
---|
[3b58d91] | 219 | Expression *member; |
---|
[0dd3a2f] | 220 | Expression *aggregate; |
---|
[51b7345] | 221 | }; |
---|
| 222 | |
---|
[47534159] | 223 | /// MemberExpr represents a member selection operation, e.g. q.p after processing by the expression analyzer |
---|
[0dd3a2f] | 224 | class MemberExpr : public Expression { |
---|
| 225 | public: |
---|
[7bf7fb9] | 226 | MemberExpr( DeclarationWithType *member, Expression *aggregate, Expression *_aname = nullptr ); |
---|
[0dd3a2f] | 227 | MemberExpr( const MemberExpr &other ); |
---|
| 228 | virtual ~MemberExpr(); |
---|
| 229 | |
---|
| 230 | DeclarationWithType *get_member() const { return member; } |
---|
| 231 | void set_member( DeclarationWithType *newValue ) { member = newValue; } |
---|
| 232 | Expression *get_aggregate() const { return aggregate; } |
---|
| 233 | void set_aggregate( Expression *newValue ) { aggregate = newValue; } |
---|
| 234 | |
---|
| 235 | virtual MemberExpr *clone() const { return new MemberExpr( *this ); } |
---|
| 236 | virtual void accept( Visitor &v ) { v.visit( this ); } |
---|
| 237 | virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); } |
---|
| 238 | virtual void print( std::ostream &os, int indent = 0 ) const; |
---|
| 239 | private: |
---|
| 240 | DeclarationWithType *member; |
---|
| 241 | Expression *aggregate; |
---|
[51b7345] | 242 | }; |
---|
| 243 | |
---|
[47534159] | 244 | /// VariableExpr represents an expression that simply refers to the value of a named variable |
---|
[0dd3a2f] | 245 | class VariableExpr : public Expression { |
---|
| 246 | public: |
---|
[7bf7fb9] | 247 | VariableExpr( DeclarationWithType *var, Expression *_aname = nullptr ); |
---|
[0dd3a2f] | 248 | VariableExpr( const VariableExpr &other ); |
---|
| 249 | virtual ~VariableExpr(); |
---|
| 250 | |
---|
| 251 | DeclarationWithType *get_var() const { return var; } |
---|
| 252 | void set_var( DeclarationWithType *newValue ) { var = newValue; } |
---|
| 253 | |
---|
| 254 | virtual VariableExpr *clone() const { return new VariableExpr( *this ); } |
---|
| 255 | virtual void accept( Visitor &v ) { v.visit( this ); } |
---|
| 256 | virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); } |
---|
| 257 | virtual void print( std::ostream &os, int indent = 0 ) const; |
---|
| 258 | private: |
---|
| 259 | DeclarationWithType *var; |
---|
[51b7345] | 260 | }; |
---|
| 261 | |
---|
[3be261a] | 262 | /// ConstantExpr represents an expression that simply refers to the value of a constant |
---|
[0dd3a2f] | 263 | class ConstantExpr : public Expression { |
---|
| 264 | public: |
---|
[7bf7fb9] | 265 | ConstantExpr( Constant constant, Expression *_aname = nullptr ); |
---|
[0dd3a2f] | 266 | ConstantExpr( const ConstantExpr &other ); |
---|
| 267 | virtual ~ConstantExpr(); |
---|
| 268 | |
---|
| 269 | Constant *get_constant() { return &constant; } |
---|
| 270 | void set_constant( const Constant &newValue ) { constant = newValue; } |
---|
| 271 | |
---|
| 272 | virtual ConstantExpr *clone() const { return new ConstantExpr( *this ); } |
---|
| 273 | virtual void accept( Visitor &v ) { v.visit( this ); } |
---|
| 274 | virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); } |
---|
| 275 | virtual void print( std::ostream &os, int indent = 0 ) const; |
---|
| 276 | private: |
---|
| 277 | Constant constant; |
---|
[51b7345] | 278 | }; |
---|
| 279 | |
---|
[47534159] | 280 | /// SizeofExpr represents a sizeof expression (could be sizeof(int) or sizeof 3+4) |
---|
[0dd3a2f] | 281 | class SizeofExpr : public Expression { |
---|
| 282 | public: |
---|
[7bf7fb9] | 283 | SizeofExpr( Expression *expr, Expression *_aname = nullptr ); |
---|
[0dd3a2f] | 284 | SizeofExpr( const SizeofExpr &other ); |
---|
[7bf7fb9] | 285 | SizeofExpr( Type *type, Expression *_aname = nullptr ); |
---|
[0dd3a2f] | 286 | virtual ~SizeofExpr(); |
---|
| 287 | |
---|
| 288 | Expression *get_expr() const { return expr; } |
---|
| 289 | void set_expr( Expression *newValue ) { expr = newValue; } |
---|
| 290 | Type *get_type() const { return type; } |
---|
| 291 | void set_type( Type *newValue ) { type = newValue; } |
---|
| 292 | bool get_isType() const { return isType; } |
---|
| 293 | void set_isType( bool newValue ) { isType = newValue; } |
---|
| 294 | |
---|
| 295 | virtual SizeofExpr *clone() const { return new SizeofExpr( *this ); } |
---|
| 296 | virtual void accept( Visitor &v ) { v.visit( this ); } |
---|
| 297 | virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); } |
---|
| 298 | virtual void print( std::ostream &os, int indent = 0 ) const; |
---|
| 299 | private: |
---|
| 300 | Expression *expr; |
---|
| 301 | Type *type; |
---|
| 302 | bool isType; |
---|
[51b7345] | 303 | }; |
---|
| 304 | |
---|
[47534159] | 305 | /// AlignofExpr represents an alignof expression |
---|
| 306 | class AlignofExpr : public Expression { |
---|
| 307 | public: |
---|
[7bf7fb9] | 308 | AlignofExpr( Expression *expr, Expression *_aname = nullptr ); |
---|
[47534159] | 309 | AlignofExpr( const AlignofExpr &other ); |
---|
[7bf7fb9] | 310 | AlignofExpr( Type *type, Expression *_aname = nullptr ); |
---|
[47534159] | 311 | virtual ~AlignofExpr(); |
---|
| 312 | |
---|
| 313 | Expression *get_expr() const { return expr; } |
---|
| 314 | void set_expr( Expression *newValue ) { expr = newValue; } |
---|
| 315 | Type *get_type() const { return type; } |
---|
| 316 | void set_type( Type *newValue ) { type = newValue; } |
---|
| 317 | bool get_isType() const { return isType; } |
---|
| 318 | void set_isType( bool newValue ) { isType = newValue; } |
---|
| 319 | |
---|
| 320 | virtual AlignofExpr *clone() const { return new AlignofExpr( *this ); } |
---|
| 321 | virtual void accept( Visitor &v ) { v.visit( this ); } |
---|
| 322 | virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); } |
---|
| 323 | virtual void print( std::ostream &os, int indent = 0 ) const; |
---|
| 324 | private: |
---|
| 325 | Expression *expr; |
---|
| 326 | Type *type; |
---|
| 327 | bool isType; |
---|
| 328 | }; |
---|
| 329 | |
---|
[2a4b088] | 330 | /// UntypedOffsetofExpr represents an offsetof expression before resolution |
---|
| 331 | class UntypedOffsetofExpr : public Expression { |
---|
| 332 | public: |
---|
[7bf7fb9] | 333 | UntypedOffsetofExpr( Type *type, const std::string &member, Expression *_aname = nullptr ); |
---|
[2a4b088] | 334 | UntypedOffsetofExpr( const UntypedOffsetofExpr &other ); |
---|
| 335 | virtual ~UntypedOffsetofExpr(); |
---|
| 336 | |
---|
| 337 | std::string get_member() const { return member; } |
---|
| 338 | void set_member( const std::string &newValue ) { member = newValue; } |
---|
| 339 | Type *get_type() const { return type; } |
---|
| 340 | void set_type( Type *newValue ) { type = newValue; } |
---|
| 341 | |
---|
| 342 | virtual UntypedOffsetofExpr *clone() const { return new UntypedOffsetofExpr( *this ); } |
---|
| 343 | virtual void accept( Visitor &v ) { v.visit( this ); } |
---|
| 344 | virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); } |
---|
| 345 | virtual void print( std::ostream &os, int indent = 0 ) const; |
---|
| 346 | private: |
---|
| 347 | Type *type; |
---|
| 348 | std::string member; |
---|
| 349 | }; |
---|
| 350 | |
---|
[25a054f] | 351 | /// OffsetofExpr represents an offsetof expression |
---|
| 352 | class OffsetofExpr : public Expression { |
---|
| 353 | public: |
---|
[7bf7fb9] | 354 | OffsetofExpr( Type *type, DeclarationWithType *member, Expression *_aname = nullptr ); |
---|
[25a054f] | 355 | OffsetofExpr( const OffsetofExpr &other ); |
---|
| 356 | virtual ~OffsetofExpr(); |
---|
| 357 | |
---|
| 358 | Type *get_type() const { return type; } |
---|
| 359 | void set_type( Type *newValue ) { type = newValue; } |
---|
| 360 | DeclarationWithType *get_member() const { return member; } |
---|
| 361 | void set_member( DeclarationWithType *newValue ) { member = newValue; } |
---|
| 362 | |
---|
| 363 | virtual OffsetofExpr *clone() const { return new OffsetofExpr( *this ); } |
---|
| 364 | virtual void accept( Visitor &v ) { v.visit( this ); } |
---|
| 365 | virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); } |
---|
| 366 | virtual void print( std::ostream &os, int indent = 0 ) const; |
---|
| 367 | private: |
---|
| 368 | Type *type; |
---|
| 369 | DeclarationWithType *member; |
---|
| 370 | }; |
---|
| 371 | |
---|
[afc1045] | 372 | /// Expression representing a pack of field-offsets for a generic type |
---|
| 373 | class OffsetPackExpr : public Expression { |
---|
| 374 | public: |
---|
| 375 | OffsetPackExpr( StructInstType *type_, Expression *aname_ = 0 ); |
---|
| 376 | OffsetPackExpr( const OffsetPackExpr &other ); |
---|
| 377 | virtual ~OffsetPackExpr(); |
---|
| 378 | |
---|
| 379 | StructInstType *get_type() const { return type; } |
---|
| 380 | void set_type( StructInstType *newValue ) { type = newValue; } |
---|
| 381 | |
---|
| 382 | virtual OffsetPackExpr *clone() const { return new OffsetPackExpr( *this ); } |
---|
| 383 | virtual void accept( Visitor &v ) { v.visit( this ); } |
---|
| 384 | virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); } |
---|
| 385 | |
---|
| 386 | virtual void print( std::ostream &os, int indent = 0 ) const; |
---|
| 387 | |
---|
| 388 | private: |
---|
| 389 | StructInstType *type; |
---|
| 390 | }; |
---|
| 391 | |
---|
[47534159] | 392 | /// AttrExpr represents an @attribute expression (like sizeof, but user-defined) |
---|
[0dd3a2f] | 393 | class AttrExpr : public Expression { |
---|
| 394 | public: |
---|
[7bf7fb9] | 395 | AttrExpr(Expression *attr, Expression *expr, Expression *_aname = nullptr ); |
---|
[0dd3a2f] | 396 | AttrExpr( const AttrExpr &other ); |
---|
[7bf7fb9] | 397 | AttrExpr( Expression *attr, Type *type, Expression *_aname = nullptr ); |
---|
[0dd3a2f] | 398 | virtual ~AttrExpr(); |
---|
| 399 | |
---|
| 400 | Expression *get_attr() const { return attr; } |
---|
| 401 | void set_attr( Expression *newValue ) { attr = newValue; } |
---|
| 402 | Expression *get_expr() const { return expr; } |
---|
| 403 | void set_expr( Expression *newValue ) { expr = newValue; } |
---|
| 404 | Type *get_type() const { return type; } |
---|
| 405 | void set_type( Type *newValue ) { type = newValue; } |
---|
| 406 | bool get_isType() const { return isType; } |
---|
| 407 | void set_isType( bool newValue ) { isType = newValue; } |
---|
| 408 | |
---|
| 409 | virtual AttrExpr *clone() const { return new AttrExpr( *this ); } |
---|
| 410 | virtual void accept( Visitor &v ) { v.visit( this ); } |
---|
| 411 | virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); } |
---|
| 412 | virtual void print( std::ostream &os, int indent = 0 ) const; |
---|
| 413 | private: |
---|
| 414 | Expression *attr; |
---|
| 415 | Expression *expr; |
---|
| 416 | Type *type; |
---|
| 417 | bool isType; |
---|
[51b7345] | 418 | }; |
---|
| 419 | |
---|
[47534159] | 420 | /// LogicalExpr represents a short-circuit boolean expression (&& or ||) |
---|
[0dd3a2f] | 421 | class LogicalExpr : public Expression { |
---|
| 422 | public: |
---|
[7bf7fb9] | 423 | LogicalExpr( Expression *arg1, Expression *arg2, bool andp = true, Expression *_aname = nullptr ); |
---|
[0dd3a2f] | 424 | LogicalExpr( const LogicalExpr &other ); |
---|
| 425 | virtual ~LogicalExpr(); |
---|
| 426 | |
---|
| 427 | bool get_isAnd() const { return isAnd; } |
---|
| 428 | Expression *get_arg1() { return arg1; } |
---|
| 429 | void set_arg1( Expression *newValue ) { arg1 = newValue; } |
---|
| 430 | Expression *get_arg2() const { return arg2; } |
---|
| 431 | void set_arg2( Expression *newValue ) { arg2 = newValue; } |
---|
| 432 | |
---|
| 433 | virtual LogicalExpr *clone() const { return new LogicalExpr( *this ); } |
---|
| 434 | virtual void accept( Visitor &v ) { v.visit( this ); } |
---|
| 435 | virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); } |
---|
| 436 | virtual void print( std::ostream &os, int indent = 0 ) const; |
---|
| 437 | private: |
---|
| 438 | Expression *arg1; |
---|
| 439 | Expression *arg2; |
---|
| 440 | bool isAnd; |
---|
[51b7345] | 441 | }; |
---|
| 442 | |
---|
[47534159] | 443 | /// ConditionalExpr represents the three-argument conditional ( p ? a : b ) |
---|
[0dd3a2f] | 444 | class ConditionalExpr : public Expression { |
---|
| 445 | public: |
---|
[7bf7fb9] | 446 | ConditionalExpr( Expression *arg1, Expression *arg2, Expression *arg3, Expression *_aname = nullptr ); |
---|
[0dd3a2f] | 447 | ConditionalExpr( const ConditionalExpr &other ); |
---|
| 448 | virtual ~ConditionalExpr(); |
---|
| 449 | |
---|
| 450 | Expression *get_arg1() const { return arg1; } |
---|
| 451 | void set_arg1( Expression *newValue ) { arg1 = newValue; } |
---|
| 452 | Expression *get_arg2() const { return arg2; } |
---|
| 453 | void set_arg2( Expression *newValue ) { arg2 = newValue; } |
---|
| 454 | Expression *get_arg3() const { return arg3; } |
---|
| 455 | void set_arg3( Expression *newValue ) { arg3 = newValue; } |
---|
| 456 | |
---|
| 457 | virtual ConditionalExpr *clone() const { return new ConditionalExpr( *this ); } |
---|
| 458 | virtual void accept( Visitor &v ) { v.visit( this ); } |
---|
| 459 | virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); } |
---|
| 460 | virtual void print( std::ostream &os, int indent = 0 ) const; |
---|
| 461 | private: |
---|
| 462 | Expression *arg1; |
---|
| 463 | Expression *arg2; |
---|
| 464 | Expression *arg3; |
---|
[51b7345] | 465 | }; |
---|
| 466 | |
---|
[47534159] | 467 | /// CommaExpr represents the sequence operator ( a, b ) |
---|
[0dd3a2f] | 468 | class CommaExpr : public Expression { |
---|
| 469 | public: |
---|
[7bf7fb9] | 470 | CommaExpr( Expression *arg1, Expression *arg2, Expression *_aname = nullptr ); |
---|
[0dd3a2f] | 471 | CommaExpr( const CommaExpr &other ); |
---|
| 472 | virtual ~CommaExpr(); |
---|
| 473 | |
---|
| 474 | Expression *get_arg1() const { return arg1; } |
---|
| 475 | void set_arg1( Expression *newValue ) { arg1 = newValue; } |
---|
| 476 | Expression *get_arg2() const { return arg2; } |
---|
| 477 | void set_arg2( Expression *newValue ) { arg2 = newValue; } |
---|
| 478 | |
---|
| 479 | virtual CommaExpr *clone() const { return new CommaExpr( *this ); } |
---|
| 480 | virtual void accept( Visitor &v ) { v.visit( this ); } |
---|
| 481 | virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); } |
---|
| 482 | virtual void print( std::ostream &os, int indent = 0 ) const; |
---|
| 483 | private: |
---|
| 484 | Expression *arg1; |
---|
| 485 | Expression *arg2; |
---|
[51b7345] | 486 | }; |
---|
| 487 | |
---|
[47534159] | 488 | /// TypeExpr represents a type used in an expression (e.g. as a type generator parameter) |
---|
[0dd3a2f] | 489 | class TypeExpr : public Expression { |
---|
| 490 | public: |
---|
| 491 | TypeExpr( Type *type ); |
---|
| 492 | TypeExpr( const TypeExpr &other ); |
---|
| 493 | virtual ~TypeExpr(); |
---|
| 494 | |
---|
| 495 | Type *get_type() const { return type; } |
---|
| 496 | void set_type( Type *newValue ) { type = newValue; } |
---|
| 497 | |
---|
| 498 | virtual TypeExpr *clone() const { return new TypeExpr( *this ); } |
---|
| 499 | virtual void accept( Visitor &v ) { v.visit( this ); } |
---|
| 500 | virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); } |
---|
| 501 | virtual void print( std::ostream &os, int indent = 0 ) const; |
---|
| 502 | private: |
---|
| 503 | Type *type; |
---|
[51b7345] | 504 | }; |
---|
| 505 | |
---|
[47534159] | 506 | /// AsmExpr represents a GCC 'asm constraint operand' used in an asm statement: [output] "=f" (result) |
---|
[7f5566b] | 507 | class AsmExpr : public Expression { |
---|
| 508 | public: |
---|
| 509 | AsmExpr( Expression *inout, ConstantExpr *constraint, Expression *operand ) : inout( inout ), constraint( constraint ), operand( operand ) {} |
---|
[3be261a] | 510 | AsmExpr( const AsmExpr & other ); |
---|
[7f5566b] | 511 | virtual ~AsmExpr() { delete inout; delete constraint; delete operand; }; |
---|
| 512 | |
---|
| 513 | Expression *get_inout() const { return inout; } |
---|
| 514 | void set_inout( Expression *newValue ) { inout = newValue; } |
---|
| 515 | |
---|
| 516 | ConstantExpr *get_constraint() const { return constraint; } |
---|
| 517 | void set_constraint( ConstantExpr *newValue ) { constraint = newValue; } |
---|
| 518 | |
---|
| 519 | Expression *get_operand() const { return operand; } |
---|
| 520 | void set_operand( Expression *newValue ) { operand = newValue; } |
---|
| 521 | |
---|
| 522 | virtual AsmExpr *clone() const { return new AsmExpr( *this ); } |
---|
| 523 | virtual void accept( Visitor &v ) { v.visit( this ); } |
---|
| 524 | virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); } |
---|
| 525 | virtual void print( std::ostream &os, int indent = 0 ) const; |
---|
| 526 | private: |
---|
| 527 | // https://gcc.gnu.org/onlinedocs/gcc-4.7.1/gcc/Machine-Constraints.html#Machine-Constraints |
---|
| 528 | Expression *inout; |
---|
| 529 | ConstantExpr *constraint; |
---|
| 530 | Expression *operand; |
---|
| 531 | }; |
---|
| 532 | |
---|
[db4ecc5] | 533 | /// ImplicitCopyCtorExpr represents the application of a function to a set of parameters, |
---|
| 534 | /// along with a set of copy constructor calls, one for each argument. |
---|
| 535 | class ImplicitCopyCtorExpr : public Expression { |
---|
| 536 | public: |
---|
| 537 | ImplicitCopyCtorExpr( ApplicationExpr * callExpr ); |
---|
| 538 | ImplicitCopyCtorExpr( const ImplicitCopyCtorExpr & other ); |
---|
| 539 | virtual ~ImplicitCopyCtorExpr(); |
---|
| 540 | |
---|
| 541 | ApplicationExpr *get_callExpr() const { return callExpr; } |
---|
| 542 | void set_callExpr( ApplicationExpr *newValue ) { callExpr = newValue; } |
---|
| 543 | |
---|
| 544 | std::list< ObjectDecl * > & get_tempDecls() { return tempDecls; } |
---|
| 545 | void set_tempDecls( std::list< ObjectDecl * > newValue ) { tempDecls = newValue; } |
---|
| 546 | |
---|
| 547 | std::list< ObjectDecl * > & get_returnDecls() { return returnDecls; } |
---|
| 548 | void set_returnDecls( std::list< ObjectDecl * > newValue ) { returnDecls = newValue; } |
---|
| 549 | |
---|
| 550 | std::list< Expression * > & get_dtors() { return dtors; } |
---|
| 551 | void set_dtors( std::list< Expression * > newValue ) { dtors = newValue; } |
---|
| 552 | |
---|
| 553 | virtual ImplicitCopyCtorExpr *clone() const { return new ImplicitCopyCtorExpr( *this ); } |
---|
| 554 | virtual void accept( Visitor &v ) { v.visit( this ); } |
---|
| 555 | virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); } |
---|
| 556 | virtual void print( std::ostream &os, int indent = 0 ) const; |
---|
| 557 | private: |
---|
| 558 | ApplicationExpr * callExpr; |
---|
| 559 | std::list< ObjectDecl * > tempDecls; |
---|
| 560 | std::list< ObjectDecl * > returnDecls; |
---|
| 561 | std::list< Expression * > dtors; |
---|
| 562 | }; |
---|
| 563 | |
---|
[b6fe7e6] | 564 | /// ConstructorExpr represents the use of a constructor in an expression context, e.g. int * x = malloc() { 5 }; |
---|
| 565 | class ConstructorExpr : public Expression { |
---|
| 566 | public: |
---|
| 567 | ConstructorExpr( Expression * callExpr ); |
---|
| 568 | ConstructorExpr( const ConstructorExpr & other ); |
---|
| 569 | ~ConstructorExpr(); |
---|
[0dd3a2f] | 570 | |
---|
[b6fe7e6] | 571 | Expression *get_callExpr() const { return callExpr; } |
---|
| 572 | void set_callExpr( Expression *newValue ) { callExpr = newValue; } |
---|
[0dd3a2f] | 573 | |
---|
[b6fe7e6] | 574 | virtual ConstructorExpr *clone() const { return new ConstructorExpr( *this ); } |
---|
[0dd3a2f] | 575 | virtual void accept( Visitor &v ) { v.visit( this ); } |
---|
| 576 | virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); } |
---|
| 577 | virtual void print( std::ostream &os, int indent = 0 ) const; |
---|
[b6fe7e6] | 578 | private: |
---|
| 579 | Expression * callExpr; |
---|
[51b7345] | 580 | }; |
---|
| 581 | |
---|
[630a82a] | 582 | /// CompoundLiteralExpr represents a C99 'compound literal' |
---|
| 583 | class CompoundLiteralExpr : public Expression { |
---|
| 584 | public: |
---|
| 585 | CompoundLiteralExpr( Type * type, Initializer * initializer ); |
---|
| 586 | CompoundLiteralExpr( const CompoundLiteralExpr &other ); |
---|
[3b58d91] | 587 | virtual ~CompoundLiteralExpr(); |
---|
[630a82a] | 588 | |
---|
| 589 | Type * get_type() const { return type; } |
---|
| 590 | void set_type( Type * t ) { type = t; } |
---|
| 591 | |
---|
| 592 | Initializer * get_initializer() const { return initializer; } |
---|
| 593 | void set_initializer( Initializer * i ) { initializer = i; } |
---|
| 594 | |
---|
| 595 | virtual CompoundLiteralExpr *clone() const { return new CompoundLiteralExpr( *this ); } |
---|
| 596 | virtual void accept( Visitor &v ) { v.visit( this ); } |
---|
| 597 | virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); } |
---|
| 598 | virtual void print( std::ostream &os, int indent = 0 ) const; |
---|
| 599 | private: |
---|
| 600 | Type * type; |
---|
| 601 | Initializer * initializer; |
---|
| 602 | }; |
---|
| 603 | |
---|
[b6fe7e6] | 604 | /// ValofExpr represents a GCC 'lambda expression' |
---|
| 605 | class UntypedValofExpr : public Expression { |
---|
| 606 | public: |
---|
| 607 | UntypedValofExpr( Statement *_body, Expression *_aname = nullptr ) : Expression( _aname ), body ( _body ) {} |
---|
| 608 | UntypedValofExpr( const UntypedValofExpr & other ); |
---|
| 609 | virtual ~UntypedValofExpr(); |
---|
| 610 | |
---|
| 611 | Expression *get_value(); |
---|
| 612 | Statement *get_body() const { return body; } |
---|
| 613 | |
---|
| 614 | virtual UntypedValofExpr *clone() const { return new UntypedValofExpr( *this ); } |
---|
| 615 | virtual void accept( Visitor &v ) { v.visit( this ); } |
---|
| 616 | virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); } |
---|
| 617 | virtual void print( std::ostream &os, int indent = 0 ) const; |
---|
| 618 | private: |
---|
| 619 | Statement *body; |
---|
| 620 | }; |
---|
| 621 | |
---|
| 622 | /// RangeExpr represents a range e.g. '3 ... 5' or '1~10' |
---|
[8688ce1] | 623 | class RangeExpr : public Expression { |
---|
| 624 | public: |
---|
[d9e2280] | 625 | RangeExpr( Expression *low, Expression *high ); |
---|
[8688ce1] | 626 | RangeExpr( const RangeExpr &other ); |
---|
| 627 | |
---|
[d9e2280] | 628 | Expression * get_low() const { return low; } |
---|
| 629 | Expression * get_high() const { return high; } |
---|
| 630 | RangeExpr * set_low( Expression *low ) { RangeExpr::low = low; return this; } |
---|
| 631 | RangeExpr * set_high( Expression *high ) { RangeExpr::high = high; return this; } |
---|
[8688ce1] | 632 | |
---|
| 633 | virtual RangeExpr *clone() const { return new RangeExpr( *this ); } |
---|
| 634 | virtual void accept( Visitor &v ) { v.visit( this ); } |
---|
| 635 | virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); } |
---|
| 636 | virtual void print( std::ostream &os, int indent = 0 ) const; |
---|
| 637 | private: |
---|
[d9e2280] | 638 | Expression *low, *high; |
---|
[8688ce1] | 639 | }; |
---|
| 640 | |
---|
[6eb8948] | 641 | /// TupleExpr represents a tuple expression ( [a, b, c] ) |
---|
| 642 | class TupleExpr : public Expression { |
---|
| 643 | public: |
---|
[3c13c03] | 644 | TupleExpr( const std::list< Expression * > & exprs = std::list< Expression * >(), Expression *_aname = nullptr ); |
---|
[6eb8948] | 645 | TupleExpr( const TupleExpr &other ); |
---|
| 646 | virtual ~TupleExpr(); |
---|
| 647 | |
---|
| 648 | void set_exprs( std::list<Expression*> newValue ) { exprs = newValue; } |
---|
| 649 | std::list<Expression*>& get_exprs() { return exprs; } |
---|
| 650 | |
---|
| 651 | virtual TupleExpr *clone() const { return new TupleExpr( *this ); } |
---|
| 652 | virtual void accept( Visitor &v ) { v.visit( this ); } |
---|
| 653 | virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); } |
---|
| 654 | virtual void print( std::ostream &os, int indent = 0 ) const; |
---|
| 655 | private: |
---|
| 656 | std::list<Expression*> exprs; |
---|
| 657 | }; |
---|
| 658 | |
---|
[3b58d91] | 659 | /// TupleIndexExpr represents an element selection operation on a tuple value, e.g. t.3 after processing by the expression analyzer |
---|
| 660 | class TupleIndexExpr : public Expression { |
---|
| 661 | public: |
---|
| 662 | TupleIndexExpr( Expression * tuple, unsigned int index ); |
---|
| 663 | TupleIndexExpr( const TupleIndexExpr &other ); |
---|
| 664 | virtual ~TupleIndexExpr(); |
---|
| 665 | |
---|
| 666 | Expression * get_tuple() const { return tuple; } |
---|
| 667 | int get_index() const { return index; } |
---|
| 668 | TupleIndexExpr * set_tuple( Expression *newValue ) { tuple = newValue; return this; } |
---|
| 669 | TupleIndexExpr * set_index( unsigned int newValue ) { index = newValue; return this; } |
---|
| 670 | |
---|
| 671 | virtual TupleIndexExpr *clone() const { return new TupleIndexExpr( *this ); } |
---|
| 672 | virtual void accept( Visitor &v ) { v.visit( this ); } |
---|
| 673 | virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); } |
---|
| 674 | virtual void print( std::ostream &os, int indent = 0 ) const; |
---|
| 675 | private: |
---|
| 676 | Expression * tuple; |
---|
| 677 | unsigned int index; |
---|
| 678 | }; |
---|
| 679 | |
---|
| 680 | /// MemberTupleExpr represents a tuple member selection operation on a struct type, e.g. s.[a, b, c] after processing by the expression analyzer |
---|
| 681 | class MemberTupleExpr : public Expression { |
---|
| 682 | public: |
---|
| 683 | MemberTupleExpr( Expression * member, Expression * aggregate, Expression * _aname = nullptr ); |
---|
| 684 | MemberTupleExpr( const MemberTupleExpr &other ); |
---|
| 685 | virtual ~MemberTupleExpr(); |
---|
| 686 | |
---|
| 687 | Expression * get_member() const { return member; } |
---|
| 688 | Expression * get_aggregate() const { return aggregate; } |
---|
| 689 | MemberTupleExpr * set_member( Expression *newValue ) { member = newValue; return this; } |
---|
| 690 | MemberTupleExpr * set_aggregate( Expression *newValue ) { aggregate = newValue; return this; } |
---|
| 691 | |
---|
| 692 | virtual MemberTupleExpr *clone() const { return new MemberTupleExpr( *this ); } |
---|
| 693 | virtual void accept( Visitor &v ) { v.visit( this ); } |
---|
| 694 | virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); } |
---|
| 695 | virtual void print( std::ostream &os, int indent = 0 ) const; |
---|
| 696 | private: |
---|
| 697 | Expression * member; |
---|
| 698 | Expression * aggregate; |
---|
| 699 | }; |
---|
| 700 | |
---|
[65660bd] | 701 | /// TupleAssignExpr represents a multiple assignment operation, where both sides of the assignment have tuple type, e.g. [a, b, c] = [d, e, f];, a mass assignment operation, where the left hand side has tuple type and the right hand side does not, e.g. [a, b, c] = 5.0;, or a tuple ctor/dtor expression |
---|
[6eb8948] | 702 | class TupleAssignExpr : public Expression { |
---|
[3b58d91] | 703 | public: |
---|
[6eb8948] | 704 | TupleAssignExpr( const std::list< Expression * > & assigns, const std::list< ObjectDecl * > & tempDecls, Expression * _aname = nullptr ); |
---|
| 705 | TupleAssignExpr( const TupleAssignExpr &other ); |
---|
| 706 | virtual ~TupleAssignExpr(); |
---|
[3b58d91] | 707 | |
---|
[6eb8948] | 708 | std::list< Expression * > & get_assigns() { return assigns; } |
---|
| 709 | std::list< ObjectDecl * > & get_tempDecls() { return tempDecls; } |
---|
[3b58d91] | 710 | |
---|
[6eb8948] | 711 | virtual TupleAssignExpr *clone() const { return new TupleAssignExpr( *this ); } |
---|
[3b58d91] | 712 | virtual void accept( Visitor &v ) { v.visit( this ); } |
---|
| 713 | virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); } |
---|
| 714 | virtual void print( std::ostream &os, int indent = 0 ) const; |
---|
| 715 | private: |
---|
[6eb8948] | 716 | std::list< Expression * > assigns; // assignment expressions that use tempDecls |
---|
| 717 | std::list< ObjectDecl * > tempDecls; // temporaries for address of lhs exprs |
---|
[3b58d91] | 718 | }; |
---|
| 719 | |
---|
[6eb8948] | 720 | /// StmtExpr represents a GCC 'statement expression', e.g. ({ int x = 5; x; }) |
---|
| 721 | class StmtExpr : public Expression { |
---|
| 722 | public: |
---|
| 723 | StmtExpr( CompoundStmt *statements ); |
---|
| 724 | StmtExpr( const StmtExpr & other ); |
---|
| 725 | virtual ~StmtExpr(); |
---|
[3b58d91] | 726 | |
---|
[6eb8948] | 727 | CompoundStmt * get_statements() const { return statements; } |
---|
| 728 | StmtExpr * set_statements( CompoundStmt * newValue ) { statements = newValue; return this; } |
---|
[3b58d91] | 729 | |
---|
[6eb8948] | 730 | virtual StmtExpr *clone() const { return new StmtExpr( *this ); } |
---|
[3b58d91] | 731 | virtual void accept( Visitor &v ) { v.visit( this ); } |
---|
| 732 | virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); } |
---|
| 733 | virtual void print( std::ostream &os, int indent = 0 ) const; |
---|
[6eb8948] | 734 | private: |
---|
| 735 | CompoundStmt * statements; |
---|
[3b58d91] | 736 | }; |
---|
| 737 | |
---|
[3c13c03] | 738 | class UniqueExpr : public Expression { |
---|
| 739 | public: |
---|
[bf32bb8] | 740 | UniqueExpr( Expression * expr, long long idVal = -1 ); |
---|
[3c13c03] | 741 | UniqueExpr( const UniqueExpr & other ); |
---|
| 742 | ~UniqueExpr(); |
---|
| 743 | |
---|
[141b786] | 744 | Expression * get_expr() const { return expr; } |
---|
| 745 | UniqueExpr * set_expr( Expression * newValue ) { expr = newValue; return this; } |
---|
[3c13c03] | 746 | |
---|
[141b786] | 747 | ObjectDecl * get_object() const { return object; } |
---|
| 748 | UniqueExpr * set_object( ObjectDecl * newValue ) { object = newValue; return this; } |
---|
| 749 | |
---|
| 750 | VariableExpr * get_var() const { return var; } |
---|
| 751 | UniqueExpr * set_var( VariableExpr * newValue ) { var = newValue; return this; } |
---|
[77971f6] | 752 | |
---|
[bf32bb8] | 753 | int get_id() const { return id; } |
---|
| 754 | |
---|
[3c13c03] | 755 | virtual UniqueExpr *clone() const { return new UniqueExpr( *this ); } |
---|
| 756 | virtual void accept( Visitor &v ) { v.visit( this ); } |
---|
| 757 | virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); } |
---|
| 758 | virtual void print( std::ostream &os, int indent = 0 ) const; |
---|
| 759 | private: |
---|
[141b786] | 760 | Expression * expr; |
---|
| 761 | ObjectDecl * object; |
---|
| 762 | VariableExpr * var; |
---|
[bf32bb8] | 763 | int id; |
---|
| 764 | static long long count; |
---|
[3c13c03] | 765 | }; |
---|
| 766 | |
---|
[3906301] | 767 | std::ostream & operator<<( std::ostream & out, const Expression * expr ); |
---|
[baf7fee] | 768 | |
---|
[0dd3a2f] | 769 | #endif // EXPRESSION_H |
---|
[51b7345] | 770 | |
---|
[0dd3a2f] | 771 | // Local Variables: // |
---|
| 772 | // tab-width: 4 // |
---|
| 773 | // mode: c++ // |
---|
| 774 | // compile-command: "make install" // |
---|
| 775 | // End: // |
---|