Changes in / [596f987b:66f8528]
- Location:
- src
- Files:
-
- 8 added
- 63 edited
Legend:
- Unmodified
- Added
- Removed
-
src/CodeGen/CodeGenerator.cc
r596f987b r66f8528 179 179 output << aggDecl->get_name(); 180 180 181 std::list< Declaration * > & memb = aggDecl->get_members();182 if ( ! memb.empty() ) {183 //if ( aggDecl->has_body() ) {184 //std::list< Declaration * > & memb = aggDecl->get_members();181 // std::list< Declaration * > & memb = aggDecl->get_members(); 182 // if ( ! memb.empty() ) { 183 if ( aggDecl->has_body() ) { 184 std::list< Declaration * > & memb = aggDecl->get_members(); 185 185 output << " {" << endl; 186 186 … … 291 291 } // if 292 292 output << " }"; 293 } 294 295 void CodeGenerator::visit( ConstructorInit * init ){ 296 assertf( false, "ConstructorInit nodes should not make it to CodeGen." ); 293 297 } 294 298 … … 917 921 } // switch 918 922 } 923 924 std::string genName( DeclarationWithType * decl ) { 925 CodeGen::OperatorInfo opInfo; 926 if ( operatorLookup( decl->get_name(), opInfo ) ) { 927 return opInfo.outputName; 928 } else { 929 return decl->get_name(); 930 } // if 931 } 919 932 } // namespace CodeGen 920 933 -
src/CodeGen/CodeGenerator.h
r596f987b r66f8528 47 47 virtual void visit( SingleInit * ); 48 48 virtual void visit( ListInit * ); 49 virtual void visit( ConstructorInit * ); 49 50 50 51 //*** Constant … … 144 145 return true; 145 146 } 147 148 /// returns C-compatible name of declaration 149 std::string genName( DeclarationWithType * decl ); 146 150 } // namespace CodeGen 147 151 -
src/GenPoly/Box.cc
r596f987b r66f8528 55 55 #include "Common/utility.h" 56 56 57 #include "InitTweak/InitTweak.h" 58 57 59 #include <ext/functional> // temporary 58 60 … … 98 100 void passArgTypeVars( ApplicationExpr *appExpr, Type *parmType, Type *argBaseType, std::list< Expression *>::iterator &arg, const TyVarMap &exprTyVars, std::set< std::string > &seenTypes ); 99 101 /// passes extra type parameters into a polymorphic function application 100 void passTypeVars( ApplicationExpr *appExpr, ReferenceToType *polyRetType, std::list< Expression *>::iterator &arg, const TyVarMap &exprTyVars );102 void passTypeVars( ApplicationExpr *appExpr, Type *polyRetType, std::list< Expression *>::iterator &arg, const TyVarMap &exprTyVars ); 101 103 /// wraps a function application with a new temporary for the out-parameter return value 102 104 Expression *addRetParam( ApplicationExpr *appExpr, FunctionType *function, Type *retType, std::list< Expression *>::iterator &arg ); … … 107 109 Type *replaceWithConcrete( ApplicationExpr *appExpr, Type *type, bool doClone = true ); 108 110 /// wraps a function application returning a polymorphic type with a new temporary for the out-parameter return value 109 Expression *addDynRetParam( ApplicationExpr *appExpr, FunctionType *function, ReferenceToType *polyType, std::list< Expression *>::iterator &arg );111 Expression *addDynRetParam( ApplicationExpr *appExpr, FunctionType *function, Type *polyType, std::list< Expression *>::iterator &arg ); 110 112 Expression *applyAdapter( ApplicationExpr *appExpr, FunctionType *function, std::list< Expression *>::iterator &arg, const TyVarMap &exprTyVars ); 111 113 void boxParam( Type *formal, Expression *&arg, const TyVarMap &exprTyVars ); … … 113 115 void addInferredParams( ApplicationExpr *appExpr, FunctionType *functionType, std::list< Expression *>::iterator &arg, const TyVarMap &tyVars ); 114 116 /// Stores assignment operators from assertion list in local map of assignment operations 115 void findTypeOps( const Type::ForallList &forall );116 117 void passAdapters( ApplicationExpr *appExpr, FunctionType *functionType, const TyVarMap &exprTyVars ); 117 118 FunctionDecl *makeAdapter( FunctionType *adaptee, FunctionType *realType, const std::string &mangleName, const TyVarMap &tyVars ); … … 121 122 ObjectDecl *makeTemporary( Type *type ); 122 123 123 ScopedMap< std::string, DeclarationWithType* > assignOps; ///< Currently known type variable assignment operators124 ScopedMap< std::string, DeclarationWithType* > ctorOps; ///< Currently known type variable constructors125 ScopedMap< std::string, DeclarationWithType* > copyOps; ///< Currently known type variable copy constructors126 ScopedMap< std::string, DeclarationWithType* > dtorOps; ///< Currently known type variable destructors127 ResolvExpr::TypeMap< DeclarationWithType > scopedAssignOps; ///< Currently known assignment operators128 ResolvExpr::TypeMap< DeclarationWithType > scopedCtorOps; ///< Currently known assignment operators129 ResolvExpr::TypeMap< DeclarationWithType > scopedCopyOps; ///< Currently known assignment operators130 ResolvExpr::TypeMap< DeclarationWithType > scopedDtorOps; ///< Currently known assignment operators131 124 ScopedMap< std::string, DeclarationWithType* > adapters; ///< Set of adapter functions in the current scope 132 125 126 std::map< ApplicationExpr *, Expression * > retVals; 127 133 128 DeclarationWithType *retval; 134 bool useRetval;135 129 UniqueName tempNamer; 136 130 }; … … 275 269 276 270 for ( std::list< TypeDecl* >::const_iterator decl = decls.begin(); decl != decls.end(); ++decl ) { 277 if ( (*decl)-> get_kind() == TypeDecl::Any) {271 if ( (*decl)->isComplete() ) { 278 272 otypeDecls.push_back( *decl ); 279 273 } … … 497 491 } 498 492 499 Pass1::Pass1() : useRetval( false ), tempNamer( "_temp" ) {} 500 501 /// Returns T if the given declaration is a function with parameter (T*) for some TypeInstType T, NULL otherwise 502 TypeInstType *isTypeInstPtrFn( DeclarationWithType *decl ) { 503 if ( FunctionType *funType = getFunctionType( decl->get_type() ) ) { 504 if ( funType->get_parameters().size() == 1 ) { 505 if ( PointerType *pointer = dynamic_cast< PointerType *>( funType->get_parameters().front()->get_type() ) ) { 506 if ( TypeInstType *refType = dynamic_cast< TypeInstType *>( pointer->get_base() ) ) { 507 return refType; 508 } // if 509 } // if 510 } // if 511 } // if 512 return 0; 513 } 514 515 /// Returns T if the given declaration is a function with parameters (T*, T) for some TypeInstType T, NULL otherwise 516 TypeInstType *isTypeInstPtrValFn( DeclarationWithType *decl ) { 517 if ( FunctionType *funType = getFunctionType( decl->get_type() ) ) { 518 if ( funType->get_parameters().size() == 2 ) { 519 if ( PointerType *pointer = dynamic_cast< PointerType *>( funType->get_parameters().front()->get_type() ) ) { 520 if ( TypeInstType *refType = dynamic_cast< TypeInstType *>( pointer->get_base() ) ) { 521 if ( TypeInstType *refType2 = dynamic_cast< TypeInstType *>( funType->get_parameters().back()->get_type() ) ) { 522 if ( refType->get_name() == refType2->get_name() ) { 523 return refType; 524 } // if 525 } // if 526 } // if 527 } // if 528 } // if 529 } // if 530 return 0; 531 } 532 533 /// Returns T if the given declaration is (*?=?)(T *, T) for some TypeInstType T (return not checked, but maybe should be), NULL otherwise 534 TypeInstType *isTypeInstAssignment( DeclarationWithType *decl ) { 535 return decl->get_name() == "?=?" ? isTypeInstPtrValFn( decl ) : 0; 536 } 537 538 /// Returns T if the given declaration is (*?{})(T *) for some TypeInstType T (return not checked, but maybe should be), NULL otherwise 539 TypeInstType *isTypeInstCtor( DeclarationWithType *decl ) { 540 return decl->get_name() == "?{}" ? isTypeInstPtrFn( decl ) : 0; 541 } 542 543 /// Returns T if the given declaration is (*?{})(T *, T) for some TypeInstType T (return not checked, but maybe should be), NULL otherwise 544 TypeInstType *isTypeInstCopy( DeclarationWithType *decl ) { 545 return decl->get_name() == "?{}" ? isTypeInstPtrValFn( decl ) : 0; 546 } 547 548 /// Returns T if the given declaration is (*^?{})(T *) for some TypeInstType T (return not checked, but maybe should be), NULL otherwise 549 TypeInstType *isTypeInstDtor( DeclarationWithType *decl ) { 550 return decl->get_name() == "^?{}" ? isTypeInstPtrFn( decl ) : 0; 551 } 552 553 /// Returns T if the given declaration is a function with parameters (T*, T) for some type T, where neither parameter is cv-qualified, 554 /// NULL otherwise 555 Type *isNoCvPtrFn( DeclarationWithType *decl ) { 556 if ( FunctionType *funType = getFunctionType( decl->get_type() ) ) { 557 if ( funType->get_parameters().size() == 1 ) { 558 Type::Qualifiers defaultQualifiers; 559 Type *paramType = funType->get_parameters().front()->get_type(); 560 if ( paramType->get_qualifiers() != defaultQualifiers ) return 0; 561 562 if ( PointerType *pointerType = dynamic_cast< PointerType* >( paramType ) ) { 563 Type *baseType = pointerType->get_base(); 564 if ( baseType->get_qualifiers() == defaultQualifiers ) { 565 return baseType; 566 } // if 567 } // if 568 } // if 569 } // if 570 return 0; 571 } 572 573 /// Returns T if the given declaration is a function with parameters (T*, T) for some type T, where neither parameter is cv-qualified, 574 /// NULL otherwise 575 Type *isNoCvPtrValFn( DeclarationWithType *decl ) { 576 if ( FunctionType *funType = getFunctionType( decl->get_type() ) ) { 577 if ( funType->get_parameters().size() == 2 ) { 578 Type::Qualifiers defaultQualifiers; 579 Type *paramType1 = funType->get_parameters().front()->get_type(); 580 if ( paramType1->get_qualifiers() != defaultQualifiers ) return 0; 581 Type *paramType2 = funType->get_parameters().back()->get_type(); 582 if ( paramType2->get_qualifiers() != defaultQualifiers ) return 0; 583 584 if ( PointerType *pointerType = dynamic_cast< PointerType* >( paramType1 ) ) { 585 Type *baseType1 = pointerType->get_base(); 586 if ( baseType1->get_qualifiers() != defaultQualifiers ) return 0; 587 SymTab::Indexer dummy; 588 if ( ResolvExpr::typesCompatible( baseType1, paramType2, dummy ) ) { 589 return baseType1; 590 } // if 591 } // if 592 } // if 593 } // if 594 return 0; 595 } 596 597 /// returns T if the given declaration is: (*?=?)(T *, T) for some type T (return not checked, but maybe should be), NULL otherwise 598 /// Only picks assignments where neither parameter is cv-qualified 599 Type *isAssignment( DeclarationWithType *decl ) { 600 return decl->get_name() == "?=?" ? isNoCvPtrValFn( decl ) : 0; 601 } 602 603 /// returns T if the given declaration is: (*?{})(T *) for some type T, NULL otherwise 604 /// Only picks ctors where the parameter is not cv-qualified 605 Type *isCtor( DeclarationWithType *decl ) { 606 return decl->get_name() == "?{}" ? isNoCvPtrFn( decl ) : 0; 607 } 608 609 /// returns T if the given declaration is: (*?{})(T *, T) for some type T (return not checked, but maybe should be), NULL otherwise 610 /// Only picks copy constructors where neither parameter is cv-qualified 611 Type *isCopy( DeclarationWithType *decl ) { 612 return decl->get_name() == "?{}" ? isNoCvPtrValFn( decl ) : 0; 613 } 614 615 /// returns T if the given declaration is: (*?{})(T *) for some type T, NULL otherwise 616 /// Only picks ctors where the parameter is not cv-qualified 617 Type *isDtor( DeclarationWithType *decl ) { 618 return decl->get_name() == "^?{}" ? isNoCvPtrFn( decl ) : 0; 619 } 620 621 void Pass1::findTypeOps( const Type::ForallList &forall ) { 622 // what if a nested function uses an assignment operator? 623 // assignOps.clear(); 624 for ( Type::ForallList::const_iterator i = forall.begin(); i != forall.end(); ++i ) { 625 for ( std::list< DeclarationWithType *>::const_iterator assert = (*i)->get_assertions().begin(); assert != (*i)->get_assertions().end(); ++assert ) { 626 std::string typeName; 627 if ( TypeInstType *typeInst = isTypeInstAssignment( *assert ) ) { 628 assignOps[ typeInst->get_name() ] = *assert; 629 } else if ( TypeInstType *typeInst = isTypeInstCtor( *assert ) ) { 630 ctorOps[ typeInst->get_name() ] = *assert; 631 } else if ( TypeInstType *typeInst = isTypeInstCopy( *assert ) ) { 632 copyOps[ typeInst->get_name() ] = *assert; 633 } else if ( TypeInstType *typeInst = isTypeInstDtor( *assert ) ) { 634 dtorOps[ typeInst->get_name() ] = *assert; 635 } // if 636 } // for 637 } // for 638 } 493 Pass1::Pass1() : tempNamer( "_temp" ) {} 639 494 640 495 DeclarationWithType *Pass1::mutate( FunctionDecl *functionDecl ) { 641 // if this is a assignment function, put it in the map for this scope642 if ( Type *paramType = isAssignment( functionDecl ) ) {643 if ( ! dynamic_cast< TypeInstType* >( paramType ) ) {644 scopedAssignOps.insert( paramType, functionDecl );645 }646 } else if ( Type *paramType = isCtor( functionDecl ) ) {647 if ( ! dynamic_cast< TypeInstType* >( paramType ) ) {648 scopedCtorOps.insert( paramType, functionDecl );649 }650 } else if ( Type *paramType = isCopy( functionDecl ) ) {651 if ( ! dynamic_cast< TypeInstType* >( paramType ) ) {652 scopedCopyOps.insert( paramType, functionDecl );653 }654 } else if ( Type *paramType = isDtor( functionDecl ) ) {655 if ( ! dynamic_cast< TypeInstType* >( paramType ) ) {656 scopedDtorOps.insert( paramType, functionDecl );657 }658 }659 660 496 if ( functionDecl->get_statements() ) { // empty routine body ? 661 497 doBeginScope(); 662 498 scopeTyVars.beginScope(); 663 assignOps.beginScope();664 ctorOps.beginScope();665 copyOps.beginScope();666 dtorOps.beginScope();667 499 668 500 DeclarationWithType *oldRetval = retval; 669 bool oldUseRetval = useRetval;670 501 671 502 // process polymorphic return value 672 retval = 0;673 if ( isDynRet( functionDecl->get_functionType() ) && functionDecl->get_linkage() == LinkageSpec::Cforall) {503 retval = nullptr; 504 if ( isDynRet( functionDecl->get_functionType() ) && functionDecl->get_linkage() != LinkageSpec::C ) { 674 505 retval = functionDecl->get_functionType()->get_returnVals().front(); 675 506 … … 683 514 FunctionType *functionType = functionDecl->get_functionType(); 684 515 makeTyVarMap( functionDecl->get_functionType(), scopeTyVars ); 685 findTypeOps( functionDecl->get_functionType()->get_forall() );686 516 687 517 std::list< DeclarationWithType *> ¶mList = functionType->get_parameters(); … … 700 530 if ( adapters.find( mangleName ) == adapters.end() ) { 701 531 std::string adapterName = makeAdapterName( mangleName ); 702 adapters.insert( std::pair< std::string, DeclarationWithType *>( mangleName, new ObjectDecl( adapterName, DeclarationNode::NoStorageClass, LinkageSpec::C, 0, new PointerType( Type::Qualifiers(), makeAdapterType( *funType, scopeTyVars ) ), 0) ) );532 adapters.insert( std::pair< std::string, DeclarationWithType *>( mangleName, new ObjectDecl( adapterName, DeclarationNode::NoStorageClass, LinkageSpec::C, nullptr, new PointerType( Type::Qualifiers(), makeAdapterType( *funType, scopeTyVars ) ), nullptr ) ) ); 703 533 } // if 704 534 } // for … … 707 537 708 538 scopeTyVars.endScope(); 709 assignOps.endScope();710 ctorOps.endScope();711 copyOps.endScope();712 dtorOps.endScope();713 539 retval = oldRetval; 714 useRetval = oldUseRetval;715 540 doEndScope(); 716 541 } // if … … 719 544 720 545 TypeDecl *Pass1::mutate( TypeDecl *typeDecl ) { 721 scopeTyVars[ typeDecl->get_name() ] = typeDecl->get_kind();546 addToTyVarMap( typeDecl, scopeTyVars ); 722 547 return Mutator::mutate( typeDecl ); 723 548 } 724 549 725 550 Expression *Pass1::mutate( CommaExpr *commaExpr ) { 726 bool oldUseRetval = useRetval; 727 useRetval = false; 551 // Attempting to find application expressions that were mutated by the copy constructor passes 552 // to use an explicit return variable, so that the variable can be reused as a parameter to the 553 // call rather than creating a new temp variable. Previously this step was an optimization, but 554 // with the introduction of tuples and UniqueExprs, it is necessary to ensure that they use the same variable. 555 // Essentially, looking for pattern: (x=f(...), x) 556 // To compound the issue, the right side can be *x, etc. because of lvalue-returning functions 557 if ( UntypedExpr * assign = dynamic_cast< UntypedExpr * >( commaExpr->get_arg1() ) ) { 558 if ( InitTweak::isAssignment( InitTweak::getFunctionName( assign ) ) ) { 559 assert( assign->get_args().size() == 2 ); 560 if ( ApplicationExpr * appExpr = dynamic_cast< ApplicationExpr * > ( assign->get_args().back() ) ) { 561 // first argument is assignable, so it must be an lvalue, so it should be legal to take its address. 562 retVals[appExpr] = assign->get_args().front(); 563 } 564 } 565 } 566 728 567 commaExpr->set_arg1( maybeMutate( commaExpr->get_arg1(), *this ) ); 729 useRetval = oldUseRetval;730 568 commaExpr->set_arg2( maybeMutate( commaExpr->get_arg2(), *this ) ); 731 569 return commaExpr; … … 733 571 734 572 Expression *Pass1::mutate( ConditionalExpr *condExpr ) { 735 bool oldUseRetval = useRetval;736 useRetval = false;737 573 condExpr->set_arg1( maybeMutate( condExpr->get_arg1(), *this ) ); 738 useRetval = oldUseRetval;739 574 condExpr->set_arg2( maybeMutate( condExpr->get_arg2(), *this ) ); 740 575 condExpr->set_arg3( maybeMutate( condExpr->get_arg3(), *this ) ); … … 769 604 } 770 605 771 void Pass1::passTypeVars( ApplicationExpr *appExpr, ReferenceToType *polyRetType, std::list< Expression *>::iterator &arg, const TyVarMap &exprTyVars ) {606 void Pass1::passTypeVars( ApplicationExpr *appExpr, Type *polyRetType, std::list< Expression *>::iterator &arg, const TyVarMap &exprTyVars ) { 772 607 // pass size/align for type variables 773 608 for ( TyVarMap::const_iterator tyParm = exprTyVars.begin(); tyParm != exprTyVars.end(); ++tyParm ) { 774 609 ResolvExpr::EqvClass eqvClass; 775 610 assert( env ); 776 if ( tyParm->second == TypeDecl::Any) {611 if ( tyParm->second.isComplete ) { 777 612 Type *concrete = env->lookup( tyParm->first ); 778 613 if ( concrete ) { … … 783 618 } else { 784 619 // xxx - should this be an assertion? 785 throw SemanticError( "unbound type variable: " + tyParm->first + " in application ", appExpr ); 620 std::string x = env ? toString( *env ) : "missing env"; 621 throw SemanticError( x + "\n" + "unbound type variable: " + tyParm->first + " in application ", appExpr ); 786 622 } // if 787 623 } // if … … 801 637 Type *concRetType = replaceWithConcrete( appExpr, polyRetType ); 802 638 passArgTypeVars( appExpr, polyRetType, concRetType, arg, exprTyVars, seenTypes ); 639 ++fnArg; // skip the return parameter in the argument list 803 640 } 804 641 805 642 // add type information args for presently unseen types in parameter list 806 643 for ( ; fnParm != funcType->get_parameters().end() && fnArg != appExpr->get_args().end(); ++fnParm, ++fnArg ) { 807 VariableExpr *fnArgBase = getBaseVar( *fnArg );808 if ( ! fnArgBase ) continue; // xxx - previously had check for non-empty fnArgBase results809 passArgTypeVars( appExpr, (*fnParm)->get_type(), fnArgBase->get_result(), arg, exprTyVars, seenTypes );644 if ( ! (*fnArg)->get_result() ) continue; 645 Type * argType = (*fnArg)->get_result(); 646 passArgTypeVars( appExpr, (*fnParm)->get_type(), argType, arg, exprTyVars, seenTypes ); 810 647 } 811 648 } … … 818 655 819 656 Expression *Pass1::addRetParam( ApplicationExpr *appExpr, FunctionType *function, Type *retType, std::list< Expression *>::iterator &arg ) { 820 // ***** Code Removal ***** After introducing a temporary variable for all return expressions, the following code appears superfluous.821 // if ( useRetval ) {822 // assert( retval );823 // arg = appExpr->get_args().insert( arg, new VariableExpr( retval ) );824 // arg++;825 // } else {826 827 657 // Create temporary to hold return value of polymorphic function and produce that temporary as a result 828 // using a comma expression. Possibly change comma expression into statement expression "{}" for multiple 829 // return values. 830 ObjectDecl *newObj = makeTemporary( retType->clone() ); 831 Expression *paramExpr = new VariableExpr( newObj ); 658 // using a comma expression. 659 assert( retType ); 660 661 Expression * paramExpr = nullptr; 662 // try to use existing return value parameter if it exists, otherwise create a new temporary 663 if ( retVals.count( appExpr ) ) { 664 paramExpr = retVals[appExpr]->clone(); 665 } else { 666 ObjectDecl *newObj = makeTemporary( retType->clone() ); 667 paramExpr = new VariableExpr( newObj ); 668 } 669 Expression * retExpr = paramExpr->clone(); 832 670 833 671 // If the type of the temporary is not polymorphic, box temporary by taking its address; 834 672 // otherwise the temporary is already boxed and can be used directly. 835 if ( ! isPolyType( newObj->get_type(), scopeTyVars, env ) ) {673 if ( ! isPolyType( paramExpr->get_result(), scopeTyVars, env ) ) { 836 674 paramExpr = new AddressExpr( paramExpr ); 837 675 } // if … … 839 677 arg++; 840 678 // Build a comma expression to call the function and emulate a normal return. 841 CommaExpr *commaExpr = new CommaExpr( appExpr, new VariableExpr( newObj ));679 CommaExpr *commaExpr = new CommaExpr( appExpr, retExpr ); 842 680 commaExpr->set_env( appExpr->get_env() ); 843 681 appExpr->set_env( 0 ); 844 682 return commaExpr; 845 // } // if846 // return appExpr;847 683 } 848 684 … … 859 695 Type *concrete = env->lookup( typeInst->get_name() ); 860 696 if ( concrete == 0 ) { 861 throw SemanticError( "Unbound type variable " + typeInst->get_name() + " in ", appExpr ); 697 // xxx - should this be an assertion? 698 std::string x = env ? toString( *env ) : "missing env"; 699 throw SemanticError( x + "\n" + "Unbound type variable " + typeInst->get_name() + " in ", appExpr ); 862 700 } // if 863 701 return concrete; … … 878 716 } 879 717 880 Expression *Pass1::addDynRetParam( ApplicationExpr *appExpr, FunctionType *function, ReferenceToType *dynType, std::list< Expression *>::iterator &arg ) {718 Expression *Pass1::addDynRetParam( ApplicationExpr *appExpr, FunctionType *function, Type *dynType, std::list< Expression *>::iterator &arg ) { 881 719 assert( env ); 882 720 Type *concrete = replaceWithConcrete( appExpr, dynType ); … … 956 794 for ( std::list< DeclarationWithType *>::iterator assert = (*tyVar)->get_assertions().begin(); assert != (*tyVar)->get_assertions().end(); ++assert ) { 957 795 InferredParams::const_iterator inferParam = appExpr->get_inferParams().find( (*assert)->get_uniqueId() ); 958 assert( inferParam != appExpr->get_inferParams().end() && "NOTE: Explicit casts of polymorphic functions to compatible monomorphic functions are currently unsupported" ); 796 if ( inferParam == appExpr->get_inferParams().end() ) { 797 std::cerr << "looking for assertion: " << (*assert) << std::endl << appExpr << std::endl; 798 } 799 assertf( inferParam != appExpr->get_inferParams().end(), "NOTE: Explicit casts of polymorphic functions to compatible monomorphic functions are currently unsupported" ); 959 800 Expression *newExpr = inferParam->second.expr->clone(); 960 801 addCast( newExpr, (*assert)->get_type(), tyVars ); … … 1267 1108 // } 1268 1109 // std::cerr << "\n"; 1269 bool oldUseRetval = useRetval;1270 useRetval = false;1271 1110 appExpr->get_function()->acceptMutator( *this ); 1272 1111 mutateAll( appExpr->get_args(), *this ); 1273 useRetval = oldUseRetval;1274 1112 1275 1113 assert( appExpr->get_function()->has_result() ); … … 1286 1124 std::list< Expression *>::iterator paramBegin = appExpr->get_args().begin(); 1287 1125 1288 TyVarMap exprTyVars( (TypeDecl::Kind)-1);1289 makeTyVarMap( function, exprTyVars ); 1126 TyVarMap exprTyVars( TypeDecl::Data{} ); 1127 makeTyVarMap( function, exprTyVars ); // xxx - should this take into account the variables already bound in scopeTyVars (i.e. remove them from exprTyVars?) 1290 1128 ReferenceToType *dynRetType = isDynRet( function, exprTyVars ); 1129 Type *concRetType = appExpr->get_result()->isVoid() ? nullptr : appExpr->get_result();// ?: dynRetType; // xxx - is concRetType a good name? 1291 1130 1292 1131 if ( dynRetType ) { 1293 ret = addDynRetParam( appExpr, function, dynRetType, arg ); 1294 } else if ( needsAdapter( function, scopeTyVars ) ) { 1132 ret = addDynRetParam( appExpr, function, concRetType, arg ); // xxx - used to use dynRetType instead of concRetType 1133 } else if ( needsAdapter( function, scopeTyVars ) && ! needsAdapter( function, exprTyVars) ) { // xxx - exprTyVars is used above...? 1134 // xxx - the ! needsAdapter check may be incorrect. It seems there is some situation where an adapter is applied where it shouldn't be, and this fixes it for some cases. More investigation is needed. 1135 1295 1136 // std::cerr << "needs adapter: "; 1296 1137 // printTyVarMap( std::cerr, scopeTyVars ); … … 1301 1142 arg = appExpr->get_args().begin(); 1302 1143 1303 passTypeVars( appExpr, dynRetType, arg, exprTyVars );1144 passTypeVars( appExpr, concRetType, arg, exprTyVars ); // xxx - used to use dynRetType instead of concRetType; this changed so that the correct type paramaters are passed for return types (it should be the concrete type's parameters, not the formal type's) 1304 1145 addInferredParams( appExpr, function, arg, exprTyVars ); 1305 1146 … … 1360 1201 } 1361 1202 1362 /// Wraps a function declaration in a new pointer-to-function variable expression1363 VariableExpr *wrapFunctionDecl( DeclarationWithType *functionDecl ) {1364 // line below cloned from FixFunction.cc1365 // xxx - functionObj is never added to a list of declarations...1366 ObjectDecl *functionObj = new ObjectDecl( functionDecl->get_name(), functionDecl->get_storageClass(), functionDecl->get_linkage(), 0,1367 new PointerType( Type::Qualifiers(), functionDecl->get_type()->clone() ), 0 );1368 functionObj->set_mangleName( functionDecl->get_mangleName() );1369 functionObj->set_scopeLevel( functionDecl->get_scopeLevel() );1370 return new VariableExpr( functionObj );1371 }1372 1373 /// Finds the operation declaration for a given type in one of the two maps1374 DeclarationWithType* findOpForType( Type *formalType, const ScopedMap< std::string, DeclarationWithType* >& ops, ResolvExpr::TypeMap< DeclarationWithType >& scopedOps ) {1375 if ( TypeInstType *formalTypeInstType = dynamic_cast< TypeInstType* >( formalType ) ) {1376 ScopedMap< std::string, DeclarationWithType *>::const_iterator opIt = ops.find( formalTypeInstType->get_name() );1377 return opIt == ops.end() ? 0 : opIt->second;1378 } else {1379 return scopedOps.find( formalType );1380 }1381 }1382 1383 /// Adds an assertion parameter to the application expression for the actual assertion declaration valued with the assert op1384 void addAssertionFor( ApplicationExpr *appExpr, DeclarationWithType *actualDecl, DeclarationWithType *assertOp ) {1385 appExpr->get_inferParams()[ actualDecl->get_uniqueId() ]1386 = ParamEntry( assertOp->get_uniqueId(), assertOp->get_type()->clone(), actualDecl->get_type()->clone(), wrapFunctionDecl( assertOp ) );1387 }1388 1389 1203 Statement * Pass1::mutate( ReturnStmt *returnStmt ) { 1204 // maybe need access to the env when mutating the expr 1205 if ( Expression * expr = returnStmt->get_expr() ) { 1206 if ( expr->get_env() ) { 1207 env = expr->get_env(); 1208 } 1209 } 1210 1390 1211 if ( retval && returnStmt->get_expr() ) { 1391 1212 assert( returnStmt->get_expr()->has_result() && ! returnStmt->get_expr()->get_result()->isVoid() ); 1392 // ***** Code Removal ***** After introducing a temporary variable for all return expressions, the following code appears superfluous. 1393 // if ( returnStmt->get_expr()->get_results().front()->get_isLvalue() ) { 1394 // by this point, a cast expr on a polymorphic return value is redundant 1395 while ( CastExpr *castExpr = dynamic_cast< CastExpr *>( returnStmt->get_expr() ) ) { 1396 returnStmt->set_expr( castExpr->get_arg() ); 1397 returnStmt->get_expr()->set_env( castExpr->get_env() ); 1398 castExpr->set_env( 0 ); 1399 castExpr->set_arg( 0 ); 1400 delete castExpr; 1401 } //while 1402 1403 // find assignment operator for (polymorphic) return type 1404 ApplicationExpr *assignExpr = 0; 1405 if ( TypeInstType *typeInst = dynamic_cast< TypeInstType *>( retval->get_type() ) ) { 1406 // find assignment operator for type variable 1407 ScopedMap< std::string, DeclarationWithType *>::const_iterator assignIter = assignOps.find( typeInst->get_name() ); 1408 if ( assignIter == assignOps.end() ) { 1409 throw SemanticError( "Attempt to return dtype or ftype object in ", returnStmt->get_expr() ); 1410 } // if 1411 assignExpr = new ApplicationExpr( new VariableExpr( assignIter->second ) ); 1412 } else if ( ReferenceToType *refType = dynamic_cast< ReferenceToType *>( retval->get_type() ) ) { 1413 // find assignment operator for generic type 1414 DeclarationWithType *functionDecl = scopedAssignOps.find( refType ); 1415 if ( ! functionDecl ) { 1416 throw SemanticError( "Attempt to return dtype or ftype generic object in ", returnStmt->get_expr() ); 1417 } 1418 1419 // wrap it up in an application expression 1420 assignExpr = new ApplicationExpr( wrapFunctionDecl( functionDecl ) ); 1421 assignExpr->set_env( env->clone() ); 1422 1423 // find each of its needed secondary assignment operators 1424 std::list< Expression* > &tyParams = refType->get_parameters(); 1425 Type::ForallList &forallParams = functionDecl->get_type()->get_forall(); 1426 std::list< Expression* >::const_iterator tyIt = tyParams.begin(); 1427 Type::ForallList::const_iterator forallIt = forallParams.begin(); 1428 for ( ; tyIt != tyParams.end() && forallIt != forallParams.end(); ++tyIt, ++forallIt ) { 1429 // Add appropriate mapping to assignment expression environment 1430 TypeExpr *formalTypeExpr = dynamic_cast< TypeExpr* >( *tyIt ); 1431 assert( formalTypeExpr && "type parameters must be type expressions" ); 1432 Type *formalType = formalTypeExpr->get_type(); 1433 assignExpr->get_env()->add( (*forallIt)->get_name(), formalType ); 1434 1435 // skip non-otype parameters (ftype/dtype) 1436 if ( (*forallIt)->get_kind() != TypeDecl::Any ) continue; 1437 1438 // find otype operators for formal type 1439 DeclarationWithType *assertAssign = findOpForType( formalType, assignOps, scopedAssignOps ); 1440 if ( ! assertAssign ) throw SemanticError( "No assignment operation found for ", formalType ); 1441 1442 DeclarationWithType *assertCtor = findOpForType( formalType, ctorOps, scopedCtorOps ); 1443 if ( ! assertCtor ) throw SemanticError( "No default constructor found for ", formalType ); 1444 1445 DeclarationWithType *assertCopy = findOpForType( formalType, copyOps, scopedCopyOps ); 1446 if ( ! assertCopy ) throw SemanticError( "No copy constructor found for ", formalType ); 1447 1448 DeclarationWithType *assertDtor = findOpForType( formalType, dtorOps, scopedDtorOps ); 1449 if ( ! assertDtor ) throw SemanticError( "No destructor found for ", formalType ); 1450 1451 // add inferred parameters for otype operators to assignment expression 1452 // NOTE: Code here assumes that first four assertions are assign op, ctor, copy ctor, dtor, in that order 1453 std::list< DeclarationWithType* > &asserts = (*forallIt)->get_assertions(); 1454 assert( asserts.size() >= 4 && "Type param needs otype operator assertions" ); 1455 1456 std::list< DeclarationWithType* >::iterator actualIt = asserts.begin(); 1457 addAssertionFor( assignExpr, *actualIt, assertAssign ); 1458 ++actualIt; 1459 addAssertionFor( assignExpr, *actualIt, assertCtor ); 1460 ++actualIt; 1461 addAssertionFor( assignExpr, *actualIt, assertCopy ); 1462 ++actualIt; 1463 addAssertionFor( assignExpr, *actualIt, assertDtor ); 1464 1465 } 1466 } 1467 assert( assignExpr ); 1468 1469 // replace return statement with appropriate assignment to out parameter 1470 Expression *retParm = new NameExpr( retval->get_name() ); 1471 retParm->set_result( new PointerType( Type::Qualifiers(), retval->get_type()->clone() ) ); 1472 assignExpr->get_args().push_back( retParm ); 1473 assignExpr->get_args().push_back( returnStmt->get_expr() ); 1474 stmtsToAdd.push_back( new ExprStmt( noLabels, mutateExpression( assignExpr ) ) ); 1475 // } else { 1476 // useRetval = true; 1477 // stmtsToAdd.push_back( new ExprStmt( noLabels, mutateExpression( returnStmt->get_expr() ) ) ); 1478 // useRetval = false; 1479 // } // if 1213 delete returnStmt->get_expr(); 1480 1214 returnStmt->set_expr( 0 ); 1481 1215 } else { … … 1507 1241 void Pass1::doBeginScope() { 1508 1242 adapters.beginScope(); 1509 scopedAssignOps.beginScope();1510 scopedCtorOps.beginScope();1511 scopedCopyOps.beginScope();1512 scopedDtorOps.beginScope();1513 1243 } 1514 1244 1515 1245 void Pass1::doEndScope() { 1516 1246 adapters.endScope(); 1517 scopedAssignOps.endScope();1518 scopedCtorOps.endScope();1519 scopedCopyOps.endScope();1520 scopedDtorOps.endScope();1521 1247 } 1522 1248 … … 1550 1276 } 1551 1277 1278 /// determines if `pref` is a prefix of `str` 1279 bool isPrefix( const std::string & str, const std::string & pref ) { 1280 if ( pref.size() > str.size() ) return false; 1281 auto its = std::mismatch( pref.begin(), pref.end(), str.begin() ); 1282 return its.first == pref.end(); 1283 } 1284 1552 1285 DeclarationWithType * Pass2::mutate( FunctionDecl *functionDecl ) { 1553 return handleDecl( functionDecl, functionDecl->get_functionType() ); 1286 functionDecl = safe_dynamic_cast< FunctionDecl * > ( handleDecl( functionDecl, functionDecl->get_functionType() ) ); 1287 FunctionType * ftype = functionDecl->get_functionType(); 1288 if ( ! ftype->get_returnVals().empty() && functionDecl->get_statements() ) { 1289 if ( functionDecl->get_name() != "?=?" && ! isPrefix( functionDecl->get_name(), "_thunk" ) ) { // xxx - remove check for ?=? once reference types are in; remove check for prefix once thunks properly use ctor/dtors 1290 assert( ftype->get_returnVals().size() == 1 ); 1291 DeclarationWithType * retval = ftype->get_returnVals().front(); 1292 if ( retval->get_name() == "" ) { 1293 retval->set_name( "_retval" ); 1294 } 1295 functionDecl->get_statements()->get_kids().push_front( new DeclStmt( noLabels, retval ) ); 1296 DeclarationWithType * newRet = retval->clone(); // for ownership purposes 1297 ftype->get_returnVals().front() = newRet; 1298 } 1299 } 1300 return functionDecl; 1554 1301 } 1555 1302 … … 1559 1306 1560 1307 TypeDecl * Pass2::mutate( TypeDecl *typeDecl ) { 1561 scopeTyVars[ typeDecl->get_name() ] = typeDecl->get_kind();1308 addToTyVarMap( typeDecl, scopeTyVars ); 1562 1309 if ( typeDecl->get_base() ) { 1563 1310 return handleDecl( typeDecl, typeDecl->get_base() ); … … 1587 1334 // move polymorphic return type to parameter list 1588 1335 if ( isDynRet( funcType ) ) { 1589 DeclarationWithType *ret = funcType->get_returnVals().front();1336 ObjectDecl *ret = safe_dynamic_cast< ObjectDecl* >( funcType->get_returnVals().front() ); 1590 1337 ret->set_type( new PointerType( Type::Qualifiers(), ret->get_type() ) ); 1591 1338 funcType->get_parameters().push_front( ret ); 1592 1339 funcType->get_returnVals().pop_front(); 1340 ret->set_init( nullptr ); // xxx - memory leak? 1593 1341 } 1594 1342 … … 1602 1350 ObjectDecl *sizeParm, *alignParm; 1603 1351 // add all size and alignment parameters to parameter list 1604 if ( (*tyParm)-> get_kind() == TypeDecl::Any) {1352 if ( (*tyParm)->isComplete() ) { 1605 1353 TypeInstType parmType( Type::Qualifiers(), (*tyParm)->get_name(), *tyParm ); 1606 1354 std::string parmName = mangleType( &parmType ); … … 1711 1459 1712 1460 TypeDecl * PolyGenericCalculator::mutate( TypeDecl *typeDecl ) { 1713 scopeTyVars[ typeDecl->get_name() ] = typeDecl->get_kind();1461 addToTyVarMap( typeDecl, scopeTyVars ); 1714 1462 return Parent::mutate( typeDecl ); 1715 1463 } … … 1825 1573 // replace member expression with pointer to base plus offset 1826 1574 UntypedExpr *fieldLoc = new UntypedExpr( new NameExpr( "?+?" ) ); 1827 fieldLoc->get_args().push_back( makeDerefdVar( varExpr->clone(), varDepth ) ); 1575 Expression * aggr = memberExpr->get_aggregate()->clone(); 1576 delete aggr->get_env(); // xxx - there's a problem with keeping the env for some reason, so for now just get rid of it 1577 aggr->set_env( nullptr ); 1578 fieldLoc->get_args().push_back( aggr ); 1828 1579 fieldLoc->get_args().push_back( makeOffsetIndex( objectType, i ) ); 1829 1580 newMemberExpr = fieldLoc; … … 1875 1626 for ( ; baseParam != baseParams.end() && typeParam != typeParams.end(); ++baseParam, ++typeParam ) { 1876 1627 // skip non-otype parameters 1877 if ( (*baseParam)->get_kind() != TypeDecl::Any) continue;1628 if ( ! (*baseParam)->isComplete() ) continue; 1878 1629 TypeExpr *typeExpr = dynamic_cast< TypeExpr* >( *typeParam ); 1879 1630 assert( typeExpr && "all otype parameters should be type expressions" ); … … 2087 1838 // Initializer *init = 0; 2088 1839 // std::list< Expression *> designators; 2089 // scopeTyVars[ typeDecl->get_name() ] = typeDecl->get_kind();1840 // addToTyVarMap( typeDecl, scopeTyVars ); 2090 1841 // if ( typeDecl->get_base() ) { 2091 1842 // init = new SimpleInit( new SizeofExpr( handleDecl( typeDecl, typeDecl->get_base() ) ), designators ); … … 2093 1844 // return new ObjectDecl( typeDecl->get_name(), Declaration::Extern, LinkageSpec::C, 0, new BasicType( Type::Qualifiers(), BasicType::UnsignedInt ), init ); 2094 1845 2095 scopeTyVars[ typeDecl->get_name() ] = typeDecl->get_kind();1846 addToTyVarMap( typeDecl, scopeTyVars ); 2096 1847 return Mutator::mutate( typeDecl ); 2097 1848 } -
src/GenPoly/CopyParams.cc
r596f987b r66f8528 38 38 }; 39 39 40 /// creates local copies of polymorphic function parameters 40 41 void copyParams( std::list< Declaration* > &translationUnit ) { 41 42 CopyParams copier; … … 53 54 if ( ! modVars.empty() ) { 54 55 std::map< std::string, DeclarationWithType* > assignOps; 56 // xxx - this needs to use constructors, not assignment operators 55 57 // assume the assignment operator is the first assert param after any "type" parameter 56 58 for ( Type::ForallList::const_iterator tyVar = funcDecl->get_functionType()->get_forall().begin(); tyVar != funcDecl->get_functionType()->get_forall().end(); ++tyVar ) { -
src/GenPoly/GenPoly.cc
r596f987b r66f8528 92 92 } 93 93 94 Type *isDynType( Type *type, const TyVarMap &tyVars, const TypeSubstitution *env ) {94 ReferenceToType *isDynType( Type *type, const TyVarMap &tyVars, const TypeSubstitution *env ) { 95 95 type = replaceTypeInst( type, env ); 96 96 97 97 if ( TypeInstType *typeInst = dynamic_cast< TypeInstType * >( type ) ) { 98 98 auto var = tyVars.find( typeInst->get_name() ); 99 if ( var != tyVars.end() && var->second == TypeDecl::Any) {100 return type ;99 if ( var != tyVars.end() && var->second.isComplete ) { 100 return typeInst; 101 101 } 102 102 } else if ( StructInstType *structType = dynamic_cast< StructInstType* >( type ) ) { 103 if ( hasDynParams( structType->get_parameters(), tyVars, env ) ) return type;103 if ( hasDynParams( structType->get_parameters(), tyVars, env ) ) return structType; 104 104 } else if ( UnionInstType *unionType = dynamic_cast< UnionInstType* >( type ) ) { 105 if ( hasDynParams( unionType->get_parameters(), tyVars, env ) ) return type;105 if ( hasDynParams( unionType->get_parameters(), tyVars, env ) ) return unionType; 106 106 } 107 107 return 0; … … 117 117 if ( function->get_returnVals().empty() ) return 0; 118 118 119 TyVarMap forallTypes( (TypeDecl::Kind)-1);119 TyVarMap forallTypes( TypeDecl::Data{} ); 120 120 makeTyVarMap( function, forallTypes ); 121 121 return (ReferenceToType*)isDynType( function->get_returnVals().front()->get_type(), forallTypes ); … … 219 219 expr = commaExpr->get_arg2(); 220 220 continue; 221 } else if ( ConditionalExpr * condExpr = dynamic_cast< ConditionalExpr * >( expr ) ) { 222 int lvl1; 223 int lvl2; 224 VariableExpr * var1 = getBaseVar( condExpr->get_arg2(), &lvl1 ); 225 VariableExpr * var2 = getBaseVar( condExpr->get_arg3(), &lvl2 ); 226 if ( lvl1 == lvl2 && var1 && var2 && var1->get_var() == var2->get_var() ) { 227 *levels = lvl1; 228 return var1; 229 } 230 break; 221 231 } else break; 222 232 … … 225 235 226 236 return 0; 237 } 238 239 void addToTyVarMap( TypeDecl * tyVar, TyVarMap &tyVarMap ) { 240 tyVarMap[ tyVar->get_name() ] = TypeDecl::Data{ tyVar }; 227 241 } 228 242 … … 230 244 for ( Type::ForallList::const_iterator tyVar = type->get_forall().begin(); tyVar != type->get_forall().end(); ++tyVar ) { 231 245 assert( *tyVar ); 232 tyVarMap[ (*tyVar)->get_name() ] = (*tyVar)->get_kind();246 addToTyVarMap( *tyVar, tyVarMap ); 233 247 } 234 248 if ( PointerType *pointer = dynamic_cast< PointerType* >( type ) ) { -
src/GenPoly/GenPoly.h
r596f987b r66f8528 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // GenPoly.h -- 7 // GenPoly.h -- 8 8 // 9 9 // Author : Richard C. Bilson … … 30 30 31 31 namespace GenPoly { 32 typedef ErasableScopedMap< std::string, TypeDecl:: Kind> TyVarMap;32 typedef ErasableScopedMap< std::string, TypeDecl::Data > TyVarMap; 33 33 34 34 /// Replaces a TypeInstType by its referrent in the environment, if applicable 35 35 Type* replaceTypeInst( Type* type, const TypeSubstitution* env ); 36 36 37 37 /// returns polymorphic type if is polymorphic type, NULL otherwise; will look up substitution in env if provided 38 38 Type *isPolyType( Type *type, const TypeSubstitution *env = 0 ); 39 39 40 40 /// returns polymorphic type if is polymorphic type in tyVars, NULL otherwise; will look up substitution in env if provided 41 41 Type *isPolyType( Type *type, const TyVarMap &tyVars, const TypeSubstitution *env = 0 ); 42 42 43 43 /// returns dynamic-layout type if is dynamic-layout type in tyVars, NULL otherwise; will look up substitution in env if provided 44 Type *isDynType( Type *type, const TyVarMap &tyVars, const TypeSubstitution *env = 0 );44 ReferenceToType *isDynType( Type *type, const TyVarMap &tyVars, const TypeSubstitution *env = 0 ); 45 45 46 46 /// true iff function has dynamic-layout return type under the given type variable map … … 55 55 /// returns polymorphic type if is pointer to polymorphic type, NULL otherwise; will look up substitution in env if provided 56 56 Type *isPolyPtr( Type *type, const TypeSubstitution *env = 0 ); 57 57 58 58 /// returns polymorphic type if is pointer to polymorphic type in tyVars, NULL otherwise; will look up substitution in env if provided 59 59 Type *isPolyPtr( Type *type, const TyVarMap &tyVars, const TypeSubstitution *env = 0 ); … … 74 74 VariableExpr *getBaseVar( Expression *expr, int *levels = 0 ); 75 75 76 /// Adds the type variable `tyVar` to `tyVarMap` 77 void addToTyVarMap( TypeDecl * tyVar, TyVarMap &tyVarMap ); 78 76 79 /// Adds the declarations in the forall list of type (and its pointed-to type if it's a pointer type) to `tyVarMap` 77 80 void makeTyVarMap( Type *type, TyVarMap &tyVarMap ); 78 81 79 82 /// Prints type variable map 80 83 void printTyVarMap( std::ostream &os, const TyVarMap &tyVarMap ); … … 82 85 /// Gets the mangled name of this type; alias for SymTab::Mangler::mangleType(). 83 86 inline std::string mangleType( Type *ty ) { return SymTab::Mangler::mangleType( ty ); } 84 87 85 88 /// Gets the name of the sizeof parameter for the type, given its mangled name 86 89 inline std::string sizeofName( const std::string &name ) { return std::string( "_sizeof_" ) + name; } … … 94 97 /// Gets the name of the layout function for a given aggregate type, given its declaration 95 98 inline std::string layoutofName( AggregateDecl *decl ) { return std::string( "_layoutof_" ) + decl->get_name(); } 96 99 97 100 } // namespace GenPoly 98 101 -
src/GenPoly/InstantiateGeneric.cc
r596f987b r66f8528 284 284 // set concDecl to new type, insert type declaration into statements to add 285 285 concDecl = new StructDecl( typeNamer.newName( inst->get_name() ) ); 286 concDecl->set_body( inst->get_baseStruct()->has_body() ); 286 287 substituteMembers( inst->get_baseStruct()->get_members(), *inst->get_baseParameters(), typeSubs, concDecl->get_members() ); 287 288 DeclMutator::addDeclaration( concDecl ); … … 337 338 // set concDecl to new type, insert type declaration into statements to add 338 339 concDecl = new UnionDecl( typeNamer.newName( inst->get_name() ) ); 340 concDecl->set_body( inst->get_baseUnion()->has_body() ); 339 341 substituteMembers( inst->get_baseUnion()->get_members(), *inst->get_baseParameters(), typeSubs, concDecl->get_members() ); 340 342 DeclMutator::addDeclaration( concDecl ); -
src/GenPoly/PolyMutator.cc
r596f987b r66f8528 23 23 24 24 namespace GenPoly { 25 namespace { 26 const std::list<Label> noLabels; 27 } 28 29 PolyMutator::PolyMutator() : scopeTyVars( (TypeDecl::Kind)-1 ), env( 0 ) {} 25 PolyMutator::PolyMutator() : scopeTyVars( TypeDecl::Data{} ), env( 0 ) {} 30 26 31 27 void PolyMutator::mutateStatementList( std::list< Statement* > &statements ) { … … 149 145 } 150 146 147 Expression *PolyMutator::mutate( StmtExpr * stmtExpr ) { 148 // don't want statements from outer CompoundStmts to be added to this StmtExpr 149 ValueGuard< std::list< Statement* > > oldStmtsToAdd( stmtsToAdd ); 150 ValueGuard< std::list< Statement* > > oldStmtsToAddAfter( stmtsToAddAfter ); 151 ValueGuard< TypeSubstitution * > oldEnv( env ); 152 153 // xxx - not sure if this is needed, along with appropriate reset, but I don't think so... 154 // ValueGuard< TyVarMap > oldScopeTyVars( scopeTyVars ); 155 156 stmtsToAdd.clear(); 157 stmtsToAddAfter.clear(); 158 // scopeTyVars.clear(); 159 160 return Parent::mutate( stmtExpr ); 161 } 151 162 152 163 Initializer *PolyMutator::mutate( SingleInit *singleInit ) { … … 154 165 return singleInit; 155 166 } 156 157 167 } // namespace GenPoly 158 168 -
src/GenPoly/PolyMutator.h
r596f987b r66f8528 47 47 48 48 virtual Expression* mutate(UntypedExpr *untypedExpr); 49 virtual Expression* mutate( StmtExpr *stmtExpr ); 49 50 50 51 virtual Initializer* mutate(SingleInit *SingleInit); -
src/GenPoly/ScrubTyVars.cc
r596f987b r66f8528 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // ScrubTyVars.cc -- 7 // ScrubTyVars.cc -- 8 8 // 9 9 // Author : Richard C. Bilson … … 28 28 TyVarMap::const_iterator tyVar = tyVars.find( typeInst->get_name() ); 29 29 if ( tyVar != tyVars.end() ) { 30 switch ( tyVar->second ) {30 switch ( tyVar->second.kind ) { 31 31 case TypeDecl::Any: 32 32 case TypeDecl::Dtype: … … 52 52 return ty; 53 53 } 54 54 55 55 Type * ScrubTyVars::mutate( StructInstType *structInst ) { 56 56 return mutateAggregateType( structInst ); -
src/InitTweak/FixInit.cc
r596f987b r66f8528 49 49 namespace InitTweak { 50 50 namespace { 51 typedef std::unordered_map< Expression *, TypeSubstitution * > EnvMap; 52 51 53 class InsertImplicitCalls final : public GenPoly::PolyMutator { 52 54 public: 53 55 /// wrap function application expressions as ImplicitCopyCtorExpr nodes so that it is easy to identify which 54 56 /// function calls need their parameters to be copy constructed 55 static void insert( std::list< Declaration * > & translationUnit ); 56 57 using GenPoly::PolyMutator::mutate; 57 static void insert( std::list< Declaration * > & translationUnit, EnvMap & envMap ); 58 59 InsertImplicitCalls( EnvMap & envMap ) : envMap( envMap ) {} 60 typedef GenPoly::PolyMutator Parent; 61 using Parent::mutate; 58 62 virtual Expression * mutate( ApplicationExpr * appExpr ) override; 63 virtual Expression * mutate( StmtExpr * stmtExpr ) override; 64 65 // collects environments for relevant nodes 66 EnvMap & envMap; 59 67 }; 60 68 … … 64 72 /// generate/resolve copy construction expressions for each, and generate/resolve destructors for both 65 73 /// arguments and return value temporaries 66 static void resolveImplicitCalls( std::list< Declaration * > & translationUnit );74 static void resolveImplicitCalls( std::list< Declaration * > & translationUnit, const EnvMap & envMap ); 67 75 68 76 typedef SymTab::Indexer Parent; 69 77 using Parent::visit; 70 78 79 ResolveCopyCtors( const EnvMap & envMap ) : envMap( envMap ) {} 80 71 81 virtual void visit( ImplicitCopyCtorExpr * impCpCtorExpr ) override; 72 virtual void visit( UniqueExpr * unqExpr ); 82 virtual void visit( UniqueExpr * unqExpr ) override; 83 virtual void visit( StmtExpr * stmtExpr ) override; 73 84 74 85 /// create and resolve ctor/dtor expression: fname(var, [cpArg]) … … 79 90 void copyConstructArg( Expression *& arg, ImplicitCopyCtorExpr * impCpCtorExpr ); 80 91 void destructRet( Expression * ret, ImplicitCopyCtorExpr * impCpCtorExpr ); 81 private: 92 82 93 TypeSubstitution * env; 94 const EnvMap & envMap; 83 95 }; 84 96 … … 174 186 static void fixInitializers( std::list< Declaration * > &translationUnit ); 175 187 176 using GenPoly::PolyMutator::mutate; 188 typedef GenPoly::PolyMutator Parent; 189 using Parent::mutate; 177 190 virtual DeclarationWithType * mutate( ObjectDecl *objDecl ) override; 178 191 … … 186 199 static void fixCopyCtors( std::list< Declaration * > &translationUnit ); 187 200 188 using GenPoly::PolyMutator::mutate; 201 typedef GenPoly::PolyMutator Parent; 202 using Parent::mutate; 189 203 virtual Expression * mutate( ImplicitCopyCtorExpr * impCpCtorExpr ) override; 190 204 virtual Expression * mutate( UniqueExpr * unqExpr ) override; 205 virtual Expression * mutate( StmtExpr * stmtExpr ) override; 191 206 }; 192 207 … … 248 263 InitTweak::fixGlobalInit( translationUnit, filename, inLibrary ); 249 264 250 251 InsertImplicitCalls::insert( translationUnit ); 252 ResolveCopyCtors::resolveImplicitCalls( translationUnit ); 265 EnvMap envMap; 266 267 InsertImplicitCalls::insert( translationUnit, envMap ); 268 ResolveCopyCtors::resolveImplicitCalls( translationUnit, envMap ); 253 269 InsertDtors::insert( translationUnit ); 254 270 FixInit::fixInitializers( translationUnit ); … … 269 285 270 286 namespace { 271 void InsertImplicitCalls::insert( std::list< Declaration * > & translationUnit ) {272 InsertImplicitCalls inserter ;287 void InsertImplicitCalls::insert( std::list< Declaration * > & translationUnit, EnvMap & envMap ) { 288 InsertImplicitCalls inserter( envMap ); 273 289 mutateAll( translationUnit, inserter ); 274 290 } 275 291 276 void ResolveCopyCtors::resolveImplicitCalls( std::list< Declaration * > & translationUnit ) {277 ResolveCopyCtors resolver ;292 void ResolveCopyCtors::resolveImplicitCalls( std::list< Declaration * > & translationUnit, const EnvMap & envMap ) { 293 ResolveCopyCtors resolver( envMap ); 278 294 acceptAll( translationUnit, resolver ); 279 295 } … … 326 342 327 343 Expression * InsertImplicitCalls::mutate( ApplicationExpr * appExpr ) { 328 appExpr = dynamic_cast< ApplicationExpr * >( Mutator::mutate( appExpr ) );344 appExpr = dynamic_cast< ApplicationExpr * >( Parent::mutate( appExpr ) ); 329 345 assert( appExpr ); 330 346 … … 339 355 Type * t1 = ftype->get_parameters().front()->get_type(); 340 356 Type * t2 = ftype->get_parameters().back()->get_type(); 341 PointerType * ptrType = dynamic_cast< PointerType * > ( t1 ); 342 assert( ptrType ); 357 PointerType * ptrType = safe_dynamic_cast< PointerType * > ( t1 ); 343 358 344 359 if ( ResolvExpr::typesCompatible( ptrType->get_base(), t2, SymTab::Indexer() ) ) { … … 357 372 // wrap each function call so that it is easy to identify nodes that have to be copy constructed 358 373 ImplicitCopyCtorExpr * expr = new ImplicitCopyCtorExpr( appExpr ); 359 // save the type substitution onto the new nodeso that it is easy to find.374 // save the type substitution into the envMap so that it is easy to find. 360 375 // Ensure it is not deleted with the ImplicitCopyCtorExpr by removing it before deletion. 361 376 // The substitution is needed to obtain the type of temporary variables so that copy constructor … … 366 381 // constructor calls together. 367 382 assert( env ); 368 e xpr->set_env( env );383 envMap[expr] = env; 369 384 return expr; 385 } 386 387 Expression * InsertImplicitCalls::mutate( StmtExpr * stmtExpr ) { 388 assert( env ); 389 envMap[stmtExpr] = env; 390 return Parent::mutate( stmtExpr ); 370 391 } 371 392 … … 392 413 assert( resolved ); 393 414 if ( resolved->get_env() ) { 415 // Extract useful information and discard new environments. Keeping them causes problems in PolyMutator passes. 394 416 env->add( *resolved->get_env() ); 417 delete resolved->get_env(); 418 resolved->set_env( nullptr ); 395 419 } // if 396 420 … … 401 425 void ResolveCopyCtors::copyConstructArg( Expression *& arg, ImplicitCopyCtorExpr * impCpCtorExpr ) { 402 426 static UniqueName tempNamer("_tmp_cp"); 403 CP_CTOR_PRINT( std::cerr << "Type Substitution: " << *impCpCtorExpr->get_env() << std::endl; ) 427 assert( env ); 428 CP_CTOR_PRINT( std::cerr << "Type Substitution: " << *env << std::endl; ) 404 429 assert( arg->has_result() ); 405 430 Type * result = arg->get_result(); … … 408 433 // type may involve type variables, so apply type substitution to get temporary variable's actual type 409 434 result = result->clone(); 410 impCpCtorExpr->get_env()->apply( result );435 env->apply( result ); 411 436 ObjectDecl * tmp = new ObjectDecl( tempNamer.newName(), DeclarationNode::NoStorageClass, LinkageSpec::C, 0, result, 0 ); 412 437 tmp->get_type()->set_isConst( false ); … … 437 462 CP_CTOR_PRINT( std::cerr << "ResolveCopyCtors: " << impCpCtorExpr << std::endl; ) 438 463 Parent::visit( impCpCtorExpr ); 439 env = impCpCtorExpr->get_env(); // xxx - maybe we really should just have a PolyIndexer... 464 env = envMap.at(impCpCtorExpr); 465 assert( env ); 440 466 441 467 ApplicationExpr * appExpr = impCpCtorExpr->get_callExpr(); … … 448 474 // each return value from the call needs to be connected with an ObjectDecl at the call site, which is 449 475 // initialized with the return value and is destructed later 450 // xxx - handle multiple return values 451 ApplicationExpr * callExpr = impCpCtorExpr->get_callExpr(); 452 // xxx - is this right? callExpr may not have the right environment, because it was attached at a higher 453 // level. Trying to pass that environment along. 454 callExpr->set_env( impCpCtorExpr->get_env()->clone() ); 476 // xxx - handle named return values? 455 477 Type * result = appExpr->get_result(); 456 478 if ( ! result->isVoid() ) { 457 479 static UniqueName retNamer("_tmp_cp_ret"); 458 480 result = result->clone(); 459 impCpCtorExpr->get_env()->apply( result );481 env->apply( result ); 460 482 ObjectDecl * ret = new ObjectDecl( retNamer.newName(), DeclarationNode::NoStorageClass, LinkageSpec::C, 0, result, 0 ); 461 483 ret->get_type()->set_isConst( false ); … … 468 490 } // for 469 491 CP_CTOR_PRINT( std::cerr << "after Resolving: " << impCpCtorExpr << std::endl; ) 492 } 493 494 void ResolveCopyCtors::visit( StmtExpr * stmtExpr ) { 495 Parent::visit( stmtExpr ); 496 env = envMap.at(stmtExpr); 497 assert( stmtExpr->get_result() ); 498 Type * result = stmtExpr->get_result(); 499 if ( ! result->isVoid() ) { 500 static UniqueName retNamer("_tmp_stmtexpr_ret"); 501 502 // create variable that will hold the result of the stmt expr 503 result = result->clone(); 504 env->apply( result ); 505 ObjectDecl * ret = new ObjectDecl( retNamer.newName(), DeclarationNode::NoStorageClass, LinkageSpec::C, 0, result, 0 ); 506 ret->get_type()->set_isConst( false ); 507 stmtExpr->get_returnDecls().push_front( ret ); 508 509 // must have a non-empty body, otherwise it wouldn't have a result 510 CompoundStmt * body = stmtExpr->get_statements(); 511 assert( ! body->get_kids().empty() ); 512 // must be an ExprStmt, otherwise it wouldn't have a result 513 ExprStmt * last = safe_dynamic_cast< ExprStmt * >( body->get_kids().back() ); 514 last->set_expr( makeCtorDtor( "?{}", ret, last->get_expr() ) ); 515 516 stmtExpr->get_dtors().push_front( makeCtorDtor( "^?{}", new AddressExpr( new VariableExpr( ret ) ) ) ); 517 } // if 518 470 519 } 471 520 … … 492 541 } 493 542 494 495 543 Expression * FixCopyCtors::mutate( ImplicitCopyCtorExpr * impCpCtorExpr ) { 496 544 CP_CTOR_PRINT( std::cerr << "FixCopyCtors: " << impCpCtorExpr << std::endl; ) 497 545 498 impCpCtorExpr = dynamic_cast< ImplicitCopyCtorExpr * >( Mutator::mutate( impCpCtorExpr ) ); 499 assert( impCpCtorExpr ); 500 546 impCpCtorExpr = safe_dynamic_cast< ImplicitCopyCtorExpr * >( Parent::mutate( impCpCtorExpr ) ); 501 547 std::list< ObjectDecl * > & tempDecls = impCpCtorExpr->get_tempDecls(); 502 548 std::list< ObjectDecl * > & returnDecls = impCpCtorExpr->get_returnDecls(); … … 558 604 retExpr = UntypedExpr::createDeref( retExpr ); 559 605 } // if 560 retExpr->set_env( env->clone() ); 606 // move env from callExpr to retExpr 607 retExpr->set_env( callExpr->get_env() ); 608 callExpr->set_env( nullptr ); 561 609 return retExpr; 562 610 } else { … … 565 613 } 566 614 615 Expression * FixCopyCtors::mutate( StmtExpr * stmtExpr ) { 616 stmtExpr = safe_dynamic_cast< StmtExpr * >( Parent::mutate( stmtExpr ) ); 617 assert( stmtExpr->get_result() ); 618 Type * result = stmtExpr->get_result(); 619 if ( ! result->isVoid() ) { 620 for ( ObjectDecl * obj : stmtExpr->get_returnDecls() ) { 621 stmtsToAdd.push_back( new DeclStmt( noLabels, obj ) ); 622 } // for 623 // add destructors after current statement 624 for ( Expression * dtor : stmtExpr->get_dtors() ) { 625 stmtsToAddAfter.push_back( new ExprStmt( noLabels, dtor ) ); 626 } // for 627 // must have a non-empty body, otherwise it wouldn't have a result 628 CompoundStmt * body = stmtExpr->get_statements(); 629 assert( ! body->get_kids().empty() ); 630 assert( ! stmtExpr->get_returnDecls().empty() ); 631 body->get_kids().push_back( new ExprStmt( noLabels, new VariableExpr( stmtExpr->get_returnDecls().front() ) ) ); 632 } 633 stmtExpr->get_returnDecls().clear(); 634 stmtExpr->get_dtors().clear(); 635 return stmtExpr; 636 } 637 567 638 Expression * FixCopyCtors::mutate( UniqueExpr * unqExpr ) { 568 639 static std::unordered_map< int, UniqueExpr * > unqMap; 569 640 static std::unordered_set< int > addDeref; 570 641 // has to be done to clean up ImplicitCopyCtorExpr nodes, even when this node was skipped in previous passes 571 unqExpr = safe_dynamic_cast< UniqueExpr * >( Parent::mutate( unqExpr ) );572 642 if ( unqMap.count( unqExpr->get_id() ) ) { 573 643 // take data from other UniqueExpr to ensure consistency … … 582 652 return unqExpr; 583 653 } 654 unqExpr = safe_dynamic_cast< UniqueExpr * >( Parent::mutate( unqExpr ) ); // stmtexprs contained should not be separately fixed, so this must occur after the lookup 584 655 unqMap[unqExpr->get_id()] = unqExpr; 585 656 if ( UntypedExpr * deref = dynamic_cast< UntypedExpr * >( unqExpr->get_expr() ) ) { … … 599 670 // first recursively handle pieces of ObjectDecl so that they aren't missed by other visitors when the init 600 671 // is removed from the ObjectDecl 601 objDecl = dynamic_cast< ObjectDecl * >( Mutator::mutate( objDecl ) ); 602 672 objDecl = dynamic_cast< ObjectDecl * >( Parent::mutate( objDecl ) ); 603 673 if ( ConstructorInit * ctorInit = dynamic_cast< ConstructorInit * >( objDecl->get_init() ) ) { 604 674 // a decision should have been made by the resolver, so ctor and init are not both non-NULL … … 904 974 // insert and resolve default/copy constructor call for each field that's unhandled 905 975 std::list< Statement * > stmt; 906 UntypedExpr * deref = new UntypedExpr( new NameExpr( "*?" ) ); 907 deref->get_args().push_back( new VariableExpr( thisParam ) ); 976 UntypedExpr * deref = UntypedExpr::createDeref( new VariableExpr( thisParam ) ); 908 977 909 978 Expression * arg2 = 0; -
src/InitTweak/GenInit.cc
r596f987b r66f8528 46 46 ReturnFixer(); 47 47 48 using GenPoly::PolyMutator::mutate; 48 typedef GenPoly::PolyMutator Parent; 49 using Parent::mutate; 49 50 virtual DeclarationWithType * mutate( FunctionDecl *functionDecl ) override; 50 51 virtual Statement * mutate( ReturnStmt * returnStmt ) override; … … 52 53 protected: 53 54 FunctionType * ftype; 54 UniqueName tempNamer;55 55 std::string funcName; 56 56 }; … … 135 135 } 136 136 137 ReturnFixer::ReturnFixer() : tempNamer( "_retVal" ){}137 ReturnFixer::ReturnFixer() {} 138 138 139 139 Statement *ReturnFixer::mutate( ReturnStmt *returnStmt ) { … … 142 142 // hands off if the function returns an lvalue - we don't want to allocate a temporary if a variable's address 143 143 // is being returned 144 // Note: under the assumption that assignments return *this, checking for ?=? here is an optimization, since it shouldn't be necessary to copy construct `this`. This is a temporary optimization until reference types are added, at which point this should be removed, along with the analogous optimization in copy constructor generation. 144 145 if ( returnStmt->get_expr() && returnVals.size() == 1 && funcName != "?=?" && ! returnVals.front()->get_type()->get_isLvalue() ) { 145 // ensure return value is not destructed by explicitly creating 146 // an empty SingleInit node wherein maybeConstruct is false 147 ObjectDecl *newObj = new ObjectDecl( tempNamer.newName(), DeclarationNode::NoStorageClass, LinkageSpec::C, 0, returnVals.front()->get_type()->clone(), new ListInit( std::list<Initializer*>(), noDesignators, false ) ); 148 stmtsToAdd.push_back( new DeclStmt( noLabels, newObj ) ); 149 150 // and explicitly create the constructor expression separately 146 // explicitly construct the return value using the return expression and the retVal object 147 assertf( returnVals.front()->get_name() != "", "Function %s has unnamed return value\n", funcName.c_str() ); 151 148 UntypedExpr *construct = new UntypedExpr( new NameExpr( "?{}" ) ); 152 construct->get_args().push_back( new AddressExpr( new VariableExpr( newObj) ) );149 construct->get_args().push_back( new AddressExpr( new VariableExpr( returnVals.front() ) ) ); 153 150 construct->get_args().push_back( returnStmt->get_expr() ); 154 151 stmtsToAdd.push_back(new ExprStmt(noLabels, construct)); 155 152 156 returnStmt->set_expr( new VariableExpr( newObj ) ); 153 // return the retVal object 154 returnStmt->set_expr( new VariableExpr( returnVals.front() ) ); 157 155 } // if 158 156 return returnStmt; … … 160 158 161 159 DeclarationWithType* ReturnFixer::mutate( FunctionDecl *functionDecl ) { 162 // xxx - need to handle named return values - this pass may need to happen163 // after resolution? the ordering is tricky because return statements must be164 // constructed - the simplest way to do that (while also handling multiple165 // returns) is to structure the returnVals into a tuple, as done here.166 // however, if the tuple return value is structured before resolution,167 // it's difficult to resolve named return values, since the name is lost168 // in conversion to a tuple. this might be easiest to deal with169 // after reference types are added, as it may then be possible to170 // uniformly move named return values to the parameter list directly171 160 ValueGuard< FunctionType * > oldFtype( ftype ); 172 161 ValueGuard< std::string > oldFuncName( funcName ); 173 162 174 163 ftype = functionDecl->get_functionType(); 175 std::list< DeclarationWithType * > & retVals = ftype->get_returnVals();176 if ( retVals.size() > 1 ) {177 TupleType * tupleType = safe_dynamic_cast< TupleType * >( ResolvExpr::extractResultType( ftype ) );178 ObjectDecl * newRet = new ObjectDecl( tempNamer.newName(), DeclarationNode::NoStorageClass, LinkageSpec::C, 0, tupleType, new ListInit( std::list<Initializer*>(), noDesignators, false ) );179 retVals.clear();180 retVals.push_back( newRet );181 }182 164 funcName = functionDecl->get_name(); 183 DeclarationWithType * decl = Mutator::mutate( functionDecl ); 184 return decl; 165 return Parent::mutate( functionDecl ); 185 166 } 186 167 … … 246 227 } 247 228 } 248 return managedTypes.find( SymTab::Mangler::mangle( type ) ) != managedTypes.end(); 229 // a type is managed if it appears in the map of known managed types, or if it contains any polymorphism (is a type variable or generic type containing a type variable) 230 return managedTypes.find( SymTab::Mangler::mangle( type ) ) != managedTypes.end() || GenPoly::isPolyType( type ); 249 231 } 250 232 -
src/ResolvExpr/AdjustExprType.cc
r596f987b r66f8528 97 97 EqvClass eqvClass; 98 98 if ( env.lookup( typeInst->get_name(), eqvClass ) ) { 99 if ( eqvClass. kind == TypeDecl::Ftype ) {99 if ( eqvClass.data.kind == TypeDecl::Ftype ) { 100 100 PointerType *pointerType = new PointerType( Type::Qualifiers(), typeInst ); 101 101 return pointerType; -
src/ResolvExpr/AlternativeFinder.cc
r596f987b r66f8528 44 44 #include "InitTweak/GenInit.h" 45 45 #include "ResolveTypeof.h" 46 #include "Resolver.h" 46 47 47 48 extern bool resolvep; … … 185 186 if ( alternatives.begin() == oldBegin ) { 186 187 std::ostringstream stream; 187 stream << "Can't choose between alternatives for expression ";188 stream << "Can't choose between " << alternatives.size() << " alternatives for expression "; 188 189 expr->print( stream ); 189 190 stream << "Alternatives are:"; … … 308 309 (*actualType)->print( std::cerr, 8 ); 309 310 std::cerr << std::endl << " to "; 310 (*formal )->get_type()->print( std::cerr, 8 );311 (*formalType)->print( std::cerr, 8 ); 311 312 ) 312 313 Cost newCost = conversionCost( *actualType, *formalType, indexer, alt.env ); … … 373 374 void makeUnifiableVars( Type *type, OpenVarSet &unifiableVars, AssertionSet &needAssertions ) { 374 375 for ( Type::ForallList::const_iterator tyvar = type->get_forall().begin(); tyvar != type->get_forall().end(); ++tyvar ) { 375 unifiableVars[ (*tyvar)->get_name() ] = (*tyvar)->get_kind();376 unifiableVars[ (*tyvar)->get_name() ] = TypeDecl::Data{ *tyvar }; 376 377 for ( std::list< DeclarationWithType* >::iterator assert = (*tyvar)->get_assertions().begin(); assert != (*tyvar)->get_assertions().end(); ++assert ) { 377 378 needAssertions[ *assert ] = true; … … 511 512 if ( ! cur->second ) { 512 513 inferRecursive( begin, end, newAlt, openVars, decls, newNeed, /*needParents,*/ level, indexer, out ); 514 return; // xxx - should this continue? previously this wasn't here, and it looks like it should be 513 515 } 514 516 DeclarationWithType *curDecl = cur->first; 517 515 518 PRINT( 516 519 std::cerr << "inferRecursive: assertion is "; … … 606 609 makeUnifiableVars( funcType, openVars, resultNeed ); 607 610 AltList instantiatedActuals; // filled by instantiate function 611 if ( targetType && ! targetType->isVoid() ) { 612 // attempt to narrow based on expected target type 613 Type * returnType = funcType->get_returnVals().front()->get_type(); 614 if ( ! unify( returnType, targetType, resultEnv, resultNeed, resultHave, openVars, indexer ) ) { 615 // unification failed, don't pursue this alternative 616 return; 617 } 618 } 619 608 620 if ( instantiateFunction( funcType->get_parameters(), actualAlt, funcType->get_isVarArgs(), openVars, resultEnv, resultNeed, resultHave, instantiatedActuals ) ) { 609 621 ApplicationExpr *appExpr = new ApplicationExpr( func.expr->clone() ); … … 649 661 AltList candidates; 650 662 SemanticError errors; 651 652 663 for ( AltList::const_iterator func = funcFinder.alternatives.begin(); func != funcFinder.alternatives.end(); ++func ) { 653 664 try { … … 739 750 740 751 findMinCost( candidates.begin(), candidates.end(), std::back_inserter( alternatives ) ); 752 753 if ( alternatives.empty() && targetType && ! targetType->isVoid() ) { 754 // xxx - this is a temporary hack. If resolution is unsuccessful with a target type, try again without a 755 // target type, since it will sometimes succeed when it wouldn't easily with target type binding. For example, 756 // forall( otype T ) lvalue T ?[?]( T *, ptrdiff_t ); 757 // const char * x = "hello world"; 758 // unsigned char ch = x[0]; 759 // Fails with simple return type binding. First, T is bound to unsigned char, then (x: const char *) is unified 760 // with unsigned char *, which fails because pointer base types must be unified exactly. The new resolver should 761 // fix this issue in a more robust way. 762 targetType = nullptr; 763 visit( untypedExpr ); 764 } 741 765 } 742 766 … … 758 782 void AlternativeFinder::visit( CastExpr *castExpr ) { 759 783 Type *& toType = castExpr->get_result(); 784 assert( toType ); 760 785 toType = resolveTypeof( toType, indexer ); 761 786 SymTab::validateType( toType, &indexer ); … … 763 788 764 789 AlternativeFinder finder( indexer, env ); 790 finder.targetType = toType; 765 791 finder.findWithAdjustment( castExpr->get_arg() ); 766 792 … … 776 802 int discardedValues = (*i).expr->get_result()->size() - castExpr->get_result()->size(); 777 803 if ( discardedValues < 0 ) continue; 778 // xxx - may need to go into tuple types and extract relavent types and use unifyList 804 // xxx - may need to go into tuple types and extract relevant types and use unifyList. Note that currently, this does not 805 // allow casting a tuple to an atomic type (e.g. (int)([1, 2, 3])) 779 806 // unification run for side-effects 780 807 unify( castExpr->get_result(), (*i).expr->get_result(), i->env, needAssertions, haveAssertions, openVars, indexer ); … … 783 810 // count one safe conversion for each value that is thrown away 784 811 thisCost += Cost( 0, 0, discardedValues ); 785 CastExpr *newExpr = castExpr->clone(); 786 newExpr->set_arg( i->expr->clone() ); 787 candidates.push_back( Alternative( newExpr, i->env, i->cost, thisCost ) ); 812 813 Expression * argExpr = i->expr->clone(); 814 if ( argExpr->get_result()->size() > 1 && ! castExpr->get_result()->isVoid() ) { 815 // Argument expression is a tuple and the target type is not void. Cast each member of the tuple 816 // to its corresponding target type, producing the tuple of those cast expressions. If there are 817 // more components of the tuple than components in the target type, then excess components do not 818 // come out in the result expression (but UniqueExprs ensure that side effects will still be done). 819 if ( Tuples::maybeImpure( argExpr ) && ! dynamic_cast< UniqueExpr * >( argExpr ) ) { 820 // expressions which may contain side effects require a single unique instance of the expression. 821 argExpr = new UniqueExpr( argExpr ); 822 } 823 std::list< Expression * > componentExprs; 824 for ( unsigned int i = 0; i < castExpr->get_result()->size(); i++ ) { 825 // cast each component 826 TupleIndexExpr * idx = new TupleIndexExpr( argExpr->clone(), i ); 827 componentExprs.push_back( new CastExpr( idx, castExpr->get_result()->getComponent( i )->clone() ) ); 828 } 829 delete argExpr; 830 assert( componentExprs.size() > 0 ); 831 // produce the tuple of casts 832 candidates.push_back( Alternative( new TupleExpr( componentExprs ), i->env, i->cost, thisCost ) ); 833 } else { 834 // handle normally 835 candidates.push_back( Alternative( new CastExpr( argExpr->clone(), toType->clone() ), i->env, i->cost, thisCost ) ); 836 } 788 837 } // if 789 838 } // for … … 800 849 AlternativeFinder funcFinder( indexer, env ); 801 850 funcFinder.findWithAdjustment( memberExpr->get_aggregate() ); 802 803 851 for ( AltList::const_iterator agg = funcFinder.alternatives.begin(); agg != funcFinder.alternatives.end(); ++agg ) { 804 852 if ( StructInstType *structInst = dynamic_cast< StructInstType* >( agg->expr->get_result() ) ) { … … 1075 1123 } 1076 1124 1125 void AlternativeFinder::visit( StmtExpr *stmtExpr ) { 1126 StmtExpr * newStmtExpr = stmtExpr->clone(); 1127 ResolvExpr::resolveStmtExpr( newStmtExpr, indexer ); 1128 // xxx - this env is almost certainly wrong, and needs to somehow contain the combined environments from all of the statements in the stmtExpr... 1129 alternatives.push_back( Alternative( newStmtExpr, env, Cost::zero ) ); 1130 } 1131 1077 1132 } // namespace ResolvExpr 1078 1133 -
src/ResolvExpr/AlternativeFinder.h
r596f987b r66f8528 70 70 virtual void visit( TupleAssignExpr *tupleExpr ); 71 71 virtual void visit( UniqueExpr *unqExpr ); 72 virtual void visit( StmtExpr *stmtExpr ); 72 73 /// Runs a new alternative finder on each element in [begin, end) 73 74 /// and writes each alternative finder to out. … … 91 92 AltList alternatives; 92 93 const TypeEnvironment &env; 94 Type * targetType = nullptr; 93 95 }; // AlternativeFinder 94 96 -
src/ResolvExpr/CommonType.cc
r596f987b r66f8528 58 58 Type *result = visitor.get_result(); 59 59 if ( ! result ) { 60 // this appears to be handling for opaque type declarations 60 61 if ( widenSecond ) { 61 TypeInstType *inst = dynamic_cast< TypeInstType* >( type2 ); 62 if ( inst ) { 63 NamedTypeDecl *nt = indexer.lookupType( inst->get_name() ); 64 if ( nt ) { 65 TypeDecl *type = dynamic_cast< TypeDecl* >( nt ); 66 assert( type ); 62 if ( TypeInstType *inst = dynamic_cast< TypeInstType* >( type2 ) ) { 63 if ( NamedTypeDecl *nt = indexer.lookupType( inst->get_name() ) ) { 64 TypeDecl *type = safe_dynamic_cast< TypeDecl* >( nt ); 67 65 if ( type->get_base() ) { 68 66 Type::Qualifiers tq1 = type1->get_qualifiers(), tq2 = type2->get_qualifiers(); … … 158 156 result->get_qualifiers() += otherPointer->get_qualifiers(); 159 157 } 160 158 161 159 void CommonType::visit( PointerType *pointerType ) { 162 160 if ( PointerType *otherPointer = dynamic_cast< PointerType* >( type2 ) ) { … … 223 221 NamedTypeDecl *nt = indexer.lookupType( inst->get_name() ); 224 222 if ( nt ) { 225 TypeDecl *type = dynamic_cast< TypeDecl* >( nt ); 226 assert( type ); 223 TypeDecl *type = safe_dynamic_cast< TypeDecl* >( nt ); 227 224 if ( type->get_base() ) { 228 225 Type::Qualifiers tq1 = inst->get_qualifiers(), tq2 = type2->get_qualifiers(); -
src/ResolvExpr/FindOpenVars.cc
r596f987b r66f8528 48 48 if ( nextIsOpen ) { 49 49 for ( Type::ForallList::const_iterator i = type->get_forall().begin(); i != type->get_forall().end(); ++i ) { 50 openVars[ (*i)->get_name() ] = (*i)->get_kind();50 openVars[ (*i)->get_name() ] = TypeDecl::Data{ (*i) }; 51 51 for ( std::list< DeclarationWithType* >::const_iterator assert = (*i)->get_assertions().begin(); assert != (*i)->get_assertions().end(); ++assert ) { 52 52 needAssertions[ *assert ] = false; … … 57 57 } else { 58 58 for ( Type::ForallList::const_iterator i = type->get_forall().begin(); i != type->get_forall().end(); ++i ) { 59 closedVars[ (*i)->get_name() ] = (*i)->get_kind();59 closedVars[ (*i)->get_name() ] = TypeDecl::Data{ (*i) }; 60 60 for ( std::list< DeclarationWithType* >::const_iterator assert = (*i)->get_assertions().begin(); assert != (*i)->get_assertions().end(); ++assert ) { 61 61 haveAssertions[ *assert ] = false; -
src/ResolvExpr/PtrsCastable.cc
r596f987b r66f8528 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // PtrsCastable.cc -- 7 // PtrsCastable.cc -- 8 8 // 9 9 // Author : Richard C. Bilson … … 25 25 public: 26 26 PtrsCastable( Type *dest, const TypeEnvironment &env, const SymTab::Indexer &indexer ); 27 27 28 28 int get_result() const { return result; } 29 29 … … 61 61 } //if 62 62 } else if ( env.lookup( typeInst->get_name(), eqvClass ) ) { 63 if ( eqvClass. kind == TypeDecl::Ftype ) {63 if ( eqvClass.data.kind == TypeDecl::Ftype ) { 64 64 return -1; 65 65 } // if -
src/ResolvExpr/Resolver.cc
r596f987b r66f8528 36 36 public: 37 37 Resolver() : SymTab::Indexer( false ) {} 38 39 using SymTab::Indexer::visit; 38 Resolver( const SymTab:: Indexer & other ) : SymTab::Indexer( other ) { 39 if ( const Resolver * res = dynamic_cast< const Resolver * >( &other ) ) { 40 functionReturn = res->functionReturn; 41 initContext = res->initContext; 42 inEnumDecl = res->inEnumDecl; 43 } 44 } 45 46 typedef SymTab::Indexer Parent; 47 using Parent::visit; 40 48 virtual void visit( FunctionDecl *functionDecl ) override; 41 49 virtual void visit( ObjectDecl *functionDecl ) override; … … 66 74 void handlePtrType( PtrType * type ); 67 75 68 void resolveAggrInit( AggregateDecl*, InitIterator &, InitIterator & );69 void resolveSingleAggrInit( Declaration *, InitIterator &, InitIterator & );76 void resolveAggrInit( ReferenceToType *, InitIterator &, InitIterator & ); 77 void resolveSingleAggrInit( Declaration *, InitIterator &, InitIterator &, TypeSubstitution sub ); 70 78 void fallbackInit( ConstructorInit * ctorInit ); 71 79 … … 192 200 initContext = new BasicType( Type::Qualifiers(), BasicType::SignedInt ); 193 201 } 194 SymTab::Indexer::visit( objectDecl );202 Parent::visit( objectDecl ); 195 203 if ( inEnumDecl && dynamic_cast< EnumInstType * >( initContext ) ) { 196 204 // delete newly created signed int type … … 212 220 void Resolver::visit( ArrayType * at ) { 213 221 handlePtrType( at ); 214 Visitor::visit( at );222 Parent::visit( at ); 215 223 } 216 224 217 225 void Resolver::visit( PointerType * pt ) { 218 226 handlePtrType( pt ); 219 Visitor::visit( pt );227 Parent::visit( pt ); 220 228 } 221 229 … … 225 233 typeDecl->set_base( new_type ); 226 234 } // if 227 SymTab::Indexer::visit( typeDecl );235 Parent::visit( typeDecl ); 228 236 } 229 237 … … 238 246 ValueGuard< Type * > oldFunctionReturn( functionReturn ); 239 247 functionReturn = ResolvExpr::extractResultType( functionDecl->get_functionType() ); 240 SymTab::Indexer::visit( functionDecl );248 Parent::visit( functionDecl ); 241 249 } 242 250 243 251 void Resolver::visit( EnumDecl * enumDecl ) { 244 252 // in case we decide to allow nested enums 245 bool oldInEnumDecl = inEnumDecl;253 ValueGuard< bool > oldInEnumDecl( inEnumDecl ); 246 254 inEnumDecl = true; 247 SymTab::Indexer::visit( enumDecl ); 248 inEnumDecl = oldInEnumDecl; 255 Parent::visit( enumDecl ); 249 256 } 250 257 251 258 void Resolver::visit( ExprStmt *exprStmt ) { 252 if ( exprStmt->get_expr() ) { 253 Expression *newExpr = findVoidExpression( exprStmt->get_expr(), *this ); 254 delete exprStmt->get_expr(); 255 exprStmt->set_expr( newExpr ); 256 } // if 259 assertf( exprStmt->get_expr(), "ExprStmt has null Expression in resolver" ); 260 Expression *newExpr = findVoidExpression( exprStmt->get_expr(), *this ); 261 delete exprStmt->get_expr(); 262 exprStmt->set_expr( newExpr ); 257 263 } 258 264 … … 277 283 delete ifStmt->get_condition(); 278 284 ifStmt->set_condition( newExpr ); 279 Visitor::visit( ifStmt );285 Parent::visit( ifStmt ); 280 286 } 281 287 … … 284 290 delete whileStmt->get_condition(); 285 291 whileStmt->set_condition( newExpr ); 286 Visitor::visit( whileStmt );292 Parent::visit( whileStmt ); 287 293 } 288 294 289 295 void Resolver::visit( ForStmt *forStmt ) { 290 SymTab::Indexer::visit( forStmt );296 Parent::visit( forStmt ); 291 297 292 298 if ( forStmt->get_condition() ) { … … 318 324 319 325 void Resolver::visit( CaseStmt *caseStmt ) { 320 Visitor::visit( caseStmt );326 Parent::visit( caseStmt ); 321 327 } 322 328 … … 396 402 } 397 403 398 void Resolver::resolveSingleAggrInit( Declaration * dcl, InitIterator & init, InitIterator & initEnd ) { 404 template< typename AggrInst > 405 TypeSubstitution makeGenericSubstitutuion( AggrInst * inst ) { 406 assert( inst ); 407 assert( inst->get_baseParameters() ); 408 std::list< TypeDecl * > baseParams = *inst->get_baseParameters(); 409 std::list< Expression * > typeSubs = inst->get_parameters(); 410 TypeSubstitution subs( baseParams.begin(), baseParams.end(), typeSubs.begin() ); 411 return subs; 412 } 413 414 ReferenceToType * isStructOrUnion( Type * type ) { 415 if ( StructInstType * sit = dynamic_cast< StructInstType * >( type ) ) { 416 return sit; 417 } else if ( UnionInstType * uit = dynamic_cast< UnionInstType * >( type ) ) { 418 return uit; 419 } 420 return nullptr; 421 } 422 423 void Resolver::resolveSingleAggrInit( Declaration * dcl, InitIterator & init, InitIterator & initEnd, TypeSubstitution sub ) { 399 424 DeclarationWithType * dt = dynamic_cast< DeclarationWithType * >( dcl ); 400 425 assert( dt ); 401 initContext = dt->get_type(); 426 // need to substitute for generic types, so that casts are to concrete types 427 initContext = dt->get_type()->clone(); 428 sub.apply( initContext ); 429 402 430 try { 403 431 if ( init == initEnd ) return; // stop when there are no more initializers … … 406 434 } catch( SemanticError & ) { 407 435 // need to delve deeper, if you can 408 if ( StructInstType * sit = dynamic_cast< StructInstType * >( dt->get_type() ) ) { 409 resolveAggrInit( sit->get_baseStruct(), init, initEnd ); 410 } else if ( UnionInstType * uit = dynamic_cast< UnionInstType * >( dt->get_type() ) ) { 411 resolveAggrInit( uit->get_baseUnion(), init, initEnd ); 436 if ( ReferenceToType * type = isStructOrUnion( initContext ) ) { 437 resolveAggrInit( type, init, initEnd ); 412 438 } else { 413 439 // member is not an aggregate type, so can't go any deeper … … 419 445 } 420 446 421 void Resolver::resolveAggrInit( AggregateDecl * aggr, InitIterator & init, InitIterator & initEnd ) { 422 if ( StructDecl * st = dynamic_cast< StructDecl * >( aggr ) ) { 447 void Resolver::resolveAggrInit( ReferenceToType * inst, InitIterator & init, InitIterator & initEnd ) { 448 if ( StructInstType * sit = dynamic_cast< StructInstType * >( inst ) ) { 449 TypeSubstitution sub = makeGenericSubstitutuion( sit ); 450 StructDecl * st = sit->get_baseStruct(); 423 451 // want to resolve each initializer to the members of the struct, 424 452 // but if there are more initializers than members we should stop 425 453 list< Declaration * >::iterator it = st->get_members().begin(); 426 454 for ( ; it != st->get_members().end(); ++it) { 427 resolveSingleAggrInit( *it, init, initEnd );455 resolveSingleAggrInit( *it, init, initEnd, sub ); 428 456 } 429 } else if ( UnionDecl * un = dynamic_cast< UnionDecl * >( aggr ) ) { 457 } else if ( UnionInstType * uit = dynamic_cast< UnionInstType * >( inst ) ) { 458 TypeSubstitution sub = makeGenericSubstitutuion( uit ); 459 UnionDecl * un = uit->get_baseUnion(); 430 460 // only resolve to the first member of a union 431 resolveSingleAggrInit( *un->get_members().begin(), init, initEnd );461 resolveSingleAggrInit( *un->get_members().begin(), init, initEnd, sub ); 432 462 } // if 433 463 } … … 449 479 (*iter++)->accept( *this ); 450 480 } 451 } else if ( StructInstType * st = dynamic_cast< StructInstType * >( initContext ) ) { 452 resolveAggrInit( st->get_baseStruct(), iter, end ); 453 } else if ( UnionInstType * st = dynamic_cast< UnionInstType * >( initContext ) ) { 454 resolveAggrInit( st->get_baseUnion(), iter, end ); 481 } else if ( ReferenceToType * type = isStructOrUnion( initContext ) ) { 482 resolveAggrInit( type, iter, end ); 455 483 } else if ( TypeInstType * tt = dynamic_cast< TypeInstType * >( initContext ) ) { 456 484 Type * base = tt->get_baseType()->get_base(); … … 461 489 } else { 462 490 // missing implementation type -- might be an unknown type variable, so try proceeding with the current init context 463 Visitor::visit( listInit );491 Parent::visit( listInit ); 464 492 } 465 493 } else { 466 494 assert( dynamic_cast< BasicType * >( initContext ) || dynamic_cast< PointerType * >( initContext ) 467 || dynamic_cast< ZeroType * >( initContext ) || dynamic_cast< OneType * >( initContext ) );495 || dynamic_cast< ZeroType * >( initContext ) || dynamic_cast< OneType * >( initContext ) || dynamic_cast < EnumInstType * > ( initContext ) ); 468 496 // basic types are handled here 469 Visitor::visit( listInit );497 Parent::visit( listInit ); 470 498 } 471 499 … … 533 561 } 534 562 563 // needs to be callable from outside the resolver, so this is a standalone function 564 void resolveCtorInit( ConstructorInit * ctorInit, const SymTab::Indexer & indexer ) { 565 assert( ctorInit ); 566 Resolver resolver( indexer ); 567 ctorInit->accept( resolver ); 568 } 569 570 void resolveStmtExpr( StmtExpr * stmtExpr, const SymTab::Indexer & indexer ) { 571 assert( stmtExpr ); 572 Resolver resolver( indexer ); 573 stmtExpr->accept( resolver ); 574 } 575 535 576 void Resolver::visit( ConstructorInit *ctorInit ) { 536 577 // xxx - fallback init has been removed => remove fallbackInit function and remove complexity from FixInit and remove C-init from ConstructorInit -
src/ResolvExpr/Resolver.h
r596f987b r66f8528 25 25 Expression *resolveInVoidContext( Expression *expr, const SymTab::Indexer &indexer ); 26 26 Expression *findVoidExpression( Expression *untyped, const SymTab::Indexer &indexer ); 27 void resolveCtorInit( ConstructorInit * ctorInit, const SymTab::Indexer & indexer ); 28 void resolveStmtExpr( StmtExpr * stmtExpr, const SymTab::Indexer & indexer ); 27 29 } // namespace ResolvExpr 28 30 -
src/ResolvExpr/TypeEnvironment.cc
r596f987b r66f8528 32 32 // 33 33 // I've seen a TU go from 54 minutes to 1 minute 34 seconds with the addition of this comparator. 34 bool AssertCompare::operator()( DeclarationWithType * d1, DeclarationWithType * d2 ) {34 bool AssertCompare::operator()( DeclarationWithType * d1, DeclarationWithType * d2 ) const { 35 35 // Objects are always less than functions 36 36 if ( ObjectDecl * objectDecl1 = dynamic_cast< ObjectDecl * >( d1 ) ) { … … 94 94 dest.type = maybeClone( src.type ); 95 95 dest.allowWidening = src.allowWidening; 96 dest. kind = src.kind;96 dest.data = src.data; 97 97 } 98 98 … … 162 162 EqvClass newClass; 163 163 newClass.vars.insert( (*i)->get_name() ); 164 newClass. kind = (*i)->get_kind();164 newClass.data = TypeDecl::Data{ (*i) }; 165 165 env.push_back( newClass ); 166 166 } // for … … 177 177 sub.add( *theVar, theClass->type ); 178 178 } else if ( theVar != theClass->vars.begin() ) { 179 TypeInstType *newTypeInst = new TypeInstType( Type::Qualifiers(), *theClass->vars.begin(), theClass-> kind == TypeDecl::Ftype );179 TypeInstType *newTypeInst = new TypeInstType( Type::Qualifiers(), *theClass->vars.begin(), theClass->data.kind == TypeDecl::Ftype ); 180 180 /// std::cout << " bound to variable " << *theClass->vars.begin() << std::endl; 181 181 sub.add( *theVar, newTypeInst ); … … 243 243 for ( std::list< EqvClass >::const_iterator eqvClass = env.begin(); eqvClass != env.end(); ++eqvClass ) { 244 244 for ( std::set< std::string >::const_iterator var = eqvClass->vars.begin(); var != eqvClass->vars.end(); ++var ) { 245 openVars[ *var ] = eqvClass-> kind;245 openVars[ *var ] = eqvClass->data; 246 246 } // for 247 247 } // for -
src/ResolvExpr/TypeEnvironment.h
r596f987b r66f8528 29 29 namespace ResolvExpr { 30 30 struct AssertCompare { 31 bool operator()( DeclarationWithType * d1, DeclarationWithType * d2 ) ;31 bool operator()( DeclarationWithType * d1, DeclarationWithType * d2 ) const; 32 32 }; 33 33 typedef std::map< DeclarationWithType*, bool, AssertCompare > AssertionSet; 34 typedef std::map< std::string, TypeDecl:: Kind> OpenVarSet;34 typedef std::map< std::string, TypeDecl::Data > OpenVarSet; 35 35 36 36 void printAssertionSet( const AssertionSet &, std::ostream &, int indent = 0 ); … … 41 41 Type *type; 42 42 bool allowWidening; 43 TypeDecl:: Kind kind;43 TypeDecl::Data data; 44 44 45 45 void initialize( const EqvClass &src, EqvClass &dest ); -
src/ResolvExpr/Unify.cc
r596f987b r66f8528 99 99 newFirst->get_qualifiers() = Type::Qualifiers(); 100 100 newSecond->get_qualifiers() = Type::Qualifiers(); 101 /// std::c out<< "first is ";102 /// first->print( std::c out);103 /// std::c out<< std::endl << "second is ";104 /// second->print( std::c out);105 /// std::c out<< std::endl << "newFirst is ";106 /// newFirst->print( std::c out);107 /// std::c out<< std::endl << "newSecond is ";108 /// newSecond->print( std::c out);109 /// std::c out<< std::endl;101 /// std::cerr << "first is "; 102 /// first->print( std::cerr ); 103 /// std::cerr << std::endl << "second is "; 104 /// second->print( std::cerr ); 105 /// std::cerr << std::endl << "newFirst is "; 106 /// newFirst->print( std::cerr ); 107 /// std::cerr << std::endl << "newSecond is "; 108 /// newSecond->print( std::cerr ); 109 /// std::cerr << std::endl; 110 110 bool result = unifyExact( newFirst, newSecond, newEnv, needAssertions, haveAssertions, openVars, WidenMode( false, false ), indexer ); 111 111 delete newFirst; … … 123 123 } 124 124 125 bool tyVarCompatible( TypeDecl::Kind kind, Type *type, const SymTab::Indexer &indexer ) { 126 switch ( kind ) { 125 struct CompleteTypeChecker : public Visitor { 126 virtual void visit( VoidType *basicType ) { status = false; } 127 virtual void visit( BasicType *basicType ) {} 128 virtual void visit( PointerType *pointerType ) {} 129 virtual void visit( ArrayType *arrayType ) { status = ! arrayType->get_isVarLen(); } 130 virtual void visit( FunctionType *functionType ) {} 131 virtual void visit( StructInstType *aggregateUseType ) { status = aggregateUseType->get_baseStruct()->has_body(); } 132 virtual void visit( UnionInstType *aggregateUseType ) { status = aggregateUseType->get_baseUnion()->has_body(); } 133 // xxx - enum inst does not currently contain a pointer to base, this should be fixed. 134 virtual void visit( EnumInstType *aggregateUseType ) { /* status = aggregateUseType->get_baseEnum()->hasBody(); */ } 135 virtual void visit( TraitInstType *aggregateUseType ) { assert( false ); } 136 virtual void visit( TypeInstType *aggregateUseType ) { status = aggregateUseType->get_baseType()->isComplete(); } 137 virtual void visit( TupleType *tupleType ) {} // xxx - not sure if this is right, might need to recursively check complete-ness 138 virtual void visit( TypeofType *typeofType ) { assert( false ); } 139 virtual void visit( AttrType *attrType ) { assert( false ); } // xxx - not sure what to do here 140 virtual void visit( VarArgsType *varArgsType ){} // xxx - is this right? 141 virtual void visit( ZeroType *zeroType ) {} 142 virtual void visit( OneType *oneType ) {} 143 bool status = true; 144 }; 145 bool isComplete( Type * type ) { 146 CompleteTypeChecker checker; 147 assert( type ); 148 type->accept( checker ); 149 return checker.status; 150 } 151 152 bool tyVarCompatible( const TypeDecl::Data & data, Type *type, const SymTab::Indexer &indexer ) { 153 switch ( data.kind ) { 127 154 case TypeDecl::Any: 128 155 case TypeDecl::Dtype: 129 return ! isFtype( type, indexer ); 130 156 // to bind to an object type variable, the type must not be a function type. 157 // if the type variable is specified to be a complete type then the incoming 158 // type must also be complete 159 return ! isFtype( type, indexer ) && (! data.isComplete || isComplete( type )); 131 160 case TypeDecl::Ftype: 132 161 return isFtype( type, indexer ); … … 136 165 } 137 166 138 bool bindVar( TypeInstType *typeInst, Type *other, TypeDecl::Kind kind, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, const OpenVarSet &openVars, WidenMode widenMode, const SymTab::Indexer &indexer ) {167 bool bindVar( TypeInstType *typeInst, Type *other, const TypeDecl::Data & data, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, const OpenVarSet &openVars, WidenMode widenMode, const SymTab::Indexer &indexer ) { 139 168 OpenVarSet::const_iterator tyvar = openVars.find( typeInst->get_name() ); 140 169 assert( tyvar != openVars.end() ); … … 175 204 newClass.type->get_qualifiers() = Type::Qualifiers(); 176 205 newClass.allowWidening = widenMode.widenFirst && widenMode.widenSecond; 177 newClass. kind = kind;206 newClass.data = data; 178 207 env.add( newClass ); 179 208 } // if … … 181 210 } 182 211 183 bool bindVarToVar( TypeInstType *var1, TypeInstType *var2, TypeDecl::Kind kind, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, const OpenVarSet &openVars, WidenMode widenMode, const SymTab::Indexer &indexer ) {212 bool bindVarToVar( TypeInstType *var1, TypeInstType *var2, const TypeDecl::Data & data, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, const OpenVarSet &openVars, WidenMode widenMode, const SymTab::Indexer &indexer ) { 184 213 bool result = true; 185 214 EqvClass class1, class2; … … 210 239 211 240 if ( type1 && type2 ) { 212 // std::c out<< "has type1 && type2" << std::endl;241 // std::cerr << "has type1 && type2" << std::endl; 213 242 WidenMode newWidenMode ( widen1, widen2 ); 214 243 Type *common = 0; … … 248 277 newClass.vars.insert( var2->get_name() ); 249 278 newClass.allowWidening = widen1 && widen2; 250 newClass. kind = kind;279 newClass.data = data; 251 280 env.add( newClass ); 252 281 } // if … … 311 340 } // if 312 341 #ifdef DEBUG 313 std::c out<< "============ unifyExact" << std::endl;314 std::c out<< "type1 is ";315 type1->print( std::c out);316 std::c out<< std::endl << "type2 is ";317 type2->print( std::c out);318 std::c out<< std::endl << "openVars are ";319 printOpenVarSet( openVars, std::c out, 8 );320 std::c out<< std::endl << "input env is " << std::endl;321 debugEnv.print( std::c out, 8 );322 std::c out<< std::endl << "result env is " << std::endl;323 env.print( std::c out, 8 );324 std::c out<< "result is " << result << std::endl;342 std::cerr << "============ unifyExact" << std::endl; 343 std::cerr << "type1 is "; 344 type1->print( std::cerr ); 345 std::cerr << std::endl << "type2 is "; 346 type2->print( std::cerr ); 347 std::cerr << std::endl << "openVars are "; 348 printOpenVarSet( openVars, std::cerr, 8 ); 349 std::cerr << std::endl << "input env is " << std::endl; 350 debugEnv.print( std::cerr, 8 ); 351 std::cerr << std::endl << "result env is " << std::endl; 352 env.print( std::cerr, 8 ); 353 std::cerr << "result is " << result << std::endl; 325 354 #endif 326 355 return result; … … 337 366 bool result; 338 367 #ifdef DEBUG 339 std::c out<< "unifyInexact type 1 is ";340 type1->print( std::c out);341 std::c out<< "type 2 is ";342 type2->print( std::c out);343 std::c out<< std::endl;368 std::cerr << "unifyInexact type 1 is "; 369 type1->print( std::cerr ); 370 std::cerr << "type 2 is "; 371 type2->print( std::cerr ); 372 std::cerr << std::endl; 344 373 #endif 345 374 if ( ! unifyExact( type1, type2, env, needAssertions, haveAssertions, openVars, widenMode, indexer ) ) { 346 375 #ifdef DEBUG 347 std::c out<< "unifyInexact: no exact unification found" << std::endl;376 std::cerr << "unifyInexact: no exact unification found" << std::endl; 348 377 #endif 349 378 if ( ( common = commonType( type1, type2, widenMode.widenFirst, widenMode.widenSecond, indexer, env, openVars ) ) ) { 350 379 common->get_qualifiers() = tq1 + tq2; 351 380 #ifdef DEBUG 352 std::c out<< "unifyInexact: common type is ";353 common->print( std::c out);354 std::c out<< std::endl;381 std::cerr << "unifyInexact: common type is "; 382 common->print( std::cerr ); 383 std::cerr << std::endl; 355 384 #endif 356 385 result = true; 357 386 } else { 358 387 #ifdef DEBUG 359 std::c out<< "unifyInexact: no common type found" << std::endl;388 std::cerr << "unifyInexact: no common type found" << std::endl; 360 389 #endif 361 390 result = false; … … 394 423 395 424 void markAssertionSet( AssertionSet &assertions, DeclarationWithType *assert ) { 396 /// std::c out<< "assertion set is" << std::endl;397 /// printAssertionSet( assertions, std::c out, 8 );398 /// std::c out<< "looking for ";399 /// assert->print( std::c out);400 /// std::c out<< std::endl;425 /// std::cerr << "assertion set is" << std::endl; 426 /// printAssertionSet( assertions, std::cerr, 8 ); 427 /// std::cerr << "looking for "; 428 /// assert->print( std::cerr ); 429 /// std::cerr << std::endl; 401 430 AssertionSet::iterator i = assertions.find( assert ); 402 431 if ( i != assertions.end() ) { 403 /// std::c out<< "found it!" << std::endl;432 /// std::cerr << "found it!" << std::endl; 404 433 i->second = true; 405 434 } // if -
src/ResolvExpr/Unify.h
r596f987b r66f8528 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // Unify.h -- 7 // Unify.h -- 8 8 // 9 9 // Author : Richard C. Bilson … … 37 37 bool widenFirst : 1, widenSecond : 1; 38 38 }; 39 40 bool bindVar( TypeInstType *typeInst, Type *other, TypeDecl::Kind kind, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, const OpenVarSet &openVars, WidenMode widenMode, const SymTab::Indexer &indexer );39 40 bool bindVar( TypeInstType *typeInst, Type *other, const TypeDecl::Data & data, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, const OpenVarSet &openVars, WidenMode widenMode, const SymTab::Indexer &indexer ); 41 41 bool unify( Type *type1, Type *type2, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, OpenVarSet &openVars, const SymTab::Indexer &indexer ); 42 42 bool unify( Type *type1, Type *type2, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, OpenVarSet &openVars, const SymTab::Indexer &indexer, Type *&commonType ); -
src/SymTab/Autogen.cc
r596f987b r66f8528 24 24 #include "MakeLibCfa.h" 25 25 #include "Autogen.h" 26 #include "GenPoly/ScopedSet.h" 27 #include "SymTab/Mangler.h" 28 #include "GenPoly/DeclMutator.h" 26 29 27 30 namespace SymTab { … … 29 32 30 33 class AutogenerateRoutines : public Visitor { 31 34 public: 32 35 std::list< Declaration * > &get_declsToAdd() { return declsToAdd; } 36 37 typedef Visitor Parent; 38 using Parent::visit; 33 39 34 40 virtual void visit( EnumDecl *enumDecl ); … … 45 51 virtual void visit( SwitchStmt *switchStmt ); 46 52 47 AutogenerateRoutines() : functionNesting( 0 ) {} 48 private: 53 private: 49 54 template< typename StmtClass > void visitStatement( StmtClass *stmt ); 50 55 51 56 std::list< Declaration * > declsToAdd; 52 57 std::set< std::string > structsDone; 53 unsigned int functionNesting ; // current level of nested functions58 unsigned int functionNesting = 0; // current level of nested functions 54 59 }; 55 60 61 /// generates routines for tuple types. 62 /// Doesn't really need to be a mutator, but it's easier to reuse DeclMutator than it is to use AddVisit 63 /// or anything we currently have that supports adding new declarations for visitors 64 class AutogenTupleRoutines : public GenPoly::DeclMutator { 65 public: 66 typedef GenPoly::DeclMutator Parent; 67 using Parent::mutate; 68 69 virtual DeclarationWithType * mutate( FunctionDecl *functionDecl ); 70 71 virtual Type * mutate( TupleType *tupleType ); 72 73 virtual CompoundStmt * mutate( CompoundStmt *compoundStmt ); 74 75 private: 76 unsigned int functionNesting = 0; // current level of nested functions 77 GenPoly::ScopedSet< std::string > seenTuples; 78 }; 79 56 80 void autogenerateRoutines( std::list< Declaration * > &translationUnit ) { 57 AutogenerateRoutines visitor; 58 acceptAndAdd( translationUnit, visitor, false ); 81 AutogenerateRoutines generator; 82 acceptAndAdd( translationUnit, generator, false ); 83 84 // needs to be done separately because AutogenerateRoutines skips types that appear as function arguments, etc. 85 // AutogenTupleRoutines tupleGenerator; 86 // tupleGenerator.mutateDeclarationList( translationUnit ); 59 87 } 60 88 … … 63 91 } 64 92 65 template< typename OutputIterator > 66 void makeUnionFieldsAssignment( ObjectDecl *srcParam, ObjectDecl *dstParam, OutputIterator out ) { 67 UntypedExpr *copy = new UntypedExpr( new NameExpr( "__builtin_memcpy" ) ); 68 copy->get_args().push_back( new VariableExpr( dstParam ) ); 69 copy->get_args().push_back( new AddressExpr( new VariableExpr( srcParam ) ) ); 70 copy->get_args().push_back( new SizeofExpr( srcParam->get_type()->clone() ) ); 71 72 *out++ = new ExprStmt( noLabels, copy ); 73 } 74 75 //E ?=?(E volatile*, int), 76 // ?=?(E _Atomic volatile*, int); 77 void makeEnumFunctions( EnumDecl *enumDecl, EnumInstType *refType, unsigned int functionNesting, std::list< Declaration * > &declsToAdd ) { 78 FunctionType *assignType = new FunctionType( Type::Qualifiers(), false ); 79 80 ObjectDecl *dstParam = new ObjectDecl( "_dst", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, new PointerType( Type::Qualifiers(), refType ), 0 ); 81 assignType->get_parameters().push_back( dstParam ); 82 83 // void ?{}(E *); void ^?{}(E *); 84 FunctionType * ctorType = assignType->clone(); 85 FunctionType * dtorType = assignType->clone(); 86 87 ObjectDecl *srcParam = new ObjectDecl( "_src", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, refType->clone(), 0 ); 88 assignType->get_parameters().push_back( srcParam ); 89 // void ?{}(E *, E); 90 FunctionType *copyCtorType = assignType->clone(); 91 92 // T ?=?(E *, E); 93 ObjectDecl *returnVal = new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, refType->clone(), 0 ); 94 assignType->get_returnVals().push_back( returnVal ); 95 96 // xxx - should we also generate void ?{}(E *, int) and E ?{}(E *, E)? 97 // right now these cases work, but that might change. 98 99 // Routines at global scope marked "static" to prevent multiple definitions is separate translation units 93 /// inserts a forward declaration for functionDecl into declsToAdd 94 void addForwardDecl( FunctionDecl * functionDecl, std::list< Declaration * > & declsToAdd ) { 95 FunctionDecl * decl = functionDecl->clone(); 96 delete decl->get_statements(); 97 decl->set_statements( NULL ); 98 declsToAdd.push_back( decl ); 99 decl->fixUniqueId(); 100 } 101 102 /// given type T, generate type of default ctor/dtor, i.e. function type void (*) (T *) 103 FunctionType * genDefaultType( Type * paramType ) { 104 FunctionType *ftype = new FunctionType( Type::Qualifiers(), false ); 105 ObjectDecl *dstParam = new ObjectDecl( "_dst", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, new PointerType( Type::Qualifiers(), paramType->clone() ), nullptr ); 106 ftype->get_parameters().push_back( dstParam ); 107 108 return ftype; 109 } 110 111 /// given type T, generate type of copy ctor, i.e. function type void (*) (T *, T) 112 FunctionType * genCopyType( Type * paramType ) { 113 FunctionType *ftype = genDefaultType( paramType ); 114 ObjectDecl *srcParam = new ObjectDecl( "_src", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, paramType->clone(), nullptr ); 115 ftype->get_parameters().push_back( srcParam ); 116 return ftype; 117 } 118 119 /// given type T, generate type of assignment, i.e. function type T (*) (T *, T) 120 FunctionType * genAssignType( Type * paramType ) { 121 FunctionType *ftype = genCopyType( paramType ); 122 ObjectDecl *returnVal = new ObjectDecl( "_ret", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, paramType->clone(), nullptr ); 123 ftype->get_returnVals().push_back( returnVal ); 124 return ftype; 125 } 126 127 /// true if the aggregate's layout is dynamic 128 template< typename AggrDecl > 129 bool hasDynamicLayout( AggrDecl * aggregateDecl ) { 130 for ( TypeDecl * param : aggregateDecl->get_parameters() ) { 131 if ( param->get_kind() == TypeDecl::Any ) return true; 132 } 133 return false; 134 } 135 136 /// generate a function decl from a name and type. Nesting depth determines whether 137 /// the declaration is static or not; optional paramter determines if declaration is intrinsic 138 FunctionDecl * genFunc( const std::string & fname, FunctionType * ftype, unsigned int functionNesting, bool isIntrinsic = false ) { 139 // Routines at global scope marked "static" to prevent multiple definitions in separate translation units 100 140 // because each unit generates copies of the default routines for each aggregate. 101 // xxx - Temporary: make these functions intrinsic so they codegen as C assignment. 102 // Really they're something of a cross between instrinsic and autogen, so should 103 // probably make a new linkage type 104 FunctionDecl *assignDecl = new FunctionDecl( "?=?", functionNesting > 0 ? DeclarationNode::NoStorageClass : DeclarationNode::Static, LinkageSpec::Intrinsic, assignType, new CompoundStmt( noLabels ), true, false ); 105 FunctionDecl *ctorDecl = new FunctionDecl( "?{}", functionNesting > 0 ? DeclarationNode::NoStorageClass : DeclarationNode::Static, LinkageSpec::Intrinsic, ctorType, new CompoundStmt( noLabels ), true, false ); 106 FunctionDecl *copyCtorDecl = new FunctionDecl( "?{}", functionNesting > 0 ? DeclarationNode::NoStorageClass : DeclarationNode::Static, LinkageSpec::Intrinsic, copyCtorType, new CompoundStmt( noLabels ), true, false ); 107 FunctionDecl *dtorDecl = new FunctionDecl( "^?{}", functionNesting > 0 ? DeclarationNode::NoStorageClass : DeclarationNode::Static, LinkageSpec::Intrinsic, dtorType, new CompoundStmt( noLabels ), true, false ); 108 assignDecl->fixUniqueId(); 109 ctorDecl->fixUniqueId(); 110 copyCtorDecl->fixUniqueId(); 111 dtorDecl->fixUniqueId(); 112 141 DeclarationNode::StorageClass sc = functionNesting > 0 ? DeclarationNode::NoStorageClass : DeclarationNode::Static; 142 LinkageSpec::Spec spec = isIntrinsic ? LinkageSpec::Intrinsic : LinkageSpec::AutoGen; 143 FunctionDecl * decl = new FunctionDecl( fname, sc, spec, ftype, new CompoundStmt( noLabels ), true, false ); 144 decl->fixUniqueId(); 145 return decl; 146 } 147 148 /// generates a single enumeration assignment expression 149 ApplicationExpr * genEnumAssign( FunctionType * ftype, FunctionDecl * assignDecl ) { 113 150 // enum copy construct and assignment is just C-style assignment. 114 151 // this looks like a bad recursive call, but code gen will turn it into 115 152 // a C-style assignment. 116 153 // This happens before function pointer type conversion, so need to do it manually here 154 // NOTE: ftype is not necessarily the functionType belonging to assignDecl - ftype is the 155 // type of the function that this expression is being generated for (so that the correct 156 // parameters) are using in the variable exprs 157 assert( ftype->get_parameters().size() == 2 ); 158 ObjectDecl * dstParam = safe_dynamic_cast< ObjectDecl * >( ftype->get_parameters().front() ); 159 ObjectDecl * srcParam = safe_dynamic_cast< ObjectDecl * >( ftype->get_parameters().back() ); 160 117 161 VariableExpr * assignVarExpr = new VariableExpr( assignDecl ); 118 162 Type * assignVarExprType = assignVarExpr->get_result(); … … 122 166 assignExpr->get_args().push_back( new VariableExpr( dstParam ) ); 123 167 assignExpr->get_args().push_back( new VariableExpr( srcParam ) ); 168 return assignExpr; 169 } 170 171 // E ?=?(E volatile*, int), 172 // ?=?(E _Atomic volatile*, int); 173 void makeEnumFunctions( EnumDecl *enumDecl, EnumInstType *refType, unsigned int functionNesting, std::list< Declaration * > &declsToAdd ) { 174 175 // T ?=?(E *, E); 176 FunctionType *assignType = genAssignType( refType ); 177 178 // void ?{}(E *); void ^?{}(E *); 179 FunctionType * ctorType = genDefaultType( refType->clone() ); 180 FunctionType * dtorType = genDefaultType( refType->clone() ); 181 182 // void ?{}(E *, E); 183 FunctionType *copyCtorType = genCopyType( refType->clone() ); 184 185 // xxx - should we also generate void ?{}(E *, int) and E ?{}(E *, E)? 186 // right now these cases work, but that might change. 187 188 // xxx - Temporary: make these functions intrinsic so they codegen as C assignment. 189 // Really they're something of a cross between instrinsic and autogen, so should 190 // probably make a new linkage type 191 FunctionDecl *assignDecl = genFunc( "?=?", assignType, functionNesting, true ); 192 FunctionDecl *ctorDecl = genFunc( "?{}", ctorType, functionNesting, true ); 193 FunctionDecl *copyCtorDecl = genFunc( "?{}", copyCtorType, functionNesting, true ); 194 FunctionDecl *dtorDecl = genFunc( "^?{}", dtorType, functionNesting, true ); 124 195 125 196 // body is either return stmt or expr stmt 126 assignDecl->get_statements()->get_kids().push_back( new ReturnStmt( noLabels, assignExpr ) ); 127 copyCtorDecl->get_statements()->get_kids().push_back( new ExprStmt( noLabels, assignExpr->clone() ) ); 128 129 declsToAdd.push_back( assignDecl ); 197 assignDecl->get_statements()->get_kids().push_back( new ReturnStmt( noLabels, genEnumAssign( assignType, assignDecl ) ) ); 198 copyCtorDecl->get_statements()->get_kids().push_back( new ExprStmt( noLabels, genEnumAssign( copyCtorType, assignDecl ) ) ); 199 130 200 declsToAdd.push_back( ctorDecl ); 131 201 declsToAdd.push_back( copyCtorDecl ); 132 202 declsToAdd.push_back( dtorDecl ); 133 } 134 135 /// Clones a reference type, replacing any parameters it may have with a clone of the provided list 136 template< typename GenericInstType > 137 GenericInstType *cloneWithParams( GenericInstType *refType, const std::list< Expression* >& params ) { 138 GenericInstType *clone = refType->clone(); 139 clone->get_parameters().clear(); 140 cloneAll( params, clone->get_parameters() ); 141 return clone; 142 } 143 144 /// Creates a new type decl that's the same as src, but renamed and with only the ?=?, ?{} (default and copy), and ^?{} assertions (for complete types only) 145 TypeDecl *cloneAndRename( TypeDecl *src, const std::string &name ) { 146 // TypeDecl *dst = new TypeDecl( name, src->get_storageClass(), 0, src->get_kind() ); 147 148 // if ( src->get_kind() == TypeDecl::Any ) { 149 // TypeInstType *opParamType = new TypeInstType( Type::Qualifiers(), name, dst ); 150 // FunctionType *opFunctionType = new FunctionType( Type::Qualifiers(), false ); 151 // opFunctionType->get_parameters().push_back( 152 // new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, new PointerType( Type::Qualifiers(), opParamType->clone() ), 0 ) ); 153 // FunctionDecl *ctorAssert = new FunctionDecl( "?{}", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, opFunctionType->clone(), 0, false, false ); 154 // FunctionDecl *dtorAssert = new FunctionDecl( "^?{}", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, opFunctionType->clone(), 0, false, false ); 155 156 // opFunctionType->get_parameters().push_back( 157 // new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, opParamType, 0 ) ); 158 // FunctionDecl *copyCtorAssert = new FunctionDecl( "?{}", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, opFunctionType->clone(), 0, false, false ); 159 160 // opFunctionType->get_returnVals().push_back( 161 // new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, opParamType->clone(), 0 ) ); 162 // FunctionDecl *assignAssert = new FunctionDecl( "?=?", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, opFunctionType, 0, false, false ); 163 164 165 // dst->get_assertions().push_back( assignAssert ); 166 // dst->get_assertions().push_back( ctorAssert ); 167 // dst->get_assertions().push_back( dtorAssert ); 168 // dst->get_assertions().push_back( copyCtorAssert ); 169 // } 170 171 TypeDecl *dst = new TypeDecl( src->get_name(), src->get_storageClass(), 0, src->get_kind() ); 172 cloneAll(src->get_assertions(), dst->get_assertions()); 173 return dst; 174 } 175 176 void makeStructMemberOp( ObjectDecl * dstParam, Expression * src, DeclarationWithType * field, FunctionDecl * func, TypeSubstitution & genericSubs, bool isDynamicLayout, bool forward = true ) { 177 // if ( isDynamicLayout && src ) { 178 // genericSubs.apply( src ); 179 // } 180 203 declsToAdd.push_back( assignDecl ); // assignment should come last since it uses copy constructor in return 204 } 205 206 /// generates a single struct member operation (constructor call, destructor call, assignment call) 207 void makeStructMemberOp( ObjectDecl * dstParam, Expression * src, DeclarationWithType * field, FunctionDecl * func, bool isDynamicLayout, bool forward = true ) { 181 208 ObjectDecl * returnVal = NULL; 182 209 if ( ! func->get_functionType()->get_returnVals().empty() ) { … … 187 214 188 215 // assign to destination (and return value if generic) 189 UntypedExpr *derefExpr = new UntypedExpr( new NameExpr( "*?" ) ); 190 derefExpr->get_args().push_back( new VariableExpr( dstParam ) ); 216 UntypedExpr *derefExpr = UntypedExpr::createDeref( new VariableExpr( dstParam ) ); 191 217 Expression *dstselect = new MemberExpr( field, derefExpr ); 192 218 genImplicitCall( srcParam, dstselect, func->get_name(), back_inserter( func->get_statements()->get_kids() ), field, forward ); 193 219 194 220 if ( isDynamicLayout && returnVal ) { 195 UntypedExpr *derefRet = new UntypedExpr( new NameExpr( "*?" ) ); 196 derefRet->get_args().push_back( new VariableExpr( returnVal ) ); 197 Expression *retselect = new MemberExpr( field, derefRet ); 221 // xxx - there used to be a dereference on returnVal, but this seems to have been wrong? 222 Expression *retselect = new MemberExpr( field, new VariableExpr( returnVal ) ); 198 223 genImplicitCall( srcParam, retselect, func->get_name(), back_inserter( func->get_statements()->get_kids() ), field, forward ); 199 224 } // if 200 225 } 201 226 227 /// 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 202 228 template<typename Iterator> 203 void makeStructFunctionBody( Iterator member, Iterator end, FunctionDecl * func, TypeSubstitution & genericSubs,bool isDynamicLayout, bool forward = true ) {229 void makeStructFunctionBody( Iterator member, Iterator end, FunctionDecl * func, bool isDynamicLayout, bool forward = true ) { 204 230 for ( ; member != end; ++member ) { 205 231 if ( DeclarationWithType *field = dynamic_cast< DeclarationWithType * >( *member ) ) { // otherwise some form of type declaration, e.g. Aggregate … … 237 263 238 264 Expression *srcselect = srcParam ? new MemberExpr( field, new VariableExpr( srcParam ) ) : NULL; 239 makeStructMemberOp( dstParam, srcselect, field, func, genericSubs,isDynamicLayout, forward );265 makeStructMemberOp( dstParam, srcselect, field, func, isDynamicLayout, forward ); 240 266 } // if 241 267 } // for … … 245 271 /// void ?{}(A *, int) and void?{}(A *, int, int) for a struct A which has two int fields. 246 272 template<typename Iterator> 247 void makeStructFieldCtorBody( Iterator member, Iterator end, FunctionDecl * func, TypeSubstitution & genericSubs,bool isDynamicLayout ) {273 void makeStructFieldCtorBody( Iterator member, Iterator end, FunctionDecl * func, bool isDynamicLayout ) { 248 274 FunctionType * ftype = func->get_functionType(); 249 275 std::list<DeclarationWithType*> & params = ftype->get_parameters(); … … 271 297 // matching parameter, initialize field with copy ctor 272 298 Expression *srcselect = new VariableExpr(*parameter); 273 makeStructMemberOp( dstParam, srcselect, field, func, genericSubs,isDynamicLayout );299 makeStructMemberOp( dstParam, srcselect, field, func, isDynamicLayout ); 274 300 ++parameter; 275 301 } else { 276 302 // no matching parameter, initialize field with default ctor 277 makeStructMemberOp( dstParam, NULL, field, func, genericSubs,isDynamicLayout );303 makeStructMemberOp( dstParam, NULL, field, func, isDynamicLayout ); 278 304 } 279 305 } … … 281 307 } 282 308 283 void addForwardDecl( FunctionDecl * functionDecl, std::list< Declaration * > & declsToAdd ) { 284 FunctionDecl * decl = functionDecl->clone(); 285 delete decl->get_statements(); 286 decl->set_statements( NULL ); 287 declsToAdd.push_back( decl ); 288 decl->fixUniqueId(); 289 } 290 309 /// generates struct constructors, destructor, and assignment functions 291 310 void makeStructFunctions( StructDecl *aggregateDecl, StructInstType *refType, unsigned int functionNesting, std::list< Declaration * > & declsToAdd ) { 292 FunctionType *assignType = new FunctionType( Type::Qualifiers(), false );293 311 294 312 // Make function polymorphic in same parameters as generic struct, if applicable 295 bool isDynamicLayout = false; // NOTE this flag is an incredibly ugly kludge; we should fix the assignment signature instead (ditto for union) 296 std::list< TypeDecl* >& genericParams = aggregateDecl->get_parameters(); 297 std::list< Expression* > structParams; // List of matching parameters to put on types 298 TypeSubstitution genericSubs; // Substitutions to make to member types of struct 299 for ( std::list< TypeDecl* >::const_iterator param = genericParams.begin(); param != genericParams.end(); ++param ) { 300 if ( (*param)->get_kind() == TypeDecl::Any ) isDynamicLayout = true; 301 TypeDecl *typeParam = cloneAndRename( *param, "_autoassign_" + aggregateDecl->get_name() + "_" + (*param)->get_name() ); 302 assignType->get_forall().push_back( typeParam ); 303 TypeInstType *newParamType = new TypeInstType( Type::Qualifiers(), typeParam->get_name(), typeParam ); 304 genericSubs.add( (*param)->get_name(), newParamType ); 305 structParams.push_back( new TypeExpr( newParamType ) ); 306 } 307 308 ObjectDecl *dstParam = new ObjectDecl( "_dst", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, new PointerType( Type::Qualifiers(), cloneWithParams( refType, structParams ) ), 0 ); 309 assignType->get_parameters().push_back( dstParam ); 313 const std::list< TypeDecl* > & typeParams = aggregateDecl->get_parameters(); // List of type variables to be placed on the generated functions 314 bool isDynamicLayout = hasDynamicLayout( aggregateDecl ); // NOTE this flag is an incredibly ugly kludge; we should fix the assignment signature instead (ditto for union) 315 316 // T ?=?(T *, T); 317 FunctionType *assignType = genAssignType( refType ); 318 cloneAll( typeParams, assignType->get_forall() ); 310 319 311 320 // void ?{}(T *); void ^?{}(T *); 312 FunctionType *ctorType = assignType->clone(); 313 FunctionType *dtorType = assignType->clone(); 314 315 ObjectDecl *srcParam = new ObjectDecl( "_src", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, cloneWithParams( refType, structParams ), 0 ); 316 assignType->get_parameters().push_back( srcParam ); 321 FunctionType *ctorType = genDefaultType( refType ); 322 cloneAll( typeParams, ctorType->get_forall() ); 323 FunctionType *dtorType = genDefaultType( refType ); 324 cloneAll( typeParams, dtorType->get_forall() ); 317 325 318 326 // void ?{}(T *, T); 319 FunctionType *copyCtorType = assignType->clone(); 320 321 // T ?=?(T *, T); 322 ObjectDecl *returnVal = new ObjectDecl( "_ret", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, cloneWithParams( refType, structParams ), 0 ); 323 assignType->get_returnVals().push_back( returnVal ); 324 325 // Routines at global scope marked "static" to prevent multiple definitions is separate translation units 326 // because each unit generates copies of the default routines for each aggregate. 327 FunctionDecl *assignDecl = new FunctionDecl( "?=?", functionNesting > 0 ? DeclarationNode::NoStorageClass : DeclarationNode::Static, LinkageSpec::AutoGen, assignType, new CompoundStmt( noLabels ), true, false ); 328 FunctionDecl *ctorDecl = new FunctionDecl( "?{}", functionNesting > 0 ? DeclarationNode::NoStorageClass : DeclarationNode::Static, LinkageSpec::AutoGen, ctorType, new CompoundStmt( noLabels ), true, false ); 329 FunctionDecl *copyCtorDecl = new FunctionDecl( "?{}", functionNesting > 0 ? DeclarationNode::NoStorageClass : DeclarationNode::Static, LinkageSpec::AutoGen, copyCtorType, new CompoundStmt( noLabels ), true, false ); 330 FunctionDecl *dtorDecl = new FunctionDecl( "^?{}", functionNesting > 0 ? DeclarationNode::NoStorageClass : DeclarationNode::Static, LinkageSpec::AutoGen, dtorType, new CompoundStmt( noLabels ), true, false ); 331 assignDecl->fixUniqueId(); 332 ctorDecl->fixUniqueId(); 333 copyCtorDecl->fixUniqueId(); 334 dtorDecl->fixUniqueId(); 327 FunctionType *copyCtorType = genCopyType( refType ); 328 cloneAll( typeParams, copyCtorType->get_forall() ); 329 330 FunctionDecl *assignDecl = genFunc( "?=?", assignType, functionNesting ); 331 FunctionDecl *ctorDecl = genFunc( "?{}", ctorType, functionNesting ); 332 FunctionDecl *copyCtorDecl = genFunc( "?{}", copyCtorType, functionNesting ); 333 FunctionDecl *dtorDecl = genFunc( "^?{}", dtorType, functionNesting ); 335 334 336 335 if ( functionNesting == 0 ) { 337 336 // forward declare if top-level struct, so that 338 337 // type is complete as soon as its body ends 338 // Note: this is necessary if we want structs which contain 339 // generic (otype) structs as members. 339 340 addForwardDecl( assignDecl, declsToAdd ); 340 341 addForwardDecl( ctorDecl, declsToAdd ); … … 365 366 } 366 367 memCtorType->get_parameters().push_back( new ObjectDecl( member->get_name(), DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, member->get_type()->clone(), 0 ) ); 367 FunctionDecl * ctor = new FunctionDecl( "?{}", functionNesting > 0 ? DeclarationNode::NoStorageClass : DeclarationNode::Static, LinkageSpec::AutoGen, memCtorType->clone(), new CompoundStmt( noLabels ), true, false ); 368 ctor->fixUniqueId(); 369 makeStructFieldCtorBody( aggregateDecl->get_members().begin(), aggregateDecl->get_members().end(), ctor, genericSubs, isDynamicLayout ); 368 FunctionDecl * ctor = genFunc( "?{}", memCtorType->clone(), functionNesting ); 369 makeStructFieldCtorBody( aggregateDecl->get_members().begin(), aggregateDecl->get_members().end(), ctor, isDynamicLayout ); 370 370 memCtors.push_back( ctor ); 371 371 } … … 373 373 374 374 // generate appropriate calls to member ctor, assignment 375 makeStructFunctionBody( aggregateDecl->get_members().begin(), aggregateDecl->get_members().end(), assignDecl, genericSubs,isDynamicLayout );376 makeStructFunctionBody( aggregateDecl->get_members().begin(), aggregateDecl->get_members().end(), ctorDecl, genericSubs,isDynamicLayout );377 makeStructFunctionBody( aggregateDecl->get_members().begin(), aggregateDecl->get_members().end(), copyCtorDecl, genericSubs,isDynamicLayout );375 makeStructFunctionBody( aggregateDecl->get_members().begin(), aggregateDecl->get_members().end(), assignDecl, isDynamicLayout ); 376 makeStructFunctionBody( aggregateDecl->get_members().begin(), aggregateDecl->get_members().end(), ctorDecl, isDynamicLayout ); 377 makeStructFunctionBody( aggregateDecl->get_members().begin(), aggregateDecl->get_members().end(), copyCtorDecl, isDynamicLayout ); 378 378 // needs to do everything in reverse, so pass "forward" as false 379 makeStructFunctionBody( aggregateDecl->get_members().rbegin(), aggregateDecl->get_members().rend(), dtorDecl, genericSubs, isDynamicLayout, false ); 380 381 if ( ! isDynamicLayout ) assignDecl->get_statements()->get_kids().push_back( new ReturnStmt( noLabels, new VariableExpr( srcParam ) ) ); 382 383 declsToAdd.push_back( assignDecl ); 379 makeStructFunctionBody( aggregateDecl->get_members().rbegin(), aggregateDecl->get_members().rend(), dtorDecl, isDynamicLayout, false ); 380 381 assert( assignType->get_parameters().size() == 2 ); 382 ObjectDecl * srcParam = safe_dynamic_cast< ObjectDecl * >( assignType->get_parameters().back() ); 383 assignDecl->get_statements()->get_kids().push_back( new ReturnStmt( noLabels, new VariableExpr( srcParam ) ) ); 384 384 385 declsToAdd.push_back( ctorDecl ); 385 386 declsToAdd.push_back( copyCtorDecl ); 386 387 declsToAdd.push_back( dtorDecl ); 388 declsToAdd.push_back( assignDecl ); // assignment should come last since it uses copy constructor in return 387 389 declsToAdd.splice( declsToAdd.end(), memCtors ); 388 390 } 389 391 392 /// generate a single union assignment expression (using memcpy) 393 template< typename OutputIterator > 394 void makeUnionFieldsAssignment( ObjectDecl * srcParam, ObjectDecl * dstParam, OutputIterator out ) { 395 UntypedExpr *copy = new UntypedExpr( new NameExpr( "__builtin_memcpy" ) ); 396 copy->get_args().push_back( new VariableExpr( dstParam ) ); 397 copy->get_args().push_back( new AddressExpr( new VariableExpr( srcParam ) ) ); 398 copy->get_args().push_back( new SizeofExpr( srcParam->get_type()->clone() ) ); 399 *out++ = new ExprStmt( noLabels, copy ); 400 } 401 402 /// generates the body of a union assignment/copy constructor/field constructor 403 void makeUnionAssignBody( FunctionDecl * funcDecl, bool isDynamicLayout ) { 404 FunctionType * ftype = funcDecl->get_functionType(); 405 assert( ftype->get_parameters().size() == 2 ); 406 ObjectDecl * dstParam = safe_dynamic_cast< ObjectDecl * >( ftype->get_parameters().front() ); 407 ObjectDecl * srcParam = safe_dynamic_cast< ObjectDecl * >( ftype->get_parameters().back() ); 408 ObjectDecl * returnVal = nullptr; 409 if ( ! ftype->get_returnVals().empty() ) { 410 returnVal = safe_dynamic_cast< ObjectDecl * >( ftype->get_returnVals().front() ); 411 } 412 413 makeUnionFieldsAssignment( srcParam, dstParam, back_inserter( funcDecl->get_statements()->get_kids() ) ); 414 if ( returnVal ) { 415 if ( isDynamicLayout ) makeUnionFieldsAssignment( srcParam, returnVal, back_inserter( funcDecl->get_statements()->get_kids() ) ); 416 else funcDecl->get_statements()->get_kids().push_back( new ReturnStmt( noLabels, new VariableExpr( srcParam ) ) ); 417 } 418 } 419 420 /// generates union constructors, destructors, and assignment operator 390 421 void makeUnionFunctions( UnionDecl *aggregateDecl, UnionInstType *refType, unsigned int functionNesting, std::list< Declaration * > & declsToAdd ) { 391 FunctionType *assignType = new FunctionType( Type::Qualifiers(), false );392 393 422 // Make function polymorphic in same parameters as generic union, if applicable 394 bool isDynamicLayout = false; // NOTE this flag is an incredibly ugly kludge; we should fix the assignment signature instead (ditto for struct) 395 std::list< TypeDecl* >& genericParams = aggregateDecl->get_parameters(); 396 std::list< Expression* > unionParams; // List of matching parameters to put on types 397 for ( std::list< TypeDecl* >::const_iterator param = genericParams.begin(); param != genericParams.end(); ++param ) { 398 if ( (*param)->get_kind() == TypeDecl::Any ) isDynamicLayout = true; 399 TypeDecl *typeParam = cloneAndRename( *param, "_autoassign_" + aggregateDecl->get_name() + "_" + (*param)->get_name() ); 400 assignType->get_forall().push_back( typeParam ); 401 unionParams.push_back( new TypeExpr( new TypeInstType( Type::Qualifiers(), typeParam->get_name(), typeParam ) ) ); 402 } 403 404 ObjectDecl *dstParam = new ObjectDecl( "_dst", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, new PointerType( Type::Qualifiers(), cloneWithParams( refType, unionParams ) ), 0 ); 405 assignType->get_parameters().push_back( dstParam ); 423 const std::list< TypeDecl* > & typeParams = aggregateDecl->get_parameters(); // List of type variables to be placed on the generated functions 424 bool isDynamicLayout = hasDynamicLayout( aggregateDecl ); // NOTE this flag is an incredibly ugly kludge; we should fix the assignment signature instead (ditto for struct) 406 425 407 426 // default ctor/dtor need only first parameter 408 FunctionType * ctorType = assignType->clone(); 409 FunctionType * dtorType = assignType->clone(); 410 411 ObjectDecl *srcParam = new ObjectDecl( "_src", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, cloneWithParams( refType, unionParams ), 0 ); 412 assignType->get_parameters().push_back( srcParam ); 427 // void ?{}(T *); void ^?{}(T *); 428 FunctionType *ctorType = genDefaultType( refType ); 429 FunctionType *dtorType = genDefaultType( refType ); 413 430 414 431 // copy ctor needs both parameters 415 FunctionType * copyCtorType = assignType->clone(); 432 // void ?{}(T *, T); 433 FunctionType *copyCtorType = genCopyType( refType ); 416 434 417 435 // assignment needs both and return value 418 ObjectDecl *returnVal = new ObjectDecl( "_ret", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, cloneWithParams( refType, unionParams ), 0 ); 419 assignType->get_returnVals().push_back( returnVal ); 436 // T ?=?(T *, T); 437 FunctionType *assignType = genAssignType( refType ); 438 439 cloneAll( typeParams, ctorType->get_forall() ); 440 cloneAll( typeParams, dtorType->get_forall() ); 441 cloneAll( typeParams, copyCtorType->get_forall() ); 442 cloneAll( typeParams, assignType->get_forall() ); 420 443 421 444 // Routines at global scope marked "static" to prevent multiple definitions is separate translation units 422 445 // because each unit generates copies of the default routines for each aggregate. 423 FunctionDecl *assignDecl = new FunctionDecl( "?=?", functionNesting > 0 ? DeclarationNode::NoStorageClass : DeclarationNode::Static, LinkageSpec::AutoGen, assignType, new CompoundStmt( noLabels ), true, false ); 424 FunctionDecl *ctorDecl = new FunctionDecl( "?{}", functionNesting > 0 ? DeclarationNode::NoStorageClass : DeclarationNode::Static, LinkageSpec::AutoGen, ctorType, new CompoundStmt( noLabels ), true, false ); 425 FunctionDecl *copyCtorDecl = new FunctionDecl( "?{}", functionNesting > 0 ? DeclarationNode::NoStorageClass : DeclarationNode::Static, LinkageSpec::AutoGen, copyCtorType, NULL, true, false ); 426 FunctionDecl *dtorDecl = new FunctionDecl( "^?{}", functionNesting > 0 ? DeclarationNode::NoStorageClass : DeclarationNode::Static, LinkageSpec::AutoGen, dtorType, new CompoundStmt( noLabels ), true, false ); 427 428 assignDecl->fixUniqueId(); 429 ctorDecl->fixUniqueId(); 430 copyCtorDecl->fixUniqueId(); 431 dtorDecl->fixUniqueId(); 432 433 makeUnionFieldsAssignment( srcParam, dstParam, back_inserter( assignDecl->get_statements()->get_kids() ) ); 434 if ( isDynamicLayout ) makeUnionFieldsAssignment( srcParam, returnVal, back_inserter( assignDecl->get_statements()->get_kids() ) ); 435 else assignDecl->get_statements()->get_kids().push_back( new ReturnStmt( noLabels, new VariableExpr( srcParam ) ) ); 446 FunctionDecl *assignDecl = genFunc( "?=?", assignType, functionNesting ); 447 FunctionDecl *ctorDecl = genFunc( "?{}", ctorType, functionNesting ); 448 FunctionDecl *copyCtorDecl = genFunc( "?{}", copyCtorType, functionNesting ); 449 FunctionDecl *dtorDecl = genFunc( "^?{}", dtorType, functionNesting ); 450 451 makeUnionAssignBody( assignDecl, isDynamicLayout ); 436 452 437 453 // body of assignment and copy ctor is the same 438 copyCtorDecl->set_statements( assignDecl->get_statements()->clone());454 makeUnionAssignBody( copyCtorDecl, isDynamicLayout ); 439 455 440 456 // create a constructor which takes the first member type as a parameter. … … 449 465 FunctionType * memCtorType = ctorType->clone(); 450 466 memCtorType->get_parameters().push_back( srcParam ); 451 FunctionDecl * ctor = new FunctionDecl( "?{}", functionNesting > 0 ? DeclarationNode::NoStorageClass : DeclarationNode::Static, LinkageSpec::AutoGen, memCtorType, new CompoundStmt( noLabels ), true, false ); 452 ctor->fixUniqueId(); 453 454 makeUnionFieldsAssignment( srcParam, dstParam, back_inserter( ctor->get_statements()->get_kids() ) ); 467 FunctionDecl * ctor = genFunc( "?{}", memCtorType, functionNesting ); 468 469 makeUnionAssignBody( ctor, isDynamicLayout ); 455 470 memCtors.push_back( ctor ); 456 471 // only generate a ctor for the first field … … 459 474 } 460 475 461 declsToAdd.push_back( assignDecl );462 476 declsToAdd.push_back( ctorDecl ); 463 477 declsToAdd.push_back( copyCtorDecl ); 464 478 declsToAdd.push_back( dtorDecl ); 479 declsToAdd.push_back( assignDecl ); // assignment should come last since it uses copy constructor in return 465 480 declsToAdd.splice( declsToAdd.end(), memCtors ); 466 481 } … … 478 493 if ( ! structDecl->get_members().empty() && structsDone.find( structDecl->get_name() ) == structsDone.end() ) { 479 494 StructInstType structInst( Type::Qualifiers(), structDecl->get_name() ); 495 for ( TypeDecl * typeDecl : structDecl->get_parameters() ) { 496 structInst.get_parameters().push_back( new TypeExpr( new TypeInstType( Type::Qualifiers(), typeDecl->get_name(), typeDecl ) ) ); 497 } 480 498 structInst.set_baseStruct( structDecl ); 481 499 makeStructFunctions( structDecl, &structInst, functionNesting, declsToAdd ); … … 488 506 UnionInstType unionInst( Type::Qualifiers(), unionDecl->get_name() ); 489 507 unionInst.set_baseUnion( unionDecl ); 508 for ( TypeDecl * typeDecl : unionDecl->get_parameters() ) { 509 unionInst.get_parameters().push_back( new TypeExpr( new TypeInstType( Type::Qualifiers(), typeDecl->get_name(), typeDecl ) ) ); 510 } 490 511 makeUnionFunctions( unionDecl, &unionInst, functionNesting, declsToAdd ); 491 512 } // if … … 493 514 494 515 void AutogenerateRoutines::visit( TypeDecl *typeDecl ) { 495 CompoundStmt *stmts = 0;496 516 TypeInstType *typeInst = new TypeInstType( Type::Qualifiers(), typeDecl->get_name(), false ); 497 517 typeInst->set_baseType( typeDecl ); 498 ObjectDecl *src = new ObjectDecl( "_src", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, typeInst->clone(), 0 ); 499 ObjectDecl *dst = new ObjectDecl( "_dst", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, new PointerType( Type::Qualifiers(), typeInst->clone() ), 0 ); 518 ObjectDecl *src = new ObjectDecl( "_src", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, typeInst->clone(), nullptr ); 519 ObjectDecl *dst = new ObjectDecl( "_dst", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, new PointerType( Type::Qualifiers(), typeInst->clone() ), nullptr ); 520 521 std::list< Statement * > stmts; 500 522 if ( typeDecl->get_base() ) { 501 523 // xxx - generate ctor/dtors for typedecls, e.g. 502 524 // otype T = int *; 503 stmts = new CompoundStmt( std::list< Label >() );504 525 UntypedExpr *assign = new UntypedExpr( new NameExpr( "?=?" ) ); 505 526 assign->get_args().push_back( new CastExpr( new VariableExpr( dst ), new PointerType( Type::Qualifiers(), typeDecl->get_base()->clone() ) ) ); 506 527 assign->get_args().push_back( new CastExpr( new VariableExpr( src ), typeDecl->get_base()->clone() ) ); 507 stmts ->get_kids().push_back( new ReturnStmt( std::list< Label >(), assign ) );528 stmts.push_back( new ReturnStmt( std::list< Label >(), assign ) ); 508 529 } // if 509 530 FunctionType *type = new FunctionType( Type::Qualifiers(), false ); … … 511 532 type->get_parameters().push_back( dst ); 512 533 type->get_parameters().push_back( src ); 513 FunctionDecl *func = new FunctionDecl( "?=?", DeclarationNode::NoStorageClass, LinkageSpec::AutoGen, type, stmts, true, false ); 534 FunctionDecl *func = genFunc( "?=?", type, functionNesting ); 535 func->get_statements()->get_kids() = stmts; 514 536 declsToAdd.push_back( func ); 515 537 } … … 556 578 visitStatement( switchStmt ); 557 579 } 580 581 void makeTupleFunctionBody( FunctionDecl * function ) { 582 FunctionType * ftype = function->get_functionType(); 583 assertf( ftype->get_parameters().size() == 1 || ftype->get_parameters().size() == 2, "too many parameters in generated tuple function" ); 584 585 UntypedExpr * untyped = new UntypedExpr( new NameExpr( function->get_name() ) ); 586 587 /// xxx - &* is used to make this easier for later passes to handle 588 untyped->get_args().push_back( new AddressExpr( UntypedExpr::createDeref( new VariableExpr( ftype->get_parameters().front() ) ) ) ); 589 if ( ftype->get_parameters().size() == 2 ) { 590 untyped->get_args().push_back( new VariableExpr( ftype->get_parameters().back() ) ); 591 } 592 function->get_statements()->get_kids().push_back( new ExprStmt( noLabels, untyped ) ); 593 function->get_statements()->get_kids().push_back( new ReturnStmt( noLabels, UntypedExpr::createDeref( new VariableExpr( ftype->get_parameters().front() ) ) ) ); 594 } 595 596 Type * AutogenTupleRoutines::mutate( TupleType * tupleType ) { 597 tupleType = safe_dynamic_cast< TupleType * >( Parent::mutate( tupleType ) ); 598 std::string mangleName = SymTab::Mangler::mangleType( tupleType ); 599 if ( seenTuples.find( mangleName ) != seenTuples.end() ) return tupleType; 600 seenTuples.insert( mangleName ); 601 602 // T ?=?(T *, T); 603 FunctionType *assignType = genAssignType( tupleType ); 604 605 // void ?{}(T *); void ^?{}(T *); 606 FunctionType *ctorType = genDefaultType( tupleType ); 607 FunctionType *dtorType = genDefaultType( tupleType ); 608 609 // void ?{}(T *, T); 610 FunctionType *copyCtorType = genCopyType( tupleType ); 611 612 std::set< TypeDecl* > done; 613 std::list< TypeDecl * > typeParams; 614 for ( Type * t : *tupleType ) { 615 if ( TypeInstType * ty = dynamic_cast< TypeInstType * >( t ) ) { 616 if ( ! done.count( ty->get_baseType() ) ) { 617 TypeDecl * newDecl = new TypeDecl( ty->get_baseType()->get_name(), DeclarationNode::NoStorageClass, nullptr, TypeDecl::Any ); 618 TypeInstType * inst = new TypeInstType( Type::Qualifiers(), newDecl->get_name(), newDecl ); 619 newDecl->get_assertions().push_back( new FunctionDecl( "?=?", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, genAssignType( inst ), nullptr, true, false ) ); 620 newDecl->get_assertions().push_back( new FunctionDecl( "?{}", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, genDefaultType( inst ), nullptr, true, false ) ); 621 newDecl->get_assertions().push_back( new FunctionDecl( "?{}", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, genCopyType( inst ), nullptr, true, false ) ); 622 newDecl->get_assertions().push_back( new FunctionDecl( "^?{}", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, genDefaultType( inst ), nullptr, true, false ) ); 623 typeParams.push_back( newDecl ); 624 done.insert( ty->get_baseType() ); 625 } 626 } 627 } 628 cloneAll( typeParams, ctorType->get_forall() ); 629 cloneAll( typeParams, dtorType->get_forall() ); 630 cloneAll( typeParams, copyCtorType->get_forall() ); 631 cloneAll( typeParams, assignType->get_forall() ); 632 633 FunctionDecl *assignDecl = genFunc( "?=?", assignType, functionNesting ); 634 FunctionDecl *ctorDecl = genFunc( "?{}", ctorType, functionNesting ); 635 FunctionDecl *copyCtorDecl = genFunc( "?{}", copyCtorType, functionNesting ); 636 FunctionDecl *dtorDecl = genFunc( "^?{}", dtorType, functionNesting ); 637 638 makeTupleFunctionBody( assignDecl ); 639 makeTupleFunctionBody( ctorDecl ); 640 makeTupleFunctionBody( copyCtorDecl ); 641 makeTupleFunctionBody( dtorDecl ); 642 643 addDeclaration( ctorDecl ); 644 addDeclaration( copyCtorDecl ); 645 addDeclaration( dtorDecl ); 646 addDeclaration( assignDecl ); // assignment should come last since it uses copy constructor in return 647 648 return tupleType; 649 } 650 651 DeclarationWithType * AutogenTupleRoutines::mutate( FunctionDecl *functionDecl ) { 652 functionDecl->set_functionType( maybeMutate( functionDecl->get_functionType(), *this ) ); 653 mutateAll( functionDecl->get_oldDecls(), *this ); 654 functionNesting += 1; 655 functionDecl->set_statements( maybeMutate( functionDecl->get_statements(), *this ) ); 656 functionNesting -= 1; 657 return functionDecl; 658 } 659 660 CompoundStmt * AutogenTupleRoutines::mutate( CompoundStmt *compoundStmt ) { 661 seenTuples.beginScope(); 662 compoundStmt = safe_dynamic_cast< CompoundStmt * >( Parent::mutate( compoundStmt ) ); 663 seenTuples.endScope(); 664 return compoundStmt; 665 } 558 666 } // SymTab -
src/SymTab/Indexer.cc
r596f987b r66f8528 40 40 41 41 namespace SymTab { 42 struct NewScope { 43 NewScope( SymTab::Indexer & indexer ) : indexer( indexer ) { indexer.enterScope(); } 44 ~NewScope() { indexer.leaveScope(); } 45 SymTab::Indexer & indexer; 46 }; 47 42 48 template< typename TreeType, typename VisitorType > 43 49 inline void acceptNewScope( TreeType *tree, VisitorType &visitor ) { … … 454 460 void Indexer::visit( TupleAssignExpr *tupleExpr ) { 455 461 acceptNewScope( tupleExpr->get_result(), *this ); 456 enterScope(); 457 acceptAll( tupleExpr->get_tempDecls(), *this ); 458 acceptAll( tupleExpr->get_assigns(), *this ); 459 leaveScope(); 462 maybeAccept( tupleExpr->get_stmtExpr(), *this ); 460 463 } 461 464 -
src/SymTab/Indexer.h
r596f987b r66f8528 25 25 class Indexer : public Visitor { 26 26 public: 27 Indexer( bool useDebug = false );27 explicit Indexer( bool useDebug = false ); 28 28 29 29 Indexer( const Indexer &that ); -
src/SymTab/Validate.cc
r596f987b r66f8528 61 61 #include <algorithm> 62 62 #include "InitTweak/InitTweak.h" 63 #include "CodeGen/CodeGenerator.h" 63 64 64 65 #define debugPrint( x ) if ( doDebug ) { std::cout << x; } 65 66 66 67 namespace SymTab { 67 class HoistStruct : public Visitor {68 class HoistStruct final : public Visitor { 68 69 public: 69 70 /// Flattens nested struct types … … 86 87 }; 87 88 89 /// Fix return types so that every function returns exactly one value 90 class ReturnTypeFixer final : public Visitor { 91 public: 92 93 typedef Visitor Parent; 94 using Parent::visit; 95 96 static void fix( std::list< Declaration * > &translationUnit ); 97 98 virtual void visit( FunctionDecl * functionDecl ); 99 100 virtual void visit( FunctionType * ftype ); 101 }; 102 88 103 /// Replaces enum types by int, and function or array types in function parameter and return lists by appropriate pointers. 89 class EnumAndPointerDecayPass : public Visitor {104 class EnumAndPointerDecayPass final : public Visitor { 90 105 typedef Visitor Parent; 91 106 virtual void visit( EnumDecl *aggregateDecl ); … … 94 109 95 110 /// Associates forward declarations of aggregates with their definitions 96 class Pass2final : public Indexer {111 class LinkReferenceToTypes final : public Indexer { 97 112 typedef Indexer Parent; 98 113 public: 99 Pass2( bool doDebug, const Indexer *indexer );114 LinkReferenceToTypes( bool doDebug, const Indexer *indexer ); 100 115 private: 101 116 using Indexer::visit; … … 193 208 void validate( std::list< Declaration * > &translationUnit, bool doDebug ) { 194 209 EnumAndPointerDecayPass epc; 195 Pass2 pass2( doDebug, 0 );210 LinkReferenceToTypes lrt( doDebug, 0 ); 196 211 Pass3 pass3( 0 ); 197 212 CompoundLiteral compoundliteral; … … 199 214 EliminateTypedef::eliminateTypedef( translationUnit ); 200 215 HoistStruct::hoistStruct( translationUnit ); 216 ReturnTypeFixer::fix( translationUnit ); // must happen before autogen 201 217 autogenerateRoutines( translationUnit ); // moved up, used to be below compoundLiteral - currently needs EnumAndPointerDecayPass 202 218 acceptAll( translationUnit, epc ); 203 acceptAll( translationUnit, pass2);219 acceptAll( translationUnit, lrt ); 204 220 ReturnChecker::checkFunctionReturns( translationUnit ); 205 221 compoundliteral.mutateDeclarationList( translationUnit ); … … 210 226 void validateType( Type *type, const Indexer *indexer ) { 211 227 EnumAndPointerDecayPass epc; 212 Pass2 pass2( false, indexer );228 LinkReferenceToTypes lrt( false, indexer ); 213 229 Pass3 pass3( indexer ); 214 230 type->accept( epc ); 215 type->accept( pass2);231 type->accept( lrt ); 216 232 type->accept( pass3 ); 217 233 } … … 324 340 } 325 341 326 Pass2::Pass2( bool doDebug, const Indexer *other_indexer ) : Indexer( doDebug ) {342 LinkReferenceToTypes::LinkReferenceToTypes( bool doDebug, const Indexer *other_indexer ) : Indexer( doDebug ) { 327 343 if ( other_indexer ) { 328 344 indexer = other_indexer; … … 332 348 } 333 349 334 void Pass2::visit( StructInstType *structInst ) {350 void LinkReferenceToTypes::visit( StructInstType *structInst ) { 335 351 Parent::visit( structInst ); 336 352 StructDecl *st = indexer->lookupStruct( structInst->get_name() ); … … 346 362 } 347 363 348 void Pass2::visit( UnionInstType *unionInst ) {364 void LinkReferenceToTypes::visit( UnionInstType *unionInst ) { 349 365 Parent::visit( unionInst ); 350 366 UnionDecl *un = indexer->lookupUnion( unionInst->get_name() ); … … 359 375 } 360 376 361 void Pass2::visit( TraitInstType *contextInst ) {377 void LinkReferenceToTypes::visit( TraitInstType *contextInst ) { 362 378 Parent::visit( contextInst ); 379 if ( contextInst->get_name() == "sized" ) { 380 // "sized" is a special trait with no members - just flick the sized status on for the type variable 381 if ( contextInst->get_parameters().size() != 1 ) { 382 throw SemanticError( "incorrect number of context parameters: ", contextInst ); 383 } 384 TypeExpr * param = safe_dynamic_cast< TypeExpr * > ( contextInst->get_parameters().front() ); 385 TypeInstType * inst = safe_dynamic_cast< TypeInstType * > ( param->get_type() ); 386 TypeDecl * decl = inst->get_baseType(); 387 decl->set_sized( true ); 388 // since "sized" is special, the next few steps don't apply 389 return; 390 } 363 391 TraitDecl *ctx = indexer->lookupTrait( contextInst->get_name() ); 364 392 if ( ! ctx ) { … … 386 414 } 387 415 388 void Pass2::visit( StructDecl *structDecl ) {416 void LinkReferenceToTypes::visit( StructDecl *structDecl ) { 389 417 // visit struct members first so that the types of self-referencing members are updated properly 390 418 Parent::visit( structDecl ); … … 400 428 } 401 429 402 void Pass2::visit( UnionDecl *unionDecl ) {430 void LinkReferenceToTypes::visit( UnionDecl *unionDecl ) { 403 431 Parent::visit( unionDecl ); 404 432 if ( ! unionDecl->get_members().empty() ) { … … 413 441 } 414 442 415 void Pass2::visit( TypeInstType *typeInst ) {443 void LinkReferenceToTypes::visit( TypeInstType *typeInst ) { 416 444 if ( NamedTypeDecl *namedTypeDecl = lookupType( typeInst->get_name() ) ) { 417 445 if ( TypeDecl *typeDecl = dynamic_cast< TypeDecl * >( namedTypeDecl ) ) { … … 584 612 585 613 typedeclNames[ typeDecl->get_name() ] = typeDecl; 586 return typeDecl;614 return Mutator::mutate( typeDecl ); 587 615 } 588 616 … … 735 763 return new VariableExpr( newtempvar ); 736 764 } 765 766 void ReturnTypeFixer::fix( std::list< Declaration * > &translationUnit ) { 767 ReturnTypeFixer fixer; 768 acceptAll( translationUnit, fixer ); 769 } 770 771 void ReturnTypeFixer::visit( FunctionDecl * functionDecl ) { 772 Parent::visit( functionDecl ); 773 FunctionType * ftype = functionDecl->get_functionType(); 774 std::list< DeclarationWithType * > & retVals = ftype->get_returnVals(); 775 assertf( retVals.size() == 0 || retVals.size() == 1, "Function %s has too many return values: %d", functionDecl->get_name().c_str(), retVals.size() ); 776 if ( retVals.size() == 1 ) { 777 // ensure all function return values have a name - use the name of the function to disambiguate (this also provides a nice bit of help for debugging) 778 // ensure other return values have a name 779 DeclarationWithType * ret = retVals.front(); 780 if ( ret->get_name() == "" ) { 781 ret->set_name( toString( "_retval_", CodeGen::genName( functionDecl ) ) ); 782 } 783 } 784 } 785 786 void ReturnTypeFixer::visit( FunctionType * ftype ) { 787 // xxx - need to handle named return values - this information needs to be saved somehow 788 // so that resolution has access to the names. 789 // Note that this pass needs to happen early so that other passes which look for tuple types 790 // find them in all of the right places, including function return types. 791 std::list< DeclarationWithType * > & retVals = ftype->get_returnVals(); 792 if ( retVals.size() > 1 ) { 793 // generate a single return parameter which is the tuple of all of the return values 794 TupleType * tupleType = safe_dynamic_cast< TupleType * >( ResolvExpr::extractResultType( ftype ) ); 795 // ensure return value is not destructed by explicitly creating an empty ListInit node wherein maybeConstruct is false. 796 ObjectDecl * newRet = new ObjectDecl( "", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, tupleType, new ListInit( std::list<Initializer*>(), noDesignators, false ) ); 797 deleteAll( retVals ); 798 retVals.clear(); 799 retVals.push_back( newRet ); 800 } 801 } 737 802 } // namespace SymTab 738 803 -
src/SynTree/ApplicationExpr.cc
r596f987b r66f8528 30 30 if ( &other == this ) return *this; 31 31 decl = other.decl; 32 // xxx - this looks like a memory leak 32 33 actualType = maybeClone( other.actualType ); 33 34 formalType = maybeClone( other.formalType ); -
src/SynTree/CompoundStmt.cc
r596f987b r66f8528 49 49 Statement * origStmt = *origit++; 50 50 if ( DeclStmt * declStmt = dynamic_cast< DeclStmt * >( s ) ) { 51 DeclStmt * origDeclStmt = dynamic_cast< DeclStmt * >( origStmt ); 52 assert( origDeclStmt ); 51 DeclStmt * origDeclStmt = safe_dynamic_cast< DeclStmt * >( origStmt ); 53 52 if ( DeclarationWithType * dwt = dynamic_cast< DeclarationWithType * > ( declStmt->get_decl() ) ) { 54 DeclarationWithType * origdwt = dynamic_cast< DeclarationWithType * > ( origDeclStmt->get_decl() ); 55 assert( origdwt ); 53 DeclarationWithType * origdwt = safe_dynamic_cast< DeclarationWithType * > ( origDeclStmt->get_decl() ); 56 54 assert( dwt->get_name() == origdwt->get_name() ); 57 55 declMap[ origdwt ] = dwt; 58 } 59 } 56 } else assert( ! dynamic_cast< DeclarationWithType * > ( origDeclStmt->get_decl() ) ); 57 } else assert( ! dynamic_cast< DeclStmt * > ( s ) ); 60 58 } 61 59 if ( ! declMap.empty() ) { -
src/SynTree/Declaration.h
r596f987b r66f8528 180 180 public: 181 181 enum Kind { Any, Dtype, Ftype }; 182 /// Data extracted from a type decl 183 struct Data { 184 TypeDecl::Kind kind; 185 bool isComplete; 186 Data() : kind( (TypeDecl::Kind)-1 ), isComplete( false ) {} 187 Data( TypeDecl * typeDecl ) : Data( typeDecl->get_kind(), typeDecl->isComplete() ) {} 188 Data( Kind kind, bool isComplete ) : kind( kind ), isComplete( isComplete ) {} 189 bool operator==(const Data & other) const { return kind == other.kind && isComplete == other.isComplete; } 190 bool operator!=(const Data & other) const { return !(*this == other);} 191 }; 182 192 183 193 TypeDecl( const std::string &name, DeclarationNode::StorageClass sc, Type *type, Kind kind ); … … 186 196 Kind get_kind() const { return kind; } 187 197 198 bool isComplete() const { return kind == Any || sized; } 199 bool get_sized() const { return sized; } 200 TypeDecl * set_sized( bool newValue ) { sized = newValue; return this; } 201 188 202 virtual TypeDecl *clone() const { return new TypeDecl( *this ); } 189 203 virtual void accept( Visitor &v ) { v.visit( this ); } … … 192 206 virtual std::string typeString() const; 193 207 Kind kind; 208 bool sized; 194 209 }; 195 210 … … 284 299 285 300 std::ostream & operator<<( std::ostream & out, const Declaration * decl ); 301 std::ostream & operator<<( std::ostream & os, const TypeDecl::Data & data ); 286 302 287 303 #endif // DECLARATION_H -
src/SynTree/Expression.cc
r596f987b r66f8528 332 332 } 333 333 334 namespace { 335 TypeSubstitution makeSub( Type * t ) { 336 if ( StructInstType * aggInst = dynamic_cast< StructInstType * >( t ) ) { 337 return TypeSubstitution( aggInst->get_baseParameters()->begin(), aggInst->get_baseParameters()->end(), aggInst->get_parameters().begin() ); 338 } else if ( UnionInstType * aggInst = dynamic_cast< UnionInstType * >( t ) ) { 339 return TypeSubstitution( aggInst->get_baseParameters()->begin(), aggInst->get_baseParameters()->end(), aggInst->get_parameters().begin() ); 340 } else { 341 assertf( false, "makeSub expects struct or union type for aggregate" ); 342 } 343 } 344 } 345 334 346 335 347 MemberExpr::MemberExpr( DeclarationWithType *_member, Expression *_aggregate, Expression *_aname ) : 336 348 Expression( _aname ), member(_member), aggregate(_aggregate) { 337 set_result( member->get_type()->clone() ); 349 350 TypeSubstitution sub( makeSub( aggregate->get_result() ) ); 351 Type * res = member->get_type()->clone(); 352 sub.apply( res ); 353 set_result( res ); 338 354 get_result()->set_isLvalue( true ); 339 355 } … … 511 527 512 528 ImplicitCopyCtorExpr::~ImplicitCopyCtorExpr() { 529 set_env( nullptr ); // ImplicitCopyCtorExpr does not take ownership of an environment 513 530 delete callExpr; 514 531 deleteAll( tempDecls ); … … 520 537 os << "Implicit Copy Constructor Expression: " << std::endl; 521 538 assert( callExpr ); 539 os << std::string( indent+2, ' ' ); 522 540 callExpr->print( os, indent + 2 ); 523 541 os << std::endl << std::string( indent, ' ' ) << "with temporaries:" << std::endl; … … 571 589 os << std::string( indent+2, ' ' ); 572 590 initializer->print( os, indent + 2 ); 591 Expression::print( os, indent ); 573 592 } 574 593 … … 590 609 os << " ... "; 591 610 high->print( os, indent ); 611 Expression::print( os, indent ); 592 612 } 593 613 … … 601 621 } 602 622 } 603 StmtExpr::StmtExpr( const StmtExpr &other ) : Expression( other ), statements( other.statements->clone() ) {} 623 StmtExpr::StmtExpr( const StmtExpr &other ) : Expression( other ), statements( other.statements->clone() ) { 624 cloneAll( other.returnDecls, returnDecls ); 625 cloneAll( other.dtors, dtors ); 626 } 604 627 StmtExpr::~StmtExpr() { 605 628 delete statements; 629 deleteAll( dtors ); 630 deleteAll( returnDecls ); 606 631 } 607 632 void StmtExpr::print( std::ostream &os, int indent ) const { 608 633 os << "Statement Expression: " << std::endl << std::string( indent, ' ' ); 609 634 statements->print( os, indent+2 ); 635 if ( ! returnDecls.empty() ) { 636 os << std::string( indent+2, ' ' ) << "with returnDecls: "; 637 printAll( returnDecls, os, indent+2 ); 638 } 639 if ( ! dtors.empty() ) { 640 os << std::string( indent+2, ' ' ) << "with dtors: "; 641 printAll( dtors, os, indent+2 ); 642 } 643 Expression::print( os, indent ); 610 644 } 611 645 … … 631 665 get_expr()->print( os, indent+2 ); 632 666 if ( get_object() ) { 633 os << "with decl: ";667 os << std::string( indent+2, ' ' ) << "with decl: "; 634 668 get_object()->printShort( os, indent+2 ); 635 669 } 670 Expression::print( os, indent ); 636 671 } 637 672 -
src/SynTree/Expression.h
r596f987b r66f8528 543 543 544 544 std::list< ObjectDecl * > & get_tempDecls() { return tempDecls; } 545 void set_tempDecls( std::list< ObjectDecl * > newValue ) { tempDecls = newValue; }546 547 545 std::list< ObjectDecl * > & get_returnDecls() { return returnDecls; } 548 void set_returnDecls( std::list< ObjectDecl * > newValue ) { returnDecls = newValue; }549 550 546 std::list< Expression * > & get_dtors() { return dtors; } 551 void set_dtors( std::list< Expression * > newValue ) { dtors = newValue; }552 547 553 548 virtual ImplicitCopyCtorExpr *clone() const { return new ImplicitCopyCtorExpr( *this ); } … … 706 701 virtual ~TupleAssignExpr(); 707 702 708 std::list< Expression * > & get_assigns() { return assigns; }709 std::list< ObjectDecl * > & get_tempDecls() { return tempDecls; }703 TupleAssignExpr * set_stmtExpr( StmtExpr * newValue ) { stmtExpr = newValue; return this; } 704 StmtExpr * get_stmtExpr() const { return stmtExpr; } 710 705 711 706 virtual TupleAssignExpr *clone() const { return new TupleAssignExpr( *this ); } … … 714 709 virtual void print( std::ostream &os, int indent = 0 ) const; 715 710 private: 716 std::list< Expression * > assigns; // assignment expressions that use tempDecls 717 std::list< ObjectDecl * > tempDecls; // temporaries for address of lhs exprs 711 StmtExpr * stmtExpr = nullptr; 718 712 }; 719 713 … … 728 722 StmtExpr * set_statements( CompoundStmt * newValue ) { statements = newValue; return this; } 729 723 724 std::list< ObjectDecl * > & get_returnDecls() { return returnDecls; } 725 std::list< Expression * > & get_dtors() { return dtors; } 726 730 727 virtual StmtExpr *clone() const { return new StmtExpr( *this ); } 731 728 virtual void accept( Visitor &v ) { v.visit( this ); } … … 734 731 private: 735 732 CompoundStmt * statements; 733 std::list< ObjectDecl * > returnDecls; // return variable(s) for stmt expression 734 std::list< Expression * > dtors; // destructor(s) for return variable(s) 736 735 }; 737 736 -
src/SynTree/Initializer.cc
r596f987b r66f8528 65 65 } 66 66 67 ListInit::ListInit( const ListInit & other ) : Initializer( other ) { 68 cloneAll( other.initializers, initializers ); 69 cloneAll( other.designators, designators ); 70 } 71 72 67 73 ListInit::~ListInit() { 68 74 deleteAll( initializers ); -
src/SynTree/Initializer.h
r596f987b r66f8528 88 88 ListInit( const std::list<Initializer*> &initializers, 89 89 const std::list<Expression *> &designators = std::list< Expression * >(), bool maybeConstructed = false ); 90 ListInit( const ListInit & other ); 90 91 virtual ~ListInit(); 91 92 -
src/SynTree/Mutator.cc
r596f987b r66f8528 325 325 mutateAll( impCpCtorExpr->get_tempDecls(), *this ); 326 326 mutateAll( impCpCtorExpr->get_returnDecls(), *this ); 327 mutateAll( impCpCtorExpr->get_dtors(), *this ); 327 328 return impCpCtorExpr; 328 329 } … … 373 374 Expression *Mutator::mutate( TupleAssignExpr *assignExpr ) { 374 375 assignExpr->set_result( maybeMutate( assignExpr->get_result(), *this ) ); 375 mutateAll( assignExpr->get_tempDecls(), *this ); 376 mutateAll( assignExpr->get_assigns(), *this ); 376 assignExpr->set_stmtExpr( maybeMutate( assignExpr->get_stmtExpr(), *this ) ); 377 377 return assignExpr; 378 378 } … … 381 381 stmtExpr->set_result( maybeMutate( stmtExpr->get_result(), *this ) ); 382 382 stmtExpr->set_statements( maybeMutate( stmtExpr->get_statements(), *this ) ); 383 mutateAll( stmtExpr->get_returnDecls(), *this ); 384 mutateAll( stmtExpr->get_dtors(), *this ); 383 385 return stmtExpr; 384 386 } … … 503 505 Initializer *Mutator::mutate( ConstructorInit *ctorInit ) { 504 506 ctorInit->set_ctor( maybeMutate( ctorInit->get_ctor(), *this ) ); 507 ctorInit->set_dtor( maybeMutate( ctorInit->get_dtor(), *this ) ); 505 508 ctorInit->set_init( maybeMutate( ctorInit->get_init(), *this ) ); 506 509 return ctorInit; -
src/SynTree/ReferenceToType.cc
r596f987b r66f8528 46 46 47 47 namespace { 48 void doLookup( const std::list< Declaration* > &members, const std::list< TypeDecl* > &parms, const std::list< Expression* > &args, const std::string &name, std::list< Declaration* > &foundDecls ) { 49 std::list< Declaration* > found; 48 void doLookup( const std::list< Declaration* > &members, const std::string &name, std::list< Declaration* > &foundDecls ) { 50 49 for ( std::list< Declaration* >::const_iterator i = members.begin(); i != members.end(); ++i ) { 51 50 if ( (*i)->get_name() == name ) { 52 found .push_back( *i );51 foundDecls.push_back( *i ); 53 52 } // if 54 53 } // for 55 applySubstitution( parms.begin(), parms.end(), args.begin(), found.begin(), found.end(), back_inserter( foundDecls ) );56 54 } 57 55 } // namespace … … 68 66 void StructInstType::lookup( const std::string &name, std::list< Declaration* > &foundDecls ) const { 69 67 assert( baseStruct ); 70 doLookup( baseStruct->get_members(), baseStruct->get_parameters(), parameters,name, foundDecls );68 doLookup( baseStruct->get_members(), name, foundDecls ); 71 69 } 72 70 … … 94 92 void UnionInstType::lookup( const std::string &name, std::list< Declaration* > &foundDecls ) const { 95 93 assert( baseUnion ); 96 doLookup( baseUnion->get_members(), baseUnion->get_parameters(), parameters,name, foundDecls );94 doLookup( baseUnion->get_members(), name, foundDecls ); 97 95 } 98 96 … … 130 128 } 131 129 130 TypeInstType::TypeInstType( const TypeInstType &other ) : Parent( other ), baseType( other.baseType ), isFtype( other.isFtype ) { 131 } 132 133 132 134 TypeInstType::~TypeInstType() { 133 135 // delete baseType; //This is shared and should not be deleted -
src/SynTree/TupleExpr.cc
r596f987b r66f8528 87 87 } 88 88 89 90 TupleAssignExpr::TupleAssignExpr( const std::list< Expression * > & assigns, const std::list< ObjectDecl * > & tempDecls, Expression * _aname ) : Expression( _aname ), assigns( assigns ), tempDecls( tempDecls ) { 89 TupleAssignExpr::TupleAssignExpr( const std::list< Expression * > & assigns, const std::list< ObjectDecl * > & tempDecls, Expression * _aname ) : Expression( _aname ) { 90 // convert internally into a StmtExpr which contains the declarations and produces the tuple of the assignments 91 91 set_result( Tuples::makeTupleType( assigns ) ); 92 CompoundStmt * compoundStmt = new CompoundStmt( noLabels ); 93 std::list< Statement * > & stmts = compoundStmt->get_kids(); 94 for ( ObjectDecl * obj : tempDecls ) { 95 stmts.push_back( new DeclStmt( noLabels, obj ) ); 96 } 97 TupleExpr * tupleExpr = new TupleExpr( assigns ); 98 assert( tupleExpr->get_result() ); 99 stmts.push_back( new ExprStmt( noLabels, tupleExpr ) ); 100 stmtExpr = new StmtExpr( compoundStmt ); 92 101 } 93 102 94 103 TupleAssignExpr::TupleAssignExpr( const TupleAssignExpr &other ) : Expression( other ) { 95 cloneAll( other.assigns, assigns ); 96 cloneAll( other.tempDecls, tempDecls ); 97 98 // clone needs to go into assigns and replace tempDecls 99 VarExprReplacer::DeclMap declMap; 100 std::list< ObjectDecl * >::const_iterator origit = other.tempDecls.begin(); 101 for ( ObjectDecl * temp : tempDecls ) { 102 assert( origit != other.tempDecls.end() ); 103 ObjectDecl * origTemp = *origit++; 104 assert( origTemp ); 105 assert( temp->get_name() == origTemp->get_name() ); 106 declMap[ origTemp ] = temp; 107 } 108 if ( ! declMap.empty() ) { 109 VarExprReplacer replacer( declMap ); 110 for ( Expression * assn : assigns ) { 111 assn->accept( replacer ); 112 } 113 } 104 assert( other.stmtExpr ); 105 stmtExpr = other.stmtExpr->clone(); 114 106 } 115 107 116 108 TupleAssignExpr::~TupleAssignExpr() { 117 deleteAll( assigns ); 118 // deleteAll( tempDecls ); 109 delete stmtExpr; 119 110 } 120 111 121 112 void TupleAssignExpr::print( std::ostream &os, int indent ) const { 122 os << "Tuple Assignment Expression, with temporaries:" << std::endl; 123 printAll( tempDecls, os, indent+4 ); 124 os << std::string( indent+2, ' ' ) << "with assignments: " << std::endl; 125 printAll( assigns, os, indent+4 ); 113 os << "Tuple Assignment Expression, with stmt expr:" << std::endl; 114 os << std::string( indent+2, ' ' ); 115 stmtExpr->print( os, indent+4 ); 126 116 Expression::print( os, indent ); 127 117 } -
src/SynTree/Type.h
r596f987b r66f8528 72 72 virtual unsigned size() const { return 1; }; 73 73 virtual bool isVoid() const { return size() == 0; } 74 virtual Type * getComponent( unsigned i ) { assertf( size() == 1 && i == 0, "Type::getComponent was called with size %d and index %d\n", size(), i ); return this; } 74 75 75 76 virtual Type *clone() const = 0; … … 339 340 TypeInstType( const Type::Qualifiers &tq, const std::string &name, TypeDecl *baseType ); 340 341 TypeInstType( const Type::Qualifiers &tq, const std::string &name, bool isFtype ); 341 TypeInstType( const TypeInstType &other ) : Parent( other ), baseType( other.baseType ), isFtype( other.isFtype ) {}342 TypeInstType( const TypeInstType &other ); 342 343 ~TypeInstType(); 343 344 … … 373 374 iterator begin() { return types.begin(); } 374 375 iterator end() { return types.end(); } 376 377 virtual Type * getComponent( unsigned i ) { 378 assertf( i < size(), "TupleType::getComponent: index %d must be less than size %d", i, size() ); 379 return *(begin()+i); 380 } 375 381 376 382 virtual TupleType *clone() const { return new TupleType( *this ); } -
src/SynTree/TypeDecl.cc
r596f987b r66f8528 5 5 // file "LICENCE" distributed with Cforall. 6 6 // 7 // TypeDecl.cc -- 7 // TypeDecl.cc -- 8 8 // 9 9 // Author : Richard C. Bilson … … 18 18 #include "Common/utility.h" 19 19 20 TypeDecl::TypeDecl( const std::string &name, DeclarationNode::StorageClass sc, Type *type, Kind kind ) : Parent( name, sc, type ), kind( kind ) {20 TypeDecl::TypeDecl( const std::string &name, DeclarationNode::StorageClass sc, Type *type, Kind kind ) : Parent( name, sc, type ), kind( kind ), sized( kind == Any ) { 21 21 } 22 22 23 TypeDecl::TypeDecl( const TypeDecl &other ) : Parent( other ), kind( other.kind ) {23 TypeDecl::TypeDecl( const TypeDecl &other ) : Parent( other ), kind( other.kind ), sized( other.sized ) { 24 24 } 25 25 … … 29 29 } 30 30 31 std::ostream & operator<<( std::ostream & os, const TypeDecl::Data & data ) { 32 return os << data.kind << ", " << data.isComplete; 33 } 34 31 35 // Local Variables: // 32 36 // tab-width: 4 // -
src/SynTree/VarExprReplacer.cc
r596f987b r66f8528 21 21 // replace variable with new node from decl map 22 22 void VarExprReplacer::visit( VariableExpr * varExpr ) { 23 // xxx - assertions and parameters aren't accounted for in this... (i.e. they aren't inserted into the map when it's made, only DeclStmts are) 23 24 if ( declMap.count( varExpr->get_var() ) ) { 24 25 varExpr->set_var( declMap.at( varExpr->get_var() ) ); -
src/SynTree/Visitor.cc
r596f987b r66f8528 276 276 acceptAll( impCpCtorExpr->get_tempDecls(), *this ); 277 277 acceptAll( impCpCtorExpr->get_returnDecls(), *this ); 278 acceptAll( impCpCtorExpr->get_dtors(), *this ); 278 279 } 279 280 … … 317 318 void Visitor::visit( TupleAssignExpr *assignExpr ) { 318 319 maybeAccept( assignExpr->get_result(), *this ); 319 acceptAll( assignExpr->get_tempDecls(), *this ); 320 acceptAll( assignExpr->get_assigns(), *this ); 320 maybeAccept( assignExpr->get_stmtExpr(), *this ); 321 321 } 322 322 … … 324 324 maybeAccept( stmtExpr->get_result(), *this ); 325 325 maybeAccept( stmtExpr->get_statements(), *this ); 326 acceptAll( stmtExpr->get_returnDecls(), *this ); 327 acceptAll( stmtExpr->get_dtors(), *this ); 326 328 } 327 329 … … 425 427 void Visitor::visit( ConstructorInit *ctorInit ) { 426 428 maybeAccept( ctorInit->get_ctor(), *this ); 429 maybeAccept( ctorInit->get_dtor(), *this ); 427 430 maybeAccept( ctorInit->get_init(), *this ); 428 431 } -
src/Tuples/Explode.cc
r596f987b r66f8528 23 23 Expression * applyAddr( Expression * expr, bool first = true ) { 24 24 if ( TupleExpr * tupleExpr = dynamic_cast< TupleExpr * >( expr ) ){ 25 foundUniqueExpr = true; 25 26 std::list< Expression * > exprs; 26 27 for ( Expression *& expr : tupleExpr->get_exprs() ) { … … 46 47 // should now be a tuple of addresses rather than the address of a tuple. 47 48 // Still, this code is a bit awkward, and could use some improvement. 48 foundUniqueExpr = true; 49 if ( dynamic_cast< AddressExpr * > ( uniqueExpr->get_expr() ) ) { 50 // this unique expression has already been mutated or otherwise shouldn't be (can't take the address-of an address-of expression) 51 return uniqueExpr; 52 } 49 53 UniqueExpr * newUniqueExpr = new UniqueExpr( applyAddr( uniqueExpr->get_expr() ), uniqueExpr->get_id() ); 50 54 delete uniqueExpr; -
src/Tuples/TupleAssignment.cc
r596f987b r66f8528 23 23 #include "Common/SemanticError.h" 24 24 #include "InitTweak/InitTweak.h" 25 #include "InitTweak/GenInit.h" 25 26 26 27 #include <functional> … … 47 48 virtual ~Matcher() {} 48 49 virtual void match( std::list< Expression * > &out ) = 0; 50 ObjectDecl * newObject( UniqueName & namer, Expression * expr ); 49 51 ResolvExpr::AltList lhs, rhs; 50 52 TupleAssignSpotter &spotter; 53 ResolvExpr::Cost baseCost; 51 54 std::list< ObjectDecl * > tmpDecls; 55 ResolvExpr::TypeEnvironment compositeEnv; 52 56 }; 53 57 … … 146 150 finder.findWithAdjustment(*i); 147 151 } catch (...) { 148 return; // xxx -no match should not mean failure, it just means this particular tuple assignment isn't valid152 return; // no match should not mean failure, it just means this particular tuple assignment isn't valid 149 153 } 150 154 // prune expressions that don't coincide with … … 161 165 solved_assigns.push_back( alt.expr->clone() ); 162 166 } 163 // xxx - need to do this?? 164 ResolvExpr::TypeEnvironment compositeEnv; 165 simpleCombineEnvironments( current.begin(), current.end(), compositeEnv ); 166 currentFinder.get_alternatives().push_front( ResolvExpr::Alternative(new TupleAssignExpr(solved_assigns, matcher->tmpDecls), compositeEnv, ResolvExpr::sumCost( current ) ) ); 167 } 168 169 TupleAssignSpotter::Matcher::Matcher( TupleAssignSpotter &spotter, const ResolvExpr::AltList &alts ) : spotter(spotter) { 167 // combine assignment environments into combined expression environment 168 simpleCombineEnvironments( current.begin(), current.end(), matcher->compositeEnv ); 169 currentFinder.get_alternatives().push_front( ResolvExpr::Alternative(new TupleAssignExpr(solved_assigns, matcher->tmpDecls), matcher->compositeEnv, ResolvExpr::sumCost( current ) + matcher->baseCost ) ); 170 } 171 172 TupleAssignSpotter::Matcher::Matcher( TupleAssignSpotter &spotter, const ResolvExpr::AltList &alts ) : spotter(spotter), baseCost( ResolvExpr::sumCost( alts ) ) { 170 173 assert( ! alts.empty() ); 174 // combine argument environments into combined expression environment 175 simpleCombineEnvironments( alts.begin(), alts.end(), compositeEnv ); 176 171 177 ResolvExpr::Alternative lhsAlt = alts.front(); 172 178 // peel off the cast that exists on ctor/dtor expressions … … 217 223 } 218 224 219 ObjectDecl * newObject( UniqueName & namer, Expression * expr ) { 225 // removes environments from subexpressions within statement exprs, which could throw off later passes like those in Box which rely on PolyMutator. 226 // xxx - maybe this should happen in alternative finder for every StmtExpr? 227 // xxx - it's possible that these environments could contain some useful information. Maybe the right thing to do is aggregate the environments and pass the aggregate back to be added into the compositeEnv 228 struct EnvRemover : public Visitor { 229 virtual void visit( ExprStmt * stmt ) { 230 delete stmt->get_expr()->get_env(); 231 stmt->get_expr()->set_env( nullptr ); 232 Visitor::visit( stmt ); 233 } 234 }; 235 236 ObjectDecl * TupleAssignSpotter::Matcher::newObject( UniqueName & namer, Expression * expr ) { 220 237 assert( expr->has_result() && ! expr->get_result()->isVoid() ); 221 return new ObjectDecl( namer.newName(), DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, expr->get_result()->clone(), new SingleInit( expr->clone() ) ); 238 ObjectDecl * ret = new ObjectDecl( namer.newName(), DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, expr->get_result()->clone(), new SingleInit( expr->clone() ) ); 239 ConstructorInit * ctorInit = InitTweak::genCtorInit( ret ); 240 ret->set_init( ctorInit ); 241 ResolvExpr::resolveCtorInit( ctorInit, spotter.currentFinder.get_indexer() ); // resolve ctor/dtors for the new object 242 EnvRemover rm; // remove environments from subexpressions of StmtExprs 243 ctorInit->accept( rm ); 244 return ret; 222 245 } 223 246 … … 244 267 std::list< ObjectDecl * > ltmp; 245 268 std::list< ObjectDecl * > rtmp; 246 std::transform( lhs.begin(), lhs.end(), back_inserter( ltmp ), [ ]( ResolvExpr::Alternative & alt ){269 std::transform( lhs.begin(), lhs.end(), back_inserter( ltmp ), [&]( ResolvExpr::Alternative & alt ){ 247 270 return newObject( lhsNamer, alt.expr ); 248 271 }); 249 std::transform( rhs.begin(), rhs.end(), back_inserter( rtmp ), [ ]( ResolvExpr::Alternative & alt ){272 std::transform( rhs.begin(), rhs.end(), back_inserter( rtmp ), [&]( ResolvExpr::Alternative & alt ){ 250 273 return newObject( rhsNamer, alt.expr ); 251 274 }); -
src/Tuples/TupleExpansion.cc
r596f987b r66f8528 93 93 typedef Mutator Parent; 94 94 using Parent::mutate; 95 95 96 96 virtual Expression * mutate( TupleExpr * tupleExpr ) override; 97 97 }; … … 194 194 new CommaExpr( new CommaExpr( assignUnq, assignFinished ), var->clone() ) ); 195 195 condExpr->set_result( var->get_result()->clone() ); 196 condExpr->set_env( maybeClone( unqExpr->get_env() ) ); 196 197 decls[id] = condExpr; 197 198 } … … 202 203 Expression * TupleAssignExpander::mutate( TupleAssignExpr * assnExpr ) { 203 204 assnExpr = safe_dynamic_cast< TupleAssignExpr * >( Parent::mutate( assnExpr ) ); 204 CompoundStmt * compoundStmt = new CompoundStmt( noLabels ); 205 std::list< Statement * > & stmts = compoundStmt->get_kids(); 206 for ( ObjectDecl * obj : assnExpr->get_tempDecls() ) { 207 stmts.push_back( new DeclStmt( noLabels, obj ) ); 208 } 209 TupleExpr * tupleExpr = new TupleExpr( assnExpr->get_assigns() ); 210 assert( tupleExpr->get_result() ); 211 stmts.push_back( new ExprStmt( noLabels, tupleExpr ) ); 212 assnExpr->get_tempDecls().clear(); 213 assnExpr->get_assigns().clear(); 205 StmtExpr * ret = assnExpr->get_stmtExpr(); 206 assnExpr->set_stmtExpr( nullptr ); 207 // move env to StmtExpr 208 ret->set_env( assnExpr->get_env() ); 209 assnExpr->set_env( nullptr ); 214 210 delete assnExpr; 215 return new StmtExpr( compoundStmt );211 return ret; 216 212 } 217 213 218 214 Type * TupleTypeReplacer::mutate( TupleType * tupleType ) { 219 215 std::string mangleName = SymTab::Mangler::mangleType( tupleType ); 220 TupleType * newType = safe_dynamic_cast< TupleType * > ( Parent::mutate( tupleType ) );216 tupleType = safe_dynamic_cast< TupleType * > ( Parent::mutate( tupleType ) ); 221 217 if ( ! typeMap.count( mangleName ) ) { 222 218 // generate struct type to replace tuple type 219 // xxx - should fix this to only generate one tuple struct for each number of type parameters 223 220 StructDecl * decl = new StructDecl( "_tuple_type_" + mangleName ); 224 221 decl->set_body( true ); 225 int cnt = 0; 226 for ( Type * t : *newType ) { 227 decl->get_members().push_back( new ObjectDecl( toString("field_", cnt++), DeclarationNode::NoStorageClass, LinkageSpec::C, nullptr, t->clone(), nullptr ) ); 222 for ( size_t i = 0; i < tupleType->size(); ++i ) { 223 TypeDecl * tyParam = new TypeDecl( toString("tuple_param_", i), DeclarationNode::NoStorageClass, nullptr, TypeDecl::Any ); 224 decl->get_members().push_back( new ObjectDecl( toString("field_", i), DeclarationNode::NoStorageClass, LinkageSpec::C, nullptr, new TypeInstType( Type::Qualifiers(), tyParam->get_name(), tyParam ), nullptr ) ); 225 decl->get_parameters().push_back( tyParam ); 228 226 } 229 227 typeMap[mangleName] = decl; 230 228 addDeclaration( decl ); 231 229 } 232 Type::Qualifiers qualifiers = newType->get_qualifiers(); 233 delete newType; 234 return new StructInstType( qualifiers, typeMap[mangleName] ); 230 Type::Qualifiers qualifiers = tupleType->get_qualifiers(); 231 232 StructDecl * decl = typeMap[mangleName]; 233 StructInstType * newType = new StructInstType( qualifiers, decl ); 234 for ( Type * t : *tupleType ) { 235 newType->get_parameters().push_back( new TypeExpr( t->clone() ) ); 236 } 237 delete tupleType; 238 return newType; 235 239 } 236 240 … … 240 244 tupleExpr->set_tuple( nullptr ); 241 245 unsigned int idx = tupleExpr->get_index(); 246 TypeSubstitution * env = tupleExpr->get_env(); 247 tupleExpr->set_env( nullptr ); 242 248 delete tupleExpr; 243 249 … … 246 252 assert( structDecl->get_members().size() > idx ); 247 253 Declaration * member = *std::next(structDecl->get_members().begin(), idx); 248 return new MemberExpr( safe_dynamic_cast< DeclarationWithType * >( member ), tuple ); 249 } 250 251 Expression * replaceTupleExpr( Type * result, const std::list< Expression * > & exprs ) { 254 MemberExpr * memExpr = new MemberExpr( safe_dynamic_cast< DeclarationWithType * >( member ), tuple ); 255 memExpr->set_env( env ); 256 return memExpr; 257 } 258 259 Expression * replaceTupleExpr( Type * result, const std::list< Expression * > & exprs, TypeSubstitution * env ) { 252 260 if ( result->isVoid() ) { 253 261 // void result - don't need to produce a value for cascading - just output a chain of comma exprs 254 262 assert( ! exprs.empty() ); 255 263 std::list< Expression * >::const_iterator iter = exprs.begin(); 256 Expression * expr = *iter++;264 Expression * expr = new CastExpr( *iter++ ); 257 265 for ( ; iter != exprs.end(); ++iter ) { 258 expr = new CommaExpr( expr, *iter ); 259 } 266 expr = new CommaExpr( expr, new CastExpr( *iter ) ); 267 } 268 expr->set_env( env ); 260 269 return expr; 261 270 } else { … … 267 276 inits.push_back( new SingleInit( expr ) ); 268 277 } 269 return new CompoundLiteralExpr( result, new ListInit( inits ) ); 278 Expression * expr = new CompoundLiteralExpr( result, new ListInit( inits ) ); 279 expr->set_env( env ); 280 return expr; 270 281 } 271 282 } … … 277 288 std::list< Expression * > exprs = tupleExpr->get_exprs(); 278 289 assert( result ); 290 TypeSubstitution * env = tupleExpr->get_env(); 279 291 280 292 // remove data from shell and delete it 281 293 tupleExpr->set_result( nullptr ); 282 294 tupleExpr->get_exprs().clear(); 295 tupleExpr->set_env( nullptr ); 283 296 delete tupleExpr; 284 297 285 return replaceTupleExpr( result, exprs );298 return replaceTupleExpr( result, exprs, env ); 286 299 } 287 300 -
src/main.cc
r596f987b r66f8528 266 266 OPTPRINT( "expandUniqueExpr" ); // xxx - is this the right place for this? want to expand ASAP so that subsequent passes don't need to worry about double-visiting a unique expr - needs to go after InitTweak::fix so that copy constructed return declarations are reused 267 267 Tuples::expandUniqueExpr( translationUnit ); 268 OPTPRINT( "expandTuples" ); // xxx - is this the right place for this? 269 Tuples::expandTuples( translationUnit ); 268 270 269 271 OPTPRINT("instantiateGenerics") … … 282 284 OPTPRINT( "box" ) 283 285 GenPoly::box( translationUnit ); 284 OPTPRINT( "expandTuples" ); // xxx - is this the right place for this?285 Tuples::expandTuples( translationUnit );286 286 287 287 // print tree right before code generation -
src/prelude/prelude.cf
r596f987b r66f8528 105 105 forall( otype T ) const volatile T * --?( const volatile T ** ); 106 106 107 forall( otype T) lvalue T *?( T * );108 forall( otype T) const lvalue T *?( const T * );109 forall( otype T) volatile lvalue T *?( volatile T * );110 forall( otype T) const volatile lvalue T *?( const volatile T * );107 forall( dtype T | sized(T) ) lvalue T *?( T * ); 108 forall( dtype T | sized(T) ) const lvalue T *?( const T * ); 109 forall( dtype T | sized(T) ) volatile lvalue T *?( volatile T * ); 110 forall( dtype T | sized(T) ) const volatile lvalue T *?( const volatile T * ); 111 111 forall( ftype FT ) lvalue FT *?( FT * ); 112 112 -
src/tests/.expect/32/declarationSpecifier.txt
r596f987b r66f8528 20 20 static inline void ___constructor__F_P13s__anonymous013s__anonymous0_autogen___1(struct __anonymous0 *___dst__P13s__anonymous0_1, struct __anonymous0 ___src__13s__anonymous0_1); 21 21 static inline void ___destructor__F_P13s__anonymous0_autogen___1(struct __anonymous0 *___dst__P13s__anonymous0_1); 22 static inline void ___constructor__F_P13s__anonymous0_autogen___1(struct __anonymous0 *___dst__P13s__anonymous0_1){ 23 ((void)((*((int *)(&(*___dst__P13s__anonymous0_1).__i__i_1)))) /* ?{} */); 24 } 25 static inline void ___constructor__F_P13s__anonymous013s__anonymous0_autogen___1(struct __anonymous0 *___dst__P13s__anonymous0_1, struct __anonymous0 ___src__13s__anonymous0_1){ 26 ((void)((*((int *)(&(*___dst__P13s__anonymous0_1).__i__i_1)))=___src__13s__anonymous0_1.__i__i_1) /* ?{} */); 27 } 28 static inline void ___destructor__F_P13s__anonymous0_autogen___1(struct __anonymous0 *___dst__P13s__anonymous0_1){ 29 ((void)((*((int *)(&(*___dst__P13s__anonymous0_1).__i__i_1)))) /* ^?{} */); 30 } 22 31 static inline struct __anonymous0 ___operator_assign__F13s__anonymous0_P13s__anonymous013s__anonymous0_autogen___1(struct __anonymous0 *___dst__P13s__anonymous0_1, struct __anonymous0 ___src__13s__anonymous0_1){ 23 32 ((void)((*___dst__P13s__anonymous0_1).__i__i_1=___src__13s__anonymous0_1.__i__i_1)); 24 33 return ((struct __anonymous0 )___src__13s__anonymous0_1); 25 }26 static inline void ___constructor__F_P13s__anonymous0_autogen___1(struct __anonymous0 *___dst__P13s__anonymous0_1){27 ((void)((*((int *)(&(*___dst__P13s__anonymous0_1).__i__i_1)))) /* ?{} */);28 }29 static inline void ___constructor__F_P13s__anonymous013s__anonymous0_autogen___1(struct __anonymous0 *___dst__P13s__anonymous0_1, struct __anonymous0 ___src__13s__anonymous0_1){30 ((void)((*((int *)(&(*___dst__P13s__anonymous0_1).__i__i_1)))=___src__13s__anonymous0_1.__i__i_1) /* ?{} */);31 }32 static inline void ___destructor__F_P13s__anonymous0_autogen___1(struct __anonymous0 *___dst__P13s__anonymous0_1){33 ((void)((*((int *)(&(*___dst__P13s__anonymous0_1).__i__i_1)))) /* ^?{} */);34 34 } 35 35 static inline void ___constructor__F_P13s__anonymous0i_autogen___1(struct __anonymous0 *___dst__P13s__anonymous0_1, int __i__i_1){ … … 44 44 static inline void ___constructor__F_P13s__anonymous113s__anonymous1_autogen___1(struct __anonymous1 *___dst__P13s__anonymous1_1, struct __anonymous1 ___src__13s__anonymous1_1); 45 45 static inline void ___destructor__F_P13s__anonymous1_autogen___1(struct __anonymous1 *___dst__P13s__anonymous1_1); 46 static inline void ___constructor__F_P13s__anonymous1_autogen___1(struct __anonymous1 *___dst__P13s__anonymous1_1){ 47 ((void)((*((int *)(&(*___dst__P13s__anonymous1_1).__i__i_1)))) /* ?{} */); 48 } 49 static inline void ___constructor__F_P13s__anonymous113s__anonymous1_autogen___1(struct __anonymous1 *___dst__P13s__anonymous1_1, struct __anonymous1 ___src__13s__anonymous1_1){ 50 ((void)((*((int *)(&(*___dst__P13s__anonymous1_1).__i__i_1)))=___src__13s__anonymous1_1.__i__i_1) /* ?{} */); 51 } 52 static inline void ___destructor__F_P13s__anonymous1_autogen___1(struct __anonymous1 *___dst__P13s__anonymous1_1){ 53 ((void)((*((int *)(&(*___dst__P13s__anonymous1_1).__i__i_1)))) /* ^?{} */); 54 } 46 55 static inline struct __anonymous1 ___operator_assign__F13s__anonymous1_P13s__anonymous113s__anonymous1_autogen___1(struct __anonymous1 *___dst__P13s__anonymous1_1, struct __anonymous1 ___src__13s__anonymous1_1){ 47 56 ((void)((*___dst__P13s__anonymous1_1).__i__i_1=___src__13s__anonymous1_1.__i__i_1)); 48 57 return ((struct __anonymous1 )___src__13s__anonymous1_1); 49 }50 static inline void ___constructor__F_P13s__anonymous1_autogen___1(struct __anonymous1 *___dst__P13s__anonymous1_1){51 ((void)((*((int *)(&(*___dst__P13s__anonymous1_1).__i__i_1)))) /* ?{} */);52 }53 static inline void ___constructor__F_P13s__anonymous113s__anonymous1_autogen___1(struct __anonymous1 *___dst__P13s__anonymous1_1, struct __anonymous1 ___src__13s__anonymous1_1){54 ((void)((*((int *)(&(*___dst__P13s__anonymous1_1).__i__i_1)))=___src__13s__anonymous1_1.__i__i_1) /* ?{} */);55 }56 static inline void ___destructor__F_P13s__anonymous1_autogen___1(struct __anonymous1 *___dst__P13s__anonymous1_1){57 ((void)((*((int *)(&(*___dst__P13s__anonymous1_1).__i__i_1)))) /* ^?{} */);58 58 } 59 59 static inline void ___constructor__F_P13s__anonymous1i_autogen___1(struct __anonymous1 *___dst__P13s__anonymous1_1, int __i__i_1){ … … 68 68 static inline void ___constructor__F_P13s__anonymous213s__anonymous2_autogen___1(struct __anonymous2 *___dst__P13s__anonymous2_1, struct __anonymous2 ___src__13s__anonymous2_1); 69 69 static inline void ___destructor__F_P13s__anonymous2_autogen___1(struct __anonymous2 *___dst__P13s__anonymous2_1); 70 static inline void ___constructor__F_P13s__anonymous2_autogen___1(struct __anonymous2 *___dst__P13s__anonymous2_1){ 71 ((void)((*((int *)(&(*___dst__P13s__anonymous2_1).__i__i_1)))) /* ?{} */); 72 } 73 static inline void ___constructor__F_P13s__anonymous213s__anonymous2_autogen___1(struct __anonymous2 *___dst__P13s__anonymous2_1, struct __anonymous2 ___src__13s__anonymous2_1){ 74 ((void)((*((int *)(&(*___dst__P13s__anonymous2_1).__i__i_1)))=___src__13s__anonymous2_1.__i__i_1) /* ?{} */); 75 } 76 static inline void ___destructor__F_P13s__anonymous2_autogen___1(struct __anonymous2 *___dst__P13s__anonymous2_1){ 77 ((void)((*((int *)(&(*___dst__P13s__anonymous2_1).__i__i_1)))) /* ^?{} */); 78 } 70 79 static inline struct __anonymous2 ___operator_assign__F13s__anonymous2_P13s__anonymous213s__anonymous2_autogen___1(struct __anonymous2 *___dst__P13s__anonymous2_1, struct __anonymous2 ___src__13s__anonymous2_1){ 71 80 ((void)((*___dst__P13s__anonymous2_1).__i__i_1=___src__13s__anonymous2_1.__i__i_1)); 72 81 return ((struct __anonymous2 )___src__13s__anonymous2_1); 73 }74 static inline void ___constructor__F_P13s__anonymous2_autogen___1(struct __anonymous2 *___dst__P13s__anonymous2_1){75 ((void)((*((int *)(&(*___dst__P13s__anonymous2_1).__i__i_1)))) /* ?{} */);76 }77 static inline void ___constructor__F_P13s__anonymous213s__anonymous2_autogen___1(struct __anonymous2 *___dst__P13s__anonymous2_1, struct __anonymous2 ___src__13s__anonymous2_1){78 ((void)((*((int *)(&(*___dst__P13s__anonymous2_1).__i__i_1)))=___src__13s__anonymous2_1.__i__i_1) /* ?{} */);79 }80 static inline void ___destructor__F_P13s__anonymous2_autogen___1(struct __anonymous2 *___dst__P13s__anonymous2_1){81 ((void)((*((int *)(&(*___dst__P13s__anonymous2_1).__i__i_1)))) /* ^?{} */);82 82 } 83 83 static inline void ___constructor__F_P13s__anonymous2i_autogen___1(struct __anonymous2 *___dst__P13s__anonymous2_1, int __i__i_1){ … … 92 92 static inline void ___constructor__F_P13s__anonymous313s__anonymous3_autogen___1(struct __anonymous3 *___dst__P13s__anonymous3_1, struct __anonymous3 ___src__13s__anonymous3_1); 93 93 static inline void ___destructor__F_P13s__anonymous3_autogen___1(struct __anonymous3 *___dst__P13s__anonymous3_1); 94 static inline void ___constructor__F_P13s__anonymous3_autogen___1(struct __anonymous3 *___dst__P13s__anonymous3_1){ 95 ((void)((*((int *)(&(*___dst__P13s__anonymous3_1).__i__i_1)))) /* ?{} */); 96 } 97 static inline void ___constructor__F_P13s__anonymous313s__anonymous3_autogen___1(struct __anonymous3 *___dst__P13s__anonymous3_1, struct __anonymous3 ___src__13s__anonymous3_1){ 98 ((void)((*((int *)(&(*___dst__P13s__anonymous3_1).__i__i_1)))=___src__13s__anonymous3_1.__i__i_1) /* ?{} */); 99 } 100 static inline void ___destructor__F_P13s__anonymous3_autogen___1(struct __anonymous3 *___dst__P13s__anonymous3_1){ 101 ((void)((*((int *)(&(*___dst__P13s__anonymous3_1).__i__i_1)))) /* ^?{} */); 102 } 94 103 static inline struct __anonymous3 ___operator_assign__F13s__anonymous3_P13s__anonymous313s__anonymous3_autogen___1(struct __anonymous3 *___dst__P13s__anonymous3_1, struct __anonymous3 ___src__13s__anonymous3_1){ 95 104 ((void)((*___dst__P13s__anonymous3_1).__i__i_1=___src__13s__anonymous3_1.__i__i_1)); 96 105 return ((struct __anonymous3 )___src__13s__anonymous3_1); 97 }98 static inline void ___constructor__F_P13s__anonymous3_autogen___1(struct __anonymous3 *___dst__P13s__anonymous3_1){99 ((void)((*((int *)(&(*___dst__P13s__anonymous3_1).__i__i_1)))) /* ?{} */);100 }101 static inline void ___constructor__F_P13s__anonymous313s__anonymous3_autogen___1(struct __anonymous3 *___dst__P13s__anonymous3_1, struct __anonymous3 ___src__13s__anonymous3_1){102 ((void)((*((int *)(&(*___dst__P13s__anonymous3_1).__i__i_1)))=___src__13s__anonymous3_1.__i__i_1) /* ?{} */);103 }104 static inline void ___destructor__F_P13s__anonymous3_autogen___1(struct __anonymous3 *___dst__P13s__anonymous3_1){105 ((void)((*((int *)(&(*___dst__P13s__anonymous3_1).__i__i_1)))) /* ^?{} */);106 106 } 107 107 static inline void ___constructor__F_P13s__anonymous3i_autogen___1(struct __anonymous3 *___dst__P13s__anonymous3_1, int __i__i_1){ … … 116 116 static inline void ___constructor__F_P13s__anonymous413s__anonymous4_autogen___1(struct __anonymous4 *___dst__P13s__anonymous4_1, struct __anonymous4 ___src__13s__anonymous4_1); 117 117 static inline void ___destructor__F_P13s__anonymous4_autogen___1(struct __anonymous4 *___dst__P13s__anonymous4_1); 118 static inline void ___constructor__F_P13s__anonymous4_autogen___1(struct __anonymous4 *___dst__P13s__anonymous4_1){ 119 ((void)((*((int *)(&(*___dst__P13s__anonymous4_1).__i__i_1)))) /* ?{} */); 120 } 121 static inline void ___constructor__F_P13s__anonymous413s__anonymous4_autogen___1(struct __anonymous4 *___dst__P13s__anonymous4_1, struct __anonymous4 ___src__13s__anonymous4_1){ 122 ((void)((*((int *)(&(*___dst__P13s__anonymous4_1).__i__i_1)))=___src__13s__anonymous4_1.__i__i_1) /* ?{} */); 123 } 124 static inline void ___destructor__F_P13s__anonymous4_autogen___1(struct __anonymous4 *___dst__P13s__anonymous4_1){ 125 ((void)((*((int *)(&(*___dst__P13s__anonymous4_1).__i__i_1)))) /* ^?{} */); 126 } 118 127 static inline struct __anonymous4 ___operator_assign__F13s__anonymous4_P13s__anonymous413s__anonymous4_autogen___1(struct __anonymous4 *___dst__P13s__anonymous4_1, struct __anonymous4 ___src__13s__anonymous4_1){ 119 128 ((void)((*___dst__P13s__anonymous4_1).__i__i_1=___src__13s__anonymous4_1.__i__i_1)); 120 129 return ((struct __anonymous4 )___src__13s__anonymous4_1); 121 }122 static inline void ___constructor__F_P13s__anonymous4_autogen___1(struct __anonymous4 *___dst__P13s__anonymous4_1){123 ((void)((*((int *)(&(*___dst__P13s__anonymous4_1).__i__i_1)))) /* ?{} */);124 }125 static inline void ___constructor__F_P13s__anonymous413s__anonymous4_autogen___1(struct __anonymous4 *___dst__P13s__anonymous4_1, struct __anonymous4 ___src__13s__anonymous4_1){126 ((void)((*((int *)(&(*___dst__P13s__anonymous4_1).__i__i_1)))=___src__13s__anonymous4_1.__i__i_1) /* ?{} */);127 }128 static inline void ___destructor__F_P13s__anonymous4_autogen___1(struct __anonymous4 *___dst__P13s__anonymous4_1){129 ((void)((*((int *)(&(*___dst__P13s__anonymous4_1).__i__i_1)))) /* ^?{} */);130 130 } 131 131 static inline void ___constructor__F_P13s__anonymous4i_autogen___1(struct __anonymous4 *___dst__P13s__anonymous4_1, int __i__i_1){ … … 140 140 static inline void ___constructor__F_P13s__anonymous513s__anonymous5_autogen___1(struct __anonymous5 *___dst__P13s__anonymous5_1, struct __anonymous5 ___src__13s__anonymous5_1); 141 141 static inline void ___destructor__F_P13s__anonymous5_autogen___1(struct __anonymous5 *___dst__P13s__anonymous5_1); 142 static inline void ___constructor__F_P13s__anonymous5_autogen___1(struct __anonymous5 *___dst__P13s__anonymous5_1){ 143 ((void)((*((int *)(&(*___dst__P13s__anonymous5_1).__i__i_1)))) /* ?{} */); 144 } 145 static inline void ___constructor__F_P13s__anonymous513s__anonymous5_autogen___1(struct __anonymous5 *___dst__P13s__anonymous5_1, struct __anonymous5 ___src__13s__anonymous5_1){ 146 ((void)((*((int *)(&(*___dst__P13s__anonymous5_1).__i__i_1)))=___src__13s__anonymous5_1.__i__i_1) /* ?{} */); 147 } 148 static inline void ___destructor__F_P13s__anonymous5_autogen___1(struct __anonymous5 *___dst__P13s__anonymous5_1){ 149 ((void)((*((int *)(&(*___dst__P13s__anonymous5_1).__i__i_1)))) /* ^?{} */); 150 } 142 151 static inline struct __anonymous5 ___operator_assign__F13s__anonymous5_P13s__anonymous513s__anonymous5_autogen___1(struct __anonymous5 *___dst__P13s__anonymous5_1, struct __anonymous5 ___src__13s__anonymous5_1){ 143 152 ((void)((*___dst__P13s__anonymous5_1).__i__i_1=___src__13s__anonymous5_1.__i__i_1)); 144 153 return ((struct __anonymous5 )___src__13s__anonymous5_1); 145 }146 static inline void ___constructor__F_P13s__anonymous5_autogen___1(struct __anonymous5 *___dst__P13s__anonymous5_1){147 ((void)((*((int *)(&(*___dst__P13s__anonymous5_1).__i__i_1)))) /* ?{} */);148 }149 static inline void ___constructor__F_P13s__anonymous513s__anonymous5_autogen___1(struct __anonymous5 *___dst__P13s__anonymous5_1, struct __anonymous5 ___src__13s__anonymous5_1){150 ((void)((*((int *)(&(*___dst__P13s__anonymous5_1).__i__i_1)))=___src__13s__anonymous5_1.__i__i_1) /* ?{} */);151 }152 static inline void ___destructor__F_P13s__anonymous5_autogen___1(struct __anonymous5 *___dst__P13s__anonymous5_1){153 ((void)((*((int *)(&(*___dst__P13s__anonymous5_1).__i__i_1)))) /* ^?{} */);154 154 } 155 155 static inline void ___constructor__F_P13s__anonymous5i_autogen___1(struct __anonymous5 *___dst__P13s__anonymous5_1, int __i__i_1){ … … 164 164 static inline void ___constructor__F_P13s__anonymous613s__anonymous6_autogen___1(struct __anonymous6 *___dst__P13s__anonymous6_1, struct __anonymous6 ___src__13s__anonymous6_1); 165 165 static inline void ___destructor__F_P13s__anonymous6_autogen___1(struct __anonymous6 *___dst__P13s__anonymous6_1); 166 static inline void ___constructor__F_P13s__anonymous6_autogen___1(struct __anonymous6 *___dst__P13s__anonymous6_1){ 167 ((void)((*((int *)(&(*___dst__P13s__anonymous6_1).__i__i_1)))) /* ?{} */); 168 } 169 static inline void ___constructor__F_P13s__anonymous613s__anonymous6_autogen___1(struct __anonymous6 *___dst__P13s__anonymous6_1, struct __anonymous6 ___src__13s__anonymous6_1){ 170 ((void)((*((int *)(&(*___dst__P13s__anonymous6_1).__i__i_1)))=___src__13s__anonymous6_1.__i__i_1) /* ?{} */); 171 } 172 static inline void ___destructor__F_P13s__anonymous6_autogen___1(struct __anonymous6 *___dst__P13s__anonymous6_1){ 173 ((void)((*((int *)(&(*___dst__P13s__anonymous6_1).__i__i_1)))) /* ^?{} */); 174 } 166 175 static inline struct __anonymous6 ___operator_assign__F13s__anonymous6_P13s__anonymous613s__anonymous6_autogen___1(struct __anonymous6 *___dst__P13s__anonymous6_1, struct __anonymous6 ___src__13s__anonymous6_1){ 167 176 ((void)((*___dst__P13s__anonymous6_1).__i__i_1=___src__13s__anonymous6_1.__i__i_1)); 168 177 return ((struct __anonymous6 )___src__13s__anonymous6_1); 169 }170 static inline void ___constructor__F_P13s__anonymous6_autogen___1(struct __anonymous6 *___dst__P13s__anonymous6_1){171 ((void)((*((int *)(&(*___dst__P13s__anonymous6_1).__i__i_1)))) /* ?{} */);172 }173 static inline void ___constructor__F_P13s__anonymous613s__anonymous6_autogen___1(struct __anonymous6 *___dst__P13s__anonymous6_1, struct __anonymous6 ___src__13s__anonymous6_1){174 ((void)((*((int *)(&(*___dst__P13s__anonymous6_1).__i__i_1)))=___src__13s__anonymous6_1.__i__i_1) /* ?{} */);175 }176 static inline void ___destructor__F_P13s__anonymous6_autogen___1(struct __anonymous6 *___dst__P13s__anonymous6_1){177 ((void)((*((int *)(&(*___dst__P13s__anonymous6_1).__i__i_1)))) /* ^?{} */);178 178 } 179 179 static inline void ___constructor__F_P13s__anonymous6i_autogen___1(struct __anonymous6 *___dst__P13s__anonymous6_1, int __i__i_1){ … … 188 188 static inline void ___constructor__F_P13s__anonymous713s__anonymous7_autogen___1(struct __anonymous7 *___dst__P13s__anonymous7_1, struct __anonymous7 ___src__13s__anonymous7_1); 189 189 static inline void ___destructor__F_P13s__anonymous7_autogen___1(struct __anonymous7 *___dst__P13s__anonymous7_1); 190 static inline void ___constructor__F_P13s__anonymous7_autogen___1(struct __anonymous7 *___dst__P13s__anonymous7_1){ 191 ((void)((*((int *)(&(*___dst__P13s__anonymous7_1).__i__i_1)))) /* ?{} */); 192 } 193 static inline void ___constructor__F_P13s__anonymous713s__anonymous7_autogen___1(struct __anonymous7 *___dst__P13s__anonymous7_1, struct __anonymous7 ___src__13s__anonymous7_1){ 194 ((void)((*((int *)(&(*___dst__P13s__anonymous7_1).__i__i_1)))=___src__13s__anonymous7_1.__i__i_1) /* ?{} */); 195 } 196 static inline void ___destructor__F_P13s__anonymous7_autogen___1(struct __anonymous7 *___dst__P13s__anonymous7_1){ 197 ((void)((*((int *)(&(*___dst__P13s__anonymous7_1).__i__i_1)))) /* ^?{} */); 198 } 190 199 static inline struct __anonymous7 ___operator_assign__F13s__anonymous7_P13s__anonymous713s__anonymous7_autogen___1(struct __anonymous7 *___dst__P13s__anonymous7_1, struct __anonymous7 ___src__13s__anonymous7_1){ 191 200 ((void)((*___dst__P13s__anonymous7_1).__i__i_1=___src__13s__anonymous7_1.__i__i_1)); 192 201 return ((struct __anonymous7 )___src__13s__anonymous7_1); 193 }194 static inline void ___constructor__F_P13s__anonymous7_autogen___1(struct __anonymous7 *___dst__P13s__anonymous7_1){195 ((void)((*((int *)(&(*___dst__P13s__anonymous7_1).__i__i_1)))) /* ?{} */);196 }197 static inline void ___constructor__F_P13s__anonymous713s__anonymous7_autogen___1(struct __anonymous7 *___dst__P13s__anonymous7_1, struct __anonymous7 ___src__13s__anonymous7_1){198 ((void)((*((int *)(&(*___dst__P13s__anonymous7_1).__i__i_1)))=___src__13s__anonymous7_1.__i__i_1) /* ?{} */);199 }200 static inline void ___destructor__F_P13s__anonymous7_autogen___1(struct __anonymous7 *___dst__P13s__anonymous7_1){201 ((void)((*((int *)(&(*___dst__P13s__anonymous7_1).__i__i_1)))) /* ^?{} */);202 202 } 203 203 static inline void ___constructor__F_P13s__anonymous7i_autogen___1(struct __anonymous7 *___dst__P13s__anonymous7_1, int __i__i_1){ … … 220 220 static inline void ___constructor__F_P13s__anonymous813s__anonymous8_autogen___1(struct __anonymous8 *___dst__P13s__anonymous8_1, struct __anonymous8 ___src__13s__anonymous8_1); 221 221 static inline void ___destructor__F_P13s__anonymous8_autogen___1(struct __anonymous8 *___dst__P13s__anonymous8_1); 222 static inline void ___constructor__F_P13s__anonymous8_autogen___1(struct __anonymous8 *___dst__P13s__anonymous8_1){ 223 ((void)((*((short *)(&(*___dst__P13s__anonymous8_1).__i__s_1)))) /* ?{} */); 224 } 225 static inline void ___constructor__F_P13s__anonymous813s__anonymous8_autogen___1(struct __anonymous8 *___dst__P13s__anonymous8_1, struct __anonymous8 ___src__13s__anonymous8_1){ 226 ((void)((*((short *)(&(*___dst__P13s__anonymous8_1).__i__s_1)))=___src__13s__anonymous8_1.__i__s_1) /* ?{} */); 227 } 228 static inline void ___destructor__F_P13s__anonymous8_autogen___1(struct __anonymous8 *___dst__P13s__anonymous8_1){ 229 ((void)((*((short *)(&(*___dst__P13s__anonymous8_1).__i__s_1)))) /* ^?{} */); 230 } 222 231 static inline struct __anonymous8 ___operator_assign__F13s__anonymous8_P13s__anonymous813s__anonymous8_autogen___1(struct __anonymous8 *___dst__P13s__anonymous8_1, struct __anonymous8 ___src__13s__anonymous8_1){ 223 232 ((void)((*___dst__P13s__anonymous8_1).__i__s_1=___src__13s__anonymous8_1.__i__s_1)); 224 233 return ((struct __anonymous8 )___src__13s__anonymous8_1); 225 }226 static inline void ___constructor__F_P13s__anonymous8_autogen___1(struct __anonymous8 *___dst__P13s__anonymous8_1){227 ((void)((*((short *)(&(*___dst__P13s__anonymous8_1).__i__s_1)))) /* ?{} */);228 }229 static inline void ___constructor__F_P13s__anonymous813s__anonymous8_autogen___1(struct __anonymous8 *___dst__P13s__anonymous8_1, struct __anonymous8 ___src__13s__anonymous8_1){230 ((void)((*((short *)(&(*___dst__P13s__anonymous8_1).__i__s_1)))=___src__13s__anonymous8_1.__i__s_1) /* ?{} */);231 }232 static inline void ___destructor__F_P13s__anonymous8_autogen___1(struct __anonymous8 *___dst__P13s__anonymous8_1){233 ((void)((*((short *)(&(*___dst__P13s__anonymous8_1).__i__s_1)))) /* ^?{} */);234 234 } 235 235 static inline void ___constructor__F_P13s__anonymous8s_autogen___1(struct __anonymous8 *___dst__P13s__anonymous8_1, short __i__s_1){ … … 244 244 static inline void ___constructor__F_P13s__anonymous913s__anonymous9_autogen___1(struct __anonymous9 *___dst__P13s__anonymous9_1, struct __anonymous9 ___src__13s__anonymous9_1); 245 245 static inline void ___destructor__F_P13s__anonymous9_autogen___1(struct __anonymous9 *___dst__P13s__anonymous9_1); 246 static inline void ___constructor__F_P13s__anonymous9_autogen___1(struct __anonymous9 *___dst__P13s__anonymous9_1){ 247 ((void)((*((short *)(&(*___dst__P13s__anonymous9_1).__i__s_1)))) /* ?{} */); 248 } 249 static inline void ___constructor__F_P13s__anonymous913s__anonymous9_autogen___1(struct __anonymous9 *___dst__P13s__anonymous9_1, struct __anonymous9 ___src__13s__anonymous9_1){ 250 ((void)((*((short *)(&(*___dst__P13s__anonymous9_1).__i__s_1)))=___src__13s__anonymous9_1.__i__s_1) /* ?{} */); 251 } 252 static inline void ___destructor__F_P13s__anonymous9_autogen___1(struct __anonymous9 *___dst__P13s__anonymous9_1){ 253 ((void)((*((short *)(&(*___dst__P13s__anonymous9_1).__i__s_1)))) /* ^?{} */); 254 } 246 255 static inline struct __anonymous9 ___operator_assign__F13s__anonymous9_P13s__anonymous913s__anonymous9_autogen___1(struct __anonymous9 *___dst__P13s__anonymous9_1, struct __anonymous9 ___src__13s__anonymous9_1){ 247 256 ((void)((*___dst__P13s__anonymous9_1).__i__s_1=___src__13s__anonymous9_1.__i__s_1)); 248 257 return ((struct __anonymous9 )___src__13s__anonymous9_1); 249 }250 static inline void ___constructor__F_P13s__anonymous9_autogen___1(struct __anonymous9 *___dst__P13s__anonymous9_1){251 ((void)((*((short *)(&(*___dst__P13s__anonymous9_1).__i__s_1)))) /* ?{} */);252 }253 static inline void ___constructor__F_P13s__anonymous913s__anonymous9_autogen___1(struct __anonymous9 *___dst__P13s__anonymous9_1, struct __anonymous9 ___src__13s__anonymous9_1){254 ((void)((*((short *)(&(*___dst__P13s__anonymous9_1).__i__s_1)))=___src__13s__anonymous9_1.__i__s_1) /* ?{} */);255 }256 static inline void ___destructor__F_P13s__anonymous9_autogen___1(struct __anonymous9 *___dst__P13s__anonymous9_1){257 ((void)((*((short *)(&(*___dst__P13s__anonymous9_1).__i__s_1)))) /* ^?{} */);258 258 } 259 259 static inline void ___constructor__F_P13s__anonymous9s_autogen___1(struct __anonymous9 *___dst__P13s__anonymous9_1, short __i__s_1){ … … 268 268 static inline void ___constructor__F_P14s__anonymous1014s__anonymous10_autogen___1(struct __anonymous10 *___dst__P14s__anonymous10_1, struct __anonymous10 ___src__14s__anonymous10_1); 269 269 static inline void ___destructor__F_P14s__anonymous10_autogen___1(struct __anonymous10 *___dst__P14s__anonymous10_1); 270 static inline void ___constructor__F_P14s__anonymous10_autogen___1(struct __anonymous10 *___dst__P14s__anonymous10_1){ 271 ((void)((*((short *)(&(*___dst__P14s__anonymous10_1).__i__s_1)))) /* ?{} */); 272 } 273 static inline void ___constructor__F_P14s__anonymous1014s__anonymous10_autogen___1(struct __anonymous10 *___dst__P14s__anonymous10_1, struct __anonymous10 ___src__14s__anonymous10_1){ 274 ((void)((*((short *)(&(*___dst__P14s__anonymous10_1).__i__s_1)))=___src__14s__anonymous10_1.__i__s_1) /* ?{} */); 275 } 276 static inline void ___destructor__F_P14s__anonymous10_autogen___1(struct __anonymous10 *___dst__P14s__anonymous10_1){ 277 ((void)((*((short *)(&(*___dst__P14s__anonymous10_1).__i__s_1)))) /* ^?{} */); 278 } 270 279 static inline struct __anonymous10 ___operator_assign__F14s__anonymous10_P14s__anonymous1014s__anonymous10_autogen___1(struct __anonymous10 *___dst__P14s__anonymous10_1, struct __anonymous10 ___src__14s__anonymous10_1){ 271 280 ((void)((*___dst__P14s__anonymous10_1).__i__s_1=___src__14s__anonymous10_1.__i__s_1)); 272 281 return ((struct __anonymous10 )___src__14s__anonymous10_1); 273 }274 static inline void ___constructor__F_P14s__anonymous10_autogen___1(struct __anonymous10 *___dst__P14s__anonymous10_1){275 ((void)((*((short *)(&(*___dst__P14s__anonymous10_1).__i__s_1)))) /* ?{} */);276 }277 static inline void ___constructor__F_P14s__anonymous1014s__anonymous10_autogen___1(struct __anonymous10 *___dst__P14s__anonymous10_1, struct __anonymous10 ___src__14s__anonymous10_1){278 ((void)((*((short *)(&(*___dst__P14s__anonymous10_1).__i__s_1)))=___src__14s__anonymous10_1.__i__s_1) /* ?{} */);279 }280 static inline void ___destructor__F_P14s__anonymous10_autogen___1(struct __anonymous10 *___dst__P14s__anonymous10_1){281 ((void)((*((short *)(&(*___dst__P14s__anonymous10_1).__i__s_1)))) /* ^?{} */);282 282 } 283 283 static inline void ___constructor__F_P14s__anonymous10s_autogen___1(struct __anonymous10 *___dst__P14s__anonymous10_1, short __i__s_1){ … … 292 292 static inline void ___constructor__F_P14s__anonymous1114s__anonymous11_autogen___1(struct __anonymous11 *___dst__P14s__anonymous11_1, struct __anonymous11 ___src__14s__anonymous11_1); 293 293 static inline void ___destructor__F_P14s__anonymous11_autogen___1(struct __anonymous11 *___dst__P14s__anonymous11_1); 294 static inline void ___constructor__F_P14s__anonymous11_autogen___1(struct __anonymous11 *___dst__P14s__anonymous11_1){ 295 ((void)((*((short *)(&(*___dst__P14s__anonymous11_1).__i__s_1)))) /* ?{} */); 296 } 297 static inline void ___constructor__F_P14s__anonymous1114s__anonymous11_autogen___1(struct __anonymous11 *___dst__P14s__anonymous11_1, struct __anonymous11 ___src__14s__anonymous11_1){ 298 ((void)((*((short *)(&(*___dst__P14s__anonymous11_1).__i__s_1)))=___src__14s__anonymous11_1.__i__s_1) /* ?{} */); 299 } 300 static inline void ___destructor__F_P14s__anonymous11_autogen___1(struct __anonymous11 *___dst__P14s__anonymous11_1){ 301 ((void)((*((short *)(&(*___dst__P14s__anonymous11_1).__i__s_1)))) /* ^?{} */); 302 } 294 303 static inline struct __anonymous11 ___operator_assign__F14s__anonymous11_P14s__anonymous1114s__anonymous11_autogen___1(struct __anonymous11 *___dst__P14s__anonymous11_1, struct __anonymous11 ___src__14s__anonymous11_1){ 295 304 ((void)((*___dst__P14s__anonymous11_1).__i__s_1=___src__14s__anonymous11_1.__i__s_1)); 296 305 return ((struct __anonymous11 )___src__14s__anonymous11_1); 297 }298 static inline void ___constructor__F_P14s__anonymous11_autogen___1(struct __anonymous11 *___dst__P14s__anonymous11_1){299 ((void)((*((short *)(&(*___dst__P14s__anonymous11_1).__i__s_1)))) /* ?{} */);300 }301 static inline void ___constructor__F_P14s__anonymous1114s__anonymous11_autogen___1(struct __anonymous11 *___dst__P14s__anonymous11_1, struct __anonymous11 ___src__14s__anonymous11_1){302 ((void)((*((short *)(&(*___dst__P14s__anonymous11_1).__i__s_1)))=___src__14s__anonymous11_1.__i__s_1) /* ?{} */);303 }304 static inline void ___destructor__F_P14s__anonymous11_autogen___1(struct __anonymous11 *___dst__P14s__anonymous11_1){305 ((void)((*((short *)(&(*___dst__P14s__anonymous11_1).__i__s_1)))) /* ^?{} */);306 306 } 307 307 static inline void ___constructor__F_P14s__anonymous11s_autogen___1(struct __anonymous11 *___dst__P14s__anonymous11_1, short __i__s_1){ … … 316 316 static inline void ___constructor__F_P14s__anonymous1214s__anonymous12_autogen___1(struct __anonymous12 *___dst__P14s__anonymous12_1, struct __anonymous12 ___src__14s__anonymous12_1); 317 317 static inline void ___destructor__F_P14s__anonymous12_autogen___1(struct __anonymous12 *___dst__P14s__anonymous12_1); 318 static inline void ___constructor__F_P14s__anonymous12_autogen___1(struct __anonymous12 *___dst__P14s__anonymous12_1){ 319 ((void)((*((short *)(&(*___dst__P14s__anonymous12_1).__i__s_1)))) /* ?{} */); 320 } 321 static inline void ___constructor__F_P14s__anonymous1214s__anonymous12_autogen___1(struct __anonymous12 *___dst__P14s__anonymous12_1, struct __anonymous12 ___src__14s__anonymous12_1){ 322 ((void)((*((short *)(&(*___dst__P14s__anonymous12_1).__i__s_1)))=___src__14s__anonymous12_1.__i__s_1) /* ?{} */); 323 } 324 static inline void ___destructor__F_P14s__anonymous12_autogen___1(struct __anonymous12 *___dst__P14s__anonymous12_1){ 325 ((void)((*((short *)(&(*___dst__P14s__anonymous12_1).__i__s_1)))) /* ^?{} */); 326 } 318 327 static inline struct __anonymous12 ___operator_assign__F14s__anonymous12_P14s__anonymous1214s__anonymous12_autogen___1(struct __anonymous12 *___dst__P14s__anonymous12_1, struct __anonymous12 ___src__14s__anonymous12_1){ 319 328 ((void)((*___dst__P14s__anonymous12_1).__i__s_1=___src__14s__anonymous12_1.__i__s_1)); 320 329 return ((struct __anonymous12 )___src__14s__anonymous12_1); 321 }322 static inline void ___constructor__F_P14s__anonymous12_autogen___1(struct __anonymous12 *___dst__P14s__anonymous12_1){323 ((void)((*((short *)(&(*___dst__P14s__anonymous12_1).__i__s_1)))) /* ?{} */);324 }325 static inline void ___constructor__F_P14s__anonymous1214s__anonymous12_autogen___1(struct __anonymous12 *___dst__P14s__anonymous12_1, struct __anonymous12 ___src__14s__anonymous12_1){326 ((void)((*((short *)(&(*___dst__P14s__anonymous12_1).__i__s_1)))=___src__14s__anonymous12_1.__i__s_1) /* ?{} */);327 }328 static inline void ___destructor__F_P14s__anonymous12_autogen___1(struct __anonymous12 *___dst__P14s__anonymous12_1){329 ((void)((*((short *)(&(*___dst__P14s__anonymous12_1).__i__s_1)))) /* ^?{} */);330 330 } 331 331 static inline void ___constructor__F_P14s__anonymous12s_autogen___1(struct __anonymous12 *___dst__P14s__anonymous12_1, short __i__s_1){ … … 340 340 static inline void ___constructor__F_P14s__anonymous1314s__anonymous13_autogen___1(struct __anonymous13 *___dst__P14s__anonymous13_1, struct __anonymous13 ___src__14s__anonymous13_1); 341 341 static inline void ___destructor__F_P14s__anonymous13_autogen___1(struct __anonymous13 *___dst__P14s__anonymous13_1); 342 static inline void ___constructor__F_P14s__anonymous13_autogen___1(struct __anonymous13 *___dst__P14s__anonymous13_1){ 343 ((void)((*((short *)(&(*___dst__P14s__anonymous13_1).__i__s_1)))) /* ?{} */); 344 } 345 static inline void ___constructor__F_P14s__anonymous1314s__anonymous13_autogen___1(struct __anonymous13 *___dst__P14s__anonymous13_1, struct __anonymous13 ___src__14s__anonymous13_1){ 346 ((void)((*((short *)(&(*___dst__P14s__anonymous13_1).__i__s_1)))=___src__14s__anonymous13_1.__i__s_1) /* ?{} */); 347 } 348 static inline void ___destructor__F_P14s__anonymous13_autogen___1(struct __anonymous13 *___dst__P14s__anonymous13_1){ 349 ((void)((*((short *)(&(*___dst__P14s__anonymous13_1).__i__s_1)))) /* ^?{} */); 350 } 342 351 static inline struct __anonymous13 ___operator_assign__F14s__anonymous13_P14s__anonymous1314s__anonymous13_autogen___1(struct __anonymous13 *___dst__P14s__anonymous13_1, struct __anonymous13 ___src__14s__anonymous13_1){ 343 352 ((void)((*___dst__P14s__anonymous13_1).__i__s_1=___src__14s__anonymous13_1.__i__s_1)); 344 353 return ((struct __anonymous13 )___src__14s__anonymous13_1); 345 }346 static inline void ___constructor__F_P14s__anonymous13_autogen___1(struct __anonymous13 *___dst__P14s__anonymous13_1){347 ((void)((*((short *)(&(*___dst__P14s__anonymous13_1).__i__s_1)))) /* ?{} */);348 }349 static inline void ___constructor__F_P14s__anonymous1314s__anonymous13_autogen___1(struct __anonymous13 *___dst__P14s__anonymous13_1, struct __anonymous13 ___src__14s__anonymous13_1){350 ((void)((*((short *)(&(*___dst__P14s__anonymous13_1).__i__s_1)))=___src__14s__anonymous13_1.__i__s_1) /* ?{} */);351 }352 static inline void ___destructor__F_P14s__anonymous13_autogen___1(struct __anonymous13 *___dst__P14s__anonymous13_1){353 ((void)((*((short *)(&(*___dst__P14s__anonymous13_1).__i__s_1)))) /* ^?{} */);354 354 } 355 355 static inline void ___constructor__F_P14s__anonymous13s_autogen___1(struct __anonymous13 *___dst__P14s__anonymous13_1, short __i__s_1){ … … 364 364 static inline void ___constructor__F_P14s__anonymous1414s__anonymous14_autogen___1(struct __anonymous14 *___dst__P14s__anonymous14_1, struct __anonymous14 ___src__14s__anonymous14_1); 365 365 static inline void ___destructor__F_P14s__anonymous14_autogen___1(struct __anonymous14 *___dst__P14s__anonymous14_1); 366 static inline void ___constructor__F_P14s__anonymous14_autogen___1(struct __anonymous14 *___dst__P14s__anonymous14_1){ 367 ((void)((*((short *)(&(*___dst__P14s__anonymous14_1).__i__s_1)))) /* ?{} */); 368 } 369 static inline void ___constructor__F_P14s__anonymous1414s__anonymous14_autogen___1(struct __anonymous14 *___dst__P14s__anonymous14_1, struct __anonymous14 ___src__14s__anonymous14_1){ 370 ((void)((*((short *)(&(*___dst__P14s__anonymous14_1).__i__s_1)))=___src__14s__anonymous14_1.__i__s_1) /* ?{} */); 371 } 372 static inline void ___destructor__F_P14s__anonymous14_autogen___1(struct __anonymous14 *___dst__P14s__anonymous14_1){ 373 ((void)((*((short *)(&(*___dst__P14s__anonymous14_1).__i__s_1)))) /* ^?{} */); 374 } 366 375 static inline struct __anonymous14 ___operator_assign__F14s__anonymous14_P14s__anonymous1414s__anonymous14_autogen___1(struct __anonymous14 *___dst__P14s__anonymous14_1, struct __anonymous14 ___src__14s__anonymous14_1){ 367 376 ((void)((*___dst__P14s__anonymous14_1).__i__s_1=___src__14s__anonymous14_1.__i__s_1)); 368 377 return ((struct __anonymous14 )___src__14s__anonymous14_1); 369 }370 static inline void ___constructor__F_P14s__anonymous14_autogen___1(struct __anonymous14 *___dst__P14s__anonymous14_1){371 ((void)((*((short *)(&(*___dst__P14s__anonymous14_1).__i__s_1)))) /* ?{} */);372 }373 static inline void ___constructor__F_P14s__anonymous1414s__anonymous14_autogen___1(struct __anonymous14 *___dst__P14s__anonymous14_1, struct __anonymous14 ___src__14s__anonymous14_1){374 ((void)((*((short *)(&(*___dst__P14s__anonymous14_1).__i__s_1)))=___src__14s__anonymous14_1.__i__s_1) /* ?{} */);375 }376 static inline void ___destructor__F_P14s__anonymous14_autogen___1(struct __anonymous14 *___dst__P14s__anonymous14_1){377 ((void)((*((short *)(&(*___dst__P14s__anonymous14_1).__i__s_1)))) /* ^?{} */);378 378 } 379 379 static inline void ___constructor__F_P14s__anonymous14s_autogen___1(struct __anonymous14 *___dst__P14s__anonymous14_1, short __i__s_1){ … … 388 388 static inline void ___constructor__F_P14s__anonymous1514s__anonymous15_autogen___1(struct __anonymous15 *___dst__P14s__anonymous15_1, struct __anonymous15 ___src__14s__anonymous15_1); 389 389 static inline void ___destructor__F_P14s__anonymous15_autogen___1(struct __anonymous15 *___dst__P14s__anonymous15_1); 390 static inline void ___constructor__F_P14s__anonymous15_autogen___1(struct __anonymous15 *___dst__P14s__anonymous15_1){ 391 ((void)((*((short *)(&(*___dst__P14s__anonymous15_1).__i__s_1)))) /* ?{} */); 392 } 393 static inline void ___constructor__F_P14s__anonymous1514s__anonymous15_autogen___1(struct __anonymous15 *___dst__P14s__anonymous15_1, struct __anonymous15 ___src__14s__anonymous15_1){ 394 ((void)((*((short *)(&(*___dst__P14s__anonymous15_1).__i__s_1)))=___src__14s__anonymous15_1.__i__s_1) /* ?{} */); 395 } 396 static inline void ___destructor__F_P14s__anonymous15_autogen___1(struct __anonymous15 *___dst__P14s__anonymous15_1){ 397 ((void)((*((short *)(&(*___dst__P14s__anonymous15_1).__i__s_1)))) /* ^?{} */); 398 } 390 399 static inline struct __anonymous15 ___operator_assign__F14s__anonymous15_P14s__anonymous1514s__anonymous15_autogen___1(struct __anonymous15 *___dst__P14s__anonymous15_1, struct __anonymous15 ___src__14s__anonymous15_1){ 391 400 ((void)((*___dst__P14s__anonymous15_1).__i__s_1=___src__14s__anonymous15_1.__i__s_1)); 392 401 return ((struct __anonymous15 )___src__14s__anonymous15_1); 393 }394 static inline void ___constructor__F_P14s__anonymous15_autogen___1(struct __anonymous15 *___dst__P14s__anonymous15_1){395 ((void)((*((short *)(&(*___dst__P14s__anonymous15_1).__i__s_1)))) /* ?{} */);396 }397 static inline void ___constructor__F_P14s__anonymous1514s__anonymous15_autogen___1(struct __anonymous15 *___dst__P14s__anonymous15_1, struct __anonymous15 ___src__14s__anonymous15_1){398 ((void)((*((short *)(&(*___dst__P14s__anonymous15_1).__i__s_1)))=___src__14s__anonymous15_1.__i__s_1) /* ?{} */);399 }400 static inline void ___destructor__F_P14s__anonymous15_autogen___1(struct __anonymous15 *___dst__P14s__anonymous15_1){401 ((void)((*((short *)(&(*___dst__P14s__anonymous15_1).__i__s_1)))) /* ^?{} */);402 402 } 403 403 static inline void ___constructor__F_P14s__anonymous15s_autogen___1(struct __anonymous15 *___dst__P14s__anonymous15_1, short __i__s_1){ … … 428 428 static inline void ___constructor__F_P14s__anonymous1614s__anonymous16_autogen___1(struct __anonymous16 *___dst__P14s__anonymous16_1, struct __anonymous16 ___src__14s__anonymous16_1); 429 429 static inline void ___destructor__F_P14s__anonymous16_autogen___1(struct __anonymous16 *___dst__P14s__anonymous16_1); 430 static inline void ___constructor__F_P14s__anonymous16_autogen___1(struct __anonymous16 *___dst__P14s__anonymous16_1){ 431 ((void)((*((int *)(&(*___dst__P14s__anonymous16_1).__i__i_1)))) /* ?{} */); 432 } 433 static inline void ___constructor__F_P14s__anonymous1614s__anonymous16_autogen___1(struct __anonymous16 *___dst__P14s__anonymous16_1, struct __anonymous16 ___src__14s__anonymous16_1){ 434 ((void)((*((int *)(&(*___dst__P14s__anonymous16_1).__i__i_1)))=___src__14s__anonymous16_1.__i__i_1) /* ?{} */); 435 } 436 static inline void ___destructor__F_P14s__anonymous16_autogen___1(struct __anonymous16 *___dst__P14s__anonymous16_1){ 437 ((void)((*((int *)(&(*___dst__P14s__anonymous16_1).__i__i_1)))) /* ^?{} */); 438 } 430 439 static inline struct __anonymous16 ___operator_assign__F14s__anonymous16_P14s__anonymous1614s__anonymous16_autogen___1(struct __anonymous16 *___dst__P14s__anonymous16_1, struct __anonymous16 ___src__14s__anonymous16_1){ 431 440 ((void)((*___dst__P14s__anonymous16_1).__i__i_1=___src__14s__anonymous16_1.__i__i_1)); 432 441 return ((struct __anonymous16 )___src__14s__anonymous16_1); 433 }434 static inline void ___constructor__F_P14s__anonymous16_autogen___1(struct __anonymous16 *___dst__P14s__anonymous16_1){435 ((void)((*((int *)(&(*___dst__P14s__anonymous16_1).__i__i_1)))) /* ?{} */);436 }437 static inline void ___constructor__F_P14s__anonymous1614s__anonymous16_autogen___1(struct __anonymous16 *___dst__P14s__anonymous16_1, struct __anonymous16 ___src__14s__anonymous16_1){438 ((void)((*((int *)(&(*___dst__P14s__anonymous16_1).__i__i_1)))=___src__14s__anonymous16_1.__i__i_1) /* ?{} */);439 }440 static inline void ___destructor__F_P14s__anonymous16_autogen___1(struct __anonymous16 *___dst__P14s__anonymous16_1){441 ((void)((*((int *)(&(*___dst__P14s__anonymous16_1).__i__i_1)))) /* ^?{} */);442 442 } 443 443 static inline void ___constructor__F_P14s__anonymous16i_autogen___1(struct __anonymous16 *___dst__P14s__anonymous16_1, int __i__i_1){ … … 452 452 static inline void ___constructor__F_P14s__anonymous1714s__anonymous17_autogen___1(struct __anonymous17 *___dst__P14s__anonymous17_1, struct __anonymous17 ___src__14s__anonymous17_1); 453 453 static inline void ___destructor__F_P14s__anonymous17_autogen___1(struct __anonymous17 *___dst__P14s__anonymous17_1); 454 static inline void ___constructor__F_P14s__anonymous17_autogen___1(struct __anonymous17 *___dst__P14s__anonymous17_1){ 455 ((void)((*((int *)(&(*___dst__P14s__anonymous17_1).__i__i_1)))) /* ?{} */); 456 } 457 static inline void ___constructor__F_P14s__anonymous1714s__anonymous17_autogen___1(struct __anonymous17 *___dst__P14s__anonymous17_1, struct __anonymous17 ___src__14s__anonymous17_1){ 458 ((void)((*((int *)(&(*___dst__P14s__anonymous17_1).__i__i_1)))=___src__14s__anonymous17_1.__i__i_1) /* ?{} */); 459 } 460 static inline void ___destructor__F_P14s__anonymous17_autogen___1(struct __anonymous17 *___dst__P14s__anonymous17_1){ 461 ((void)((*((int *)(&(*___dst__P14s__anonymous17_1).__i__i_1)))) /* ^?{} */); 462 } 454 463 static inline struct __anonymous17 ___operator_assign__F14s__anonymous17_P14s__anonymous1714s__anonymous17_autogen___1(struct __anonymous17 *___dst__P14s__anonymous17_1, struct __anonymous17 ___src__14s__anonymous17_1){ 455 464 ((void)((*___dst__P14s__anonymous17_1).__i__i_1=___src__14s__anonymous17_1.__i__i_1)); 456 465 return ((struct __anonymous17 )___src__14s__anonymous17_1); 457 }458 static inline void ___constructor__F_P14s__anonymous17_autogen___1(struct __anonymous17 *___dst__P14s__anonymous17_1){459 ((void)((*((int *)(&(*___dst__P14s__anonymous17_1).__i__i_1)))) /* ?{} */);460 }461 static inline void ___constructor__F_P14s__anonymous1714s__anonymous17_autogen___1(struct __anonymous17 *___dst__P14s__anonymous17_1, struct __anonymous17 ___src__14s__anonymous17_1){462 ((void)((*((int *)(&(*___dst__P14s__anonymous17_1).__i__i_1)))=___src__14s__anonymous17_1.__i__i_1) /* ?{} */);463 }464 static inline void ___destructor__F_P14s__anonymous17_autogen___1(struct __anonymous17 *___dst__P14s__anonymous17_1){465 ((void)((*((int *)(&(*___dst__P14s__anonymous17_1).__i__i_1)))) /* ^?{} */);466 466 } 467 467 static inline void ___constructor__F_P14s__anonymous17i_autogen___1(struct __anonymous17 *___dst__P14s__anonymous17_1, int __i__i_1){ … … 476 476 static inline void ___constructor__F_P14s__anonymous1814s__anonymous18_autogen___1(struct __anonymous18 *___dst__P14s__anonymous18_1, struct __anonymous18 ___src__14s__anonymous18_1); 477 477 static inline void ___destructor__F_P14s__anonymous18_autogen___1(struct __anonymous18 *___dst__P14s__anonymous18_1); 478 static inline void ___constructor__F_P14s__anonymous18_autogen___1(struct __anonymous18 *___dst__P14s__anonymous18_1){ 479 ((void)((*((int *)(&(*___dst__P14s__anonymous18_1).__i__i_1)))) /* ?{} */); 480 } 481 static inline void ___constructor__F_P14s__anonymous1814s__anonymous18_autogen___1(struct __anonymous18 *___dst__P14s__anonymous18_1, struct __anonymous18 ___src__14s__anonymous18_1){ 482 ((void)((*((int *)(&(*___dst__P14s__anonymous18_1).__i__i_1)))=___src__14s__anonymous18_1.__i__i_1) /* ?{} */); 483 } 484 static inline void ___destructor__F_P14s__anonymous18_autogen___1(struct __anonymous18 *___dst__P14s__anonymous18_1){ 485 ((void)((*((int *)(&(*___dst__P14s__anonymous18_1).__i__i_1)))) /* ^?{} */); 486 } 478 487 static inline struct __anonymous18 ___operator_assign__F14s__anonymous18_P14s__anonymous1814s__anonymous18_autogen___1(struct __anonymous18 *___dst__P14s__anonymous18_1, struct __anonymous18 ___src__14s__anonymous18_1){ 479 488 ((void)((*___dst__P14s__anonymous18_1).__i__i_1=___src__14s__anonymous18_1.__i__i_1)); 480 489 return ((struct __anonymous18 )___src__14s__anonymous18_1); 481 }482 static inline void ___constructor__F_P14s__anonymous18_autogen___1(struct __anonymous18 *___dst__P14s__anonymous18_1){483 ((void)((*((int *)(&(*___dst__P14s__anonymous18_1).__i__i_1)))) /* ?{} */);484 }485 static inline void ___constructor__F_P14s__anonymous1814s__anonymous18_autogen___1(struct __anonymous18 *___dst__P14s__anonymous18_1, struct __anonymous18 ___src__14s__anonymous18_1){486 ((void)((*((int *)(&(*___dst__P14s__anonymous18_1).__i__i_1)))=___src__14s__anonymous18_1.__i__i_1) /* ?{} */);487 }488 static inline void ___destructor__F_P14s__anonymous18_autogen___1(struct __anonymous18 *___dst__P14s__anonymous18_1){489 ((void)((*((int *)(&(*___dst__P14s__anonymous18_1).__i__i_1)))) /* ^?{} */);490 490 } 491 491 static inline void ___constructor__F_P14s__anonymous18i_autogen___1(struct __anonymous18 *___dst__P14s__anonymous18_1, int __i__i_1){ … … 500 500 static inline void ___constructor__F_P14s__anonymous1914s__anonymous19_autogen___1(struct __anonymous19 *___dst__P14s__anonymous19_1, struct __anonymous19 ___src__14s__anonymous19_1); 501 501 static inline void ___destructor__F_P14s__anonymous19_autogen___1(struct __anonymous19 *___dst__P14s__anonymous19_1); 502 static inline void ___constructor__F_P14s__anonymous19_autogen___1(struct __anonymous19 *___dst__P14s__anonymous19_1){ 503 ((void)((*((int *)(&(*___dst__P14s__anonymous19_1).__i__i_1)))) /* ?{} */); 504 } 505 static inline void ___constructor__F_P14s__anonymous1914s__anonymous19_autogen___1(struct __anonymous19 *___dst__P14s__anonymous19_1, struct __anonymous19 ___src__14s__anonymous19_1){ 506 ((void)((*((int *)(&(*___dst__P14s__anonymous19_1).__i__i_1)))=___src__14s__anonymous19_1.__i__i_1) /* ?{} */); 507 } 508 static inline void ___destructor__F_P14s__anonymous19_autogen___1(struct __anonymous19 *___dst__P14s__anonymous19_1){ 509 ((void)((*((int *)(&(*___dst__P14s__anonymous19_1).__i__i_1)))) /* ^?{} */); 510 } 502 511 static inline struct __anonymous19 ___operator_assign__F14s__anonymous19_P14s__anonymous1914s__anonymous19_autogen___1(struct __anonymous19 *___dst__P14s__anonymous19_1, struct __anonymous19 ___src__14s__anonymous19_1){ 503 512 ((void)((*___dst__P14s__anonymous19_1).__i__i_1=___src__14s__anonymous19_1.__i__i_1)); 504 513 return ((struct __anonymous19 )___src__14s__anonymous19_1); 505 }506 static inline void ___constructor__F_P14s__anonymous19_autogen___1(struct __anonymous19 *___dst__P14s__anonymous19_1){507 ((void)((*((int *)(&(*___dst__P14s__anonymous19_1).__i__i_1)))) /* ?{} */);508 }509 static inline void ___constructor__F_P14s__anonymous1914s__anonymous19_autogen___1(struct __anonymous19 *___dst__P14s__anonymous19_1, struct __anonymous19 ___src__14s__anonymous19_1){510 ((void)((*((int *)(&(*___dst__P14s__anonymous19_1).__i__i_1)))=___src__14s__anonymous19_1.__i__i_1) /* ?{} */);511 }512 static inline void ___destructor__F_P14s__anonymous19_autogen___1(struct __anonymous19 *___dst__P14s__anonymous19_1){513 ((void)((*((int *)(&(*___dst__P14s__anonymous19_1).__i__i_1)))) /* ^?{} */);514 514 } 515 515 static inline void ___constructor__F_P14s__anonymous19i_autogen___1(struct __anonymous19 *___dst__P14s__anonymous19_1, int __i__i_1){ … … 524 524 static inline void ___constructor__F_P14s__anonymous2014s__anonymous20_autogen___1(struct __anonymous20 *___dst__P14s__anonymous20_1, struct __anonymous20 ___src__14s__anonymous20_1); 525 525 static inline void ___destructor__F_P14s__anonymous20_autogen___1(struct __anonymous20 *___dst__P14s__anonymous20_1); 526 static inline void ___constructor__F_P14s__anonymous20_autogen___1(struct __anonymous20 *___dst__P14s__anonymous20_1){ 527 ((void)((*((int *)(&(*___dst__P14s__anonymous20_1).__i__i_1)))) /* ?{} */); 528 } 529 static inline void ___constructor__F_P14s__anonymous2014s__anonymous20_autogen___1(struct __anonymous20 *___dst__P14s__anonymous20_1, struct __anonymous20 ___src__14s__anonymous20_1){ 530 ((void)((*((int *)(&(*___dst__P14s__anonymous20_1).__i__i_1)))=___src__14s__anonymous20_1.__i__i_1) /* ?{} */); 531 } 532 static inline void ___destructor__F_P14s__anonymous20_autogen___1(struct __anonymous20 *___dst__P14s__anonymous20_1){ 533 ((void)((*((int *)(&(*___dst__P14s__anonymous20_1).__i__i_1)))) /* ^?{} */); 534 } 526 535 static inline struct __anonymous20 ___operator_assign__F14s__anonymous20_P14s__anonymous2014s__anonymous20_autogen___1(struct __anonymous20 *___dst__P14s__anonymous20_1, struct __anonymous20 ___src__14s__anonymous20_1){ 527 536 ((void)((*___dst__P14s__anonymous20_1).__i__i_1=___src__14s__anonymous20_1.__i__i_1)); 528 537 return ((struct __anonymous20 )___src__14s__anonymous20_1); 529 }530 static inline void ___constructor__F_P14s__anonymous20_autogen___1(struct __anonymous20 *___dst__P14s__anonymous20_1){531 ((void)((*((int *)(&(*___dst__P14s__anonymous20_1).__i__i_1)))) /* ?{} */);532 }533 static inline void ___constructor__F_P14s__anonymous2014s__anonymous20_autogen___1(struct __anonymous20 *___dst__P14s__anonymous20_1, struct __anonymous20 ___src__14s__anonymous20_1){534 ((void)((*((int *)(&(*___dst__P14s__anonymous20_1).__i__i_1)))=___src__14s__anonymous20_1.__i__i_1) /* ?{} */);535 }536 static inline void ___destructor__F_P14s__anonymous20_autogen___1(struct __anonymous20 *___dst__P14s__anonymous20_1){537 ((void)((*((int *)(&(*___dst__P14s__anonymous20_1).__i__i_1)))) /* ^?{} */);538 538 } 539 539 static inline void ___constructor__F_P14s__anonymous20i_autogen___1(struct __anonymous20 *___dst__P14s__anonymous20_1, int __i__i_1){ … … 548 548 static inline void ___constructor__F_P14s__anonymous2114s__anonymous21_autogen___1(struct __anonymous21 *___dst__P14s__anonymous21_1, struct __anonymous21 ___src__14s__anonymous21_1); 549 549 static inline void ___destructor__F_P14s__anonymous21_autogen___1(struct __anonymous21 *___dst__P14s__anonymous21_1); 550 static inline void ___constructor__F_P14s__anonymous21_autogen___1(struct __anonymous21 *___dst__P14s__anonymous21_1){ 551 ((void)((*((int *)(&(*___dst__P14s__anonymous21_1).__i__i_1)))) /* ?{} */); 552 } 553 static inline void ___constructor__F_P14s__anonymous2114s__anonymous21_autogen___1(struct __anonymous21 *___dst__P14s__anonymous21_1, struct __anonymous21 ___src__14s__anonymous21_1){ 554 ((void)((*((int *)(&(*___dst__P14s__anonymous21_1).__i__i_1)))=___src__14s__anonymous21_1.__i__i_1) /* ?{} */); 555 } 556 static inline void ___destructor__F_P14s__anonymous21_autogen___1(struct __anonymous21 *___dst__P14s__anonymous21_1){ 557 ((void)((*((int *)(&(*___dst__P14s__anonymous21_1).__i__i_1)))) /* ^?{} */); 558 } 550 559 static inline struct __anonymous21 ___operator_assign__F14s__anonymous21_P14s__anonymous2114s__anonymous21_autogen___1(struct __anonymous21 *___dst__P14s__anonymous21_1, struct __anonymous21 ___src__14s__anonymous21_1){ 551 560 ((void)((*___dst__P14s__anonymous21_1).__i__i_1=___src__14s__anonymous21_1.__i__i_1)); 552 561 return ((struct __anonymous21 )___src__14s__anonymous21_1); 553 }554 static inline void ___constructor__F_P14s__anonymous21_autogen___1(struct __anonymous21 *___dst__P14s__anonymous21_1){555 ((void)((*((int *)(&(*___dst__P14s__anonymous21_1).__i__i_1)))) /* ?{} */);556 }557 static inline void ___constructor__F_P14s__anonymous2114s__anonymous21_autogen___1(struct __anonymous21 *___dst__P14s__anonymous21_1, struct __anonymous21 ___src__14s__anonymous21_1){558 ((void)((*((int *)(&(*___dst__P14s__anonymous21_1).__i__i_1)))=___src__14s__anonymous21_1.__i__i_1) /* ?{} */);559 }560 static inline void ___destructor__F_P14s__anonymous21_autogen___1(struct __anonymous21 *___dst__P14s__anonymous21_1){561 ((void)((*((int *)(&(*___dst__P14s__anonymous21_1).__i__i_1)))) /* ^?{} */);562 562 } 563 563 static inline void ___constructor__F_P14s__anonymous21i_autogen___1(struct __anonymous21 *___dst__P14s__anonymous21_1, int __i__i_1){ … … 572 572 static inline void ___constructor__F_P14s__anonymous2214s__anonymous22_autogen___1(struct __anonymous22 *___dst__P14s__anonymous22_1, struct __anonymous22 ___src__14s__anonymous22_1); 573 573 static inline void ___destructor__F_P14s__anonymous22_autogen___1(struct __anonymous22 *___dst__P14s__anonymous22_1); 574 static inline void ___constructor__F_P14s__anonymous22_autogen___1(struct __anonymous22 *___dst__P14s__anonymous22_1){ 575 ((void)((*((int *)(&(*___dst__P14s__anonymous22_1).__i__i_1)))) /* ?{} */); 576 } 577 static inline void ___constructor__F_P14s__anonymous2214s__anonymous22_autogen___1(struct __anonymous22 *___dst__P14s__anonymous22_1, struct __anonymous22 ___src__14s__anonymous22_1){ 578 ((void)((*((int *)(&(*___dst__P14s__anonymous22_1).__i__i_1)))=___src__14s__anonymous22_1.__i__i_1) /* ?{} */); 579 } 580 static inline void ___destructor__F_P14s__anonymous22_autogen___1(struct __anonymous22 *___dst__P14s__anonymous22_1){ 581 ((void)((*((int *)(&(*___dst__P14s__anonymous22_1).__i__i_1)))) /* ^?{} */); 582 } 574 583 static inline struct __anonymous22 ___operator_assign__F14s__anonymous22_P14s__anonymous2214s__anonymous22_autogen___1(struct __anonymous22 *___dst__P14s__anonymous22_1, struct __anonymous22 ___src__14s__anonymous22_1){ 575 584 ((void)((*___dst__P14s__anonymous22_1).__i__i_1=___src__14s__anonymous22_1.__i__i_1)); 576 585 return ((struct __anonymous22 )___src__14s__anonymous22_1); 577 }578 static inline void ___constructor__F_P14s__anonymous22_autogen___1(struct __anonymous22 *___dst__P14s__anonymous22_1){579 ((void)((*((int *)(&(*___dst__P14s__anonymous22_1).__i__i_1)))) /* ?{} */);580 }581 static inline void ___constructor__F_P14s__anonymous2214s__anonymous22_autogen___1(struct __anonymous22 *___dst__P14s__anonymous22_1, struct __anonymous22 ___src__14s__anonymous22_1){582 ((void)((*((int *)(&(*___dst__P14s__anonymous22_1).__i__i_1)))=___src__14s__anonymous22_1.__i__i_1) /* ?{} */);583 }584 static inline void ___destructor__F_P14s__anonymous22_autogen___1(struct __anonymous22 *___dst__P14s__anonymous22_1){585 ((void)((*((int *)(&(*___dst__P14s__anonymous22_1).__i__i_1)))) /* ^?{} */);586 586 } 587 587 static inline void ___constructor__F_P14s__anonymous22i_autogen___1(struct __anonymous22 *___dst__P14s__anonymous22_1, int __i__i_1){ … … 596 596 static inline void ___constructor__F_P14s__anonymous2314s__anonymous23_autogen___1(struct __anonymous23 *___dst__P14s__anonymous23_1, struct __anonymous23 ___src__14s__anonymous23_1); 597 597 static inline void ___destructor__F_P14s__anonymous23_autogen___1(struct __anonymous23 *___dst__P14s__anonymous23_1); 598 static inline void ___constructor__F_P14s__anonymous23_autogen___1(struct __anonymous23 *___dst__P14s__anonymous23_1){ 599 ((void)((*((int *)(&(*___dst__P14s__anonymous23_1).__i__i_1)))) /* ?{} */); 600 } 601 static inline void ___constructor__F_P14s__anonymous2314s__anonymous23_autogen___1(struct __anonymous23 *___dst__P14s__anonymous23_1, struct __anonymous23 ___src__14s__anonymous23_1){ 602 ((void)((*((int *)(&(*___dst__P14s__anonymous23_1).__i__i_1)))=___src__14s__anonymous23_1.__i__i_1) /* ?{} */); 603 } 604 static inline void ___destructor__F_P14s__anonymous23_autogen___1(struct __anonymous23 *___dst__P14s__anonymous23_1){ 605 ((void)((*((int *)(&(*___dst__P14s__anonymous23_1).__i__i_1)))) /* ^?{} */); 606 } 598 607 static inline struct __anonymous23 ___operator_assign__F14s__anonymous23_P14s__anonymous2314s__anonymous23_autogen___1(struct __anonymous23 *___dst__P14s__anonymous23_1, struct __anonymous23 ___src__14s__anonymous23_1){ 599 608 ((void)((*___dst__P14s__anonymous23_1).__i__i_1=___src__14s__anonymous23_1.__i__i_1)); 600 609 return ((struct __anonymous23 )___src__14s__anonymous23_1); 601 }602 static inline void ___constructor__F_P14s__anonymous23_autogen___1(struct __anonymous23 *___dst__P14s__anonymous23_1){603 ((void)((*((int *)(&(*___dst__P14s__anonymous23_1).__i__i_1)))) /* ?{} */);604 }605 static inline void ___constructor__F_P14s__anonymous2314s__anonymous23_autogen___1(struct __anonymous23 *___dst__P14s__anonymous23_1, struct __anonymous23 ___src__14s__anonymous23_1){606 ((void)((*((int *)(&(*___dst__P14s__anonymous23_1).__i__i_1)))=___src__14s__anonymous23_1.__i__i_1) /* ?{} */);607 }608 static inline void ___destructor__F_P14s__anonymous23_autogen___1(struct __anonymous23 *___dst__P14s__anonymous23_1){609 ((void)((*((int *)(&(*___dst__P14s__anonymous23_1).__i__i_1)))) /* ^?{} */);610 610 } 611 611 static inline void ___constructor__F_P14s__anonymous23i_autogen___1(struct __anonymous23 *___dst__P14s__anonymous23_1, int __i__i_1){ … … 622 622 static inline volatile const short __f48__FCVs___1(); 623 623 int main(int __argc__i_1, const char **__argv__PPCc_1){ 624 int _ retVal0 = { 0 };625 ((void)(_ retVal0=((int )0)) /* ?{} */);626 return ((int )_ retVal0);627 } 624 int ___retval_main__i_1; 625 ((void)(___retval_main__i_1=((int )0)) /* ?{} */); 626 return ((int )___retval_main__i_1); 627 } -
src/tests/.expect/32/extension.txt
r596f987b r66f8528 17 17 static inline void ___constructor__F_P2sS2sS_autogen___1(struct S *___dst__P2sS_1, struct S ___src__2sS_1); 18 18 static inline void ___destructor__F_P2sS_autogen___1(struct S *___dst__P2sS_1); 19 static inline struct S ___operator_assign__F2sS_P2sS2sS_autogen___1(struct S *___dst__P2sS_1, struct S ___src__2sS_1){20 ((void)((*___dst__P2sS_1).__a__i_1=___src__2sS_1.__a__i_1));21 ((void)((*___dst__P2sS_1).__b__i_1=___src__2sS_1.__b__i_1));22 ((void)((*___dst__P2sS_1).__c__i_1=___src__2sS_1.__c__i_1));23 return ((struct S )___src__2sS_1);24 }25 19 static inline void ___constructor__F_P2sS_autogen___1(struct S *___dst__P2sS_1){ 26 20 ((void)((*((int *)(&(*___dst__P2sS_1).__a__i_1)))) /* ?{} */); … … 37 31 ((void)((*((int *)(&(*___dst__P2sS_1).__b__i_1)))) /* ^?{} */); 38 32 ((void)((*((int *)(&(*___dst__P2sS_1).__a__i_1)))) /* ^?{} */); 33 } 34 static inline struct S ___operator_assign__F2sS_P2sS2sS_autogen___1(struct S *___dst__P2sS_1, struct S ___src__2sS_1){ 35 ((void)((*___dst__P2sS_1).__a__i_1=___src__2sS_1.__a__i_1)); 36 ((void)((*___dst__P2sS_1).__b__i_1=___src__2sS_1.__b__i_1)); 37 ((void)((*___dst__P2sS_1).__c__i_1=___src__2sS_1.__c__i_1)); 38 return ((struct S )___src__2sS_1); 39 39 } 40 40 static inline void ___constructor__F_P2sSi_autogen___1(struct S *___dst__P2sS_1, int __a__i_1){ … … 58 58 __extension__ int __c__i_1; 59 59 }; 60 static inline union U ___operator_assign__F2uU_P2uU2uU_autogen___1(union U *___dst__P2uU_1, union U ___src__2uU_1){61 ((void)__builtin_memcpy(((void *)___dst__P2uU_1), ((const void *)(&___src__2uU_1)), sizeof(union U )));62 return ((union U )___src__2uU_1);63 }64 60 static inline void ___constructor__F_P2uU_autogen___1(union U *___dst__P2uU_1){ 65 61 } 66 62 static inline void ___constructor__F_P2uU2uU_autogen___1(union U *___dst__P2uU_1, union U ___src__2uU_1){ 67 63 ((void)__builtin_memcpy(((void *)___dst__P2uU_1), ((const void *)(&___src__2uU_1)), sizeof(union U ))); 68 return ((void)___src__2uU_1);69 64 } 70 65 static inline void ___destructor__F_P2uU_autogen___1(union U *___dst__P2uU_1){ 66 } 67 static inline union U ___operator_assign__F2uU_P2uU2uU_autogen___1(union U *___dst__P2uU_1, union U ___src__2uU_1){ 68 ((void)__builtin_memcpy(((void *)___dst__P2uU_1), ((const void *)(&___src__2uU_1)), sizeof(union U ))); 69 return ((union U )___src__2uU_1); 71 70 } 72 71 static inline void ___constructor__F_P2uUi_autogen___1(union U *___dst__P2uU_1, int __src__i_1){ … … 79 78 }; 80 79 __extension__ int __fred__Fi_i__1(int __p__i_1){ 80 int ___retval_fred__i_1; 81 81 __extension__ struct S { 82 82 __extension__ int __a__i_2; -
src/tests/.expect/32/gccExtensions.txt
r596f987b r66f8528 7 7 extern int __x__i_1 asm ( "xx" ); 8 8 int main(int __argc__i_1, const char **__argv__PPCc_1){ 9 int ___retval_main__i_1; 9 10 asm ( "nop" : : : ); 10 11 asm ( "nop" : : : ); … … 25 26 const int __i3__Ci_2; 26 27 inline int __f1__Fi___2(){ 28 int ___retval_f1__i_2; 27 29 } 28 30 inline int __f2__Fi___2(){ 31 int ___retval_f2__i_2; 29 32 } 30 33 int __s1__i_2; … … 40 43 __extension__ int __c__i_2; 41 44 }; 42 inline struct S ___operator_assign__F2sS_P2sS2sS_autogen___2(struct S *___dst__P2sS_2, struct S ___src__2sS_2){43 ((void)((*___dst__P2sS_2).__a__i_2=___src__2sS_2.__a__i_2));44 ((void)((*___dst__P2sS_2).__b__i_2=___src__2sS_2.__b__i_2));45 ((void)((*___dst__P2sS_2).__c__i_2=___src__2sS_2.__c__i_2));46 return ((struct S )___src__2sS_2);47 }48 45 inline void ___constructor__F_P2sS_autogen___2(struct S *___dst__P2sS_2){ 49 46 ((void)((*((int *)(&(*___dst__P2sS_2).__a__i_2)))) /* ?{} */); … … 60 57 ((void)((*((int *)(&(*___dst__P2sS_2).__b__i_2)))) /* ^?{} */); 61 58 ((void)((*((int *)(&(*___dst__P2sS_2).__a__i_2)))) /* ^?{} */); 59 } 60 inline struct S ___operator_assign__F2sS_P2sS2sS_autogen___2(struct S *___dst__P2sS_2, struct S ___src__2sS_2){ 61 ((void)((*___dst__P2sS_2).__a__i_2=___src__2sS_2.__a__i_2)); 62 ((void)((*___dst__P2sS_2).__b__i_2=___src__2sS_2.__b__i_2)); 63 ((void)((*___dst__P2sS_2).__c__i_2=___src__2sS_2.__c__i_2)); 64 return ((struct S )___src__2sS_2); 62 65 } 63 66 inline void ___constructor__F_P2sSi_autogen___2(struct S *___dst__P2sS_2, int __a__i_2){ … … 96 99 int __i__i_2; 97 100 }; 98 inline struct s2 ___operator_assign__F3ss2_P3ss23ss2_autogen___2(struct s2 *___dst__P3ss2_2, struct s2 ___src__3ss2_2){99 ((void)((*___dst__P3ss2_2).__i__i_2=___src__3ss2_2.__i__i_2));100 return ((struct s2 )___src__3ss2_2);101 }102 101 inline void ___constructor__F_P3ss2_autogen___2(struct s2 *___dst__P3ss2_2){ 103 102 ((void)((*((int *)(&(*___dst__P3ss2_2).__i__i_2)))) /* ?{} */); … … 109 108 ((void)((*((int *)(&(*___dst__P3ss2_2).__i__i_2)))) /* ^?{} */); 110 109 } 110 inline struct s2 ___operator_assign__F3ss2_P3ss23ss2_autogen___2(struct s2 *___dst__P3ss2_2, struct s2 ___src__3ss2_2){ 111 ((void)((*___dst__P3ss2_2).__i__i_2=___src__3ss2_2.__i__i_2)); 112 return ((struct s2 )___src__3ss2_2); 113 } 111 114 inline void ___constructor__F_P3ss2i_autogen___2(struct s2 *___dst__P3ss2_2, int __i__i_2){ 112 115 ((void)((*((int *)(&(*___dst__P3ss2_2).__i__i_2)))=__i__i_2) /* ?{} */); … … 115 118 int __i__i_2; 116 119 }; 117 inline struct s3 ___operator_assign__F3ss3_P3ss33ss3_autogen___2(struct s3 *___dst__P3ss3_2, struct s3 ___src__3ss3_2){118 ((void)((*___dst__P3ss3_2).__i__i_2=___src__3ss3_2.__i__i_2));119 return ((struct s3 )___src__3ss3_2);120 }121 120 inline void ___constructor__F_P3ss3_autogen___2(struct s3 *___dst__P3ss3_2){ 122 121 ((void)((*((int *)(&(*___dst__P3ss3_2).__i__i_2)))) /* ?{} */); … … 128 127 ((void)((*((int *)(&(*___dst__P3ss3_2).__i__i_2)))) /* ^?{} */); 129 128 } 129 inline struct s3 ___operator_assign__F3ss3_P3ss33ss3_autogen___2(struct s3 *___dst__P3ss3_2, struct s3 ___src__3ss3_2){ 130 ((void)((*___dst__P3ss3_2).__i__i_2=___src__3ss3_2.__i__i_2)); 131 return ((struct s3 )___src__3ss3_2); 132 } 130 133 inline void ___constructor__F_P3ss3i_autogen___2(struct s3 *___dst__P3ss3_2, int __i__i_2){ 131 134 ((void)((*((int *)(&(*___dst__P3ss3_2).__i__i_2)))=__i__i_2) /* ?{} */); … … 136 139 int __i__i_2; 137 140 }; 138 inline struct s4 ___operator_assign__F3ss4_P3ss43ss4_autogen___2(struct s4 *___dst__P3ss4_2, struct s4 ___src__3ss4_2){139 ((void)((*___dst__P3ss4_2).__i__i_2=___src__3ss4_2.__i__i_2));140 return ((struct s4 )___src__3ss4_2);141 }142 141 inline void ___constructor__F_P3ss4_autogen___2(struct s4 *___dst__P3ss4_2){ 143 142 ((void)((*((int *)(&(*___dst__P3ss4_2).__i__i_2)))) /* ?{} */); … … 149 148 ((void)((*((int *)(&(*___dst__P3ss4_2).__i__i_2)))) /* ^?{} */); 150 149 } 150 inline struct s4 ___operator_assign__F3ss4_P3ss43ss4_autogen___2(struct s4 *___dst__P3ss4_2, struct s4 ___src__3ss4_2){ 151 ((void)((*___dst__P3ss4_2).__i__i_2=___src__3ss4_2.__i__i_2)); 152 return ((struct s4 )___src__3ss4_2); 153 } 151 154 inline void ___constructor__F_P3ss4i_autogen___2(struct s4 *___dst__P3ss4_2, int __i__i_2){ 152 155 ((void)((*((int *)(&(*___dst__P3ss4_2).__i__i_2)))=__i__i_2) /* ?{} */); … … 157 160 int __m2__A0A0i_2[((unsigned int )10)][((unsigned int )10)]; 158 161 int __m3__A0A0i_2[((unsigned int )10)][((unsigned int )10)]; 159 int _retVal0 = { 0 }; 160 ((void)(_retVal0=((int )0)) /* ?{} */); 161 return ((int )_retVal0); 162 ((void)(___retval_main__i_1=((int )0)) /* ?{} */); 163 return ((int )___retval_main__i_1); 162 164 } -
src/tests/.expect/64/declarationSpecifier.txt
r596f987b r66f8528 20 20 static inline void ___constructor__F_P13s__anonymous013s__anonymous0_autogen___1(struct __anonymous0 *___dst__P13s__anonymous0_1, struct __anonymous0 ___src__13s__anonymous0_1); 21 21 static inline void ___destructor__F_P13s__anonymous0_autogen___1(struct __anonymous0 *___dst__P13s__anonymous0_1); 22 static inline void ___constructor__F_P13s__anonymous0_autogen___1(struct __anonymous0 *___dst__P13s__anonymous0_1){ 23 ((void)((*((int *)(&(*___dst__P13s__anonymous0_1).__i__i_1)))) /* ?{} */); 24 } 25 static inline void ___constructor__F_P13s__anonymous013s__anonymous0_autogen___1(struct __anonymous0 *___dst__P13s__anonymous0_1, struct __anonymous0 ___src__13s__anonymous0_1){ 26 ((void)((*((int *)(&(*___dst__P13s__anonymous0_1).__i__i_1)))=___src__13s__anonymous0_1.__i__i_1) /* ?{} */); 27 } 28 static inline void ___destructor__F_P13s__anonymous0_autogen___1(struct __anonymous0 *___dst__P13s__anonymous0_1){ 29 ((void)((*((int *)(&(*___dst__P13s__anonymous0_1).__i__i_1)))) /* ^?{} */); 30 } 22 31 static inline struct __anonymous0 ___operator_assign__F13s__anonymous0_P13s__anonymous013s__anonymous0_autogen___1(struct __anonymous0 *___dst__P13s__anonymous0_1, struct __anonymous0 ___src__13s__anonymous0_1){ 23 32 ((void)((*___dst__P13s__anonymous0_1).__i__i_1=___src__13s__anonymous0_1.__i__i_1)); 24 33 return ((struct __anonymous0 )___src__13s__anonymous0_1); 25 }26 static inline void ___constructor__F_P13s__anonymous0_autogen___1(struct __anonymous0 *___dst__P13s__anonymous0_1){27 ((void)((*((int *)(&(*___dst__P13s__anonymous0_1).__i__i_1)))) /* ?{} */);28 }29 static inline void ___constructor__F_P13s__anonymous013s__anonymous0_autogen___1(struct __anonymous0 *___dst__P13s__anonymous0_1, struct __anonymous0 ___src__13s__anonymous0_1){30 ((void)((*((int *)(&(*___dst__P13s__anonymous0_1).__i__i_1)))=___src__13s__anonymous0_1.__i__i_1) /* ?{} */);31 }32 static inline void ___destructor__F_P13s__anonymous0_autogen___1(struct __anonymous0 *___dst__P13s__anonymous0_1){33 ((void)((*((int *)(&(*___dst__P13s__anonymous0_1).__i__i_1)))) /* ^?{} */);34 34 } 35 35 static inline void ___constructor__F_P13s__anonymous0i_autogen___1(struct __anonymous0 *___dst__P13s__anonymous0_1, int __i__i_1){ … … 44 44 static inline void ___constructor__F_P13s__anonymous113s__anonymous1_autogen___1(struct __anonymous1 *___dst__P13s__anonymous1_1, struct __anonymous1 ___src__13s__anonymous1_1); 45 45 static inline void ___destructor__F_P13s__anonymous1_autogen___1(struct __anonymous1 *___dst__P13s__anonymous1_1); 46 static inline void ___constructor__F_P13s__anonymous1_autogen___1(struct __anonymous1 *___dst__P13s__anonymous1_1){ 47 ((void)((*((int *)(&(*___dst__P13s__anonymous1_1).__i__i_1)))) /* ?{} */); 48 } 49 static inline void ___constructor__F_P13s__anonymous113s__anonymous1_autogen___1(struct __anonymous1 *___dst__P13s__anonymous1_1, struct __anonymous1 ___src__13s__anonymous1_1){ 50 ((void)((*((int *)(&(*___dst__P13s__anonymous1_1).__i__i_1)))=___src__13s__anonymous1_1.__i__i_1) /* ?{} */); 51 } 52 static inline void ___destructor__F_P13s__anonymous1_autogen___1(struct __anonymous1 *___dst__P13s__anonymous1_1){ 53 ((void)((*((int *)(&(*___dst__P13s__anonymous1_1).__i__i_1)))) /* ^?{} */); 54 } 46 55 static inline struct __anonymous1 ___operator_assign__F13s__anonymous1_P13s__anonymous113s__anonymous1_autogen___1(struct __anonymous1 *___dst__P13s__anonymous1_1, struct __anonymous1 ___src__13s__anonymous1_1){ 47 56 ((void)((*___dst__P13s__anonymous1_1).__i__i_1=___src__13s__anonymous1_1.__i__i_1)); 48 57 return ((struct __anonymous1 )___src__13s__anonymous1_1); 49 }50 static inline void ___constructor__F_P13s__anonymous1_autogen___1(struct __anonymous1 *___dst__P13s__anonymous1_1){51 ((void)((*((int *)(&(*___dst__P13s__anonymous1_1).__i__i_1)))) /* ?{} */);52 }53 static inline void ___constructor__F_P13s__anonymous113s__anonymous1_autogen___1(struct __anonymous1 *___dst__P13s__anonymous1_1, struct __anonymous1 ___src__13s__anonymous1_1){54 ((void)((*((int *)(&(*___dst__P13s__anonymous1_1).__i__i_1)))=___src__13s__anonymous1_1.__i__i_1) /* ?{} */);55 }56 static inline void ___destructor__F_P13s__anonymous1_autogen___1(struct __anonymous1 *___dst__P13s__anonymous1_1){57 ((void)((*((int *)(&(*___dst__P13s__anonymous1_1).__i__i_1)))) /* ^?{} */);58 58 } 59 59 static inline void ___constructor__F_P13s__anonymous1i_autogen___1(struct __anonymous1 *___dst__P13s__anonymous1_1, int __i__i_1){ … … 68 68 static inline void ___constructor__F_P13s__anonymous213s__anonymous2_autogen___1(struct __anonymous2 *___dst__P13s__anonymous2_1, struct __anonymous2 ___src__13s__anonymous2_1); 69 69 static inline void ___destructor__F_P13s__anonymous2_autogen___1(struct __anonymous2 *___dst__P13s__anonymous2_1); 70 static inline void ___constructor__F_P13s__anonymous2_autogen___1(struct __anonymous2 *___dst__P13s__anonymous2_1){ 71 ((void)((*((int *)(&(*___dst__P13s__anonymous2_1).__i__i_1)))) /* ?{} */); 72 } 73 static inline void ___constructor__F_P13s__anonymous213s__anonymous2_autogen___1(struct __anonymous2 *___dst__P13s__anonymous2_1, struct __anonymous2 ___src__13s__anonymous2_1){ 74 ((void)((*((int *)(&(*___dst__P13s__anonymous2_1).__i__i_1)))=___src__13s__anonymous2_1.__i__i_1) /* ?{} */); 75 } 76 static inline void ___destructor__F_P13s__anonymous2_autogen___1(struct __anonymous2 *___dst__P13s__anonymous2_1){ 77 ((void)((*((int *)(&(*___dst__P13s__anonymous2_1).__i__i_1)))) /* ^?{} */); 78 } 70 79 static inline struct __anonymous2 ___operator_assign__F13s__anonymous2_P13s__anonymous213s__anonymous2_autogen___1(struct __anonymous2 *___dst__P13s__anonymous2_1, struct __anonymous2 ___src__13s__anonymous2_1){ 71 80 ((void)((*___dst__P13s__anonymous2_1).__i__i_1=___src__13s__anonymous2_1.__i__i_1)); 72 81 return ((struct __anonymous2 )___src__13s__anonymous2_1); 73 }74 static inline void ___constructor__F_P13s__anonymous2_autogen___1(struct __anonymous2 *___dst__P13s__anonymous2_1){75 ((void)((*((int *)(&(*___dst__P13s__anonymous2_1).__i__i_1)))) /* ?{} */);76 }77 static inline void ___constructor__F_P13s__anonymous213s__anonymous2_autogen___1(struct __anonymous2 *___dst__P13s__anonymous2_1, struct __anonymous2 ___src__13s__anonymous2_1){78 ((void)((*((int *)(&(*___dst__P13s__anonymous2_1).__i__i_1)))=___src__13s__anonymous2_1.__i__i_1) /* ?{} */);79 }80 static inline void ___destructor__F_P13s__anonymous2_autogen___1(struct __anonymous2 *___dst__P13s__anonymous2_1){81 ((void)((*((int *)(&(*___dst__P13s__anonymous2_1).__i__i_1)))) /* ^?{} */);82 82 } 83 83 static inline void ___constructor__F_P13s__anonymous2i_autogen___1(struct __anonymous2 *___dst__P13s__anonymous2_1, int __i__i_1){ … … 92 92 static inline void ___constructor__F_P13s__anonymous313s__anonymous3_autogen___1(struct __anonymous3 *___dst__P13s__anonymous3_1, struct __anonymous3 ___src__13s__anonymous3_1); 93 93 static inline void ___destructor__F_P13s__anonymous3_autogen___1(struct __anonymous3 *___dst__P13s__anonymous3_1); 94 static inline void ___constructor__F_P13s__anonymous3_autogen___1(struct __anonymous3 *___dst__P13s__anonymous3_1){ 95 ((void)((*((int *)(&(*___dst__P13s__anonymous3_1).__i__i_1)))) /* ?{} */); 96 } 97 static inline void ___constructor__F_P13s__anonymous313s__anonymous3_autogen___1(struct __anonymous3 *___dst__P13s__anonymous3_1, struct __anonymous3 ___src__13s__anonymous3_1){ 98 ((void)((*((int *)(&(*___dst__P13s__anonymous3_1).__i__i_1)))=___src__13s__anonymous3_1.__i__i_1) /* ?{} */); 99 } 100 static inline void ___destructor__F_P13s__anonymous3_autogen___1(struct __anonymous3 *___dst__P13s__anonymous3_1){ 101 ((void)((*((int *)(&(*___dst__P13s__anonymous3_1).__i__i_1)))) /* ^?{} */); 102 } 94 103 static inline struct __anonymous3 ___operator_assign__F13s__anonymous3_P13s__anonymous313s__anonymous3_autogen___1(struct __anonymous3 *___dst__P13s__anonymous3_1, struct __anonymous3 ___src__13s__anonymous3_1){ 95 104 ((void)((*___dst__P13s__anonymous3_1).__i__i_1=___src__13s__anonymous3_1.__i__i_1)); 96 105 return ((struct __anonymous3 )___src__13s__anonymous3_1); 97 }98 static inline void ___constructor__F_P13s__anonymous3_autogen___1(struct __anonymous3 *___dst__P13s__anonymous3_1){99 ((void)((*((int *)(&(*___dst__P13s__anonymous3_1).__i__i_1)))) /* ?{} */);100 }101 static inline void ___constructor__F_P13s__anonymous313s__anonymous3_autogen___1(struct __anonymous3 *___dst__P13s__anonymous3_1, struct __anonymous3 ___src__13s__anonymous3_1){102 ((void)((*((int *)(&(*___dst__P13s__anonymous3_1).__i__i_1)))=___src__13s__anonymous3_1.__i__i_1) /* ?{} */);103 }104 static inline void ___destructor__F_P13s__anonymous3_autogen___1(struct __anonymous3 *___dst__P13s__anonymous3_1){105 ((void)((*((int *)(&(*___dst__P13s__anonymous3_1).__i__i_1)))) /* ^?{} */);106 106 } 107 107 static inline void ___constructor__F_P13s__anonymous3i_autogen___1(struct __anonymous3 *___dst__P13s__anonymous3_1, int __i__i_1){ … … 116 116 static inline void ___constructor__F_P13s__anonymous413s__anonymous4_autogen___1(struct __anonymous4 *___dst__P13s__anonymous4_1, struct __anonymous4 ___src__13s__anonymous4_1); 117 117 static inline void ___destructor__F_P13s__anonymous4_autogen___1(struct __anonymous4 *___dst__P13s__anonymous4_1); 118 static inline void ___constructor__F_P13s__anonymous4_autogen___1(struct __anonymous4 *___dst__P13s__anonymous4_1){ 119 ((void)((*((int *)(&(*___dst__P13s__anonymous4_1).__i__i_1)))) /* ?{} */); 120 } 121 static inline void ___constructor__F_P13s__anonymous413s__anonymous4_autogen___1(struct __anonymous4 *___dst__P13s__anonymous4_1, struct __anonymous4 ___src__13s__anonymous4_1){ 122 ((void)((*((int *)(&(*___dst__P13s__anonymous4_1).__i__i_1)))=___src__13s__anonymous4_1.__i__i_1) /* ?{} */); 123 } 124 static inline void ___destructor__F_P13s__anonymous4_autogen___1(struct __anonymous4 *___dst__P13s__anonymous4_1){ 125 ((void)((*((int *)(&(*___dst__P13s__anonymous4_1).__i__i_1)))) /* ^?{} */); 126 } 118 127 static inline struct __anonymous4 ___operator_assign__F13s__anonymous4_P13s__anonymous413s__anonymous4_autogen___1(struct __anonymous4 *___dst__P13s__anonymous4_1, struct __anonymous4 ___src__13s__anonymous4_1){ 119 128 ((void)((*___dst__P13s__anonymous4_1).__i__i_1=___src__13s__anonymous4_1.__i__i_1)); 120 129 return ((struct __anonymous4 )___src__13s__anonymous4_1); 121 }122 static inline void ___constructor__F_P13s__anonymous4_autogen___1(struct __anonymous4 *___dst__P13s__anonymous4_1){123 ((void)((*((int *)(&(*___dst__P13s__anonymous4_1).__i__i_1)))) /* ?{} */);124 }125 static inline void ___constructor__F_P13s__anonymous413s__anonymous4_autogen___1(struct __anonymous4 *___dst__P13s__anonymous4_1, struct __anonymous4 ___src__13s__anonymous4_1){126 ((void)((*((int *)(&(*___dst__P13s__anonymous4_1).__i__i_1)))=___src__13s__anonymous4_1.__i__i_1) /* ?{} */);127 }128 static inline void ___destructor__F_P13s__anonymous4_autogen___1(struct __anonymous4 *___dst__P13s__anonymous4_1){129 ((void)((*((int *)(&(*___dst__P13s__anonymous4_1).__i__i_1)))) /* ^?{} */);130 130 } 131 131 static inline void ___constructor__F_P13s__anonymous4i_autogen___1(struct __anonymous4 *___dst__P13s__anonymous4_1, int __i__i_1){ … … 140 140 static inline void ___constructor__F_P13s__anonymous513s__anonymous5_autogen___1(struct __anonymous5 *___dst__P13s__anonymous5_1, struct __anonymous5 ___src__13s__anonymous5_1); 141 141 static inline void ___destructor__F_P13s__anonymous5_autogen___1(struct __anonymous5 *___dst__P13s__anonymous5_1); 142 static inline void ___constructor__F_P13s__anonymous5_autogen___1(struct __anonymous5 *___dst__P13s__anonymous5_1){ 143 ((void)((*((int *)(&(*___dst__P13s__anonymous5_1).__i__i_1)))) /* ?{} */); 144 } 145 static inline void ___constructor__F_P13s__anonymous513s__anonymous5_autogen___1(struct __anonymous5 *___dst__P13s__anonymous5_1, struct __anonymous5 ___src__13s__anonymous5_1){ 146 ((void)((*((int *)(&(*___dst__P13s__anonymous5_1).__i__i_1)))=___src__13s__anonymous5_1.__i__i_1) /* ?{} */); 147 } 148 static inline void ___destructor__F_P13s__anonymous5_autogen___1(struct __anonymous5 *___dst__P13s__anonymous5_1){ 149 ((void)((*((int *)(&(*___dst__P13s__anonymous5_1).__i__i_1)))) /* ^?{} */); 150 } 142 151 static inline struct __anonymous5 ___operator_assign__F13s__anonymous5_P13s__anonymous513s__anonymous5_autogen___1(struct __anonymous5 *___dst__P13s__anonymous5_1, struct __anonymous5 ___src__13s__anonymous5_1){ 143 152 ((void)((*___dst__P13s__anonymous5_1).__i__i_1=___src__13s__anonymous5_1.__i__i_1)); 144 153 return ((struct __anonymous5 )___src__13s__anonymous5_1); 145 }146 static inline void ___constructor__F_P13s__anonymous5_autogen___1(struct __anonymous5 *___dst__P13s__anonymous5_1){147 ((void)((*((int *)(&(*___dst__P13s__anonymous5_1).__i__i_1)))) /* ?{} */);148 }149 static inline void ___constructor__F_P13s__anonymous513s__anonymous5_autogen___1(struct __anonymous5 *___dst__P13s__anonymous5_1, struct __anonymous5 ___src__13s__anonymous5_1){150 ((void)((*((int *)(&(*___dst__P13s__anonymous5_1).__i__i_1)))=___src__13s__anonymous5_1.__i__i_1) /* ?{} */);151 }152 static inline void ___destructor__F_P13s__anonymous5_autogen___1(struct __anonymous5 *___dst__P13s__anonymous5_1){153 ((void)((*((int *)(&(*___dst__P13s__anonymous5_1).__i__i_1)))) /* ^?{} */);154 154 } 155 155 static inline void ___constructor__F_P13s__anonymous5i_autogen___1(struct __anonymous5 *___dst__P13s__anonymous5_1, int __i__i_1){ … … 164 164 static inline void ___constructor__F_P13s__anonymous613s__anonymous6_autogen___1(struct __anonymous6 *___dst__P13s__anonymous6_1, struct __anonymous6 ___src__13s__anonymous6_1); 165 165 static inline void ___destructor__F_P13s__anonymous6_autogen___1(struct __anonymous6 *___dst__P13s__anonymous6_1); 166 static inline void ___constructor__F_P13s__anonymous6_autogen___1(struct __anonymous6 *___dst__P13s__anonymous6_1){ 167 ((void)((*((int *)(&(*___dst__P13s__anonymous6_1).__i__i_1)))) /* ?{} */); 168 } 169 static inline void ___constructor__F_P13s__anonymous613s__anonymous6_autogen___1(struct __anonymous6 *___dst__P13s__anonymous6_1, struct __anonymous6 ___src__13s__anonymous6_1){ 170 ((void)((*((int *)(&(*___dst__P13s__anonymous6_1).__i__i_1)))=___src__13s__anonymous6_1.__i__i_1) /* ?{} */); 171 } 172 static inline void ___destructor__F_P13s__anonymous6_autogen___1(struct __anonymous6 *___dst__P13s__anonymous6_1){ 173 ((void)((*((int *)(&(*___dst__P13s__anonymous6_1).__i__i_1)))) /* ^?{} */); 174 } 166 175 static inline struct __anonymous6 ___operator_assign__F13s__anonymous6_P13s__anonymous613s__anonymous6_autogen___1(struct __anonymous6 *___dst__P13s__anonymous6_1, struct __anonymous6 ___src__13s__anonymous6_1){ 167 176 ((void)((*___dst__P13s__anonymous6_1).__i__i_1=___src__13s__anonymous6_1.__i__i_1)); 168 177 return ((struct __anonymous6 )___src__13s__anonymous6_1); 169 }170 static inline void ___constructor__F_P13s__anonymous6_autogen___1(struct __anonymous6 *___dst__P13s__anonymous6_1){171 ((void)((*((int *)(&(*___dst__P13s__anonymous6_1).__i__i_1)))) /* ?{} */);172 }173 static inline void ___constructor__F_P13s__anonymous613s__anonymous6_autogen___1(struct __anonymous6 *___dst__P13s__anonymous6_1, struct __anonymous6 ___src__13s__anonymous6_1){174 ((void)((*((int *)(&(*___dst__P13s__anonymous6_1).__i__i_1)))=___src__13s__anonymous6_1.__i__i_1) /* ?{} */);175 }176 static inline void ___destructor__F_P13s__anonymous6_autogen___1(struct __anonymous6 *___dst__P13s__anonymous6_1){177 ((void)((*((int *)(&(*___dst__P13s__anonymous6_1).__i__i_1)))) /* ^?{} */);178 178 } 179 179 static inline void ___constructor__F_P13s__anonymous6i_autogen___1(struct __anonymous6 *___dst__P13s__anonymous6_1, int __i__i_1){ … … 188 188 static inline void ___constructor__F_P13s__anonymous713s__anonymous7_autogen___1(struct __anonymous7 *___dst__P13s__anonymous7_1, struct __anonymous7 ___src__13s__anonymous7_1); 189 189 static inline void ___destructor__F_P13s__anonymous7_autogen___1(struct __anonymous7 *___dst__P13s__anonymous7_1); 190 static inline void ___constructor__F_P13s__anonymous7_autogen___1(struct __anonymous7 *___dst__P13s__anonymous7_1){ 191 ((void)((*((int *)(&(*___dst__P13s__anonymous7_1).__i__i_1)))) /* ?{} */); 192 } 193 static inline void ___constructor__F_P13s__anonymous713s__anonymous7_autogen___1(struct __anonymous7 *___dst__P13s__anonymous7_1, struct __anonymous7 ___src__13s__anonymous7_1){ 194 ((void)((*((int *)(&(*___dst__P13s__anonymous7_1).__i__i_1)))=___src__13s__anonymous7_1.__i__i_1) /* ?{} */); 195 } 196 static inline void ___destructor__F_P13s__anonymous7_autogen___1(struct __anonymous7 *___dst__P13s__anonymous7_1){ 197 ((void)((*((int *)(&(*___dst__P13s__anonymous7_1).__i__i_1)))) /* ^?{} */); 198 } 190 199 static inline struct __anonymous7 ___operator_assign__F13s__anonymous7_P13s__anonymous713s__anonymous7_autogen___1(struct __anonymous7 *___dst__P13s__anonymous7_1, struct __anonymous7 ___src__13s__anonymous7_1){ 191 200 ((void)((*___dst__P13s__anonymous7_1).__i__i_1=___src__13s__anonymous7_1.__i__i_1)); 192 201 return ((struct __anonymous7 )___src__13s__anonymous7_1); 193 }194 static inline void ___constructor__F_P13s__anonymous7_autogen___1(struct __anonymous7 *___dst__P13s__anonymous7_1){195 ((void)((*((int *)(&(*___dst__P13s__anonymous7_1).__i__i_1)))) /* ?{} */);196 }197 static inline void ___constructor__F_P13s__anonymous713s__anonymous7_autogen___1(struct __anonymous7 *___dst__P13s__anonymous7_1, struct __anonymous7 ___src__13s__anonymous7_1){198 ((void)((*((int *)(&(*___dst__P13s__anonymous7_1).__i__i_1)))=___src__13s__anonymous7_1.__i__i_1) /* ?{} */);199 }200 static inline void ___destructor__F_P13s__anonymous7_autogen___1(struct __anonymous7 *___dst__P13s__anonymous7_1){201 ((void)((*((int *)(&(*___dst__P13s__anonymous7_1).__i__i_1)))) /* ^?{} */);202 202 } 203 203 static inline void ___constructor__F_P13s__anonymous7i_autogen___1(struct __anonymous7 *___dst__P13s__anonymous7_1, int __i__i_1){ … … 220 220 static inline void ___constructor__F_P13s__anonymous813s__anonymous8_autogen___1(struct __anonymous8 *___dst__P13s__anonymous8_1, struct __anonymous8 ___src__13s__anonymous8_1); 221 221 static inline void ___destructor__F_P13s__anonymous8_autogen___1(struct __anonymous8 *___dst__P13s__anonymous8_1); 222 static inline void ___constructor__F_P13s__anonymous8_autogen___1(struct __anonymous8 *___dst__P13s__anonymous8_1){ 223 ((void)((*((short *)(&(*___dst__P13s__anonymous8_1).__i__s_1)))) /* ?{} */); 224 } 225 static inline void ___constructor__F_P13s__anonymous813s__anonymous8_autogen___1(struct __anonymous8 *___dst__P13s__anonymous8_1, struct __anonymous8 ___src__13s__anonymous8_1){ 226 ((void)((*((short *)(&(*___dst__P13s__anonymous8_1).__i__s_1)))=___src__13s__anonymous8_1.__i__s_1) /* ?{} */); 227 } 228 static inline void ___destructor__F_P13s__anonymous8_autogen___1(struct __anonymous8 *___dst__P13s__anonymous8_1){ 229 ((void)((*((short *)(&(*___dst__P13s__anonymous8_1).__i__s_1)))) /* ^?{} */); 230 } 222 231 static inline struct __anonymous8 ___operator_assign__F13s__anonymous8_P13s__anonymous813s__anonymous8_autogen___1(struct __anonymous8 *___dst__P13s__anonymous8_1, struct __anonymous8 ___src__13s__anonymous8_1){ 223 232 ((void)((*___dst__P13s__anonymous8_1).__i__s_1=___src__13s__anonymous8_1.__i__s_1)); 224 233 return ((struct __anonymous8 )___src__13s__anonymous8_1); 225 }226 static inline void ___constructor__F_P13s__anonymous8_autogen___1(struct __anonymous8 *___dst__P13s__anonymous8_1){227 ((void)((*((short *)(&(*___dst__P13s__anonymous8_1).__i__s_1)))) /* ?{} */);228 }229 static inline void ___constructor__F_P13s__anonymous813s__anonymous8_autogen___1(struct __anonymous8 *___dst__P13s__anonymous8_1, struct __anonymous8 ___src__13s__anonymous8_1){230 ((void)((*((short *)(&(*___dst__P13s__anonymous8_1).__i__s_1)))=___src__13s__anonymous8_1.__i__s_1) /* ?{} */);231 }232 static inline void ___destructor__F_P13s__anonymous8_autogen___1(struct __anonymous8 *___dst__P13s__anonymous8_1){233 ((void)((*((short *)(&(*___dst__P13s__anonymous8_1).__i__s_1)))) /* ^?{} */);234 234 } 235 235 static inline void ___constructor__F_P13s__anonymous8s_autogen___1(struct __anonymous8 *___dst__P13s__anonymous8_1, short __i__s_1){ … … 244 244 static inline void ___constructor__F_P13s__anonymous913s__anonymous9_autogen___1(struct __anonymous9 *___dst__P13s__anonymous9_1, struct __anonymous9 ___src__13s__anonymous9_1); 245 245 static inline void ___destructor__F_P13s__anonymous9_autogen___1(struct __anonymous9 *___dst__P13s__anonymous9_1); 246 static inline void ___constructor__F_P13s__anonymous9_autogen___1(struct __anonymous9 *___dst__P13s__anonymous9_1){ 247 ((void)((*((short *)(&(*___dst__P13s__anonymous9_1).__i__s_1)))) /* ?{} */); 248 } 249 static inline void ___constructor__F_P13s__anonymous913s__anonymous9_autogen___1(struct __anonymous9 *___dst__P13s__anonymous9_1, struct __anonymous9 ___src__13s__anonymous9_1){ 250 ((void)((*((short *)(&(*___dst__P13s__anonymous9_1).__i__s_1)))=___src__13s__anonymous9_1.__i__s_1) /* ?{} */); 251 } 252 static inline void ___destructor__F_P13s__anonymous9_autogen___1(struct __anonymous9 *___dst__P13s__anonymous9_1){ 253 ((void)((*((short *)(&(*___dst__P13s__anonymous9_1).__i__s_1)))) /* ^?{} */); 254 } 246 255 static inline struct __anonymous9 ___operator_assign__F13s__anonymous9_P13s__anonymous913s__anonymous9_autogen___1(struct __anonymous9 *___dst__P13s__anonymous9_1, struct __anonymous9 ___src__13s__anonymous9_1){ 247 256 ((void)((*___dst__P13s__anonymous9_1).__i__s_1=___src__13s__anonymous9_1.__i__s_1)); 248 257 return ((struct __anonymous9 )___src__13s__anonymous9_1); 249 }250 static inline void ___constructor__F_P13s__anonymous9_autogen___1(struct __anonymous9 *___dst__P13s__anonymous9_1){251 ((void)((*((short *)(&(*___dst__P13s__anonymous9_1).__i__s_1)))) /* ?{} */);252 }253 static inline void ___constructor__F_P13s__anonymous913s__anonymous9_autogen___1(struct __anonymous9 *___dst__P13s__anonymous9_1, struct __anonymous9 ___src__13s__anonymous9_1){254 ((void)((*((short *)(&(*___dst__P13s__anonymous9_1).__i__s_1)))=___src__13s__anonymous9_1.__i__s_1) /* ?{} */);255 }256 static inline void ___destructor__F_P13s__anonymous9_autogen___1(struct __anonymous9 *___dst__P13s__anonymous9_1){257 ((void)((*((short *)(&(*___dst__P13s__anonymous9_1).__i__s_1)))) /* ^?{} */);258 258 } 259 259 static inline void ___constructor__F_P13s__anonymous9s_autogen___1(struct __anonymous9 *___dst__P13s__anonymous9_1, short __i__s_1){ … … 268 268 static inline void ___constructor__F_P14s__anonymous1014s__anonymous10_autogen___1(struct __anonymous10 *___dst__P14s__anonymous10_1, struct __anonymous10 ___src__14s__anonymous10_1); 269 269 static inline void ___destructor__F_P14s__anonymous10_autogen___1(struct __anonymous10 *___dst__P14s__anonymous10_1); 270 static inline void ___constructor__F_P14s__anonymous10_autogen___1(struct __anonymous10 *___dst__P14s__anonymous10_1){ 271 ((void)((*((short *)(&(*___dst__P14s__anonymous10_1).__i__s_1)))) /* ?{} */); 272 } 273 static inline void ___constructor__F_P14s__anonymous1014s__anonymous10_autogen___1(struct __anonymous10 *___dst__P14s__anonymous10_1, struct __anonymous10 ___src__14s__anonymous10_1){ 274 ((void)((*((short *)(&(*___dst__P14s__anonymous10_1).__i__s_1)))=___src__14s__anonymous10_1.__i__s_1) /* ?{} */); 275 } 276 static inline void ___destructor__F_P14s__anonymous10_autogen___1(struct __anonymous10 *___dst__P14s__anonymous10_1){ 277 ((void)((*((short *)(&(*___dst__P14s__anonymous10_1).__i__s_1)))) /* ^?{} */); 278 } 270 279 static inline struct __anonymous10 ___operator_assign__F14s__anonymous10_P14s__anonymous1014s__anonymous10_autogen___1(struct __anonymous10 *___dst__P14s__anonymous10_1, struct __anonymous10 ___src__14s__anonymous10_1){ 271 280 ((void)((*___dst__P14s__anonymous10_1).__i__s_1=___src__14s__anonymous10_1.__i__s_1)); 272 281 return ((struct __anonymous10 )___src__14s__anonymous10_1); 273 }274 static inline void ___constructor__F_P14s__anonymous10_autogen___1(struct __anonymous10 *___dst__P14s__anonymous10_1){275 ((void)((*((short *)(&(*___dst__P14s__anonymous10_1).__i__s_1)))) /* ?{} */);276 }277 static inline void ___constructor__F_P14s__anonymous1014s__anonymous10_autogen___1(struct __anonymous10 *___dst__P14s__anonymous10_1, struct __anonymous10 ___src__14s__anonymous10_1){278 ((void)((*((short *)(&(*___dst__P14s__anonymous10_1).__i__s_1)))=___src__14s__anonymous10_1.__i__s_1) /* ?{} */);279 }280 static inline void ___destructor__F_P14s__anonymous10_autogen___1(struct __anonymous10 *___dst__P14s__anonymous10_1){281 ((void)((*((short *)(&(*___dst__P14s__anonymous10_1).__i__s_1)))) /* ^?{} */);282 282 } 283 283 static inline void ___constructor__F_P14s__anonymous10s_autogen___1(struct __anonymous10 *___dst__P14s__anonymous10_1, short __i__s_1){ … … 292 292 static inline void ___constructor__F_P14s__anonymous1114s__anonymous11_autogen___1(struct __anonymous11 *___dst__P14s__anonymous11_1, struct __anonymous11 ___src__14s__anonymous11_1); 293 293 static inline void ___destructor__F_P14s__anonymous11_autogen___1(struct __anonymous11 *___dst__P14s__anonymous11_1); 294 static inline void ___constructor__F_P14s__anonymous11_autogen___1(struct __anonymous11 *___dst__P14s__anonymous11_1){ 295 ((void)((*((short *)(&(*___dst__P14s__anonymous11_1).__i__s_1)))) /* ?{} */); 296 } 297 static inline void ___constructor__F_P14s__anonymous1114s__anonymous11_autogen___1(struct __anonymous11 *___dst__P14s__anonymous11_1, struct __anonymous11 ___src__14s__anonymous11_1){ 298 ((void)((*((short *)(&(*___dst__P14s__anonymous11_1).__i__s_1)))=___src__14s__anonymous11_1.__i__s_1) /* ?{} */); 299 } 300 static inline void ___destructor__F_P14s__anonymous11_autogen___1(struct __anonymous11 *___dst__P14s__anonymous11_1){ 301 ((void)((*((short *)(&(*___dst__P14s__anonymous11_1).__i__s_1)))) /* ^?{} */); 302 } 294 303 static inline struct __anonymous11 ___operator_assign__F14s__anonymous11_P14s__anonymous1114s__anonymous11_autogen___1(struct __anonymous11 *___dst__P14s__anonymous11_1, struct __anonymous11 ___src__14s__anonymous11_1){ 295 304 ((void)((*___dst__P14s__anonymous11_1).__i__s_1=___src__14s__anonymous11_1.__i__s_1)); 296 305 return ((struct __anonymous11 )___src__14s__anonymous11_1); 297 }298 static inline void ___constructor__F_P14s__anonymous11_autogen___1(struct __anonymous11 *___dst__P14s__anonymous11_1){299 ((void)((*((short *)(&(*___dst__P14s__anonymous11_1).__i__s_1)))) /* ?{} */);300 }301 static inline void ___constructor__F_P14s__anonymous1114s__anonymous11_autogen___1(struct __anonymous11 *___dst__P14s__anonymous11_1, struct __anonymous11 ___src__14s__anonymous11_1){302 ((void)((*((short *)(&(*___dst__P14s__anonymous11_1).__i__s_1)))=___src__14s__anonymous11_1.__i__s_1) /* ?{} */);303 }304 static inline void ___destructor__F_P14s__anonymous11_autogen___1(struct __anonymous11 *___dst__P14s__anonymous11_1){305 ((void)((*((short *)(&(*___dst__P14s__anonymous11_1).__i__s_1)))) /* ^?{} */);306 306 } 307 307 static inline void ___constructor__F_P14s__anonymous11s_autogen___1(struct __anonymous11 *___dst__P14s__anonymous11_1, short __i__s_1){ … … 316 316 static inline void ___constructor__F_P14s__anonymous1214s__anonymous12_autogen___1(struct __anonymous12 *___dst__P14s__anonymous12_1, struct __anonymous12 ___src__14s__anonymous12_1); 317 317 static inline void ___destructor__F_P14s__anonymous12_autogen___1(struct __anonymous12 *___dst__P14s__anonymous12_1); 318 static inline void ___constructor__F_P14s__anonymous12_autogen___1(struct __anonymous12 *___dst__P14s__anonymous12_1){ 319 ((void)((*((short *)(&(*___dst__P14s__anonymous12_1).__i__s_1)))) /* ?{} */); 320 } 321 static inline void ___constructor__F_P14s__anonymous1214s__anonymous12_autogen___1(struct __anonymous12 *___dst__P14s__anonymous12_1, struct __anonymous12 ___src__14s__anonymous12_1){ 322 ((void)((*((short *)(&(*___dst__P14s__anonymous12_1).__i__s_1)))=___src__14s__anonymous12_1.__i__s_1) /* ?{} */); 323 } 324 static inline void ___destructor__F_P14s__anonymous12_autogen___1(struct __anonymous12 *___dst__P14s__anonymous12_1){ 325 ((void)((*((short *)(&(*___dst__P14s__anonymous12_1).__i__s_1)))) /* ^?{} */); 326 } 318 327 static inline struct __anonymous12 ___operator_assign__F14s__anonymous12_P14s__anonymous1214s__anonymous12_autogen___1(struct __anonymous12 *___dst__P14s__anonymous12_1, struct __anonymous12 ___src__14s__anonymous12_1){ 319 328 ((void)((*___dst__P14s__anonymous12_1).__i__s_1=___src__14s__anonymous12_1.__i__s_1)); 320 329 return ((struct __anonymous12 )___src__14s__anonymous12_1); 321 }322 static inline void ___constructor__F_P14s__anonymous12_autogen___1(struct __anonymous12 *___dst__P14s__anonymous12_1){323 ((void)((*((short *)(&(*___dst__P14s__anonymous12_1).__i__s_1)))) /* ?{} */);324 }325 static inline void ___constructor__F_P14s__anonymous1214s__anonymous12_autogen___1(struct __anonymous12 *___dst__P14s__anonymous12_1, struct __anonymous12 ___src__14s__anonymous12_1){326 ((void)((*((short *)(&(*___dst__P14s__anonymous12_1).__i__s_1)))=___src__14s__anonymous12_1.__i__s_1) /* ?{} */);327 }328 static inline void ___destructor__F_P14s__anonymous12_autogen___1(struct __anonymous12 *___dst__P14s__anonymous12_1){329 ((void)((*((short *)(&(*___dst__P14s__anonymous12_1).__i__s_1)))) /* ^?{} */);330 330 } 331 331 static inline void ___constructor__F_P14s__anonymous12s_autogen___1(struct __anonymous12 *___dst__P14s__anonymous12_1, short __i__s_1){ … … 340 340 static inline void ___constructor__F_P14s__anonymous1314s__anonymous13_autogen___1(struct __anonymous13 *___dst__P14s__anonymous13_1, struct __anonymous13 ___src__14s__anonymous13_1); 341 341 static inline void ___destructor__F_P14s__anonymous13_autogen___1(struct __anonymous13 *___dst__P14s__anonymous13_1); 342 static inline void ___constructor__F_P14s__anonymous13_autogen___1(struct __anonymous13 *___dst__P14s__anonymous13_1){ 343 ((void)((*((short *)(&(*___dst__P14s__anonymous13_1).__i__s_1)))) /* ?{} */); 344 } 345 static inline void ___constructor__F_P14s__anonymous1314s__anonymous13_autogen___1(struct __anonymous13 *___dst__P14s__anonymous13_1, struct __anonymous13 ___src__14s__anonymous13_1){ 346 ((void)((*((short *)(&(*___dst__P14s__anonymous13_1).__i__s_1)))=___src__14s__anonymous13_1.__i__s_1) /* ?{} */); 347 } 348 static inline void ___destructor__F_P14s__anonymous13_autogen___1(struct __anonymous13 *___dst__P14s__anonymous13_1){ 349 ((void)((*((short *)(&(*___dst__P14s__anonymous13_1).__i__s_1)))) /* ^?{} */); 350 } 342 351 static inline struct __anonymous13 ___operator_assign__F14s__anonymous13_P14s__anonymous1314s__anonymous13_autogen___1(struct __anonymous13 *___dst__P14s__anonymous13_1, struct __anonymous13 ___src__14s__anonymous13_1){ 343 352 ((void)((*___dst__P14s__anonymous13_1).__i__s_1=___src__14s__anonymous13_1.__i__s_1)); 344 353 return ((struct __anonymous13 )___src__14s__anonymous13_1); 345 }346 static inline void ___constructor__F_P14s__anonymous13_autogen___1(struct __anonymous13 *___dst__P14s__anonymous13_1){347 ((void)((*((short *)(&(*___dst__P14s__anonymous13_1).__i__s_1)))) /* ?{} */);348 }349 static inline void ___constructor__F_P14s__anonymous1314s__anonymous13_autogen___1(struct __anonymous13 *___dst__P14s__anonymous13_1, struct __anonymous13 ___src__14s__anonymous13_1){350 ((void)((*((short *)(&(*___dst__P14s__anonymous13_1).__i__s_1)))=___src__14s__anonymous13_1.__i__s_1) /* ?{} */);351 }352 static inline void ___destructor__F_P14s__anonymous13_autogen___1(struct __anonymous13 *___dst__P14s__anonymous13_1){353 ((void)((*((short *)(&(*___dst__P14s__anonymous13_1).__i__s_1)))) /* ^?{} */);354 354 } 355 355 static inline void ___constructor__F_P14s__anonymous13s_autogen___1(struct __anonymous13 *___dst__P14s__anonymous13_1, short __i__s_1){ … … 364 364 static inline void ___constructor__F_P14s__anonymous1414s__anonymous14_autogen___1(struct __anonymous14 *___dst__P14s__anonymous14_1, struct __anonymous14 ___src__14s__anonymous14_1); 365 365 static inline void ___destructor__F_P14s__anonymous14_autogen___1(struct __anonymous14 *___dst__P14s__anonymous14_1); 366 static inline void ___constructor__F_P14s__anonymous14_autogen___1(struct __anonymous14 *___dst__P14s__anonymous14_1){ 367 ((void)((*((short *)(&(*___dst__P14s__anonymous14_1).__i__s_1)))) /* ?{} */); 368 } 369 static inline void ___constructor__F_P14s__anonymous1414s__anonymous14_autogen___1(struct __anonymous14 *___dst__P14s__anonymous14_1, struct __anonymous14 ___src__14s__anonymous14_1){ 370 ((void)((*((short *)(&(*___dst__P14s__anonymous14_1).__i__s_1)))=___src__14s__anonymous14_1.__i__s_1) /* ?{} */); 371 } 372 static inline void ___destructor__F_P14s__anonymous14_autogen___1(struct __anonymous14 *___dst__P14s__anonymous14_1){ 373 ((void)((*((short *)(&(*___dst__P14s__anonymous14_1).__i__s_1)))) /* ^?{} */); 374 } 366 375 static inline struct __anonymous14 ___operator_assign__F14s__anonymous14_P14s__anonymous1414s__anonymous14_autogen___1(struct __anonymous14 *___dst__P14s__anonymous14_1, struct __anonymous14 ___src__14s__anonymous14_1){ 367 376 ((void)((*___dst__P14s__anonymous14_1).__i__s_1=___src__14s__anonymous14_1.__i__s_1)); 368 377 return ((struct __anonymous14 )___src__14s__anonymous14_1); 369 }370 static inline void ___constructor__F_P14s__anonymous14_autogen___1(struct __anonymous14 *___dst__P14s__anonymous14_1){371 ((void)((*((short *)(&(*___dst__P14s__anonymous14_1).__i__s_1)))) /* ?{} */);372 }373 static inline void ___constructor__F_P14s__anonymous1414s__anonymous14_autogen___1(struct __anonymous14 *___dst__P14s__anonymous14_1, struct __anonymous14 ___src__14s__anonymous14_1){374 ((void)((*((short *)(&(*___dst__P14s__anonymous14_1).__i__s_1)))=___src__14s__anonymous14_1.__i__s_1) /* ?{} */);375 }376 static inline void ___destructor__F_P14s__anonymous14_autogen___1(struct __anonymous14 *___dst__P14s__anonymous14_1){377 ((void)((*((short *)(&(*___dst__P14s__anonymous14_1).__i__s_1)))) /* ^?{} */);378 378 } 379 379 static inline void ___constructor__F_P14s__anonymous14s_autogen___1(struct __anonymous14 *___dst__P14s__anonymous14_1, short __i__s_1){ … … 388 388 static inline void ___constructor__F_P14s__anonymous1514s__anonymous15_autogen___1(struct __anonymous15 *___dst__P14s__anonymous15_1, struct __anonymous15 ___src__14s__anonymous15_1); 389 389 static inline void ___destructor__F_P14s__anonymous15_autogen___1(struct __anonymous15 *___dst__P14s__anonymous15_1); 390 static inline void ___constructor__F_P14s__anonymous15_autogen___1(struct __anonymous15 *___dst__P14s__anonymous15_1){ 391 ((void)((*((short *)(&(*___dst__P14s__anonymous15_1).__i__s_1)))) /* ?{} */); 392 } 393 static inline void ___constructor__F_P14s__anonymous1514s__anonymous15_autogen___1(struct __anonymous15 *___dst__P14s__anonymous15_1, struct __anonymous15 ___src__14s__anonymous15_1){ 394 ((void)((*((short *)(&(*___dst__P14s__anonymous15_1).__i__s_1)))=___src__14s__anonymous15_1.__i__s_1) /* ?{} */); 395 } 396 static inline void ___destructor__F_P14s__anonymous15_autogen___1(struct __anonymous15 *___dst__P14s__anonymous15_1){ 397 ((void)((*((short *)(&(*___dst__P14s__anonymous15_1).__i__s_1)))) /* ^?{} */); 398 } 390 399 static inline struct __anonymous15 ___operator_assign__F14s__anonymous15_P14s__anonymous1514s__anonymous15_autogen___1(struct __anonymous15 *___dst__P14s__anonymous15_1, struct __anonymous15 ___src__14s__anonymous15_1){ 391 400 ((void)((*___dst__P14s__anonymous15_1).__i__s_1=___src__14s__anonymous15_1.__i__s_1)); 392 401 return ((struct __anonymous15 )___src__14s__anonymous15_1); 393 }394 static inline void ___constructor__F_P14s__anonymous15_autogen___1(struct __anonymous15 *___dst__P14s__anonymous15_1){395 ((void)((*((short *)(&(*___dst__P14s__anonymous15_1).__i__s_1)))) /* ?{} */);396 }397 static inline void ___constructor__F_P14s__anonymous1514s__anonymous15_autogen___1(struct __anonymous15 *___dst__P14s__anonymous15_1, struct __anonymous15 ___src__14s__anonymous15_1){398 ((void)((*((short *)(&(*___dst__P14s__anonymous15_1).__i__s_1)))=___src__14s__anonymous15_1.__i__s_1) /* ?{} */);399 }400 static inline void ___destructor__F_P14s__anonymous15_autogen___1(struct __anonymous15 *___dst__P14s__anonymous15_1){401 ((void)((*((short *)(&(*___dst__P14s__anonymous15_1).__i__s_1)))) /* ^?{} */);402 402 } 403 403 static inline void ___constructor__F_P14s__anonymous15s_autogen___1(struct __anonymous15 *___dst__P14s__anonymous15_1, short __i__s_1){ … … 428 428 static inline void ___constructor__F_P14s__anonymous1614s__anonymous16_autogen___1(struct __anonymous16 *___dst__P14s__anonymous16_1, struct __anonymous16 ___src__14s__anonymous16_1); 429 429 static inline void ___destructor__F_P14s__anonymous16_autogen___1(struct __anonymous16 *___dst__P14s__anonymous16_1); 430 static inline void ___constructor__F_P14s__anonymous16_autogen___1(struct __anonymous16 *___dst__P14s__anonymous16_1){ 431 ((void)((*((int *)(&(*___dst__P14s__anonymous16_1).__i__i_1)))) /* ?{} */); 432 } 433 static inline void ___constructor__F_P14s__anonymous1614s__anonymous16_autogen___1(struct __anonymous16 *___dst__P14s__anonymous16_1, struct __anonymous16 ___src__14s__anonymous16_1){ 434 ((void)((*((int *)(&(*___dst__P14s__anonymous16_1).__i__i_1)))=___src__14s__anonymous16_1.__i__i_1) /* ?{} */); 435 } 436 static inline void ___destructor__F_P14s__anonymous16_autogen___1(struct __anonymous16 *___dst__P14s__anonymous16_1){ 437 ((void)((*((int *)(&(*___dst__P14s__anonymous16_1).__i__i_1)))) /* ^?{} */); 438 } 430 439 static inline struct __anonymous16 ___operator_assign__F14s__anonymous16_P14s__anonymous1614s__anonymous16_autogen___1(struct __anonymous16 *___dst__P14s__anonymous16_1, struct __anonymous16 ___src__14s__anonymous16_1){ 431 440 ((void)((*___dst__P14s__anonymous16_1).__i__i_1=___src__14s__anonymous16_1.__i__i_1)); 432 441 return ((struct __anonymous16 )___src__14s__anonymous16_1); 433 }434 static inline void ___constructor__F_P14s__anonymous16_autogen___1(struct __anonymous16 *___dst__P14s__anonymous16_1){435 ((void)((*((int *)(&(*___dst__P14s__anonymous16_1).__i__i_1)))) /* ?{} */);436 }437 static inline void ___constructor__F_P14s__anonymous1614s__anonymous16_autogen___1(struct __anonymous16 *___dst__P14s__anonymous16_1, struct __anonymous16 ___src__14s__anonymous16_1){438 ((void)((*((int *)(&(*___dst__P14s__anonymous16_1).__i__i_1)))=___src__14s__anonymous16_1.__i__i_1) /* ?{} */);439 }440 static inline void ___destructor__F_P14s__anonymous16_autogen___1(struct __anonymous16 *___dst__P14s__anonymous16_1){441 ((void)((*((int *)(&(*___dst__P14s__anonymous16_1).__i__i_1)))) /* ^?{} */);442 442 } 443 443 static inline void ___constructor__F_P14s__anonymous16i_autogen___1(struct __anonymous16 *___dst__P14s__anonymous16_1, int __i__i_1){ … … 452 452 static inline void ___constructor__F_P14s__anonymous1714s__anonymous17_autogen___1(struct __anonymous17 *___dst__P14s__anonymous17_1, struct __anonymous17 ___src__14s__anonymous17_1); 453 453 static inline void ___destructor__F_P14s__anonymous17_autogen___1(struct __anonymous17 *___dst__P14s__anonymous17_1); 454 static inline void ___constructor__F_P14s__anonymous17_autogen___1(struct __anonymous17 *___dst__P14s__anonymous17_1){ 455 ((void)((*((int *)(&(*___dst__P14s__anonymous17_1).__i__i_1)))) /* ?{} */); 456 } 457 static inline void ___constructor__F_P14s__anonymous1714s__anonymous17_autogen___1(struct __anonymous17 *___dst__P14s__anonymous17_1, struct __anonymous17 ___src__14s__anonymous17_1){ 458 ((void)((*((int *)(&(*___dst__P14s__anonymous17_1).__i__i_1)))=___src__14s__anonymous17_1.__i__i_1) /* ?{} */); 459 } 460 static inline void ___destructor__F_P14s__anonymous17_autogen___1(struct __anonymous17 *___dst__P14s__anonymous17_1){ 461 ((void)((*((int *)(&(*___dst__P14s__anonymous17_1).__i__i_1)))) /* ^?{} */); 462 } 454 463 static inline struct __anonymous17 ___operator_assign__F14s__anonymous17_P14s__anonymous1714s__anonymous17_autogen___1(struct __anonymous17 *___dst__P14s__anonymous17_1, struct __anonymous17 ___src__14s__anonymous17_1){ 455 464 ((void)((*___dst__P14s__anonymous17_1).__i__i_1=___src__14s__anonymous17_1.__i__i_1)); 456 465 return ((struct __anonymous17 )___src__14s__anonymous17_1); 457 }458 static inline void ___constructor__F_P14s__anonymous17_autogen___1(struct __anonymous17 *___dst__P14s__anonymous17_1){459 ((void)((*((int *)(&(*___dst__P14s__anonymous17_1).__i__i_1)))) /* ?{} */);460 }461 static inline void ___constructor__F_P14s__anonymous1714s__anonymous17_autogen___1(struct __anonymous17 *___dst__P14s__anonymous17_1, struct __anonymous17 ___src__14s__anonymous17_1){462 ((void)((*((int *)(&(*___dst__P14s__anonymous17_1).__i__i_1)))=___src__14s__anonymous17_1.__i__i_1) /* ?{} */);463 }464 static inline void ___destructor__F_P14s__anonymous17_autogen___1(struct __anonymous17 *___dst__P14s__anonymous17_1){465 ((void)((*((int *)(&(*___dst__P14s__anonymous17_1).__i__i_1)))) /* ^?{} */);466 466 } 467 467 static inline void ___constructor__F_P14s__anonymous17i_autogen___1(struct __anonymous17 *___dst__P14s__anonymous17_1, int __i__i_1){ … … 476 476 static inline void ___constructor__F_P14s__anonymous1814s__anonymous18_autogen___1(struct __anonymous18 *___dst__P14s__anonymous18_1, struct __anonymous18 ___src__14s__anonymous18_1); 477 477 static inline void ___destructor__F_P14s__anonymous18_autogen___1(struct __anonymous18 *___dst__P14s__anonymous18_1); 478 static inline void ___constructor__F_P14s__anonymous18_autogen___1(struct __anonymous18 *___dst__P14s__anonymous18_1){ 479 ((void)((*((int *)(&(*___dst__P14s__anonymous18_1).__i__i_1)))) /* ?{} */); 480 } 481 static inline void ___constructor__F_P14s__anonymous1814s__anonymous18_autogen___1(struct __anonymous18 *___dst__P14s__anonymous18_1, struct __anonymous18 ___src__14s__anonymous18_1){ 482 ((void)((*((int *)(&(*___dst__P14s__anonymous18_1).__i__i_1)))=___src__14s__anonymous18_1.__i__i_1) /* ?{} */); 483 } 484 static inline void ___destructor__F_P14s__anonymous18_autogen___1(struct __anonymous18 *___dst__P14s__anonymous18_1){ 485 ((void)((*((int *)(&(*___dst__P14s__anonymous18_1).__i__i_1)))) /* ^?{} */); 486 } 478 487 static inline struct __anonymous18 ___operator_assign__F14s__anonymous18_P14s__anonymous1814s__anonymous18_autogen___1(struct __anonymous18 *___dst__P14s__anonymous18_1, struct __anonymous18 ___src__14s__anonymous18_1){ 479 488 ((void)((*___dst__P14s__anonymous18_1).__i__i_1=___src__14s__anonymous18_1.__i__i_1)); 480 489 return ((struct __anonymous18 )___src__14s__anonymous18_1); 481 }482 static inline void ___constructor__F_P14s__anonymous18_autogen___1(struct __anonymous18 *___dst__P14s__anonymous18_1){483 ((void)((*((int *)(&(*___dst__P14s__anonymous18_1).__i__i_1)))) /* ?{} */);484 }485 static inline void ___constructor__F_P14s__anonymous1814s__anonymous18_autogen___1(struct __anonymous18 *___dst__P14s__anonymous18_1, struct __anonymous18 ___src__14s__anonymous18_1){486 ((void)((*((int *)(&(*___dst__P14s__anonymous18_1).__i__i_1)))=___src__14s__anonymous18_1.__i__i_1) /* ?{} */);487 }488 static inline void ___destructor__F_P14s__anonymous18_autogen___1(struct __anonymous18 *___dst__P14s__anonymous18_1){489 ((void)((*((int *)(&(*___dst__P14s__anonymous18_1).__i__i_1)))) /* ^?{} */);490 490 } 491 491 static inline void ___constructor__F_P14s__anonymous18i_autogen___1(struct __anonymous18 *___dst__P14s__anonymous18_1, int __i__i_1){ … … 500 500 static inline void ___constructor__F_P14s__anonymous1914s__anonymous19_autogen___1(struct __anonymous19 *___dst__P14s__anonymous19_1, struct __anonymous19 ___src__14s__anonymous19_1); 501 501 static inline void ___destructor__F_P14s__anonymous19_autogen___1(struct __anonymous19 *___dst__P14s__anonymous19_1); 502 static inline void ___constructor__F_P14s__anonymous19_autogen___1(struct __anonymous19 *___dst__P14s__anonymous19_1){ 503 ((void)((*((int *)(&(*___dst__P14s__anonymous19_1).__i__i_1)))) /* ?{} */); 504 } 505 static inline void ___constructor__F_P14s__anonymous1914s__anonymous19_autogen___1(struct __anonymous19 *___dst__P14s__anonymous19_1, struct __anonymous19 ___src__14s__anonymous19_1){ 506 ((void)((*((int *)(&(*___dst__P14s__anonymous19_1).__i__i_1)))=___src__14s__anonymous19_1.__i__i_1) /* ?{} */); 507 } 508 static inline void ___destructor__F_P14s__anonymous19_autogen___1(struct __anonymous19 *___dst__P14s__anonymous19_1){ 509 ((void)((*((int *)(&(*___dst__P14s__anonymous19_1).__i__i_1)))) /* ^?{} */); 510 } 502 511 static inline struct __anonymous19 ___operator_assign__F14s__anonymous19_P14s__anonymous1914s__anonymous19_autogen___1(struct __anonymous19 *___dst__P14s__anonymous19_1, struct __anonymous19 ___src__14s__anonymous19_1){ 503 512 ((void)((*___dst__P14s__anonymous19_1).__i__i_1=___src__14s__anonymous19_1.__i__i_1)); 504 513 return ((struct __anonymous19 )___src__14s__anonymous19_1); 505 }506 static inline void ___constructor__F_P14s__anonymous19_autogen___1(struct __anonymous19 *___dst__P14s__anonymous19_1){507 ((void)((*((int *)(&(*___dst__P14s__anonymous19_1).__i__i_1)))) /* ?{} */);508 }509 static inline void ___constructor__F_P14s__anonymous1914s__anonymous19_autogen___1(struct __anonymous19 *___dst__P14s__anonymous19_1, struct __anonymous19 ___src__14s__anonymous19_1){510 ((void)((*((int *)(&(*___dst__P14s__anonymous19_1).__i__i_1)))=___src__14s__anonymous19_1.__i__i_1) /* ?{} */);511 }512 static inline void ___destructor__F_P14s__anonymous19_autogen___1(struct __anonymous19 *___dst__P14s__anonymous19_1){513 ((void)((*((int *)(&(*___dst__P14s__anonymous19_1).__i__i_1)))) /* ^?{} */);514 514 } 515 515 static inline void ___constructor__F_P14s__anonymous19i_autogen___1(struct __anonymous19 *___dst__P14s__anonymous19_1, int __i__i_1){ … … 524 524 static inline void ___constructor__F_P14s__anonymous2014s__anonymous20_autogen___1(struct __anonymous20 *___dst__P14s__anonymous20_1, struct __anonymous20 ___src__14s__anonymous20_1); 525 525 static inline void ___destructor__F_P14s__anonymous20_autogen___1(struct __anonymous20 *___dst__P14s__anonymous20_1); 526 static inline void ___constructor__F_P14s__anonymous20_autogen___1(struct __anonymous20 *___dst__P14s__anonymous20_1){ 527 ((void)((*((int *)(&(*___dst__P14s__anonymous20_1).__i__i_1)))) /* ?{} */); 528 } 529 static inline void ___constructor__F_P14s__anonymous2014s__anonymous20_autogen___1(struct __anonymous20 *___dst__P14s__anonymous20_1, struct __anonymous20 ___src__14s__anonymous20_1){ 530 ((void)((*((int *)(&(*___dst__P14s__anonymous20_1).__i__i_1)))=___src__14s__anonymous20_1.__i__i_1) /* ?{} */); 531 } 532 static inline void ___destructor__F_P14s__anonymous20_autogen___1(struct __anonymous20 *___dst__P14s__anonymous20_1){ 533 ((void)((*((int *)(&(*___dst__P14s__anonymous20_1).__i__i_1)))) /* ^?{} */); 534 } 526 535 static inline struct __anonymous20 ___operator_assign__F14s__anonymous20_P14s__anonymous2014s__anonymous20_autogen___1(struct __anonymous20 *___dst__P14s__anonymous20_1, struct __anonymous20 ___src__14s__anonymous20_1){ 527 536 ((void)((*___dst__P14s__anonymous20_1).__i__i_1=___src__14s__anonymous20_1.__i__i_1)); 528 537 return ((struct __anonymous20 )___src__14s__anonymous20_1); 529 }530 static inline void ___constructor__F_P14s__anonymous20_autogen___1(struct __anonymous20 *___dst__P14s__anonymous20_1){531 ((void)((*((int *)(&(*___dst__P14s__anonymous20_1).__i__i_1)))) /* ?{} */);532 }533 static inline void ___constructor__F_P14s__anonymous2014s__anonymous20_autogen___1(struct __anonymous20 *___dst__P14s__anonymous20_1, struct __anonymous20 ___src__14s__anonymous20_1){534 ((void)((*((int *)(&(*___dst__P14s__anonymous20_1).__i__i_1)))=___src__14s__anonymous20_1.__i__i_1) /* ?{} */);535 }536 static inline void ___destructor__F_P14s__anonymous20_autogen___1(struct __anonymous20 *___dst__P14s__anonymous20_1){537 ((void)((*((int *)(&(*___dst__P14s__anonymous20_1).__i__i_1)))) /* ^?{} */);538 538 } 539 539 static inline void ___constructor__F_P14s__anonymous20i_autogen___1(struct __anonymous20 *___dst__P14s__anonymous20_1, int __i__i_1){ … … 548 548 static inline void ___constructor__F_P14s__anonymous2114s__anonymous21_autogen___1(struct __anonymous21 *___dst__P14s__anonymous21_1, struct __anonymous21 ___src__14s__anonymous21_1); 549 549 static inline void ___destructor__F_P14s__anonymous21_autogen___1(struct __anonymous21 *___dst__P14s__anonymous21_1); 550 static inline void ___constructor__F_P14s__anonymous21_autogen___1(struct __anonymous21 *___dst__P14s__anonymous21_1){ 551 ((void)((*((int *)(&(*___dst__P14s__anonymous21_1).__i__i_1)))) /* ?{} */); 552 } 553 static inline void ___constructor__F_P14s__anonymous2114s__anonymous21_autogen___1(struct __anonymous21 *___dst__P14s__anonymous21_1, struct __anonymous21 ___src__14s__anonymous21_1){ 554 ((void)((*((int *)(&(*___dst__P14s__anonymous21_1).__i__i_1)))=___src__14s__anonymous21_1.__i__i_1) /* ?{} */); 555 } 556 static inline void ___destructor__F_P14s__anonymous21_autogen___1(struct __anonymous21 *___dst__P14s__anonymous21_1){ 557 ((void)((*((int *)(&(*___dst__P14s__anonymous21_1).__i__i_1)))) /* ^?{} */); 558 } 550 559 static inline struct __anonymous21 ___operator_assign__F14s__anonymous21_P14s__anonymous2114s__anonymous21_autogen___1(struct __anonymous21 *___dst__P14s__anonymous21_1, struct __anonymous21 ___src__14s__anonymous21_1){ 551 560 ((void)((*___dst__P14s__anonymous21_1).__i__i_1=___src__14s__anonymous21_1.__i__i_1)); 552 561 return ((struct __anonymous21 )___src__14s__anonymous21_1); 553 }554 static inline void ___constructor__F_P14s__anonymous21_autogen___1(struct __anonymous21 *___dst__P14s__anonymous21_1){555 ((void)((*((int *)(&(*___dst__P14s__anonymous21_1).__i__i_1)))) /* ?{} */);556 }557 static inline void ___constructor__F_P14s__anonymous2114s__anonymous21_autogen___1(struct __anonymous21 *___dst__P14s__anonymous21_1, struct __anonymous21 ___src__14s__anonymous21_1){558 ((void)((*((int *)(&(*___dst__P14s__anonymous21_1).__i__i_1)))=___src__14s__anonymous21_1.__i__i_1) /* ?{} */);559 }560 static inline void ___destructor__F_P14s__anonymous21_autogen___1(struct __anonymous21 *___dst__P14s__anonymous21_1){561 ((void)((*((int *)(&(*___dst__P14s__anonymous21_1).__i__i_1)))) /* ^?{} */);562 562 } 563 563 static inline void ___constructor__F_P14s__anonymous21i_autogen___1(struct __anonymous21 *___dst__P14s__anonymous21_1, int __i__i_1){ … … 572 572 static inline void ___constructor__F_P14s__anonymous2214s__anonymous22_autogen___1(struct __anonymous22 *___dst__P14s__anonymous22_1, struct __anonymous22 ___src__14s__anonymous22_1); 573 573 static inline void ___destructor__F_P14s__anonymous22_autogen___1(struct __anonymous22 *___dst__P14s__anonymous22_1); 574 static inline void ___constructor__F_P14s__anonymous22_autogen___1(struct __anonymous22 *___dst__P14s__anonymous22_1){ 575 ((void)((*((int *)(&(*___dst__P14s__anonymous22_1).__i__i_1)))) /* ?{} */); 576 } 577 static inline void ___constructor__F_P14s__anonymous2214s__anonymous22_autogen___1(struct __anonymous22 *___dst__P14s__anonymous22_1, struct __anonymous22 ___src__14s__anonymous22_1){ 578 ((void)((*((int *)(&(*___dst__P14s__anonymous22_1).__i__i_1)))=___src__14s__anonymous22_1.__i__i_1) /* ?{} */); 579 } 580 static inline void ___destructor__F_P14s__anonymous22_autogen___1(struct __anonymous22 *___dst__P14s__anonymous22_1){ 581 ((void)((*((int *)(&(*___dst__P14s__anonymous22_1).__i__i_1)))) /* ^?{} */); 582 } 574 583 static inline struct __anonymous22 ___operator_assign__F14s__anonymous22_P14s__anonymous2214s__anonymous22_autogen___1(struct __anonymous22 *___dst__P14s__anonymous22_1, struct __anonymous22 ___src__14s__anonymous22_1){ 575 584 ((void)((*___dst__P14s__anonymous22_1).__i__i_1=___src__14s__anonymous22_1.__i__i_1)); 576 585 return ((struct __anonymous22 )___src__14s__anonymous22_1); 577 }578 static inline void ___constructor__F_P14s__anonymous22_autogen___1(struct __anonymous22 *___dst__P14s__anonymous22_1){579 ((void)((*((int *)(&(*___dst__P14s__anonymous22_1).__i__i_1)))) /* ?{} */);580 }581 static inline void ___constructor__F_P14s__anonymous2214s__anonymous22_autogen___1(struct __anonymous22 *___dst__P14s__anonymous22_1, struct __anonymous22 ___src__14s__anonymous22_1){582 ((void)((*((int *)(&(*___dst__P14s__anonymous22_1).__i__i_1)))=___src__14s__anonymous22_1.__i__i_1) /* ?{} */);583 }584 static inline void ___destructor__F_P14s__anonymous22_autogen___1(struct __anonymous22 *___dst__P14s__anonymous22_1){585 ((void)((*((int *)(&(*___dst__P14s__anonymous22_1).__i__i_1)))) /* ^?{} */);586 586 } 587 587 static inline void ___constructor__F_P14s__anonymous22i_autogen___1(struct __anonymous22 *___dst__P14s__anonymous22_1, int __i__i_1){ … … 596 596 static inline void ___constructor__F_P14s__anonymous2314s__anonymous23_autogen___1(struct __anonymous23 *___dst__P14s__anonymous23_1, struct __anonymous23 ___src__14s__anonymous23_1); 597 597 static inline void ___destructor__F_P14s__anonymous23_autogen___1(struct __anonymous23 *___dst__P14s__anonymous23_1); 598 static inline void ___constructor__F_P14s__anonymous23_autogen___1(struct __anonymous23 *___dst__P14s__anonymous23_1){ 599 ((void)((*((int *)(&(*___dst__P14s__anonymous23_1).__i__i_1)))) /* ?{} */); 600 } 601 static inline void ___constructor__F_P14s__anonymous2314s__anonymous23_autogen___1(struct __anonymous23 *___dst__P14s__anonymous23_1, struct __anonymous23 ___src__14s__anonymous23_1){ 602 ((void)((*((int *)(&(*___dst__P14s__anonymous23_1).__i__i_1)))=___src__14s__anonymous23_1.__i__i_1) /* ?{} */); 603 } 604 static inline void ___destructor__F_P14s__anonymous23_autogen___1(struct __anonymous23 *___dst__P14s__anonymous23_1){ 605 ((void)((*((int *)(&(*___dst__P14s__anonymous23_1).__i__i_1)))) /* ^?{} */); 606 } 598 607 static inline struct __anonymous23 ___operator_assign__F14s__anonymous23_P14s__anonymous2314s__anonymous23_autogen___1(struct __anonymous23 *___dst__P14s__anonymous23_1, struct __anonymous23 ___src__14s__anonymous23_1){ 599 608 ((void)((*___dst__P14s__anonymous23_1).__i__i_1=___src__14s__anonymous23_1.__i__i_1)); 600 609 return ((struct __anonymous23 )___src__14s__anonymous23_1); 601 }602 static inline void ___constructor__F_P14s__anonymous23_autogen___1(struct __anonymous23 *___dst__P14s__anonymous23_1){603 ((void)((*((int *)(&(*___dst__P14s__anonymous23_1).__i__i_1)))) /* ?{} */);604 }605 static inline void ___constructor__F_P14s__anonymous2314s__anonymous23_autogen___1(struct __anonymous23 *___dst__P14s__anonymous23_1, struct __anonymous23 ___src__14s__anonymous23_1){606 ((void)((*((int *)(&(*___dst__P14s__anonymous23_1).__i__i_1)))=___src__14s__anonymous23_1.__i__i_1) /* ?{} */);607 }608 static inline void ___destructor__F_P14s__anonymous23_autogen___1(struct __anonymous23 *___dst__P14s__anonymous23_1){609 ((void)((*((int *)(&(*___dst__P14s__anonymous23_1).__i__i_1)))) /* ^?{} */);610 610 } 611 611 static inline void ___constructor__F_P14s__anonymous23i_autogen___1(struct __anonymous23 *___dst__P14s__anonymous23_1, int __i__i_1){ … … 622 622 static inline volatile const short __f48__FCVs___1(); 623 623 int main(int __argc__i_1, const char **__argv__PPCc_1){ 624 int _ retVal0 = { 0 };625 ((void)(_ retVal0=((int )0)) /* ?{} */);626 return ((int )_ retVal0);627 } 624 int ___retval_main__i_1; 625 ((void)(___retval_main__i_1=((int )0)) /* ?{} */); 626 return ((int )___retval_main__i_1); 627 } -
src/tests/.expect/64/extension.txt
r596f987b r66f8528 17 17 static inline void ___constructor__F_P2sS2sS_autogen___1(struct S *___dst__P2sS_1, struct S ___src__2sS_1); 18 18 static inline void ___destructor__F_P2sS_autogen___1(struct S *___dst__P2sS_1); 19 static inline struct S ___operator_assign__F2sS_P2sS2sS_autogen___1(struct S *___dst__P2sS_1, struct S ___src__2sS_1){20 ((void)((*___dst__P2sS_1).__a__i_1=___src__2sS_1.__a__i_1));21 ((void)((*___dst__P2sS_1).__b__i_1=___src__2sS_1.__b__i_1));22 ((void)((*___dst__P2sS_1).__c__i_1=___src__2sS_1.__c__i_1));23 return ((struct S )___src__2sS_1);24 }25 19 static inline void ___constructor__F_P2sS_autogen___1(struct S *___dst__P2sS_1){ 26 20 ((void)((*((int *)(&(*___dst__P2sS_1).__a__i_1)))) /* ?{} */); … … 37 31 ((void)((*((int *)(&(*___dst__P2sS_1).__b__i_1)))) /* ^?{} */); 38 32 ((void)((*((int *)(&(*___dst__P2sS_1).__a__i_1)))) /* ^?{} */); 33 } 34 static inline struct S ___operator_assign__F2sS_P2sS2sS_autogen___1(struct S *___dst__P2sS_1, struct S ___src__2sS_1){ 35 ((void)((*___dst__P2sS_1).__a__i_1=___src__2sS_1.__a__i_1)); 36 ((void)((*___dst__P2sS_1).__b__i_1=___src__2sS_1.__b__i_1)); 37 ((void)((*___dst__P2sS_1).__c__i_1=___src__2sS_1.__c__i_1)); 38 return ((struct S )___src__2sS_1); 39 39 } 40 40 static inline void ___constructor__F_P2sSi_autogen___1(struct S *___dst__P2sS_1, int __a__i_1){ … … 58 58 __extension__ int __c__i_1; 59 59 }; 60 static inline union U ___operator_assign__F2uU_P2uU2uU_autogen___1(union U *___dst__P2uU_1, union U ___src__2uU_1){61 ((void)__builtin_memcpy(((void *)___dst__P2uU_1), ((const void *)(&___src__2uU_1)), sizeof(union U )));62 return ((union U )___src__2uU_1);63 }64 60 static inline void ___constructor__F_P2uU_autogen___1(union U *___dst__P2uU_1){ 65 61 } 66 62 static inline void ___constructor__F_P2uU2uU_autogen___1(union U *___dst__P2uU_1, union U ___src__2uU_1){ 67 63 ((void)__builtin_memcpy(((void *)___dst__P2uU_1), ((const void *)(&___src__2uU_1)), sizeof(union U ))); 68 return ((void)___src__2uU_1);69 64 } 70 65 static inline void ___destructor__F_P2uU_autogen___1(union U *___dst__P2uU_1){ 66 } 67 static inline union U ___operator_assign__F2uU_P2uU2uU_autogen___1(union U *___dst__P2uU_1, union U ___src__2uU_1){ 68 ((void)__builtin_memcpy(((void *)___dst__P2uU_1), ((const void *)(&___src__2uU_1)), sizeof(union U ))); 69 return ((union U )___src__2uU_1); 71 70 } 72 71 static inline void ___constructor__F_P2uUi_autogen___1(union U *___dst__P2uU_1, int __src__i_1){ … … 79 78 }; 80 79 __extension__ int __fred__Fi_i__1(int __p__i_1){ 80 int ___retval_fred__i_1; 81 81 __extension__ struct S { 82 82 __extension__ int __a__i_2; -
src/tests/.expect/64/gccExtensions.txt
r596f987b r66f8528 7 7 extern int __x__i_1 asm ( "xx" ); 8 8 int main(int __argc__i_1, const char **__argv__PPCc_1){ 9 int ___retval_main__i_1; 9 10 asm ( "nop" : : : ); 10 11 asm ( "nop" : : : ); … … 25 26 const int __i3__Ci_2; 26 27 inline int __f1__Fi___2(){ 28 int ___retval_f1__i_2; 27 29 } 28 30 inline int __f2__Fi___2(){ 31 int ___retval_f2__i_2; 29 32 } 30 33 int __s1__i_2; … … 40 43 __extension__ int __c__i_2; 41 44 }; 42 inline struct S ___operator_assign__F2sS_P2sS2sS_autogen___2(struct S *___dst__P2sS_2, struct S ___src__2sS_2){43 ((void)((*___dst__P2sS_2).__a__i_2=___src__2sS_2.__a__i_2));44 ((void)((*___dst__P2sS_2).__b__i_2=___src__2sS_2.__b__i_2));45 ((void)((*___dst__P2sS_2).__c__i_2=___src__2sS_2.__c__i_2));46 return ((struct S )___src__2sS_2);47 }48 45 inline void ___constructor__F_P2sS_autogen___2(struct S *___dst__P2sS_2){ 49 46 ((void)((*((int *)(&(*___dst__P2sS_2).__a__i_2)))) /* ?{} */); … … 60 57 ((void)((*((int *)(&(*___dst__P2sS_2).__b__i_2)))) /* ^?{} */); 61 58 ((void)((*((int *)(&(*___dst__P2sS_2).__a__i_2)))) /* ^?{} */); 59 } 60 inline struct S ___operator_assign__F2sS_P2sS2sS_autogen___2(struct S *___dst__P2sS_2, struct S ___src__2sS_2){ 61 ((void)((*___dst__P2sS_2).__a__i_2=___src__2sS_2.__a__i_2)); 62 ((void)((*___dst__P2sS_2).__b__i_2=___src__2sS_2.__b__i_2)); 63 ((void)((*___dst__P2sS_2).__c__i_2=___src__2sS_2.__c__i_2)); 64 return ((struct S )___src__2sS_2); 62 65 } 63 66 inline void ___constructor__F_P2sSi_autogen___2(struct S *___dst__P2sS_2, int __a__i_2){ … … 96 99 int __i__i_2; 97 100 }; 98 inline struct s2 ___operator_assign__F3ss2_P3ss23ss2_autogen___2(struct s2 *___dst__P3ss2_2, struct s2 ___src__3ss2_2){99 ((void)((*___dst__P3ss2_2).__i__i_2=___src__3ss2_2.__i__i_2));100 return ((struct s2 )___src__3ss2_2);101 }102 101 inline void ___constructor__F_P3ss2_autogen___2(struct s2 *___dst__P3ss2_2){ 103 102 ((void)((*((int *)(&(*___dst__P3ss2_2).__i__i_2)))) /* ?{} */); … … 109 108 ((void)((*((int *)(&(*___dst__P3ss2_2).__i__i_2)))) /* ^?{} */); 110 109 } 110 inline struct s2 ___operator_assign__F3ss2_P3ss23ss2_autogen___2(struct s2 *___dst__P3ss2_2, struct s2 ___src__3ss2_2){ 111 ((void)((*___dst__P3ss2_2).__i__i_2=___src__3ss2_2.__i__i_2)); 112 return ((struct s2 )___src__3ss2_2); 113 } 111 114 inline void ___constructor__F_P3ss2i_autogen___2(struct s2 *___dst__P3ss2_2, int __i__i_2){ 112 115 ((void)((*((int *)(&(*___dst__P3ss2_2).__i__i_2)))=__i__i_2) /* ?{} */); … … 115 118 int __i__i_2; 116 119 }; 117 inline struct s3 ___operator_assign__F3ss3_P3ss33ss3_autogen___2(struct s3 *___dst__P3ss3_2, struct s3 ___src__3ss3_2){118 ((void)((*___dst__P3ss3_2).__i__i_2=___src__3ss3_2.__i__i_2));119 return ((struct s3 )___src__3ss3_2);120 }121 120 inline void ___constructor__F_P3ss3_autogen___2(struct s3 *___dst__P3ss3_2){ 122 121 ((void)((*((int *)(&(*___dst__P3ss3_2).__i__i_2)))) /* ?{} */); … … 128 127 ((void)((*((int *)(&(*___dst__P3ss3_2).__i__i_2)))) /* ^?{} */); 129 128 } 129 inline struct s3 ___operator_assign__F3ss3_P3ss33ss3_autogen___2(struct s3 *___dst__P3ss3_2, struct s3 ___src__3ss3_2){ 130 ((void)((*___dst__P3ss3_2).__i__i_2=___src__3ss3_2.__i__i_2)); 131 return ((struct s3 )___src__3ss3_2); 132 } 130 133 inline void ___constructor__F_P3ss3i_autogen___2(struct s3 *___dst__P3ss3_2, int __i__i_2){ 131 134 ((void)((*((int *)(&(*___dst__P3ss3_2).__i__i_2)))=__i__i_2) /* ?{} */); … … 136 139 int __i__i_2; 137 140 }; 138 inline struct s4 ___operator_assign__F3ss4_P3ss43ss4_autogen___2(struct s4 *___dst__P3ss4_2, struct s4 ___src__3ss4_2){139 ((void)((*___dst__P3ss4_2).__i__i_2=___src__3ss4_2.__i__i_2));140 return ((struct s4 )___src__3ss4_2);141 }142 141 inline void ___constructor__F_P3ss4_autogen___2(struct s4 *___dst__P3ss4_2){ 143 142 ((void)((*((int *)(&(*___dst__P3ss4_2).__i__i_2)))) /* ?{} */); … … 149 148 ((void)((*((int *)(&(*___dst__P3ss4_2).__i__i_2)))) /* ^?{} */); 150 149 } 150 inline struct s4 ___operator_assign__F3ss4_P3ss43ss4_autogen___2(struct s4 *___dst__P3ss4_2, struct s4 ___src__3ss4_2){ 151 ((void)((*___dst__P3ss4_2).__i__i_2=___src__3ss4_2.__i__i_2)); 152 return ((struct s4 )___src__3ss4_2); 153 } 151 154 inline void ___constructor__F_P3ss4i_autogen___2(struct s4 *___dst__P3ss4_2, int __i__i_2){ 152 155 ((void)((*((int *)(&(*___dst__P3ss4_2).__i__i_2)))=__i__i_2) /* ?{} */); … … 157 160 int __m2__A0A0i_2[((long unsigned int )10)][((long unsigned int )10)]; 158 161 int __m3__A0A0i_2[((long unsigned int )10)][((long unsigned int )10)]; 159 int _retVal0 = { 0 }; 160 ((void)(_retVal0=((int )0)) /* ?{} */); 161 return ((int )_retVal0); 162 ((void)(___retval_main__i_1=((int )0)) /* ?{} */); 163 return ((int )___retval_main__i_1); 162 164 } -
src/tests/.expect/castError.txt
r596f987b r66f8528 1 Error: Can't choose between alternatives for expression Cast of:1 Error: Can't choose between 3 alternatives for expression Cast of: 2 2 Name: f 3 3 -
src/tests/.expect/memberCtors.txt
r596f987b r66f8528 6 6 constructing int 7 7 constructing int 8 begin construct B 9 assign b->a2 8 10 constructing int 9 11 constructing int 12 begin construct A 13 construct a->x 10 14 constructing int: 1001 15 assign a->y 11 16 assigning int: 0 0 17 end construct A 18 construct b->a1 12 19 constructing int 13 20 constructing int 21 begin construct A 22 construct a->x 14 23 constructing int: 1000 24 assign a->y 15 25 assigning int: 0 0 26 end construct A 27 end construct B 16 28 destructing int: 0 17 29 destructing int: 0 … … 20 32 copy constructing int: 0 21 33 copy constructing int: 0 34 begin copy construct A 35 copy construct this->x 22 36 copy constructing int: 1000 37 assign this->y 38 end copy construct A 23 39 copy constructing int: 0 24 40 copy constructing int: 0 41 begin copy construct A 42 copy construct this->x 25 43 copy constructing int: 1001 44 assign this->y 45 end copy construct A 26 46 copy constructing int: 0 27 47 copy constructing int: 0 48 begin copy construct A 49 copy construct this->x 28 50 copy constructing int: 0 51 assign this->y 52 end copy construct A 29 53 End of main 30 54 constructing int 31 55 constructing int 56 begin construct A 57 construct a->x 32 58 constructing int: 999 59 assign a->y 33 60 assigning int: 0 0 61 end construct A 34 62 destructing int: 0 35 63 destructing int: 0 … … 46 74 constructing int 47 75 constructing int 76 begin construct A 77 construct a->x 48 78 constructing int: 999 79 assign a->y 49 80 assigning int: 0 0 81 end construct A 50 82 destructing int: 0 51 83 destructing int: 0 -
src/tests/.expect/scopeErrors.txt
r596f987b r66f8528 4 4 double 5 5 returning 6 double6 _retval_butThisIsAnError: double 7 7 with body 8 8 CompoundStmt -
src/tests/Makefile.am
r596f987b r66f8528 67 67 memberCtors-ERR1: memberCtors.c 68 68 ${CC} ${CFLAGS} -DERR1 ${<} -o ${@} 69 70 completeTypeError : completeTypeError.c 71 ${CC} ${CFLAGS} -DERR1 ${<} -o ${@} -
src/tests/Makefile.in
r596f987b r66f8528 689 689 ${CC} ${CFLAGS} -DERR1 ${<} -o ${@} 690 690 691 completeTypeError : completeTypeError.c 692 ${CC} ${CFLAGS} -DERR1 ${<} -o ${@} 693 691 694 # Tell versions [3.59,3.63) of GNU make to not export all variables. 692 695 # Otherwise a system limit (for SysV at least) may be exceeded. -
src/tests/memberCtors.c
r596f987b r66f8528 32 32 33 33 void ?{}(A * a, int x) { 34 printf("begin construct A\n"); 35 printf("construct a->x\n"); 34 36 (&a->x){ x+999 }; 37 printf("assign a->y\n"); 35 38 a->y = 0; // not a constructor - default constructor will be inserted 39 printf("end construct A\n"); 36 40 } // z never constructed - will be automatically default constructed 37 41 38 42 void ?{}(A * this, A other) { 43 printf("begin copy construct A\n"); 44 printf("copy construct this->x\n"); 39 45 (&this->x){ other.x }; 46 printf("assign this->y\n"); 40 47 this->y = other.y; // not a constructor - copy constructor will be inserted 48 printf("end copy construct A\n"); 41 49 } // z never constructed - will be automatically copy constructed 42 50 … … 46 54 47 55 void ?{}(B * b) { 56 printf("begin construct B\n"); 57 printf("assign b->a2\n"); 48 58 b->a2 = (A) { 2 }; 59 printf("construct b->a1\n"); 49 60 (&b->a1){ 1 }; 50 61 #ifdef ERR1 51 62 (&b->a2){ b->a3 }; // error, b->a2 was used previously but is explicitly constructed 52 63 #endif 64 printf("end construct B\n"); 53 65 } // a2, a3 never constructed - will be automatically default constructed 54 66 -
src/tests/shortCircuit.c
r596f987b r66f8528 11 11 12 12 void g() { 13 14 15 13 int a; 14 struct { int b; } a; 15 if ( a ) { 16 16 while ( a ) { 17 17 int *b; … … 19 19 } 20 20 } 21 21 } 22 22 } 23 23 -
src/tests/tupleAssign.c
r596f987b r66f8528 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 // tupleAssign.c -- 8 // 9 // Author : Rob Schluntz 10 // Created On : Tue Nov 15 17:24:32 2016 11 // Last Modified By : Rob Schluntz 12 // Last Modified On : Tue Nov 15 17:27:28 2016 13 // Update Count : 3 14 // 15 1 16 int main() { 2 17 { … … 39 54 } 40 55 } 56 57 // Local Variables: // 58 // tab-width: 4 // 59 // End: // -
src/tests/tupleFunction.c
r596f987b r66f8528 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 // tupleFunction.c -- 8 // 9 // Author : Rob Schluntz 10 // Created On : Tue Nov 15 17:24:32 2016 11 // Last Modified By : Rob Schluntz 12 // Last Modified On : Tue Nov 15 17:27:28 2016 13 // Update Count : 3 14 // 15 1 16 struct S { 2 17 int f1, f2; … … 36 51 } 37 52 38 // forall(otype T | { T ?+?(T, T); }) 39 // [T, T, T] ?+?([T, T, T] x, [T, T, T] y) { 40 // T x1, x2, x3, y1, y2, y3; 41 // [x1, x2, x3] = x; 42 // [y1, y2, y3] = y; 43 // return [x1+y1, x2+y2, x3+y3]; 44 // } 53 int main() { 54 [int, double, int] x = [777, 2.76, 8675]; 55 int x1 = 123, x3 = 456; 56 double x2 = 999.123; 45 57 46 int main() { 47 [int, double, int] x = [777, 2.76, 8675]; 48 int x1 = 123, x3 = 456; 49 double x2 = 999.123; 50 51 printf("foo(...)=%d\n", foo(x1, x3, x2, (S){ 321, 654, 'Q', 3.14 })); 58 printf("foo(...)=%d\n", foo(x1, x3, x2, (S){ 321, 654, 'Q', 3.14 })); 52 59 53 60 // call function with tuple parameter using tuple variable arg … … 76 83 [x1, x2, x3] = quux(); 77 84 printf("x1=%d x2=%lg x3=%d\n", x1, x2, x3); 85 86 // xxx - tuples of type parameters should come out as generic types? 87 // [x1, x2, x3] = ([(int)x1, (int)x2, (int)x3]) + ([(int)1, (int)2, (int)3]); 88 // ([(int)x1, (int)x2, (int)x3]) + ([(int)1, (int)2, (int)3]); 89 // printf("%d %g %d\n", x1, x2, x3); 90 91 // xxx - comes out the back as a cast, but should come out as a tuple expression of the first n fields cast to each of the result types 92 // ([int, double])x; 78 93 } 94 95 // Local Variables: // 96 // tab-width: 4 // 97 // End: // 98 -
src/tests/tupleMember.c
r596f987b r66f8528 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 // tupleFunction.c -- 8 // 9 // Author : Rob Schluntz 10 // Created On : Tue Nov 15 17:24:32 2016 11 // Last Modified By : Rob Schluntz 12 // Last Modified On : Tue Nov 15 17:27:28 2016 13 // Update Count : 3 14 // 15 1 16 void f() { 2 17 printf("called f!\n"); … … 41 56 printf("v.[f1, i.[f2, f3], f4]=[%d, [%d, %d], %lg]\n", h().[f1, i.[f2, f3], f4]); 42 57 } 58 59 // Local Variables: // 60 // tab-width: 4 // 61 // End: //
Note:
See TracChangeset
for help on using the changeset viewer.