Changeset e33f321 for src/SynTree
- Timestamp:
- Dec 21, 2016, 2:55:56 PM (8 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
- Children:
- 626dbc10
- Parents:
- 8bf784a
- Location:
- src/SynTree
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SynTree/Mutator.cc
r8bf784a re33f321 23 23 #include "Constant.h" 24 24 #include "Common/utility.h" 25 #include "TypeSubstitution.h" 25 26 26 27 Mutator::Mutator() {} … … 178 179 179 180 Expression *Mutator::mutate( ApplicationExpr *applicationExpr ) { 181 applicationExpr->set_env( maybeMutate( applicationExpr->get_env(), *this ) ); 180 182 applicationExpr->set_result( maybeMutate( applicationExpr->get_result(), *this ) ); 181 183 applicationExpr->set_function( maybeMutate( applicationExpr->get_function(), *this ) ); … … 185 187 186 188 Expression *Mutator::mutate( UntypedExpr *untypedExpr ) { 189 untypedExpr->set_env( maybeMutate( untypedExpr->get_env(), *this ) ); 187 190 untypedExpr->set_result( maybeMutate( untypedExpr->get_result(), *this ) ); 188 191 mutateAll( untypedExpr->get_args(), *this ); … … 191 194 192 195 Expression *Mutator::mutate( NameExpr *nameExpr ) { 196 nameExpr->set_env( maybeMutate( nameExpr->get_env(), *this ) ); 193 197 nameExpr->set_result( maybeMutate( nameExpr->get_result(), *this ) ); 194 198 return nameExpr; … … 196 200 197 201 Expression *Mutator::mutate( AddressExpr *addressExpr ) { 202 addressExpr->set_env( maybeMutate( addressExpr->get_env(), *this ) ); 198 203 addressExpr->set_result( maybeMutate( addressExpr->get_result(), *this ) ); 199 204 addressExpr->set_arg( maybeMutate( addressExpr->get_arg(), *this ) ); … … 202 207 203 208 Expression *Mutator::mutate( LabelAddressExpr *labelAddressExpr ) { 209 labelAddressExpr->set_env( maybeMutate( labelAddressExpr->get_env(), *this ) ); 204 210 labelAddressExpr->set_result( maybeMutate( labelAddressExpr->get_result(), *this ) ); 205 211 labelAddressExpr->set_arg( maybeMutate( labelAddressExpr->get_arg(), *this ) ); … … 208 214 209 215 Expression *Mutator::mutate( CastExpr *castExpr ) { 216 castExpr->set_env( maybeMutate( castExpr->get_env(), *this ) ); 210 217 castExpr->set_result( maybeMutate( castExpr->get_result(), *this ) ); 211 218 castExpr->set_arg( maybeMutate( castExpr->get_arg(), *this ) ); … … 214 221 215 222 Expression *Mutator::mutate( UntypedMemberExpr *memberExpr ) { 223 memberExpr->set_env( maybeMutate( memberExpr->get_env(), *this ) ); 216 224 memberExpr->set_result( maybeMutate( memberExpr->get_result(), *this ) ); 217 225 memberExpr->set_aggregate( maybeMutate( memberExpr->get_aggregate(), *this ) ); … … 221 229 222 230 Expression *Mutator::mutate( MemberExpr *memberExpr ) { 231 memberExpr->set_env( maybeMutate( memberExpr->get_env(), *this ) ); 223 232 memberExpr->set_result( maybeMutate( memberExpr->get_result(), *this ) ); 224 233 memberExpr->set_aggregate( maybeMutate( memberExpr->get_aggregate(), *this ) ); … … 227 236 228 237 Expression *Mutator::mutate( VariableExpr *variableExpr ) { 238 variableExpr->set_env( maybeMutate( variableExpr->get_env(), *this ) ); 229 239 variableExpr->set_result( maybeMutate( variableExpr->get_result(), *this ) ); 230 240 return variableExpr; … … 232 242 233 243 Expression *Mutator::mutate( ConstantExpr *constantExpr ) { 244 constantExpr->set_env( maybeMutate( constantExpr->get_env(), *this ) ); 234 245 constantExpr->set_result( maybeMutate( constantExpr->get_result(), *this ) ); 235 246 // maybeMutate( constantExpr->get_constant(), *this ) … … 238 249 239 250 Expression *Mutator::mutate( SizeofExpr *sizeofExpr ) { 251 sizeofExpr->set_env( maybeMutate( sizeofExpr->get_env(), *this ) ); 240 252 sizeofExpr->set_result( maybeMutate( sizeofExpr->get_result(), *this ) ); 241 253 if ( sizeofExpr->get_isType() ) { … … 248 260 249 261 Expression *Mutator::mutate( AlignofExpr *alignofExpr ) { 262 alignofExpr->set_env( maybeMutate( alignofExpr->get_env(), *this ) ); 250 263 alignofExpr->set_result( maybeMutate( alignofExpr->get_result(), *this ) ); 251 264 if ( alignofExpr->get_isType() ) { … … 258 271 259 272 Expression *Mutator::mutate( UntypedOffsetofExpr *offsetofExpr ) { 273 offsetofExpr->set_env( maybeMutate( offsetofExpr->get_env(), *this ) ); 260 274 offsetofExpr->set_result( maybeMutate( offsetofExpr->get_result(), *this ) ); 261 275 offsetofExpr->set_type( maybeMutate( offsetofExpr->get_type(), *this ) ); … … 264 278 265 279 Expression *Mutator::mutate( OffsetofExpr *offsetofExpr ) { 280 offsetofExpr->set_env( maybeMutate( offsetofExpr->get_env(), *this ) ); 266 281 offsetofExpr->set_result( maybeMutate( offsetofExpr->get_result(), *this ) ); 267 282 offsetofExpr->set_type( maybeMutate( offsetofExpr->get_type(), *this ) ); … … 271 286 272 287 Expression *Mutator::mutate( OffsetPackExpr *offsetPackExpr ) { 288 offsetPackExpr->set_env( maybeMutate( offsetPackExpr->get_env(), *this ) ); 273 289 offsetPackExpr->set_result( maybeMutate( offsetPackExpr->get_result(), *this ) ); 274 290 offsetPackExpr->set_type( maybeMutate( offsetPackExpr->get_type(), *this ) ); … … 277 293 278 294 Expression *Mutator::mutate( AttrExpr *attrExpr ) { 295 attrExpr->set_env( maybeMutate( attrExpr->get_env(), *this ) ); 279 296 attrExpr->set_result( maybeMutate( attrExpr->get_result(), *this ) ); 280 297 if ( attrExpr->get_isType() ) { … … 287 304 288 305 Expression *Mutator::mutate( LogicalExpr *logicalExpr ) { 306 logicalExpr->set_env( maybeMutate( logicalExpr->get_env(), *this ) ); 289 307 logicalExpr->set_result( maybeMutate( logicalExpr->get_result(), *this ) ); 290 308 logicalExpr->set_arg1( maybeMutate( logicalExpr->get_arg1(), *this ) ); … … 294 312 295 313 Expression *Mutator::mutate( ConditionalExpr *conditionalExpr ) { 314 conditionalExpr->set_env( maybeMutate( conditionalExpr->get_env(), *this ) ); 296 315 conditionalExpr->set_result( maybeMutate( conditionalExpr->get_result(), *this ) ); 297 316 conditionalExpr->set_arg1( maybeMutate( conditionalExpr->get_arg1(), *this ) ); … … 302 321 303 322 Expression *Mutator::mutate( CommaExpr *commaExpr ) { 323 commaExpr->set_env( maybeMutate( commaExpr->get_env(), *this ) ); 304 324 commaExpr->set_result( maybeMutate( commaExpr->get_result(), *this ) ); 305 325 commaExpr->set_arg1( maybeMutate( commaExpr->get_arg1(), *this ) ); … … 309 329 310 330 Expression *Mutator::mutate( TypeExpr *typeExpr ) { 331 typeExpr->set_env( maybeMutate( typeExpr->get_env(), *this ) ); 311 332 typeExpr->set_result( maybeMutate( typeExpr->get_result(), *this ) ); 312 333 typeExpr->set_type( maybeMutate( typeExpr->get_type(), *this ) ); … … 315 336 316 337 Expression *Mutator::mutate( AsmExpr *asmExpr ) { 338 asmExpr->set_env( maybeMutate( asmExpr->get_env(), *this ) ); 317 339 asmExpr->set_inout( maybeMutate( asmExpr->get_inout(), *this ) ); 318 340 asmExpr->set_constraint( maybeMutate( asmExpr->get_constraint(), *this ) ); … … 322 344 323 345 Expression* Mutator::mutate( ImplicitCopyCtorExpr *impCpCtorExpr ) { 346 impCpCtorExpr->set_env( maybeMutate( impCpCtorExpr->get_env(), *this ) ); 324 347 impCpCtorExpr->set_callExpr( maybeMutate( impCpCtorExpr->get_callExpr(), *this ) ); 325 348 mutateAll( impCpCtorExpr->get_tempDecls(), *this ); … … 330 353 331 354 Expression* Mutator::mutate( ConstructorExpr *ctorExpr ) { 355 ctorExpr->set_env( maybeMutate( ctorExpr->get_env(), *this ) ); 332 356 ctorExpr->set_result( maybeMutate( ctorExpr->get_result(), *this ) ); 333 357 ctorExpr->set_callExpr( maybeMutate( ctorExpr->get_callExpr(), *this ) ); … … 336 360 337 361 Expression *Mutator::mutate( CompoundLiteralExpr *compLitExpr ) { 362 compLitExpr->set_env( maybeMutate( compLitExpr->get_env(), *this ) ); 338 363 compLitExpr->set_result( maybeMutate( compLitExpr->get_result(), *this ) ); 339 364 compLitExpr->set_type( maybeMutate( compLitExpr->get_type(), *this ) ); … … 343 368 344 369 Expression *Mutator::mutate( UntypedValofExpr *valofExpr ) { 370 valofExpr->set_env( maybeMutate( valofExpr->get_env(), *this ) ); 345 371 valofExpr->set_result( maybeMutate( valofExpr->get_result(), *this ) ); 346 372 return valofExpr; … … 348 374 349 375 Expression *Mutator::mutate( RangeExpr *rangeExpr ) { 376 rangeExpr->set_env( maybeMutate( rangeExpr->get_env(), *this ) ); 350 377 rangeExpr->set_low( maybeMutate( rangeExpr->get_low(), *this ) ); 351 378 rangeExpr->set_high( maybeMutate( rangeExpr->get_high(), *this ) ); … … 354 381 355 382 Expression *Mutator::mutate( TupleExpr *tupleExpr ) { 383 tupleExpr->set_env( maybeMutate( tupleExpr->get_env(), *this ) ); 356 384 tupleExpr->set_result( maybeMutate( tupleExpr->get_result(), *this ) ); 357 385 mutateAll( tupleExpr->get_exprs(), *this ); … … 360 388 361 389 Expression *Mutator::mutate( TupleIndexExpr *tupleExpr ) { 390 tupleExpr->set_env( maybeMutate( tupleExpr->get_env(), *this ) ); 362 391 tupleExpr->set_result( maybeMutate( tupleExpr->get_result(), *this ) ); 363 392 tupleExpr->set_tuple( maybeMutate( tupleExpr->get_tuple(), *this ) ); … … 366 395 367 396 Expression *Mutator::mutate( MemberTupleExpr *tupleExpr ) { 397 tupleExpr->set_env( maybeMutate( tupleExpr->get_env(), *this ) ); 368 398 tupleExpr->set_result( maybeMutate( tupleExpr->get_result(), *this ) ); 369 399 tupleExpr->set_member( maybeMutate( tupleExpr->get_member(), *this ) ); … … 373 403 374 404 Expression *Mutator::mutate( TupleAssignExpr *assignExpr ) { 405 assignExpr->set_env( maybeMutate( assignExpr->get_env(), *this ) ); 375 406 assignExpr->set_result( maybeMutate( assignExpr->get_result(), *this ) ); 376 407 assignExpr->set_stmtExpr( maybeMutate( assignExpr->get_stmtExpr(), *this ) ); … … 379 410 380 411 Expression *Mutator::mutate( StmtExpr *stmtExpr ) { 412 stmtExpr->set_env( maybeMutate( stmtExpr->get_env(), *this ) ); 381 413 stmtExpr->set_result( maybeMutate( stmtExpr->get_result(), *this ) ); 382 414 stmtExpr->set_statements( maybeMutate( stmtExpr->get_statements(), *this ) ); … … 387 419 388 420 Expression *Mutator::mutate( UniqueExpr *uniqueExpr ) { 421 uniqueExpr->set_env( maybeMutate( uniqueExpr->get_env(), *this ) ); 389 422 uniqueExpr->set_result( maybeMutate( uniqueExpr->get_result(), *this ) ); 390 423 uniqueExpr->set_expr( maybeMutate( uniqueExpr->get_expr(), *this ) ); -
src/SynTree/TypeSubstitution.cc
r8bf784a re33f321 231 231 } 232 232 233 TypeSubstitution * TypeSubstitution::acceptMutator( Mutator & mutator ) { 234 for ( auto & p : typeEnv ) { 235 p.second = maybeMutate( p.second, mutator ); 236 } 237 for ( auto & p : varEnv ) { 238 p.second = maybeMutate( p.second, mutator ); 239 } 240 return this; 241 } 242 233 243 void TypeSubstitution::print( std::ostream &os, int indent ) const { 234 244 os << std::string( indent, ' ' ) << "Types:" << std::endl; -
src/SynTree/TypeSubstitution.h
r8bf784a re33f321 53 53 54 54 void normalize(); 55 56 TypeSubstitution * acceptMutator( Mutator & mutator ); 55 57 56 58 void print( std::ostream &os, int indent = 0 ) const;
Note: See TracChangeset
for help on using the changeset viewer.