source: src/SynTree/Expression.h @ 630a82a

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsctordeferred_resndemanglerenumforall-pointer-decaygc_noraiijacob/cs343-translationjenkins-sandboxmemorynew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newstringwith_gc
Last change on this file since 630a82a was 630a82a, checked in by Peter A. Buhr <pabuhr@…>, 8 years ago

C99 compound literals now work, comment rational code, clean up hoisting AddVisit?

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