source: src/SynTree/Mutator.cc @ a5f0529

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

Virtual casts have been added. They still require a lot of hand coded support to work but for simple cases it should be enough.

  • Property mode set to 100644
File size: 20.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 : Andrew Beach
12// Last Modified On : Mon Jul 24 16:32:00 2017
13// Update Count     : 25
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        tryStmt->set_finally( maybeMutate( tryStmt->get_finally(), *this ) );
165        return tryStmt;
166}
167
168Statement *Mutator::mutate( CatchStmt *catchStmt ) {
169        catchStmt->set_decl( maybeMutate( catchStmt->get_decl(), *this ) );
170        catchStmt->set_cond( maybeMutate( catchStmt->get_cond(), *this ) );
171        catchStmt->set_body( maybeMutate( catchStmt->get_body(), *this ) );
172        return catchStmt;
173}
174
175Statement *Mutator::mutate( FinallyStmt *finalStmt ) {
176        finalStmt->set_block( maybeMutate( finalStmt->get_block(), *this ) );
177        return finalStmt;
178}
179
180NullStmt *Mutator::mutate( NullStmt *nullStmt ) {
181        return nullStmt;
182}
183
184Statement *Mutator::mutate( DeclStmt *declStmt ) {
185        declStmt->set_decl( maybeMutate( declStmt->get_decl(), *this ) );
186        return declStmt;
187}
188
189Statement *Mutator::mutate( ImplicitCtorDtorStmt *impCtorDtorStmt ) {
190        impCtorDtorStmt->set_callStmt( maybeMutate( impCtorDtorStmt->get_callStmt(), *this ) );
191        return impCtorDtorStmt;
192}
193
194
195Expression *Mutator::mutate( ApplicationExpr *applicationExpr ) {
196        applicationExpr->set_env( maybeMutate( applicationExpr->get_env(), *this ) );
197        applicationExpr->set_result( maybeMutate( applicationExpr->get_result(), *this ) );
198        applicationExpr->set_function( maybeMutate( applicationExpr->get_function(), *this ) );
199        mutateAll( applicationExpr->get_args(), *this );
200        return applicationExpr;
201}
202
203Expression *Mutator::mutate( UntypedExpr *untypedExpr ) {
204        untypedExpr->set_env( maybeMutate( untypedExpr->get_env(), *this ) );
205        untypedExpr->set_result( maybeMutate( untypedExpr->get_result(), *this ) );
206        mutateAll( untypedExpr->get_args(), *this );
207        return untypedExpr;
208}
209
210Expression *Mutator::mutate( NameExpr *nameExpr ) {
211        nameExpr->set_env( maybeMutate( nameExpr->get_env(), *this ) );
212        nameExpr->set_result( maybeMutate( nameExpr->get_result(), *this ) );
213        return nameExpr;
214}
215
216Expression *Mutator::mutate( AddressExpr *addressExpr ) {
217        addressExpr->set_env( maybeMutate( addressExpr->get_env(), *this ) );
218        addressExpr->set_result( maybeMutate( addressExpr->get_result(), *this ) );
219        addressExpr->set_arg( maybeMutate( addressExpr->get_arg(), *this ) );
220        return addressExpr;
221}
222
223Expression *Mutator::mutate( LabelAddressExpr *labelAddressExpr ) {
224        labelAddressExpr->set_env( maybeMutate( labelAddressExpr->get_env(), *this ) );
225        labelAddressExpr->set_result( maybeMutate( labelAddressExpr->get_result(), *this ) );
226        labelAddressExpr->set_arg( maybeMutate( labelAddressExpr->get_arg(), *this ) );
227        return labelAddressExpr;
228}
229
230Expression *Mutator::mutate( CastExpr *castExpr ) {
231        castExpr->set_env( maybeMutate( castExpr->get_env(), *this ) );
232        castExpr->set_result( maybeMutate( castExpr->get_result(), *this ) );
233        castExpr->set_arg( maybeMutate( castExpr->get_arg(), *this ) );
234        return castExpr;
235}
236
237Expression *Mutator::mutate( VirtualCastExpr *castExpr ) {
238        castExpr->set_env( maybeMutate( castExpr->get_env(), *this ) );
239        castExpr->set_result( maybeMutate( castExpr->get_result(), *this ) );
240        castExpr->set_arg( maybeMutate( castExpr->get_arg(), *this ) );
241        return castExpr;
242}
243
244Expression *Mutator::mutate( UntypedMemberExpr *memberExpr ) {
245        memberExpr->set_env( maybeMutate( memberExpr->get_env(), *this ) );
246        memberExpr->set_result( maybeMutate( memberExpr->get_result(), *this ) );
247        memberExpr->set_aggregate( maybeMutate( memberExpr->get_aggregate(), *this ) );
248        memberExpr->set_member( maybeMutate( memberExpr->get_member(), *this ) );
249        return memberExpr;
250}
251
252Expression *Mutator::mutate( MemberExpr *memberExpr ) {
253        memberExpr->set_env( maybeMutate( memberExpr->get_env(), *this ) );
254        memberExpr->set_result( maybeMutate( memberExpr->get_result(), *this ) );
255        memberExpr->set_aggregate( maybeMutate( memberExpr->get_aggregate(), *this ) );
256        return memberExpr;
257}
258
259Expression *Mutator::mutate( VariableExpr *variableExpr ) {
260        variableExpr->set_env( maybeMutate( variableExpr->get_env(), *this ) );
261        variableExpr->set_result( maybeMutate( variableExpr->get_result(), *this ) );
262        return variableExpr;
263}
264
265Expression *Mutator::mutate( ConstantExpr *constantExpr ) {
266        constantExpr->set_env( maybeMutate( constantExpr->get_env(), *this ) );
267        constantExpr->set_result( maybeMutate( constantExpr->get_result(), *this ) );
268//  maybeMutate( constantExpr->get_constant(), *this )
269        return constantExpr;
270}
271
272Expression *Mutator::mutate( SizeofExpr *sizeofExpr ) {
273        sizeofExpr->set_env( maybeMutate( sizeofExpr->get_env(), *this ) );
274        sizeofExpr->set_result( maybeMutate( sizeofExpr->get_result(), *this ) );
275        if ( sizeofExpr->get_isType() ) {
276                sizeofExpr->set_type( maybeMutate( sizeofExpr->get_type(), *this ) );
277        } else {
278                sizeofExpr->set_expr( maybeMutate( sizeofExpr->get_expr(), *this ) );
279        }
280        return sizeofExpr;
281}
282
283Expression *Mutator::mutate( AlignofExpr *alignofExpr ) {
284        alignofExpr->set_env( maybeMutate( alignofExpr->get_env(), *this ) );
285        alignofExpr->set_result( maybeMutate( alignofExpr->get_result(), *this ) );
286        if ( alignofExpr->get_isType() ) {
287                alignofExpr->set_type( maybeMutate( alignofExpr->get_type(), *this ) );
288        } else {
289                alignofExpr->set_expr( maybeMutate( alignofExpr->get_expr(), *this ) );
290        }
291        return alignofExpr;
292}
293
294Expression *Mutator::mutate( UntypedOffsetofExpr *offsetofExpr ) {
295        offsetofExpr->set_env( maybeMutate( offsetofExpr->get_env(), *this ) );
296        offsetofExpr->set_result( maybeMutate( offsetofExpr->get_result(), *this ) );
297        offsetofExpr->set_type( maybeMutate( offsetofExpr->get_type(), *this ) );
298        return offsetofExpr;
299}
300
301Expression *Mutator::mutate( OffsetofExpr *offsetofExpr ) {
302        offsetofExpr->set_env( maybeMutate( offsetofExpr->get_env(), *this ) );
303        offsetofExpr->set_result( maybeMutate( offsetofExpr->get_result(), *this ) );
304        offsetofExpr->set_type( maybeMutate( offsetofExpr->get_type(), *this ) );
305        offsetofExpr->set_member( maybeMutate( offsetofExpr->get_member(), *this ) );
306        return offsetofExpr;
307}
308
309Expression *Mutator::mutate( OffsetPackExpr *offsetPackExpr ) {
310        offsetPackExpr->set_env( maybeMutate( offsetPackExpr->get_env(), *this ) );
311        offsetPackExpr->set_result( maybeMutate( offsetPackExpr->get_result(), *this ) );
312        offsetPackExpr->set_type( maybeMutate( offsetPackExpr->get_type(), *this ) );
313        return offsetPackExpr;
314}
315
316Expression *Mutator::mutate( AttrExpr *attrExpr ) {
317        attrExpr->set_env( maybeMutate( attrExpr->get_env(), *this ) );
318        attrExpr->set_result( maybeMutate( attrExpr->get_result(), *this ) );
319        if ( attrExpr->get_isType() ) {
320                attrExpr->set_type( maybeMutate( attrExpr->get_type(), *this ) );
321        } else {
322                attrExpr->set_expr( maybeMutate( attrExpr->get_expr(), *this ) );
323        }
324        return attrExpr;
325}
326
327Expression *Mutator::mutate( LogicalExpr *logicalExpr ) {
328        logicalExpr->set_env( maybeMutate( logicalExpr->get_env(), *this ) );
329        logicalExpr->set_result( maybeMutate( logicalExpr->get_result(), *this ) );
330        logicalExpr->set_arg1( maybeMutate( logicalExpr->get_arg1(), *this ) );
331        logicalExpr->set_arg2( maybeMutate( logicalExpr->get_arg2(), *this ) );
332        return logicalExpr;
333}
334
335Expression *Mutator::mutate( ConditionalExpr *conditionalExpr ) {
336        conditionalExpr->set_env( maybeMutate( conditionalExpr->get_env(), *this ) );
337        conditionalExpr->set_result( maybeMutate( conditionalExpr->get_result(), *this ) );
338        conditionalExpr->set_arg1( maybeMutate( conditionalExpr->get_arg1(), *this ) );
339        conditionalExpr->set_arg2( maybeMutate( conditionalExpr->get_arg2(), *this ) );
340        conditionalExpr->set_arg3( maybeMutate( conditionalExpr->get_arg3(), *this ) );
341        return conditionalExpr;
342}
343
344Expression *Mutator::mutate( CommaExpr *commaExpr ) {
345        commaExpr->set_env( maybeMutate( commaExpr->get_env(), *this ) );
346        commaExpr->set_result( maybeMutate( commaExpr->get_result(), *this ) );
347        commaExpr->set_arg1( maybeMutate( commaExpr->get_arg1(), *this ) );
348        commaExpr->set_arg2( maybeMutate( commaExpr->get_arg2(), *this ) );
349        return commaExpr;
350}
351
352Expression *Mutator::mutate( TypeExpr *typeExpr ) {
353        typeExpr->set_env( maybeMutate( typeExpr->get_env(), *this ) );
354        typeExpr->set_result( maybeMutate( typeExpr->get_result(), *this ) );
355        typeExpr->set_type( maybeMutate( typeExpr->get_type(), *this ) );
356        return typeExpr;
357}
358
359Expression *Mutator::mutate( AsmExpr *asmExpr ) {
360        asmExpr->set_env( maybeMutate( asmExpr->get_env(), *this ) );
361        asmExpr->set_inout( maybeMutate( asmExpr->get_inout(), *this ) );
362        asmExpr->set_constraint( maybeMutate( asmExpr->get_constraint(), *this ) );
363        asmExpr->set_operand( maybeMutate( asmExpr->get_operand(), *this ) );
364        return asmExpr;
365}
366
367Expression* Mutator::mutate( ImplicitCopyCtorExpr *impCpCtorExpr ) {
368        impCpCtorExpr->set_env( maybeMutate( impCpCtorExpr->get_env(), *this ) );
369        impCpCtorExpr->set_result( maybeMutate( impCpCtorExpr->get_result(), *this ) );
370        impCpCtorExpr->set_callExpr( maybeMutate( impCpCtorExpr->get_callExpr(), *this ) );
371        mutateAll( impCpCtorExpr->get_tempDecls(), *this );
372        mutateAll( impCpCtorExpr->get_returnDecls(), *this );
373        mutateAll( impCpCtorExpr->get_dtors(), *this );
374        return impCpCtorExpr;
375}
376
377Expression* Mutator::mutate( ConstructorExpr *ctorExpr ) {
378        ctorExpr->set_env( maybeMutate( ctorExpr->get_env(), *this ) );
379        ctorExpr->set_result( maybeMutate( ctorExpr->get_result(), *this ) );
380        ctorExpr->set_callExpr( maybeMutate( ctorExpr->get_callExpr(), *this ) );
381        return ctorExpr;
382}
383
384Expression *Mutator::mutate( CompoundLiteralExpr *compLitExpr ) {
385        compLitExpr->set_env( maybeMutate( compLitExpr->get_env(), *this ) );
386        compLitExpr->set_result( maybeMutate( compLitExpr->get_result(), *this ) );
387        compLitExpr->set_initializer( maybeMutate( compLitExpr->get_initializer(), *this ) );
388        return compLitExpr;
389}
390
391Expression *Mutator::mutate( RangeExpr *rangeExpr ) {
392        rangeExpr->set_env( maybeMutate( rangeExpr->get_env(), *this ) );
393        rangeExpr->set_low( maybeMutate( rangeExpr->get_low(), *this ) );
394        rangeExpr->set_high( maybeMutate( rangeExpr->get_high(), *this ) );
395        return rangeExpr;
396}
397
398Expression *Mutator::mutate( UntypedTupleExpr *tupleExpr ) {
399        tupleExpr->set_env( maybeMutate( tupleExpr->get_env(), *this ) );
400        tupleExpr->set_result( maybeMutate( tupleExpr->get_result(), *this ) );
401        mutateAll( tupleExpr->get_exprs(), *this );
402        return tupleExpr;
403}
404
405Expression *Mutator::mutate( TupleExpr *tupleExpr ) {
406        tupleExpr->set_env( maybeMutate( tupleExpr->get_env(), *this ) );
407        tupleExpr->set_result( maybeMutate( tupleExpr->get_result(), *this ) );
408        mutateAll( tupleExpr->get_exprs(), *this );
409        return tupleExpr;
410}
411
412Expression *Mutator::mutate( TupleIndexExpr *tupleExpr ) {
413        tupleExpr->set_env( maybeMutate( tupleExpr->get_env(), *this ) );
414        tupleExpr->set_result( maybeMutate( tupleExpr->get_result(), *this ) );
415        tupleExpr->set_tuple( maybeMutate( tupleExpr->get_tuple(), *this ) );
416        return tupleExpr;
417}
418
419Expression *Mutator::mutate( TupleAssignExpr *assignExpr ) {
420        assignExpr->set_env( maybeMutate( assignExpr->get_env(), *this ) );
421        assignExpr->set_result( maybeMutate( assignExpr->get_result(), *this ) );
422        assignExpr->set_stmtExpr( maybeMutate( assignExpr->get_stmtExpr(), *this ) );
423        return assignExpr;
424}
425
426Expression *Mutator::mutate( StmtExpr *stmtExpr ) {
427        stmtExpr->set_env( maybeMutate( stmtExpr->get_env(), *this ) );
428        stmtExpr->set_result( maybeMutate( stmtExpr->get_result(), *this ) );
429        stmtExpr->set_statements( maybeMutate( stmtExpr->get_statements(), *this ) );
430        mutateAll( stmtExpr->get_returnDecls(), *this );
431        mutateAll( stmtExpr->get_dtors(), *this );
432        return stmtExpr;
433}
434
435Expression *Mutator::mutate( UniqueExpr *uniqueExpr ) {
436        uniqueExpr->set_env( maybeMutate( uniqueExpr->get_env(), *this ) );
437        uniqueExpr->set_result( maybeMutate( uniqueExpr->get_result(), *this ) );
438        uniqueExpr->set_expr( maybeMutate( uniqueExpr->get_expr(), *this ) );
439        return uniqueExpr;
440}
441
442Expression *Mutator::mutate( UntypedInitExpr * initExpr ) {
443        initExpr->set_env( maybeMutate( initExpr->get_env(), *this ) );
444        initExpr->set_result( maybeMutate( initExpr->get_result(), *this ) );
445        initExpr->set_expr( maybeMutate( initExpr->get_expr(), *this ) );
446        // not currently mutating initAlts, but this doesn't matter since this node is only used in the resolver.
447        return initExpr;
448}
449
450Expression *Mutator::mutate( InitExpr * initExpr ) {
451        initExpr->set_env( maybeMutate( initExpr->get_env(), *this ) );
452        initExpr->set_result( maybeMutate( initExpr->get_result(), *this ) );
453        initExpr->set_expr( maybeMutate( initExpr->get_expr(), *this ) );
454        initExpr->set_designation( maybeMutate( initExpr->get_designation(), *this ) );
455        return initExpr;
456}
457
458
459Type *Mutator::mutate( VoidType *voidType ) {
460        mutateAll( voidType->get_forall(), *this );
461        return voidType;
462}
463
464Type *Mutator::mutate( BasicType *basicType ) {
465        mutateAll( basicType->get_forall(), *this );
466        return basicType;
467}
468
469Type *Mutator::mutate( PointerType *pointerType ) {
470        mutateAll( pointerType->get_forall(), *this );
471        pointerType->set_base( maybeMutate( pointerType->get_base(), *this ) );
472        return pointerType;
473}
474
475Type *Mutator::mutate( ArrayType *arrayType ) {
476        mutateAll( arrayType->get_forall(), *this );
477        arrayType->set_dimension( maybeMutate( arrayType->get_dimension(), *this ) );
478        arrayType->set_base( maybeMutate( arrayType->get_base(), *this ) );
479        return arrayType;
480}
481
482Type *Mutator::mutate( FunctionType *functionType ) {
483        mutateAll( functionType->get_forall(), *this );
484        mutateAll( functionType->get_returnVals(), *this );
485        mutateAll( functionType->get_parameters(), *this );
486        return functionType;
487}
488
489Type *Mutator::handleReferenceToType( ReferenceToType *aggregateUseType ) {
490        mutateAll( aggregateUseType->get_forall(), *this );
491        mutateAll( aggregateUseType->get_parameters(), *this );
492        return aggregateUseType;
493}
494
495Type *Mutator::mutate( StructInstType *aggregateUseType ) {
496        handleReferenceToType( aggregateUseType );
497        return aggregateUseType;
498}
499
500Type *Mutator::mutate( UnionInstType *aggregateUseType ) {
501        handleReferenceToType( aggregateUseType );
502        return aggregateUseType;
503}
504
505Type *Mutator::mutate( EnumInstType *aggregateUseType ) {
506        handleReferenceToType( aggregateUseType );
507        return aggregateUseType;
508}
509
510Type *Mutator::mutate( TraitInstType *aggregateUseType ) {
511        handleReferenceToType( aggregateUseType );
512        mutateAll( aggregateUseType->get_members(), *this );
513        return aggregateUseType;
514}
515
516Type *Mutator::mutate( TypeInstType *aggregateUseType ) {
517        handleReferenceToType( aggregateUseType );
518        return aggregateUseType;
519}
520
521Type *Mutator::mutate( TupleType *tupleType ) {
522        mutateAll( tupleType->get_forall(), *this );
523        mutateAll( tupleType->get_types(), *this );
524        mutateAll( tupleType->get_members(), *this );
525        return tupleType;
526}
527
528Type *Mutator::mutate( TypeofType *typeofType ) {
529        assert( typeofType->get_expr() );
530        typeofType->set_expr( typeofType->get_expr()->acceptMutator( *this ) );
531        return typeofType;
532}
533
534Type *Mutator::mutate( AttrType *attrType ) {
535        if ( attrType->get_isType() ) {
536                assert( attrType->get_type() );
537                attrType->set_type( attrType->get_type()->acceptMutator( *this ) );
538        } else {
539                assert( attrType->get_expr() );
540                attrType->set_expr( attrType->get_expr()->acceptMutator( *this ) );
541        }
542        return attrType;
543}
544
545Type *Mutator::mutate( VarArgsType *varArgsType ) {
546        mutateAll( varArgsType->get_forall(), *this );
547        return varArgsType;
548}
549
550Type *Mutator::mutate( ZeroType *zeroType ) {
551        mutateAll( zeroType->get_forall(), *this );
552        return zeroType;
553}
554
555Type *Mutator::mutate( OneType *oneType ) {
556        mutateAll( oneType->get_forall(), *this );
557        return oneType;
558}
559
560
561Designation *Mutator::mutate( Designation * designation ) {
562        mutateAll( designation->get_designators(), *this );
563        return designation;
564}
565
566Initializer *Mutator::mutate( SingleInit *singleInit ) {
567        singleInit->set_value( singleInit->get_value()->acceptMutator( *this ) );
568        return singleInit;
569}
570
571Initializer *Mutator::mutate( ListInit *listInit ) {
572        mutateAll( listInit->get_designations(), *this );
573        mutateAll( listInit->get_initializers(), *this );
574        return listInit;
575}
576
577Initializer *Mutator::mutate( ConstructorInit *ctorInit ) {
578        ctorInit->set_ctor( maybeMutate( ctorInit->get_ctor(), *this ) );
579        ctorInit->set_dtor( maybeMutate( ctorInit->get_dtor(), *this ) );
580        ctorInit->set_init( maybeMutate( ctorInit->get_init(), *this ) );
581        return ctorInit;
582}
583
584
585Subrange *Mutator::mutate( Subrange *subrange ) {
586        return subrange;
587}
588
589
590Constant *Mutator::mutate( Constant *constant ) {
591        return constant;
592}
593
594// Local Variables: //
595// tab-width: 4 //
596// mode: c++ //
597// compile-command: "make install" //
598// End: //
Note: See TracBrowser for help on using the repository browser.