source: src/SynTree/Mutator.cc@ 5e298d7

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 5e298d7 was daf1af8, checked in by Andrew Beach <ajbeach@…>, 8 years ago

Added a new ThrowStmt node to the Syntax Tree.

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