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 | // Mutator.cc --
|
---|
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 : Thu Aug 17 15:39:37 2017
|
---|
13 | // Update Count : 27
|
---|
14 | //
|
---|
15 |
|
---|
16 | #include <cassert> // for assert
|
---|
17 | #include <list> // for list
|
---|
18 |
|
---|
19 | #include "Declaration.h" // for ObjectDecl, Declaration, DeclarationWi...
|
---|
20 | #include "Expression.h" // for Expression, ConstantExpr, ConditionalExpr
|
---|
21 | #include "Initializer.h" // for ConstructorInit, Initializer, Designation
|
---|
22 | #include "Mutator.h"
|
---|
23 | #include "Statement.h" // for Statement, CatchStmt, AsmStmt, ForStmt
|
---|
24 | #include "Type.h" // for Type, Type::ForallList, AttrType, Arra...
|
---|
25 | #include "TypeSubstitution.h" // for TypeSubstitution
|
---|
26 |
|
---|
27 | class Constant;
|
---|
28 | class Subrange;
|
---|
29 |
|
---|
30 | Mutator::Mutator() {}
|
---|
31 |
|
---|
32 | Mutator::~Mutator() {}
|
---|
33 |
|
---|
34 | DeclarationWithType * Mutator::mutate( ObjectDecl *objectDecl ) {
|
---|
35 | objectDecl->set_type( maybeMutate( objectDecl->get_type(), *this ) );
|
---|
36 | objectDecl->set_init( maybeMutate( objectDecl->get_init(), *this ) );
|
---|
37 | objectDecl->set_bitfieldWidth( maybeMutate( objectDecl->get_bitfieldWidth(), *this ) );
|
---|
38 | return objectDecl;
|
---|
39 | }
|
---|
40 |
|
---|
41 | DeclarationWithType * Mutator::mutate( FunctionDecl *functionDecl ) {
|
---|
42 | functionDecl->set_functionType( maybeMutate( functionDecl->get_functionType(), *this ) );
|
---|
43 | functionDecl->set_statements( maybeMutate( functionDecl->get_statements(), *this ) );
|
---|
44 | return functionDecl;
|
---|
45 | }
|
---|
46 |
|
---|
47 | Declaration * Mutator::handleAggregateDecl( AggregateDecl *aggregateDecl ) {
|
---|
48 | mutateAll( aggregateDecl->get_parameters(), *this );
|
---|
49 | mutateAll( aggregateDecl->get_members(), *this );
|
---|
50 | return aggregateDecl;
|
---|
51 | }
|
---|
52 |
|
---|
53 | Declaration * Mutator::mutate( StructDecl *aggregateDecl ) {
|
---|
54 | handleAggregateDecl( aggregateDecl );
|
---|
55 | return aggregateDecl;
|
---|
56 | }
|
---|
57 |
|
---|
58 | Declaration * Mutator::mutate( UnionDecl *aggregateDecl ) {
|
---|
59 | handleAggregateDecl( aggregateDecl );
|
---|
60 | return aggregateDecl;
|
---|
61 | }
|
---|
62 |
|
---|
63 | Declaration * Mutator::mutate( EnumDecl *aggregateDecl ) {
|
---|
64 | handleAggregateDecl( aggregateDecl );
|
---|
65 | return aggregateDecl;
|
---|
66 | }
|
---|
67 |
|
---|
68 | Declaration * Mutator::mutate( TraitDecl *aggregateDecl ) {
|
---|
69 | handleAggregateDecl( aggregateDecl );
|
---|
70 | return aggregateDecl;
|
---|
71 | }
|
---|
72 |
|
---|
73 | Declaration * Mutator::handleNamedTypeDecl( NamedTypeDecl *typeDecl ) {
|
---|
74 | mutateAll( typeDecl->get_parameters(), *this );
|
---|
75 | mutateAll( typeDecl->get_assertions(), *this );
|
---|
76 | typeDecl->set_base( maybeMutate( typeDecl->get_base(), *this ) );
|
---|
77 | return typeDecl;
|
---|
78 | }
|
---|
79 |
|
---|
80 | TypeDecl * Mutator::mutate( TypeDecl *typeDecl ) {
|
---|
81 | handleNamedTypeDecl( typeDecl );
|
---|
82 | typeDecl->set_init( maybeMutate( typeDecl->get_init(), *this ) );
|
---|
83 | return typeDecl;
|
---|
84 | }
|
---|
85 |
|
---|
86 | Declaration * Mutator::mutate( TypedefDecl *typeDecl ) {
|
---|
87 | handleNamedTypeDecl( typeDecl );
|
---|
88 | return typeDecl;
|
---|
89 | }
|
---|
90 |
|
---|
91 | AsmDecl * Mutator::mutate( AsmDecl *asmDecl ) {
|
---|
92 | asmDecl->set_stmt( maybeMutate( asmDecl->get_stmt(), *this ) );
|
---|
93 | return asmDecl;
|
---|
94 | }
|
---|
95 |
|
---|
96 |
|
---|
97 | CompoundStmt * Mutator::mutate( CompoundStmt *compoundStmt ) {
|
---|
98 | mutateAll( compoundStmt->get_kids(), *this );
|
---|
99 | return compoundStmt;
|
---|
100 | }
|
---|
101 |
|
---|
102 | Statement * Mutator::mutate( ExprStmt *exprStmt ) {
|
---|
103 | exprStmt->set_expr( maybeMutate( exprStmt->get_expr(), *this ) );
|
---|
104 | return exprStmt;
|
---|
105 | }
|
---|
106 |
|
---|
107 | Statement * Mutator::mutate( AsmStmt *asmStmt ) {
|
---|
108 | asmStmt->set_instruction( maybeMutate( asmStmt->get_instruction(), *this ) );
|
---|
109 | mutateAll( asmStmt->get_output(), *this );
|
---|
110 | mutateAll( asmStmt->get_input(), *this );
|
---|
111 | mutateAll( asmStmt->get_clobber(), *this );
|
---|
112 | return asmStmt;
|
---|
113 | }
|
---|
114 |
|
---|
115 | Statement * Mutator::mutate( IfStmt *ifStmt ) {
|
---|
116 | mutateAll( ifStmt->get_initialization(), *this );
|
---|
117 | ifStmt->set_condition( maybeMutate( ifStmt->get_condition(), *this ) );
|
---|
118 | ifStmt->set_thenPart( maybeMutate( ifStmt->get_thenPart(), *this ) );
|
---|
119 | ifStmt->set_elsePart( maybeMutate( ifStmt->get_elsePart(), *this ) );
|
---|
120 | return ifStmt;
|
---|
121 | }
|
---|
122 |
|
---|
123 | Statement * Mutator::mutate( WhileStmt *whileStmt ) {
|
---|
124 | whileStmt->set_condition( maybeMutate( whileStmt->get_condition(), *this ) );
|
---|
125 | whileStmt->set_body( maybeMutate( whileStmt->get_body(), *this ) );
|
---|
126 | return whileStmt;
|
---|
127 | }
|
---|
128 |
|
---|
129 | Statement * Mutator::mutate( ForStmt *forStmt ) {
|
---|
130 | mutateAll( forStmt->get_initialization(), *this );
|
---|
131 | forStmt->set_condition( maybeMutate( forStmt->get_condition(), *this ) );
|
---|
132 | forStmt->set_increment( maybeMutate( forStmt->get_increment(), *this ) );
|
---|
133 | forStmt->set_body( maybeMutate( forStmt->get_body(), *this ) );
|
---|
134 | return forStmt;
|
---|
135 | }
|
---|
136 |
|
---|
137 | Statement * Mutator::mutate( SwitchStmt *switchStmt ) {
|
---|
138 | switchStmt->set_condition( maybeMutate( switchStmt->get_condition(), *this ) );
|
---|
139 | mutateAll( switchStmt->get_statements(), *this );
|
---|
140 | return switchStmt;
|
---|
141 | }
|
---|
142 |
|
---|
143 | Statement * Mutator::mutate( CaseStmt *caseStmt ) {
|
---|
144 | caseStmt->set_condition( maybeMutate( caseStmt->get_condition(), *this ) );
|
---|
145 | mutateAll (caseStmt->get_statements(), *this );
|
---|
146 |
|
---|
147 | return caseStmt;
|
---|
148 | }
|
---|
149 |
|
---|
150 | Statement * Mutator::mutate( BranchStmt *branchStmt ) {
|
---|
151 | return branchStmt;
|
---|
152 | }
|
---|
153 |
|
---|
154 | Statement * Mutator::mutate( ReturnStmt *returnStmt ) {
|
---|
155 | returnStmt->set_expr( maybeMutate( returnStmt->get_expr(), *this ) );
|
---|
156 | return returnStmt;
|
---|
157 | }
|
---|
158 |
|
---|
159 | Statement * Mutator::mutate( ThrowStmt *throwStmt ) {
|
---|
160 | throwStmt->set_expr( maybeMutate( throwStmt->get_expr(), *this ) );
|
---|
161 | throwStmt->set_target( maybeMutate( throwStmt->get_target(), *this ) );
|
---|
162 | return throwStmt;
|
---|
163 | }
|
---|
164 |
|
---|
165 | Statement * Mutator::mutate( TryStmt *tryStmt ) {
|
---|
166 | tryStmt->set_block( maybeMutate( tryStmt->get_block(), *this ) );
|
---|
167 | mutateAll( tryStmt->get_catchers(), *this );
|
---|
168 | tryStmt->set_finally( maybeMutate( tryStmt->get_finally(), *this ) );
|
---|
169 | return tryStmt;
|
---|
170 | }
|
---|
171 |
|
---|
172 | Statement * Mutator::mutate( CatchStmt *catchStmt ) {
|
---|
173 | catchStmt->set_decl( maybeMutate( catchStmt->get_decl(), *this ) );
|
---|
174 | catchStmt->set_cond( maybeMutate( catchStmt->get_cond(), *this ) );
|
---|
175 | catchStmt->set_body( maybeMutate( catchStmt->get_body(), *this ) );
|
---|
176 | return catchStmt;
|
---|
177 | }
|
---|
178 |
|
---|
179 | Statement * Mutator::mutate( FinallyStmt *finalStmt ) {
|
---|
180 | finalStmt->set_block( maybeMutate( finalStmt->get_block(), *this ) );
|
---|
181 | return finalStmt;
|
---|
182 | }
|
---|
183 |
|
---|
184 | Statement * Mutator::mutate( WaitForStmt *waitforStmt ) {
|
---|
185 | for( auto & clause : waitforStmt->clauses ) {
|
---|
186 | clause.target.function = maybeMutate( clause.target.function, *this );
|
---|
187 | mutateAll( clause.target.arguments, *this );
|
---|
188 |
|
---|
189 | clause.statement = maybeMutate( clause.statement, *this );
|
---|
190 | clause.condition = maybeMutate( clause.condition, *this );
|
---|
191 | }
|
---|
192 |
|
---|
193 | waitforStmt->timeout.time = maybeMutate( waitforStmt->timeout.time, *this );
|
---|
194 | waitforStmt->timeout.statement = maybeMutate( waitforStmt->timeout.statement, *this );
|
---|
195 | waitforStmt->timeout.condition = maybeMutate( waitforStmt->timeout.condition, *this );
|
---|
196 | waitforStmt->orelse.statement = maybeMutate( waitforStmt->orelse.statement, *this );
|
---|
197 | waitforStmt->orelse.condition = maybeMutate( waitforStmt->orelse.condition, *this );
|
---|
198 |
|
---|
199 | return waitforStmt;
|
---|
200 | }
|
---|
201 |
|
---|
202 | NullStmt * Mutator::mutate( NullStmt *nullStmt ) {
|
---|
203 | return nullStmt;
|
---|
204 | }
|
---|
205 |
|
---|
206 | Statement * Mutator::mutate( DeclStmt *declStmt ) {
|
---|
207 | declStmt->set_decl( maybeMutate( declStmt->get_decl(), *this ) );
|
---|
208 | return declStmt;
|
---|
209 | }
|
---|
210 |
|
---|
211 | Statement * Mutator::mutate( ImplicitCtorDtorStmt *impCtorDtorStmt ) {
|
---|
212 | impCtorDtorStmt->set_callStmt( maybeMutate( impCtorDtorStmt->get_callStmt(), *this ) );
|
---|
213 | return impCtorDtorStmt;
|
---|
214 | }
|
---|
215 |
|
---|
216 |
|
---|
217 | Expression * Mutator::mutate( ApplicationExpr *applicationExpr ) {
|
---|
218 | applicationExpr->set_env( maybeMutate( applicationExpr->get_env(), *this ) );
|
---|
219 | applicationExpr->set_result( maybeMutate( applicationExpr->get_result(), *this ) );
|
---|
220 | applicationExpr->set_function( maybeMutate( applicationExpr->get_function(), *this ) );
|
---|
221 | mutateAll( applicationExpr->get_args(), *this );
|
---|
222 | return applicationExpr;
|
---|
223 | }
|
---|
224 |
|
---|
225 | Expression * Mutator::mutate( UntypedExpr *untypedExpr ) {
|
---|
226 | untypedExpr->set_env( maybeMutate( untypedExpr->get_env(), *this ) );
|
---|
227 | untypedExpr->set_result( maybeMutate( untypedExpr->get_result(), *this ) );
|
---|
228 | mutateAll( untypedExpr->get_args(), *this );
|
---|
229 | return untypedExpr;
|
---|
230 | }
|
---|
231 |
|
---|
232 | Expression * Mutator::mutate( NameExpr *nameExpr ) {
|
---|
233 | nameExpr->set_env( maybeMutate( nameExpr->get_env(), *this ) );
|
---|
234 | nameExpr->set_result( maybeMutate( nameExpr->get_result(), *this ) );
|
---|
235 | return nameExpr;
|
---|
236 | }
|
---|
237 |
|
---|
238 | Expression * Mutator::mutate( AddressExpr *addressExpr ) {
|
---|
239 | addressExpr->set_env( maybeMutate( addressExpr->get_env(), *this ) );
|
---|
240 | addressExpr->set_result( maybeMutate( addressExpr->get_result(), *this ) );
|
---|
241 | addressExpr->set_arg( maybeMutate( addressExpr->get_arg(), *this ) );
|
---|
242 | return addressExpr;
|
---|
243 | }
|
---|
244 |
|
---|
245 | Expression * Mutator::mutate( LabelAddressExpr *labelAddressExpr ) {
|
---|
246 | labelAddressExpr->set_env( maybeMutate( labelAddressExpr->get_env(), *this ) );
|
---|
247 | labelAddressExpr->set_result( maybeMutate( labelAddressExpr->get_result(), *this ) );
|
---|
248 | labelAddressExpr->set_arg( maybeMutate( labelAddressExpr->get_arg(), *this ) );
|
---|
249 | return labelAddressExpr;
|
---|
250 | }
|
---|
251 |
|
---|
252 | Expression * Mutator::mutate( CastExpr *castExpr ) {
|
---|
253 | castExpr->set_env( maybeMutate( castExpr->get_env(), *this ) );
|
---|
254 | castExpr->set_result( maybeMutate( castExpr->get_result(), *this ) );
|
---|
255 | castExpr->set_arg( maybeMutate( castExpr->get_arg(), *this ) );
|
---|
256 | return castExpr;
|
---|
257 | }
|
---|
258 |
|
---|
259 | Expression * Mutator::mutate( VirtualCastExpr *castExpr ) {
|
---|
260 | castExpr->set_env( maybeMutate( castExpr->get_env(), *this ) );
|
---|
261 | castExpr->set_result( maybeMutate( castExpr->get_result(), *this ) );
|
---|
262 | castExpr->set_arg( maybeMutate( castExpr->get_arg(), *this ) );
|
---|
263 | return castExpr;
|
---|
264 | }
|
---|
265 |
|
---|
266 | Expression * Mutator::mutate( UntypedMemberExpr *memberExpr ) {
|
---|
267 | memberExpr->set_env( maybeMutate( memberExpr->get_env(), *this ) );
|
---|
268 | memberExpr->set_result( maybeMutate( memberExpr->get_result(), *this ) );
|
---|
269 | memberExpr->set_aggregate( maybeMutate( memberExpr->get_aggregate(), *this ) );
|
---|
270 | memberExpr->set_member( maybeMutate( memberExpr->get_member(), *this ) );
|
---|
271 | return memberExpr;
|
---|
272 | }
|
---|
273 |
|
---|
274 | Expression * Mutator::mutate( MemberExpr *memberExpr ) {
|
---|
275 | memberExpr->set_env( maybeMutate( memberExpr->get_env(), *this ) );
|
---|
276 | memberExpr->set_result( maybeMutate( memberExpr->get_result(), *this ) );
|
---|
277 | memberExpr->set_aggregate( maybeMutate( memberExpr->get_aggregate(), *this ) );
|
---|
278 | return memberExpr;
|
---|
279 | }
|
---|
280 |
|
---|
281 | Expression * Mutator::mutate( VariableExpr *variableExpr ) {
|
---|
282 | variableExpr->set_env( maybeMutate( variableExpr->get_env(), *this ) );
|
---|
283 | variableExpr->set_result( maybeMutate( variableExpr->get_result(), *this ) );
|
---|
284 | return variableExpr;
|
---|
285 | }
|
---|
286 |
|
---|
287 | Expression * Mutator::mutate( ConstantExpr *constantExpr ) {
|
---|
288 | constantExpr->set_env( maybeMutate( constantExpr->get_env(), *this ) );
|
---|
289 | constantExpr->set_result( maybeMutate( constantExpr->get_result(), *this ) );
|
---|
290 | // maybeMutate( constantExpr->get_constant(), *this )
|
---|
291 | return constantExpr;
|
---|
292 | }
|
---|
293 |
|
---|
294 | Expression * Mutator::mutate( SizeofExpr *sizeofExpr ) {
|
---|
295 | sizeofExpr->set_env( maybeMutate( sizeofExpr->get_env(), *this ) );
|
---|
296 | sizeofExpr->set_result( maybeMutate( sizeofExpr->get_result(), *this ) );
|
---|
297 | if ( sizeofExpr->get_isType() ) {
|
---|
298 | sizeofExpr->set_type( maybeMutate( sizeofExpr->get_type(), *this ) );
|
---|
299 | } else {
|
---|
300 | sizeofExpr->set_expr( maybeMutate( sizeofExpr->get_expr(), *this ) );
|
---|
301 | }
|
---|
302 | return sizeofExpr;
|
---|
303 | }
|
---|
304 |
|
---|
305 | Expression * Mutator::mutate( AlignofExpr *alignofExpr ) {
|
---|
306 | alignofExpr->set_env( maybeMutate( alignofExpr->get_env(), *this ) );
|
---|
307 | alignofExpr->set_result( maybeMutate( alignofExpr->get_result(), *this ) );
|
---|
308 | if ( alignofExpr->get_isType() ) {
|
---|
309 | alignofExpr->set_type( maybeMutate( alignofExpr->get_type(), *this ) );
|
---|
310 | } else {
|
---|
311 | alignofExpr->set_expr( maybeMutate( alignofExpr->get_expr(), *this ) );
|
---|
312 | }
|
---|
313 | return alignofExpr;
|
---|
314 | }
|
---|
315 |
|
---|
316 | Expression * Mutator::mutate( UntypedOffsetofExpr *offsetofExpr ) {
|
---|
317 | offsetofExpr->set_env( maybeMutate( offsetofExpr->get_env(), *this ) );
|
---|
318 | offsetofExpr->set_result( maybeMutate( offsetofExpr->get_result(), *this ) );
|
---|
319 | offsetofExpr->set_type( maybeMutate( offsetofExpr->get_type(), *this ) );
|
---|
320 | return offsetofExpr;
|
---|
321 | }
|
---|
322 |
|
---|
323 | Expression * Mutator::mutate( OffsetofExpr *offsetofExpr ) {
|
---|
324 | offsetofExpr->set_env( maybeMutate( offsetofExpr->get_env(), *this ) );
|
---|
325 | offsetofExpr->set_result( maybeMutate( offsetofExpr->get_result(), *this ) );
|
---|
326 | offsetofExpr->set_type( maybeMutate( offsetofExpr->get_type(), *this ) );
|
---|
327 | offsetofExpr->set_member( maybeMutate( offsetofExpr->get_member(), *this ) );
|
---|
328 | return offsetofExpr;
|
---|
329 | }
|
---|
330 |
|
---|
331 | Expression * Mutator::mutate( OffsetPackExpr *offsetPackExpr ) {
|
---|
332 | offsetPackExpr->set_env( maybeMutate( offsetPackExpr->get_env(), *this ) );
|
---|
333 | offsetPackExpr->set_result( maybeMutate( offsetPackExpr->get_result(), *this ) );
|
---|
334 | offsetPackExpr->set_type( maybeMutate( offsetPackExpr->get_type(), *this ) );
|
---|
335 | return offsetPackExpr;
|
---|
336 | }
|
---|
337 |
|
---|
338 | Expression * Mutator::mutate( AttrExpr *attrExpr ) {
|
---|
339 | attrExpr->set_env( maybeMutate( attrExpr->get_env(), *this ) );
|
---|
340 | attrExpr->set_result( maybeMutate( attrExpr->get_result(), *this ) );
|
---|
341 | if ( attrExpr->get_isType() ) {
|
---|
342 | attrExpr->set_type( maybeMutate( attrExpr->get_type(), *this ) );
|
---|
343 | } else {
|
---|
344 | attrExpr->set_expr( maybeMutate( attrExpr->get_expr(), *this ) );
|
---|
345 | }
|
---|
346 | return attrExpr;
|
---|
347 | }
|
---|
348 |
|
---|
349 | Expression * Mutator::mutate( LogicalExpr *logicalExpr ) {
|
---|
350 | logicalExpr->set_env( maybeMutate( logicalExpr->get_env(), *this ) );
|
---|
351 | logicalExpr->set_result( maybeMutate( logicalExpr->get_result(), *this ) );
|
---|
352 | logicalExpr->set_arg1( maybeMutate( logicalExpr->get_arg1(), *this ) );
|
---|
353 | logicalExpr->set_arg2( maybeMutate( logicalExpr->get_arg2(), *this ) );
|
---|
354 | return logicalExpr;
|
---|
355 | }
|
---|
356 |
|
---|
357 | Expression * Mutator::mutate( ConditionalExpr *conditionalExpr ) {
|
---|
358 | conditionalExpr->set_env( maybeMutate( conditionalExpr->get_env(), *this ) );
|
---|
359 | conditionalExpr->set_result( maybeMutate( conditionalExpr->get_result(), *this ) );
|
---|
360 | conditionalExpr->set_arg1( maybeMutate( conditionalExpr->get_arg1(), *this ) );
|
---|
361 | conditionalExpr->set_arg2( maybeMutate( conditionalExpr->get_arg2(), *this ) );
|
---|
362 | conditionalExpr->set_arg3( maybeMutate( conditionalExpr->get_arg3(), *this ) );
|
---|
363 | return conditionalExpr;
|
---|
364 | }
|
---|
365 |
|
---|
366 | Expression * Mutator::mutate( CommaExpr *commaExpr ) {
|
---|
367 | commaExpr->set_env( maybeMutate( commaExpr->get_env(), *this ) );
|
---|
368 | commaExpr->set_result( maybeMutate( commaExpr->get_result(), *this ) );
|
---|
369 | commaExpr->set_arg1( maybeMutate( commaExpr->get_arg1(), *this ) );
|
---|
370 | commaExpr->set_arg2( maybeMutate( commaExpr->get_arg2(), *this ) );
|
---|
371 | return commaExpr;
|
---|
372 | }
|
---|
373 |
|
---|
374 | Expression * Mutator::mutate( TypeExpr *typeExpr ) {
|
---|
375 | typeExpr->set_env( maybeMutate( typeExpr->get_env(), *this ) );
|
---|
376 | typeExpr->set_result( maybeMutate( typeExpr->get_result(), *this ) );
|
---|
377 | typeExpr->set_type( maybeMutate( typeExpr->get_type(), *this ) );
|
---|
378 | return typeExpr;
|
---|
379 | }
|
---|
380 |
|
---|
381 | Expression * Mutator::mutate( AsmExpr *asmExpr ) {
|
---|
382 | asmExpr->set_env( maybeMutate( asmExpr->get_env(), *this ) );
|
---|
383 | asmExpr->set_inout( maybeMutate( asmExpr->get_inout(), *this ) );
|
---|
384 | asmExpr->set_constraint( maybeMutate( asmExpr->get_constraint(), *this ) );
|
---|
385 | asmExpr->set_operand( maybeMutate( asmExpr->get_operand(), *this ) );
|
---|
386 | return asmExpr;
|
---|
387 | }
|
---|
388 |
|
---|
389 | Expression* Mutator::mutate( ImplicitCopyCtorExpr *impCpCtorExpr ) {
|
---|
390 | impCpCtorExpr->set_env( maybeMutate( impCpCtorExpr->get_env(), *this ) );
|
---|
391 | impCpCtorExpr->set_result( maybeMutate( impCpCtorExpr->get_result(), *this ) );
|
---|
392 | impCpCtorExpr->set_callExpr( maybeMutate( impCpCtorExpr->get_callExpr(), *this ) );
|
---|
393 | mutateAll( impCpCtorExpr->get_tempDecls(), *this );
|
---|
394 | mutateAll( impCpCtorExpr->get_returnDecls(), *this );
|
---|
395 | mutateAll( impCpCtorExpr->get_dtors(), *this );
|
---|
396 | return impCpCtorExpr;
|
---|
397 | }
|
---|
398 |
|
---|
399 | Expression* Mutator::mutate( ConstructorExpr *ctorExpr ) {
|
---|
400 | ctorExpr->set_env( maybeMutate( ctorExpr->get_env(), *this ) );
|
---|
401 | ctorExpr->set_result( maybeMutate( ctorExpr->get_result(), *this ) );
|
---|
402 | ctorExpr->set_callExpr( maybeMutate( ctorExpr->get_callExpr(), *this ) );
|
---|
403 | return ctorExpr;
|
---|
404 | }
|
---|
405 |
|
---|
406 | Expression * Mutator::mutate( CompoundLiteralExpr *compLitExpr ) {
|
---|
407 | compLitExpr->set_env( maybeMutate( compLitExpr->get_env(), *this ) );
|
---|
408 | compLitExpr->set_result( maybeMutate( compLitExpr->get_result(), *this ) );
|
---|
409 | compLitExpr->set_initializer( maybeMutate( compLitExpr->get_initializer(), *this ) );
|
---|
410 | return compLitExpr;
|
---|
411 | }
|
---|
412 |
|
---|
413 | Expression * Mutator::mutate( RangeExpr *rangeExpr ) {
|
---|
414 | rangeExpr->set_env( maybeMutate( rangeExpr->get_env(), *this ) );
|
---|
415 | rangeExpr->set_low( maybeMutate( rangeExpr->get_low(), *this ) );
|
---|
416 | rangeExpr->set_high( maybeMutate( rangeExpr->get_high(), *this ) );
|
---|
417 | return rangeExpr;
|
---|
418 | }
|
---|
419 |
|
---|
420 | Expression * Mutator::mutate( UntypedTupleExpr *tupleExpr ) {
|
---|
421 | tupleExpr->set_env( maybeMutate( tupleExpr->get_env(), *this ) );
|
---|
422 | tupleExpr->set_result( maybeMutate( tupleExpr->get_result(), *this ) );
|
---|
423 | mutateAll( tupleExpr->get_exprs(), *this );
|
---|
424 | return tupleExpr;
|
---|
425 | }
|
---|
426 |
|
---|
427 | Expression * Mutator::mutate( TupleExpr *tupleExpr ) {
|
---|
428 | tupleExpr->set_env( maybeMutate( tupleExpr->get_env(), *this ) );
|
---|
429 | tupleExpr->set_result( maybeMutate( tupleExpr->get_result(), *this ) );
|
---|
430 | mutateAll( tupleExpr->get_exprs(), *this );
|
---|
431 | return tupleExpr;
|
---|
432 | }
|
---|
433 |
|
---|
434 | Expression * Mutator::mutate( TupleIndexExpr *tupleExpr ) {
|
---|
435 | tupleExpr->set_env( maybeMutate( tupleExpr->get_env(), *this ) );
|
---|
436 | tupleExpr->set_result( maybeMutate( tupleExpr->get_result(), *this ) );
|
---|
437 | tupleExpr->set_tuple( maybeMutate( tupleExpr->get_tuple(), *this ) );
|
---|
438 | return tupleExpr;
|
---|
439 | }
|
---|
440 |
|
---|
441 | Expression * Mutator::mutate( TupleAssignExpr *assignExpr ) {
|
---|
442 | assignExpr->set_env( maybeMutate( assignExpr->get_env(), *this ) );
|
---|
443 | assignExpr->set_result( maybeMutate( assignExpr->get_result(), *this ) );
|
---|
444 | assignExpr->set_stmtExpr( maybeMutate( assignExpr->get_stmtExpr(), *this ) );
|
---|
445 | return assignExpr;
|
---|
446 | }
|
---|
447 |
|
---|
448 | Expression * Mutator::mutate( StmtExpr *stmtExpr ) {
|
---|
449 | stmtExpr->set_env( maybeMutate( stmtExpr->get_env(), *this ) );
|
---|
450 | stmtExpr->set_result( maybeMutate( stmtExpr->get_result(), *this ) );
|
---|
451 | stmtExpr->set_statements( maybeMutate( stmtExpr->get_statements(), *this ) );
|
---|
452 | mutateAll( stmtExpr->get_returnDecls(), *this );
|
---|
453 | mutateAll( stmtExpr->get_dtors(), *this );
|
---|
454 | return stmtExpr;
|
---|
455 | }
|
---|
456 |
|
---|
457 | Expression * Mutator::mutate( UniqueExpr *uniqueExpr ) {
|
---|
458 | uniqueExpr->set_env( maybeMutate( uniqueExpr->get_env(), *this ) );
|
---|
459 | uniqueExpr->set_result( maybeMutate( uniqueExpr->get_result(), *this ) );
|
---|
460 | uniqueExpr->set_expr( maybeMutate( uniqueExpr->get_expr(), *this ) );
|
---|
461 | return uniqueExpr;
|
---|
462 | }
|
---|
463 |
|
---|
464 | Expression * Mutator::mutate( UntypedInitExpr * initExpr ) {
|
---|
465 | initExpr->set_env( maybeMutate( initExpr->get_env(), *this ) );
|
---|
466 | initExpr->set_result( maybeMutate( initExpr->get_result(), *this ) );
|
---|
467 | initExpr->set_expr( maybeMutate( initExpr->get_expr(), *this ) );
|
---|
468 | // not currently mutating initAlts, but this doesn't matter since this node is only used in the resolver.
|
---|
469 | return initExpr;
|
---|
470 | }
|
---|
471 |
|
---|
472 | Expression * Mutator::mutate( InitExpr * initExpr ) {
|
---|
473 | initExpr->set_env( maybeMutate( initExpr->get_env(), *this ) );
|
---|
474 | initExpr->set_result( maybeMutate( initExpr->get_result(), *this ) );
|
---|
475 | initExpr->set_expr( maybeMutate( initExpr->get_expr(), *this ) );
|
---|
476 | initExpr->set_designation( maybeMutate( initExpr->get_designation(), *this ) );
|
---|
477 | return initExpr;
|
---|
478 | }
|
---|
479 |
|
---|
480 |
|
---|
481 | Type * Mutator::mutate( VoidType *voidType ) {
|
---|
482 | mutateAll( voidType->get_forall(), *this );
|
---|
483 | return voidType;
|
---|
484 | }
|
---|
485 |
|
---|
486 | Type * Mutator::mutate( BasicType *basicType ) {
|
---|
487 | mutateAll( basicType->get_forall(), *this );
|
---|
488 | return basicType;
|
---|
489 | }
|
---|
490 |
|
---|
491 | Type * Mutator::mutate( PointerType *pointerType ) {
|
---|
492 | mutateAll( pointerType->get_forall(), *this );
|
---|
493 | pointerType->set_base( maybeMutate( pointerType->get_base(), *this ) );
|
---|
494 | return pointerType;
|
---|
495 | }
|
---|
496 |
|
---|
497 | Type * Mutator::mutate( ArrayType *arrayType ) {
|
---|
498 | mutateAll( arrayType->get_forall(), *this );
|
---|
499 | arrayType->set_dimension( maybeMutate( arrayType->get_dimension(), *this ) );
|
---|
500 | arrayType->set_base( maybeMutate( arrayType->get_base(), *this ) );
|
---|
501 | return arrayType;
|
---|
502 | }
|
---|
503 |
|
---|
504 | Type * Mutator::mutate( ReferenceType * refType ) {
|
---|
505 | mutateAll( refType->get_forall(), *this );
|
---|
506 | refType->set_base( maybeMutate( refType->get_base(), *this ) );
|
---|
507 | return refType;
|
---|
508 | }
|
---|
509 |
|
---|
510 | Type * Mutator::mutate( FunctionType * functionType ) {
|
---|
511 | mutateAll( functionType->get_forall(), *this );
|
---|
512 | mutateAll( functionType->get_returnVals(), *this );
|
---|
513 | mutateAll( functionType->get_parameters(), *this );
|
---|
514 | return functionType;
|
---|
515 | }
|
---|
516 |
|
---|
517 | Type * Mutator::handleReferenceToType( ReferenceToType *aggregateUseType ) {
|
---|
518 | mutateAll( aggregateUseType->get_forall(), *this );
|
---|
519 | mutateAll( aggregateUseType->get_parameters(), *this );
|
---|
520 | return aggregateUseType;
|
---|
521 | }
|
---|
522 |
|
---|
523 | Type * Mutator::mutate( StructInstType *aggregateUseType ) {
|
---|
524 | handleReferenceToType( aggregateUseType );
|
---|
525 | return aggregateUseType;
|
---|
526 | }
|
---|
527 |
|
---|
528 | Type * Mutator::mutate( UnionInstType *aggregateUseType ) {
|
---|
529 | handleReferenceToType( aggregateUseType );
|
---|
530 | return aggregateUseType;
|
---|
531 | }
|
---|
532 |
|
---|
533 | Type * Mutator::mutate( EnumInstType *aggregateUseType ) {
|
---|
534 | handleReferenceToType( aggregateUseType );
|
---|
535 | return aggregateUseType;
|
---|
536 | }
|
---|
537 |
|
---|
538 | Type * Mutator::mutate( TraitInstType *aggregateUseType ) {
|
---|
539 | handleReferenceToType( aggregateUseType );
|
---|
540 | mutateAll( aggregateUseType->get_members(), *this );
|
---|
541 | return aggregateUseType;
|
---|
542 | }
|
---|
543 |
|
---|
544 | Type * Mutator::mutate( TypeInstType *aggregateUseType ) {
|
---|
545 | handleReferenceToType( aggregateUseType );
|
---|
546 | return aggregateUseType;
|
---|
547 | }
|
---|
548 |
|
---|
549 | Type * Mutator::mutate( TupleType *tupleType ) {
|
---|
550 | mutateAll( tupleType->get_forall(), *this );
|
---|
551 | mutateAll( tupleType->get_types(), *this );
|
---|
552 | mutateAll( tupleType->get_members(), *this );
|
---|
553 | return tupleType;
|
---|
554 | }
|
---|
555 |
|
---|
556 | Type * Mutator::mutate( TypeofType *typeofType ) {
|
---|
557 | assert( typeofType->get_expr() );
|
---|
558 | typeofType->set_expr( typeofType->get_expr()->acceptMutator( *this ) );
|
---|
559 | return typeofType;
|
---|
560 | }
|
---|
561 |
|
---|
562 | Type * Mutator::mutate( AttrType *attrType ) {
|
---|
563 | if ( attrType->get_isType() ) {
|
---|
564 | assert( attrType->get_type() );
|
---|
565 | attrType->set_type( attrType->get_type()->acceptMutator( *this ) );
|
---|
566 | } else {
|
---|
567 | assert( attrType->get_expr() );
|
---|
568 | attrType->set_expr( attrType->get_expr()->acceptMutator( *this ) );
|
---|
569 | }
|
---|
570 | return attrType;
|
---|
571 | }
|
---|
572 |
|
---|
573 | Type * Mutator::mutate( VarArgsType *varArgsType ) {
|
---|
574 | mutateAll( varArgsType->get_forall(), *this );
|
---|
575 | return varArgsType;
|
---|
576 | }
|
---|
577 |
|
---|
578 | Type * Mutator::mutate( ZeroType *zeroType ) {
|
---|
579 | mutateAll( zeroType->get_forall(), *this );
|
---|
580 | return zeroType;
|
---|
581 | }
|
---|
582 |
|
---|
583 | Type * Mutator::mutate( OneType *oneType ) {
|
---|
584 | mutateAll( oneType->get_forall(), *this );
|
---|
585 | return oneType;
|
---|
586 | }
|
---|
587 |
|
---|
588 |
|
---|
589 | Designation * Mutator::mutate( Designation * designation ) {
|
---|
590 | mutateAll( designation->get_designators(), *this );
|
---|
591 | return designation;
|
---|
592 | }
|
---|
593 |
|
---|
594 | Initializer * Mutator::mutate( SingleInit *singleInit ) {
|
---|
595 | singleInit->set_value( singleInit->get_value()->acceptMutator( *this ) );
|
---|
596 | return singleInit;
|
---|
597 | }
|
---|
598 |
|
---|
599 | Initializer * Mutator::mutate( ListInit *listInit ) {
|
---|
600 | mutateAll( listInit->get_designations(), *this );
|
---|
601 | mutateAll( listInit->get_initializers(), *this );
|
---|
602 | return listInit;
|
---|
603 | }
|
---|
604 |
|
---|
605 | Initializer * Mutator::mutate( ConstructorInit *ctorInit ) {
|
---|
606 | ctorInit->set_ctor( maybeMutate( ctorInit->get_ctor(), *this ) );
|
---|
607 | ctorInit->set_dtor( maybeMutate( ctorInit->get_dtor(), *this ) );
|
---|
608 | ctorInit->set_init( maybeMutate( ctorInit->get_init(), *this ) );
|
---|
609 | return ctorInit;
|
---|
610 | }
|
---|
611 |
|
---|
612 |
|
---|
613 | Subrange * Mutator::mutate( Subrange *subrange ) {
|
---|
614 | return subrange;
|
---|
615 | }
|
---|
616 |
|
---|
617 |
|
---|
618 | Constant * Mutator::mutate( Constant *constant ) {
|
---|
619 | return constant;
|
---|
620 | }
|
---|
621 |
|
---|
622 | // Local Variables: //
|
---|
623 | // tab-width: 4 //
|
---|
624 | // mode: c++ //
|
---|
625 | // compile-command: "make install" //
|
---|
626 | // End: //
|
---|