source: src/SynTree/Mutator.cc @ 1bc749f

ADTarm-ehast-experimentalcleanup-dtorsenumforall-pointer-decayjacob/cs343-translationjenkins-sandboxnew-astnew-ast-unique-exprpthread-emulationqualifiedEnum
Last change on this file since 1bc749f was 96f9ef5, checked in by Rob Schluntz <rschlunt@…>, 7 years ago

Modify TypeDecl? mutate to return a Declaration

  • Property mode set to 100644
File size: 22.1 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
[51b7345]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;
[51b7345]29
[d9a0e76]30Mutator::Mutator() {}
[51b7345]31
[d9a0e76]32Mutator::~Mutator() {}
[51b7345]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;
[51b7345]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;
[51b7345]45}
46
[135b431]47Declaration * Mutator::handleAggregateDecl( AggregateDecl *aggregateDecl ) {
[0dd3a2f]48        mutateAll( aggregateDecl->get_parameters(), *this );
49        mutateAll( aggregateDecl->get_members(), *this );
50        return aggregateDecl;
[51b7345]51}
52
[135b431]53Declaration * Mutator::mutate( StructDecl *aggregateDecl ) {
[0dd3a2f]54        handleAggregateDecl( aggregateDecl );
55        return aggregateDecl;
[51b7345]56}
57
[135b431]58Declaration * Mutator::mutate( UnionDecl *aggregateDecl ) {
[0dd3a2f]59        handleAggregateDecl( aggregateDecl );
60        return aggregateDecl;
[51b7345]61}
62
[135b431]63Declaration * Mutator::mutate( EnumDecl *aggregateDecl ) {
[0dd3a2f]64        handleAggregateDecl( aggregateDecl );
65        return aggregateDecl;
[51b7345]66}
67
[135b431]68Declaration * Mutator::mutate( TraitDecl *aggregateDecl ) {
[0dd3a2f]69        handleAggregateDecl( aggregateDecl );
70        return aggregateDecl;
[51b7345]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;
[51b7345]78}
79
[96f9ef5]80Declaration * Mutator::mutate( TypeDecl *typeDecl ) {
[0dd3a2f]81        handleNamedTypeDecl( typeDecl );
[67cf18c]82        typeDecl->set_init( maybeMutate( typeDecl->get_init(), *this ) );
[0dd3a2f]83        return typeDecl;
[51b7345]84}
85
[135b431]86Declaration * Mutator::mutate( TypedefDecl *typeDecl ) {
[0dd3a2f]87        handleNamedTypeDecl( typeDecl );
88        return typeDecl;
[51b7345]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;
[51b7345]100}
101
[135b431]102Statement * Mutator::mutate( ExprStmt *exprStmt ) {
[0dd3a2f]103        exprStmt->set_expr( maybeMutate( exprStmt->get_expr(), *this ) );
104        return exprStmt;
[51b7345]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;
[51b7345]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;
[51b7345]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;
[51b7345]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;
[51b7345]141}
142
[135b431]143Statement * Mutator::mutate( CaseStmt *caseStmt ) {
[0dd3a2f]144        caseStmt->set_condition( maybeMutate( caseStmt->get_condition(), *this ) );
145        mutateAll (caseStmt->get_statements(), *this );
[51b7345]146
[0dd3a2f]147        return caseStmt;
[51b7345]148}
149
[135b431]150Statement * Mutator::mutate( BranchStmt *branchStmt ) {
[0dd3a2f]151        return branchStmt;
[51b7345]152}
153
[135b431]154Statement * Mutator::mutate( ReturnStmt *returnStmt ) {
[0dd3a2f]155        returnStmt->set_expr( maybeMutate( returnStmt->get_expr(), *this ) );
156        return returnStmt;
[51b7345]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;
[51b7345]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;
[51b7345]177}
178
[135b431]179Statement * Mutator::mutate( FinallyStmt *finalStmt ) {
[0dd3a2f]180        finalStmt->set_block( maybeMutate( finalStmt->get_block(), *this ) );
181        return finalStmt;
[51b7345]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;
[51b7345]204}
205
[135b431]206Statement * Mutator::mutate( DeclStmt *declStmt ) {
[0dd3a2f]207        declStmt->set_decl( maybeMutate( declStmt->get_decl(), *this ) );
208        return declStmt;
[51b7345]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;
[51b7345]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;
[51b7345]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;
[51b7345]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;
[51b7345]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        return labelAddressExpr;
[51b7345]249}
250
[135b431]251Expression * Mutator::mutate( CastExpr *castExpr ) {
[e33f321]252        castExpr->set_env( maybeMutate( castExpr->get_env(), *this ) );
[906e24d]253        castExpr->set_result( maybeMutate( castExpr->get_result(), *this ) );
[a5f0529]254        castExpr->set_arg( maybeMutate( castExpr->get_arg(), *this ) );
255        return castExpr;
256}
257
[135b431]258Expression * Mutator::mutate( VirtualCastExpr *castExpr ) {
[a5f0529]259        castExpr->set_env( maybeMutate( castExpr->get_env(), *this ) );
260        castExpr->set_result( maybeMutate( castExpr->get_result(), *this ) );
[0dd3a2f]261        castExpr->set_arg( maybeMutate( castExpr->get_arg(), *this ) );
262        return castExpr;
[51b7345]263}
264
[135b431]265Expression * Mutator::mutate( UntypedMemberExpr *memberExpr ) {
[e33f321]266        memberExpr->set_env( maybeMutate( memberExpr->get_env(), *this ) );
[906e24d]267        memberExpr->set_result( maybeMutate( memberExpr->get_result(), *this ) );
[0dd3a2f]268        memberExpr->set_aggregate( maybeMutate( memberExpr->get_aggregate(), *this ) );
[3b58d91]269        memberExpr->set_member( maybeMutate( memberExpr->get_member(), *this ) );
[0dd3a2f]270        return memberExpr;
[51b7345]271}
272
[135b431]273Expression * Mutator::mutate( MemberExpr *memberExpr ) {
[e33f321]274        memberExpr->set_env( maybeMutate( memberExpr->get_env(), *this ) );
[906e24d]275        memberExpr->set_result( maybeMutate( memberExpr->get_result(), *this ) );
[0dd3a2f]276        memberExpr->set_aggregate( maybeMutate( memberExpr->get_aggregate(), *this ) );
277        return memberExpr;
[51b7345]278}
279
[135b431]280Expression * Mutator::mutate( VariableExpr *variableExpr ) {
[e33f321]281        variableExpr->set_env( maybeMutate( variableExpr->get_env(), *this ) );
[906e24d]282        variableExpr->set_result( maybeMutate( variableExpr->get_result(), *this ) );
[0dd3a2f]283        return variableExpr;
[51b7345]284}
285
[135b431]286Expression * Mutator::mutate( ConstantExpr *constantExpr ) {
[e33f321]287        constantExpr->set_env( maybeMutate( constantExpr->get_env(), *this ) );
[906e24d]288        constantExpr->set_result( maybeMutate( constantExpr->get_result(), *this ) );
[51b7345]289//  maybeMutate( constantExpr->get_constant(), *this )
[0dd3a2f]290        return constantExpr;
[51b7345]291}
292
[135b431]293Expression * Mutator::mutate( SizeofExpr *sizeofExpr ) {
[e33f321]294        sizeofExpr->set_env( maybeMutate( sizeofExpr->get_env(), *this ) );
[906e24d]295        sizeofExpr->set_result( maybeMutate( sizeofExpr->get_result(), *this ) );
[0dd3a2f]296        if ( sizeofExpr->get_isType() ) {
297                sizeofExpr->set_type( maybeMutate( sizeofExpr->get_type(), *this ) );
298        } else {
299                sizeofExpr->set_expr( maybeMutate( sizeofExpr->get_expr(), *this ) );
300        }
301        return sizeofExpr;
[51b7345]302}
303
[135b431]304Expression * Mutator::mutate( AlignofExpr *alignofExpr ) {
[e33f321]305        alignofExpr->set_env( maybeMutate( alignofExpr->get_env(), *this ) );
[906e24d]306        alignofExpr->set_result( maybeMutate( alignofExpr->get_result(), *this ) );
[47534159]307        if ( alignofExpr->get_isType() ) {
308                alignofExpr->set_type( maybeMutate( alignofExpr->get_type(), *this ) );
309        } else {
310                alignofExpr->set_expr( maybeMutate( alignofExpr->get_expr(), *this ) );
311        }
312        return alignofExpr;
313}
314
[135b431]315Expression * Mutator::mutate( UntypedOffsetofExpr *offsetofExpr ) {
[e33f321]316        offsetofExpr->set_env( maybeMutate( offsetofExpr->get_env(), *this ) );
[906e24d]317        offsetofExpr->set_result( maybeMutate( offsetofExpr->get_result(), *this ) );
[2a4b088]318        offsetofExpr->set_type( maybeMutate( offsetofExpr->get_type(), *this ) );
319        return offsetofExpr;
320}
321
[135b431]322Expression * Mutator::mutate( OffsetofExpr *offsetofExpr ) {
[e33f321]323        offsetofExpr->set_env( maybeMutate( offsetofExpr->get_env(), *this ) );
[906e24d]324        offsetofExpr->set_result( maybeMutate( offsetofExpr->get_result(), *this ) );
[25a054f]325        offsetofExpr->set_type( maybeMutate( offsetofExpr->get_type(), *this ) );
326        offsetofExpr->set_member( maybeMutate( offsetofExpr->get_member(), *this ) );
327        return offsetofExpr;
328}
329
[135b431]330Expression * Mutator::mutate( OffsetPackExpr *offsetPackExpr ) {
[e33f321]331        offsetPackExpr->set_env( maybeMutate( offsetPackExpr->get_env(), *this ) );
[906e24d]332        offsetPackExpr->set_result( maybeMutate( offsetPackExpr->get_result(), *this ) );
[afc1045]333        offsetPackExpr->set_type( maybeMutate( offsetPackExpr->get_type(), *this ) );
334        return offsetPackExpr;
335}
336
[135b431]337Expression * Mutator::mutate( AttrExpr *attrExpr ) {
[e33f321]338        attrExpr->set_env( maybeMutate( attrExpr->get_env(), *this ) );
[906e24d]339        attrExpr->set_result( maybeMutate( attrExpr->get_result(), *this ) );
[0dd3a2f]340        if ( attrExpr->get_isType() ) {
341                attrExpr->set_type( maybeMutate( attrExpr->get_type(), *this ) );
342        } else {
343                attrExpr->set_expr( maybeMutate( attrExpr->get_expr(), *this ) );
344        }
345        return attrExpr;
[51b7345]346}
347
[135b431]348Expression * Mutator::mutate( LogicalExpr *logicalExpr ) {
[e33f321]349        logicalExpr->set_env( maybeMutate( logicalExpr->get_env(), *this ) );
[906e24d]350        logicalExpr->set_result( maybeMutate( logicalExpr->get_result(), *this ) );
[0dd3a2f]351        logicalExpr->set_arg1( maybeMutate( logicalExpr->get_arg1(), *this ) );
352        logicalExpr->set_arg2( maybeMutate( logicalExpr->get_arg2(), *this ) );
353        return logicalExpr;
[51b7345]354}
355
[135b431]356Expression * Mutator::mutate( ConditionalExpr *conditionalExpr ) {
[e33f321]357        conditionalExpr->set_env( maybeMutate( conditionalExpr->get_env(), *this ) );
[906e24d]358        conditionalExpr->set_result( maybeMutate( conditionalExpr->get_result(), *this ) );
[0dd3a2f]359        conditionalExpr->set_arg1( maybeMutate( conditionalExpr->get_arg1(), *this ) );
360        conditionalExpr->set_arg2( maybeMutate( conditionalExpr->get_arg2(), *this ) );
361        conditionalExpr->set_arg3( maybeMutate( conditionalExpr->get_arg3(), *this ) );
362        return conditionalExpr;
[51b7345]363}
364
[135b431]365Expression * Mutator::mutate( CommaExpr *commaExpr ) {
[e33f321]366        commaExpr->set_env( maybeMutate( commaExpr->get_env(), *this ) );
[906e24d]367        commaExpr->set_result( maybeMutate( commaExpr->get_result(), *this ) );
[0dd3a2f]368        commaExpr->set_arg1( maybeMutate( commaExpr->get_arg1(), *this ) );
369        commaExpr->set_arg2( maybeMutate( commaExpr->get_arg2(), *this ) );
370        return commaExpr;
[51b7345]371}
372
[135b431]373Expression * Mutator::mutate( TypeExpr *typeExpr ) {
[e33f321]374        typeExpr->set_env( maybeMutate( typeExpr->get_env(), *this ) );
[906e24d]375        typeExpr->set_result( maybeMutate( typeExpr->get_result(), *this ) );
[0dd3a2f]376        typeExpr->set_type( maybeMutate( typeExpr->get_type(), *this ) );
377        return typeExpr;
[51b7345]378}
379
[135b431]380Expression * Mutator::mutate( AsmExpr *asmExpr ) {
[e33f321]381        asmExpr->set_env( maybeMutate( asmExpr->get_env(), *this ) );
[7f5566b]382        asmExpr->set_inout( maybeMutate( asmExpr->get_inout(), *this ) );
383        asmExpr->set_constraint( maybeMutate( asmExpr->get_constraint(), *this ) );
384        asmExpr->set_operand( maybeMutate( asmExpr->get_operand(), *this ) );
385        return asmExpr;
386}
387
[db4ecc5]388Expression* Mutator::mutate( ImplicitCopyCtorExpr *impCpCtorExpr ) {
[e33f321]389        impCpCtorExpr->set_env( maybeMutate( impCpCtorExpr->get_env(), *this ) );
[907eccb]390        impCpCtorExpr->set_result( maybeMutate( impCpCtorExpr->get_result(), *this ) );
[db4ecc5]391        impCpCtorExpr->set_callExpr( maybeMutate( impCpCtorExpr->get_callExpr(), *this ) );
392        mutateAll( impCpCtorExpr->get_tempDecls(), *this );
[dc2e7e0]393        mutateAll( impCpCtorExpr->get_returnDecls(), *this );
[d5556a3]394        mutateAll( impCpCtorExpr->get_dtors(), *this );
[db4ecc5]395        return impCpCtorExpr;
396}
397
[b6fe7e6]398Expression* Mutator::mutate( ConstructorExpr *ctorExpr ) {
[e33f321]399        ctorExpr->set_env( maybeMutate( ctorExpr->get_env(), *this ) );
[906e24d]400        ctorExpr->set_result( maybeMutate( ctorExpr->get_result(), *this ) );
[b6fe7e6]401        ctorExpr->set_callExpr( maybeMutate( ctorExpr->get_callExpr(), *this ) );
402        return ctorExpr;
[51b7345]403}
404
[135b431]405Expression * Mutator::mutate( CompoundLiteralExpr *compLitExpr ) {
[e33f321]406        compLitExpr->set_env( maybeMutate( compLitExpr->get_env(), *this ) );
[906e24d]407        compLitExpr->set_result( maybeMutate( compLitExpr->get_result(), *this ) );
[630a82a]408        compLitExpr->set_initializer( maybeMutate( compLitExpr->get_initializer(), *this ) );
409        return compLitExpr;
410}
411
[135b431]412Expression * Mutator::mutate( RangeExpr *rangeExpr ) {
[e33f321]413        rangeExpr->set_env( maybeMutate( rangeExpr->get_env(), *this ) );
[8688ce1]414        rangeExpr->set_low( maybeMutate( rangeExpr->get_low(), *this ) );
415        rangeExpr->set_high( maybeMutate( rangeExpr->get_high(), *this ) );
416        return rangeExpr;
417}
418
[135b431]419Expression * Mutator::mutate( UntypedTupleExpr *tupleExpr ) {
[907eccb]420        tupleExpr->set_env( maybeMutate( tupleExpr->get_env(), *this ) );
421        tupleExpr->set_result( maybeMutate( tupleExpr->get_result(), *this ) );
422        mutateAll( tupleExpr->get_exprs(), *this );
423        return tupleExpr;
424}
425
[135b431]426Expression * Mutator::mutate( TupleExpr *tupleExpr ) {
[e33f321]427        tupleExpr->set_env( maybeMutate( tupleExpr->get_env(), *this ) );
[aa8f9df]428        tupleExpr->set_result( maybeMutate( tupleExpr->get_result(), *this ) );
[6eb8948]429        mutateAll( tupleExpr->get_exprs(), *this );
430        return tupleExpr;
431}
432
[135b431]433Expression * Mutator::mutate( TupleIndexExpr *tupleExpr ) {
[e33f321]434        tupleExpr->set_env( maybeMutate( tupleExpr->get_env(), *this ) );
[aa8f9df]435        tupleExpr->set_result( maybeMutate( tupleExpr->get_result(), *this ) );
[3b58d91]436        tupleExpr->set_tuple( maybeMutate( tupleExpr->get_tuple(), *this ) );
437        return tupleExpr;
438}
439
[135b431]440Expression * Mutator::mutate( TupleAssignExpr *assignExpr ) {
[e33f321]441        assignExpr->set_env( maybeMutate( assignExpr->get_env(), *this ) );
[aa8f9df]442        assignExpr->set_result( maybeMutate( assignExpr->get_result(), *this ) );
[d5556a3]443        assignExpr->set_stmtExpr( maybeMutate( assignExpr->get_stmtExpr(), *this ) );
[3b58d91]444        return assignExpr;
445}
446
[135b431]447Expression * Mutator::mutate( StmtExpr *stmtExpr ) {
[e33f321]448        stmtExpr->set_env( maybeMutate( stmtExpr->get_env(), *this ) );
[aa8f9df]449        stmtExpr->set_result( maybeMutate( stmtExpr->get_result(), *this ) );
[6eb8948]450        stmtExpr->set_statements( maybeMutate( stmtExpr->get_statements(), *this ) );
[d5556a3]451        mutateAll( stmtExpr->get_returnDecls(), *this );
452        mutateAll( stmtExpr->get_dtors(), *this );
[6eb8948]453        return stmtExpr;
[3b58d91]454}
455
[135b431]456Expression * Mutator::mutate( UniqueExpr *uniqueExpr ) {
[e33f321]457        uniqueExpr->set_env( maybeMutate( uniqueExpr->get_env(), *this ) );
[3c13c03]458        uniqueExpr->set_result( maybeMutate( uniqueExpr->get_result(), *this ) );
459        uniqueExpr->set_expr( maybeMutate( uniqueExpr->get_expr(), *this ) );
460        return uniqueExpr;
461}
462
[135b431]463Expression * Mutator::mutate( UntypedInitExpr * initExpr ) {
[e4d829b]464        initExpr->set_env( maybeMutate( initExpr->get_env(), *this ) );
465        initExpr->set_result( maybeMutate( initExpr->get_result(), *this ) );
466        initExpr->set_expr( maybeMutate( initExpr->get_expr(), *this ) );
467        // not currently mutating initAlts, but this doesn't matter since this node is only used in the resolver.
468        return initExpr;
469}
470
[135b431]471Expression * Mutator::mutate( InitExpr * initExpr ) {
[e4d829b]472        initExpr->set_env( maybeMutate( initExpr->get_env(), *this ) );
473        initExpr->set_result( maybeMutate( initExpr->get_result(), *this ) );
474        initExpr->set_expr( maybeMutate( initExpr->get_expr(), *this ) );
475        initExpr->set_designation( maybeMutate( initExpr->get_designation(), *this ) );
476        return initExpr;
477}
478
[e994912]479
[135b431]480Type * Mutator::mutate( VoidType *voidType ) {
[0dd3a2f]481        mutateAll( voidType->get_forall(), *this );
482        return voidType;
[51b7345]483}
484
[135b431]485Type * Mutator::mutate( BasicType *basicType ) {
[0dd3a2f]486        mutateAll( basicType->get_forall(), *this );
487        return basicType;
[51b7345]488}
489
[135b431]490Type * Mutator::mutate( PointerType *pointerType ) {
[0dd3a2f]491        mutateAll( pointerType->get_forall(), *this );
492        pointerType->set_base( maybeMutate( pointerType->get_base(), *this ) );
493        return pointerType;
[51b7345]494}
495
[135b431]496Type * Mutator::mutate( ArrayType *arrayType ) {
[0dd3a2f]497        mutateAll( arrayType->get_forall(), *this );
498        arrayType->set_dimension( maybeMutate( arrayType->get_dimension(), *this ) );
499        arrayType->set_base( maybeMutate( arrayType->get_base(), *this ) );
500        return arrayType;
[51b7345]501}
502
[6b224a52]503Type * Mutator::mutate( ReferenceType * refType ) {
[ce8c12f]504        mutateAll( refType->get_forall(), *this );
505        refType->set_base( maybeMutate( refType->get_base(), *this ) );
506        return refType;
507}
508
[6b224a52]509Type * Mutator::mutate( FunctionType * functionType ) {
[0dd3a2f]510        mutateAll( functionType->get_forall(), *this );
511        mutateAll( functionType->get_returnVals(), *this );
512        mutateAll( functionType->get_parameters(), *this );
513        return functionType;
[51b7345]514}
515
[135b431]516Type * Mutator::handleReferenceToType( ReferenceToType *aggregateUseType ) {
[0dd3a2f]517        mutateAll( aggregateUseType->get_forall(), *this );
518        mutateAll( aggregateUseType->get_parameters(), *this );
519        return aggregateUseType;
[51b7345]520}
521
[135b431]522Type * Mutator::mutate( StructInstType *aggregateUseType ) {
[0dd3a2f]523        handleReferenceToType( aggregateUseType );
524        return aggregateUseType;
[51b7345]525}
526
[135b431]527Type * Mutator::mutate( UnionInstType *aggregateUseType ) {
[0dd3a2f]528        handleReferenceToType( aggregateUseType );
529        return aggregateUseType;
[51b7345]530}
531
[135b431]532Type * Mutator::mutate( EnumInstType *aggregateUseType ) {
[0dd3a2f]533        handleReferenceToType( aggregateUseType );
534        return aggregateUseType;
[51b7345]535}
536
[135b431]537Type * Mutator::mutate( TraitInstType *aggregateUseType ) {
[0dd3a2f]538        handleReferenceToType( aggregateUseType );
539        return aggregateUseType;
[51b7345]540}
541
[135b431]542Type * Mutator::mutate( TypeInstType *aggregateUseType ) {
[0dd3a2f]543        handleReferenceToType( aggregateUseType );
544        return aggregateUseType;
[51b7345]545}
546
[135b431]547Type * Mutator::mutate( TupleType *tupleType ) {
[0dd3a2f]548        mutateAll( tupleType->get_forall(), *this );
549        mutateAll( tupleType->get_types(), *this );
[62423350]550        mutateAll( tupleType->get_members(), *this );
[0dd3a2f]551        return tupleType;
[51b7345]552}
553
[135b431]554Type * Mutator::mutate( TypeofType *typeofType ) {
[0dd3a2f]555        assert( typeofType->get_expr() );
556        typeofType->set_expr( typeofType->get_expr()->acceptMutator( *this ) );
557        return typeofType;
[51b7345]558}
559
[135b431]560Type * Mutator::mutate( AttrType *attrType ) {
[0dd3a2f]561        if ( attrType->get_isType() ) {
562                assert( attrType->get_type() );
563                attrType->set_type( attrType->get_type()->acceptMutator( *this ) );
564        } else {
565                assert( attrType->get_expr() );
566                attrType->set_expr( attrType->get_expr()->acceptMutator( *this ) );
567        }
568        return attrType;
[51b7345]569}
570
[135b431]571Type * Mutator::mutate( VarArgsType *varArgsType ) {
[44b7088]572        mutateAll( varArgsType->get_forall(), *this );
573        return varArgsType;
574}
575
[135b431]576Type * Mutator::mutate( ZeroType *zeroType ) {
[89e6ffc]577        mutateAll( zeroType->get_forall(), *this );
578        return zeroType;
579}
580
[135b431]581Type * Mutator::mutate( OneType *oneType ) {
[89e6ffc]582        mutateAll( oneType->get_forall(), *this );
583        return oneType;
584}
585
[e994912]586
[135b431]587Designation * Mutator::mutate( Designation * designation ) {
[e4d829b]588        mutateAll( designation->get_designators(), *this );
589        return designation;
590}
591
[135b431]592Initializer * Mutator::mutate( SingleInit *singleInit ) {
[0dd3a2f]593        singleInit->set_value( singleInit->get_value()->acceptMutator( *this ) );
594        return singleInit;
[51b7345]595}
596
[135b431]597Initializer * Mutator::mutate( ListInit *listInit ) {
[e4d829b]598        mutateAll( listInit->get_designations(), *this );
[0dd3a2f]599        mutateAll( listInit->get_initializers(), *this );
600        return listInit;
[51b7345]601}
602
[135b431]603Initializer * Mutator::mutate( ConstructorInit *ctorInit ) {
[71f4e4f]604        ctorInit->set_ctor( maybeMutate( ctorInit->get_ctor(), *this ) );
[d5556a3]605        ctorInit->set_dtor( maybeMutate( ctorInit->get_dtor(), *this ) );
[71f4e4f]606        ctorInit->set_init( maybeMutate( ctorInit->get_init(), *this ) );
607        return ctorInit;
608}
609
[e994912]610
[135b431]611Subrange * Mutator::mutate( Subrange *subrange ) {
[0dd3a2f]612        return subrange;
[51b7345]613}
614
[e994912]615
[135b431]616Constant * Mutator::mutate( Constant *constant ) {
[0dd3a2f]617        return constant;
[51b7345]618}
[0dd3a2f]619
620// Local Variables: //
621// tab-width: 4 //
622// mode: c++ //
623// compile-command: "make install" //
624// End: //
Note: See TracBrowser for help on using the repository browser.