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