Changeset f232977
- Timestamp:
- Oct 19, 2017, 11:15:35 AM (7 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:
- b93a3de
- Parents:
- 150ec33
- git-author:
- Rob Schluntz <rschlunt@…> (10/13/17 16:05:16)
- git-committer:
- Rob Schluntz <rschlunt@…> (10/19/17 11:15:35)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified src/SymTab/Autogen.cc ¶
r150ec33 rf232977 295 295 for ( FunctionDecl * dcl : newFuncs ) { 296 296 genFuncBody( dcl ); 297 if ( CodeGen::isAssignment( dcl->name ) ) { 298 // assignment needs to return a value 299 FunctionType * assignType = dcl->type; 300 assert( assignType->parameters.size() == 2 ); 301 assert( assignType->returnVals.size() == 1 ); 302 ObjectDecl * dstParam = strict_dynamic_cast< ObjectDecl * >( assignType->parameters.front() ); 303 dcl->statements->push_back( new ReturnStmt( noLabels, new VariableExpr( dstParam ) ) ); 304 } 297 305 resolve( dcl ); 298 306 } … … 349 357 } else { 350 358 makeFunctionBody( aggregateDecl->members.rbegin(), aggregateDecl->members.rend(), dcl, false ); 351 }352 if ( CodeGen::isAssignment( dcl->name ) ) {353 // assignment needs to return a value354 FunctionType * assignType = dcl->type;355 assert( assignType->parameters.size() == 2 );356 assert( assignType->returnVals.size() == 1 );357 ObjectDecl * srcParam = strict_dynamic_cast< ObjectDecl * >( assignType->parameters.back() );358 ObjectDecl * retParam = strict_dynamic_cast< ObjectDecl * >( assignType->returnVals.front() );359 360 dcl->statements->push_back( new ExprStmt( noLabels, new UntypedExpr( new NameExpr("?{}"), { new VariableExpr( retParam ), new VariableExpr( srcParam ) } ) ) );361 dcl->statements->push_back( new ReturnStmt( noLabels, new VariableExpr( retParam ) ) );362 359 } 363 360 } … … 483 480 ObjectDecl * dstParam = strict_dynamic_cast< ObjectDecl * >( ftype->parameters.front() ); 484 481 ObjectDecl * srcParam = strict_dynamic_cast< ObjectDecl * >( ftype->parameters.back() ); 485 486 482 makeMemberOp( srcParam, dstParam, back_inserter( funcDecl->statements->kids ) ); 487 if ( CodeGen::isAssignment( funcDecl->name ) ) {488 // also generate return statement in assignment489 funcDecl->statements->push_back( new ReturnStmt( noLabels, new VariableExpr( srcParam ) ) );490 }491 483 } else { 492 484 // default ctor/dtor body is empty - add unused attribute to parameter to silence warnings … … 551 543 callExpr->get_args().push_back( new VariableExpr( srcParam ) ); 552 544 funcDecl->statements->push_back( new ExprStmt( noLabels, callExpr ) ); 553 if ( CodeGen::isAssignment( funcDecl->name ) ) {554 // also generate return statement in assignment555 funcDecl->statements->push_back( new ReturnStmt( noLabels, new VariableExpr( srcParam ) ) );556 }557 545 } else { 558 546 // default ctor/dtor body is empty - add unused attribute to parameter to silence warnings … … 580 568 if ( src ) expr->args.push_back( new CastExpr( new VariableExpr( src ), typeDecl->base->clone() ) ); 581 569 dcl->statements->kids.push_back( new ExprStmt( noLabels, expr ) ); 582 if ( CodeGen::isAssignment( dcl->get_name() ) ) {583 // assignment needs to return a value584 FunctionType * assignType = dcl->type;585 assert( assignType->parameters.size() == 2 );586 ObjectDecl * srcParam = strict_dynamic_cast< ObjectDecl * >( assignType->parameters.back() );587 dcl->statements->kids.push_back( new ReturnStmt( noLabels, new VariableExpr( srcParam ) ) );588 }589 570 }; 590 571
Note: See TracChangeset
for help on using the changeset viewer.