source: src/SynTree/Mutator.cc @ ea6332d

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 ea6332d was ea6332d, checked in by Thierry Delisle <tdelisle@…>, 7 years ago

Big header cleaning pass - commit 3

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