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