| 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 | TypeDecl *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 | NullStmt *Mutator::mutate( NullStmt *nullStmt ) {
 | 
|---|
| 185 |         return nullStmt;
 | 
|---|
| 186 | }
 | 
|---|
| 187 | 
 | 
|---|
| 188 | Statement *Mutator::mutate( DeclStmt *declStmt ) {
 | 
|---|
| 189 |         declStmt->set_decl( maybeMutate( declStmt->get_decl(), *this ) );
 | 
|---|
| 190 |         return declStmt;
 | 
|---|
| 191 | }
 | 
|---|
| 192 | 
 | 
|---|
| 193 | Statement *Mutator::mutate( ImplicitCtorDtorStmt *impCtorDtorStmt ) {
 | 
|---|
| 194 |         impCtorDtorStmt->set_callStmt( maybeMutate( impCtorDtorStmt->get_callStmt(), *this ) );
 | 
|---|
| 195 |         return impCtorDtorStmt;
 | 
|---|
| 196 | }
 | 
|---|
| 197 | 
 | 
|---|
| 198 | 
 | 
|---|
| 199 | Expression *Mutator::mutate( ApplicationExpr *applicationExpr ) {
 | 
|---|
| 200 |         applicationExpr->set_env( maybeMutate( applicationExpr->get_env(), *this ) );
 | 
|---|
| 201 |         applicationExpr->set_result( maybeMutate( applicationExpr->get_result(), *this ) );
 | 
|---|
| 202 |         applicationExpr->set_function( maybeMutate( applicationExpr->get_function(), *this ) );
 | 
|---|
| 203 |         mutateAll( applicationExpr->get_args(), *this );
 | 
|---|
| 204 |         return applicationExpr;
 | 
|---|
| 205 | }
 | 
|---|
| 206 | 
 | 
|---|
| 207 | Expression *Mutator::mutate( UntypedExpr *untypedExpr ) {
 | 
|---|
| 208 |         untypedExpr->set_env( maybeMutate( untypedExpr->get_env(), *this ) );
 | 
|---|
| 209 |         untypedExpr->set_result( maybeMutate( untypedExpr->get_result(), *this ) );
 | 
|---|
| 210 |         mutateAll( untypedExpr->get_args(), *this );
 | 
|---|
| 211 |         return untypedExpr;
 | 
|---|
| 212 | }
 | 
|---|
| 213 | 
 | 
|---|
| 214 | Expression *Mutator::mutate( NameExpr *nameExpr ) {
 | 
|---|
| 215 |         nameExpr->set_env( maybeMutate( nameExpr->get_env(), *this ) );
 | 
|---|
| 216 |         nameExpr->set_result( maybeMutate( nameExpr->get_result(), *this ) );
 | 
|---|
| 217 |         return nameExpr;
 | 
|---|
| 218 | }
 | 
|---|
| 219 | 
 | 
|---|
| 220 | Expression *Mutator::mutate( AddressExpr *addressExpr ) {
 | 
|---|
| 221 |         addressExpr->set_env( maybeMutate( addressExpr->get_env(), *this ) );
 | 
|---|
| 222 |         addressExpr->set_result( maybeMutate( addressExpr->get_result(), *this ) );
 | 
|---|
| 223 |         addressExpr->set_arg( maybeMutate( addressExpr->get_arg(), *this ) );
 | 
|---|
| 224 |         return addressExpr;
 | 
|---|
| 225 | }
 | 
|---|
| 226 | 
 | 
|---|
| 227 | Expression *Mutator::mutate( LabelAddressExpr *labelAddressExpr ) {
 | 
|---|
| 228 |         labelAddressExpr->set_env( maybeMutate( labelAddressExpr->get_env(), *this ) );
 | 
|---|
| 229 |         labelAddressExpr->set_result( maybeMutate( labelAddressExpr->get_result(), *this ) );
 | 
|---|
| 230 |         labelAddressExpr->set_arg( maybeMutate( labelAddressExpr->get_arg(), *this ) );
 | 
|---|
| 231 |         return labelAddressExpr;
 | 
|---|
| 232 | }
 | 
|---|
| 233 | 
 | 
|---|
| 234 | Expression *Mutator::mutate( CastExpr *castExpr ) {
 | 
|---|
| 235 |         castExpr->set_env( maybeMutate( castExpr->get_env(), *this ) );
 | 
|---|
| 236 |         castExpr->set_result( maybeMutate( castExpr->get_result(), *this ) );
 | 
|---|
| 237 |         castExpr->set_arg( maybeMutate( castExpr->get_arg(), *this ) );
 | 
|---|
| 238 |         return castExpr;
 | 
|---|
| 239 | }
 | 
|---|
| 240 | 
 | 
|---|
| 241 | Expression *Mutator::mutate( VirtualCastExpr *castExpr ) {
 | 
|---|
| 242 |         castExpr->set_env( maybeMutate( castExpr->get_env(), *this ) );
 | 
|---|
| 243 |         castExpr->set_result( maybeMutate( castExpr->get_result(), *this ) );
 | 
|---|
| 244 |         castExpr->set_arg( maybeMutate( castExpr->get_arg(), *this ) );
 | 
|---|
| 245 |         return castExpr;
 | 
|---|
| 246 | }
 | 
|---|
| 247 | 
 | 
|---|
| 248 | Expression *Mutator::mutate( UntypedMemberExpr *memberExpr ) {
 | 
|---|
| 249 |         memberExpr->set_env( maybeMutate( memberExpr->get_env(), *this ) );
 | 
|---|
| 250 |         memberExpr->set_result( maybeMutate( memberExpr->get_result(), *this ) );
 | 
|---|
| 251 |         memberExpr->set_aggregate( maybeMutate( memberExpr->get_aggregate(), *this ) );
 | 
|---|
| 252 |         memberExpr->set_member( maybeMutate( memberExpr->get_member(), *this ) );
 | 
|---|
| 253 |         return memberExpr;
 | 
|---|
| 254 | }
 | 
|---|
| 255 | 
 | 
|---|
| 256 | Expression *Mutator::mutate( MemberExpr *memberExpr ) {
 | 
|---|
| 257 |         memberExpr->set_env( maybeMutate( memberExpr->get_env(), *this ) );
 | 
|---|
| 258 |         memberExpr->set_result( maybeMutate( memberExpr->get_result(), *this ) );
 | 
|---|
| 259 |         memberExpr->set_aggregate( maybeMutate( memberExpr->get_aggregate(), *this ) );
 | 
|---|
| 260 |         return memberExpr;
 | 
|---|
| 261 | }
 | 
|---|
| 262 | 
 | 
|---|
| 263 | Expression *Mutator::mutate( VariableExpr *variableExpr ) {
 | 
|---|
| 264 |         variableExpr->set_env( maybeMutate( variableExpr->get_env(), *this ) );
 | 
|---|
| 265 |         variableExpr->set_result( maybeMutate( variableExpr->get_result(), *this ) );
 | 
|---|
| 266 |         return variableExpr;
 | 
|---|
| 267 | }
 | 
|---|
| 268 | 
 | 
|---|
| 269 | Expression *Mutator::mutate( ConstantExpr *constantExpr ) {
 | 
|---|
| 270 |         constantExpr->set_env( maybeMutate( constantExpr->get_env(), *this ) );
 | 
|---|
| 271 |         constantExpr->set_result( maybeMutate( constantExpr->get_result(), *this ) );
 | 
|---|
| 272 | //  maybeMutate( constantExpr->get_constant(), *this )
 | 
|---|
| 273 |         return constantExpr;
 | 
|---|
| 274 | }
 | 
|---|
| 275 | 
 | 
|---|
| 276 | Expression *Mutator::mutate( SizeofExpr *sizeofExpr ) {
 | 
|---|
| 277 |         sizeofExpr->set_env( maybeMutate( sizeofExpr->get_env(), *this ) );
 | 
|---|
| 278 |         sizeofExpr->set_result( maybeMutate( sizeofExpr->get_result(), *this ) );
 | 
|---|
| 279 |         if ( sizeofExpr->get_isType() ) {
 | 
|---|
| 280 |                 sizeofExpr->set_type( maybeMutate( sizeofExpr->get_type(), *this ) );
 | 
|---|
| 281 |         } else {
 | 
|---|
| 282 |                 sizeofExpr->set_expr( maybeMutate( sizeofExpr->get_expr(), *this ) );
 | 
|---|
| 283 |         }
 | 
|---|
| 284 |         return sizeofExpr;
 | 
|---|
| 285 | }
 | 
|---|
| 286 | 
 | 
|---|
| 287 | Expression *Mutator::mutate( AlignofExpr *alignofExpr ) {
 | 
|---|
| 288 |         alignofExpr->set_env( maybeMutate( alignofExpr->get_env(), *this ) );
 | 
|---|
| 289 |         alignofExpr->set_result( maybeMutate( alignofExpr->get_result(), *this ) );
 | 
|---|
| 290 |         if ( alignofExpr->get_isType() ) {
 | 
|---|
| 291 |                 alignofExpr->set_type( maybeMutate( alignofExpr->get_type(), *this ) );
 | 
|---|
| 292 |         } else {
 | 
|---|
| 293 |                 alignofExpr->set_expr( maybeMutate( alignofExpr->get_expr(), *this ) );
 | 
|---|
| 294 |         }
 | 
|---|
| 295 |         return alignofExpr;
 | 
|---|
| 296 | }
 | 
|---|
| 297 | 
 | 
|---|
| 298 | Expression *Mutator::mutate( UntypedOffsetofExpr *offsetofExpr ) {
 | 
|---|
| 299 |         offsetofExpr->set_env( maybeMutate( offsetofExpr->get_env(), *this ) );
 | 
|---|
| 300 |         offsetofExpr->set_result( maybeMutate( offsetofExpr->get_result(), *this ) );
 | 
|---|
| 301 |         offsetofExpr->set_type( maybeMutate( offsetofExpr->get_type(), *this ) );
 | 
|---|
| 302 |         return offsetofExpr;
 | 
|---|
| 303 | }
 | 
|---|
| 304 | 
 | 
|---|
| 305 | Expression *Mutator::mutate( OffsetofExpr *offsetofExpr ) {
 | 
|---|
| 306 |         offsetofExpr->set_env( maybeMutate( offsetofExpr->get_env(), *this ) );
 | 
|---|
| 307 |         offsetofExpr->set_result( maybeMutate( offsetofExpr->get_result(), *this ) );
 | 
|---|
| 308 |         offsetofExpr->set_type( maybeMutate( offsetofExpr->get_type(), *this ) );
 | 
|---|
| 309 |         offsetofExpr->set_member( maybeMutate( offsetofExpr->get_member(), *this ) );
 | 
|---|
| 310 |         return offsetofExpr;
 | 
|---|
| 311 | }
 | 
|---|
| 312 | 
 | 
|---|
| 313 | Expression *Mutator::mutate( OffsetPackExpr *offsetPackExpr ) {
 | 
|---|
| 314 |         offsetPackExpr->set_env( maybeMutate( offsetPackExpr->get_env(), *this ) );
 | 
|---|
| 315 |         offsetPackExpr->set_result( maybeMutate( offsetPackExpr->get_result(), *this ) );
 | 
|---|
| 316 |         offsetPackExpr->set_type( maybeMutate( offsetPackExpr->get_type(), *this ) );
 | 
|---|
| 317 |         return offsetPackExpr;
 | 
|---|
| 318 | }
 | 
|---|
| 319 | 
 | 
|---|
| 320 | Expression *Mutator::mutate( AttrExpr *attrExpr ) {
 | 
|---|
| 321 |         attrExpr->set_env( maybeMutate( attrExpr->get_env(), *this ) );
 | 
|---|
| 322 |         attrExpr->set_result( maybeMutate( attrExpr->get_result(), *this ) );
 | 
|---|
| 323 |         if ( attrExpr->get_isType() ) {
 | 
|---|
| 324 |                 attrExpr->set_type( maybeMutate( attrExpr->get_type(), *this ) );
 | 
|---|
| 325 |         } else {
 | 
|---|
| 326 |                 attrExpr->set_expr( maybeMutate( attrExpr->get_expr(), *this ) );
 | 
|---|
| 327 |         }
 | 
|---|
| 328 |         return attrExpr;
 | 
|---|
| 329 | }
 | 
|---|
| 330 | 
 | 
|---|
| 331 | Expression *Mutator::mutate( LogicalExpr *logicalExpr ) {
 | 
|---|
| 332 |         logicalExpr->set_env( maybeMutate( logicalExpr->get_env(), *this ) );
 | 
|---|
| 333 |         logicalExpr->set_result( maybeMutate( logicalExpr->get_result(), *this ) );
 | 
|---|
| 334 |         logicalExpr->set_arg1( maybeMutate( logicalExpr->get_arg1(), *this ) );
 | 
|---|
| 335 |         logicalExpr->set_arg2( maybeMutate( logicalExpr->get_arg2(), *this ) );
 | 
|---|
| 336 |         return logicalExpr;
 | 
|---|
| 337 | }
 | 
|---|
| 338 | 
 | 
|---|
| 339 | Expression *Mutator::mutate( ConditionalExpr *conditionalExpr ) {
 | 
|---|
| 340 |         conditionalExpr->set_env( maybeMutate( conditionalExpr->get_env(), *this ) );
 | 
|---|
| 341 |         conditionalExpr->set_result( maybeMutate( conditionalExpr->get_result(), *this ) );
 | 
|---|
| 342 |         conditionalExpr->set_arg1( maybeMutate( conditionalExpr->get_arg1(), *this ) );
 | 
|---|
| 343 |         conditionalExpr->set_arg2( maybeMutate( conditionalExpr->get_arg2(), *this ) );
 | 
|---|
| 344 |         conditionalExpr->set_arg3( maybeMutate( conditionalExpr->get_arg3(), *this ) );
 | 
|---|
| 345 |         return conditionalExpr;
 | 
|---|
| 346 | }
 | 
|---|
| 347 | 
 | 
|---|
| 348 | Expression *Mutator::mutate( CommaExpr *commaExpr ) {
 | 
|---|
| 349 |         commaExpr->set_env( maybeMutate( commaExpr->get_env(), *this ) );
 | 
|---|
| 350 |         commaExpr->set_result( maybeMutate( commaExpr->get_result(), *this ) );
 | 
|---|
| 351 |         commaExpr->set_arg1( maybeMutate( commaExpr->get_arg1(), *this ) );
 | 
|---|
| 352 |         commaExpr->set_arg2( maybeMutate( commaExpr->get_arg2(), *this ) );
 | 
|---|
| 353 |         return commaExpr;
 | 
|---|
| 354 | }
 | 
|---|
| 355 | 
 | 
|---|
| 356 | Expression *Mutator::mutate( TypeExpr *typeExpr ) {
 | 
|---|
| 357 |         typeExpr->set_env( maybeMutate( typeExpr->get_env(), *this ) );
 | 
|---|
| 358 |         typeExpr->set_result( maybeMutate( typeExpr->get_result(), *this ) );
 | 
|---|
| 359 |         typeExpr->set_type( maybeMutate( typeExpr->get_type(), *this ) );
 | 
|---|
| 360 |         return typeExpr;
 | 
|---|
| 361 | }
 | 
|---|
| 362 | 
 | 
|---|
| 363 | Expression *Mutator::mutate( AsmExpr *asmExpr ) {
 | 
|---|
| 364 |         asmExpr->set_env( maybeMutate( asmExpr->get_env(), *this ) );
 | 
|---|
| 365 |         asmExpr->set_inout( maybeMutate( asmExpr->get_inout(), *this ) );
 | 
|---|
| 366 |         asmExpr->set_constraint( maybeMutate( asmExpr->get_constraint(), *this ) );
 | 
|---|
| 367 |         asmExpr->set_operand( maybeMutate( asmExpr->get_operand(), *this ) );
 | 
|---|
| 368 |         return asmExpr;
 | 
|---|
| 369 | }
 | 
|---|
| 370 | 
 | 
|---|
| 371 | Expression* Mutator::mutate( ImplicitCopyCtorExpr *impCpCtorExpr ) {
 | 
|---|
| 372 |         impCpCtorExpr->set_env( maybeMutate( impCpCtorExpr->get_env(), *this ) );
 | 
|---|
| 373 |         impCpCtorExpr->set_result( maybeMutate( impCpCtorExpr->get_result(), *this ) );
 | 
|---|
| 374 |         impCpCtorExpr->set_callExpr( maybeMutate( impCpCtorExpr->get_callExpr(), *this ) );
 | 
|---|
| 375 |         mutateAll( impCpCtorExpr->get_tempDecls(), *this );
 | 
|---|
| 376 |         mutateAll( impCpCtorExpr->get_returnDecls(), *this );
 | 
|---|
| 377 |         mutateAll( impCpCtorExpr->get_dtors(), *this );
 | 
|---|
| 378 |         return impCpCtorExpr;
 | 
|---|
| 379 | }
 | 
|---|
| 380 | 
 | 
|---|
| 381 | Expression* Mutator::mutate( ConstructorExpr *ctorExpr ) {
 | 
|---|
| 382 |         ctorExpr->set_env( maybeMutate( ctorExpr->get_env(), *this ) );
 | 
|---|
| 383 |         ctorExpr->set_result( maybeMutate( ctorExpr->get_result(), *this ) );
 | 
|---|
| 384 |         ctorExpr->set_callExpr( maybeMutate( ctorExpr->get_callExpr(), *this ) );
 | 
|---|
| 385 |         return ctorExpr;
 | 
|---|
| 386 | }
 | 
|---|
| 387 | 
 | 
|---|
| 388 | Expression *Mutator::mutate( CompoundLiteralExpr *compLitExpr ) {
 | 
|---|
| 389 |         compLitExpr->set_env( maybeMutate( compLitExpr->get_env(), *this ) );
 | 
|---|
| 390 |         compLitExpr->set_result( maybeMutate( compLitExpr->get_result(), *this ) );
 | 
|---|
| 391 |         compLitExpr->set_initializer( maybeMutate( compLitExpr->get_initializer(), *this ) );
 | 
|---|
| 392 |         return compLitExpr;
 | 
|---|
| 393 | }
 | 
|---|
| 394 | 
 | 
|---|
| 395 | Expression *Mutator::mutate( RangeExpr *rangeExpr ) {
 | 
|---|
| 396 |         rangeExpr->set_env( maybeMutate( rangeExpr->get_env(), *this ) );
 | 
|---|
| 397 |         rangeExpr->set_low( maybeMutate( rangeExpr->get_low(), *this ) );
 | 
|---|
| 398 |         rangeExpr->set_high( maybeMutate( rangeExpr->get_high(), *this ) );
 | 
|---|
| 399 |         return rangeExpr;
 | 
|---|
| 400 | }
 | 
|---|
| 401 | 
 | 
|---|
| 402 | Expression *Mutator::mutate( UntypedTupleExpr *tupleExpr ) {
 | 
|---|
| 403 |         tupleExpr->set_env( maybeMutate( tupleExpr->get_env(), *this ) );
 | 
|---|
| 404 |         tupleExpr->set_result( maybeMutate( tupleExpr->get_result(), *this ) );
 | 
|---|
| 405 |         mutateAll( tupleExpr->get_exprs(), *this );
 | 
|---|
| 406 |         return tupleExpr;
 | 
|---|
| 407 | }
 | 
|---|
| 408 | 
 | 
|---|
| 409 | Expression *Mutator::mutate( TupleExpr *tupleExpr ) {
 | 
|---|
| 410 |         tupleExpr->set_env( maybeMutate( tupleExpr->get_env(), *this ) );
 | 
|---|
| 411 |         tupleExpr->set_result( maybeMutate( tupleExpr->get_result(), *this ) );
 | 
|---|
| 412 |         mutateAll( tupleExpr->get_exprs(), *this );
 | 
|---|
| 413 |         return tupleExpr;
 | 
|---|
| 414 | }
 | 
|---|
| 415 | 
 | 
|---|
| 416 | Expression *Mutator::mutate( TupleIndexExpr *tupleExpr ) {
 | 
|---|
| 417 |         tupleExpr->set_env( maybeMutate( tupleExpr->get_env(), *this ) );
 | 
|---|
| 418 |         tupleExpr->set_result( maybeMutate( tupleExpr->get_result(), *this ) );
 | 
|---|
| 419 |         tupleExpr->set_tuple( maybeMutate( tupleExpr->get_tuple(), *this ) );
 | 
|---|
| 420 |         return tupleExpr;
 | 
|---|
| 421 | }
 | 
|---|
| 422 | 
 | 
|---|
| 423 | Expression *Mutator::mutate( TupleAssignExpr *assignExpr ) {
 | 
|---|
| 424 |         assignExpr->set_env( maybeMutate( assignExpr->get_env(), *this ) );
 | 
|---|
| 425 |         assignExpr->set_result( maybeMutate( assignExpr->get_result(), *this ) );
 | 
|---|
| 426 |         assignExpr->set_stmtExpr( maybeMutate( assignExpr->get_stmtExpr(), *this ) );
 | 
|---|
| 427 |         return assignExpr;
 | 
|---|
| 428 | }
 | 
|---|
| 429 | 
 | 
|---|
| 430 | Expression *Mutator::mutate( StmtExpr *stmtExpr ) {
 | 
|---|
| 431 |         stmtExpr->set_env( maybeMutate( stmtExpr->get_env(), *this ) );
 | 
|---|
| 432 |         stmtExpr->set_result( maybeMutate( stmtExpr->get_result(), *this ) );
 | 
|---|
| 433 |         stmtExpr->set_statements( maybeMutate( stmtExpr->get_statements(), *this ) );
 | 
|---|
| 434 |         mutateAll( stmtExpr->get_returnDecls(), *this );
 | 
|---|
| 435 |         mutateAll( stmtExpr->get_dtors(), *this );
 | 
|---|
| 436 |         return stmtExpr;
 | 
|---|
| 437 | }
 | 
|---|
| 438 | 
 | 
|---|
| 439 | Expression *Mutator::mutate( UniqueExpr *uniqueExpr ) {
 | 
|---|
| 440 |         uniqueExpr->set_env( maybeMutate( uniqueExpr->get_env(), *this ) );
 | 
|---|
| 441 |         uniqueExpr->set_result( maybeMutate( uniqueExpr->get_result(), *this ) );
 | 
|---|
| 442 |         uniqueExpr->set_expr( maybeMutate( uniqueExpr->get_expr(), *this ) );
 | 
|---|
| 443 |         return uniqueExpr;
 | 
|---|
| 444 | }
 | 
|---|
| 445 | 
 | 
|---|
| 446 | Expression *Mutator::mutate( UntypedInitExpr * initExpr ) {
 | 
|---|
| 447 |         initExpr->set_env( maybeMutate( initExpr->get_env(), *this ) );
 | 
|---|
| 448 |         initExpr->set_result( maybeMutate( initExpr->get_result(), *this ) );
 | 
|---|
| 449 |         initExpr->set_expr( maybeMutate( initExpr->get_expr(), *this ) );
 | 
|---|
| 450 |         // not currently mutating initAlts, but this doesn't matter since this node is only used in the resolver.
 | 
|---|
| 451 |         return initExpr;
 | 
|---|
| 452 | }
 | 
|---|
| 453 | 
 | 
|---|
| 454 | Expression *Mutator::mutate( InitExpr * initExpr ) {
 | 
|---|
| 455 |         initExpr->set_env( maybeMutate( initExpr->get_env(), *this ) );
 | 
|---|
| 456 |         initExpr->set_result( maybeMutate( initExpr->get_result(), *this ) );
 | 
|---|
| 457 |         initExpr->set_expr( maybeMutate( initExpr->get_expr(), *this ) );
 | 
|---|
| 458 |         initExpr->set_designation( maybeMutate( initExpr->get_designation(), *this ) );
 | 
|---|
| 459 |         return initExpr;
 | 
|---|
| 460 | }
 | 
|---|
| 461 | 
 | 
|---|
| 462 | 
 | 
|---|
| 463 | Type *Mutator::mutate( VoidType *voidType ) {
 | 
|---|
| 464 |         mutateAll( voidType->get_forall(), *this );
 | 
|---|
| 465 |         return voidType;
 | 
|---|
| 466 | }
 | 
|---|
| 467 | 
 | 
|---|
| 468 | Type *Mutator::mutate( BasicType *basicType ) {
 | 
|---|
| 469 |         mutateAll( basicType->get_forall(), *this );
 | 
|---|
| 470 |         return basicType;
 | 
|---|
| 471 | }
 | 
|---|
| 472 | 
 | 
|---|
| 473 | Type *Mutator::mutate( PointerType *pointerType ) {
 | 
|---|
| 474 |         mutateAll( pointerType->get_forall(), *this );
 | 
|---|
| 475 |         pointerType->set_base( maybeMutate( pointerType->get_base(), *this ) );
 | 
|---|
| 476 |         return pointerType;
 | 
|---|
| 477 | }
 | 
|---|
| 478 | 
 | 
|---|
| 479 | Type *Mutator::mutate( ArrayType *arrayType ) {
 | 
|---|
| 480 |         mutateAll( arrayType->get_forall(), *this );
 | 
|---|
| 481 |         arrayType->set_dimension( maybeMutate( arrayType->get_dimension(), *this ) );
 | 
|---|
| 482 |         arrayType->set_base( maybeMutate( arrayType->get_base(), *this ) );
 | 
|---|
| 483 |         return arrayType;
 | 
|---|
| 484 | }
 | 
|---|
| 485 | 
 | 
|---|
| 486 | Type *Mutator::mutate( ReferenceType *refType ) {
 | 
|---|
| 487 |         mutateAll( refType->get_forall(), *this );
 | 
|---|
| 488 |         refType->set_base( maybeMutate( refType->get_base(), *this ) );
 | 
|---|
| 489 |         return refType;
 | 
|---|
| 490 | }
 | 
|---|
| 491 | 
 | 
|---|
| 492 | Type *Mutator::mutate( FunctionType *functionType ) {
 | 
|---|
| 493 |         mutateAll( functionType->get_forall(), *this );
 | 
|---|
| 494 |         mutateAll( functionType->get_returnVals(), *this );
 | 
|---|
| 495 |         mutateAll( functionType->get_parameters(), *this );
 | 
|---|
| 496 |         return functionType;
 | 
|---|
| 497 | }
 | 
|---|
| 498 | 
 | 
|---|
| 499 | Type *Mutator::handleReferenceToType( ReferenceToType *aggregateUseType ) {
 | 
|---|
| 500 |         mutateAll( aggregateUseType->get_forall(), *this );
 | 
|---|
| 501 |         mutateAll( aggregateUseType->get_parameters(), *this );
 | 
|---|
| 502 |         return aggregateUseType;
 | 
|---|
| 503 | }
 | 
|---|
| 504 | 
 | 
|---|
| 505 | Type *Mutator::mutate( StructInstType *aggregateUseType ) {
 | 
|---|
| 506 |         handleReferenceToType( aggregateUseType );
 | 
|---|
| 507 |         return aggregateUseType;
 | 
|---|
| 508 | }
 | 
|---|
| 509 | 
 | 
|---|
| 510 | Type *Mutator::mutate( UnionInstType *aggregateUseType ) {
 | 
|---|
| 511 |         handleReferenceToType( aggregateUseType );
 | 
|---|
| 512 |         return aggregateUseType;
 | 
|---|
| 513 | }
 | 
|---|
| 514 | 
 | 
|---|
| 515 | Type *Mutator::mutate( EnumInstType *aggregateUseType ) {
 | 
|---|
| 516 |         handleReferenceToType( aggregateUseType );
 | 
|---|
| 517 |         return aggregateUseType;
 | 
|---|
| 518 | }
 | 
|---|
| 519 | 
 | 
|---|
| 520 | Type *Mutator::mutate( TraitInstType *aggregateUseType ) {
 | 
|---|
| 521 |         handleReferenceToType( aggregateUseType );
 | 
|---|
| 522 |         mutateAll( aggregateUseType->get_members(), *this );
 | 
|---|
| 523 |         return aggregateUseType;
 | 
|---|
| 524 | }
 | 
|---|
| 525 | 
 | 
|---|
| 526 | Type *Mutator::mutate( TypeInstType *aggregateUseType ) {
 | 
|---|
| 527 |         handleReferenceToType( aggregateUseType );
 | 
|---|
| 528 |         return aggregateUseType;
 | 
|---|
| 529 | }
 | 
|---|
| 530 | 
 | 
|---|
| 531 | Type *Mutator::mutate( TupleType *tupleType ) {
 | 
|---|
| 532 |         mutateAll( tupleType->get_forall(), *this );
 | 
|---|
| 533 |         mutateAll( tupleType->get_types(), *this );
 | 
|---|
| 534 |         mutateAll( tupleType->get_members(), *this );
 | 
|---|
| 535 |         return tupleType;
 | 
|---|
| 536 | }
 | 
|---|
| 537 | 
 | 
|---|
| 538 | Type *Mutator::mutate( TypeofType *typeofType ) {
 | 
|---|
| 539 |         assert( typeofType->get_expr() );
 | 
|---|
| 540 |         typeofType->set_expr( typeofType->get_expr()->acceptMutator( *this ) );
 | 
|---|
| 541 |         return typeofType;
 | 
|---|
| 542 | }
 | 
|---|
| 543 | 
 | 
|---|
| 544 | Type *Mutator::mutate( AttrType *attrType ) {
 | 
|---|
| 545 |         if ( attrType->get_isType() ) {
 | 
|---|
| 546 |                 assert( attrType->get_type() );
 | 
|---|
| 547 |                 attrType->set_type( attrType->get_type()->acceptMutator( *this ) );
 | 
|---|
| 548 |         } else {
 | 
|---|
| 549 |                 assert( attrType->get_expr() );
 | 
|---|
| 550 |                 attrType->set_expr( attrType->get_expr()->acceptMutator( *this ) );
 | 
|---|
| 551 |         }
 | 
|---|
| 552 |         return attrType;
 | 
|---|
| 553 | }
 | 
|---|
| 554 | 
 | 
|---|
| 555 | Type *Mutator::mutate( VarArgsType *varArgsType ) {
 | 
|---|
| 556 |         mutateAll( varArgsType->get_forall(), *this );
 | 
|---|
| 557 |         return varArgsType;
 | 
|---|
| 558 | }
 | 
|---|
| 559 | 
 | 
|---|
| 560 | Type *Mutator::mutate( ZeroType *zeroType ) {
 | 
|---|
| 561 |         mutateAll( zeroType->get_forall(), *this );
 | 
|---|
| 562 |         return zeroType;
 | 
|---|
| 563 | }
 | 
|---|
| 564 | 
 | 
|---|
| 565 | Type *Mutator::mutate( OneType *oneType ) {
 | 
|---|
| 566 |         mutateAll( oneType->get_forall(), *this );
 | 
|---|
| 567 |         return oneType;
 | 
|---|
| 568 | }
 | 
|---|
| 569 | 
 | 
|---|
| 570 | 
 | 
|---|
| 571 | Designation *Mutator::mutate( Designation * designation ) {
 | 
|---|
| 572 |         mutateAll( designation->get_designators(), *this );
 | 
|---|
| 573 |         return designation;
 | 
|---|
| 574 | }
 | 
|---|
| 575 | 
 | 
|---|
| 576 | Initializer *Mutator::mutate( SingleInit *singleInit ) {
 | 
|---|
| 577 |         singleInit->set_value( singleInit->get_value()->acceptMutator( *this ) );
 | 
|---|
| 578 |         return singleInit;
 | 
|---|
| 579 | }
 | 
|---|
| 580 | 
 | 
|---|
| 581 | Initializer *Mutator::mutate( ListInit *listInit ) {
 | 
|---|
| 582 |         mutateAll( listInit->get_designations(), *this );
 | 
|---|
| 583 |         mutateAll( listInit->get_initializers(), *this );
 | 
|---|
| 584 |         return listInit;
 | 
|---|
| 585 | }
 | 
|---|
| 586 | 
 | 
|---|
| 587 | Initializer *Mutator::mutate( ConstructorInit *ctorInit ) {
 | 
|---|
| 588 |         ctorInit->set_ctor( maybeMutate( ctorInit->get_ctor(), *this ) );
 | 
|---|
| 589 |         ctorInit->set_dtor( maybeMutate( ctorInit->get_dtor(), *this ) );
 | 
|---|
| 590 |         ctorInit->set_init( maybeMutate( ctorInit->get_init(), *this ) );
 | 
|---|
| 591 |         return ctorInit;
 | 
|---|
| 592 | }
 | 
|---|
| 593 | 
 | 
|---|
| 594 | 
 | 
|---|
| 595 | Subrange *Mutator::mutate( Subrange *subrange ) {
 | 
|---|
| 596 |         return subrange;
 | 
|---|
| 597 | }
 | 
|---|
| 598 | 
 | 
|---|
| 599 | 
 | 
|---|
| 600 | Constant *Mutator::mutate( Constant *constant ) {
 | 
|---|
| 601 |         return constant;
 | 
|---|
| 602 | }
 | 
|---|
| 603 | 
 | 
|---|
| 604 | // Local Variables: //
 | 
|---|
| 605 | // tab-width: 4 //
 | 
|---|
| 606 | // mode: c++ //
 | 
|---|
| 607 | // compile-command: "make install" //
 | 
|---|
| 608 | // End: //
 | 
|---|