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