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