source: src/SynTree/Mutator.cc@ 800d275

ADT aaron-thesis arm-eh ast-experimental cleanup-dtors deferred_resn demangler enum forall-pointer-decay jacob/cs343-translation jenkins-sandbox new-ast new-ast-unique-expr new-env no_list persistent-indexer pthread-emulation qualifiedEnum resolv-new with_gc
Last change on this file since 800d275 was 6b224a52, checked in by Thierry Delisle <tdelisle@…>, 8 years ago

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

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