Changes in / [66f8528:596f987b]


Ignore:
Location:
src
Files:
8 deleted
63 edited

Legend:

Unmodified
Added
Removed
  • src/CodeGen/CodeGenerator.cc

    r66f8528 r596f987b  
    179179                        output << aggDecl->get_name();
    180180
    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();
    185185                        output << " {" << endl;
    186186
     
    291291                } // if
    292292                output << " }";
    293         }
    294 
    295         void CodeGenerator::visit( ConstructorInit * init ){
    296                 assertf( false, "ConstructorInit nodes should not make it to CodeGen." );
    297293        }
    298294
     
    921917                } // switch
    922918        }
    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         }
    932919} // namespace CodeGen
    933920
  • src/CodeGen/CodeGenerator.h

    r66f8528 r596f987b  
    4747                virtual void visit( SingleInit * );
    4848                virtual void visit( ListInit * );
    49                 virtual void visit( ConstructorInit * );
    5049
    5150                //*** Constant
     
    145144                return true;
    146145        }
    147 
    148         /// returns C-compatible name of declaration
    149         std::string genName( DeclarationWithType * decl );
    150146} // namespace CodeGen
    151147
  • src/GenPoly/Box.cc

    r66f8528 r596f987b  
    5555#include "Common/utility.h"
    5656
    57 #include "InitTweak/InitTweak.h"
    58 
    5957#include <ext/functional> // temporary
    6058
     
    10098                        void passArgTypeVars( ApplicationExpr *appExpr, Type *parmType, Type *argBaseType, std::list< Expression *>::iterator &arg, const TyVarMap &exprTyVars, std::set< std::string > &seenTypes );
    10199                        /// passes extra type parameters into a polymorphic function application
    102                         void passTypeVars( ApplicationExpr *appExpr, Type *polyRetType, std::list< Expression *>::iterator &arg, const TyVarMap &exprTyVars );
     100                        void passTypeVars( ApplicationExpr *appExpr, ReferenceToType *polyRetType, std::list< Expression *>::iterator &arg, const TyVarMap &exprTyVars );
    103101                        /// wraps a function application with a new temporary for the out-parameter return value
    104102                        Expression *addRetParam( ApplicationExpr *appExpr, FunctionType *function, Type *retType, std::list< Expression *>::iterator &arg );
     
    109107                        Type *replaceWithConcrete( ApplicationExpr *appExpr, Type *type, bool doClone = true );
    110108                        /// wraps a function application returning a polymorphic type with a new temporary for the out-parameter return value
    111                         Expression *addDynRetParam( ApplicationExpr *appExpr, FunctionType *function, Type *polyType, std::list< Expression *>::iterator &arg );
     109                        Expression *addDynRetParam( ApplicationExpr *appExpr, FunctionType *function, ReferenceToType *polyType, std::list< Expression *>::iterator &arg );
    112110                        Expression *applyAdapter( ApplicationExpr *appExpr, FunctionType *function, std::list< Expression *>::iterator &arg, const TyVarMap &exprTyVars );
    113111                        void boxParam( Type *formal, Expression *&arg, const TyVarMap &exprTyVars );
     
    115113                        void addInferredParams( ApplicationExpr *appExpr, FunctionType *functionType, std::list< Expression *>::iterator &arg, const TyVarMap &tyVars );
    116114                        /// Stores assignment operators from assertion list in local map of assignment operations
     115                        void findTypeOps( const Type::ForallList &forall );
    117116                        void passAdapters( ApplicationExpr *appExpr, FunctionType *functionType, const TyVarMap &exprTyVars );
    118117                        FunctionDecl *makeAdapter( FunctionType *adaptee, FunctionType *realType, const std::string &mangleName, const TyVarMap &tyVars );
     
    122121                        ObjectDecl *makeTemporary( Type *type );
    123122
     123                        ScopedMap< std::string, DeclarationWithType* > assignOps;    ///< Currently known type variable assignment operators
     124                        ScopedMap< std::string, DeclarationWithType* > ctorOps;      ///< Currently known type variable constructors
     125                        ScopedMap< std::string, DeclarationWithType* > copyOps;      ///< Currently known type variable copy constructors
     126                        ScopedMap< std::string, DeclarationWithType* > dtorOps;      ///< Currently known type variable destructors
     127                        ResolvExpr::TypeMap< DeclarationWithType > scopedAssignOps;  ///< Currently known assignment operators
     128                        ResolvExpr::TypeMap< DeclarationWithType > scopedCtorOps;    ///< Currently known assignment operators
     129                        ResolvExpr::TypeMap< DeclarationWithType > scopedCopyOps;    ///< Currently known assignment operators
     130                        ResolvExpr::TypeMap< DeclarationWithType > scopedDtorOps;    ///< Currently known assignment operators
    124131                        ScopedMap< std::string, DeclarationWithType* > adapters;     ///< Set of adapter functions in the current scope
    125132
    126                         std::map< ApplicationExpr *, Expression * > retVals;
    127 
    128133                        DeclarationWithType *retval;
     134                        bool useRetval;
    129135                        UniqueName tempNamer;
    130136                };
     
    269275
    270276                for ( std::list< TypeDecl* >::const_iterator decl = decls.begin(); decl != decls.end(); ++decl ) {
    271                         if ( (*decl)->isComplete() ) {
     277                        if ( (*decl)->get_kind() == TypeDecl::Any ) {
    272278                                otypeDecls.push_back( *decl );
    273279                        }
     
    491497                }
    492498
    493                 Pass1::Pass1() : tempNamer( "_temp" ) {}
     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                }
    494639
    495640                DeclarationWithType *Pass1::mutate( FunctionDecl *functionDecl ) {
     641                        // if this is a assignment function, put it in the map for this scope
     642                        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
    496660                        if ( functionDecl->get_statements() ) {         // empty routine body ?
    497661                                doBeginScope();
    498662                                scopeTyVars.beginScope();
     663                                assignOps.beginScope();
     664                                ctorOps.beginScope();
     665                                copyOps.beginScope();
     666                                dtorOps.beginScope();
    499667
    500668                                DeclarationWithType *oldRetval = retval;
     669                                bool oldUseRetval = useRetval;
    501670
    502671                                // process polymorphic return value
    503                                 retval = nullptr;
    504                                 if ( isDynRet( functionDecl->get_functionType() ) && functionDecl->get_linkage() != LinkageSpec::C ) {
     672                                retval = 0;
     673                                if ( isDynRet( functionDecl->get_functionType() ) && functionDecl->get_linkage() == LinkageSpec::Cforall ) {
    505674                                        retval = functionDecl->get_functionType()->get_returnVals().front();
    506675
     
    514683                                FunctionType *functionType = functionDecl->get_functionType();
    515684                                makeTyVarMap( functionDecl->get_functionType(), scopeTyVars );
     685                                findTypeOps( functionDecl->get_functionType()->get_forall() );
    516686
    517687                                std::list< DeclarationWithType *> &paramList = functionType->get_parameters();
     
    530700                                        if ( adapters.find( mangleName ) == adapters.end() ) {
    531701                                                std::string adapterName = makeAdapterName( mangleName );
    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 ) ) );
     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 ) ) );
    533703                                        } // if
    534704                                } // for
     
    537707
    538708                                scopeTyVars.endScope();
     709                                assignOps.endScope();
     710                                ctorOps.endScope();
     711                                copyOps.endScope();
     712                                dtorOps.endScope();
    539713                                retval = oldRetval;
     714                                useRetval = oldUseRetval;
    540715                                doEndScope();
    541716                        } // if
     
    544719
    545720                TypeDecl *Pass1::mutate( TypeDecl *typeDecl ) {
    546                         addToTyVarMap( typeDecl, scopeTyVars );
     721                        scopeTyVars[ typeDecl->get_name() ] = typeDecl->get_kind();
    547722                        return Mutator::mutate( typeDecl );
    548723                }
    549724
    550725                Expression *Pass1::mutate( CommaExpr *commaExpr ) {
    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 
     726                        bool oldUseRetval = useRetval;
     727                        useRetval = false;
    567728                        commaExpr->set_arg1( maybeMutate( commaExpr->get_arg1(), *this ) );
     729                        useRetval = oldUseRetval;
    568730                        commaExpr->set_arg2( maybeMutate( commaExpr->get_arg2(), *this ) );
    569731                        return commaExpr;
     
    571733
    572734                Expression *Pass1::mutate( ConditionalExpr *condExpr ) {
     735                        bool oldUseRetval = useRetval;
     736                        useRetval = false;
    573737                        condExpr->set_arg1( maybeMutate( condExpr->get_arg1(), *this ) );
     738                        useRetval = oldUseRetval;
    574739                        condExpr->set_arg2( maybeMutate( condExpr->get_arg2(), *this ) );
    575740                        condExpr->set_arg3( maybeMutate( condExpr->get_arg3(), *this ) );
     
    604769                }
    605770
    606                 void Pass1::passTypeVars( ApplicationExpr *appExpr, Type *polyRetType, std::list< Expression *>::iterator &arg, const TyVarMap &exprTyVars ) {
     771                void Pass1::passTypeVars( ApplicationExpr *appExpr, ReferenceToType *polyRetType, std::list< Expression *>::iterator &arg, const TyVarMap &exprTyVars ) {
    607772                        // pass size/align for type variables
    608773                        for ( TyVarMap::const_iterator tyParm = exprTyVars.begin(); tyParm != exprTyVars.end(); ++tyParm ) {
    609774                                ResolvExpr::EqvClass eqvClass;
    610775                                assert( env );
    611                                 if ( tyParm->second.isComplete ) {
     776                                if ( tyParm->second == TypeDecl::Any ) {
    612777                                        Type *concrete = env->lookup( tyParm->first );
    613778                                        if ( concrete ) {
     
    618783                                        } else {
    619784                                                // xxx - should this be an assertion?
    620                                                 std::string x = env ? toString( *env ) : "missing env";
    621                                                 throw SemanticError( x + "\n" + "unbound type variable: " + tyParm->first + " in application ", appExpr );
     785                                                throw SemanticError( "unbound type variable: " + tyParm->first + " in application ", appExpr );
    622786                                        } // if
    623787                                } // if
     
    637801                                Type *concRetType = replaceWithConcrete( appExpr, polyRetType );
    638802                                passArgTypeVars( appExpr, polyRetType, concRetType, arg, exprTyVars, seenTypes );
    639                                 ++fnArg; // skip the return parameter in the argument list
    640803                        }
    641804
    642805                        // add type information args for presently unseen types in parameter list
    643806                        for ( ; fnParm != funcType->get_parameters().end() && fnArg != appExpr->get_args().end(); ++fnParm, ++fnArg ) {
    644                                 if ( ! (*fnArg)->get_result() ) continue;
    645                                 Type * argType = (*fnArg)->get_result();
    646                                 passArgTypeVars( appExpr, (*fnParm)->get_type(), argType, arg, exprTyVars, seenTypes );
     807                                VariableExpr *fnArgBase = getBaseVar( *fnArg );
     808                                if ( ! fnArgBase ) continue; // xxx - previously had check for non-empty fnArgBase results
     809                                passArgTypeVars( appExpr, (*fnParm)->get_type(), fnArgBase->get_result(), arg, exprTyVars, seenTypes );
    647810                        }
    648811                }
     
    655818
    656819                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
    657827                        // Create temporary to hold return value of polymorphic function and produce that temporary as a result
    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();
     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 );
    670832
    671833                        // If the type of the temporary is not polymorphic, box temporary by taking its address;
    672834                        // otherwise the temporary is already boxed and can be used directly.
    673                         if ( ! isPolyType( paramExpr->get_result(), scopeTyVars, env ) ) {
     835                        if ( ! isPolyType( newObj->get_type(), scopeTyVars, env ) ) {
    674836                                paramExpr = new AddressExpr( paramExpr );
    675837                        } // if
     
    677839                        arg++;
    678840                        // Build a comma expression to call the function and emulate a normal return.
    679                         CommaExpr *commaExpr = new CommaExpr( appExpr, retExpr );
     841                        CommaExpr *commaExpr = new CommaExpr( appExpr, new VariableExpr( newObj ) );
    680842                        commaExpr->set_env( appExpr->get_env() );
    681843                        appExpr->set_env( 0 );
    682844                        return commaExpr;
     845                        // } // if
     846                        // return appExpr;
    683847                }
    684848
     
    695859                                Type *concrete = env->lookup( typeInst->get_name() );
    696860                                if ( concrete == 0 ) {
    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 );
     861                                        throw SemanticError( "Unbound type variable " + typeInst->get_name() + " in ", appExpr );
    700862                                } // if
    701863                                return concrete;
     
    716878                }
    717879
    718                 Expression *Pass1::addDynRetParam( ApplicationExpr *appExpr, FunctionType *function, Type *dynType, std::list< Expression *>::iterator &arg ) {
     880                Expression *Pass1::addDynRetParam( ApplicationExpr *appExpr, FunctionType *function, ReferenceToType *dynType, std::list< Expression *>::iterator &arg ) {
    719881                        assert( env );
    720882                        Type *concrete = replaceWithConcrete( appExpr, dynType );
     
    794956                                for ( std::list< DeclarationWithType *>::iterator assert = (*tyVar)->get_assertions().begin(); assert != (*tyVar)->get_assertions().end(); ++assert ) {
    795957                                        InferredParams::const_iterator inferParam = appExpr->get_inferParams().find( (*assert)->get_uniqueId() );
    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" );
     958                                        assert( inferParam != appExpr->get_inferParams().end() && "NOTE: Explicit casts of polymorphic functions to compatible monomorphic functions are currently unsupported" );
    800959                                        Expression *newExpr = inferParam->second.expr->clone();
    801960                                        addCast( newExpr, (*assert)->get_type(), tyVars );
     
    11081267                        // }
    11091268                        // std::cerr << "\n";
     1269                        bool oldUseRetval = useRetval;
     1270                        useRetval = false;
    11101271                        appExpr->get_function()->acceptMutator( *this );
    11111272                        mutateAll( appExpr->get_args(), *this );
     1273                        useRetval = oldUseRetval;
    11121274
    11131275                        assert( appExpr->get_function()->has_result() );
     
    11241286                        std::list< Expression *>::iterator paramBegin = appExpr->get_args().begin();
    11251287
    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?)
     1288                        TyVarMap exprTyVars( (TypeDecl::Kind)-1 );
     1289                        makeTyVarMap( function, exprTyVars );
    11281290                        ReferenceToType *dynRetType = isDynRet( function, exprTyVars );
    1129                         Type *concRetType = appExpr->get_result()->isVoid() ? nullptr : appExpr->get_result();// ?: dynRetType; // xxx - is concRetType a good name?
    11301291
    11311292                        if ( dynRetType ) {
    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 
     1293                                ret = addDynRetParam( appExpr, function, dynRetType, arg );
     1294                        } else if ( needsAdapter( function, scopeTyVars ) ) {
    11361295                                // std::cerr << "needs adapter: ";
    11371296                                // printTyVarMap( std::cerr, scopeTyVars );
     
    11421301                        arg = appExpr->get_args().begin();
    11431302
    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)
     1303                        passTypeVars( appExpr, dynRetType, arg, exprTyVars );
    11451304                        addInferredParams( appExpr, function, arg, exprTyVars );
    11461305
     
    12011360                }
    12021361
     1362                /// Wraps a function declaration in a new pointer-to-function variable expression
     1363                VariableExpr *wrapFunctionDecl( DeclarationWithType *functionDecl ) {
     1364                        // line below cloned from FixFunction.cc
     1365                        // 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 maps
     1374                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 op
     1384                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
    12031389                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 
    12111390                        if ( retval && returnStmt->get_expr() ) {
    12121391                                assert( returnStmt->get_expr()->has_result() && ! returnStmt->get_expr()->get_result()->isVoid() );
    1213                                 delete returnStmt->get_expr();
     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
    12141480                                returnStmt->set_expr( 0 );
    12151481                        } else {
     
    12411507                void Pass1::doBeginScope() {
    12421508                        adapters.beginScope();
     1509                        scopedAssignOps.beginScope();
     1510                        scopedCtorOps.beginScope();
     1511                        scopedCopyOps.beginScope();
     1512                        scopedDtorOps.beginScope();
    12431513                }
    12441514
    12451515                void Pass1::doEndScope() {
    12461516                        adapters.endScope();
     1517                        scopedAssignOps.endScope();
     1518                        scopedCtorOps.endScope();
     1519                        scopedCopyOps.endScope();
     1520                        scopedDtorOps.endScope();
    12471521                }
    12481522
     
    12761550                }
    12771551
    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 
    12851552                DeclarationWithType * Pass2::mutate( FunctionDecl *functionDecl ) {
    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;
     1553                        return handleDecl( functionDecl, functionDecl->get_functionType() );
    13011554                }
    13021555
     
    13061559
    13071560                TypeDecl * Pass2::mutate( TypeDecl *typeDecl ) {
    1308                         addToTyVarMap( typeDecl, scopeTyVars );
     1561                        scopeTyVars[ typeDecl->get_name() ] = typeDecl->get_kind();
    13091562                        if ( typeDecl->get_base() ) {
    13101563                                return handleDecl( typeDecl, typeDecl->get_base() );
     
    13341587                        // move polymorphic return type to parameter list
    13351588                        if ( isDynRet( funcType ) ) {
    1336                                 ObjectDecl *ret = safe_dynamic_cast< ObjectDecl* >( funcType->get_returnVals().front() );
     1589                                DeclarationWithType *ret = funcType->get_returnVals().front();
    13371590                                ret->set_type( new PointerType( Type::Qualifiers(), ret->get_type() ) );
    13381591                                funcType->get_parameters().push_front( ret );
    13391592                                funcType->get_returnVals().pop_front();
    1340                                 ret->set_init( nullptr ); // xxx - memory leak?
    13411593                        }
    13421594
     
    13501602                                ObjectDecl *sizeParm, *alignParm;
    13511603                                // add all size and alignment parameters to parameter list
    1352                                 if ( (*tyParm)->isComplete() ) {
     1604                                if ( (*tyParm)->get_kind() == TypeDecl::Any ) {
    13531605                                        TypeInstType parmType( Type::Qualifiers(), (*tyParm)->get_name(), *tyParm );
    13541606                                        std::string parmName = mangleType( &parmType );
     
    14591711
    14601712                TypeDecl * PolyGenericCalculator::mutate( TypeDecl *typeDecl ) {
    1461                         addToTyVarMap( typeDecl, scopeTyVars );
     1713                        scopeTyVars[ typeDecl->get_name() ] = typeDecl->get_kind();
    14621714                        return Parent::mutate( typeDecl );
    14631715                }
     
    15731825                                // replace member expression with pointer to base plus offset
    15741826                                UntypedExpr *fieldLoc = new UntypedExpr( new NameExpr( "?+?" ) );
    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 );
     1827                                fieldLoc->get_args().push_back( makeDerefdVar( varExpr->clone(), varDepth ) );
    15791828                                fieldLoc->get_args().push_back( makeOffsetIndex( objectType, i ) );
    15801829                                newMemberExpr = fieldLoc;
     
    16261875                        for ( ; baseParam != baseParams.end() && typeParam != typeParams.end(); ++baseParam, ++typeParam ) {
    16271876                                // skip non-otype parameters
    1628                                 if ( ! (*baseParam)->isComplete() ) continue;
     1877                                if ( (*baseParam)->get_kind() != TypeDecl::Any ) continue;
    16291878                                TypeExpr *typeExpr = dynamic_cast< TypeExpr* >( *typeParam );
    16301879                                assert( typeExpr && "all otype parameters should be type expressions" );
     
    18382087//   Initializer *init = 0;
    18392088//   std::list< Expression *> designators;
    1840 //   addToTyVarMap( typeDecl, scopeTyVars );
     2089//   scopeTyVars[ typeDecl->get_name() ] = typeDecl->get_kind();
    18412090//   if ( typeDecl->get_base() ) {
    18422091//     init = new SimpleInit( new SizeofExpr( handleDecl( typeDecl, typeDecl->get_base() ) ), designators );
     
    18442093//   return new ObjectDecl( typeDecl->get_name(), Declaration::Extern, LinkageSpec::C, 0, new BasicType( Type::Qualifiers(), BasicType::UnsignedInt ), init );
    18452094
    1846                         addToTyVarMap( typeDecl, scopeTyVars );
     2095                        scopeTyVars[ typeDecl->get_name() ] = typeDecl->get_kind();
    18472096                        return Mutator::mutate( typeDecl );
    18482097                }
  • src/GenPoly/CopyParams.cc

    r66f8528 r596f987b  
    3838        };
    3939
    40         /// creates local copies of polymorphic function parameters
    4140        void copyParams( std::list< Declaration* > &translationUnit ) {
    4241                CopyParams copier;
     
    5453                        if ( ! modVars.empty() ) {
    5554                                std::map< std::string, DeclarationWithType* > assignOps;
    56                                 // xxx - this needs to use constructors, not assignment operators
    5755                                // assume the assignment operator is the first assert param after any "type" parameter
    5856                                for ( Type::ForallList::const_iterator tyVar = funcDecl->get_functionType()->get_forall().begin(); tyVar != funcDecl->get_functionType()->get_forall().end(); ++tyVar ) {
  • src/GenPoly/GenPoly.cc

    r66f8528 r596f987b  
    9292        }
    9393
    94         ReferenceToType *isDynType( Type *type, const TyVarMap &tyVars, const TypeSubstitution *env ) {
     94        Type *isDynType( Type *type, const TyVarMap &tyVars, const TypeSubstitution *env ) {
    9595                type = replaceTypeInst( type, env );
    9696
    9797                if ( TypeInstType *typeInst = dynamic_cast< TypeInstType * >( type ) ) {
    9898                        auto var = tyVars.find( typeInst->get_name() );
    99                         if ( var != tyVars.end() && var->second.isComplete ) {
    100                                 return typeInst;
     99                        if ( var != tyVars.end() && var->second == TypeDecl::Any ) {
     100                                return type;
    101101                        }
    102102                } else if ( StructInstType *structType = dynamic_cast< StructInstType* >( type ) ) {
    103                         if ( hasDynParams( structType->get_parameters(), tyVars, env ) ) return structType;
     103                        if ( hasDynParams( structType->get_parameters(), tyVars, env ) ) return type;
    104104                } else if ( UnionInstType *unionType = dynamic_cast< UnionInstType* >( type ) ) {
    105                         if ( hasDynParams( unionType->get_parameters(), tyVars, env ) ) return unionType;
     105                        if ( hasDynParams( unionType->get_parameters(), tyVars, env ) ) return type;
    106106                }
    107107                return 0;
     
    117117                if ( function->get_returnVals().empty() ) return 0;
    118118
    119                 TyVarMap forallTypes( TypeDecl::Data{} );
     119                TyVarMap forallTypes( (TypeDecl::Kind)-1 );
    120120                makeTyVarMap( function, forallTypes );
    121121                return (ReferenceToType*)isDynType( function->get_returnVals().front()->get_type(), forallTypes );
     
    219219                                expr = commaExpr->get_arg2();
    220220                                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;
    231221                        } else break;
    232222
     
    235225
    236226                return 0;
    237         }
    238 
    239         void addToTyVarMap( TypeDecl * tyVar, TyVarMap &tyVarMap ) {
    240                 tyVarMap[ tyVar->get_name() ] = TypeDecl::Data{ tyVar };
    241227        }
    242228
     
    244230                for ( Type::ForallList::const_iterator tyVar = type->get_forall().begin(); tyVar != type->get_forall().end(); ++tyVar ) {
    245231                        assert( *tyVar );
    246                         addToTyVarMap( *tyVar, tyVarMap );
     232                        tyVarMap[ (*tyVar)->get_name() ] = (*tyVar)->get_kind();
    247233                }
    248234                if ( PointerType *pointer = dynamic_cast< PointerType* >( type ) ) {
  • src/GenPoly/GenPoly.h

    r66f8528 r596f987b  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // GenPoly.h --
     7// GenPoly.h -- 
    88//
    99// Author           : Richard C. Bilson
     
    3030
    3131namespace GenPoly {
    32         typedef ErasableScopedMap< std::string, TypeDecl::Data > TyVarMap;
     32        typedef ErasableScopedMap< std::string, TypeDecl::Kind > TyVarMap;
    3333
    3434        /// Replaces a TypeInstType by its referrent in the environment, if applicable
    3535        Type* replaceTypeInst( Type* type, const TypeSubstitution* env );
    36 
     36       
    3737        /// returns polymorphic type if is polymorphic type, NULL otherwise; will look up substitution in env if provided
    3838        Type *isPolyType( Type *type, const TypeSubstitution *env = 0 );
    39 
     39       
    4040        /// returns polymorphic type if is polymorphic type in tyVars, NULL otherwise; will look up substitution in env if provided
    4141        Type *isPolyType( Type *type, const TyVarMap &tyVars, const TypeSubstitution *env = 0 );
    4242
    4343        /// returns dynamic-layout type if is dynamic-layout type in tyVars, NULL otherwise; will look up substitution in env if provided
    44         ReferenceToType *isDynType( Type *type, const TyVarMap &tyVars, const TypeSubstitution *env = 0 );
     44        Type *isDynType( Type *type, const TyVarMap &tyVars, const TypeSubstitution *env = 0 );
    4545
    4646        /// true iff function has dynamic-layout return type under the given type variable map
     
    5555        /// returns polymorphic type if is pointer to polymorphic type, NULL otherwise; will look up substitution in env if provided
    5656        Type *isPolyPtr( Type *type, const TypeSubstitution *env = 0 );
    57 
     57       
    5858        /// returns polymorphic type if is pointer to polymorphic type in tyVars, NULL otherwise; will look up substitution in env if provided
    5959        Type *isPolyPtr( Type *type, const TyVarMap &tyVars, const TypeSubstitution *env = 0 );
     
    7474        VariableExpr *getBaseVar( Expression *expr, int *levels = 0 );
    7575
    76         /// Adds the type variable `tyVar` to `tyVarMap`
    77         void addToTyVarMap( TypeDecl * tyVar, TyVarMap &tyVarMap );
    78 
    7976        /// Adds the declarations in the forall list of type (and its pointed-to type if it's a pointer type) to `tyVarMap`
    8077        void makeTyVarMap( Type *type, TyVarMap &tyVarMap );
    81 
     78       
    8279        /// Prints type variable map
    8380        void printTyVarMap( std::ostream &os, const TyVarMap &tyVarMap );
     
    8582        /// Gets the mangled name of this type; alias for SymTab::Mangler::mangleType().
    8683        inline std::string mangleType( Type *ty ) { return SymTab::Mangler::mangleType( ty ); }
    87 
     84       
    8885        /// Gets the name of the sizeof parameter for the type, given its mangled name
    8986        inline std::string sizeofName( const std::string &name ) { return std::string( "_sizeof_" ) + name; }
     
    9794        /// Gets the name of the layout function for a given aggregate type, given its declaration
    9895        inline std::string layoutofName( AggregateDecl *decl ) { return std::string( "_layoutof_" ) + decl->get_name(); }
    99 
     96       
    10097} // namespace GenPoly
    10198
  • src/GenPoly/InstantiateGeneric.cc

    r66f8528 r596f987b  
    284284                                // set concDecl to new type, insert type declaration into statements to add
    285285                                concDecl = new StructDecl( typeNamer.newName( inst->get_name() ) );
    286                                 concDecl->set_body( inst->get_baseStruct()->has_body() );
    287286                                substituteMembers( inst->get_baseStruct()->get_members(), *inst->get_baseParameters(), typeSubs,        concDecl->get_members() );
    288287                                DeclMutator::addDeclaration( concDecl );
     
    338337                                // set concDecl to new type, insert type declaration into statements to add
    339338                                concDecl = new UnionDecl( typeNamer.newName( inst->get_name() ) );
    340                                 concDecl->set_body( inst->get_baseUnion()->has_body() );
    341339                                substituteMembers( inst->get_baseUnion()->get_members(), *inst->get_baseParameters(), typeSubs, concDecl->get_members() );
    342340                                DeclMutator::addDeclaration( concDecl );
  • src/GenPoly/PolyMutator.cc

    r66f8528 r596f987b  
    2323
    2424namespace GenPoly {
    25         PolyMutator::PolyMutator() : scopeTyVars( TypeDecl::Data{} ), env( 0 ) {}
     25        namespace {
     26                const std::list<Label> noLabels;
     27        }
     28
     29        PolyMutator::PolyMutator() : scopeTyVars( (TypeDecl::Kind)-1 ), env( 0 ) {}
    2630
    2731        void PolyMutator::mutateStatementList( std::list< Statement* > &statements ) {
     
    145149        }
    146150
    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         }
    162151
    163152        Initializer *PolyMutator::mutate( SingleInit *singleInit ) {
     
    165154                return singleInit;
    166155        }
     156
    167157} // namespace GenPoly
    168158
  • src/GenPoly/PolyMutator.h

    r66f8528 r596f987b  
    4747
    4848                virtual Expression* mutate(UntypedExpr *untypedExpr);
    49                 virtual Expression* mutate( StmtExpr *stmtExpr );
    5049
    5150                virtual Initializer* mutate(SingleInit *SingleInit);
  • src/GenPoly/ScrubTyVars.cc

    r66f8528 r596f987b  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // ScrubTyVars.cc --
     7// ScrubTyVars.cc -- 
    88//
    99// Author           : Richard C. Bilson
     
    2828                TyVarMap::const_iterator tyVar = tyVars.find( typeInst->get_name() );
    2929                if ( tyVar != tyVars.end() ) {
    30                         switch ( tyVar->second.kind ) {
     30                        switch ( tyVar->second ) {
    3131                          case TypeDecl::Any:
    3232                          case TypeDecl::Dtype:
     
    5252                return ty;
    5353        }
    54 
     54       
    5555        Type * ScrubTyVars::mutate( StructInstType *structInst ) {
    5656                return mutateAggregateType( structInst );
  • src/InitTweak/FixInit.cc

    r66f8528 r596f987b  
    4949namespace InitTweak {
    5050        namespace {
    51                 typedef std::unordered_map< Expression *, TypeSubstitution * > EnvMap;
    52 
    5351                class InsertImplicitCalls final : public GenPoly::PolyMutator {
    5452                public:
    5553                        /// wrap function application expressions as ImplicitCopyCtorExpr nodes so that it is easy to identify which
    5654                        /// function calls need their parameters to be copy constructed
    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;
     55                        static void insert( std::list< Declaration * > & translationUnit );
     56
     57                        using GenPoly::PolyMutator::mutate;
    6258                        virtual Expression * mutate( ApplicationExpr * appExpr ) override;
    63                         virtual Expression * mutate( StmtExpr * stmtExpr ) override;
    64 
    65                         // collects environments for relevant nodes
    66                         EnvMap & envMap;
    6759                };
    6860
     
    7264                        /// generate/resolve copy construction expressions for each, and generate/resolve destructors for both
    7365                        /// arguments and return value temporaries
    74                         static void resolveImplicitCalls( std::list< Declaration * > & translationUnit, const EnvMap & envMap );
     66                        static void resolveImplicitCalls( std::list< Declaration * > & translationUnit );
    7567
    7668                        typedef SymTab::Indexer Parent;
    7769                        using Parent::visit;
    7870
    79                         ResolveCopyCtors( const EnvMap & envMap ) : envMap( envMap ) {}
    80 
    8171                        virtual void visit( ImplicitCopyCtorExpr * impCpCtorExpr ) override;
    82                         virtual void visit( UniqueExpr * unqExpr ) override;
    83                         virtual void visit( StmtExpr * stmtExpr ) override;
     72                        virtual void visit( UniqueExpr * unqExpr );
    8473
    8574                        /// create and resolve ctor/dtor expression: fname(var, [cpArg])
     
    9079                        void copyConstructArg( Expression *& arg, ImplicitCopyCtorExpr * impCpCtorExpr );
    9180                        void destructRet( Expression * ret, ImplicitCopyCtorExpr * impCpCtorExpr );
    92 
     81                private:
    9382                        TypeSubstitution * env;
    94                         const EnvMap & envMap;
    9583                };
    9684
     
    186174                        static void fixInitializers( std::list< Declaration * > &translationUnit );
    187175
    188                         typedef GenPoly::PolyMutator Parent;
    189                         using Parent::mutate;
     176                        using GenPoly::PolyMutator::mutate;
    190177                        virtual DeclarationWithType * mutate( ObjectDecl *objDecl ) override;
    191178
     
    199186                        static void fixCopyCtors( std::list< Declaration * > &translationUnit );
    200187
    201                         typedef GenPoly::PolyMutator Parent;
    202                         using Parent::mutate;
     188                        using GenPoly::PolyMutator::mutate;
    203189                        virtual Expression * mutate( ImplicitCopyCtorExpr * impCpCtorExpr ) override;
    204190                        virtual Expression * mutate( UniqueExpr * unqExpr ) override;
    205                         virtual Expression * mutate( StmtExpr * stmtExpr ) override;
    206191                };
    207192
     
    263248                InitTweak::fixGlobalInit( translationUnit, filename, inLibrary );
    264249
    265                 EnvMap envMap;
    266 
    267                 InsertImplicitCalls::insert( translationUnit, envMap );
    268                 ResolveCopyCtors::resolveImplicitCalls( translationUnit, envMap );
     250
     251                InsertImplicitCalls::insert( translationUnit );
     252                ResolveCopyCtors::resolveImplicitCalls( translationUnit );
    269253                InsertDtors::insert( translationUnit );
    270254                FixInit::fixInitializers( translationUnit );
     
    285269
    286270        namespace {
    287                 void InsertImplicitCalls::insert( std::list< Declaration * > & translationUnit, EnvMap & envMap ) {
    288                         InsertImplicitCalls inserter( envMap );
     271                void InsertImplicitCalls::insert( std::list< Declaration * > & translationUnit ) {
     272                        InsertImplicitCalls inserter;
    289273                        mutateAll( translationUnit, inserter );
    290274                }
    291275
    292                 void ResolveCopyCtors::resolveImplicitCalls( std::list< Declaration * > & translationUnit, const EnvMap & envMap ) {
    293                         ResolveCopyCtors resolver( envMap );
     276                void ResolveCopyCtors::resolveImplicitCalls( std::list< Declaration * > & translationUnit ) {
     277                        ResolveCopyCtors resolver;
    294278                        acceptAll( translationUnit, resolver );
    295279                }
     
    342326
    343327                Expression * InsertImplicitCalls::mutate( ApplicationExpr * appExpr ) {
    344                         appExpr = dynamic_cast< ApplicationExpr * >( Parent::mutate( appExpr ) );
     328                        appExpr = dynamic_cast< ApplicationExpr * >( Mutator::mutate( appExpr ) );
    345329                        assert( appExpr );
    346330
     
    355339                                                Type * t1 = ftype->get_parameters().front()->get_type();
    356340                                                Type * t2 = ftype->get_parameters().back()->get_type();
    357                                                 PointerType * ptrType = safe_dynamic_cast< PointerType * > ( t1 );
     341                                                PointerType * ptrType = dynamic_cast< PointerType * > ( t1 );
     342                                                assert( ptrType );
    358343
    359344                                                if ( ResolvExpr::typesCompatible( ptrType->get_base(), t2, SymTab::Indexer() ) ) {
     
    372357                        // wrap each function call so that it is easy to identify nodes that have to be copy constructed
    373358                        ImplicitCopyCtorExpr * expr = new ImplicitCopyCtorExpr( appExpr );
    374                         // save the type substitution into the envMap so that it is easy to find.
     359                        // save the type substitution onto the new node so that it is easy to find.
    375360                        // Ensure it is not deleted with the ImplicitCopyCtorExpr by removing it before deletion.
    376361                        // The substitution is needed to obtain the type of temporary variables so that copy constructor
     
    381366                        // constructor calls together.
    382367                        assert( env );
    383                         envMap[expr] = env;
     368                        expr->set_env( env );
    384369                        return expr;
    385                 }
    386 
    387                 Expression * InsertImplicitCalls::mutate( StmtExpr * stmtExpr ) {
    388                         assert( env );
    389                         envMap[stmtExpr] = env;
    390                         return Parent::mutate( stmtExpr );
    391370                }
    392371
     
    413392                        assert( resolved );
    414393                        if ( resolved->get_env() ) {
    415                                 // Extract useful information and discard new environments. Keeping them causes problems in PolyMutator passes.
    416394                                env->add( *resolved->get_env() );
    417                                 delete resolved->get_env();
    418                                 resolved->set_env( nullptr );
    419395                        } // if
    420396
     
    425401                void ResolveCopyCtors::copyConstructArg( Expression *& arg, ImplicitCopyCtorExpr * impCpCtorExpr ) {
    426402                        static UniqueName tempNamer("_tmp_cp");
    427                         assert( env );
    428                         CP_CTOR_PRINT( std::cerr << "Type Substitution: " << *env << std::endl; )
     403                        CP_CTOR_PRINT( std::cerr << "Type Substitution: " << *impCpCtorExpr->get_env() << std::endl; )
    429404                        assert( arg->has_result() );
    430405                        Type * result = arg->get_result();
     
    433408                        // type may involve type variables, so apply type substitution to get temporary variable's actual type
    434409                        result = result->clone();
    435                         env->apply( result );
     410                        impCpCtorExpr->get_env()->apply( result );
    436411                        ObjectDecl * tmp = new ObjectDecl( tempNamer.newName(), DeclarationNode::NoStorageClass, LinkageSpec::C, 0, result, 0 );
    437412                        tmp->get_type()->set_isConst( false );
     
    462437                        CP_CTOR_PRINT( std::cerr << "ResolveCopyCtors: " << impCpCtorExpr << std::endl; )
    463438                        Parent::visit( impCpCtorExpr );
    464                         env = envMap.at(impCpCtorExpr);
    465                         assert( env );
     439                        env = impCpCtorExpr->get_env(); // xxx - maybe we really should just have a PolyIndexer...
    466440
    467441                        ApplicationExpr * appExpr = impCpCtorExpr->get_callExpr();
     
    474448                        // each return value from the call needs to be connected with an ObjectDecl at the call site, which is
    475449                        // initialized with the return value and is destructed later
    476                         // xxx - handle named return values?
     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() );
    477455                        Type * result = appExpr->get_result();
    478456                        if ( ! result->isVoid() ) {
    479457                                static UniqueName retNamer("_tmp_cp_ret");
    480458                                result = result->clone();
    481                                 env->apply( result );
     459                                impCpCtorExpr->get_env()->apply( result );
    482460                                ObjectDecl * ret = new ObjectDecl( retNamer.newName(), DeclarationNode::NoStorageClass, LinkageSpec::C, 0, result, 0 );
    483461                                ret->get_type()->set_isConst( false );
     
    490468                        } // for
    491469                        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 
    519470                }
    520471
     
    541492                }
    542493
     494
    543495                Expression * FixCopyCtors::mutate( ImplicitCopyCtorExpr * impCpCtorExpr ) {
    544496                        CP_CTOR_PRINT( std::cerr << "FixCopyCtors: " << impCpCtorExpr << std::endl; )
    545497
    546                         impCpCtorExpr = safe_dynamic_cast< ImplicitCopyCtorExpr * >( Parent::mutate( impCpCtorExpr ) );
     498                        impCpCtorExpr = dynamic_cast< ImplicitCopyCtorExpr * >( Mutator::mutate( impCpCtorExpr ) );
     499                        assert( impCpCtorExpr );
     500
    547501                        std::list< ObjectDecl * > & tempDecls = impCpCtorExpr->get_tempDecls();
    548502                        std::list< ObjectDecl * > & returnDecls = impCpCtorExpr->get_returnDecls();
     
    604558                                        retExpr = UntypedExpr::createDeref( retExpr );
    605559                                } // if
    606                                 // move env from callExpr to retExpr
    607                                 retExpr->set_env( callExpr->get_env() );
    608                                 callExpr->set_env( nullptr );
     560                                retExpr->set_env( env->clone() );
    609561                                return retExpr;
    610562                        } else {
     
    613565                }
    614566
    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 
    638567                Expression * FixCopyCtors::mutate( UniqueExpr * unqExpr ) {
    639568                        static std::unordered_map< int, UniqueExpr * > unqMap;
    640569                        static std::unordered_set< int > addDeref;
    641570                        // 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 ) );
    642572                        if ( unqMap.count( unqExpr->get_id() ) ) {
    643573                                // take data from other UniqueExpr to ensure consistency
     
    652582                                return unqExpr;
    653583                        }
    654                         unqExpr = safe_dynamic_cast< UniqueExpr * >( Parent::mutate( unqExpr ) ); // stmtexprs contained should not be separately fixed, so this must occur after the lookup
    655584                        unqMap[unqExpr->get_id()] = unqExpr;
    656585                        if ( UntypedExpr * deref = dynamic_cast< UntypedExpr * >( unqExpr->get_expr() ) ) {
     
    670599                        // first recursively handle pieces of ObjectDecl so that they aren't missed by other visitors when the init
    671600                        // is removed from the ObjectDecl
    672                         objDecl = dynamic_cast< ObjectDecl * >( Parent::mutate( objDecl ) );
     601                        objDecl = dynamic_cast< ObjectDecl * >( Mutator::mutate( objDecl ) );
     602
    673603                        if ( ConstructorInit * ctorInit = dynamic_cast< ConstructorInit * >( objDecl->get_init() ) ) {
    674604                                // a decision should have been made by the resolver, so ctor and init are not both non-NULL
     
    974904                                        // insert and resolve default/copy constructor call for each field that's unhandled
    975905                                        std::list< Statement * > stmt;
    976                                         UntypedExpr * deref = UntypedExpr::createDeref( new VariableExpr( thisParam ) );
     906                                        UntypedExpr * deref = new UntypedExpr( new NameExpr( "*?" ) );
     907                                        deref->get_args().push_back( new VariableExpr( thisParam ) );
    977908
    978909                                        Expression * arg2 = 0;
  • src/InitTweak/GenInit.cc

    r66f8528 r596f987b  
    4646                ReturnFixer();
    4747
    48                 typedef GenPoly::PolyMutator Parent;
    49                 using Parent::mutate;
     48                using GenPoly::PolyMutator::mutate;
    5049                virtual DeclarationWithType * mutate( FunctionDecl *functionDecl ) override;
    5150                virtual Statement * mutate( ReturnStmt * returnStmt ) override;
     
    5352          protected:
    5453                FunctionType * ftype;
     54                UniqueName tempNamer;
    5555                std::string funcName;
    5656        };
     
    135135        }
    136136
    137         ReturnFixer::ReturnFixer() {}
     137        ReturnFixer::ReturnFixer() : tempNamer( "_retVal" ) {}
    138138
    139139        Statement *ReturnFixer::mutate( ReturnStmt *returnStmt ) {
     
    142142                // hands off if the function returns an lvalue - we don't want to allocate a temporary if a variable's address
    143143                // 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.
    145144                if ( returnStmt->get_expr() && returnVals.size() == 1 && funcName != "?=?" && ! returnVals.front()->get_type()->get_isLvalue() ) {
    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() );
     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
    148151                        UntypedExpr *construct = new UntypedExpr( new NameExpr( "?{}" ) );
    149                         construct->get_args().push_back( new AddressExpr( new VariableExpr( returnVals.front() ) ) );
     152                        construct->get_args().push_back( new AddressExpr( new VariableExpr( newObj ) ) );
    150153                        construct->get_args().push_back( returnStmt->get_expr() );
    151154                        stmtsToAdd.push_back(new ExprStmt(noLabels, construct));
    152155
    153                         // return the retVal object
    154                         returnStmt->set_expr( new VariableExpr( returnVals.front() ) );
     156                        returnStmt->set_expr( new VariableExpr( newObj ) );
    155157                } // if
    156158                return returnStmt;
     
    158160
    159161        DeclarationWithType* ReturnFixer::mutate( FunctionDecl *functionDecl ) {
     162                // xxx - need to handle named return values - this pass may need to happen
     163                // after resolution? the ordering is tricky because return statements must be
     164                // constructed - the simplest way to do that (while also handling multiple
     165                // 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 lost
     168                // in conversion to a tuple. this might be easiest to deal with
     169                // after reference types are added, as it may then be possible to
     170                // uniformly move named return values to the parameter list directly
    160171                ValueGuard< FunctionType * > oldFtype( ftype );
    161172                ValueGuard< std::string > oldFuncName( funcName );
    162173
    163174                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                }
    164182                funcName = functionDecl->get_name();
    165                 return Parent::mutate( functionDecl );
     183                DeclarationWithType * decl = Mutator::mutate( functionDecl );
     184                return decl;
    166185        }
    167186
     
    227246                        }
    228247                }
    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 );
     248                return managedTypes.find( SymTab::Mangler::mangle( type ) ) != managedTypes.end();
    231249        }
    232250
  • src/ResolvExpr/AdjustExprType.cc

    r66f8528 r596f987b  
    9797                EqvClass eqvClass;
    9898                if ( env.lookup( typeInst->get_name(), eqvClass ) ) {
    99                         if ( eqvClass.data.kind == TypeDecl::Ftype ) {
     99                        if ( eqvClass.kind == TypeDecl::Ftype ) {
    100100                                PointerType *pointerType = new PointerType( Type::Qualifiers(), typeInst );
    101101                                return pointerType;
  • src/ResolvExpr/AlternativeFinder.cc

    r66f8528 r596f987b  
    4444#include "InitTweak/GenInit.h"
    4545#include "ResolveTypeof.h"
    46 #include "Resolver.h"
    4746
    4847extern bool resolvep;
     
    186185                        if ( alternatives.begin() == oldBegin ) {
    187186                                std::ostringstream stream;
    188                                 stream << "Can't choose between " << alternatives.size() << " alternatives for expression ";
     187                                stream << "Can't choose between alternatives for expression ";
    189188                                expr->print( stream );
    190189                                stream << "Alternatives are:";
     
    309308                                        (*actualType)->print( std::cerr, 8 );
    310309                                        std::cerr << std::endl << " to ";
    311                                         (*formalType)->print( std::cerr, 8 );
     310                                        (*formal)->get_type()->print( std::cerr, 8 );
    312311                                )
    313312                                Cost newCost = conversionCost( *actualType, *formalType, indexer, alt.env );
     
    374373        void makeUnifiableVars( Type *type, OpenVarSet &unifiableVars, AssertionSet &needAssertions ) {
    375374                for ( Type::ForallList::const_iterator tyvar = type->get_forall().begin(); tyvar != type->get_forall().end(); ++tyvar ) {
    376                         unifiableVars[ (*tyvar)->get_name() ] = TypeDecl::Data{ *tyvar };
     375                        unifiableVars[ (*tyvar)->get_name() ] = (*tyvar)->get_kind();
    377376                        for ( std::list< DeclarationWithType* >::iterator assert = (*tyvar)->get_assertions().begin(); assert != (*tyvar)->get_assertions().end(); ++assert ) {
    378377                                needAssertions[ *assert ] = true;
     
    512511                if ( ! cur->second ) {
    513512                        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
    515513                }
    516514                DeclarationWithType *curDecl = cur->first;
    517 
    518515                PRINT(
    519516                        std::cerr << "inferRecursive: assertion is ";
     
    609606                makeUnifiableVars( funcType, openVars, resultNeed );
    610607                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 
    620608                if ( instantiateFunction( funcType->get_parameters(), actualAlt, funcType->get_isVarArgs(), openVars, resultEnv, resultNeed, resultHave, instantiatedActuals ) ) {
    621609                        ApplicationExpr *appExpr = new ApplicationExpr( func.expr->clone() );
     
    661649                AltList candidates;
    662650                SemanticError errors;
     651
    663652                for ( AltList::const_iterator func = funcFinder.alternatives.begin(); func != funcFinder.alternatives.end(); ++func ) {
    664653                        try {
     
    750739
    751740                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                 }
    765741        }
    766742
     
    782758        void AlternativeFinder::visit( CastExpr *castExpr ) {
    783759                Type *& toType = castExpr->get_result();
    784                 assert( toType );
    785760                toType = resolveTypeof( toType, indexer );
    786761                SymTab::validateType( toType, &indexer );
     
    788763
    789764                AlternativeFinder finder( indexer, env );
    790                 finder.targetType = toType;
    791765                finder.findWithAdjustment( castExpr->get_arg() );
    792766
     
    802776                        int discardedValues = (*i).expr->get_result()->size() - castExpr->get_result()->size();
    803777                        if ( discardedValues < 0 ) continue;
    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]))
     778                        // xxx - may need to go into tuple types and extract relavent types and use unifyList
    806779                        // unification run for side-effects
    807780                        unify( castExpr->get_result(), (*i).expr->get_result(), i->env, needAssertions, haveAssertions, openVars, indexer );
     
    810783                                // count one safe conversion for each value that is thrown away
    811784                                thisCost += Cost( 0, 0, discardedValues );
    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                                 }
     785                                CastExpr *newExpr = castExpr->clone();
     786                                newExpr->set_arg( i->expr->clone() );
     787                                candidates.push_back( Alternative( newExpr, i->env, i->cost, thisCost ) );
    837788                        } // if
    838789                } // for
     
    849800                AlternativeFinder funcFinder( indexer, env );
    850801                funcFinder.findWithAdjustment( memberExpr->get_aggregate() );
     802
    851803                for ( AltList::const_iterator agg = funcFinder.alternatives.begin(); agg != funcFinder.alternatives.end(); ++agg ) {
    852804                        if ( StructInstType *structInst = dynamic_cast< StructInstType* >( agg->expr->get_result() ) ) {
     
    11231075        }
    11241076
    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 
    11321077} // namespace ResolvExpr
    11331078
  • src/ResolvExpr/AlternativeFinder.h

    r66f8528 r596f987b  
    7070                virtual void visit( TupleAssignExpr *tupleExpr );
    7171                virtual void visit( UniqueExpr *unqExpr );
    72                 virtual void visit( StmtExpr *stmtExpr );
    7372                /// Runs a new alternative finder on each element in [begin, end)
    7473                /// and writes each alternative finder to out.
     
    9291                AltList alternatives;
    9392                const TypeEnvironment &env;
    94                 Type * targetType = nullptr;
    9593        }; // AlternativeFinder
    9694
  • src/ResolvExpr/CommonType.cc

    r66f8528 r596f987b  
    5858                Type *result = visitor.get_result();
    5959                if ( ! result ) {
    60                         // this appears to be handling for opaque type declarations
    6160                        if ( widenSecond ) {
    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 );
     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 );
    6567                                                if ( type->get_base() ) {
    6668                                                        Type::Qualifiers tq1 = type1->get_qualifiers(), tq2 = type2->get_qualifiers();
     
    156158                result->get_qualifiers() += otherPointer->get_qualifiers();
    157159        }
    158 
     160       
    159161        void CommonType::visit( PointerType *pointerType ) {
    160162                if ( PointerType *otherPointer = dynamic_cast< PointerType* >( type2 ) ) {
     
    221223                        NamedTypeDecl *nt = indexer.lookupType( inst->get_name() );
    222224                        if ( nt ) {
    223                                 TypeDecl *type = safe_dynamic_cast< TypeDecl* >( nt );
     225                                TypeDecl *type = dynamic_cast< TypeDecl* >( nt );
     226                                assert( type );
    224227                                if ( type->get_base() ) {
    225228                                        Type::Qualifiers tq1 = inst->get_qualifiers(), tq2 = type2->get_qualifiers();
  • src/ResolvExpr/FindOpenVars.cc

    r66f8528 r596f987b  
    4848                if ( nextIsOpen ) {
    4949                        for ( Type::ForallList::const_iterator i = type->get_forall().begin(); i != type->get_forall().end(); ++i ) {
    50                                 openVars[ (*i)->get_name() ] = TypeDecl::Data{ (*i) };
     50                                openVars[ (*i)->get_name() ] = (*i)->get_kind();
    5151                                for ( std::list< DeclarationWithType* >::const_iterator assert = (*i)->get_assertions().begin(); assert != (*i)->get_assertions().end(); ++assert ) {
    5252                                        needAssertions[ *assert ] = false;
     
    5757                } else {
    5858                        for ( Type::ForallList::const_iterator i = type->get_forall().begin(); i != type->get_forall().end(); ++i ) {
    59                                 closedVars[ (*i)->get_name() ] = TypeDecl::Data{ (*i) };
     59                                closedVars[ (*i)->get_name() ] = (*i)->get_kind();
    6060                                for ( std::list< DeclarationWithType* >::const_iterator assert = (*i)->get_assertions().begin(); assert != (*i)->get_assertions().end(); ++assert ) {
    6161                                        haveAssertions[ *assert ] = false;
  • src/ResolvExpr/PtrsCastable.cc

    r66f8528 r596f987b  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // PtrsCastable.cc --
     7// PtrsCastable.cc -- 
    88//
    99// Author           : Richard C. Bilson
     
    2525          public:
    2626                PtrsCastable( Type *dest, const TypeEnvironment &env, const SymTab::Indexer &indexer );
    27 
     27 
    2828                int get_result() const { return result; }
    2929
     
    6161                                } //if
    6262                        } else if ( env.lookup( typeInst->get_name(), eqvClass ) ) {
    63                                 if ( eqvClass.data.kind == TypeDecl::Ftype ) {
     63                                if ( eqvClass.kind == TypeDecl::Ftype ) {
    6464                                        return -1;
    6565                                } // if
  • src/ResolvExpr/Resolver.cc

    r66f8528 r596f987b  
    3636          public:
    3737                Resolver() : SymTab::Indexer( false ) {}
    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;
     38
     39                using SymTab::Indexer::visit;
    4840                virtual void visit( FunctionDecl *functionDecl ) override;
    4941                virtual void visit( ObjectDecl *functionDecl ) override;
     
    7466                void handlePtrType( PtrType * type );
    7567
    76           void resolveAggrInit( ReferenceToType *, InitIterator &, InitIterator & );
    77           void resolveSingleAggrInit( Declaration *, InitIterator &, InitIterator &, TypeSubstitution sub );
     68          void resolveAggrInit( AggregateDecl *, InitIterator &, InitIterator & );
     69          void resolveSingleAggrInit( Declaration *, InitIterator &, InitIterator & );
    7870          void fallbackInit( ConstructorInit * ctorInit );
    7971
     
    200192                        initContext = new BasicType( Type::Qualifiers(), BasicType::SignedInt );
    201193                }
    202                 Parent::visit( objectDecl );
     194                SymTab::Indexer::visit( objectDecl );
    203195                if ( inEnumDecl && dynamic_cast< EnumInstType * >( initContext ) ) {
    204196                        // delete newly created signed int type
     
    220212        void Resolver::visit( ArrayType * at ) {
    221213                handlePtrType( at );
    222                 Parent::visit( at );
     214                Visitor::visit( at );
    223215        }
    224216
    225217        void Resolver::visit( PointerType * pt ) {
    226218                handlePtrType( pt );
    227                 Parent::visit( pt );
     219                Visitor::visit( pt );
    228220        }
    229221
     
    233225                        typeDecl->set_base( new_type );
    234226                } // if
    235                 Parent::visit( typeDecl );
     227                SymTab::Indexer::visit( typeDecl );
    236228        }
    237229
     
    246238                ValueGuard< Type * > oldFunctionReturn( functionReturn );
    247239                functionReturn = ResolvExpr::extractResultType( functionDecl->get_functionType() );
    248                 Parent::visit( functionDecl );
     240                SymTab::Indexer::visit( functionDecl );
    249241        }
    250242
    251243        void Resolver::visit( EnumDecl * enumDecl ) {
    252244                // in case we decide to allow nested enums
    253                 ValueGuard< bool > oldInEnumDecl( inEnumDecl );
     245                bool oldInEnumDecl = inEnumDecl;
    254246                inEnumDecl = true;
    255                 Parent::visit( enumDecl );
     247                SymTab::Indexer::visit( enumDecl );
     248                inEnumDecl = oldInEnumDecl;
    256249        }
    257250
    258251        void Resolver::visit( ExprStmt *exprStmt ) {
    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 );
     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
    263257        }
    264258
     
    283277                delete ifStmt->get_condition();
    284278                ifStmt->set_condition( newExpr );
    285                 Parent::visit( ifStmt );
     279                Visitor::visit( ifStmt );
    286280        }
    287281
     
    290284                delete whileStmt->get_condition();
    291285                whileStmt->set_condition( newExpr );
    292                 Parent::visit( whileStmt );
     286                Visitor::visit( whileStmt );
    293287        }
    294288
    295289        void Resolver::visit( ForStmt *forStmt ) {
    296                 Parent::visit( forStmt );
     290                SymTab::Indexer::visit( forStmt );
    297291
    298292                if ( forStmt->get_condition() ) {
     
    324318
    325319        void Resolver::visit( CaseStmt *caseStmt ) {
    326                 Parent::visit( caseStmt );
     320                Visitor::visit( caseStmt );
    327321        }
    328322
     
    402396        }
    403397
    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 ) {
     398        void Resolver::resolveSingleAggrInit( Declaration * dcl, InitIterator & init, InitIterator & initEnd ) {
    424399                DeclarationWithType * dt = dynamic_cast< DeclarationWithType * >( dcl );
    425400                assert( dt );
    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 
     401                initContext = dt->get_type();
    430402                try {
    431403                        if ( init == initEnd ) return; // stop when there are no more initializers
     
    434406                } catch( SemanticError & ) {
    435407                        // need to delve deeper, if you can
    436                         if ( ReferenceToType * type = isStructOrUnion( initContext ) ) {
    437                                 resolveAggrInit( type, init, initEnd );
     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 );
    438412                        } else {
    439413                                // member is not an aggregate type, so can't go any deeper
     
    445419        }
    446420
    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();
     421        void Resolver::resolveAggrInit( AggregateDecl * aggr, InitIterator & init, InitIterator & initEnd ) {
     422                if ( StructDecl * st = dynamic_cast< StructDecl * >( aggr ) ) {
    451423                        // want to resolve each initializer to the members of the struct,
    452424                        // but if there are more initializers than members we should stop
    453425                        list< Declaration * >::iterator it = st->get_members().begin();
    454426                        for ( ; it != st->get_members().end(); ++it) {
    455                                 resolveSingleAggrInit( *it, init, initEnd, sub );
     427                                resolveSingleAggrInit( *it, init, initEnd );
    456428                        }
    457                 } else if ( UnionInstType * uit = dynamic_cast< UnionInstType * >( inst ) ) {
    458                         TypeSubstitution sub = makeGenericSubstitutuion( uit );
    459                         UnionDecl * un = uit->get_baseUnion();
     429                } else if ( UnionDecl * un = dynamic_cast< UnionDecl * >( aggr ) ) {
    460430                        // only resolve to the first member of a union
    461                         resolveSingleAggrInit( *un->get_members().begin(), init, initEnd, sub );
     431                        resolveSingleAggrInit( *un->get_members().begin(), init, initEnd );
    462432                } // if
    463433        }
     
    479449                                (*iter++)->accept( *this );
    480450                        }
    481                 } else if ( ReferenceToType * type = isStructOrUnion( initContext ) ) {
    482                         resolveAggrInit( type, iter, end );
     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 );
    483455                } else if ( TypeInstType * tt = dynamic_cast< TypeInstType * >( initContext ) ) {
    484456                        Type * base = tt->get_baseType()->get_base();
     
    489461                        } else {
    490462                                // missing implementation type -- might be an unknown type variable, so try proceeding with the current init context
    491                                 Parent::visit( listInit );
     463                                Visitor::visit( listInit );
    492464                        }
    493465                } else {
    494466                        assert( dynamic_cast< BasicType * >( initContext ) || dynamic_cast< PointerType * >( initContext )
    495                                 || dynamic_cast< ZeroType * >( initContext ) || dynamic_cast< OneType * >( initContext ) || dynamic_cast < EnumInstType * > ( initContext ) );
     467                                || dynamic_cast< ZeroType * >( initContext ) || dynamic_cast< OneType * >( initContext ) );
    496468                        // basic types are handled here
    497                         Parent::visit( listInit );
     469                        Visitor::visit( listInit );
    498470                }
    499471
     
    561533        }
    562534
    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 
    576535        void Resolver::visit( ConstructorInit *ctorInit ) {
    577536                // xxx - fallback init has been removed => remove fallbackInit function and remove complexity from FixInit and remove C-init from ConstructorInit
  • src/ResolvExpr/Resolver.h

    r66f8528 r596f987b  
    2525        Expression *resolveInVoidContext( Expression *expr, const SymTab::Indexer &indexer );
    2626        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 );
    2927} // namespace ResolvExpr
    3028
  • src/ResolvExpr/TypeEnvironment.cc

    r66f8528 r596f987b  
    3232        //
    3333        // 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 ) const {
     34        bool AssertCompare::operator()( DeclarationWithType * d1, DeclarationWithType * d2 ) {
    3535                        // Objects are always less than functions
    3636                        if ( ObjectDecl * objectDecl1 = dynamic_cast< ObjectDecl * >( d1 ) ) {
     
    9494                dest.type = maybeClone( src.type );
    9595                dest.allowWidening = src.allowWidening;
    96                 dest.data = src.data;
     96                dest.kind = src.kind;
    9797        }
    9898
     
    162162                        EqvClass newClass;
    163163                        newClass.vars.insert( (*i)->get_name() );
    164                         newClass.data = TypeDecl::Data{ (*i) };
     164                        newClass.kind = (*i)->get_kind();
    165165                        env.push_back( newClass );
    166166                } // for
     
    177177                                        sub.add( *theVar, theClass->type );
    178178                                } else if ( theVar != theClass->vars.begin() ) {
    179                                         TypeInstType *newTypeInst = new TypeInstType( Type::Qualifiers(), *theClass->vars.begin(), theClass->data.kind == TypeDecl::Ftype );
     179                                        TypeInstType *newTypeInst = new TypeInstType( Type::Qualifiers(), *theClass->vars.begin(), theClass->kind == TypeDecl::Ftype );
    180180///         std::cout << " bound to variable " << *theClass->vars.begin() << std::endl;
    181181                                        sub.add( *theVar, newTypeInst );
     
    243243                for ( std::list< EqvClass >::const_iterator eqvClass = env.begin(); eqvClass != env.end(); ++eqvClass ) {
    244244                        for ( std::set< std::string >::const_iterator var = eqvClass->vars.begin(); var != eqvClass->vars.end(); ++var ) {
    245                                 openVars[ *var ] = eqvClass->data;
     245                                openVars[ *var ] = eqvClass->kind;
    246246                        } // for
    247247                } // for
  • src/ResolvExpr/TypeEnvironment.h

    r66f8528 r596f987b  
    2929namespace ResolvExpr {
    3030        struct AssertCompare {
    31                 bool operator()( DeclarationWithType * d1, DeclarationWithType * d2 ) const;
     31                bool operator()( DeclarationWithType * d1, DeclarationWithType * d2 );
    3232        };
    3333        typedef std::map< DeclarationWithType*, bool, AssertCompare > AssertionSet;
    34         typedef std::map< std::string, TypeDecl::Data > OpenVarSet;
     34        typedef std::map< std::string, TypeDecl::Kind > OpenVarSet;
    3535
    3636        void printAssertionSet( const AssertionSet &, std::ostream &, int indent = 0 );
     
    4141                Type *type;
    4242                bool allowWidening;
    43                 TypeDecl::Data data;
     43                TypeDecl::Kind kind;
    4444
    4545                void initialize( const EqvClass &src, EqvClass &dest );
  • src/ResolvExpr/Unify.cc

    r66f8528 r596f987b  
    9999                newFirst->get_qualifiers() = Type::Qualifiers();
    100100                newSecond->get_qualifiers() = Type::Qualifiers();
    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;
     101///   std::cout << "first is ";
     102///   first->print( std::cout );
     103///   std::cout << std::endl << "second is ";
     104///   second->print( std::cout );
     105///   std::cout << std::endl << "newFirst is ";
     106///   newFirst->print( std::cout );
     107///   std::cout << std::endl << "newSecond is ";
     108///   newSecond->print( std::cout );
     109///   std::cout << std::endl;
    110110                bool result = unifyExact( newFirst, newSecond, newEnv, needAssertions, haveAssertions, openVars, WidenMode( false, false ), indexer );
    111111                delete newFirst;
     
    123123        }
    124124
    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 ) {
     125        bool tyVarCompatible( TypeDecl::Kind kind, Type *type, const SymTab::Indexer &indexer ) {
     126                switch ( kind ) {
    154127                  case TypeDecl::Any:
    155128                  case TypeDecl::Dtype:
    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 ));
     129                        return ! isFtype( type, indexer );
     130
    160131                  case TypeDecl::Ftype:
    161132                        return isFtype( type, indexer );
     
    165136        }
    166137
    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 ) {
     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 ) {
    168139                OpenVarSet::const_iterator tyvar = openVars.find( typeInst->get_name() );
    169140                assert( tyvar != openVars.end() );
     
    204175                        newClass.type->get_qualifiers() = Type::Qualifiers();
    205176                        newClass.allowWidening = widenMode.widenFirst && widenMode.widenSecond;
    206                         newClass.data = data;
     177                        newClass.kind = kind;
    207178                        env.add( newClass );
    208179                } // if
     
    210181        }
    211182
    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 ) {
     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 ) {
    213184                bool result = true;
    214185                EqvClass class1, class2;
     
    239210
    240211                if ( type1 && type2 ) {
    241 //    std::cerr << "has type1 && type2" << std::endl;
     212//    std::cout << "has type1 && type2" << std::endl;
    242213                        WidenMode newWidenMode ( widen1, widen2 );
    243214                        Type *common = 0;
     
    277248                        newClass.vars.insert( var2->get_name() );
    278249                        newClass.allowWidening = widen1 && widen2;
    279                         newClass.data = data;
     250                        newClass.kind = kind;
    280251                        env.add( newClass );
    281252                } // if
     
    340311                } // if
    341312#ifdef DEBUG
    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;
     313                std::cout << "============ unifyExact" << std::endl;
     314                std::cout << "type1 is ";
     315                type1->print( std::cout );
     316                std::cout << std::endl << "type2 is ";
     317                type2->print( std::cout );
     318                std::cout << std::endl << "openVars are ";
     319                printOpenVarSet( openVars, std::cout, 8 );
     320                std::cout << std::endl << "input env is " << std::endl;
     321                debugEnv.print( std::cout, 8 );
     322                std::cout << std::endl << "result env is " << std::endl;
     323                env.print( std::cout, 8 );
     324                std::cout << "result is " << result << std::endl;
    354325#endif
    355326                return result;
     
    366337                bool result;
    367338#ifdef DEBUG
    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;
     339                std::cout << "unifyInexact type 1 is ";
     340                type1->print( std::cout );
     341                std::cout << "type 2 is ";
     342                type2->print( std::cout );
     343                std::cout << std::endl;
    373344#endif
    374345                if ( ! unifyExact( type1, type2, env, needAssertions, haveAssertions, openVars, widenMode, indexer ) ) {
    375346#ifdef DEBUG
    376                         std::cerr << "unifyInexact: no exact unification found" << std::endl;
     347                        std::cout << "unifyInexact: no exact unification found" << std::endl;
    377348#endif
    378349                        if ( ( common = commonType( type1, type2, widenMode.widenFirst, widenMode.widenSecond, indexer, env, openVars ) ) ) {
    379350                                common->get_qualifiers() = tq1 + tq2;
    380351#ifdef DEBUG
    381                                 std::cerr << "unifyInexact: common type is ";
    382                                 common->print( std::cerr );
    383                                 std::cerr << std::endl;
     352                                std::cout << "unifyInexact: common type is ";
     353                                common->print( std::cout );
     354                                std::cout << std::endl;
    384355#endif
    385356                                result = true;
    386357                        } else {
    387358#ifdef DEBUG
    388                                 std::cerr << "unifyInexact: no common type found" << std::endl;
     359                                std::cout << "unifyInexact: no common type found" << std::endl;
    389360#endif
    390361                                result = false;
     
    423394
    424395        void markAssertionSet( AssertionSet &assertions, DeclarationWithType *assert ) {
    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;
     396///   std::cout << "assertion set is" << std::endl;
     397///   printAssertionSet( assertions, std::cout, 8 );
     398///   std::cout << "looking for ";
     399///   assert->print( std::cout );
     400///   std::cout << std::endl;
    430401                AssertionSet::iterator i = assertions.find( assert );
    431402                if ( i != assertions.end() ) {
    432 ///     std::cerr << "found it!" << std::endl;
     403///     std::cout << "found it!" << std::endl;
    433404                        i->second = true;
    434405                } // if
  • src/ResolvExpr/Unify.h

    r66f8528 r596f987b  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // Unify.h --
     7// Unify.h -- 
    88//
    99// Author           : Richard C. Bilson
     
    3737                bool widenFirst : 1, widenSecond : 1;
    3838        };
    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 );
     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 );
    4141        bool unify( Type *type1, Type *type2, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, OpenVarSet &openVars, const SymTab::Indexer &indexer );
    4242        bool unify( Type *type1, Type *type2, TypeEnvironment &env, AssertionSet &needAssertions, AssertionSet &haveAssertions, OpenVarSet &openVars, const SymTab::Indexer &indexer, Type *&commonType );
  • src/SymTab/Autogen.cc

    r66f8528 r596f987b  
    2424#include "MakeLibCfa.h"
    2525#include "Autogen.h"
    26 #include "GenPoly/ScopedSet.h"
    27 #include "SymTab/Mangler.h"
    28 #include "GenPoly/DeclMutator.h"
    2926
    3027namespace SymTab {
     
    3229
    3330        class AutogenerateRoutines : public Visitor {
    34           public:
     31                public:
    3532                std::list< Declaration * > &get_declsToAdd() { return declsToAdd; }
    36 
    37                 typedef Visitor Parent;
    38                 using Parent::visit;
    3933
    4034                virtual void visit( EnumDecl *enumDecl );
     
    5145                virtual void visit( SwitchStmt *switchStmt );
    5246
    53           private:
     47                AutogenerateRoutines() : functionNesting( 0 ) {}
     48                private:
    5449                template< typename StmtClass > void visitStatement( StmtClass *stmt );
    5550
    5651                std::list< Declaration * > declsToAdd;
    5752                std::set< std::string > structsDone;
    58                 unsigned int functionNesting = 0;     // current level of nested functions
     53                unsigned int functionNesting;     // current level of nested functions
    5954        };
    6055
    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 
    8056        void autogenerateRoutines( std::list< Declaration * > &translationUnit ) {
    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 );
     57                AutogenerateRoutines visitor;
     58                acceptAndAdd( translationUnit, visitor, false );
    8759        }
    8860
     
    9163        }
    9264
    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
     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
    140100                // because each unit generates copies of the default routines for each aggregate.
    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 ) {
     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
    150113                // enum copy construct and assignment is just C-style assignment.
    151114                // this looks like a bad recursive call, but code gen will turn it into
    152115                // a C-style assignment.
    153116                // 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 
    161117                VariableExpr * assignVarExpr = new VariableExpr( assignDecl );
    162118                Type * assignVarExprType = assignVarExpr->get_result();
     
    166122                assignExpr->get_args().push_back( new VariableExpr( dstParam ) );
    167123                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 );
    195124
    196125                // body is either return stmt or expr stmt
    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 
     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 );
    200130                declsToAdd.push_back( ctorDecl );
    201131                declsToAdd.push_back( copyCtorDecl );
    202132                declsToAdd.push_back( dtorDecl );
    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 ) {
     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
    208181                ObjectDecl * returnVal = NULL;
    209182                if ( ! func->get_functionType()->get_returnVals().empty() ) {
     
    214187
    215188                // assign to destination (and return value if generic)
    216                 UntypedExpr *derefExpr = UntypedExpr::createDeref( new VariableExpr( dstParam ) );
     189                UntypedExpr *derefExpr = new UntypedExpr( new NameExpr( "*?" ) );
     190                derefExpr->get_args().push_back( new VariableExpr( dstParam ) );
    217191                Expression *dstselect = new MemberExpr( field, derefExpr );
    218192                genImplicitCall( srcParam, dstselect, func->get_name(), back_inserter( func->get_statements()->get_kids() ), field, forward );
    219193
    220194                if ( isDynamicLayout && returnVal ) {
    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 ) );
     195                        UntypedExpr *derefRet = new UntypedExpr( new NameExpr( "*?" ) );
     196                        derefRet->get_args().push_back( new VariableExpr( returnVal ) );
     197                        Expression *retselect = new MemberExpr( field, derefRet );
    223198                        genImplicitCall( srcParam, retselect, func->get_name(), back_inserter( func->get_statements()->get_kids() ), field, forward );
    224199                } // if
    225200        }
    226201
    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
    228202        template<typename Iterator>
    229         void makeStructFunctionBody( Iterator member, Iterator end, FunctionDecl * func, bool isDynamicLayout, bool forward = true ) {
     203        void makeStructFunctionBody( Iterator member, Iterator end, FunctionDecl * func, TypeSubstitution & genericSubs, bool isDynamicLayout, bool forward = true ) {
    230204                for ( ; member != end; ++member ) {
    231205                        if ( DeclarationWithType *field = dynamic_cast< DeclarationWithType * >( *member ) ) { // otherwise some form of type declaration, e.g. Aggregate
     
    263237
    264238                                Expression *srcselect = srcParam ? new MemberExpr( field, new VariableExpr( srcParam ) ) : NULL;
    265                                 makeStructMemberOp( dstParam, srcselect, field, func, isDynamicLayout, forward );
     239                                makeStructMemberOp( dstParam, srcselect, field, func, genericSubs, isDynamicLayout, forward );
    266240                        } // if
    267241                } // for
     
    271245        /// void ?{}(A *, int) and void?{}(A *, int, int) for a struct A which has two int fields.
    272246        template<typename Iterator>
    273         void makeStructFieldCtorBody( Iterator member, Iterator end, FunctionDecl * func, bool isDynamicLayout ) {
     247        void makeStructFieldCtorBody( Iterator member, Iterator end, FunctionDecl * func, TypeSubstitution & genericSubs, bool isDynamicLayout ) {
    274248                FunctionType * ftype = func->get_functionType();
    275249                std::list<DeclarationWithType*> & params = ftype->get_parameters();
     
    297271                                        // matching parameter, initialize field with copy ctor
    298272                                        Expression *srcselect = new VariableExpr(*parameter);
    299                                         makeStructMemberOp( dstParam, srcselect, field, func, isDynamicLayout );
     273                                        makeStructMemberOp( dstParam, srcselect, field, func, genericSubs, isDynamicLayout );
    300274                                        ++parameter;
    301275                                } else {
    302276                                        // no matching parameter, initialize field with default ctor
    303                                         makeStructMemberOp( dstParam, NULL, field, func, isDynamicLayout );
     277                                        makeStructMemberOp( dstParam, NULL, field, func, genericSubs, isDynamicLayout );
    304278                                }
    305279                        }
     
    307281        }
    308282
    309         /// generates struct constructors, destructor, and assignment functions
     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
    310291        void makeStructFunctions( StructDecl *aggregateDecl, StructInstType *refType, unsigned int functionNesting, std::list< Declaration * > & declsToAdd ) {
     292                FunctionType *assignType = new FunctionType( Type::Qualifiers(), false );
    311293
    312294                // Make function polymorphic in same parameters as generic struct, if applicable
    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)
     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 );
     310
     311                // 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 );
     317
     318                // void ?{}(T *, T);
     319                FunctionType *copyCtorType = assignType->clone();
    315320
    316321                // T ?=?(T *, T);
    317                 FunctionType *assignType = genAssignType( refType );
    318                 cloneAll( typeParams, assignType->get_forall() );
    319 
    320                 // void ?{}(T *); void ^?{}(T *);
    321                 FunctionType *ctorType = genDefaultType( refType );
    322                 cloneAll( typeParams, ctorType->get_forall() );
    323                 FunctionType *dtorType = genDefaultType( refType );
    324                 cloneAll( typeParams, dtorType->get_forall() );
    325 
    326                 // void ?{}(T *, T);
    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 );
     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();
    334335
    335336                if ( functionNesting == 0 ) {
    336337                        // forward declare if top-level struct, so that
    337338                        // 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.
    340339                        addForwardDecl( assignDecl, declsToAdd );
    341340                        addForwardDecl( ctorDecl, declsToAdd );
     
    366365                        }
    367366                        memCtorType->get_parameters().push_back( new ObjectDecl( member->get_name(), DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, member->get_type()->clone(), 0 ) );
    368                         FunctionDecl * ctor = genFunc( "?{}", memCtorType->clone(), functionNesting );
    369                         makeStructFieldCtorBody( aggregateDecl->get_members().begin(), aggregateDecl->get_members().end(), ctor, isDynamicLayout );
     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 );
    370370                        memCtors.push_back( ctor );
    371371                }
     
    373373
    374374                // generate appropriate calls to member ctor, assignment
    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 );
     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 );
    378378                // needs to do everything in reverse, so pass "forward" as false
    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 
     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 );
    385384                declsToAdd.push_back( ctorDecl );
    386385                declsToAdd.push_back( copyCtorDecl );
    387386                declsToAdd.push_back( dtorDecl );
    388                 declsToAdd.push_back( assignDecl ); // assignment should come last since it uses copy constructor in return
    389387                declsToAdd.splice( declsToAdd.end(), memCtors );
    390388        }
    391389
    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
    421390        void makeUnionFunctions( UnionDecl *aggregateDecl, UnionInstType *refType, unsigned int functionNesting, std::list< Declaration * > & declsToAdd ) {
     391                FunctionType *assignType = new FunctionType( Type::Qualifiers(), false );
     392
    422393                // Make function polymorphic in same parameters as generic union, if applicable
    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)
     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 );
    425406
    426407                // default ctor/dtor need only first parameter
    427                 // void ?{}(T *); void ^?{}(T *);
    428                 FunctionType *ctorType = genDefaultType( refType );
    429                 FunctionType *dtorType = genDefaultType( refType );
     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 );
    430413
    431414                // copy ctor needs both parameters
    432                 // void ?{}(T *, T);
    433                 FunctionType *copyCtorType = genCopyType( refType );
     415                FunctionType * copyCtorType = assignType->clone();
    434416
    435417                // assignment needs both and return value
    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() );
     418                ObjectDecl *returnVal = new ObjectDecl( "_ret", DeclarationNode::NoStorageClass, LinkageSpec::Cforall, 0, cloneWithParams( refType, unionParams ), 0 );
     419                assignType->get_returnVals().push_back( returnVal );
    443420
    444421                // Routines at global scope marked "static" to prevent multiple definitions is separate translation units
    445422                // because each unit generates copies of the default routines for each aggregate.
    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 );
     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 ) ) );
    452436
    453437                // body of assignment and copy ctor is the same
    454                 makeUnionAssignBody( copyCtorDecl, isDynamicLayout );
     438                copyCtorDecl->set_statements( assignDecl->get_statements()->clone() );
    455439
    456440                // create a constructor which takes the first member type as a parameter.
     
    465449                                FunctionType * memCtorType = ctorType->clone();
    466450                                memCtorType->get_parameters().push_back( srcParam );
    467                                 FunctionDecl * ctor = genFunc( "?{}", memCtorType, functionNesting );
    468 
    469                                 makeUnionAssignBody( ctor, isDynamicLayout );
     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() ) );
    470455                                memCtors.push_back( ctor );
    471456                                // only generate a ctor for the first field
     
    474459                }
    475460
     461                declsToAdd.push_back( assignDecl );
    476462                declsToAdd.push_back( ctorDecl );
    477463                declsToAdd.push_back( copyCtorDecl );
    478464                declsToAdd.push_back( dtorDecl );
    479                 declsToAdd.push_back( assignDecl ); // assignment should come last since it uses copy constructor in return
    480465                declsToAdd.splice( declsToAdd.end(), memCtors );
    481466        }
     
    493478                if ( ! structDecl->get_members().empty() && structsDone.find( structDecl->get_name() ) == structsDone.end() ) {
    494479                        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                         }
    498480                        structInst.set_baseStruct( structDecl );
    499481                        makeStructFunctions( structDecl, &structInst, functionNesting, declsToAdd );
     
    506488                        UnionInstType unionInst( Type::Qualifiers(), unionDecl->get_name() );
    507489                        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                         }
    511490                        makeUnionFunctions( unionDecl, &unionInst, functionNesting, declsToAdd );
    512491                } // if
     
    514493
    515494        void AutogenerateRoutines::visit( TypeDecl *typeDecl ) {
     495                CompoundStmt *stmts = 0;
    516496                TypeInstType *typeInst = new TypeInstType( Type::Qualifiers(), typeDecl->get_name(), false );
    517497                typeInst->set_baseType( typeDecl );
    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;
     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 );
    522500                if ( typeDecl->get_base() ) {
    523501                        // xxx - generate ctor/dtors for typedecls, e.g.
    524502                        // otype T = int *;
     503                        stmts = new CompoundStmt( std::list< Label >() );
    525504                        UntypedExpr *assign = new UntypedExpr( new NameExpr( "?=?" ) );
    526505                        assign->get_args().push_back( new CastExpr( new VariableExpr( dst ), new PointerType( Type::Qualifiers(), typeDecl->get_base()->clone() ) ) );
    527506                        assign->get_args().push_back( new CastExpr( new VariableExpr( src ), typeDecl->get_base()->clone() ) );
    528                         stmts.push_back( new ReturnStmt( std::list< Label >(), assign ) );
     507                        stmts->get_kids().push_back( new ReturnStmt( std::list< Label >(), assign ) );
    529508                } // if
    530509                FunctionType *type = new FunctionType( Type::Qualifiers(), false );
     
    532511                type->get_parameters().push_back( dst );
    533512                type->get_parameters().push_back( src );
    534                 FunctionDecl *func = genFunc( "?=?", type, functionNesting );
    535                 func->get_statements()->get_kids() = stmts;
     513                FunctionDecl *func = new FunctionDecl( "?=?", DeclarationNode::NoStorageClass, LinkageSpec::AutoGen, type, stmts, true, false );
    536514                declsToAdd.push_back( func );
    537515        }
     
    578556                visitStatement( switchStmt );
    579557        }
    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         }
    666558} // SymTab
  • src/SymTab/Indexer.cc

    r66f8528 r596f987b  
    4040
    4141namespace SymTab {
    42         struct NewScope {
    43                 NewScope( SymTab::Indexer & indexer ) : indexer( indexer ) { indexer.enterScope(); }
    44                 ~NewScope() { indexer.leaveScope(); }
    45                 SymTab::Indexer & indexer;
    46         };
    47 
    4842        template< typename TreeType, typename VisitorType >
    4943        inline void acceptNewScope( TreeType *tree, VisitorType &visitor ) {
     
    460454        void Indexer::visit( TupleAssignExpr *tupleExpr ) {
    461455                acceptNewScope( tupleExpr->get_result(), *this );
    462                 maybeAccept( tupleExpr->get_stmtExpr(), *this );
     456                enterScope();
     457                acceptAll( tupleExpr->get_tempDecls(), *this );
     458                acceptAll( tupleExpr->get_assigns(), *this );
     459                leaveScope();
    463460        }
    464461
  • src/SymTab/Indexer.h

    r66f8528 r596f987b  
    2525        class Indexer : public Visitor {
    2626          public:
    27                 explicit Indexer( bool useDebug = false );
     27                Indexer( bool useDebug = false );
    2828
    2929                Indexer( const Indexer &that );
  • src/SymTab/Validate.cc

    r66f8528 r596f987b  
    6161#include <algorithm>
    6262#include "InitTweak/InitTweak.h"
    63 #include "CodeGen/CodeGenerator.h"
    6463
    6564#define debugPrint( x ) if ( doDebug ) { std::cout << x; }
    6665
    6766namespace SymTab {
    68         class HoistStruct final : public Visitor {
     67        class HoistStruct : public Visitor {
    6968          public:
    7069                /// Flattens nested struct types
     
    8786        };
    8887
    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 
    10388        /// Replaces enum types by int, and function or array types in function parameter and return lists by appropriate pointers.
    104         class EnumAndPointerDecayPass final : public Visitor {
     89        class EnumAndPointerDecayPass : public Visitor {
    10590                typedef Visitor Parent;
    10691                virtual void visit( EnumDecl *aggregateDecl );
     
    10994
    11095        /// Associates forward declarations of aggregates with their definitions
    111         class LinkReferenceToTypes final : public Indexer {
     96        class Pass2 final : public Indexer {
    11297                typedef Indexer Parent;
    11398          public:
    114                 LinkReferenceToTypes( bool doDebug, const Indexer *indexer );
     99                Pass2( bool doDebug, const Indexer *indexer );
    115100          private:
    116101                using Indexer::visit;
     
    208193        void validate( std::list< Declaration * > &translationUnit, bool doDebug ) {
    209194                EnumAndPointerDecayPass epc;
    210                 LinkReferenceToTypes lrt( doDebug, 0 );
     195                Pass2 pass2( doDebug, 0 );
    211196                Pass3 pass3( 0 );
    212197                CompoundLiteral compoundliteral;
     
    214199                EliminateTypedef::eliminateTypedef( translationUnit );
    215200                HoistStruct::hoistStruct( translationUnit );
    216                 ReturnTypeFixer::fix( translationUnit ); // must happen before autogen
    217201                autogenerateRoutines( translationUnit ); // moved up, used to be below compoundLiteral - currently needs EnumAndPointerDecayPass
    218202                acceptAll( translationUnit, epc );
    219                 acceptAll( translationUnit, lrt );
     203                acceptAll( translationUnit, pass2 );
    220204                ReturnChecker::checkFunctionReturns( translationUnit );
    221205                compoundliteral.mutateDeclarationList( translationUnit );
     
    226210        void validateType( Type *type, const Indexer *indexer ) {
    227211                EnumAndPointerDecayPass epc;
    228                 LinkReferenceToTypes lrt( false, indexer );
     212                Pass2 pass2( false, indexer );
    229213                Pass3 pass3( indexer );
    230214                type->accept( epc );
    231                 type->accept( lrt );
     215                type->accept( pass2 );
    232216                type->accept( pass3 );
    233217        }
     
    340324        }
    341325
    342         LinkReferenceToTypes::LinkReferenceToTypes( bool doDebug, const Indexer *other_indexer ) : Indexer( doDebug ) {
     326        Pass2::Pass2( bool doDebug, const Indexer *other_indexer ) : Indexer( doDebug ) {
    343327                if ( other_indexer ) {
    344328                        indexer = other_indexer;
     
    348332        }
    349333
    350         void LinkReferenceToTypes::visit( StructInstType *structInst ) {
     334        void Pass2::visit( StructInstType *structInst ) {
    351335                Parent::visit( structInst );
    352336                StructDecl *st = indexer->lookupStruct( structInst->get_name() );
     
    362346        }
    363347
    364         void LinkReferenceToTypes::visit( UnionInstType *unionInst ) {
     348        void Pass2::visit( UnionInstType *unionInst ) {
    365349                Parent::visit( unionInst );
    366350                UnionDecl *un = indexer->lookupUnion( unionInst->get_name() );
     
    375359        }
    376360
    377         void LinkReferenceToTypes::visit( TraitInstType *contextInst ) {
     361        void Pass2::visit( TraitInstType *contextInst ) {
    378362                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                 }
    391363                TraitDecl *ctx = indexer->lookupTrait( contextInst->get_name() );
    392364                if ( ! ctx ) {
     
    414386        }
    415387
    416         void LinkReferenceToTypes::visit( StructDecl *structDecl ) {
     388        void Pass2::visit( StructDecl *structDecl ) {
    417389                // visit struct members first so that the types of self-referencing members are updated properly
    418390                Parent::visit( structDecl );
     
    428400        }
    429401
    430         void LinkReferenceToTypes::visit( UnionDecl *unionDecl ) {
     402        void Pass2::visit( UnionDecl *unionDecl ) {
    431403                Parent::visit( unionDecl );
    432404                if ( ! unionDecl->get_members().empty() ) {
     
    441413        }
    442414
    443         void LinkReferenceToTypes::visit( TypeInstType *typeInst ) {
     415        void Pass2::visit( TypeInstType *typeInst ) {
    444416                if ( NamedTypeDecl *namedTypeDecl = lookupType( typeInst->get_name() ) ) {
    445417                        if ( TypeDecl *typeDecl = dynamic_cast< TypeDecl * >( namedTypeDecl ) ) {
     
    612584
    613585                typedeclNames[ typeDecl->get_name() ] = typeDecl;
    614                 return Mutator::mutate( typeDecl );
     586                return typeDecl;
    615587        }
    616588
     
    763735                return new VariableExpr( newtempvar );
    764736        }
    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         }
    802737} // namespace SymTab
    803738
  • src/SynTree/ApplicationExpr.cc

    r66f8528 r596f987b  
    3030        if ( &other == this ) return *this;
    3131        decl = other.decl;
    32         // xxx - this looks like a memory leak
    3332        actualType = maybeClone( other.actualType );
    3433        formalType = maybeClone( other.formalType );
  • src/SynTree/CompoundStmt.cc

    r66f8528 r596f987b  
    4949                Statement * origStmt = *origit++;
    5050                if ( DeclStmt * declStmt = dynamic_cast< DeclStmt * >( s ) ) {
    51                         DeclStmt * origDeclStmt = safe_dynamic_cast< DeclStmt * >( origStmt );
     51                        DeclStmt * origDeclStmt = dynamic_cast< DeclStmt * >( origStmt );
     52                        assert( origDeclStmt );
    5253                        if ( DeclarationWithType * dwt = dynamic_cast< DeclarationWithType * > ( declStmt->get_decl() ) ) {
    53                                 DeclarationWithType * origdwt = safe_dynamic_cast< DeclarationWithType * > ( origDeclStmt->get_decl() );
     54                                DeclarationWithType * origdwt = dynamic_cast< DeclarationWithType * > ( origDeclStmt->get_decl() );
     55                                assert( origdwt );
    5456                                assert( dwt->get_name() == origdwt->get_name() );
    5557                                declMap[ origdwt ] = dwt;
    56                         } else assert( ! dynamic_cast< DeclarationWithType * > ( origDeclStmt->get_decl() ) );
    57                 } else assert( ! dynamic_cast< DeclStmt * > ( s ) );
     58                        }
     59                }
    5860        }
    5961        if ( ! declMap.empty() ) {
  • src/SynTree/Declaration.h

    r66f8528 r596f987b  
    180180  public:
    181181        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         };
    192182
    193183        TypeDecl( const std::string &name, DeclarationNode::StorageClass sc, Type *type, Kind kind );
     
    196186        Kind get_kind() const { return kind; }
    197187
    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 
    202188        virtual TypeDecl *clone() const { return new TypeDecl( *this ); }
    203189        virtual void accept( Visitor &v ) { v.visit( this ); }
     
    206192        virtual std::string typeString() const;
    207193        Kind kind;
    208         bool sized;
    209194};
    210195
     
    299284
    300285std::ostream & operator<<( std::ostream & out, const Declaration * decl );
    301 std::ostream & operator<<( std::ostream & os, const TypeDecl::Data & data );
    302286
    303287#endif // DECLARATION_H
  • src/SynTree/Expression.cc

    r66f8528 r596f987b  
    332332}
    333333
    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 
    346334
    347335MemberExpr::MemberExpr( DeclarationWithType *_member, Expression *_aggregate, Expression *_aname ) :
    348336                Expression( _aname ), member(_member), aggregate(_aggregate) {
    349 
    350         TypeSubstitution sub( makeSub( aggregate->get_result() ) );
    351         Type * res = member->get_type()->clone();
    352         sub.apply( res );
    353         set_result( res );
     337        set_result( member->get_type()->clone() );
    354338        get_result()->set_isLvalue( true );
    355339}
     
    527511
    528512ImplicitCopyCtorExpr::~ImplicitCopyCtorExpr() {
    529         set_env( nullptr ); // ImplicitCopyCtorExpr does not take ownership of an environment
    530513        delete callExpr;
    531514        deleteAll( tempDecls );
     
    537520        os <<  "Implicit Copy Constructor Expression: " << std::endl;
    538521        assert( callExpr );
    539         os << std::string( indent+2, ' ' );
    540522        callExpr->print( os, indent + 2 );
    541523        os << std::endl << std::string( indent, ' ' ) << "with temporaries:" << std::endl;
     
    589571        os << std::string( indent+2, ' ' );
    590572        initializer->print( os, indent + 2 );
    591         Expression::print( os, indent );
    592573}
    593574
     
    609590        os << " ... ";
    610591        high->print( os, indent );
    611         Expression::print( os, indent );
    612592}
    613593
     
    621601        }
    622602}
    623 StmtExpr::StmtExpr( const StmtExpr &other ) : Expression( other ), statements( other.statements->clone() ) {
    624         cloneAll( other.returnDecls, returnDecls );
    625         cloneAll( other.dtors, dtors );
    626 }
     603StmtExpr::StmtExpr( const StmtExpr &other ) : Expression( other ), statements( other.statements->clone() ) {}
    627604StmtExpr::~StmtExpr() {
    628605        delete statements;
    629         deleteAll( dtors );
    630         deleteAll( returnDecls );
    631606}
    632607void StmtExpr::print( std::ostream &os, int indent ) const {
    633608        os << "Statement Expression: " << std::endl << std::string( indent, ' ' );
    634609        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 );
    644610}
    645611
     
    665631        get_expr()->print( os, indent+2 );
    666632        if ( get_object() ) {
    667                 os << std::string( indent+2, ' ' ) << "with decl: ";
     633                os << " with decl: ";
    668634                get_object()->printShort( os, indent+2 );
    669635        }
    670         Expression::print( os, indent );
    671636}
    672637
  • src/SynTree/Expression.h

    r66f8528 r596f987b  
    543543
    544544        std::list< ObjectDecl * > & get_tempDecls() { return tempDecls; }
     545        void set_tempDecls( std::list< ObjectDecl * > newValue ) { tempDecls = newValue; }
     546
    545547        std::list< ObjectDecl * > & get_returnDecls() { return returnDecls; }
     548        void set_returnDecls( std::list< ObjectDecl * > newValue ) { returnDecls = newValue; }
     549
    546550        std::list< Expression * > & get_dtors() { return dtors; }
     551        void set_dtors( std::list< Expression * > newValue ) { dtors = newValue; }
    547552
    548553        virtual ImplicitCopyCtorExpr *clone() const { return new ImplicitCopyCtorExpr( *this ); }
     
    701706        virtual ~TupleAssignExpr();
    702707
    703         TupleAssignExpr * set_stmtExpr( StmtExpr * newValue ) { stmtExpr = newValue; return this; }
    704         StmtExpr * get_stmtExpr() const { return stmtExpr; }
     708        std::list< Expression * > & get_assigns() { return assigns; }
     709        std::list< ObjectDecl * > & get_tempDecls() { return tempDecls; }
    705710
    706711        virtual TupleAssignExpr *clone() const { return new TupleAssignExpr( *this ); }
     
    709714        virtual void print( std::ostream &os, int indent = 0 ) const;
    710715  private:
    711         StmtExpr * stmtExpr = nullptr;
     716        std::list< Expression * > assigns; // assignment expressions that use tempDecls
     717        std::list< ObjectDecl * > tempDecls; // temporaries for address of lhs exprs
    712718};
    713719
     
    722728        StmtExpr * set_statements( CompoundStmt * newValue ) { statements = newValue; return this; }
    723729
    724         std::list< ObjectDecl * > & get_returnDecls() { return returnDecls; }
    725         std::list< Expression * > & get_dtors() { return dtors; }
    726 
    727730        virtual StmtExpr *clone() const { return new StmtExpr( *this ); }
    728731        virtual void accept( Visitor &v ) { v.visit( this ); }
     
    731734private:
    732735        CompoundStmt * statements;
    733         std::list< ObjectDecl * > returnDecls; // return variable(s) for stmt expression
    734         std::list< Expression * > dtors; // destructor(s) for return variable(s)
    735736};
    736737
  • src/SynTree/Initializer.cc

    r66f8528 r596f987b  
    6565}
    6666
    67 ListInit::ListInit( const ListInit & other ) : Initializer( other ) {
    68         cloneAll( other.initializers, initializers );
    69         cloneAll( other.designators, designators );
    70 }
    71 
    72 
    7367ListInit::~ListInit() {
    7468        deleteAll( initializers );
  • src/SynTree/Initializer.h

    r66f8528 r596f987b  
    8888        ListInit( const std::list<Initializer*> &initializers,
    8989                          const std::list<Expression *> &designators = std::list< Expression * >(), bool maybeConstructed = false );
    90         ListInit( const ListInit & other );
    9190        virtual ~ListInit();
    9291
  • src/SynTree/Mutator.cc

    r66f8528 r596f987b  
    325325        mutateAll( impCpCtorExpr->get_tempDecls(), *this );
    326326        mutateAll( impCpCtorExpr->get_returnDecls(), *this );
    327         mutateAll( impCpCtorExpr->get_dtors(), *this );
    328327        return impCpCtorExpr;
    329328}
     
    374373Expression *Mutator::mutate( TupleAssignExpr *assignExpr ) {
    375374        assignExpr->set_result( maybeMutate( assignExpr->get_result(), *this ) );
    376         assignExpr->set_stmtExpr( maybeMutate( assignExpr->get_stmtExpr(), *this ) );
     375        mutateAll( assignExpr->get_tempDecls(), *this );
     376        mutateAll( assignExpr->get_assigns(), *this );
    377377        return assignExpr;
    378378}
     
    381381        stmtExpr->set_result( maybeMutate( stmtExpr->get_result(), *this ) );
    382382        stmtExpr->set_statements( maybeMutate( stmtExpr->get_statements(), *this ) );
    383         mutateAll( stmtExpr->get_returnDecls(), *this );
    384         mutateAll( stmtExpr->get_dtors(), *this );
    385383        return stmtExpr;
    386384}
     
    505503Initializer *Mutator::mutate( ConstructorInit *ctorInit ) {
    506504        ctorInit->set_ctor( maybeMutate( ctorInit->get_ctor(), *this ) );
    507         ctorInit->set_dtor( maybeMutate( ctorInit->get_dtor(), *this ) );
    508505        ctorInit->set_init( maybeMutate( ctorInit->get_init(), *this ) );
    509506        return ctorInit;
  • src/SynTree/ReferenceToType.cc

    r66f8528 r596f987b  
    4646
    4747namespace {
    48         void doLookup( const std::list< Declaration* > &members, const std::string &name, std::list< Declaration* > &foundDecls ) {
     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;
    4950                for ( std::list< Declaration* >::const_iterator i = members.begin(); i != members.end(); ++i ) {
    5051                        if ( (*i)->get_name() == name ) {
    51                                 foundDecls.push_back( *i );
     52                                found.push_back( *i );
    5253                        } // if
    5354                } // for
     55                applySubstitution( parms.begin(), parms.end(), args.begin(), found.begin(), found.end(), back_inserter( foundDecls ) );
    5456        }
    5557} // namespace
     
    6668void StructInstType::lookup( const std::string &name, std::list< Declaration* > &foundDecls ) const {
    6769        assert( baseStruct );
    68         doLookup( baseStruct->get_members(), name, foundDecls );
     70        doLookup( baseStruct->get_members(), baseStruct->get_parameters(), parameters, name, foundDecls );
    6971}
    7072
     
    9294void UnionInstType::lookup( const std::string &name, std::list< Declaration* > &foundDecls ) const {
    9395        assert( baseUnion );
    94         doLookup( baseUnion->get_members(), name, foundDecls );
     96        doLookup( baseUnion->get_members(), baseUnion->get_parameters(), parameters, name, foundDecls );
    9597}
    9698
     
    128130}
    129131
    130 TypeInstType::TypeInstType( const TypeInstType &other ) : Parent( other ), baseType( other.baseType ), isFtype( other.isFtype ) {
    131 }
    132 
    133 
    134132TypeInstType::~TypeInstType() {
    135133        // delete baseType; //This is shared and should not be deleted
  • src/SynTree/TupleExpr.cc

    r66f8528 r596f987b  
    8787}
    8888
    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
     89
     90TupleAssignExpr::TupleAssignExpr( const std::list< Expression * > & assigns, const std::list< ObjectDecl * > & tempDecls, Expression * _aname ) : Expression( _aname ), assigns( assigns ), tempDecls( tempDecls ) {
    9191        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 );
    10192}
    10293
    10394TupleAssignExpr::TupleAssignExpr( const TupleAssignExpr &other ) : Expression( other ) {
    104         assert( other.stmtExpr );
    105         stmtExpr = other.stmtExpr->clone();
     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        }
    106114}
    107115
    108116TupleAssignExpr::~TupleAssignExpr() {
    109         delete stmtExpr;
     117        deleteAll( assigns );
     118        // deleteAll( tempDecls );
    110119}
    111120
    112121void TupleAssignExpr::print( std::ostream &os, int indent ) const {
    113         os << "Tuple Assignment Expression, with stmt expr:" << std::endl;
    114         os << std::string( indent+2, ' ' );
    115         stmtExpr->print( os, indent+4 );
     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 );
    116126        Expression::print( os, indent );
    117127}
  • src/SynTree/Type.h

    r66f8528 r596f987b  
    7272        virtual unsigned size() const { return 1; };
    7373        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; }
    7574
    7675        virtual Type *clone() const = 0;
     
    340339        TypeInstType( const Type::Qualifiers &tq, const std::string &name, TypeDecl *baseType );
    341340        TypeInstType( const Type::Qualifiers &tq, const std::string &name, bool isFtype );
    342         TypeInstType( const TypeInstType &other );
     341        TypeInstType( const TypeInstType &other ) : Parent( other ), baseType( other.baseType ), isFtype( other.isFtype ) {}
    343342        ~TypeInstType();
    344343
     
    374373        iterator begin() { return types.begin(); }
    375374        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         }
    381375
    382376        virtual TupleType *clone() const { return new TupleType( *this ); }
  • src/SynTree/TypeDecl.cc

    r66f8528 r596f987b  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // TypeDecl.cc --
     7// TypeDecl.cc -- 
    88//
    99// Author           : Richard C. Bilson
     
    1818#include "Common/utility.h"
    1919
    20 TypeDecl::TypeDecl( const std::string &name, DeclarationNode::StorageClass sc, Type *type, Kind kind ) : Parent( name, sc, type ), kind( kind ), sized( kind == Any ) {
     20TypeDecl::TypeDecl( const std::string &name, DeclarationNode::StorageClass sc, Type *type, Kind kind ) : Parent( name, sc, type ), kind( kind ) {
    2121}
    2222
    23 TypeDecl::TypeDecl( const TypeDecl &other ) : Parent( other ), kind( other.kind ), sized( other.sized ) {
     23TypeDecl::TypeDecl( const TypeDecl &other ) : Parent( other ), kind( other.kind ) {
    2424}
    2525
     
    2929}
    3030
    31 std::ostream & operator<<( std::ostream & os, const TypeDecl::Data & data ) {
    32   return os << data.kind << ", " << data.isComplete;
    33 }
    34 
    3531// Local Variables: //
    3632// tab-width: 4 //
  • src/SynTree/VarExprReplacer.cc

    r66f8528 r596f987b  
    2121// replace variable with new node from decl map
    2222void 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)
    2423  if ( declMap.count( varExpr->get_var() ) ) {
    2524    varExpr->set_var( declMap.at( varExpr->get_var() ) );
  • src/SynTree/Visitor.cc

    r66f8528 r596f987b  
    276276        acceptAll( impCpCtorExpr->get_tempDecls(), *this );
    277277        acceptAll( impCpCtorExpr->get_returnDecls(), *this );
    278         acceptAll( impCpCtorExpr->get_dtors(), *this );
    279278}
    280279
     
    318317void Visitor::visit( TupleAssignExpr *assignExpr ) {
    319318        maybeAccept( assignExpr->get_result(), *this );
    320         maybeAccept( assignExpr->get_stmtExpr(), *this );
     319        acceptAll( assignExpr->get_tempDecls(), *this );
     320        acceptAll( assignExpr->get_assigns(), *this );
    321321}
    322322
     
    324324        maybeAccept( stmtExpr->get_result(), *this );
    325325        maybeAccept( stmtExpr->get_statements(), *this );
    326         acceptAll( stmtExpr->get_returnDecls(), *this );
    327         acceptAll( stmtExpr->get_dtors(), *this );
    328326}
    329327
     
    427425void Visitor::visit( ConstructorInit *ctorInit ) {
    428426        maybeAccept( ctorInit->get_ctor(), *this );
    429         maybeAccept( ctorInit->get_dtor(), *this );
    430427        maybeAccept( ctorInit->get_init(), *this );
    431428}
  • src/Tuples/Explode.cc

    r66f8528 r596f987b  
    2323                        Expression * applyAddr( Expression * expr, bool first = true ) {
    2424                                if ( TupleExpr * tupleExpr = dynamic_cast< TupleExpr * >( expr ) ){
    25                                         foundUniqueExpr = true;
    2625                                        std::list< Expression * > exprs;
    2726                                        for ( Expression *& expr : tupleExpr->get_exprs() ) {
     
    4746                                // should now be a tuple of addresses rather than the address of a tuple.
    4847                                // Still, this code is a bit awkward, and could use some improvement.
    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                                 }
     48                                foundUniqueExpr = true;
    5349                                UniqueExpr * newUniqueExpr = new UniqueExpr( applyAddr( uniqueExpr->get_expr() ), uniqueExpr->get_id() );
    5450                                delete uniqueExpr;
  • src/Tuples/TupleAssignment.cc

    r66f8528 r596f987b  
    2323#include "Common/SemanticError.h"
    2424#include "InitTweak/InitTweak.h"
    25 #include "InitTweak/GenInit.h"
    2625
    2726#include <functional>
     
    4847                        virtual ~Matcher() {}
    4948                        virtual void match( std::list< Expression * > &out ) = 0;
    50                         ObjectDecl * newObject( UniqueName & namer, Expression * expr );
    5149                        ResolvExpr::AltList lhs, rhs;
    5250                        TupleAssignSpotter &spotter;
    53                         ResolvExpr::Cost baseCost;
    5451                        std::list< ObjectDecl * > tmpDecls;
    55                         ResolvExpr::TypeEnvironment compositeEnv;
    5652                };
    5753
     
    150146                                finder.findWithAdjustment(*i);
    151147                        } catch (...) {
    152                                 return; // no match should not mean failure, it just means this particular tuple assignment isn't valid
     148                                return; // xxx - no match should not mean failure, it just means this particular tuple assignment isn't valid
    153149                        }
    154150                        // prune expressions that don't coincide with
     
    165161                        solved_assigns.push_back( alt.expr->clone() );
    166162                }
    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 ) ) {
     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) {
    173170                assert( ! alts.empty() );
    174                 // combine argument environments into combined expression environment
    175                 simpleCombineEnvironments( alts.begin(), alts.end(), compositeEnv );
    176 
    177171                ResolvExpr::Alternative lhsAlt = alts.front();
    178172                // peel off the cast that exists on ctor/dtor expressions
     
    223217        }
    224218
    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 ) {
     219        ObjectDecl * newObject( UniqueName & namer, Expression * expr ) {
    237220                assert( expr->has_result() && ! expr->get_result()->isVoid() );
    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;
     221                return new ObjectDecl( namer.newName(), DeclarationNode::NoStorageClass, LinkageSpec::Cforall, nullptr, expr->get_result()->clone(), new SingleInit( expr->clone() ) );
    245222        }
    246223
     
    267244                        std::list< ObjectDecl * > ltmp;
    268245                        std::list< ObjectDecl * > rtmp;
    269                         std::transform( lhs.begin(), lhs.end(), back_inserter( ltmp ), [&]( ResolvExpr::Alternative & alt ){
     246                        std::transform( lhs.begin(), lhs.end(), back_inserter( ltmp ), []( ResolvExpr::Alternative & alt ){
    270247                                return newObject( lhsNamer, alt.expr );
    271248                        });
    272                         std::transform( rhs.begin(), rhs.end(), back_inserter( rtmp ), [&]( ResolvExpr::Alternative & alt ){
     249                        std::transform( rhs.begin(), rhs.end(), back_inserter( rtmp ), []( ResolvExpr::Alternative & alt ){
    273250                                return newObject( rhsNamer, alt.expr );
    274251                        });
  • src/Tuples/TupleExpansion.cc

    r66f8528 r596f987b  
    9393                        typedef Mutator Parent;
    9494                        using Parent::mutate;
    95 
     95                       
    9696                        virtual Expression * mutate( TupleExpr * tupleExpr ) override;
    9797                };
     
    194194                                new CommaExpr( new CommaExpr( assignUnq, assignFinished ), var->clone() ) );
    195195                        condExpr->set_result( var->get_result()->clone() );
    196                         condExpr->set_env( maybeClone( unqExpr->get_env() ) );
    197196                        decls[id] = condExpr;
    198197                }
     
    203202        Expression * TupleAssignExpander::mutate( TupleAssignExpr * assnExpr ) {
    204203                assnExpr = safe_dynamic_cast< TupleAssignExpr * >( Parent::mutate( assnExpr ) );
    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 );
     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();
    210214                delete assnExpr;
    211                 return ret;
     215                return new StmtExpr( compoundStmt );
    212216        }
    213217
    214218        Type * TupleTypeReplacer::mutate( TupleType * tupleType ) {
    215219                std::string mangleName = SymTab::Mangler::mangleType( tupleType );
    216                 tupleType = safe_dynamic_cast< TupleType * > ( Parent::mutate( tupleType ) );
     220                TupleType * newType = safe_dynamic_cast< TupleType * > ( Parent::mutate( tupleType ) );
    217221                if ( ! typeMap.count( mangleName ) ) {
    218222                        // generate struct type to replace tuple type
    219                         // xxx - should fix this to only generate one tuple struct for each number of type parameters
    220223                        StructDecl * decl = new StructDecl( "_tuple_type_" + mangleName );
    221224                        decl->set_body( true );
    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 );
     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 ) );
    226228                        }
    227229                        typeMap[mangleName] = decl;
    228230                        addDeclaration( decl );
    229231                }
    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;
     232                Type::Qualifiers qualifiers = newType->get_qualifiers();
     233                delete newType;
     234                return new StructInstType( qualifiers, typeMap[mangleName] );
    239235        }
    240236
     
    244240                tupleExpr->set_tuple( nullptr );
    245241                unsigned int idx = tupleExpr->get_index();
    246                 TypeSubstitution * env = tupleExpr->get_env();
    247                 tupleExpr->set_env( nullptr );
    248242                delete tupleExpr;
    249243
     
    252246                assert( structDecl->get_members().size() > idx );
    253247                Declaration * member = *std::next(structDecl->get_members().begin(), idx);
    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 ) {
     248                return new MemberExpr( safe_dynamic_cast< DeclarationWithType * >( member ), tuple );
     249        }
     250
     251        Expression * replaceTupleExpr( Type * result, const std::list< Expression * > & exprs ) {
    260252                if ( result->isVoid() ) {
    261253                        // void result - don't need to produce a value for cascading - just output a chain of comma exprs
    262254                        assert( ! exprs.empty() );
    263255                        std::list< Expression * >::const_iterator iter = exprs.begin();
    264                         Expression * expr = new CastExpr( *iter++ );
     256                        Expression * expr = *iter++;
    265257                        for ( ; iter != exprs.end(); ++iter ) {
    266                                 expr = new CommaExpr( expr, new CastExpr( *iter ) );
    267                         }
    268                         expr->set_env( env );
     258                                expr = new CommaExpr( expr, *iter );
     259                        }
    269260                        return expr;
    270261                } else {
     
    276267                                inits.push_back( new SingleInit( expr ) );
    277268                        }
    278                         Expression * expr = new CompoundLiteralExpr( result, new ListInit( inits ) );
    279                         expr->set_env( env );
    280                         return expr;
     269                        return new CompoundLiteralExpr( result, new ListInit( inits ) );
    281270                }
    282271        }
     
    288277                std::list< Expression * > exprs = tupleExpr->get_exprs();
    289278                assert( result );
    290                 TypeSubstitution * env = tupleExpr->get_env();
    291279
    292280                // remove data from shell and delete it
    293281                tupleExpr->set_result( nullptr );
    294282                tupleExpr->get_exprs().clear();
    295                 tupleExpr->set_env( nullptr );
    296283                delete tupleExpr;
    297284
    298                 return replaceTupleExpr( result, exprs, env );
     285                return replaceTupleExpr( result, exprs );
    299286        }
    300287
  • src/main.cc

    r66f8528 r596f987b  
    266266                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
    267267                Tuples::expandUniqueExpr( translationUnit );
    268                 OPTPRINT( "expandTuples" ); // xxx - is this the right place for this?
    269                 Tuples::expandTuples( translationUnit );
    270268
    271269                OPTPRINT("instantiateGenerics")
     
    284282                OPTPRINT( "box" )
    285283                GenPoly::box( translationUnit );
     284                OPTPRINT( "expandTuples" ); // xxx - is this the right place for this?
     285                Tuples::expandTuples( translationUnit );
    286286
    287287                // print tree right before code generation
  • src/prelude/prelude.cf

    r66f8528 r596f987b  
    105105forall( otype T ) const volatile T *     --?( const volatile T ** );
    106106
    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 * );
     107forall( otype T ) lvalue T               *?(                 T * );
     108forall( otype T ) const lvalue T                 *?( const           T * );
     109forall( otype T ) volatile lvalue T      *?(       volatile  T * );
     110forall( otype T ) const volatile lvalue T *?( const volatile  T * );
    111111forall( ftype FT ) lvalue FT             *?( FT * );
    112112
  • src/tests/.expect/32/declarationSpecifier.txt

    r66f8528 r596f987b  
    2020static inline void ___constructor__F_P13s__anonymous013s__anonymous0_autogen___1(struct __anonymous0 *___dst__P13s__anonymous0_1, struct __anonymous0 ___src__13s__anonymous0_1);
    2121static 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 }
    3122static inline struct __anonymous0 ___operator_assign__F13s__anonymous0_P13s__anonymous013s__anonymous0_autogen___1(struct __anonymous0 *___dst__P13s__anonymous0_1, struct __anonymous0 ___src__13s__anonymous0_1){
    3223    ((void)((*___dst__P13s__anonymous0_1).__i__i_1=___src__13s__anonymous0_1.__i__i_1));
    3324    return ((struct __anonymous0 )___src__13s__anonymous0_1);
     25}
     26static 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}
     29static 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}
     32static inline void ___destructor__F_P13s__anonymous0_autogen___1(struct __anonymous0 *___dst__P13s__anonymous0_1){
     33    ((void)((*((int *)(&(*___dst__P13s__anonymous0_1).__i__i_1)))) /* ^?{} */);
    3434}
    3535static inline void ___constructor__F_P13s__anonymous0i_autogen___1(struct __anonymous0 *___dst__P13s__anonymous0_1, int __i__i_1){
     
    4444static inline void ___constructor__F_P13s__anonymous113s__anonymous1_autogen___1(struct __anonymous1 *___dst__P13s__anonymous1_1, struct __anonymous1 ___src__13s__anonymous1_1);
    4545static 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 }
    5546static inline struct __anonymous1 ___operator_assign__F13s__anonymous1_P13s__anonymous113s__anonymous1_autogen___1(struct __anonymous1 *___dst__P13s__anonymous1_1, struct __anonymous1 ___src__13s__anonymous1_1){
    5647    ((void)((*___dst__P13s__anonymous1_1).__i__i_1=___src__13s__anonymous1_1.__i__i_1));
    5748    return ((struct __anonymous1 )___src__13s__anonymous1_1);
     49}
     50static 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}
     53static 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}
     56static inline void ___destructor__F_P13s__anonymous1_autogen___1(struct __anonymous1 *___dst__P13s__anonymous1_1){
     57    ((void)((*((int *)(&(*___dst__P13s__anonymous1_1).__i__i_1)))) /* ^?{} */);
    5858}
    5959static inline void ___constructor__F_P13s__anonymous1i_autogen___1(struct __anonymous1 *___dst__P13s__anonymous1_1, int __i__i_1){
     
    6868static inline void ___constructor__F_P13s__anonymous213s__anonymous2_autogen___1(struct __anonymous2 *___dst__P13s__anonymous2_1, struct __anonymous2 ___src__13s__anonymous2_1);
    6969static 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 }
    7970static inline struct __anonymous2 ___operator_assign__F13s__anonymous2_P13s__anonymous213s__anonymous2_autogen___1(struct __anonymous2 *___dst__P13s__anonymous2_1, struct __anonymous2 ___src__13s__anonymous2_1){
    8071    ((void)((*___dst__P13s__anonymous2_1).__i__i_1=___src__13s__anonymous2_1.__i__i_1));
    8172    return ((struct __anonymous2 )___src__13s__anonymous2_1);
     73}
     74static 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}
     77static 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}
     80static inline void ___destructor__F_P13s__anonymous2_autogen___1(struct __anonymous2 *___dst__P13s__anonymous2_1){
     81    ((void)((*((int *)(&(*___dst__P13s__anonymous2_1).__i__i_1)))) /* ^?{} */);
    8282}
    8383static inline void ___constructor__F_P13s__anonymous2i_autogen___1(struct __anonymous2 *___dst__P13s__anonymous2_1, int __i__i_1){
     
    9292static inline void ___constructor__F_P13s__anonymous313s__anonymous3_autogen___1(struct __anonymous3 *___dst__P13s__anonymous3_1, struct __anonymous3 ___src__13s__anonymous3_1);
    9393static 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 }
    10394static inline struct __anonymous3 ___operator_assign__F13s__anonymous3_P13s__anonymous313s__anonymous3_autogen___1(struct __anonymous3 *___dst__P13s__anonymous3_1, struct __anonymous3 ___src__13s__anonymous3_1){
    10495    ((void)((*___dst__P13s__anonymous3_1).__i__i_1=___src__13s__anonymous3_1.__i__i_1));
    10596    return ((struct __anonymous3 )___src__13s__anonymous3_1);
     97}
     98static 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}
     101static 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}
     104static inline void ___destructor__F_P13s__anonymous3_autogen___1(struct __anonymous3 *___dst__P13s__anonymous3_1){
     105    ((void)((*((int *)(&(*___dst__P13s__anonymous3_1).__i__i_1)))) /* ^?{} */);
    106106}
    107107static inline void ___constructor__F_P13s__anonymous3i_autogen___1(struct __anonymous3 *___dst__P13s__anonymous3_1, int __i__i_1){
     
    116116static inline void ___constructor__F_P13s__anonymous413s__anonymous4_autogen___1(struct __anonymous4 *___dst__P13s__anonymous4_1, struct __anonymous4 ___src__13s__anonymous4_1);
    117117static 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 }
    127118static inline struct __anonymous4 ___operator_assign__F13s__anonymous4_P13s__anonymous413s__anonymous4_autogen___1(struct __anonymous4 *___dst__P13s__anonymous4_1, struct __anonymous4 ___src__13s__anonymous4_1){
    128119    ((void)((*___dst__P13s__anonymous4_1).__i__i_1=___src__13s__anonymous4_1.__i__i_1));
    129120    return ((struct __anonymous4 )___src__13s__anonymous4_1);
     121}
     122static 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}
     125static 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}
     128static inline void ___destructor__F_P13s__anonymous4_autogen___1(struct __anonymous4 *___dst__P13s__anonymous4_1){
     129    ((void)((*((int *)(&(*___dst__P13s__anonymous4_1).__i__i_1)))) /* ^?{} */);
    130130}
    131131static inline void ___constructor__F_P13s__anonymous4i_autogen___1(struct __anonymous4 *___dst__P13s__anonymous4_1, int __i__i_1){
     
    140140static inline void ___constructor__F_P13s__anonymous513s__anonymous5_autogen___1(struct __anonymous5 *___dst__P13s__anonymous5_1, struct __anonymous5 ___src__13s__anonymous5_1);
    141141static 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 }
    151142static inline struct __anonymous5 ___operator_assign__F13s__anonymous5_P13s__anonymous513s__anonymous5_autogen___1(struct __anonymous5 *___dst__P13s__anonymous5_1, struct __anonymous5 ___src__13s__anonymous5_1){
    152143    ((void)((*___dst__P13s__anonymous5_1).__i__i_1=___src__13s__anonymous5_1.__i__i_1));
    153144    return ((struct __anonymous5 )___src__13s__anonymous5_1);
     145}
     146static 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}
     149static 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}
     152static inline void ___destructor__F_P13s__anonymous5_autogen___1(struct __anonymous5 *___dst__P13s__anonymous5_1){
     153    ((void)((*((int *)(&(*___dst__P13s__anonymous5_1).__i__i_1)))) /* ^?{} */);
    154154}
    155155static inline void ___constructor__F_P13s__anonymous5i_autogen___1(struct __anonymous5 *___dst__P13s__anonymous5_1, int __i__i_1){
     
    164164static inline void ___constructor__F_P13s__anonymous613s__anonymous6_autogen___1(struct __anonymous6 *___dst__P13s__anonymous6_1, struct __anonymous6 ___src__13s__anonymous6_1);
    165165static 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 }
    175166static inline struct __anonymous6 ___operator_assign__F13s__anonymous6_P13s__anonymous613s__anonymous6_autogen___1(struct __anonymous6 *___dst__P13s__anonymous6_1, struct __anonymous6 ___src__13s__anonymous6_1){
    176167    ((void)((*___dst__P13s__anonymous6_1).__i__i_1=___src__13s__anonymous6_1.__i__i_1));
    177168    return ((struct __anonymous6 )___src__13s__anonymous6_1);
     169}
     170static 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}
     173static 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}
     176static inline void ___destructor__F_P13s__anonymous6_autogen___1(struct __anonymous6 *___dst__P13s__anonymous6_1){
     177    ((void)((*((int *)(&(*___dst__P13s__anonymous6_1).__i__i_1)))) /* ^?{} */);
    178178}
    179179static inline void ___constructor__F_P13s__anonymous6i_autogen___1(struct __anonymous6 *___dst__P13s__anonymous6_1, int __i__i_1){
     
    188188static inline void ___constructor__F_P13s__anonymous713s__anonymous7_autogen___1(struct __anonymous7 *___dst__P13s__anonymous7_1, struct __anonymous7 ___src__13s__anonymous7_1);
    189189static 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 }
    199190static inline struct __anonymous7 ___operator_assign__F13s__anonymous7_P13s__anonymous713s__anonymous7_autogen___1(struct __anonymous7 *___dst__P13s__anonymous7_1, struct __anonymous7 ___src__13s__anonymous7_1){
    200191    ((void)((*___dst__P13s__anonymous7_1).__i__i_1=___src__13s__anonymous7_1.__i__i_1));
    201192    return ((struct __anonymous7 )___src__13s__anonymous7_1);
     193}
     194static 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}
     197static 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}
     200static inline void ___destructor__F_P13s__anonymous7_autogen___1(struct __anonymous7 *___dst__P13s__anonymous7_1){
     201    ((void)((*((int *)(&(*___dst__P13s__anonymous7_1).__i__i_1)))) /* ^?{} */);
    202202}
    203203static inline void ___constructor__F_P13s__anonymous7i_autogen___1(struct __anonymous7 *___dst__P13s__anonymous7_1, int __i__i_1){
     
    220220static inline void ___constructor__F_P13s__anonymous813s__anonymous8_autogen___1(struct __anonymous8 *___dst__P13s__anonymous8_1, struct __anonymous8 ___src__13s__anonymous8_1);
    221221static 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 }
    231222static inline struct __anonymous8 ___operator_assign__F13s__anonymous8_P13s__anonymous813s__anonymous8_autogen___1(struct __anonymous8 *___dst__P13s__anonymous8_1, struct __anonymous8 ___src__13s__anonymous8_1){
    232223    ((void)((*___dst__P13s__anonymous8_1).__i__s_1=___src__13s__anonymous8_1.__i__s_1));
    233224    return ((struct __anonymous8 )___src__13s__anonymous8_1);
     225}
     226static 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}
     229static 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}
     232static inline void ___destructor__F_P13s__anonymous8_autogen___1(struct __anonymous8 *___dst__P13s__anonymous8_1){
     233    ((void)((*((short *)(&(*___dst__P13s__anonymous8_1).__i__s_1)))) /* ^?{} */);
    234234}
    235235static inline void ___constructor__F_P13s__anonymous8s_autogen___1(struct __anonymous8 *___dst__P13s__anonymous8_1, short __i__s_1){
     
    244244static inline void ___constructor__F_P13s__anonymous913s__anonymous9_autogen___1(struct __anonymous9 *___dst__P13s__anonymous9_1, struct __anonymous9 ___src__13s__anonymous9_1);
    245245static 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 }
    255246static inline struct __anonymous9 ___operator_assign__F13s__anonymous9_P13s__anonymous913s__anonymous9_autogen___1(struct __anonymous9 *___dst__P13s__anonymous9_1, struct __anonymous9 ___src__13s__anonymous9_1){
    256247    ((void)((*___dst__P13s__anonymous9_1).__i__s_1=___src__13s__anonymous9_1.__i__s_1));
    257248    return ((struct __anonymous9 )___src__13s__anonymous9_1);
     249}
     250static 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}
     253static 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}
     256static inline void ___destructor__F_P13s__anonymous9_autogen___1(struct __anonymous9 *___dst__P13s__anonymous9_1){
     257    ((void)((*((short *)(&(*___dst__P13s__anonymous9_1).__i__s_1)))) /* ^?{} */);
    258258}
    259259static inline void ___constructor__F_P13s__anonymous9s_autogen___1(struct __anonymous9 *___dst__P13s__anonymous9_1, short __i__s_1){
     
    268268static inline void ___constructor__F_P14s__anonymous1014s__anonymous10_autogen___1(struct __anonymous10 *___dst__P14s__anonymous10_1, struct __anonymous10 ___src__14s__anonymous10_1);
    269269static 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 }
    279270static inline struct __anonymous10 ___operator_assign__F14s__anonymous10_P14s__anonymous1014s__anonymous10_autogen___1(struct __anonymous10 *___dst__P14s__anonymous10_1, struct __anonymous10 ___src__14s__anonymous10_1){
    280271    ((void)((*___dst__P14s__anonymous10_1).__i__s_1=___src__14s__anonymous10_1.__i__s_1));
    281272    return ((struct __anonymous10 )___src__14s__anonymous10_1);
     273}
     274static 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}
     277static 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}
     280static inline void ___destructor__F_P14s__anonymous10_autogen___1(struct __anonymous10 *___dst__P14s__anonymous10_1){
     281    ((void)((*((short *)(&(*___dst__P14s__anonymous10_1).__i__s_1)))) /* ^?{} */);
    282282}
    283283static inline void ___constructor__F_P14s__anonymous10s_autogen___1(struct __anonymous10 *___dst__P14s__anonymous10_1, short __i__s_1){
     
    292292static inline void ___constructor__F_P14s__anonymous1114s__anonymous11_autogen___1(struct __anonymous11 *___dst__P14s__anonymous11_1, struct __anonymous11 ___src__14s__anonymous11_1);
    293293static 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 }
    303294static inline struct __anonymous11 ___operator_assign__F14s__anonymous11_P14s__anonymous1114s__anonymous11_autogen___1(struct __anonymous11 *___dst__P14s__anonymous11_1, struct __anonymous11 ___src__14s__anonymous11_1){
    304295    ((void)((*___dst__P14s__anonymous11_1).__i__s_1=___src__14s__anonymous11_1.__i__s_1));
    305296    return ((struct __anonymous11 )___src__14s__anonymous11_1);
     297}
     298static 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}
     301static 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}
     304static inline void ___destructor__F_P14s__anonymous11_autogen___1(struct __anonymous11 *___dst__P14s__anonymous11_1){
     305    ((void)((*((short *)(&(*___dst__P14s__anonymous11_1).__i__s_1)))) /* ^?{} */);
    306306}
    307307static inline void ___constructor__F_P14s__anonymous11s_autogen___1(struct __anonymous11 *___dst__P14s__anonymous11_1, short __i__s_1){
     
    316316static inline void ___constructor__F_P14s__anonymous1214s__anonymous12_autogen___1(struct __anonymous12 *___dst__P14s__anonymous12_1, struct __anonymous12 ___src__14s__anonymous12_1);
    317317static 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 }
    327318static inline struct __anonymous12 ___operator_assign__F14s__anonymous12_P14s__anonymous1214s__anonymous12_autogen___1(struct __anonymous12 *___dst__P14s__anonymous12_1, struct __anonymous12 ___src__14s__anonymous12_1){
    328319    ((void)((*___dst__P14s__anonymous12_1).__i__s_1=___src__14s__anonymous12_1.__i__s_1));
    329320    return ((struct __anonymous12 )___src__14s__anonymous12_1);
     321}
     322static 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}
     325static 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}
     328static inline void ___destructor__F_P14s__anonymous12_autogen___1(struct __anonymous12 *___dst__P14s__anonymous12_1){
     329    ((void)((*((short *)(&(*___dst__P14s__anonymous12_1).__i__s_1)))) /* ^?{} */);
    330330}
    331331static inline void ___constructor__F_P14s__anonymous12s_autogen___1(struct __anonymous12 *___dst__P14s__anonymous12_1, short __i__s_1){
     
    340340static inline void ___constructor__F_P14s__anonymous1314s__anonymous13_autogen___1(struct __anonymous13 *___dst__P14s__anonymous13_1, struct __anonymous13 ___src__14s__anonymous13_1);
    341341static 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 }
    351342static inline struct __anonymous13 ___operator_assign__F14s__anonymous13_P14s__anonymous1314s__anonymous13_autogen___1(struct __anonymous13 *___dst__P14s__anonymous13_1, struct __anonymous13 ___src__14s__anonymous13_1){
    352343    ((void)((*___dst__P14s__anonymous13_1).__i__s_1=___src__14s__anonymous13_1.__i__s_1));
    353344    return ((struct __anonymous13 )___src__14s__anonymous13_1);
     345}
     346static 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}
     349static 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}
     352static inline void ___destructor__F_P14s__anonymous13_autogen___1(struct __anonymous13 *___dst__P14s__anonymous13_1){
     353    ((void)((*((short *)(&(*___dst__P14s__anonymous13_1).__i__s_1)))) /* ^?{} */);
    354354}
    355355static inline void ___constructor__F_P14s__anonymous13s_autogen___1(struct __anonymous13 *___dst__P14s__anonymous13_1, short __i__s_1){
     
    364364static inline void ___constructor__F_P14s__anonymous1414s__anonymous14_autogen___1(struct __anonymous14 *___dst__P14s__anonymous14_1, struct __anonymous14 ___src__14s__anonymous14_1);
    365365static 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 }
    375366static inline struct __anonymous14 ___operator_assign__F14s__anonymous14_P14s__anonymous1414s__anonymous14_autogen___1(struct __anonymous14 *___dst__P14s__anonymous14_1, struct __anonymous14 ___src__14s__anonymous14_1){
    376367    ((void)((*___dst__P14s__anonymous14_1).__i__s_1=___src__14s__anonymous14_1.__i__s_1));
    377368    return ((struct __anonymous14 )___src__14s__anonymous14_1);
     369}
     370static 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}
     373static 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}
     376static inline void ___destructor__F_P14s__anonymous14_autogen___1(struct __anonymous14 *___dst__P14s__anonymous14_1){
     377    ((void)((*((short *)(&(*___dst__P14s__anonymous14_1).__i__s_1)))) /* ^?{} */);
    378378}
    379379static inline void ___constructor__F_P14s__anonymous14s_autogen___1(struct __anonymous14 *___dst__P14s__anonymous14_1, short __i__s_1){
     
    388388static inline void ___constructor__F_P14s__anonymous1514s__anonymous15_autogen___1(struct __anonymous15 *___dst__P14s__anonymous15_1, struct __anonymous15 ___src__14s__anonymous15_1);
    389389static 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 }
    399390static inline struct __anonymous15 ___operator_assign__F14s__anonymous15_P14s__anonymous1514s__anonymous15_autogen___1(struct __anonymous15 *___dst__P14s__anonymous15_1, struct __anonymous15 ___src__14s__anonymous15_1){
    400391    ((void)((*___dst__P14s__anonymous15_1).__i__s_1=___src__14s__anonymous15_1.__i__s_1));
    401392    return ((struct __anonymous15 )___src__14s__anonymous15_1);
     393}
     394static 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}
     397static 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}
     400static inline void ___destructor__F_P14s__anonymous15_autogen___1(struct __anonymous15 *___dst__P14s__anonymous15_1){
     401    ((void)((*((short *)(&(*___dst__P14s__anonymous15_1).__i__s_1)))) /* ^?{} */);
    402402}
    403403static inline void ___constructor__F_P14s__anonymous15s_autogen___1(struct __anonymous15 *___dst__P14s__anonymous15_1, short __i__s_1){
     
    428428static inline void ___constructor__F_P14s__anonymous1614s__anonymous16_autogen___1(struct __anonymous16 *___dst__P14s__anonymous16_1, struct __anonymous16 ___src__14s__anonymous16_1);
    429429static 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 }
    439430static inline struct __anonymous16 ___operator_assign__F14s__anonymous16_P14s__anonymous1614s__anonymous16_autogen___1(struct __anonymous16 *___dst__P14s__anonymous16_1, struct __anonymous16 ___src__14s__anonymous16_1){
    440431    ((void)((*___dst__P14s__anonymous16_1).__i__i_1=___src__14s__anonymous16_1.__i__i_1));
    441432    return ((struct __anonymous16 )___src__14s__anonymous16_1);
     433}
     434static 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}
     437static 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}
     440static inline void ___destructor__F_P14s__anonymous16_autogen___1(struct __anonymous16 *___dst__P14s__anonymous16_1){
     441    ((void)((*((int *)(&(*___dst__P14s__anonymous16_1).__i__i_1)))) /* ^?{} */);
    442442}
    443443static inline void ___constructor__F_P14s__anonymous16i_autogen___1(struct __anonymous16 *___dst__P14s__anonymous16_1, int __i__i_1){
     
    452452static inline void ___constructor__F_P14s__anonymous1714s__anonymous17_autogen___1(struct __anonymous17 *___dst__P14s__anonymous17_1, struct __anonymous17 ___src__14s__anonymous17_1);
    453453static 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 }
    463454static inline struct __anonymous17 ___operator_assign__F14s__anonymous17_P14s__anonymous1714s__anonymous17_autogen___1(struct __anonymous17 *___dst__P14s__anonymous17_1, struct __anonymous17 ___src__14s__anonymous17_1){
    464455    ((void)((*___dst__P14s__anonymous17_1).__i__i_1=___src__14s__anonymous17_1.__i__i_1));
    465456    return ((struct __anonymous17 )___src__14s__anonymous17_1);
     457}
     458static 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}
     461static 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}
     464static inline void ___destructor__F_P14s__anonymous17_autogen___1(struct __anonymous17 *___dst__P14s__anonymous17_1){
     465    ((void)((*((int *)(&(*___dst__P14s__anonymous17_1).__i__i_1)))) /* ^?{} */);
    466466}
    467467static inline void ___constructor__F_P14s__anonymous17i_autogen___1(struct __anonymous17 *___dst__P14s__anonymous17_1, int __i__i_1){
     
    476476static inline void ___constructor__F_P14s__anonymous1814s__anonymous18_autogen___1(struct __anonymous18 *___dst__P14s__anonymous18_1, struct __anonymous18 ___src__14s__anonymous18_1);
    477477static 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 }
    487478static inline struct __anonymous18 ___operator_assign__F14s__anonymous18_P14s__anonymous1814s__anonymous18_autogen___1(struct __anonymous18 *___dst__P14s__anonymous18_1, struct __anonymous18 ___src__14s__anonymous18_1){
    488479    ((void)((*___dst__P14s__anonymous18_1).__i__i_1=___src__14s__anonymous18_1.__i__i_1));
    489480    return ((struct __anonymous18 )___src__14s__anonymous18_1);
     481}
     482static 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}
     485static 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}
     488static inline void ___destructor__F_P14s__anonymous18_autogen___1(struct __anonymous18 *___dst__P14s__anonymous18_1){
     489    ((void)((*((int *)(&(*___dst__P14s__anonymous18_1).__i__i_1)))) /* ^?{} */);
    490490}
    491491static inline void ___constructor__F_P14s__anonymous18i_autogen___1(struct __anonymous18 *___dst__P14s__anonymous18_1, int __i__i_1){
     
    500500static inline void ___constructor__F_P14s__anonymous1914s__anonymous19_autogen___1(struct __anonymous19 *___dst__P14s__anonymous19_1, struct __anonymous19 ___src__14s__anonymous19_1);
    501501static 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 }
    511502static inline struct __anonymous19 ___operator_assign__F14s__anonymous19_P14s__anonymous1914s__anonymous19_autogen___1(struct __anonymous19 *___dst__P14s__anonymous19_1, struct __anonymous19 ___src__14s__anonymous19_1){
    512503    ((void)((*___dst__P14s__anonymous19_1).__i__i_1=___src__14s__anonymous19_1.__i__i_1));
    513504    return ((struct __anonymous19 )___src__14s__anonymous19_1);
     505}
     506static 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}
     509static 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}
     512static inline void ___destructor__F_P14s__anonymous19_autogen___1(struct __anonymous19 *___dst__P14s__anonymous19_1){
     513    ((void)((*((int *)(&(*___dst__P14s__anonymous19_1).__i__i_1)))) /* ^?{} */);
    514514}
    515515static inline void ___constructor__F_P14s__anonymous19i_autogen___1(struct __anonymous19 *___dst__P14s__anonymous19_1, int __i__i_1){
     
    524524static inline void ___constructor__F_P14s__anonymous2014s__anonymous20_autogen___1(struct __anonymous20 *___dst__P14s__anonymous20_1, struct __anonymous20 ___src__14s__anonymous20_1);
    525525static 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 }
    535526static inline struct __anonymous20 ___operator_assign__F14s__anonymous20_P14s__anonymous2014s__anonymous20_autogen___1(struct __anonymous20 *___dst__P14s__anonymous20_1, struct __anonymous20 ___src__14s__anonymous20_1){
    536527    ((void)((*___dst__P14s__anonymous20_1).__i__i_1=___src__14s__anonymous20_1.__i__i_1));
    537528    return ((struct __anonymous20 )___src__14s__anonymous20_1);
     529}
     530static 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}
     533static 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}
     536static inline void ___destructor__F_P14s__anonymous20_autogen___1(struct __anonymous20 *___dst__P14s__anonymous20_1){
     537    ((void)((*((int *)(&(*___dst__P14s__anonymous20_1).__i__i_1)))) /* ^?{} */);
    538538}
    539539static inline void ___constructor__F_P14s__anonymous20i_autogen___1(struct __anonymous20 *___dst__P14s__anonymous20_1, int __i__i_1){
     
    548548static inline void ___constructor__F_P14s__anonymous2114s__anonymous21_autogen___1(struct __anonymous21 *___dst__P14s__anonymous21_1, struct __anonymous21 ___src__14s__anonymous21_1);
    549549static 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 }
    559550static inline struct __anonymous21 ___operator_assign__F14s__anonymous21_P14s__anonymous2114s__anonymous21_autogen___1(struct __anonymous21 *___dst__P14s__anonymous21_1, struct __anonymous21 ___src__14s__anonymous21_1){
    560551    ((void)((*___dst__P14s__anonymous21_1).__i__i_1=___src__14s__anonymous21_1.__i__i_1));
    561552    return ((struct __anonymous21 )___src__14s__anonymous21_1);
     553}
     554static 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}
     557static 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}
     560static inline void ___destructor__F_P14s__anonymous21_autogen___1(struct __anonymous21 *___dst__P14s__anonymous21_1){
     561    ((void)((*((int *)(&(*___dst__P14s__anonymous21_1).__i__i_1)))) /* ^?{} */);
    562562}
    563563static inline void ___constructor__F_P14s__anonymous21i_autogen___1(struct __anonymous21 *___dst__P14s__anonymous21_1, int __i__i_1){
     
    572572static inline void ___constructor__F_P14s__anonymous2214s__anonymous22_autogen___1(struct __anonymous22 *___dst__P14s__anonymous22_1, struct __anonymous22 ___src__14s__anonymous22_1);
    573573static 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 }
    583574static inline struct __anonymous22 ___operator_assign__F14s__anonymous22_P14s__anonymous2214s__anonymous22_autogen___1(struct __anonymous22 *___dst__P14s__anonymous22_1, struct __anonymous22 ___src__14s__anonymous22_1){
    584575    ((void)((*___dst__P14s__anonymous22_1).__i__i_1=___src__14s__anonymous22_1.__i__i_1));
    585576    return ((struct __anonymous22 )___src__14s__anonymous22_1);
     577}
     578static 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}
     581static 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}
     584static inline void ___destructor__F_P14s__anonymous22_autogen___1(struct __anonymous22 *___dst__P14s__anonymous22_1){
     585    ((void)((*((int *)(&(*___dst__P14s__anonymous22_1).__i__i_1)))) /* ^?{} */);
    586586}
    587587static inline void ___constructor__F_P14s__anonymous22i_autogen___1(struct __anonymous22 *___dst__P14s__anonymous22_1, int __i__i_1){
     
    596596static inline void ___constructor__F_P14s__anonymous2314s__anonymous23_autogen___1(struct __anonymous23 *___dst__P14s__anonymous23_1, struct __anonymous23 ___src__14s__anonymous23_1);
    597597static 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 }
    607598static inline struct __anonymous23 ___operator_assign__F14s__anonymous23_P14s__anonymous2314s__anonymous23_autogen___1(struct __anonymous23 *___dst__P14s__anonymous23_1, struct __anonymous23 ___src__14s__anonymous23_1){
    608599    ((void)((*___dst__P14s__anonymous23_1).__i__i_1=___src__14s__anonymous23_1.__i__i_1));
    609600    return ((struct __anonymous23 )___src__14s__anonymous23_1);
     601}
     602static 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}
     605static 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}
     608static inline void ___destructor__F_P14s__anonymous23_autogen___1(struct __anonymous23 *___dst__P14s__anonymous23_1){
     609    ((void)((*((int *)(&(*___dst__P14s__anonymous23_1).__i__i_1)))) /* ^?{} */);
    610610}
    611611static inline void ___constructor__F_P14s__anonymous23i_autogen___1(struct __anonymous23 *___dst__P14s__anonymous23_1, int __i__i_1){
     
    622622static inline volatile const short __f48__FCVs___1();
    623623int main(int __argc__i_1, const char **__argv__PPCc_1){
    624     int ___retval_main__i_1;
    625     ((void)(___retval_main__i_1=((int )0)) /* ?{} */);
    626     return ((int )___retval_main__i_1);
    627 }
     624    int _retVal0 = { 0 };
     625    ((void)(_retVal0=((int )0)) /* ?{} */);
     626    return ((int )_retVal0);
     627}
  • src/tests/.expect/32/extension.txt

    r66f8528 r596f987b  
    1717static inline void ___constructor__F_P2sS2sS_autogen___1(struct S *___dst__P2sS_1, struct S ___src__2sS_1);
    1818static inline void ___destructor__F_P2sS_autogen___1(struct S *___dst__P2sS_1);
     19static 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}
    1925static inline void ___constructor__F_P2sS_autogen___1(struct S *___dst__P2sS_1){
    2026    ((void)((*((int *)(&(*___dst__P2sS_1).__a__i_1)))) /* ?{} */);
     
    3137    ((void)((*((int *)(&(*___dst__P2sS_1).__b__i_1)))) /* ^?{} */);
    3238    ((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);
    3939}
    4040static inline void ___constructor__F_P2sSi_autogen___1(struct S *___dst__P2sS_1, int __a__i_1){
     
    5858    __extension__ int __c__i_1;
    5959};
     60static 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}
    6064static inline void ___constructor__F_P2uU_autogen___1(union U *___dst__P2uU_1){
    6165}
    6266static inline void ___constructor__F_P2uU2uU_autogen___1(union U *___dst__P2uU_1, union U ___src__2uU_1){
    6367    ((void)__builtin_memcpy(((void *)___dst__P2uU_1), ((const void *)(&___src__2uU_1)), sizeof(union U )));
     68    return ((void)___src__2uU_1);
    6469}
    6570static 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);
    7071}
    7172static inline void ___constructor__F_P2uUi_autogen___1(union U *___dst__P2uU_1, int __src__i_1){
     
    7879};
    7980__extension__ int __fred__Fi_i__1(int __p__i_1){
    80     int ___retval_fred__i_1;
    8181    __extension__ struct S {
    8282        __extension__ int __a__i_2;
  • src/tests/.expect/32/gccExtensions.txt

    r66f8528 r596f987b  
    77extern int __x__i_1 asm ( "xx" );
    88int main(int __argc__i_1, const char **__argv__PPCc_1){
    9     int ___retval_main__i_1;
    109    asm ( "nop" :  :  :  );
    1110    asm ( "nop" :  :  :  );
     
    2625    const int __i3__Ci_2;
    2726    inline int __f1__Fi___2(){
    28         int ___retval_f1__i_2;
    2927    }
    3028    inline int __f2__Fi___2(){
    31         int ___retval_f2__i_2;
    3229    }
    3330    int __s1__i_2;
     
    4340        __extension__ int __c__i_2;
    4441    };
     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    }
    4548    inline void ___constructor__F_P2sS_autogen___2(struct S *___dst__P2sS_2){
    4649        ((void)((*((int *)(&(*___dst__P2sS_2).__a__i_2)))) /* ?{} */);
     
    5760        ((void)((*((int *)(&(*___dst__P2sS_2).__b__i_2)))) /* ^?{} */);
    5861        ((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);
    6562    }
    6663    inline void ___constructor__F_P2sSi_autogen___2(struct S *___dst__P2sS_2, int __a__i_2){
     
    9996        int __i__i_2;
    10097    };
     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    }
    101102    inline void ___constructor__F_P3ss2_autogen___2(struct s2 *___dst__P3ss2_2){
    102103        ((void)((*((int *)(&(*___dst__P3ss2_2).__i__i_2)))) /* ?{} */);
     
    108109        ((void)((*((int *)(&(*___dst__P3ss2_2).__i__i_2)))) /* ^?{} */);
    109110    }
    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     }
    114111    inline void ___constructor__F_P3ss2i_autogen___2(struct s2 *___dst__P3ss2_2, int __i__i_2){
    115112        ((void)((*((int *)(&(*___dst__P3ss2_2).__i__i_2)))=__i__i_2) /* ?{} */);
     
    118115        int __i__i_2;
    119116    };
     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    }
    120121    inline void ___constructor__F_P3ss3_autogen___2(struct s3 *___dst__P3ss3_2){
    121122        ((void)((*((int *)(&(*___dst__P3ss3_2).__i__i_2)))) /* ?{} */);
     
    127128        ((void)((*((int *)(&(*___dst__P3ss3_2).__i__i_2)))) /* ^?{} */);
    128129    }
    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     }
    133130    inline void ___constructor__F_P3ss3i_autogen___2(struct s3 *___dst__P3ss3_2, int __i__i_2){
    134131        ((void)((*((int *)(&(*___dst__P3ss3_2).__i__i_2)))=__i__i_2) /* ?{} */);
     
    139136        int __i__i_2;
    140137    };
     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    }
    141142    inline void ___constructor__F_P3ss4_autogen___2(struct s4 *___dst__P3ss4_2){
    142143        ((void)((*((int *)(&(*___dst__P3ss4_2).__i__i_2)))) /* ?{} */);
     
    148149        ((void)((*((int *)(&(*___dst__P3ss4_2).__i__i_2)))) /* ^?{} */);
    149150    }
    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     }
    154151    inline void ___constructor__F_P3ss4i_autogen___2(struct s4 *___dst__P3ss4_2, int __i__i_2){
    155152        ((void)((*((int *)(&(*___dst__P3ss4_2).__i__i_2)))=__i__i_2) /* ?{} */);
     
    160157    int __m2__A0A0i_2[((unsigned int )10)][((unsigned int )10)];
    161158    int __m3__A0A0i_2[((unsigned int )10)][((unsigned int )10)];
    162     ((void)(___retval_main__i_1=((int )0)) /* ?{} */);
    163     return ((int )___retval_main__i_1);
     159    int _retVal0 = { 0 };
     160    ((void)(_retVal0=((int )0)) /* ?{} */);
     161    return ((int )_retVal0);
    164162}
  • src/tests/.expect/64/declarationSpecifier.txt

    r66f8528 r596f987b  
    2020static inline void ___constructor__F_P13s__anonymous013s__anonymous0_autogen___1(struct __anonymous0 *___dst__P13s__anonymous0_1, struct __anonymous0 ___src__13s__anonymous0_1);
    2121static 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 }
    3122static inline struct __anonymous0 ___operator_assign__F13s__anonymous0_P13s__anonymous013s__anonymous0_autogen___1(struct __anonymous0 *___dst__P13s__anonymous0_1, struct __anonymous0 ___src__13s__anonymous0_1){
    3223    ((void)((*___dst__P13s__anonymous0_1).__i__i_1=___src__13s__anonymous0_1.__i__i_1));
    3324    return ((struct __anonymous0 )___src__13s__anonymous0_1);
     25}
     26static 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}
     29static 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}
     32static inline void ___destructor__F_P13s__anonymous0_autogen___1(struct __anonymous0 *___dst__P13s__anonymous0_1){
     33    ((void)((*((int *)(&(*___dst__P13s__anonymous0_1).__i__i_1)))) /* ^?{} */);
    3434}
    3535static inline void ___constructor__F_P13s__anonymous0i_autogen___1(struct __anonymous0 *___dst__P13s__anonymous0_1, int __i__i_1){
     
    4444static inline void ___constructor__F_P13s__anonymous113s__anonymous1_autogen___1(struct __anonymous1 *___dst__P13s__anonymous1_1, struct __anonymous1 ___src__13s__anonymous1_1);
    4545static 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 }
    5546static inline struct __anonymous1 ___operator_assign__F13s__anonymous1_P13s__anonymous113s__anonymous1_autogen___1(struct __anonymous1 *___dst__P13s__anonymous1_1, struct __anonymous1 ___src__13s__anonymous1_1){
    5647    ((void)((*___dst__P13s__anonymous1_1).__i__i_1=___src__13s__anonymous1_1.__i__i_1));
    5748    return ((struct __anonymous1 )___src__13s__anonymous1_1);
     49}
     50static 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}
     53static 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}
     56static inline void ___destructor__F_P13s__anonymous1_autogen___1(struct __anonymous1 *___dst__P13s__anonymous1_1){
     57    ((void)((*((int *)(&(*___dst__P13s__anonymous1_1).__i__i_1)))) /* ^?{} */);
    5858}
    5959static inline void ___constructor__F_P13s__anonymous1i_autogen___1(struct __anonymous1 *___dst__P13s__anonymous1_1, int __i__i_1){
     
    6868static inline void ___constructor__F_P13s__anonymous213s__anonymous2_autogen___1(struct __anonymous2 *___dst__P13s__anonymous2_1, struct __anonymous2 ___src__13s__anonymous2_1);
    6969static 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 }
    7970static inline struct __anonymous2 ___operator_assign__F13s__anonymous2_P13s__anonymous213s__anonymous2_autogen___1(struct __anonymous2 *___dst__P13s__anonymous2_1, struct __anonymous2 ___src__13s__anonymous2_1){
    8071    ((void)((*___dst__P13s__anonymous2_1).__i__i_1=___src__13s__anonymous2_1.__i__i_1));
    8172    return ((struct __anonymous2 )___src__13s__anonymous2_1);
     73}
     74static 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}
     77static 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}
     80static inline void ___destructor__F_P13s__anonymous2_autogen___1(struct __anonymous2 *___dst__P13s__anonymous2_1){
     81    ((void)((*((int *)(&(*___dst__P13s__anonymous2_1).__i__i_1)))) /* ^?{} */);
    8282}
    8383static inline void ___constructor__F_P13s__anonymous2i_autogen___1(struct __anonymous2 *___dst__P13s__anonymous2_1, int __i__i_1){
     
    9292static inline void ___constructor__F_P13s__anonymous313s__anonymous3_autogen___1(struct __anonymous3 *___dst__P13s__anonymous3_1, struct __anonymous3 ___src__13s__anonymous3_1);
    9393static 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 }
    10394static inline struct __anonymous3 ___operator_assign__F13s__anonymous3_P13s__anonymous313s__anonymous3_autogen___1(struct __anonymous3 *___dst__P13s__anonymous3_1, struct __anonymous3 ___src__13s__anonymous3_1){
    10495    ((void)((*___dst__P13s__anonymous3_1).__i__i_1=___src__13s__anonymous3_1.__i__i_1));
    10596    return ((struct __anonymous3 )___src__13s__anonymous3_1);
     97}
     98static 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}
     101static 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}
     104static inline void ___destructor__F_P13s__anonymous3_autogen___1(struct __anonymous3 *___dst__P13s__anonymous3_1){
     105    ((void)((*((int *)(&(*___dst__P13s__anonymous3_1).__i__i_1)))) /* ^?{} */);
    106106}
    107107static inline void ___constructor__F_P13s__anonymous3i_autogen___1(struct __anonymous3 *___dst__P13s__anonymous3_1, int __i__i_1){
     
    116116static inline void ___constructor__F_P13s__anonymous413s__anonymous4_autogen___1(struct __anonymous4 *___dst__P13s__anonymous4_1, struct __anonymous4 ___src__13s__anonymous4_1);
    117117static 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 }
    127118static inline struct __anonymous4 ___operator_assign__F13s__anonymous4_P13s__anonymous413s__anonymous4_autogen___1(struct __anonymous4 *___dst__P13s__anonymous4_1, struct __anonymous4 ___src__13s__anonymous4_1){
    128119    ((void)((*___dst__P13s__anonymous4_1).__i__i_1=___src__13s__anonymous4_1.__i__i_1));
    129120    return ((struct __anonymous4 )___src__13s__anonymous4_1);
     121}
     122static 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}
     125static 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}
     128static inline void ___destructor__F_P13s__anonymous4_autogen___1(struct __anonymous4 *___dst__P13s__anonymous4_1){
     129    ((void)((*((int *)(&(*___dst__P13s__anonymous4_1).__i__i_1)))) /* ^?{} */);
    130130}
    131131static inline void ___constructor__F_P13s__anonymous4i_autogen___1(struct __anonymous4 *___dst__P13s__anonymous4_1, int __i__i_1){
     
    140140static inline void ___constructor__F_P13s__anonymous513s__anonymous5_autogen___1(struct __anonymous5 *___dst__P13s__anonymous5_1, struct __anonymous5 ___src__13s__anonymous5_1);
    141141static 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 }
    151142static inline struct __anonymous5 ___operator_assign__F13s__anonymous5_P13s__anonymous513s__anonymous5_autogen___1(struct __anonymous5 *___dst__P13s__anonymous5_1, struct __anonymous5 ___src__13s__anonymous5_1){
    152143    ((void)((*___dst__P13s__anonymous5_1).__i__i_1=___src__13s__anonymous5_1.__i__i_1));
    153144    return ((struct __anonymous5 )___src__13s__anonymous5_1);
     145}
     146static 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}
     149static 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}
     152static inline void ___destructor__F_P13s__anonymous5_autogen___1(struct __anonymous5 *___dst__P13s__anonymous5_1){
     153    ((void)((*((int *)(&(*___dst__P13s__anonymous5_1).__i__i_1)))) /* ^?{} */);
    154154}
    155155static inline void ___constructor__F_P13s__anonymous5i_autogen___1(struct __anonymous5 *___dst__P13s__anonymous5_1, int __i__i_1){
     
    164164static inline void ___constructor__F_P13s__anonymous613s__anonymous6_autogen___1(struct __anonymous6 *___dst__P13s__anonymous6_1, struct __anonymous6 ___src__13s__anonymous6_1);
    165165static 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 }
    175166static inline struct __anonymous6 ___operator_assign__F13s__anonymous6_P13s__anonymous613s__anonymous6_autogen___1(struct __anonymous6 *___dst__P13s__anonymous6_1, struct __anonymous6 ___src__13s__anonymous6_1){
    176167    ((void)((*___dst__P13s__anonymous6_1).__i__i_1=___src__13s__anonymous6_1.__i__i_1));
    177168    return ((struct __anonymous6 )___src__13s__anonymous6_1);
     169}
     170static 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}
     173static 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}
     176static inline void ___destructor__F_P13s__anonymous6_autogen___1(struct __anonymous6 *___dst__P13s__anonymous6_1){
     177    ((void)((*((int *)(&(*___dst__P13s__anonymous6_1).__i__i_1)))) /* ^?{} */);
    178178}
    179179static inline void ___constructor__F_P13s__anonymous6i_autogen___1(struct __anonymous6 *___dst__P13s__anonymous6_1, int __i__i_1){
     
    188188static inline void ___constructor__F_P13s__anonymous713s__anonymous7_autogen___1(struct __anonymous7 *___dst__P13s__anonymous7_1, struct __anonymous7 ___src__13s__anonymous7_1);
    189189static 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 }
    199190static inline struct __anonymous7 ___operator_assign__F13s__anonymous7_P13s__anonymous713s__anonymous7_autogen___1(struct __anonymous7 *___dst__P13s__anonymous7_1, struct __anonymous7 ___src__13s__anonymous7_1){
    200191    ((void)((*___dst__P13s__anonymous7_1).__i__i_1=___src__13s__anonymous7_1.__i__i_1));
    201192    return ((struct __anonymous7 )___src__13s__anonymous7_1);
     193}
     194static 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}
     197static 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}
     200static inline void ___destructor__F_P13s__anonymous7_autogen___1(struct __anonymous7 *___dst__P13s__anonymous7_1){
     201    ((void)((*((int *)(&(*___dst__P13s__anonymous7_1).__i__i_1)))) /* ^?{} */);
    202202}
    203203static inline void ___constructor__F_P13s__anonymous7i_autogen___1(struct __anonymous7 *___dst__P13s__anonymous7_1, int __i__i_1){
     
    220220static inline void ___constructor__F_P13s__anonymous813s__anonymous8_autogen___1(struct __anonymous8 *___dst__P13s__anonymous8_1, struct __anonymous8 ___src__13s__anonymous8_1);
    221221static 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 }
    231222static inline struct __anonymous8 ___operator_assign__F13s__anonymous8_P13s__anonymous813s__anonymous8_autogen___1(struct __anonymous8 *___dst__P13s__anonymous8_1, struct __anonymous8 ___src__13s__anonymous8_1){
    232223    ((void)((*___dst__P13s__anonymous8_1).__i__s_1=___src__13s__anonymous8_1.__i__s_1));
    233224    return ((struct __anonymous8 )___src__13s__anonymous8_1);
     225}
     226static 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}
     229static 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}
     232static inline void ___destructor__F_P13s__anonymous8_autogen___1(struct __anonymous8 *___dst__P13s__anonymous8_1){
     233    ((void)((*((short *)(&(*___dst__P13s__anonymous8_1).__i__s_1)))) /* ^?{} */);
    234234}
    235235static inline void ___constructor__F_P13s__anonymous8s_autogen___1(struct __anonymous8 *___dst__P13s__anonymous8_1, short __i__s_1){
     
    244244static inline void ___constructor__F_P13s__anonymous913s__anonymous9_autogen___1(struct __anonymous9 *___dst__P13s__anonymous9_1, struct __anonymous9 ___src__13s__anonymous9_1);
    245245static 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 }
    255246static inline struct __anonymous9 ___operator_assign__F13s__anonymous9_P13s__anonymous913s__anonymous9_autogen___1(struct __anonymous9 *___dst__P13s__anonymous9_1, struct __anonymous9 ___src__13s__anonymous9_1){
    256247    ((void)((*___dst__P13s__anonymous9_1).__i__s_1=___src__13s__anonymous9_1.__i__s_1));
    257248    return ((struct __anonymous9 )___src__13s__anonymous9_1);
     249}
     250static 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}
     253static 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}
     256static inline void ___destructor__F_P13s__anonymous9_autogen___1(struct __anonymous9 *___dst__P13s__anonymous9_1){
     257    ((void)((*((short *)(&(*___dst__P13s__anonymous9_1).__i__s_1)))) /* ^?{} */);
    258258}
    259259static inline void ___constructor__F_P13s__anonymous9s_autogen___1(struct __anonymous9 *___dst__P13s__anonymous9_1, short __i__s_1){
     
    268268static inline void ___constructor__F_P14s__anonymous1014s__anonymous10_autogen___1(struct __anonymous10 *___dst__P14s__anonymous10_1, struct __anonymous10 ___src__14s__anonymous10_1);
    269269static 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 }
    279270static inline struct __anonymous10 ___operator_assign__F14s__anonymous10_P14s__anonymous1014s__anonymous10_autogen___1(struct __anonymous10 *___dst__P14s__anonymous10_1, struct __anonymous10 ___src__14s__anonymous10_1){
    280271    ((void)((*___dst__P14s__anonymous10_1).__i__s_1=___src__14s__anonymous10_1.__i__s_1));
    281272    return ((struct __anonymous10 )___src__14s__anonymous10_1);
     273}
     274static 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}
     277static 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}
     280static inline void ___destructor__F_P14s__anonymous10_autogen___1(struct __anonymous10 *___dst__P14s__anonymous10_1){
     281    ((void)((*((short *)(&(*___dst__P14s__anonymous10_1).__i__s_1)))) /* ^?{} */);
    282282}
    283283static inline void ___constructor__F_P14s__anonymous10s_autogen___1(struct __anonymous10 *___dst__P14s__anonymous10_1, short __i__s_1){
     
    292292static inline void ___constructor__F_P14s__anonymous1114s__anonymous11_autogen___1(struct __anonymous11 *___dst__P14s__anonymous11_1, struct __anonymous11 ___src__14s__anonymous11_1);
    293293static 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 }
    303294static inline struct __anonymous11 ___operator_assign__F14s__anonymous11_P14s__anonymous1114s__anonymous11_autogen___1(struct __anonymous11 *___dst__P14s__anonymous11_1, struct __anonymous11 ___src__14s__anonymous11_1){
    304295    ((void)((*___dst__P14s__anonymous11_1).__i__s_1=___src__14s__anonymous11_1.__i__s_1));
    305296    return ((struct __anonymous11 )___src__14s__anonymous11_1);
     297}
     298static 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}
     301static 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}
     304static inline void ___destructor__F_P14s__anonymous11_autogen___1(struct __anonymous11 *___dst__P14s__anonymous11_1){
     305    ((void)((*((short *)(&(*___dst__P14s__anonymous11_1).__i__s_1)))) /* ^?{} */);
    306306}
    307307static inline void ___constructor__F_P14s__anonymous11s_autogen___1(struct __anonymous11 *___dst__P14s__anonymous11_1, short __i__s_1){
     
    316316static inline void ___constructor__F_P14s__anonymous1214s__anonymous12_autogen___1(struct __anonymous12 *___dst__P14s__anonymous12_1, struct __anonymous12 ___src__14s__anonymous12_1);
    317317static 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 }
    327318static inline struct __anonymous12 ___operator_assign__F14s__anonymous12_P14s__anonymous1214s__anonymous12_autogen___1(struct __anonymous12 *___dst__P14s__anonymous12_1, struct __anonymous12 ___src__14s__anonymous12_1){
    328319    ((void)((*___dst__P14s__anonymous12_1).__i__s_1=___src__14s__anonymous12_1.__i__s_1));
    329320    return ((struct __anonymous12 )___src__14s__anonymous12_1);
     321}
     322static 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}
     325static 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}
     328static inline void ___destructor__F_P14s__anonymous12_autogen___1(struct __anonymous12 *___dst__P14s__anonymous12_1){
     329    ((void)((*((short *)(&(*___dst__P14s__anonymous12_1).__i__s_1)))) /* ^?{} */);
    330330}
    331331static inline void ___constructor__F_P14s__anonymous12s_autogen___1(struct __anonymous12 *___dst__P14s__anonymous12_1, short __i__s_1){
     
    340340static inline void ___constructor__F_P14s__anonymous1314s__anonymous13_autogen___1(struct __anonymous13 *___dst__P14s__anonymous13_1, struct __anonymous13 ___src__14s__anonymous13_1);
    341341static 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 }
    351342static inline struct __anonymous13 ___operator_assign__F14s__anonymous13_P14s__anonymous1314s__anonymous13_autogen___1(struct __anonymous13 *___dst__P14s__anonymous13_1, struct __anonymous13 ___src__14s__anonymous13_1){
    352343    ((void)((*___dst__P14s__anonymous13_1).__i__s_1=___src__14s__anonymous13_1.__i__s_1));
    353344    return ((struct __anonymous13 )___src__14s__anonymous13_1);
     345}
     346static 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}
     349static 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}
     352static inline void ___destructor__F_P14s__anonymous13_autogen___1(struct __anonymous13 *___dst__P14s__anonymous13_1){
     353    ((void)((*((short *)(&(*___dst__P14s__anonymous13_1).__i__s_1)))) /* ^?{} */);
    354354}
    355355static inline void ___constructor__F_P14s__anonymous13s_autogen___1(struct __anonymous13 *___dst__P14s__anonymous13_1, short __i__s_1){
     
    364364static inline void ___constructor__F_P14s__anonymous1414s__anonymous14_autogen___1(struct __anonymous14 *___dst__P14s__anonymous14_1, struct __anonymous14 ___src__14s__anonymous14_1);
    365365static 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 }
    375366static inline struct __anonymous14 ___operator_assign__F14s__anonymous14_P14s__anonymous1414s__anonymous14_autogen___1(struct __anonymous14 *___dst__P14s__anonymous14_1, struct __anonymous14 ___src__14s__anonymous14_1){
    376367    ((void)((*___dst__P14s__anonymous14_1).__i__s_1=___src__14s__anonymous14_1.__i__s_1));
    377368    return ((struct __anonymous14 )___src__14s__anonymous14_1);
     369}
     370static 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}
     373static 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}
     376static inline void ___destructor__F_P14s__anonymous14_autogen___1(struct __anonymous14 *___dst__P14s__anonymous14_1){
     377    ((void)((*((short *)(&(*___dst__P14s__anonymous14_1).__i__s_1)))) /* ^?{} */);
    378378}
    379379static inline void ___constructor__F_P14s__anonymous14s_autogen___1(struct __anonymous14 *___dst__P14s__anonymous14_1, short __i__s_1){
     
    388388static inline void ___constructor__F_P14s__anonymous1514s__anonymous15_autogen___1(struct __anonymous15 *___dst__P14s__anonymous15_1, struct __anonymous15 ___src__14s__anonymous15_1);
    389389static 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 }
    399390static inline struct __anonymous15 ___operator_assign__F14s__anonymous15_P14s__anonymous1514s__anonymous15_autogen___1(struct __anonymous15 *___dst__P14s__anonymous15_1, struct __anonymous15 ___src__14s__anonymous15_1){
    400391    ((void)((*___dst__P14s__anonymous15_1).__i__s_1=___src__14s__anonymous15_1.__i__s_1));
    401392    return ((struct __anonymous15 )___src__14s__anonymous15_1);
     393}
     394static 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}
     397static 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}
     400static inline void ___destructor__F_P14s__anonymous15_autogen___1(struct __anonymous15 *___dst__P14s__anonymous15_1){
     401    ((void)((*((short *)(&(*___dst__P14s__anonymous15_1).__i__s_1)))) /* ^?{} */);
    402402}
    403403static inline void ___constructor__F_P14s__anonymous15s_autogen___1(struct __anonymous15 *___dst__P14s__anonymous15_1, short __i__s_1){
     
    428428static inline void ___constructor__F_P14s__anonymous1614s__anonymous16_autogen___1(struct __anonymous16 *___dst__P14s__anonymous16_1, struct __anonymous16 ___src__14s__anonymous16_1);
    429429static 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 }
    439430static inline struct __anonymous16 ___operator_assign__F14s__anonymous16_P14s__anonymous1614s__anonymous16_autogen___1(struct __anonymous16 *___dst__P14s__anonymous16_1, struct __anonymous16 ___src__14s__anonymous16_1){
    440431    ((void)((*___dst__P14s__anonymous16_1).__i__i_1=___src__14s__anonymous16_1.__i__i_1));
    441432    return ((struct __anonymous16 )___src__14s__anonymous16_1);
     433}
     434static 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}
     437static 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}
     440static inline void ___destructor__F_P14s__anonymous16_autogen___1(struct __anonymous16 *___dst__P14s__anonymous16_1){
     441    ((void)((*((int *)(&(*___dst__P14s__anonymous16_1).__i__i_1)))) /* ^?{} */);
    442442}
    443443static inline void ___constructor__F_P14s__anonymous16i_autogen___1(struct __anonymous16 *___dst__P14s__anonymous16_1, int __i__i_1){
     
    452452static inline void ___constructor__F_P14s__anonymous1714s__anonymous17_autogen___1(struct __anonymous17 *___dst__P14s__anonymous17_1, struct __anonymous17 ___src__14s__anonymous17_1);
    453453static 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 }
    463454static inline struct __anonymous17 ___operator_assign__F14s__anonymous17_P14s__anonymous1714s__anonymous17_autogen___1(struct __anonymous17 *___dst__P14s__anonymous17_1, struct __anonymous17 ___src__14s__anonymous17_1){
    464455    ((void)((*___dst__P14s__anonymous17_1).__i__i_1=___src__14s__anonymous17_1.__i__i_1));
    465456    return ((struct __anonymous17 )___src__14s__anonymous17_1);
     457}
     458static 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}
     461static 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}
     464static inline void ___destructor__F_P14s__anonymous17_autogen___1(struct __anonymous17 *___dst__P14s__anonymous17_1){
     465    ((void)((*((int *)(&(*___dst__P14s__anonymous17_1).__i__i_1)))) /* ^?{} */);
    466466}
    467467static inline void ___constructor__F_P14s__anonymous17i_autogen___1(struct __anonymous17 *___dst__P14s__anonymous17_1, int __i__i_1){
     
    476476static inline void ___constructor__F_P14s__anonymous1814s__anonymous18_autogen___1(struct __anonymous18 *___dst__P14s__anonymous18_1, struct __anonymous18 ___src__14s__anonymous18_1);
    477477static 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 }
    487478static inline struct __anonymous18 ___operator_assign__F14s__anonymous18_P14s__anonymous1814s__anonymous18_autogen___1(struct __anonymous18 *___dst__P14s__anonymous18_1, struct __anonymous18 ___src__14s__anonymous18_1){
    488479    ((void)((*___dst__P14s__anonymous18_1).__i__i_1=___src__14s__anonymous18_1.__i__i_1));
    489480    return ((struct __anonymous18 )___src__14s__anonymous18_1);
     481}
     482static 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}
     485static 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}
     488static inline void ___destructor__F_P14s__anonymous18_autogen___1(struct __anonymous18 *___dst__P14s__anonymous18_1){
     489    ((void)((*((int *)(&(*___dst__P14s__anonymous18_1).__i__i_1)))) /* ^?{} */);
    490490}
    491491static inline void ___constructor__F_P14s__anonymous18i_autogen___1(struct __anonymous18 *___dst__P14s__anonymous18_1, int __i__i_1){
     
    500500static inline void ___constructor__F_P14s__anonymous1914s__anonymous19_autogen___1(struct __anonymous19 *___dst__P14s__anonymous19_1, struct __anonymous19 ___src__14s__anonymous19_1);
    501501static 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 }
    511502static inline struct __anonymous19 ___operator_assign__F14s__anonymous19_P14s__anonymous1914s__anonymous19_autogen___1(struct __anonymous19 *___dst__P14s__anonymous19_1, struct __anonymous19 ___src__14s__anonymous19_1){
    512503    ((void)((*___dst__P14s__anonymous19_1).__i__i_1=___src__14s__anonymous19_1.__i__i_1));
    513504    return ((struct __anonymous19 )___src__14s__anonymous19_1);
     505}
     506static 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}
     509static 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}
     512static inline void ___destructor__F_P14s__anonymous19_autogen___1(struct __anonymous19 *___dst__P14s__anonymous19_1){
     513    ((void)((*((int *)(&(*___dst__P14s__anonymous19_1).__i__i_1)))) /* ^?{} */);
    514514}
    515515static inline void ___constructor__F_P14s__anonymous19i_autogen___1(struct __anonymous19 *___dst__P14s__anonymous19_1, int __i__i_1){
     
    524524static inline void ___constructor__F_P14s__anonymous2014s__anonymous20_autogen___1(struct __anonymous20 *___dst__P14s__anonymous20_1, struct __anonymous20 ___src__14s__anonymous20_1);
    525525static 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 }
    535526static inline struct __anonymous20 ___operator_assign__F14s__anonymous20_P14s__anonymous2014s__anonymous20_autogen___1(struct __anonymous20 *___dst__P14s__anonymous20_1, struct __anonymous20 ___src__14s__anonymous20_1){
    536527    ((void)((*___dst__P14s__anonymous20_1).__i__i_1=___src__14s__anonymous20_1.__i__i_1));
    537528    return ((struct __anonymous20 )___src__14s__anonymous20_1);
     529}
     530static 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}
     533static 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}
     536static inline void ___destructor__F_P14s__anonymous20_autogen___1(struct __anonymous20 *___dst__P14s__anonymous20_1){
     537    ((void)((*((int *)(&(*___dst__P14s__anonymous20_1).__i__i_1)))) /* ^?{} */);
    538538}
    539539static inline void ___constructor__F_P14s__anonymous20i_autogen___1(struct __anonymous20 *___dst__P14s__anonymous20_1, int __i__i_1){
     
    548548static inline void ___constructor__F_P14s__anonymous2114s__anonymous21_autogen___1(struct __anonymous21 *___dst__P14s__anonymous21_1, struct __anonymous21 ___src__14s__anonymous21_1);
    549549static 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 }
    559550static inline struct __anonymous21 ___operator_assign__F14s__anonymous21_P14s__anonymous2114s__anonymous21_autogen___1(struct __anonymous21 *___dst__P14s__anonymous21_1, struct __anonymous21 ___src__14s__anonymous21_1){
    560551    ((void)((*___dst__P14s__anonymous21_1).__i__i_1=___src__14s__anonymous21_1.__i__i_1));
    561552    return ((struct __anonymous21 )___src__14s__anonymous21_1);
     553}
     554static 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}
     557static 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}
     560static inline void ___destructor__F_P14s__anonymous21_autogen___1(struct __anonymous21 *___dst__P14s__anonymous21_1){
     561    ((void)((*((int *)(&(*___dst__P14s__anonymous21_1).__i__i_1)))) /* ^?{} */);
    562562}
    563563static inline void ___constructor__F_P14s__anonymous21i_autogen___1(struct __anonymous21 *___dst__P14s__anonymous21_1, int __i__i_1){
     
    572572static inline void ___constructor__F_P14s__anonymous2214s__anonymous22_autogen___1(struct __anonymous22 *___dst__P14s__anonymous22_1, struct __anonymous22 ___src__14s__anonymous22_1);
    573573static 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 }
    583574static inline struct __anonymous22 ___operator_assign__F14s__anonymous22_P14s__anonymous2214s__anonymous22_autogen___1(struct __anonymous22 *___dst__P14s__anonymous22_1, struct __anonymous22 ___src__14s__anonymous22_1){
    584575    ((void)((*___dst__P14s__anonymous22_1).__i__i_1=___src__14s__anonymous22_1.__i__i_1));
    585576    return ((struct __anonymous22 )___src__14s__anonymous22_1);
     577}
     578static 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}
     581static 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}
     584static inline void ___destructor__F_P14s__anonymous22_autogen___1(struct __anonymous22 *___dst__P14s__anonymous22_1){
     585    ((void)((*((int *)(&(*___dst__P14s__anonymous22_1).__i__i_1)))) /* ^?{} */);
    586586}
    587587static inline void ___constructor__F_P14s__anonymous22i_autogen___1(struct __anonymous22 *___dst__P14s__anonymous22_1, int __i__i_1){
     
    596596static inline void ___constructor__F_P14s__anonymous2314s__anonymous23_autogen___1(struct __anonymous23 *___dst__P14s__anonymous23_1, struct __anonymous23 ___src__14s__anonymous23_1);
    597597static 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 }
    607598static inline struct __anonymous23 ___operator_assign__F14s__anonymous23_P14s__anonymous2314s__anonymous23_autogen___1(struct __anonymous23 *___dst__P14s__anonymous23_1, struct __anonymous23 ___src__14s__anonymous23_1){
    608599    ((void)((*___dst__P14s__anonymous23_1).__i__i_1=___src__14s__anonymous23_1.__i__i_1));
    609600    return ((struct __anonymous23 )___src__14s__anonymous23_1);
     601}
     602static 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}
     605static 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}
     608static inline void ___destructor__F_P14s__anonymous23_autogen___1(struct __anonymous23 *___dst__P14s__anonymous23_1){
     609    ((void)((*((int *)(&(*___dst__P14s__anonymous23_1).__i__i_1)))) /* ^?{} */);
    610610}
    611611static inline void ___constructor__F_P14s__anonymous23i_autogen___1(struct __anonymous23 *___dst__P14s__anonymous23_1, int __i__i_1){
     
    622622static inline volatile const short __f48__FCVs___1();
    623623int main(int __argc__i_1, const char **__argv__PPCc_1){
    624     int ___retval_main__i_1;
    625     ((void)(___retval_main__i_1=((int )0)) /* ?{} */);
    626     return ((int )___retval_main__i_1);
    627 }
     624    int _retVal0 = { 0 };
     625    ((void)(_retVal0=((int )0)) /* ?{} */);
     626    return ((int )_retVal0);
     627}
  • src/tests/.expect/64/extension.txt

    r66f8528 r596f987b  
    1717static inline void ___constructor__F_P2sS2sS_autogen___1(struct S *___dst__P2sS_1, struct S ___src__2sS_1);
    1818static inline void ___destructor__F_P2sS_autogen___1(struct S *___dst__P2sS_1);
     19static 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}
    1925static inline void ___constructor__F_P2sS_autogen___1(struct S *___dst__P2sS_1){
    2026    ((void)((*((int *)(&(*___dst__P2sS_1).__a__i_1)))) /* ?{} */);
     
    3137    ((void)((*((int *)(&(*___dst__P2sS_1).__b__i_1)))) /* ^?{} */);
    3238    ((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);
    3939}
    4040static inline void ___constructor__F_P2sSi_autogen___1(struct S *___dst__P2sS_1, int __a__i_1){
     
    5858    __extension__ int __c__i_1;
    5959};
     60static 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}
    6064static inline void ___constructor__F_P2uU_autogen___1(union U *___dst__P2uU_1){
    6165}
    6266static inline void ___constructor__F_P2uU2uU_autogen___1(union U *___dst__P2uU_1, union U ___src__2uU_1){
    6367    ((void)__builtin_memcpy(((void *)___dst__P2uU_1), ((const void *)(&___src__2uU_1)), sizeof(union U )));
     68    return ((void)___src__2uU_1);
    6469}
    6570static 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);
    7071}
    7172static inline void ___constructor__F_P2uUi_autogen___1(union U *___dst__P2uU_1, int __src__i_1){
     
    7879};
    7980__extension__ int __fred__Fi_i__1(int __p__i_1){
    80     int ___retval_fred__i_1;
    8181    __extension__ struct S {
    8282        __extension__ int __a__i_2;
  • src/tests/.expect/64/gccExtensions.txt

    r66f8528 r596f987b  
    77extern int __x__i_1 asm ( "xx" );
    88int main(int __argc__i_1, const char **__argv__PPCc_1){
    9     int ___retval_main__i_1;
    109    asm ( "nop" :  :  :  );
    1110    asm ( "nop" :  :  :  );
     
    2625    const int __i3__Ci_2;
    2726    inline int __f1__Fi___2(){
    28         int ___retval_f1__i_2;
    2927    }
    3028    inline int __f2__Fi___2(){
    31         int ___retval_f2__i_2;
    3229    }
    3330    int __s1__i_2;
     
    4340        __extension__ int __c__i_2;
    4441    };
     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    }
    4548    inline void ___constructor__F_P2sS_autogen___2(struct S *___dst__P2sS_2){
    4649        ((void)((*((int *)(&(*___dst__P2sS_2).__a__i_2)))) /* ?{} */);
     
    5760        ((void)((*((int *)(&(*___dst__P2sS_2).__b__i_2)))) /* ^?{} */);
    5861        ((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);
    6562    }
    6663    inline void ___constructor__F_P2sSi_autogen___2(struct S *___dst__P2sS_2, int __a__i_2){
     
    9996        int __i__i_2;
    10097    };
     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    }
    101102    inline void ___constructor__F_P3ss2_autogen___2(struct s2 *___dst__P3ss2_2){
    102103        ((void)((*((int *)(&(*___dst__P3ss2_2).__i__i_2)))) /* ?{} */);
     
    108109        ((void)((*((int *)(&(*___dst__P3ss2_2).__i__i_2)))) /* ^?{} */);
    109110    }
    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     }
    114111    inline void ___constructor__F_P3ss2i_autogen___2(struct s2 *___dst__P3ss2_2, int __i__i_2){
    115112        ((void)((*((int *)(&(*___dst__P3ss2_2).__i__i_2)))=__i__i_2) /* ?{} */);
     
    118115        int __i__i_2;
    119116    };
     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    }
    120121    inline void ___constructor__F_P3ss3_autogen___2(struct s3 *___dst__P3ss3_2){
    121122        ((void)((*((int *)(&(*___dst__P3ss3_2).__i__i_2)))) /* ?{} */);
     
    127128        ((void)((*((int *)(&(*___dst__P3ss3_2).__i__i_2)))) /* ^?{} */);
    128129    }
    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     }
    133130    inline void ___constructor__F_P3ss3i_autogen___2(struct s3 *___dst__P3ss3_2, int __i__i_2){
    134131        ((void)((*((int *)(&(*___dst__P3ss3_2).__i__i_2)))=__i__i_2) /* ?{} */);
     
    139136        int __i__i_2;
    140137    };
     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    }
    141142    inline void ___constructor__F_P3ss4_autogen___2(struct s4 *___dst__P3ss4_2){
    142143        ((void)((*((int *)(&(*___dst__P3ss4_2).__i__i_2)))) /* ?{} */);
     
    148149        ((void)((*((int *)(&(*___dst__P3ss4_2).__i__i_2)))) /* ^?{} */);
    149150    }
    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     }
    154151    inline void ___constructor__F_P3ss4i_autogen___2(struct s4 *___dst__P3ss4_2, int __i__i_2){
    155152        ((void)((*((int *)(&(*___dst__P3ss4_2).__i__i_2)))=__i__i_2) /* ?{} */);
     
    160157    int __m2__A0A0i_2[((long unsigned int )10)][((long unsigned int )10)];
    161158    int __m3__A0A0i_2[((long unsigned int )10)][((long unsigned int )10)];
    162     ((void)(___retval_main__i_1=((int )0)) /* ?{} */);
    163     return ((int )___retval_main__i_1);
     159    int _retVal0 = { 0 };
     160    ((void)(_retVal0=((int )0)) /* ?{} */);
     161    return ((int )_retVal0);
    164162}
  • src/tests/.expect/castError.txt

    r66f8528 r596f987b  
    1 Error: Can't choose between 3 alternatives for expression Cast of:
     1Error: Can't choose between alternatives for expression Cast of:
    22  Name: f
    33
  • src/tests/.expect/memberCtors.txt

    r66f8528 r596f987b  
    66constructing int
    77constructing int
    8 begin construct B
    9 assign b->a2
    108constructing int
    119constructing int
    12 begin construct A
    13 construct a->x
    1410constructing int: 1001
    15 assign a->y
    1611assigning int: 0 0
    17 end construct A
    18 construct b->a1
    1912constructing int
    2013constructing int
    21 begin construct A
    22 construct a->x
    2314constructing int: 1000
    24 assign a->y
    2515assigning int: 0 0
    26 end construct A
    27 end construct B
    2816destructing int: 0
    2917destructing int: 0
     
    3220copy constructing int: 0
    3321copy constructing int: 0
    34 begin copy construct A
    35 copy construct this->x
    3622copy constructing int: 1000
    37 assign this->y
    38 end copy construct A
    3923copy constructing int: 0
    4024copy constructing int: 0
    41 begin copy construct A
    42 copy construct this->x
    4325copy constructing int: 1001
    44 assign this->y
    45 end copy construct A
    4626copy constructing int: 0
    4727copy constructing int: 0
    48 begin copy construct A
    49 copy construct this->x
    5028copy constructing int: 0
    51 assign this->y
    52 end copy construct A
    5329End of main
    5430constructing int
    5531constructing int
    56 begin construct A
    57 construct a->x
    5832constructing int: 999
    59 assign a->y
    6033assigning int: 0 0
    61 end construct A
    6234destructing int: 0
    6335destructing int: 0
     
    7446constructing int
    7547constructing int
    76 begin construct A
    77 construct a->x
    7848constructing int: 999
    79 assign a->y
    8049assigning int: 0 0
    81 end construct A
    8250destructing int: 0
    8351destructing int: 0
  • src/tests/.expect/scopeErrors.txt

    r66f8528 r596f987b  
    44    double
    55  returning
    6     _retval_butThisIsAnError: double
     6    double
    77  with body
    88    CompoundStmt
  • src/tests/Makefile.am

    r66f8528 r596f987b  
    6767memberCtors-ERR1: memberCtors.c
    6868        ${CC} ${CFLAGS} -DERR1 ${<} -o ${@}
    69 
    70 completeTypeError : completeTypeError.c
    71         ${CC} ${CFLAGS} -DERR1 ${<} -o ${@}
  • src/tests/Makefile.in

    r66f8528 r596f987b  
    689689        ${CC} ${CFLAGS} -DERR1 ${<} -o ${@}
    690690
    691 completeTypeError : completeTypeError.c
    692         ${CC} ${CFLAGS} -DERR1 ${<} -o ${@}
    693 
    694691# Tell versions [3.59,3.63) of GNU make to not export all variables.
    695692# Otherwise a system limit (for SysV at least) may be exceeded.
  • src/tests/memberCtors.c

    r66f8528 r596f987b  
    3232
    3333void ?{}(A * a, int x) {
    34   printf("begin construct A\n");
    35   printf("construct a->x\n");
    3634  (&a->x){ x+999 };
    37   printf("assign a->y\n");
    3835  a->y = 0; // not a constructor - default constructor will be inserted
    39   printf("end construct A\n");
    4036} // z never constructed - will be automatically default constructed
    4137
    4238void ?{}(A * this, A other) {
    43   printf("begin copy construct A\n");
    44   printf("copy construct this->x\n");
    4539  (&this->x){ other.x };
    46   printf("assign this->y\n");
    4740  this->y = other.y; // not a constructor - copy constructor will be inserted
    48   printf("end copy construct A\n");
    4941} // z never constructed - will be automatically copy constructed
    5042
     
    5446
    5547void ?{}(B * b) {
    56   printf("begin construct B\n");
    57   printf("assign b->a2\n");
    5848  b->a2 = (A) { 2 };
    59   printf("construct b->a1\n");
    6049  (&b->a1){ 1 };
    6150#ifdef ERR1
    6251  (&b->a2){ b->a3 }; // error, b->a2 was used previously but is explicitly constructed
    6352#endif
    64   printf("end construct B\n");
    6553} // a2, a3 never constructed - will be automatically default constructed
    6654
  • src/tests/shortCircuit.c

    r66f8528 r596f987b  
    1111
    1212void g() {
    13         int a;
    14         struct { int b; } a;
    15         if ( a ) {
     13    int a;
     14    struct { int b; } a;
     15    if ( a ) {
    1616                while ( a ) {
    1717                        int *b;
     
    1919                        }
    2020                }
    21         }
     21    }
    2222}
    2323
  • src/tests/tupleAssign.c

    r66f8528 r596f987b  
    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 
    161int main() {
    172        {
     
    5439        }
    5540}
    56 
    57 // Local Variables: //
    58 // tab-width: 4 //
    59 // End: //
  • src/tests/tupleFunction.c

    r66f8528 r596f987b  
    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 
    161struct S {
    172        int f1, f2;
     
    5136}
    5237
     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// }
     45
    5346int main() {
    54         [int, double, int] x = [777, 2.76, 8675];
    55         int x1 = 123, x3 = 456;
    56         double x2 = 999.123;
     47  [int, double, int] x = [777, 2.76, 8675];
     48  int x1 = 123, x3 = 456;
     49  double x2 = 999.123;
    5750
    58         printf("foo(...)=%d\n", foo(x1, x3, x2, (S){ 321, 654, 'Q', 3.14 }));
     51  printf("foo(...)=%d\n", foo(x1, x3, x2, (S){ 321, 654, 'Q', 3.14 }));
    5952
    6053        // call function with tuple parameter using tuple variable arg
     
    8376        [x1, x2, x3] = quux();
    8477        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;
    9378}
    94 
    95 // Local Variables: //
    96 // tab-width: 4 //
    97 // End: //
    98 
  • src/tests/tupleMember.c

    r66f8528 r596f987b  
    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 
    161void f() {
    172        printf("called f!\n");
     
    5641        printf("v.[f1, i.[f2, f3], f4]=[%d, [%d, %d], %lg]\n", h().[f1, i.[f2, f3], f4]);
    5742}
    58 
    59 // Local Variables: //
    60 // tab-width: 4 //
    61 // End: //
Note: See TracChangeset for help on using the changeset viewer.