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