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