| 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 : Sat Jul 25 19:21:33 2015
 | 
|---|
| 13 | // Update Count     : 11
 | 
|---|
| 14 | //
 | 
|---|
| 15 | 
 | 
|---|
| 16 | #include <cassert>
 | 
|---|
| 17 | #include "Mutator.h"
 | 
|---|
| 18 | #include "Initializer.h"
 | 
|---|
| 19 | #include "Statement.h"
 | 
|---|
| 20 | #include "Type.h"
 | 
|---|
| 21 | #include "Declaration.h"
 | 
|---|
| 22 | #include "Expression.h"
 | 
|---|
| 23 | #include "Constant.h"
 | 
|---|
| 24 | #include "Common/utility.h"
 | 
|---|
| 25 | 
 | 
|---|
| 26 | Mutator::Mutator() {}
 | 
|---|
| 27 | 
 | 
|---|
| 28 | Mutator::~Mutator() {}
 | 
|---|
| 29 | 
 | 
|---|
| 30 | DeclarationWithType *Mutator::mutate( ObjectDecl *objectDecl ) {
 | 
|---|
| 31 |         objectDecl->set_type( maybeMutate( objectDecl->get_type(), *this ) );
 | 
|---|
| 32 |         objectDecl->set_init( maybeMutate( objectDecl->get_init(), *this ) );
 | 
|---|
| 33 |         objectDecl->set_bitfieldWidth( maybeMutate( objectDecl->get_bitfieldWidth(), *this ) );
 | 
|---|
| 34 |         return objectDecl;
 | 
|---|
| 35 | }
 | 
|---|
| 36 | 
 | 
|---|
| 37 | DeclarationWithType *Mutator::mutate( FunctionDecl *functionDecl ) {
 | 
|---|
| 38 |         functionDecl->set_functionType( maybeMutate( functionDecl->get_functionType(), *this ) );
 | 
|---|
| 39 |         mutateAll( functionDecl->get_oldDecls(), *this );
 | 
|---|
| 40 |         functionDecl->set_statements( maybeMutate( functionDecl->get_statements(), *this ) );
 | 
|---|
| 41 |         return functionDecl;
 | 
|---|
| 42 | }
 | 
|---|
| 43 | 
 | 
|---|
| 44 | Declaration *Mutator::handleAggregateDecl( AggregateDecl *aggregateDecl ) {
 | 
|---|
| 45 |         mutateAll( aggregateDecl->get_parameters(), *this );
 | 
|---|
| 46 |         mutateAll( aggregateDecl->get_members(), *this );
 | 
|---|
| 47 |         return aggregateDecl;
 | 
|---|
| 48 | }
 | 
|---|
| 49 | 
 | 
|---|
| 50 | Declaration *Mutator::mutate( StructDecl *aggregateDecl ) {
 | 
|---|
| 51 |         handleAggregateDecl( aggregateDecl );
 | 
|---|
| 52 |         return aggregateDecl;
 | 
|---|
| 53 | }
 | 
|---|
| 54 | 
 | 
|---|
| 55 | Declaration *Mutator::mutate( UnionDecl *aggregateDecl ) {
 | 
|---|
| 56 |         handleAggregateDecl( aggregateDecl );
 | 
|---|
| 57 |         return aggregateDecl;
 | 
|---|
| 58 | }
 | 
|---|
| 59 | 
 | 
|---|
| 60 | Declaration *Mutator::mutate( EnumDecl *aggregateDecl ) {
 | 
|---|
| 61 |         handleAggregateDecl( aggregateDecl );
 | 
|---|
| 62 |         return aggregateDecl;
 | 
|---|
| 63 | }
 | 
|---|
| 64 | 
 | 
|---|
| 65 | Declaration *Mutator::mutate( ContextDecl *aggregateDecl ) {
 | 
|---|
| 66 |         handleAggregateDecl( aggregateDecl );
 | 
|---|
| 67 |         return aggregateDecl;
 | 
|---|
| 68 | }
 | 
|---|
| 69 | 
 | 
|---|
| 70 | Declaration *Mutator::handleNamedTypeDecl( NamedTypeDecl *typeDecl ) {
 | 
|---|
| 71 |         mutateAll( typeDecl->get_parameters(), *this );
 | 
|---|
| 72 |         mutateAll( typeDecl->get_assertions(), *this );
 | 
|---|
| 73 |         typeDecl->set_base( maybeMutate( typeDecl->get_base(), *this ) );
 | 
|---|
| 74 |         return typeDecl;
 | 
|---|
| 75 | }
 | 
|---|
| 76 | 
 | 
|---|
| 77 | TypeDecl *Mutator::mutate( TypeDecl *typeDecl ) {
 | 
|---|
| 78 |         handleNamedTypeDecl( typeDecl );
 | 
|---|
| 79 |         return typeDecl;
 | 
|---|
| 80 | }
 | 
|---|
| 81 | 
 | 
|---|
| 82 | Declaration *Mutator::mutate( TypedefDecl *typeDecl ) {
 | 
|---|
| 83 |         handleNamedTypeDecl( typeDecl );
 | 
|---|
| 84 |         return typeDecl;
 | 
|---|
| 85 | }
 | 
|---|
| 86 | 
 | 
|---|
| 87 | CompoundStmt *Mutator::mutate( CompoundStmt *compoundStmt ) {
 | 
|---|
| 88 |         mutateAll( compoundStmt->get_kids(), *this );
 | 
|---|
| 89 |         return compoundStmt;
 | 
|---|
| 90 | }
 | 
|---|
| 91 | 
 | 
|---|
| 92 | Statement *Mutator::mutate( ExprStmt *exprStmt ) {
 | 
|---|
| 93 |         exprStmt->set_expr( maybeMutate( exprStmt->get_expr(), *this ) );
 | 
|---|
| 94 |         return exprStmt;
 | 
|---|
| 95 | }
 | 
|---|
| 96 | 
 | 
|---|
| 97 | Statement *Mutator::mutate( AsmStmt *asmStmt ) {
 | 
|---|
| 98 |         asmStmt->set_instruction( maybeMutate( asmStmt->get_instruction(), *this ) );
 | 
|---|
| 99 |         mutateAll( asmStmt->get_output(), *this );
 | 
|---|
| 100 |         mutateAll( asmStmt->get_input(), *this );
 | 
|---|
| 101 |         mutateAll( asmStmt->get_clobber(), *this );
 | 
|---|
| 102 |         return asmStmt;
 | 
|---|
| 103 | }
 | 
|---|
| 104 | 
 | 
|---|
| 105 | Statement *Mutator::mutate( IfStmt *ifStmt ) {
 | 
|---|
| 106 |         ifStmt->set_condition( maybeMutate( ifStmt->get_condition(), *this ) );
 | 
|---|
| 107 |         ifStmt->set_thenPart( maybeMutate( ifStmt->get_thenPart(), *this ) );
 | 
|---|
| 108 |         ifStmt->set_elsePart( maybeMutate( ifStmt->get_elsePart(), *this ) );
 | 
|---|
| 109 |         return ifStmt;
 | 
|---|
| 110 | }
 | 
|---|
| 111 | 
 | 
|---|
| 112 | Statement *Mutator::mutate( WhileStmt *whileStmt ) {
 | 
|---|
| 113 |         whileStmt->set_condition( maybeMutate( whileStmt->get_condition(), *this ) );
 | 
|---|
| 114 |         whileStmt->set_body( maybeMutate( whileStmt->get_body(), *this ) );
 | 
|---|
| 115 |         return whileStmt;
 | 
|---|
| 116 | }
 | 
|---|
| 117 | 
 | 
|---|
| 118 | Statement *Mutator::mutate( ForStmt *forStmt ) {
 | 
|---|
| 119 |         mutateAll( forStmt->get_initialization(), *this );
 | 
|---|
| 120 |         forStmt->set_condition( maybeMutate( forStmt->get_condition(), *this ) );
 | 
|---|
| 121 |         forStmt->set_increment( maybeMutate( forStmt->get_increment(), *this ) );
 | 
|---|
| 122 |         forStmt->set_body( maybeMutate( forStmt->get_body(), *this ) );
 | 
|---|
| 123 |         return forStmt;
 | 
|---|
| 124 | }
 | 
|---|
| 125 | 
 | 
|---|
| 126 | Statement *Mutator::mutate( SwitchStmt *switchStmt ) {
 | 
|---|
| 127 |         switchStmt->set_condition( maybeMutate( switchStmt->get_condition(), *this ) );
 | 
|---|
| 128 |         mutateAll( switchStmt->get_branches(), *this );
 | 
|---|
| 129 |         return switchStmt;
 | 
|---|
| 130 | }
 | 
|---|
| 131 | 
 | 
|---|
| 132 | Statement *Mutator::mutate( ChooseStmt *switchStmt ) {
 | 
|---|
| 133 |         switchStmt->set_condition( maybeMutate( switchStmt->get_condition(), *this ) );
 | 
|---|
| 134 |         mutateAll( switchStmt->get_branches(), *this );
 | 
|---|
| 135 |         return switchStmt;
 | 
|---|
| 136 | }
 | 
|---|
| 137 | 
 | 
|---|
| 138 | Statement *Mutator::mutate( FallthruStmt *fallthruStmt ) {
 | 
|---|
| 139 |         return fallthruStmt;
 | 
|---|
| 140 | }
 | 
|---|
| 141 | 
 | 
|---|
| 142 | Statement *Mutator::mutate( CaseStmt *caseStmt ) {
 | 
|---|
| 143 |         caseStmt->set_condition( maybeMutate( caseStmt->get_condition(), *this ) );
 | 
|---|
| 144 |         mutateAll (caseStmt->get_statements(), *this );
 | 
|---|
| 145 | 
 | 
|---|
| 146 |         return caseStmt;
 | 
|---|
| 147 | }
 | 
|---|
| 148 | 
 | 
|---|
| 149 | Statement *Mutator::mutate( BranchStmt *branchStmt ) {
 | 
|---|
| 150 |         return branchStmt;
 | 
|---|
| 151 | }
 | 
|---|
| 152 | 
 | 
|---|
| 153 | Statement *Mutator::mutate( ReturnStmt *returnStmt ) {
 | 
|---|
| 154 |         returnStmt->set_expr( maybeMutate( returnStmt->get_expr(), *this ) );
 | 
|---|
| 155 |         return returnStmt;
 | 
|---|
| 156 | }
 | 
|---|
| 157 | 
 | 
|---|
| 158 | Statement *Mutator::mutate( TryStmt *tryStmt ) {
 | 
|---|
| 159 |         tryStmt->set_block( maybeMutate( tryStmt->get_block(), *this ) );
 | 
|---|
| 160 |         mutateAll( tryStmt->get_catchers(), *this );
 | 
|---|
| 161 |         return tryStmt;
 | 
|---|
| 162 | }
 | 
|---|
| 163 | 
 | 
|---|
| 164 | Statement *Mutator::mutate( CatchStmt *catchStmt ) {
 | 
|---|
| 165 |         catchStmt->set_decl( maybeMutate( catchStmt->get_decl(), *this ) );
 | 
|---|
| 166 |         catchStmt->set_body( maybeMutate( catchStmt->get_body(), *this ) );
 | 
|---|
| 167 |         return catchStmt;
 | 
|---|
| 168 | }
 | 
|---|
| 169 | 
 | 
|---|
| 170 | Statement *Mutator::mutate( FinallyStmt *finalStmt ) {
 | 
|---|
| 171 |         finalStmt->set_block( maybeMutate( finalStmt->get_block(), *this ) );
 | 
|---|
| 172 |         return finalStmt;
 | 
|---|
| 173 | }
 | 
|---|
| 174 | 
 | 
|---|
| 175 | NullStmt *Mutator::mutate( NullStmt *nullStmt ) {
 | 
|---|
| 176 |         return nullStmt;
 | 
|---|
| 177 | }
 | 
|---|
| 178 | 
 | 
|---|
| 179 | Statement *Mutator::mutate( DeclStmt *declStmt ) {
 | 
|---|
| 180 |         declStmt->set_decl( maybeMutate( declStmt->get_decl(), *this ) );
 | 
|---|
| 181 |         return declStmt;
 | 
|---|
| 182 | }
 | 
|---|
| 183 | 
 | 
|---|
| 184 | Expression *Mutator::mutate( ApplicationExpr *applicationExpr ) {
 | 
|---|
| 185 |         mutateAll( applicationExpr->get_results(), *this );
 | 
|---|
| 186 |         applicationExpr->set_function( maybeMutate( applicationExpr->get_function(), *this ) );
 | 
|---|
| 187 |         mutateAll( applicationExpr->get_args(), *this );
 | 
|---|
| 188 |         return applicationExpr;
 | 
|---|
| 189 | }
 | 
|---|
| 190 | 
 | 
|---|
| 191 | Expression *Mutator::mutate( UntypedExpr *untypedExpr ) {
 | 
|---|
| 192 |         mutateAll( untypedExpr->get_results(), *this );
 | 
|---|
| 193 |         mutateAll( untypedExpr->get_args(), *this );
 | 
|---|
| 194 |         return untypedExpr;
 | 
|---|
| 195 | }
 | 
|---|
| 196 | 
 | 
|---|
| 197 | Expression *Mutator::mutate( NameExpr *nameExpr ) {
 | 
|---|
| 198 |         mutateAll( nameExpr->get_results(), *this );
 | 
|---|
| 199 |         return nameExpr;
 | 
|---|
| 200 | }
 | 
|---|
| 201 | 
 | 
|---|
| 202 | Expression *Mutator::mutate( AddressExpr *addressExpr ) {
 | 
|---|
| 203 |         mutateAll( addressExpr->get_results(), *this );
 | 
|---|
| 204 |         addressExpr->set_arg( maybeMutate( addressExpr->get_arg(), *this ) );
 | 
|---|
| 205 |         return addressExpr;
 | 
|---|
| 206 | }
 | 
|---|
| 207 | 
 | 
|---|
| 208 | Expression *Mutator::mutate( LabelAddressExpr *labelAddressExpr ) {
 | 
|---|
| 209 |         mutateAll( labelAddressExpr->get_results(), *this );
 | 
|---|
| 210 |         labelAddressExpr->set_arg( maybeMutate( labelAddressExpr->get_arg(), *this ) );
 | 
|---|
| 211 |         return labelAddressExpr;
 | 
|---|
| 212 | }
 | 
|---|
| 213 | 
 | 
|---|
| 214 | Expression *Mutator::mutate( CastExpr *castExpr ) {
 | 
|---|
| 215 |         mutateAll( castExpr->get_results(), *this );
 | 
|---|
| 216 |         castExpr->set_arg( maybeMutate( castExpr->get_arg(), *this ) );
 | 
|---|
| 217 |         return castExpr;
 | 
|---|
| 218 | }
 | 
|---|
| 219 | 
 | 
|---|
| 220 | Expression *Mutator::mutate( UntypedMemberExpr *memberExpr ) {
 | 
|---|
| 221 |         mutateAll( memberExpr->get_results(), *this );
 | 
|---|
| 222 |         memberExpr->set_aggregate( maybeMutate( memberExpr->get_aggregate(), *this ) );
 | 
|---|
| 223 |         return memberExpr;
 | 
|---|
| 224 | }
 | 
|---|
| 225 | 
 | 
|---|
| 226 | Expression *Mutator::mutate( MemberExpr *memberExpr ) {
 | 
|---|
| 227 |         mutateAll( memberExpr->get_results(), *this );
 | 
|---|
| 228 |         memberExpr->set_aggregate( maybeMutate( memberExpr->get_aggregate(), *this ) );
 | 
|---|
| 229 |         return memberExpr;
 | 
|---|
| 230 | }
 | 
|---|
| 231 | 
 | 
|---|
| 232 | Expression *Mutator::mutate( VariableExpr *variableExpr ) {
 | 
|---|
| 233 |         mutateAll( variableExpr->get_results(), *this );
 | 
|---|
| 234 |         return variableExpr;
 | 
|---|
| 235 | }
 | 
|---|
| 236 | 
 | 
|---|
| 237 | Expression *Mutator::mutate( ConstantExpr *constantExpr ) {
 | 
|---|
| 238 |         mutateAll( constantExpr->get_results(), *this );
 | 
|---|
| 239 | //  maybeMutate( constantExpr->get_constant(), *this )
 | 
|---|
| 240 |         return constantExpr;
 | 
|---|
| 241 | }
 | 
|---|
| 242 | 
 | 
|---|
| 243 | Expression *Mutator::mutate( SizeofExpr *sizeofExpr ) {
 | 
|---|
| 244 |         mutateAll( sizeofExpr->get_results(), *this );
 | 
|---|
| 245 |         if ( sizeofExpr->get_isType() ) {
 | 
|---|
| 246 |                 sizeofExpr->set_type( maybeMutate( sizeofExpr->get_type(), *this ) );
 | 
|---|
| 247 |         } else {
 | 
|---|
| 248 |                 sizeofExpr->set_expr( maybeMutate( sizeofExpr->get_expr(), *this ) );
 | 
|---|
| 249 |         }
 | 
|---|
| 250 |         return sizeofExpr;
 | 
|---|
| 251 | }
 | 
|---|
| 252 | 
 | 
|---|
| 253 | Expression *Mutator::mutate( AlignofExpr *alignofExpr ) {
 | 
|---|
| 254 |         mutateAll( alignofExpr->get_results(), *this );
 | 
|---|
| 255 |         if ( alignofExpr->get_isType() ) {
 | 
|---|
| 256 |                 alignofExpr->set_type( maybeMutate( alignofExpr->get_type(), *this ) );
 | 
|---|
| 257 |         } else {
 | 
|---|
| 258 |                 alignofExpr->set_expr( maybeMutate( alignofExpr->get_expr(), *this ) );
 | 
|---|
| 259 |         }
 | 
|---|
| 260 |         return alignofExpr;
 | 
|---|
| 261 | }
 | 
|---|
| 262 | 
 | 
|---|
| 263 | Expression *Mutator::mutate( UntypedOffsetofExpr *offsetofExpr ) {
 | 
|---|
| 264 |         mutateAll( offsetofExpr->get_results(), *this );
 | 
|---|
| 265 |         offsetofExpr->set_type( maybeMutate( offsetofExpr->get_type(), *this ) );
 | 
|---|
| 266 |         return offsetofExpr;
 | 
|---|
| 267 | }
 | 
|---|
| 268 | 
 | 
|---|
| 269 | Expression *Mutator::mutate( OffsetofExpr *offsetofExpr ) {
 | 
|---|
| 270 |         mutateAll( offsetofExpr->get_results(), *this );
 | 
|---|
| 271 |         offsetofExpr->set_type( maybeMutate( offsetofExpr->get_type(), *this ) );
 | 
|---|
| 272 |         offsetofExpr->set_member( maybeMutate( offsetofExpr->get_member(), *this ) );
 | 
|---|
| 273 |         return offsetofExpr;
 | 
|---|
| 274 | }
 | 
|---|
| 275 | 
 | 
|---|
| 276 | Expression *Mutator::mutate( AttrExpr *attrExpr ) {
 | 
|---|
| 277 |         mutateAll( attrExpr->get_results(), *this );
 | 
|---|
| 278 |         if ( attrExpr->get_isType() ) {
 | 
|---|
| 279 |                 attrExpr->set_type( maybeMutate( attrExpr->get_type(), *this ) );
 | 
|---|
| 280 |         } else {
 | 
|---|
| 281 |                 attrExpr->set_expr( maybeMutate( attrExpr->get_expr(), *this ) );
 | 
|---|
| 282 |         }
 | 
|---|
| 283 |         return attrExpr;
 | 
|---|
| 284 | }
 | 
|---|
| 285 | 
 | 
|---|
| 286 | Expression *Mutator::mutate( LogicalExpr *logicalExpr ) {
 | 
|---|
| 287 |         mutateAll( logicalExpr->get_results(), *this );
 | 
|---|
| 288 |         logicalExpr->set_arg1( maybeMutate( logicalExpr->get_arg1(), *this ) );
 | 
|---|
| 289 |         logicalExpr->set_arg2( maybeMutate( logicalExpr->get_arg2(), *this ) );
 | 
|---|
| 290 |         return logicalExpr;
 | 
|---|
| 291 | }
 | 
|---|
| 292 | 
 | 
|---|
| 293 | Expression *Mutator::mutate( ConditionalExpr *conditionalExpr ) {
 | 
|---|
| 294 |         mutateAll( conditionalExpr->get_results(), *this );
 | 
|---|
| 295 |         conditionalExpr->set_arg1( maybeMutate( conditionalExpr->get_arg1(), *this ) );
 | 
|---|
| 296 |         conditionalExpr->set_arg2( maybeMutate( conditionalExpr->get_arg2(), *this ) );
 | 
|---|
| 297 |         conditionalExpr->set_arg3( maybeMutate( conditionalExpr->get_arg3(), *this ) );
 | 
|---|
| 298 |         return conditionalExpr;
 | 
|---|
| 299 | }
 | 
|---|
| 300 | 
 | 
|---|
| 301 | Expression *Mutator::mutate( CommaExpr *commaExpr ) {
 | 
|---|
| 302 |         mutateAll( commaExpr->get_results(), *this );
 | 
|---|
| 303 |         commaExpr->set_arg1( maybeMutate( commaExpr->get_arg1(), *this ) );
 | 
|---|
| 304 |         commaExpr->set_arg2( maybeMutate( commaExpr->get_arg2(), *this ) );
 | 
|---|
| 305 |         return commaExpr;
 | 
|---|
| 306 | }
 | 
|---|
| 307 | 
 | 
|---|
| 308 | Expression *Mutator::mutate( TupleExpr *tupleExpr ) {
 | 
|---|
| 309 |         mutateAll( tupleExpr->get_results(), *this );
 | 
|---|
| 310 |         mutateAll( tupleExpr->get_exprs(), *this );
 | 
|---|
| 311 |         return tupleExpr;
 | 
|---|
| 312 | }
 | 
|---|
| 313 | 
 | 
|---|
| 314 | Expression *Mutator::mutate( SolvedTupleExpr *tupleExpr ) {
 | 
|---|
| 315 |         mutateAll( tupleExpr->get_results(), *this );
 | 
|---|
| 316 |         mutateAll( tupleExpr->get_exprs(), *this );
 | 
|---|
| 317 |         return tupleExpr;
 | 
|---|
| 318 | }
 | 
|---|
| 319 | 
 | 
|---|
| 320 | Expression *Mutator::mutate( TypeExpr *typeExpr ) {
 | 
|---|
| 321 |         mutateAll( typeExpr->get_results(), *this );
 | 
|---|
| 322 |         typeExpr->set_type( maybeMutate( typeExpr->get_type(), *this ) );
 | 
|---|
| 323 |         return typeExpr;
 | 
|---|
| 324 | }
 | 
|---|
| 325 | 
 | 
|---|
| 326 | Expression *Mutator::mutate( AsmExpr *asmExpr ) {
 | 
|---|
| 327 |         asmExpr->set_inout( maybeMutate( asmExpr->get_inout(), *this ) );
 | 
|---|
| 328 |         asmExpr->set_constraint( maybeMutate( asmExpr->get_constraint(), *this ) );
 | 
|---|
| 329 |         asmExpr->set_operand( maybeMutate( asmExpr->get_operand(), *this ) );
 | 
|---|
| 330 |         return asmExpr;
 | 
|---|
| 331 | }
 | 
|---|
| 332 | 
 | 
|---|
| 333 | Expression *Mutator::mutate( UntypedValofExpr *valofExpr ) {
 | 
|---|
| 334 |         mutateAll( valofExpr->get_results(), *this );
 | 
|---|
| 335 |         return valofExpr;
 | 
|---|
| 336 | }
 | 
|---|
| 337 | 
 | 
|---|
| 338 | Type *Mutator::mutate( VoidType *voidType ) {
 | 
|---|
| 339 |         mutateAll( voidType->get_forall(), *this );
 | 
|---|
| 340 |         return voidType;
 | 
|---|
| 341 | }
 | 
|---|
| 342 | 
 | 
|---|
| 343 | Type *Mutator::mutate( BasicType *basicType ) {
 | 
|---|
| 344 |         mutateAll( basicType->get_forall(), *this );
 | 
|---|
| 345 |         return basicType;
 | 
|---|
| 346 | }
 | 
|---|
| 347 | 
 | 
|---|
| 348 | Type *Mutator::mutate( PointerType *pointerType ) {
 | 
|---|
| 349 |         mutateAll( pointerType->get_forall(), *this );
 | 
|---|
| 350 |         pointerType->set_base( maybeMutate( pointerType->get_base(), *this ) );
 | 
|---|
| 351 |         return pointerType;
 | 
|---|
| 352 | }
 | 
|---|
| 353 | 
 | 
|---|
| 354 | Type *Mutator::mutate( ArrayType *arrayType ) {
 | 
|---|
| 355 |         mutateAll( arrayType->get_forall(), *this );
 | 
|---|
| 356 |         arrayType->set_dimension( maybeMutate( arrayType->get_dimension(), *this ) );
 | 
|---|
| 357 |         arrayType->set_base( maybeMutate( arrayType->get_base(), *this ) );
 | 
|---|
| 358 |         return arrayType;
 | 
|---|
| 359 | }
 | 
|---|
| 360 | 
 | 
|---|
| 361 | Type *Mutator::mutate( FunctionType *functionType ) {
 | 
|---|
| 362 |         mutateAll( functionType->get_forall(), *this );
 | 
|---|
| 363 |         mutateAll( functionType->get_returnVals(), *this );
 | 
|---|
| 364 |         mutateAll( functionType->get_parameters(), *this );
 | 
|---|
| 365 |         return functionType;
 | 
|---|
| 366 | }
 | 
|---|
| 367 | 
 | 
|---|
| 368 | Type *Mutator::handleReferenceToType( ReferenceToType *aggregateUseType ) {
 | 
|---|
| 369 |         mutateAll( aggregateUseType->get_forall(), *this );
 | 
|---|
| 370 |         mutateAll( aggregateUseType->get_parameters(), *this );
 | 
|---|
| 371 |         return aggregateUseType;
 | 
|---|
| 372 | }
 | 
|---|
| 373 | 
 | 
|---|
| 374 | Type *Mutator::mutate( StructInstType *aggregateUseType ) {
 | 
|---|
| 375 |         handleReferenceToType( aggregateUseType );
 | 
|---|
| 376 |         return aggregateUseType;
 | 
|---|
| 377 | }
 | 
|---|
| 378 | 
 | 
|---|
| 379 | Type *Mutator::mutate( UnionInstType *aggregateUseType ) {
 | 
|---|
| 380 |         handleReferenceToType( aggregateUseType );
 | 
|---|
| 381 |         return aggregateUseType;
 | 
|---|
| 382 | }
 | 
|---|
| 383 | 
 | 
|---|
| 384 | Type *Mutator::mutate( EnumInstType *aggregateUseType ) {
 | 
|---|
| 385 |         handleReferenceToType( aggregateUseType );
 | 
|---|
| 386 |         return aggregateUseType;
 | 
|---|
| 387 | }
 | 
|---|
| 388 | 
 | 
|---|
| 389 | Type *Mutator::mutate( ContextInstType *aggregateUseType ) {
 | 
|---|
| 390 |         handleReferenceToType( aggregateUseType );
 | 
|---|
| 391 |         mutateAll( aggregateUseType->get_members(), *this );
 | 
|---|
| 392 |         return aggregateUseType;
 | 
|---|
| 393 | }
 | 
|---|
| 394 | 
 | 
|---|
| 395 | Type *Mutator::mutate( TypeInstType *aggregateUseType ) {
 | 
|---|
| 396 |         handleReferenceToType( aggregateUseType );
 | 
|---|
| 397 |         return aggregateUseType;
 | 
|---|
| 398 | }
 | 
|---|
| 399 | 
 | 
|---|
| 400 | Type *Mutator::mutate( TupleType *tupleType ) {
 | 
|---|
| 401 |         mutateAll( tupleType->get_forall(), *this );
 | 
|---|
| 402 |         mutateAll( tupleType->get_types(), *this );
 | 
|---|
| 403 |         return tupleType;
 | 
|---|
| 404 | }
 | 
|---|
| 405 | 
 | 
|---|
| 406 | Type *Mutator::mutate( TypeofType *typeofType ) {
 | 
|---|
| 407 |         assert( typeofType->get_expr() );
 | 
|---|
| 408 |         typeofType->set_expr( typeofType->get_expr()->acceptMutator( *this ) );
 | 
|---|
| 409 |         return typeofType;
 | 
|---|
| 410 | }
 | 
|---|
| 411 | 
 | 
|---|
| 412 | Type *Mutator::mutate( AttrType *attrType ) {
 | 
|---|
| 413 |         if ( attrType->get_isType() ) {
 | 
|---|
| 414 |                 assert( attrType->get_type() );
 | 
|---|
| 415 |                 attrType->set_type( attrType->get_type()->acceptMutator( *this ) );
 | 
|---|
| 416 |         } else {
 | 
|---|
| 417 |                 assert( attrType->get_expr() );
 | 
|---|
| 418 |                 attrType->set_expr( attrType->get_expr()->acceptMutator( *this ) );
 | 
|---|
| 419 |         }
 | 
|---|
| 420 |         return attrType;
 | 
|---|
| 421 | }
 | 
|---|
| 422 | 
 | 
|---|
| 423 | Initializer *Mutator::mutate( SingleInit *singleInit ) {
 | 
|---|
| 424 |         singleInit->set_value( singleInit->get_value()->acceptMutator( *this ) );
 | 
|---|
| 425 |         return singleInit;
 | 
|---|
| 426 | }
 | 
|---|
| 427 | 
 | 
|---|
| 428 | Initializer *Mutator::mutate( ListInit *listInit ) {
 | 
|---|
| 429 |         mutateAll( listInit->get_designators(), *this );
 | 
|---|
| 430 |         mutateAll( listInit->get_initializers(), *this );
 | 
|---|
| 431 |         return listInit;
 | 
|---|
| 432 | }
 | 
|---|
| 433 | 
 | 
|---|
| 434 | Subrange *Mutator::mutate( Subrange *subrange ) {
 | 
|---|
| 435 |         return subrange;
 | 
|---|
| 436 | }
 | 
|---|
| 437 | 
 | 
|---|
| 438 | Constant *Mutator::mutate( Constant *constant ) {
 | 
|---|
| 439 |         return constant;
 | 
|---|
| 440 | }
 | 
|---|
| 441 | 
 | 
|---|
| 442 | // Local Variables: //
 | 
|---|
| 443 | // tab-width: 4 //
 | 
|---|
| 444 | // mode: c++ //
 | 
|---|
| 445 | // compile-command: "make install" //
 | 
|---|
| 446 | // End: //
 | 
|---|