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