Changeset 4d4882a for src/InitTweak
- Timestamp:
- Sep 1, 2016, 4:53:22 PM (9 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, ctor, 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:
- 44f6341
- Parents:
- fba44f8
- Location:
- src/InitTweak
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified src/InitTweak/FixInit.cc ¶
rfba44f8 r4d4882a 787 787 UntypedExpr * deref = new UntypedExpr( new NameExpr( "*?" ) ); 788 788 deref->get_args().push_back( new VariableExpr( thisParam ) ); 789 InitExpander srcParam( (Initializer *)NULL ); // xxx - if copy ctor, need to pass appropriate argument - second param of this function dot member 789 790 Expression * arg2 = 0; 791 if ( isCopyConstructor( function ) ) { 792 // if copy ctor, need to pass second-param-of-this-function.member 793 std::list< DeclarationWithType * > & params = function->get_functionType()->get_parameters(); 794 assert( params.size() == 2 ); 795 arg2 = new MemberExpr( member, new VariableExpr( params.back() ) ); 796 } 797 InitExpander srcParam( arg2 ); 790 798 SymTab::genImplicitCall( srcParam, new MemberExpr( member, deref ), function->get_name(), back_inserter( stmt ), member, isCtor ); 791 799 … … 832 840 handleFirstParam( firstParam ); 833 841 } 834 } else if ( fname == "?=?" && isIntrinsicCallExpr( appExpr ) ) {835 // forgive use of intrinsic assignment to construct, since instrinsic constructors836 // codegen as assignment anyway.837 assert( appExpr->get_args().size() == 2 );838 handleFirstParam( appExpr->get_args().front() );839 842 } 840 843 -
TabularUnified src/InitTweak/InitTweak.cc ¶
rfba44f8 r4d4882a 7 7 #include "SynTree/Attribute.h" 8 8 #include "GenPoly/GenPoly.h" 9 #include "ResolvExpr/typeops.h" 9 10 10 11 namespace InitTweak { … … 439 440 bool isDestructor( const std::string & str ) { return str == "^?{}"; } 440 441 bool isCtorDtor( const std::string & str ) { return isConstructor( str ) || isDestructor( str ); } 442 443 FunctionDecl * isCopyConstructor( Declaration * decl ) { 444 FunctionDecl * function = dynamic_cast< FunctionDecl * >( decl ); 445 if ( ! function ) return 0; 446 if ( ! isConstructor( function->get_name() ) ) return 0; 447 FunctionType * ftype = function->get_functionType(); 448 if ( ftype->get_parameters().size() != 2 ) return 0; 449 450 Type * t1 = ftype->get_parameters().front()->get_type(); 451 Type * t2 = ftype->get_parameters().back()->get_type(); 452 PointerType * ptrType = dynamic_cast< PointerType * > ( t1 ); 453 assert( ptrType ); 454 455 if ( ResolvExpr::typesCompatible( ptrType->get_base(), t2, SymTab::Indexer() ) ) { 456 return function; 457 } else { 458 return 0; 459 } 460 } 441 461 } -
TabularUnified src/InitTweak/InitTweak.h ¶
rfba44f8 r4d4882a 29 29 bool isDestructor( const std::string & ); 30 30 bool isCtorDtor( const std::string & ); 31 32 FunctionDecl * isCopyConstructor( Declaration * decl ); 31 33 32 34 /// transform Initializer into an argument list that can be passed to a call expression
Note: See TracChangeset
for help on using the changeset viewer.