source: src/SynTree/Mutator.cc @ 0c92c9f

ADTaaron-thesisarm-ehast-experimentalcleanup-dtorsdeferred_resndemanglerenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprnew-envno_listpersistent-indexerpthread-emulationqualifiedEnumresolv-newwith_gc
Last change on this file since 0c92c9f was 907eccb, checked in by Rob Schluntz <rschlunt@…>, 7 years ago

added UntypedTupleExpr? to better differentiate typed and untyped contexts, simplifying some code

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