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