source: src/SynTree/Expression.h@ 4d3ca1d8

ADT aaron-thesis arm-eh ast-experimental cleanup-dtors ctor deferred_resn demangler enum forall-pointer-decay gc_noraii jacob/cs343-translation jenkins-sandbox memory new-ast new-ast-unique-expr new-env no_list persistent-indexer pthread-emulation qualifiedEnum resolv-new with_gc
Last change on this file since 4d3ca1d8 was e04ef3a, checked in by Peter A. Buhr <pabuhr@…>, 9 years ago

add gcc extension, first attempt, not done yet

  • Property mode set to 100644
File size: 24.3 KB
Line 
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//
7// Expression.h --
8//
9// Author : Richard C. Bilson
10// Created On : Mon May 18 07:44:20 2015
11// Last Modified By : Peter A. Buhr
12// Last Modified On : Wed Jun 8 17:05:30 2016
13// Update Count : 22
14//
15
16#ifndef EXPRESSION_H
17#define EXPRESSION_H
18
19#include <map>
20#include "SynTree.h"
21#include "Visitor.h"
22#include "Mutator.h"
23#include "Constant.h"
24#include "Common/UniqueName.h"
25
26/// Expression is the root type for all expressions
27class Expression {
28 public:
29 Expression(Expression *_aname = 0 );
30 Expression( const Expression &other );
31 virtual ~Expression();
32
33 std::list<Type *>& get_results() { return results; }
34 void add_result( Type *t );
35
36 TypeSubstitution *get_env() const { return env; }
37 void set_env( TypeSubstitution *newValue ) { env = newValue; }
38 Expression *get_argName() const { return argName; }
39 void set_argName( Expression *name ) { argName = name; }
40 bool get_extension() const { return extension; }
41 void set_extension( bool exten ) { extension = exten; }
42
43 virtual Expression *clone() const = 0;
44 virtual void accept( Visitor &v ) = 0;
45 virtual Expression *acceptMutator( Mutator &m ) = 0;
46 virtual void print( std::ostream &os, int indent = 0 ) const;
47 protected:
48 std::list<Type *> results;
49 TypeSubstitution *env;
50 Expression* argName; // if expression is used as an argument, it can be "designated" by this name
51 bool extension = false;
52};
53
54/// ParamEntry contains the i.d. of a declaration and a type that is derived from that declaration,
55/// but subject to decay-to-pointer and type parameter renaming
56struct ParamEntry {
57 ParamEntry(): decl( 0 ), actualType( 0 ), formalType( 0 ), expr( 0 ) {}
58 ParamEntry( UniqueId decl, Type *actualType, Type *formalType, Expression* expr ): decl( decl ), actualType( actualType ), formalType( formalType ), expr( expr ) {}
59 ParamEntry( const ParamEntry &other );
60 ~ParamEntry();
61 ParamEntry &operator=( const ParamEntry &other );
62
63 UniqueId decl;
64 Type *actualType;
65 Type *formalType;
66 Expression* expr;
67};
68
69typedef std::map< UniqueId, ParamEntry > InferredParams;
70
71/// ApplicationExpr represents the application of a function to a set of parameters. This is the
72/// result of running an UntypedExpr through the expression analyzer.
73class ApplicationExpr : public Expression {
74 public:
75 ApplicationExpr( Expression *function );
76 ApplicationExpr( const ApplicationExpr &other );
77 virtual ~ApplicationExpr();
78
79 Expression *get_function() const { return function; }
80 void set_function( Expression *newValue ) { function = newValue; }
81 std::list<Expression *>& get_args() { return args; }
82 InferredParams &get_inferParams() { return inferParams; }
83
84 virtual ApplicationExpr *clone() const { return new ApplicationExpr( *this ); }
85 virtual void accept( Visitor &v ) { v.visit( this ); }
86 virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
87 virtual void print( std::ostream &os, int indent = 0 ) const;
88 private:
89 Expression *function;
90 std::list<Expression *> args;
91 InferredParams inferParams;
92};
93
94/// UntypedExpr represents the application of a function to a set of parameters, but where the
95/// particular overload for the function name has not yet been determined. Most operators are
96/// converted into functional form automatically, to permit operator overloading.
97class UntypedExpr : public Expression {
98 public:
99 UntypedExpr( Expression *function, Expression *_aname = 0 );
100 UntypedExpr( const UntypedExpr &other );
101 UntypedExpr( Expression *function, std::list<Expression *> &args, Expression *_aname = 0 );
102 virtual ~UntypedExpr();
103
104 Expression *get_function() const { return function; }
105 void set_function( Expression *newValue ) { function = newValue; }
106
107 void set_args( std::list<Expression *> &listArgs ) { args = listArgs; }
108 std::list<Expression*>::iterator begin_args() { return args.begin(); }
109 std::list<Expression*>::iterator end_args() { return args.end(); }
110 std::list<Expression*>& get_args() { return args; }
111
112 virtual UntypedExpr *clone() const { return new UntypedExpr( *this ); }
113 virtual void accept( Visitor &v ) { v.visit( this ); }
114 virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
115 virtual void print( std::ostream &os, int indent = 0 ) const;
116 virtual void printArgs(std::ostream &os, int indent = 0) const;
117 private:
118 Expression *function;
119 std::list<Expression*> args;
120};
121
122/// NameExpr contains a name whose meaning is still not determined
123class NameExpr : public Expression {
124 public:
125 NameExpr( std::string name, Expression *_aname = 0 );
126 NameExpr( const NameExpr &other );
127 virtual ~NameExpr();
128
129 const std::string &get_name() const { return name; }
130 void set_name( std::string newValue ) { name = newValue; }
131
132 virtual NameExpr *clone() const { return new NameExpr( *this ); }
133 virtual void accept( Visitor &v ) { v.visit( this ); }
134 virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
135 virtual void print( std::ostream &os, int indent = 0 ) const;
136 private:
137 std::string name;
138};
139
140// The following classes are used to represent expression types that cannot be converted into
141// function-call format.
142
143/// AddressExpr represents a address-of expression, e.g. &e
144class AddressExpr : public Expression {
145 public:
146 AddressExpr( Expression *arg, Expression *_aname = 0 );
147 AddressExpr( const AddressExpr &other );
148 virtual ~AddressExpr();
149
150 Expression *get_arg() const { return arg; }
151 void set_arg(Expression *newValue ) { arg = newValue; }
152
153 virtual AddressExpr *clone() const { return new AddressExpr( *this ); }
154 virtual void accept( Visitor &v ) { v.visit( this ); }
155 virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
156 virtual void print( std::ostream &os, int indent = 0 ) const;
157 private:
158 Expression *arg;
159};
160
161// xxx - this doesn't appear to actually be hooked in anywhere. We should use this instead of the "&&"" UntypedExpr hack
162class LabelAddressExpr : public Expression {
163 public:
164 LabelAddressExpr( Expression *arg );
165 LabelAddressExpr( const LabelAddressExpr &other );
166 virtual ~LabelAddressExpr();
167
168 Expression *get_arg() const { return arg; }
169 void set_arg(Expression *newValue ) { arg = newValue; }
170
171 virtual LabelAddressExpr *clone() const { return new LabelAddressExpr( *this ); }
172 virtual void accept( Visitor &v ) { v.visit( this ); }
173 virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
174 virtual void print( std::ostream &os, int indent = 0 ) const;
175 private:
176 Expression *arg;
177};
178
179/// CastExpr represents a type cast expression, e.g. (int)e
180class CastExpr : public Expression {
181 public:
182 CastExpr( Expression *arg, Expression *_aname = 0 );
183 CastExpr( Expression *arg, Type *toType, Expression *_aname = 0 );
184 CastExpr( const CastExpr &other );
185 virtual ~CastExpr();
186
187 Expression *get_arg() const { return arg; }
188 void set_arg(Expression *newValue ) { arg = newValue; }
189
190 virtual CastExpr *clone() const { return new CastExpr( *this ); }
191 virtual void accept( Visitor &v ) { v.visit( this ); }
192 virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
193 virtual void print( std::ostream &os, int indent = 0 ) const;
194 private:
195 Expression *arg;
196};
197
198/// UntypedMemberExpr represents a member selection operation, e.g. q.p before processing by the expression analyzer
199class UntypedMemberExpr : public Expression {
200 public:
201 UntypedMemberExpr( std::string member, Expression *aggregate, Expression *_aname = 0 );
202 UntypedMemberExpr( const UntypedMemberExpr &other );
203 virtual ~UntypedMemberExpr();
204
205 std::string get_member() const { return member; }
206 void set_member( const std::string &newValue ) { member = newValue; }
207 Expression *get_aggregate() const { return aggregate; }
208 void set_aggregate( Expression *newValue ) { aggregate = newValue; }
209
210 virtual UntypedMemberExpr *clone() const { return new UntypedMemberExpr( *this ); }
211 virtual void accept( Visitor &v ) { v.visit( this ); }
212 virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
213 virtual void print( std::ostream &os, int indent = 0 ) const;
214 private:
215 std::string member;
216 Expression *aggregate;
217};
218
219/// MemberExpr represents a member selection operation, e.g. q.p after processing by the expression analyzer
220class MemberExpr : public Expression {
221 public:
222 MemberExpr( DeclarationWithType *member, Expression *aggregate, Expression *_aname = 0 );
223 MemberExpr( const MemberExpr &other );
224 virtual ~MemberExpr();
225
226 DeclarationWithType *get_member() const { return member; }
227 void set_member( DeclarationWithType *newValue ) { member = newValue; }
228 Expression *get_aggregate() const { return aggregate; }
229 void set_aggregate( Expression *newValue ) { aggregate = newValue; }
230
231 virtual MemberExpr *clone() const { return new MemberExpr( *this ); }
232 virtual void accept( Visitor &v ) { v.visit( this ); }
233 virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
234 virtual void print( std::ostream &os, int indent = 0 ) const;
235 private:
236 DeclarationWithType *member;
237 Expression *aggregate;
238};
239
240/// VariableExpr represents an expression that simply refers to the value of a named variable
241class VariableExpr : public Expression {
242 public:
243 VariableExpr( DeclarationWithType *var, Expression *_aname = 0 );
244 VariableExpr( const VariableExpr &other );
245 virtual ~VariableExpr();
246
247 DeclarationWithType *get_var() const { return var; }
248 void set_var( DeclarationWithType *newValue ) { var = newValue; }
249
250 virtual VariableExpr *clone() const { return new VariableExpr( *this ); }
251 virtual void accept( Visitor &v ) { v.visit( this ); }
252 virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
253 virtual void print( std::ostream &os, int indent = 0 ) const;
254 private:
255 DeclarationWithType *var;
256};
257
258/// ConstantExpr represents an expression that simply refers to the value of a constant
259class ConstantExpr : public Expression {
260 public:
261 ConstantExpr( Constant constant, Expression *_aname = 0 );
262 ConstantExpr( const ConstantExpr &other );
263 virtual ~ConstantExpr();
264
265 Constant *get_constant() { return &constant; }
266 void set_constant( const Constant &newValue ) { constant = newValue; }
267
268 virtual ConstantExpr *clone() const { return new ConstantExpr( *this ); }
269 virtual void accept( Visitor &v ) { v.visit( this ); }
270 virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
271 virtual void print( std::ostream &os, int indent = 0 ) const;
272 private:
273 Constant constant;
274};
275
276/// SizeofExpr represents a sizeof expression (could be sizeof(int) or sizeof 3+4)
277class SizeofExpr : public Expression {
278 public:
279 SizeofExpr( Expression *expr, Expression *_aname = 0 );
280 SizeofExpr( const SizeofExpr &other );
281 SizeofExpr( Type *type, Expression *_aname = 0 );
282 virtual ~SizeofExpr();
283
284 Expression *get_expr() const { return expr; }
285 void set_expr( Expression *newValue ) { expr = newValue; }
286 Type *get_type() const { return type; }
287 void set_type( Type *newValue ) { type = newValue; }
288 bool get_isType() const { return isType; }
289 void set_isType( bool newValue ) { isType = newValue; }
290
291 virtual SizeofExpr *clone() const { return new SizeofExpr( *this ); }
292 virtual void accept( Visitor &v ) { v.visit( this ); }
293 virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
294 virtual void print( std::ostream &os, int indent = 0 ) const;
295 private:
296 Expression *expr;
297 Type *type;
298 bool isType;
299};
300
301/// AlignofExpr represents an alignof expression
302class AlignofExpr : public Expression {
303 public:
304 AlignofExpr( Expression *expr, Expression *_aname = 0 );
305 AlignofExpr( const AlignofExpr &other );
306 AlignofExpr( Type *type, Expression *_aname = 0 );
307 virtual ~AlignofExpr();
308
309 Expression *get_expr() const { return expr; }
310 void set_expr( Expression *newValue ) { expr = newValue; }
311 Type *get_type() const { return type; }
312 void set_type( Type *newValue ) { type = newValue; }
313 bool get_isType() const { return isType; }
314 void set_isType( bool newValue ) { isType = newValue; }
315
316 virtual AlignofExpr *clone() const { return new AlignofExpr( *this ); }
317 virtual void accept( Visitor &v ) { v.visit( this ); }
318 virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
319 virtual void print( std::ostream &os, int indent = 0 ) const;
320 private:
321 Expression *expr;
322 Type *type;
323 bool isType;
324};
325
326/// UntypedOffsetofExpr represents an offsetof expression before resolution
327class UntypedOffsetofExpr : public Expression {
328 public:
329 UntypedOffsetofExpr( Type *type, const std::string &member, Expression *_aname = 0 );
330 UntypedOffsetofExpr( const UntypedOffsetofExpr &other );
331 virtual ~UntypedOffsetofExpr();
332
333 std::string get_member() const { return member; }
334 void set_member( const std::string &newValue ) { member = newValue; }
335 Type *get_type() const { return type; }
336 void set_type( Type *newValue ) { type = newValue; }
337
338 virtual UntypedOffsetofExpr *clone() const { return new UntypedOffsetofExpr( *this ); }
339 virtual void accept( Visitor &v ) { v.visit( this ); }
340 virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
341 virtual void print( std::ostream &os, int indent = 0 ) const;
342 private:
343 Type *type;
344 std::string member;
345};
346
347/// OffsetofExpr represents an offsetof expression
348class OffsetofExpr : public Expression {
349 public:
350 OffsetofExpr( Type *type, DeclarationWithType *member, Expression *_aname = 0 );
351 OffsetofExpr( const OffsetofExpr &other );
352 virtual ~OffsetofExpr();
353
354 Type *get_type() const { return type; }
355 void set_type( Type *newValue ) { type = newValue; }
356 DeclarationWithType *get_member() const { return member; }
357 void set_member( DeclarationWithType *newValue ) { member = newValue; }
358
359 virtual OffsetofExpr *clone() const { return new OffsetofExpr( *this ); }
360 virtual void accept( Visitor &v ) { v.visit( this ); }
361 virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
362 virtual void print( std::ostream &os, int indent = 0 ) const;
363 private:
364 Type *type;
365 DeclarationWithType *member;
366};
367
368/// Expression representing a pack of field-offsets for a generic type
369class OffsetPackExpr : public Expression {
370public:
371 OffsetPackExpr( StructInstType *type_, Expression *aname_ = 0 );
372 OffsetPackExpr( const OffsetPackExpr &other );
373 virtual ~OffsetPackExpr();
374
375 StructInstType *get_type() const { return type; }
376 void set_type( StructInstType *newValue ) { type = newValue; }
377
378 virtual OffsetPackExpr *clone() const { return new OffsetPackExpr( *this ); }
379 virtual void accept( Visitor &v ) { v.visit( this ); }
380 virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
381
382 virtual void print( std::ostream &os, int indent = 0 ) const;
383
384private:
385 StructInstType *type;
386};
387
388/// AttrExpr represents an @attribute expression (like sizeof, but user-defined)
389class AttrExpr : public Expression {
390 public:
391 AttrExpr(Expression *attr, Expression *expr, Expression *_aname = 0 );
392 AttrExpr( const AttrExpr &other );
393 AttrExpr( Expression *attr, Type *type, Expression *_aname = 0 );
394 virtual ~AttrExpr();
395
396 Expression *get_attr() const { return attr; }
397 void set_attr( Expression *newValue ) { attr = newValue; }
398 Expression *get_expr() const { return expr; }
399 void set_expr( Expression *newValue ) { expr = newValue; }
400 Type *get_type() const { return type; }
401 void set_type( Type *newValue ) { type = newValue; }
402 bool get_isType() const { return isType; }
403 void set_isType( bool newValue ) { isType = newValue; }
404
405 virtual AttrExpr *clone() const { return new AttrExpr( *this ); }
406 virtual void accept( Visitor &v ) { v.visit( this ); }
407 virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
408 virtual void print( std::ostream &os, int indent = 0 ) const;
409 private:
410 Expression *attr;
411 Expression *expr;
412 Type *type;
413 bool isType;
414};
415
416/// LogicalExpr represents a short-circuit boolean expression (&& or ||)
417class LogicalExpr : public Expression {
418 public:
419 LogicalExpr( Expression *arg1, Expression *arg2, bool andp = true, Expression *_aname = 0 );
420 LogicalExpr( const LogicalExpr &other );
421 virtual ~LogicalExpr();
422
423 bool get_isAnd() const { return isAnd; }
424 Expression *get_arg1() { return arg1; }
425 void set_arg1( Expression *newValue ) { arg1 = newValue; }
426 Expression *get_arg2() const { return arg2; }
427 void set_arg2( Expression *newValue ) { arg2 = newValue; }
428
429 virtual LogicalExpr *clone() const { return new LogicalExpr( *this ); }
430 virtual void accept( Visitor &v ) { v.visit( this ); }
431 virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
432 virtual void print( std::ostream &os, int indent = 0 ) const;
433 private:
434 Expression *arg1;
435 Expression *arg2;
436 bool isAnd;
437};
438
439/// ConditionalExpr represents the three-argument conditional ( p ? a : b )
440class ConditionalExpr : public Expression {
441 public:
442 ConditionalExpr( Expression *arg1, Expression *arg2, Expression *arg3, Expression *_aname = 0 );
443 ConditionalExpr( const ConditionalExpr &other );
444 virtual ~ConditionalExpr();
445
446 Expression *get_arg1() const { return arg1; }
447 void set_arg1( Expression *newValue ) { arg1 = newValue; }
448 Expression *get_arg2() const { return arg2; }
449 void set_arg2( Expression *newValue ) { arg2 = newValue; }
450 Expression *get_arg3() const { return arg3; }
451 void set_arg3( Expression *newValue ) { arg3 = newValue; }
452
453 virtual ConditionalExpr *clone() const { return new ConditionalExpr( *this ); }
454 virtual void accept( Visitor &v ) { v.visit( this ); }
455 virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
456 virtual void print( std::ostream &os, int indent = 0 ) const;
457 private:
458 Expression *arg1;
459 Expression *arg2;
460 Expression *arg3;
461};
462
463/// CommaExpr represents the sequence operator ( a, b )
464class CommaExpr : public Expression {
465 public:
466 CommaExpr( Expression *arg1, Expression *arg2, Expression *_aname = 0 );
467 CommaExpr( const CommaExpr &other );
468 virtual ~CommaExpr();
469
470 Expression *get_arg1() const { return arg1; }
471 void set_arg1( Expression *newValue ) { arg1 = newValue; }
472 Expression *get_arg2() const { return arg2; }
473 void set_arg2( Expression *newValue ) { arg2 = newValue; }
474
475 virtual CommaExpr *clone() const { return new CommaExpr( *this ); }
476 virtual void accept( Visitor &v ) { v.visit( this ); }
477 virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
478 virtual void print( std::ostream &os, int indent = 0 ) const;
479 private:
480 Expression *arg1;
481 Expression *arg2;
482};
483
484/// TupleExpr represents a tuple expression ( [a, b, c] )
485class TupleExpr : public Expression {
486 public:
487 TupleExpr( Expression *_aname = 0 );
488 TupleExpr( const TupleExpr &other );
489 virtual ~TupleExpr();
490
491 void set_exprs( std::list<Expression*> newValue ) { exprs = newValue; }
492 std::list<Expression*>& get_exprs() { return exprs; }
493
494 virtual TupleExpr *clone() const { return new TupleExpr( *this ); }
495 virtual void accept( Visitor &v ) { v.visit( this ); }
496 virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
497 virtual void print( std::ostream &os, int indent = 0 ) const;
498 private:
499 std::list<Expression*> exprs;
500};
501
502/// SolvedTupleExpr represents a TupleExpr whose components have been type-resolved. It is effectively a shell for the code generator to work on
503class SolvedTupleExpr : public Expression {
504 public:
505 SolvedTupleExpr( Expression *_aname = 0 ) : Expression( _aname ) {}
506 SolvedTupleExpr( std::list<Expression *> &, Expression *_aname = 0 );
507 SolvedTupleExpr( const SolvedTupleExpr &other );
508 virtual ~SolvedTupleExpr() {}
509
510 std::list<Expression*> &get_exprs() { return exprs; }
511
512 virtual SolvedTupleExpr *clone() const { return new SolvedTupleExpr( *this ); }
513 virtual void accept( Visitor &v ) { v.visit( this ); }
514 virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
515 virtual void print( std::ostream &os, int indent = 0 ) const;
516 private:
517 std::list<Expression*> exprs;
518};
519
520/// TypeExpr represents a type used in an expression (e.g. as a type generator parameter)
521class TypeExpr : public Expression {
522 public:
523 TypeExpr( Type *type );
524 TypeExpr( const TypeExpr &other );
525 virtual ~TypeExpr();
526
527 Type *get_type() const { return type; }
528 void set_type( Type *newValue ) { type = newValue; }
529
530 virtual TypeExpr *clone() const { return new TypeExpr( *this ); }
531 virtual void accept( Visitor &v ) { v.visit( this ); }
532 virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
533 virtual void print( std::ostream &os, int indent = 0 ) const;
534 private:
535 Type *type;
536};
537
538/// AsmExpr represents a GCC 'asm constraint operand' used in an asm statement: [output] "=f" (result)
539class AsmExpr : public Expression {
540 public:
541 AsmExpr( Expression *inout, ConstantExpr *constraint, Expression *operand ) : inout( inout ), constraint( constraint ), operand( operand ) {}
542 AsmExpr( const AsmExpr & other );
543 virtual ~AsmExpr() { delete inout; delete constraint; delete operand; };
544
545 Expression *get_inout() const { return inout; }
546 void set_inout( Expression *newValue ) { inout = newValue; }
547
548 ConstantExpr *get_constraint() const { return constraint; }
549 void set_constraint( ConstantExpr *newValue ) { constraint = newValue; }
550
551 Expression *get_operand() const { return operand; }
552 void set_operand( Expression *newValue ) { operand = newValue; }
553
554 virtual AsmExpr *clone() const { return new AsmExpr( *this ); }
555 virtual void accept( Visitor &v ) { v.visit( this ); }
556 virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
557 virtual void print( std::ostream &os, int indent = 0 ) const;
558 private:
559 // https://gcc.gnu.org/onlinedocs/gcc-4.7.1/gcc/Machine-Constraints.html#Machine-Constraints
560 Expression *inout;
561 ConstantExpr *constraint;
562 Expression *operand;
563};
564
565/// ImplicitCopyCtorExpr represents the application of a function to a set of parameters,
566/// along with a set of copy constructor calls, one for each argument.
567class ImplicitCopyCtorExpr : public Expression {
568public:
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 void set_tempDecls( std::list< ObjectDecl * > newValue ) { tempDecls = newValue; }
578
579 std::list< ObjectDecl * > & get_returnDecls() { return returnDecls; }
580 void set_returnDecls( std::list< ObjectDecl * > newValue ) { returnDecls = newValue; }
581
582 std::list< Expression * > & get_dtors() { return dtors; }
583 void set_dtors( std::list< Expression * > newValue ) { dtors = newValue; }
584
585 virtual ImplicitCopyCtorExpr *clone() const { return new ImplicitCopyCtorExpr( *this ); }
586 virtual void accept( Visitor &v ) { v.visit( this ); }
587 virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
588 virtual void print( std::ostream &os, int indent = 0 ) const;
589 private:
590 ApplicationExpr * callExpr;
591 std::list< ObjectDecl * > tempDecls;
592 std::list< ObjectDecl * > returnDecls;
593 std::list< Expression * > dtors;
594};
595
596/// ValofExpr represents a GCC 'lambda expression'
597class UntypedValofExpr : public Expression {
598 public:
599 UntypedValofExpr( Statement *_body, Expression *_aname = 0 ) : Expression( _aname ), body ( _body ) {}
600 UntypedValofExpr( const UntypedValofExpr & other );
601 virtual ~UntypedValofExpr();
602
603 Expression *get_value();
604 Statement *get_body() const { return body; }
605
606 virtual UntypedValofExpr *clone() const { return new UntypedValofExpr( *this ); }
607 virtual void accept( Visitor &v ) { v.visit( this ); }
608 virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
609 virtual void print( std::ostream &os, int indent = 0 ) const;
610 private:
611 Statement *body;
612};
613
614/// CompoundLiteralExpr represents a C99 'compound literal'
615class CompoundLiteralExpr : public Expression {
616 public:
617 CompoundLiteralExpr( Type * type, Initializer * initializer );
618 CompoundLiteralExpr( const CompoundLiteralExpr &other );
619 ~CompoundLiteralExpr();
620
621 Type * get_type() const { return type; }
622 void set_type( Type * t ) { type = t; }
623
624 Initializer * get_initializer() const { return initializer; }
625 void set_initializer( Initializer * i ) { initializer = i; }
626
627 virtual CompoundLiteralExpr *clone() const { return new CompoundLiteralExpr( *this ); }
628 virtual void accept( Visitor &v ) { v.visit( this ); }
629 virtual Expression *acceptMutator( Mutator &m ) { return m.mutate( this ); }
630 virtual void print( std::ostream &os, int indent = 0 ) const;
631 private:
632 Type * type;
633 Initializer * initializer;
634};
635
636std::ostream & operator<<( std::ostream & out, Expression * expr );
637
638#endif // EXPRESSION_H
639
640// Local Variables: //
641// tab-width: 4 //
642// mode: c++ //
643// compile-command: "make install" //
644// End: //
Note: See TracBrowser for help on using the repository browser.