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 : Mon Feb 18 18:29:51 2019 |
---|
13 | // Update Count : 49 |
---|
14 | // |
---|
15 | |
---|
16 | #pragma once |
---|
17 | |
---|
18 | #include <iosfwd> // for ostream |
---|
19 | #include <list> // for list, list<>::iterator |
---|
20 | #include <map> // for map, map<>::value_compare |
---|
21 | #include <memory> // for allocator, unique_ptr |
---|
22 | #include <string> // for string |
---|
23 | #include <vector> // for vector |
---|
24 | |
---|
25 | #include "BaseSyntaxNode.h" // for BaseSyntaxNode |
---|
26 | #include "Constant.h" // for Constant |
---|
27 | #include "Initializer.h" // for Designation (ptr only), Initializer |
---|
28 | #include "Label.h" // for Label |
---|
29 | #include "Mutator.h" // for Mutator |
---|
30 | #include "SynTree.h" // for UniqueId |
---|
31 | #include "Visitor.h" // for Visitor |
---|
32 | |
---|
33 | |
---|
34 | struct ParamEntry; |
---|
35 | |
---|
36 | typedef std::map< UniqueId, ParamEntry > InferredParams; |
---|
37 | |
---|
38 | /// ParamEntry contains the i.d. of a declaration and a type that is derived from that declaration, |
---|
39 | /// but subject to decay-to-pointer and type parameter renaming |
---|
40 | struct ParamEntry { |
---|
41 | ParamEntry(): decl( 0 ), declptr( nullptr ), actualType( nullptr ), formalType( nullptr ), expr( nullptr ) {} |
---|
42 | ParamEntry( UniqueId decl, Declaration * declptr, Type * actualType, Type * formalType, Expression* expr ); |
---|
43 | ParamEntry( const ParamEntry & other ); |
---|
44 | ParamEntry( ParamEntry && other ); |
---|
45 | ~ParamEntry(); |
---|
46 | ParamEntry & operator=( ParamEntry && other ); |
---|
47 | |
---|
48 | UniqueId const decl; |
---|
49 | Declaration * const declptr; |
---|
50 | Type * const actualType; |
---|
51 | Type * const formalType; |
---|
52 | Expression * expr; |
---|
53 | }; |
---|
54 | |
---|
55 | /// Expression is the root type for all expressions |
---|
56 | class Expression : public BaseSyntaxNode { |
---|
57 | public: |
---|
58 | Type * result; |
---|
59 | TypeSubstitution * env; |
---|
60 | bool extension = false; |
---|
61 | InferredParams inferParams; ///< Post-resolution inferred parameter slots |
---|
62 | std::vector<UniqueId> resnSlots; ///< Pre-resolution inferred parameter slots |
---|
63 | |
---|
64 | // xxx - should turn inferParams+resnSlots into a union to save some memory |
---|
65 | |
---|
66 | Expression(); |
---|
67 | Expression( const Expression & other ); |
---|
68 | virtual ~Expression(); |
---|
69 | |
---|
70 | Type *& get_result() { return result; } |
---|
71 | const Type * get_result() const { return result; } |
---|
72 | void set_result( Type * newValue ) { result = newValue; } |
---|
73 | |
---|
74 | TypeSubstitution * get_env() const { return env; } |
---|
75 | void set_env( TypeSubstitution * newValue ) { env = newValue; } |
---|
76 | bool get_extension() const { return extension; } |
---|
77 | Expression * set_extension( bool exten ) { extension = exten; return this; } |
---|
78 | |
---|
79 | // move other's inferParams to this |
---|
80 | void spliceInferParams( Expression * other ); |
---|
81 | |
---|
82 | virtual Expression * clone() const override = 0; |
---|
83 | virtual void accept( Visitor & v ) override = 0; |
---|
84 | virtual Expression * acceptMutator( Mutator & m ) override = 0; |
---|
85 | virtual void print( std::ostream & os, Indenter indent = {} ) const override; |
---|
86 | }; |
---|
87 | |
---|
88 | /// ApplicationExpr represents the application of a function to a set of parameters. This is the result of running an |
---|
89 | /// UntypedExpr through the expression analyzer. |
---|
90 | class ApplicationExpr : public Expression { |
---|
91 | public: |
---|
92 | Expression * function; |
---|
93 | std::list<Expression *> args; |
---|
94 | |
---|
95 | ApplicationExpr( Expression * function, const std::list<Expression *> & args = std::list< Expression * >() ); |
---|
96 | ApplicationExpr( const ApplicationExpr & other ); |
---|
97 | virtual ~ApplicationExpr(); |
---|
98 | |
---|
99 | Expression * get_function() const { return function; } |
---|
100 | void set_function( Expression * newValue ) { function = newValue; } |
---|
101 | std::list<Expression *>& get_args() { return args; } |
---|
102 | |
---|
103 | virtual ApplicationExpr * clone() const { return new ApplicationExpr( * this ); } |
---|
104 | virtual void accept( Visitor & v ) { v.visit( this ); } |
---|
105 | virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } |
---|
106 | virtual void print( std::ostream & os, Indenter indent = {} ) const; |
---|
107 | }; |
---|
108 | |
---|
109 | /// UntypedExpr represents the application of a function to a set of parameters, but where the particular overload for |
---|
110 | /// the function name has not yet been determined. Most operators are converted into functional form automatically, to |
---|
111 | /// permit operator overloading. |
---|
112 | class UntypedExpr : public Expression { |
---|
113 | public: |
---|
114 | Expression * function; |
---|
115 | std::list<Expression*> args; |
---|
116 | |
---|
117 | UntypedExpr( Expression * function, const std::list<Expression *> & args = std::list< Expression * >() ); |
---|
118 | UntypedExpr( const UntypedExpr & other ); |
---|
119 | virtual ~UntypedExpr(); |
---|
120 | |
---|
121 | Expression * get_function() const { return function; } |
---|
122 | void set_function( Expression * newValue ) { function = newValue; } |
---|
123 | |
---|
124 | std::list<Expression*>::iterator begin_args() { return args.begin(); } |
---|
125 | std::list<Expression*>::iterator end_args() { return args.end(); } |
---|
126 | std::list<Expression*>& get_args() { return args; } |
---|
127 | |
---|
128 | static UntypedExpr * createDeref( Expression * arg ); |
---|
129 | static UntypedExpr * createAssign( Expression * arg1, Expression * arg2 ); |
---|
130 | |
---|
131 | virtual UntypedExpr * clone() const { return new UntypedExpr( * this ); } |
---|
132 | virtual void accept( Visitor & v ) { v.visit( this ); } |
---|
133 | virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } |
---|
134 | virtual void print( std::ostream & os, Indenter indent = {} ) const; |
---|
135 | }; |
---|
136 | |
---|
137 | /// NameExpr contains a name whose meaning is still not determined |
---|
138 | class NameExpr : public Expression { |
---|
139 | public: |
---|
140 | std::string name; |
---|
141 | |
---|
142 | NameExpr( std::string name ); |
---|
143 | NameExpr( const NameExpr & other ); |
---|
144 | virtual ~NameExpr(); |
---|
145 | |
---|
146 | const std::string & get_name() const { return name; } |
---|
147 | void set_name( std::string newValue ) { name = newValue; } |
---|
148 | |
---|
149 | virtual NameExpr * clone() const { return new NameExpr( * 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, Indenter indent = {} ) const; |
---|
153 | }; |
---|
154 | |
---|
155 | // The following classes are used to represent expression types that cannot be converted into |
---|
156 | // function-call format. |
---|
157 | |
---|
158 | /// AddressExpr represents a address-of expression, e.g. & e |
---|
159 | class AddressExpr : public Expression { |
---|
160 | public: |
---|
161 | Expression * arg; |
---|
162 | |
---|
163 | AddressExpr( Expression * arg ); |
---|
164 | AddressExpr( const AddressExpr & other ); |
---|
165 | virtual ~AddressExpr(); |
---|
166 | |
---|
167 | Expression * get_arg() const { return arg; } |
---|
168 | void set_arg(Expression * newValue ) { arg = newValue; } |
---|
169 | |
---|
170 | virtual AddressExpr * clone() const { return new AddressExpr( * this ); } |
---|
171 | virtual void accept( Visitor & v ) { v.visit( this ); } |
---|
172 | virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } |
---|
173 | virtual void print( std::ostream & os, Indenter indent = {} ) const; |
---|
174 | }; |
---|
175 | |
---|
176 | // GCC &&label |
---|
177 | // https://gcc.gnu.org/onlinedocs/gcc-3.4.2/gcc/Labels-as-Values.html |
---|
178 | class LabelAddressExpr : public Expression { |
---|
179 | public: |
---|
180 | Label arg; |
---|
181 | |
---|
182 | LabelAddressExpr( const Label &arg ); |
---|
183 | LabelAddressExpr( const LabelAddressExpr & other ); |
---|
184 | virtual ~LabelAddressExpr(); |
---|
185 | |
---|
186 | virtual LabelAddressExpr * clone() const { return new LabelAddressExpr( * 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, Indenter indent = {} ) const; |
---|
190 | }; |
---|
191 | |
---|
192 | /// CastExpr represents a type cast expression, e.g. (int)e |
---|
193 | class CastExpr : public Expression { |
---|
194 | public: |
---|
195 | Expression * arg; |
---|
196 | bool isGenerated = true; // cast generated implicitly by code generation or explicit in program |
---|
197 | |
---|
198 | CastExpr( Expression * arg, bool isGenerated = true ); |
---|
199 | CastExpr( Expression * arg, Type * toType, bool isGenerated = true ); |
---|
200 | CastExpr( Expression * arg, void * ) = delete; // prevent accidentally passing pointers for isGenerated in the first constructor |
---|
201 | CastExpr( const CastExpr & other ); |
---|
202 | virtual ~CastExpr(); |
---|
203 | |
---|
204 | Expression * get_arg() const { return arg; } |
---|
205 | void set_arg( Expression * newValue ) { arg = newValue; } |
---|
206 | |
---|
207 | virtual CastExpr * clone() const { return new CastExpr( * this ); } |
---|
208 | virtual void accept( Visitor & v ) { v.visit( this ); } |
---|
209 | virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } |
---|
210 | virtual void print( std::ostream & os, Indenter indent = {} ) const; |
---|
211 | }; |
---|
212 | |
---|
213 | /// KeywordCastExpr represents a cast to 'keyword types', e.g. (thread &)t |
---|
214 | class KeywordCastExpr : public Expression { |
---|
215 | public: |
---|
216 | Expression * arg; |
---|
217 | enum Target { |
---|
218 | Coroutine, Thread, Monitor, NUMBER_OF_TARGETS |
---|
219 | } target; |
---|
220 | |
---|
221 | KeywordCastExpr( Expression * arg, Target target ); |
---|
222 | KeywordCastExpr( const KeywordCastExpr & other ); |
---|
223 | virtual ~KeywordCastExpr(); |
---|
224 | |
---|
225 | const std::string & targetString() const; |
---|
226 | |
---|
227 | virtual KeywordCastExpr * clone() const { return new KeywordCastExpr( * 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, Indenter indent = {} ) const; |
---|
231 | }; |
---|
232 | |
---|
233 | /// VirtualCastExpr repersents a virtual dynamic cast, e.g. (virtual exception)e |
---|
234 | class VirtualCastExpr : public Expression { |
---|
235 | public: |
---|
236 | Expression * arg; |
---|
237 | |
---|
238 | VirtualCastExpr( Expression * arg, Type * toType ); |
---|
239 | VirtualCastExpr( const VirtualCastExpr & other ); |
---|
240 | virtual ~VirtualCastExpr(); |
---|
241 | |
---|
242 | Expression * get_arg() const { return arg; } |
---|
243 | void set_arg( Expression * newValue ) { arg = newValue; } |
---|
244 | |
---|
245 | virtual VirtualCastExpr * clone() const { return new VirtualCastExpr( * this ); } |
---|
246 | virtual void accept( Visitor & v ) { v.visit( this ); } |
---|
247 | virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } |
---|
248 | virtual void print( std::ostream & os, Indenter indent = {} ) const; |
---|
249 | }; |
---|
250 | |
---|
251 | /// UntypedMemberExpr represents a member selection operation, e.g. q.p before processing by the expression analyzer |
---|
252 | class UntypedMemberExpr : public Expression { |
---|
253 | public: |
---|
254 | Expression * member; |
---|
255 | Expression * aggregate; |
---|
256 | |
---|
257 | UntypedMemberExpr( Expression * member, Expression * aggregate ); |
---|
258 | UntypedMemberExpr( const UntypedMemberExpr & other ); |
---|
259 | virtual ~UntypedMemberExpr(); |
---|
260 | |
---|
261 | Expression * get_member() const { return member; } |
---|
262 | void set_member( Expression * newValue ) { member = newValue; } |
---|
263 | Expression * get_aggregate() const { return aggregate; } |
---|
264 | void set_aggregate( Expression * newValue ) { aggregate = newValue; } |
---|
265 | |
---|
266 | virtual UntypedMemberExpr * clone() const { return new UntypedMemberExpr( * this ); } |
---|
267 | virtual void accept( Visitor & v ) { v.visit( this ); } |
---|
268 | virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } |
---|
269 | virtual void print( std::ostream & os, Indenter indent = {} ) const; |
---|
270 | }; |
---|
271 | |
---|
272 | /// MemberExpr represents a member selection operation, e.g. q.p after processing by the expression analyzer. |
---|
273 | /// Does not take ownership of member. |
---|
274 | class MemberExpr : public Expression { |
---|
275 | public: |
---|
276 | DeclarationWithType * member; |
---|
277 | Expression * aggregate; |
---|
278 | |
---|
279 | MemberExpr( DeclarationWithType * member, Expression * aggregate ); |
---|
280 | MemberExpr( const MemberExpr & other ); |
---|
281 | virtual ~MemberExpr(); |
---|
282 | |
---|
283 | DeclarationWithType * get_member() const { return member; } |
---|
284 | void set_member( DeclarationWithType * newValue ) { member = newValue; } |
---|
285 | Expression * get_aggregate() const { return aggregate; } |
---|
286 | void set_aggregate( Expression * newValue ) { aggregate = newValue; } |
---|
287 | |
---|
288 | virtual MemberExpr * clone() const { return new MemberExpr( * this ); } |
---|
289 | virtual void accept( Visitor & v ) { v.visit( this ); } |
---|
290 | virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } |
---|
291 | virtual void print( std::ostream & os, Indenter indent = {} ) const; |
---|
292 | }; |
---|
293 | |
---|
294 | /// VariableExpr represents an expression that simply refers to the value of a named variable. |
---|
295 | /// Does not take ownership of var. |
---|
296 | class VariableExpr : public Expression { |
---|
297 | public: |
---|
298 | DeclarationWithType * var; |
---|
299 | |
---|
300 | VariableExpr(); |
---|
301 | VariableExpr( DeclarationWithType * var ); |
---|
302 | VariableExpr( const VariableExpr & other ); |
---|
303 | virtual ~VariableExpr(); |
---|
304 | |
---|
305 | DeclarationWithType * get_var() const { return var; } |
---|
306 | void set_var( DeclarationWithType * newValue ) { var = newValue; } |
---|
307 | |
---|
308 | static VariableExpr * functionPointer( FunctionDecl * decl ); |
---|
309 | |
---|
310 | virtual VariableExpr * clone() const { return new VariableExpr( * this ); } |
---|
311 | virtual void accept( Visitor & v ) { v.visit( this ); } |
---|
312 | virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } |
---|
313 | virtual void print( std::ostream & os, Indenter indent = {} ) const; |
---|
314 | }; |
---|
315 | |
---|
316 | /// ConstantExpr represents an expression that simply refers to the value of a constant |
---|
317 | class ConstantExpr : public Expression { |
---|
318 | public: |
---|
319 | Constant constant; |
---|
320 | |
---|
321 | ConstantExpr( Constant constant ); |
---|
322 | ConstantExpr( const ConstantExpr & other ); |
---|
323 | virtual ~ConstantExpr(); |
---|
324 | |
---|
325 | Constant * get_constant() { return & constant; } |
---|
326 | const Constant * get_constant() const { return & constant; } |
---|
327 | void set_constant( const Constant & newValue ) { constant = newValue; } |
---|
328 | |
---|
329 | long long int intValue() const; |
---|
330 | |
---|
331 | virtual ConstantExpr * clone() const { return new ConstantExpr( * this ); } |
---|
332 | virtual void accept( Visitor & v ) { v.visit( this ); } |
---|
333 | virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } |
---|
334 | virtual void print( std::ostream & os, Indenter indent = {} ) const; |
---|
335 | }; |
---|
336 | |
---|
337 | /// SizeofExpr represents a sizeof expression (could be sizeof(int) or sizeof 3+4) |
---|
338 | class SizeofExpr : public Expression { |
---|
339 | public: |
---|
340 | Expression * expr; |
---|
341 | Type * type; |
---|
342 | bool isType; |
---|
343 | |
---|
344 | SizeofExpr( Expression * expr ); |
---|
345 | SizeofExpr( const SizeofExpr & other ); |
---|
346 | SizeofExpr( Type * type ); |
---|
347 | virtual ~SizeofExpr(); |
---|
348 | |
---|
349 | Expression * get_expr() const { return expr; } |
---|
350 | void set_expr( Expression * newValue ) { expr = newValue; } |
---|
351 | Type * get_type() const { return type; } |
---|
352 | void set_type( Type * newValue ) { type = newValue; } |
---|
353 | bool get_isType() const { return isType; } |
---|
354 | void set_isType( bool newValue ) { isType = newValue; } |
---|
355 | |
---|
356 | virtual SizeofExpr * clone() const { return new SizeofExpr( * this ); } |
---|
357 | virtual void accept( Visitor & v ) { v.visit( this ); } |
---|
358 | virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } |
---|
359 | virtual void print( std::ostream & os, Indenter indent = {} ) const; |
---|
360 | }; |
---|
361 | |
---|
362 | /// AlignofExpr represents an alignof expression |
---|
363 | class AlignofExpr : public Expression { |
---|
364 | public: |
---|
365 | Expression * expr; |
---|
366 | Type * type; |
---|
367 | bool isType; |
---|
368 | |
---|
369 | AlignofExpr( Expression * expr ); |
---|
370 | AlignofExpr( const AlignofExpr & other ); |
---|
371 | AlignofExpr( Type * type ); |
---|
372 | virtual ~AlignofExpr(); |
---|
373 | |
---|
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 AlignofExpr * clone() const { return new AlignofExpr( * 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, Indenter indent = {} ) const; |
---|
385 | }; |
---|
386 | |
---|
387 | /// UntypedOffsetofExpr represents an offsetof expression before resolution |
---|
388 | class UntypedOffsetofExpr : public Expression { |
---|
389 | public: |
---|
390 | Type * type; |
---|
391 | std::string member; |
---|
392 | |
---|
393 | UntypedOffsetofExpr( Type * type, const std::string & member ); |
---|
394 | UntypedOffsetofExpr( const UntypedOffsetofExpr & other ); |
---|
395 | virtual ~UntypedOffsetofExpr(); |
---|
396 | |
---|
397 | std::string get_member() const { return member; } |
---|
398 | void set_member( const std::string & newValue ) { member = newValue; } |
---|
399 | Type * get_type() const { return type; } |
---|
400 | void set_type( Type * newValue ) { type = newValue; } |
---|
401 | |
---|
402 | virtual UntypedOffsetofExpr * clone() const { return new UntypedOffsetofExpr( * this ); } |
---|
403 | virtual void accept( Visitor & v ) { v.visit( this ); } |
---|
404 | virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } |
---|
405 | virtual void print( std::ostream & os, Indenter indent = {} ) const; |
---|
406 | }; |
---|
407 | |
---|
408 | /// OffsetofExpr represents an offsetof expression |
---|
409 | class OffsetofExpr : public Expression { |
---|
410 | public: |
---|
411 | Type * type; |
---|
412 | DeclarationWithType * member; |
---|
413 | |
---|
414 | OffsetofExpr( Type * type, DeclarationWithType * member ); |
---|
415 | OffsetofExpr( const OffsetofExpr & other ); |
---|
416 | virtual ~OffsetofExpr(); |
---|
417 | |
---|
418 | Type * get_type() const { return type; } |
---|
419 | void set_type( Type * newValue ) { type = newValue; } |
---|
420 | DeclarationWithType * get_member() const { return member; } |
---|
421 | void set_member( DeclarationWithType * newValue ) { member = newValue; } |
---|
422 | |
---|
423 | virtual OffsetofExpr * clone() const { return new OffsetofExpr( * this ); } |
---|
424 | virtual void accept( Visitor & v ) { v.visit( this ); } |
---|
425 | virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } |
---|
426 | virtual void print( std::ostream & os, Indenter indent = {} ) const; |
---|
427 | }; |
---|
428 | |
---|
429 | /// Expression representing a pack of field-offsets for a generic type |
---|
430 | class OffsetPackExpr : public Expression { |
---|
431 | public: |
---|
432 | StructInstType * type; |
---|
433 | |
---|
434 | OffsetPackExpr( StructInstType * type ); |
---|
435 | OffsetPackExpr( const OffsetPackExpr & other ); |
---|
436 | virtual ~OffsetPackExpr(); |
---|
437 | |
---|
438 | StructInstType * get_type() const { return type; } |
---|
439 | void set_type( StructInstType * newValue ) { type = newValue; } |
---|
440 | |
---|
441 | virtual OffsetPackExpr * clone() const { return new OffsetPackExpr( * this ); } |
---|
442 | virtual void accept( Visitor & v ) { v.visit( this ); } |
---|
443 | virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } |
---|
444 | virtual void print( std::ostream & os, Indenter indent = {} ) const; |
---|
445 | }; |
---|
446 | |
---|
447 | /// AttrExpr represents an @attribute expression (like sizeof, but user-defined) |
---|
448 | class AttrExpr : public Expression { |
---|
449 | public: |
---|
450 | Expression * attr; |
---|
451 | Expression * expr; |
---|
452 | Type * type; |
---|
453 | bool isType; |
---|
454 | |
---|
455 | AttrExpr(Expression * attr, Expression * expr ); |
---|
456 | AttrExpr( const AttrExpr & other ); |
---|
457 | AttrExpr( Expression * attr, Type * type ); |
---|
458 | virtual ~AttrExpr(); |
---|
459 | |
---|
460 | Expression * get_attr() const { return attr; } |
---|
461 | void set_attr( Expression * newValue ) { attr = newValue; } |
---|
462 | Expression * get_expr() const { return expr; } |
---|
463 | void set_expr( Expression * newValue ) { expr = newValue; } |
---|
464 | Type * get_type() const { return type; } |
---|
465 | void set_type( Type * newValue ) { type = newValue; } |
---|
466 | bool get_isType() const { return isType; } |
---|
467 | void set_isType( bool newValue ) { isType = newValue; } |
---|
468 | |
---|
469 | virtual AttrExpr * clone() const { return new AttrExpr( * this ); } |
---|
470 | virtual void accept( Visitor & v ) { v.visit( this ); } |
---|
471 | virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } |
---|
472 | virtual void print( std::ostream & os, Indenter indent = {} ) const; |
---|
473 | }; |
---|
474 | |
---|
475 | /// LogicalExpr represents a short-circuit boolean expression (&& or ||) |
---|
476 | class LogicalExpr : public Expression { |
---|
477 | public: |
---|
478 | Expression * arg1; |
---|
479 | Expression * arg2; |
---|
480 | |
---|
481 | LogicalExpr( Expression * arg1, Expression * arg2, bool andp = true ); |
---|
482 | LogicalExpr( const LogicalExpr & other ); |
---|
483 | virtual ~LogicalExpr(); |
---|
484 | |
---|
485 | bool get_isAnd() const { return isAnd; } |
---|
486 | Expression * get_arg1() { return arg1; } |
---|
487 | void set_arg1( Expression * newValue ) { arg1 = newValue; } |
---|
488 | Expression * get_arg2() const { return arg2; } |
---|
489 | void set_arg2( Expression * newValue ) { arg2 = newValue; } |
---|
490 | |
---|
491 | virtual LogicalExpr * clone() const { return new LogicalExpr( * this ); } |
---|
492 | virtual void accept( Visitor & v ) { v.visit( this ); } |
---|
493 | virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } |
---|
494 | virtual void print( std::ostream & os, Indenter indent = {} ) const; |
---|
495 | |
---|
496 | private: |
---|
497 | bool isAnd; |
---|
498 | }; |
---|
499 | |
---|
500 | /// ConditionalExpr represents the three-argument conditional ( p ? a : b ) |
---|
501 | class ConditionalExpr : public Expression { |
---|
502 | public: |
---|
503 | Expression * arg1; |
---|
504 | Expression * arg2; |
---|
505 | Expression * arg3; |
---|
506 | |
---|
507 | ConditionalExpr( Expression * arg1, Expression * arg2, Expression * arg3 ); |
---|
508 | ConditionalExpr( const ConditionalExpr & other ); |
---|
509 | virtual ~ConditionalExpr(); |
---|
510 | |
---|
511 | Expression * get_arg1() const { return arg1; } |
---|
512 | void set_arg1( Expression * newValue ) { arg1 = newValue; } |
---|
513 | Expression * get_arg2() const { return arg2; } |
---|
514 | void set_arg2( Expression * newValue ) { arg2 = newValue; } |
---|
515 | Expression * get_arg3() const { return arg3; } |
---|
516 | void set_arg3( Expression * newValue ) { arg3 = newValue; } |
---|
517 | |
---|
518 | virtual ConditionalExpr * clone() const { return new ConditionalExpr( * this ); } |
---|
519 | virtual void accept( Visitor & v ) { v.visit( this ); } |
---|
520 | virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } |
---|
521 | virtual void print( std::ostream & os, Indenter indent = {} ) const; |
---|
522 | }; |
---|
523 | |
---|
524 | /// CommaExpr represents the sequence operator ( a, b ) |
---|
525 | class CommaExpr : public Expression { |
---|
526 | public: |
---|
527 | Expression * arg1; |
---|
528 | Expression * arg2; |
---|
529 | |
---|
530 | CommaExpr( Expression * arg1, Expression * arg2 ); |
---|
531 | CommaExpr( const CommaExpr & other ); |
---|
532 | virtual ~CommaExpr(); |
---|
533 | |
---|
534 | Expression * get_arg1() const { return arg1; } |
---|
535 | void set_arg1( Expression * newValue ) { arg1 = newValue; } |
---|
536 | Expression * get_arg2() const { return arg2; } |
---|
537 | void set_arg2( Expression * newValue ) { arg2 = newValue; } |
---|
538 | |
---|
539 | virtual CommaExpr * clone() const { return new CommaExpr( * this ); } |
---|
540 | virtual void accept( Visitor & v ) { v.visit( this ); } |
---|
541 | virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } |
---|
542 | virtual void print( std::ostream & os, Indenter indent = {} ) const; |
---|
543 | }; |
---|
544 | |
---|
545 | /// TypeExpr represents a type used in an expression (e.g. as a type generator parameter) |
---|
546 | class TypeExpr : public Expression { |
---|
547 | public: |
---|
548 | Type * type; |
---|
549 | |
---|
550 | TypeExpr( Type * type ); |
---|
551 | TypeExpr( const TypeExpr & other ); |
---|
552 | virtual ~TypeExpr(); |
---|
553 | |
---|
554 | Type * get_type() const { return type; } |
---|
555 | void set_type( Type * newValue ) { type = newValue; } |
---|
556 | |
---|
557 | virtual TypeExpr * clone() const { return new TypeExpr( * this ); } |
---|
558 | virtual void accept( Visitor & v ) { v.visit( this ); } |
---|
559 | virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } |
---|
560 | virtual void print( std::ostream & os, Indenter indent = {} ) const; |
---|
561 | }; |
---|
562 | |
---|
563 | /// AsmExpr represents a GCC 'asm constraint operand' used in an asm statement: [output] "=f" (result) |
---|
564 | class AsmExpr : public Expression { |
---|
565 | public: |
---|
566 | Expression * inout; |
---|
567 | Expression * constraint; |
---|
568 | Expression * operand; |
---|
569 | |
---|
570 | AsmExpr( Expression * inout, Expression * constraint, Expression * operand ) : inout( inout ), constraint( constraint ), operand( operand ) {} |
---|
571 | AsmExpr( const AsmExpr & other ); |
---|
572 | virtual ~AsmExpr() { delete inout; delete constraint; delete operand; }; |
---|
573 | |
---|
574 | Expression * get_inout() const { return inout; } |
---|
575 | void set_inout( Expression * newValue ) { inout = newValue; } |
---|
576 | |
---|
577 | Expression * get_constraint() const { return constraint; } |
---|
578 | void set_constraint( Expression * newValue ) { constraint = newValue; } |
---|
579 | |
---|
580 | Expression * get_operand() const { return operand; } |
---|
581 | void set_operand( Expression * newValue ) { operand = newValue; } |
---|
582 | |
---|
583 | virtual AsmExpr * clone() const { return new AsmExpr( * this ); } |
---|
584 | virtual void accept( Visitor & v ) { v.visit( this ); } |
---|
585 | virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } |
---|
586 | virtual void print( std::ostream & os, Indenter indent = {} ) const; |
---|
587 | |
---|
588 | // https://gcc.gnu.org/onlinedocs/gcc-4.7.1/gcc/Machine-Constraints.html#Machine-Constraints |
---|
589 | }; |
---|
590 | |
---|
591 | /// ImplicitCopyCtorExpr represents the application of a function to a set of parameters, |
---|
592 | /// along with a set of copy constructor calls, one for each argument. |
---|
593 | class ImplicitCopyCtorExpr : public Expression { |
---|
594 | public: |
---|
595 | ApplicationExpr * callExpr = nullptr; |
---|
596 | |
---|
597 | ImplicitCopyCtorExpr( ApplicationExpr * callExpr ); |
---|
598 | ImplicitCopyCtorExpr( const ImplicitCopyCtorExpr & other ); |
---|
599 | virtual ~ImplicitCopyCtorExpr(); |
---|
600 | |
---|
601 | virtual ImplicitCopyCtorExpr * clone() const { return new ImplicitCopyCtorExpr( * this ); } |
---|
602 | virtual void accept( Visitor & v ) { v.visit( this ); } |
---|
603 | virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } |
---|
604 | virtual void print( std::ostream & os, Indenter indent = {} ) const; |
---|
605 | }; |
---|
606 | |
---|
607 | /// ConstructorExpr represents the use of a constructor in an expression context, e.g. int * x = malloc() { 5 }; |
---|
608 | class ConstructorExpr : public Expression { |
---|
609 | public: |
---|
610 | Expression * callExpr; |
---|
611 | |
---|
612 | ConstructorExpr( Expression * callExpr ); |
---|
613 | ConstructorExpr( const ConstructorExpr & other ); |
---|
614 | ~ConstructorExpr(); |
---|
615 | |
---|
616 | Expression * get_callExpr() const { return callExpr; } |
---|
617 | void set_callExpr( Expression * newValue ) { callExpr = newValue; } |
---|
618 | |
---|
619 | virtual ConstructorExpr * clone() const { return new ConstructorExpr( * this ); } |
---|
620 | virtual void accept( Visitor & v ) { v.visit( this ); } |
---|
621 | virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } |
---|
622 | virtual void print( std::ostream & os, Indenter indent = {} ) const; |
---|
623 | }; |
---|
624 | |
---|
625 | /// CompoundLiteralExpr represents a C99 'compound literal' |
---|
626 | class CompoundLiteralExpr : public Expression { |
---|
627 | public: |
---|
628 | Initializer * initializer; |
---|
629 | |
---|
630 | CompoundLiteralExpr( Type * type, Initializer * initializer ); |
---|
631 | CompoundLiteralExpr( const CompoundLiteralExpr & other ); |
---|
632 | virtual ~CompoundLiteralExpr(); |
---|
633 | |
---|
634 | Initializer * get_initializer() const { return initializer; } |
---|
635 | void set_initializer( Initializer * i ) { initializer = i; } |
---|
636 | |
---|
637 | virtual CompoundLiteralExpr * clone() const { return new CompoundLiteralExpr( * this ); } |
---|
638 | virtual void accept( Visitor & v ) { v.visit( this ); } |
---|
639 | virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } |
---|
640 | virtual void print( std::ostream & os, Indenter indent = {} ) const; |
---|
641 | }; |
---|
642 | |
---|
643 | /// RangeExpr represents a range e.g. '3 ... 5' or '1~10' |
---|
644 | class RangeExpr : public Expression { |
---|
645 | public: |
---|
646 | Expression * low, * high; |
---|
647 | |
---|
648 | RangeExpr( Expression * low, Expression * high ); |
---|
649 | RangeExpr( const RangeExpr & other ); |
---|
650 | |
---|
651 | Expression * get_low() const { return low; } |
---|
652 | Expression * get_high() const { return high; } |
---|
653 | RangeExpr * set_low( Expression * low ) { RangeExpr::low = low; return this; } |
---|
654 | RangeExpr * set_high( Expression * high ) { RangeExpr::high = high; return this; } |
---|
655 | |
---|
656 | virtual RangeExpr * clone() const { return new RangeExpr( * this ); } |
---|
657 | virtual void accept( Visitor & v ) { v.visit( this ); } |
---|
658 | virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } |
---|
659 | virtual void print( std::ostream & os, Indenter indent = {} ) const; |
---|
660 | }; |
---|
661 | |
---|
662 | /// UntypedTupleExpr represents a tuple expression ( [a, b, c] ) before resolution |
---|
663 | class UntypedTupleExpr : public Expression { |
---|
664 | public: |
---|
665 | std::list<Expression*> exprs; |
---|
666 | |
---|
667 | UntypedTupleExpr( const std::list< Expression * > & exprs ); |
---|
668 | UntypedTupleExpr( const UntypedTupleExpr & other ); |
---|
669 | virtual ~UntypedTupleExpr(); |
---|
670 | |
---|
671 | std::list<Expression*>& get_exprs() { return exprs; } |
---|
672 | |
---|
673 | virtual UntypedTupleExpr * clone() const { return new UntypedTupleExpr( * this ); } |
---|
674 | virtual void accept( Visitor & v ) { v.visit( this ); } |
---|
675 | virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } |
---|
676 | virtual void print( std::ostream & os, Indenter indent = {} ) const; |
---|
677 | }; |
---|
678 | |
---|
679 | /// TupleExpr represents a tuple expression ( [a, b, c] ) |
---|
680 | class TupleExpr : public Expression { |
---|
681 | public: |
---|
682 | std::list<Expression*> exprs; |
---|
683 | |
---|
684 | TupleExpr( const std::list< Expression * > & exprs ); |
---|
685 | TupleExpr( const TupleExpr & other ); |
---|
686 | virtual ~TupleExpr(); |
---|
687 | |
---|
688 | std::list<Expression*>& get_exprs() { return exprs; } |
---|
689 | |
---|
690 | virtual TupleExpr * clone() const { return new TupleExpr( * this ); } |
---|
691 | virtual void accept( Visitor & v ) { v.visit( this ); } |
---|
692 | virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } |
---|
693 | virtual void print( std::ostream & os, Indenter indent = {} ) const; |
---|
694 | }; |
---|
695 | |
---|
696 | /// TupleIndexExpr represents an element selection operation on a tuple value, e.g. t.3 after processing by the expression analyzer |
---|
697 | class TupleIndexExpr : public Expression { |
---|
698 | public: |
---|
699 | Expression * tuple; |
---|
700 | unsigned int index; |
---|
701 | |
---|
702 | TupleIndexExpr( Expression * tuple, unsigned int index ); |
---|
703 | TupleIndexExpr( const TupleIndexExpr & other ); |
---|
704 | virtual ~TupleIndexExpr(); |
---|
705 | |
---|
706 | Expression * get_tuple() const { return tuple; } |
---|
707 | int get_index() const { return index; } |
---|
708 | TupleIndexExpr * set_tuple( Expression * newValue ) { tuple = newValue; return this; } |
---|
709 | TupleIndexExpr * set_index( unsigned int newValue ) { index = newValue; return this; } |
---|
710 | |
---|
711 | virtual TupleIndexExpr * clone() const { return new TupleIndexExpr( * this ); } |
---|
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, Indenter indent = {} ) const; |
---|
715 | }; |
---|
716 | |
---|
717 | /// 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 |
---|
718 | class TupleAssignExpr : public Expression { |
---|
719 | public: |
---|
720 | StmtExpr * stmtExpr = nullptr; |
---|
721 | |
---|
722 | TupleAssignExpr( const std::list< Expression * > & assigns, const std::list< ObjectDecl * > & tempDecls ); |
---|
723 | TupleAssignExpr( const TupleAssignExpr & other ); |
---|
724 | virtual ~TupleAssignExpr(); |
---|
725 | |
---|
726 | TupleAssignExpr * set_stmtExpr( StmtExpr * newValue ) { stmtExpr = newValue; return this; } |
---|
727 | StmtExpr * get_stmtExpr() const { return stmtExpr; } |
---|
728 | |
---|
729 | virtual TupleAssignExpr * clone() const { return new TupleAssignExpr( * this ); } |
---|
730 | virtual void accept( Visitor & v ) { v.visit( this ); } |
---|
731 | virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } |
---|
732 | virtual void print( std::ostream & os, Indenter indent = {} ) const; |
---|
733 | |
---|
734 | friend class ConverterNewToOld; |
---|
735 | private: |
---|
736 | TupleAssignExpr( StmtExpr * stmts ); |
---|
737 | }; |
---|
738 | |
---|
739 | /// StmtExpr represents a GCC 'statement expression', e.g. ({ int x = 5; x; }) |
---|
740 | class StmtExpr : public Expression { |
---|
741 | public: |
---|
742 | CompoundStmt * statements; |
---|
743 | std::list< ObjectDecl * > returnDecls; // return variable(s) for stmt expression |
---|
744 | std::list< Expression * > dtors; // destructor(s) for return variable(s) |
---|
745 | |
---|
746 | // readonly |
---|
747 | ExprStmt * resultExpr = nullptr; |
---|
748 | |
---|
749 | StmtExpr( CompoundStmt * statements ); |
---|
750 | StmtExpr( const StmtExpr & other ); |
---|
751 | virtual ~StmtExpr(); |
---|
752 | |
---|
753 | CompoundStmt * get_statements() const { return statements; } |
---|
754 | StmtExpr * set_statements( CompoundStmt * newValue ) { statements = newValue; return this; } |
---|
755 | |
---|
756 | // call to set the result type of this StmtExpr based on its body |
---|
757 | void computeResult(); |
---|
758 | |
---|
759 | std::list< ObjectDecl * > & get_returnDecls() { return returnDecls; } |
---|
760 | std::list< Expression * > & get_dtors() { return dtors; } |
---|
761 | |
---|
762 | virtual StmtExpr * clone() const { return new StmtExpr( * this ); } |
---|
763 | virtual void accept( Visitor & v ) { v.visit( this ); } |
---|
764 | virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } |
---|
765 | virtual void print( std::ostream & os, Indenter indent = {} ) const; |
---|
766 | }; |
---|
767 | |
---|
768 | class UniqueExpr : public Expression { |
---|
769 | public: |
---|
770 | Expression * expr; |
---|
771 | ObjectDecl * object; |
---|
772 | VariableExpr * var; |
---|
773 | |
---|
774 | UniqueExpr( Expression * expr, long long idVal = -1 ); |
---|
775 | UniqueExpr( const UniqueExpr & other ); |
---|
776 | ~UniqueExpr(); |
---|
777 | |
---|
778 | Expression * get_expr() const { return expr; } |
---|
779 | UniqueExpr * set_expr( Expression * newValue ) { expr = newValue; return this; } |
---|
780 | |
---|
781 | ObjectDecl * get_object() const { return object; } |
---|
782 | UniqueExpr * set_object( ObjectDecl * newValue ) { object = newValue; return this; } |
---|
783 | |
---|
784 | VariableExpr * get_var() const { return var; } |
---|
785 | UniqueExpr * set_var( VariableExpr * newValue ) { var = newValue; return this; } |
---|
786 | |
---|
787 | int get_id() const { return id; } |
---|
788 | |
---|
789 | virtual UniqueExpr * clone() const { return new UniqueExpr( * this ); } |
---|
790 | virtual void accept( Visitor & v ) { v.visit( this ); } |
---|
791 | virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } |
---|
792 | virtual void print( std::ostream & os, Indenter indent = {} ) const; |
---|
793 | |
---|
794 | private: |
---|
795 | int id; |
---|
796 | static long long count; |
---|
797 | }; |
---|
798 | |
---|
799 | struct InitAlternative { |
---|
800 | public: |
---|
801 | Type * type = nullptr; |
---|
802 | Designation * designation = nullptr; |
---|
803 | InitAlternative( Type * type, Designation * designation ); |
---|
804 | InitAlternative( const InitAlternative & other ); |
---|
805 | InitAlternative & operator=( const Initializer & other ) = delete; // at the moment this isn't used, and I don't want to implement it |
---|
806 | ~InitAlternative(); |
---|
807 | }; |
---|
808 | |
---|
809 | class UntypedInitExpr : public Expression { |
---|
810 | public: |
---|
811 | Expression * expr; |
---|
812 | std::list<InitAlternative> initAlts; |
---|
813 | |
---|
814 | UntypedInitExpr( Expression * expr, const std::list<InitAlternative> & initAlts ); |
---|
815 | UntypedInitExpr( const UntypedInitExpr & other ); |
---|
816 | ~UntypedInitExpr(); |
---|
817 | |
---|
818 | Expression * get_expr() const { return expr; } |
---|
819 | UntypedInitExpr * set_expr( Expression * newValue ) { expr = newValue; return this; } |
---|
820 | |
---|
821 | std::list<InitAlternative> & get_initAlts() { return initAlts; } |
---|
822 | |
---|
823 | virtual UntypedInitExpr * clone() const { return new UntypedInitExpr( * this ); } |
---|
824 | virtual void accept( Visitor & v ) { v.visit( this ); } |
---|
825 | virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } |
---|
826 | virtual void print( std::ostream & os, Indenter indent = {} ) const; |
---|
827 | }; |
---|
828 | |
---|
829 | class InitExpr : public Expression { |
---|
830 | public: |
---|
831 | Expression * expr; |
---|
832 | Designation * designation; |
---|
833 | |
---|
834 | InitExpr( Expression * expr, Designation * designation ); |
---|
835 | InitExpr( const InitExpr & other ); |
---|
836 | ~InitExpr(); |
---|
837 | |
---|
838 | Expression * get_expr() const { return expr; } |
---|
839 | InitExpr * set_expr( Expression * newValue ) { expr = newValue; return this; } |
---|
840 | |
---|
841 | Designation * get_designation() const { return designation; } |
---|
842 | InitExpr * set_designation( Designation * newValue ) { designation = newValue; return this; } |
---|
843 | |
---|
844 | virtual InitExpr * clone() const { return new InitExpr( * this ); } |
---|
845 | virtual void accept( Visitor & v ) { v.visit( this ); } |
---|
846 | virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } |
---|
847 | virtual void print( std::ostream & os, Indenter indent = {} ) const; |
---|
848 | }; |
---|
849 | |
---|
850 | /// expression that contains a deleted identifier - should never make it past the resolver. |
---|
851 | class DeletedExpr : public Expression { |
---|
852 | public: |
---|
853 | Expression * expr; |
---|
854 | BaseSyntaxNode * deleteStmt; |
---|
855 | |
---|
856 | DeletedExpr( Expression * expr, BaseSyntaxNode * deleteStmt ); |
---|
857 | DeletedExpr( const DeletedExpr & other ); |
---|
858 | ~DeletedExpr(); |
---|
859 | |
---|
860 | virtual DeletedExpr * clone() const { return new DeletedExpr( * this ); } |
---|
861 | virtual void accept( Visitor & v ) { v.visit( this ); } |
---|
862 | virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } |
---|
863 | virtual void print( std::ostream & os, Indenter indent = {} ) const; |
---|
864 | }; |
---|
865 | |
---|
866 | /// expression wrapping the use of a default argument - should never make it past the resolver. |
---|
867 | class DefaultArgExpr : public Expression { |
---|
868 | public: |
---|
869 | Expression * expr; |
---|
870 | |
---|
871 | DefaultArgExpr( Expression * expr ); |
---|
872 | DefaultArgExpr( const DefaultArgExpr & other ); |
---|
873 | ~DefaultArgExpr(); |
---|
874 | |
---|
875 | virtual DefaultArgExpr * clone() const { return new DefaultArgExpr( * this ); } |
---|
876 | virtual void accept( Visitor & v ) { v.visit( this ); } |
---|
877 | virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } |
---|
878 | virtual void print( std::ostream & os, Indenter indent = {} ) const; |
---|
879 | }; |
---|
880 | |
---|
881 | /// C11 _Generic expression |
---|
882 | class GenericExpr : public Expression { |
---|
883 | public: |
---|
884 | struct Association { |
---|
885 | Type * type = nullptr; |
---|
886 | Expression * expr = nullptr; |
---|
887 | bool isDefault = false; |
---|
888 | |
---|
889 | Association( Type * type, Expression * expr ); |
---|
890 | Association( Expression * expr ); |
---|
891 | Association( const Association & other ); |
---|
892 | Association & operator=( const Association & other ) = delete; // at the moment this isn't used, and I don't want to implement it |
---|
893 | ~Association(); |
---|
894 | }; |
---|
895 | |
---|
896 | Expression * control; |
---|
897 | std::list<Association> associations; |
---|
898 | |
---|
899 | GenericExpr( Expression * control, const std::list<Association> & assoc ); |
---|
900 | GenericExpr( const GenericExpr & other ); |
---|
901 | virtual ~GenericExpr(); |
---|
902 | |
---|
903 | virtual GenericExpr * clone() const { return new GenericExpr( * this ); } |
---|
904 | virtual void accept( Visitor & v ) { v.visit( this ); } |
---|
905 | virtual Expression * acceptMutator( Mutator & m ) { return m.mutate( this ); } |
---|
906 | virtual void print( std::ostream & os, Indenter indent = {} ) const; |
---|
907 | }; |
---|
908 | |
---|
909 | // Local Variables: // |
---|
910 | // tab-width: 4 // |
---|
911 | // mode: c++ // |
---|
912 | // compile-command: "make install" // |
---|
913 | // End: // |
---|