source: src/SynTree/Mutator.cc @ 67cf18c

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 67cf18c was 67cf18c, checked in by Rob Schluntz <rschlunt@…>, 7 years ago

implement default type arguments for generic types [closes #13]

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