source: src/SynTree/Mutator.cc @ af08051

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 af08051 was 6d49ea3, checked in by Peter A. Buhr <pabuhr@…>, 7 years ago

second attempt, add declarations into if conditional

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