Changeset 74b007ba
- Timestamp:
- Aug 14, 2017, 2:05:42 PM (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:
- 36a5a77
- Parents:
- 9236060
- Location:
- src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/ResolvExpr/AlternativeFinder.cc
r9236060 r74b007ba 633 633 AssertionSet newNeed; 634 634 //AssertionParentSet needParents; 635 PRINT( 636 std::cerr << "env is: " << std::endl; 637 newAlt.env.print( std::cerr, 0 ); 638 std::cerr << std::endl; 639 ) 640 635 641 inferRecursive( need.begin(), need.end(), newAlt, openVars, decls, newNeed, /*needParents,*/ 0, indexer, out ); 636 642 // PRINT( -
src/ResolvExpr/ConversionCost.cc
r9236060 r74b007ba 77 77 78 78 Cost convertToReferenceCost( Type * src, Type * dest, int diff, const SymTab::Indexer & indexer, const TypeEnvironment & env ) { 79 std::cerr << "convert to reference cost..." << std::endl;79 // std::cerr << "convert to reference cost..." << std::endl; 80 80 if ( diff > 0 ) { 81 81 // TODO: document this … … 92 92 ReferenceType * destAsRef = dynamic_cast< ReferenceType * >( dest ); 93 93 if ( srcAsRef && destAsRef ) { // pointer-like conversions between references 94 std::cerr << "converting between references" << std::endl;94 // std::cerr << "converting between references" << std::endl; 95 95 if ( srcAsRef->get_base()->get_qualifiers() <= destAsRef->get_base()->get_qualifiers() && typesCompatibleIgnoreQualifiers( srcAsRef->get_base(), destAsRef->get_base(), indexer, env ) ) { 96 96 return Cost::safe; … … 104 104 } // if 105 105 } else { 106 std::cerr << "reference to rvalue conversion" << std::endl;106 // std::cerr << "reference to rvalue conversion" << std::endl; 107 107 ConversionCost converter( dest, indexer, env ); 108 108 src->accept( converter ); … … 113 113 assert( diff == -1 && destAsRef ); 114 114 if ( typesCompatibleIgnoreQualifiers( src, destAsRef->get_base(), indexer, env ) ) { 115 std::cerr << "converting compatible base type" << std::endl;115 // std::cerr << "converting compatible base type" << std::endl; 116 116 if ( src->get_lvalue() ) { 117 std::cerr << "lvalue to reference conversion" << std::endl;117 // std::cerr << "lvalue to reference conversion" << std::endl; 118 118 // lvalue-to-reference conversion: cv lvalue T => cv T & 119 119 if ( src->get_qualifiers() == destAsRef->get_base()->get_qualifiers() ) { … … 125 125 } // if 126 126 } else if ( destAsRef->get_base()->get_const() ) { 127 std::cerr << "rvalue to const ref conversion" << std::endl;127 // std::cerr << "rvalue to const ref conversion" << std::endl; 128 128 // rvalue-to-const-reference conversion: T => const T & 129 129 return Cost::safe; … … 134 134 } // if 135 135 } // if 136 std::cerr << "attempting to convert from incompatible base type -- fail" << std::endl;136 // std::cerr << "attempting to convert from incompatible base type -- fail" << std::endl; 137 137 } 138 138 return Cost::infinity; -
src/SymTab/Autogen.cc
r9236060 r74b007ba 156 156 } 157 157 158 /// true if the aggregate's layout is dynamic159 template< typename AggrDecl >160 bool hasDynamicLayout( AggrDecl * aggregateDecl ) {161 for ( TypeDecl * param : aggregateDecl->get_parameters() ) {162 if ( param->isComplete() ) return true;163 }164 return false;165 }166 167 158 /// generate a function decl from a name and type. Nesting depth determines whether 168 159 /// the declaration is static or not; optional paramter determines if declaration is intrinsic … … 310 301 311 302 /// generates a single struct member operation (constructor call, destructor call, assignment call) 312 void makeStructMemberOp( ObjectDecl * dstParam, Expression * src, DeclarationWithType * field, FunctionDecl * func, bool isDynamicLayout, boolforward = true ) {303 void makeStructMemberOp( ObjectDecl * dstParam, Expression * src, DeclarationWithType * field, FunctionDecl * func, bool forward = true ) { 313 304 InitTweak::InitExpander srcParam( src ); 314 305 … … 320 311 /// generates the body of a struct function by iterating the struct members (via parameters) - generates default ctor, copy ctor, assignment, and dtor bodies, but NOT field ctor bodies 321 312 template<typename Iterator> 322 void makeStructFunctionBody( Iterator member, Iterator end, FunctionDecl * func, bool isDynamicLayout, boolforward = true ) {313 void makeStructFunctionBody( Iterator member, Iterator end, FunctionDecl * func, bool forward = true ) { 323 314 for ( ; member != end; ++member ) { 324 315 if ( DeclarationWithType *field = dynamic_cast< DeclarationWithType * >( *member ) ) { // otherwise some form of type declaration, e.g. Aggregate … … 356 347 357 348 Expression *srcselect = srcParam ? new MemberExpr( field, new VariableExpr( srcParam ) ) : NULL; 358 makeStructMemberOp( dstParam, srcselect, field, func, isDynamicLayout,forward );349 makeStructMemberOp( dstParam, srcselect, field, func, forward ); 359 350 } // if 360 351 } // for … … 364 355 /// void ?{}(A *, int) and void?{}(A *, int, int) for a struct A which has two int fields. 365 356 template<typename Iterator> 366 void makeStructFieldCtorBody( Iterator member, Iterator end, FunctionDecl * func , bool isDynamicLayout) {357 void makeStructFieldCtorBody( Iterator member, Iterator end, FunctionDecl * func ) { 367 358 FunctionType * ftype = func->get_functionType(); 368 359 std::list<DeclarationWithType*> & params = ftype->get_parameters(); … … 390 381 // matching parameter, initialize field with copy ctor 391 382 Expression *srcselect = new VariableExpr(*parameter); 392 makeStructMemberOp( dstParam, srcselect, field, func , isDynamicLayout);383 makeStructMemberOp( dstParam, srcselect, field, func ); 393 384 ++parameter; 394 385 } else { 395 386 // no matching parameter, initialize field with default ctor 396 makeStructMemberOp( dstParam, NULL, field, func , isDynamicLayout);387 makeStructMemberOp( dstParam, NULL, field, func ); 397 388 } 398 389 } … … 410 401 // Make function polymorphic in same parameters as generic struct, if applicable 411 402 const std::list< TypeDecl* > & typeParams = aggregateDecl->get_parameters(); // List of type variables to be placed on the generated functions 412 bool isDynamicLayout = hasDynamicLayout( aggregateDecl ); // NOTE this flag is an incredibly ugly kludge; we should fix the assignment signature instead (ditto for union)413 403 414 404 // generate each of the functions based on the supplied FuncData objects … … 436 426 // destructor needs to do everything in reverse, so pass "forward" based on whether the function is a destructor 437 427 if ( ! CodeGen::isDestructor( dcl->get_name() ) ) { 438 makeStructFunctionBody( aggregateDecl->get_members().begin(), aggregateDecl->get_members().end(), dcl , isDynamicLayout);428 makeStructFunctionBody( aggregateDecl->get_members().begin(), aggregateDecl->get_members().end(), dcl ); 439 429 } else { 440 makeStructFunctionBody( aggregateDecl->get_members().rbegin(), aggregateDecl->get_members().rend(), dcl, isDynamicLayout,false );430 makeStructFunctionBody( aggregateDecl->get_members().rbegin(), aggregateDecl->get_members().rend(), dcl, false ); 441 431 } 442 432 if ( CodeGen::isAssignment( dcl->get_name() ) ) { … … 474 464 memCtorType->get_parameters().push_back( new ObjectDecl( member->get_name(), Type::StorageClasses(), LinkageSpec::Cforall, 0, member->get_type()->clone(), 0 ) ); 475 465 FunctionDecl * ctor = genFunc( "?{}", memCtorType->clone(), functionNesting ); 476 makeStructFieldCtorBody( aggregateDecl->get_members().begin(), aggregateDecl->get_members().end(), ctor , isDynamicLayout);466 makeStructFieldCtorBody( aggregateDecl->get_members().begin(), aggregateDecl->get_members().end(), ctor ); 477 467 declsToAdd.push_back( ctor ); 478 468 }
Note: See TracChangeset
for help on using the changeset viewer.