source: src/SynTree/Mutator.cc@ 6182039

ADT aaron-thesis arm-eh ast-experimental cleanup-dtors deferred_resn demangler enum forall-pointer-decay jacob/cs343-translation jenkins-sandbox new-ast new-ast-unique-expr new-env no_list persistent-indexer pthread-emulation qualifiedEnum resolv-new with_gc
Last change on this file since 6182039 was fbcde64, checked in by Peter A. Buhr <pabuhr@…>, 8 years ago

remove duplication in compound literal, support aggregate-type compound literals

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