Ignore:
Timestamp:
Oct 19, 2017, 2:20:53 PM (6 years ago)
Author:
Rob Schluntz <rschlunt@…>
Branches:
ADT, arm-eh, ast-experimental, cleanup-dtors, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
Children:
72f85de
Parents:
6840e7c
Message:

Fix cleanup function generation to always generate monomorphic functions

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SymTab/Autogen.cc

    r6840e7c r837ce06  
    4646        /// Data used to generate functions generically. Specifically, the name of the generated function and a function which generates the routine protoype
    4747        struct FuncData {
    48                 typedef FunctionType * (*TypeGen)( Type * );
     48                typedef FunctionType * (*TypeGen)( Type *, bool );
    4949                FuncData( const std::string & fname, const TypeGen & genType ) : fname( fname ), genType( genType ) {}
    5050                std::string fname;
     
    236236
    237237        /// given type T, generate type of default ctor/dtor, i.e. function type void (*) (T *)
    238         FunctionType * genDefaultType( Type * paramType ) {
    239                 const auto & typeParams = getGenericParams( paramType );
     238        FunctionType * genDefaultType( Type * paramType, bool maybePolymorphic ) {
    240239                FunctionType *ftype = new FunctionType( Type::Qualifiers(), false );
    241                 cloneAll( typeParams, ftype->forall );
     240                if ( maybePolymorphic ) {
     241                        // only copy in
     242                        const auto & typeParams = getGenericParams( paramType );
     243                        cloneAll( typeParams, ftype->forall );
     244                }
    242245                ObjectDecl *dstParam = new ObjectDecl( "_dst", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, new ReferenceType( Type::Qualifiers(), paramType->clone() ), nullptr );
    243246                ftype->parameters.push_back( dstParam );
     
    246249
    247250        /// given type T, generate type of copy ctor, i.e. function type void (*) (T *, T)
    248         FunctionType * genCopyType( Type * paramType ) {
    249                 FunctionType *ftype = genDefaultType( paramType );
     251        FunctionType * genCopyType( Type * paramType, bool maybePolymorphic ) {
     252                FunctionType *ftype = genDefaultType( paramType, maybePolymorphic );
    250253                ObjectDecl *srcParam = new ObjectDecl( "_src", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, paramType->clone(), nullptr );
    251254                ftype->parameters.push_back( srcParam );
     
    254257
    255258        /// given type T, generate type of assignment, i.e. function type T (*) (T *, T)
    256         FunctionType * genAssignType( Type * paramType ) {
    257                 FunctionType *ftype = genCopyType( paramType );
     259        FunctionType * genAssignType( Type * paramType, bool maybePolymorphic ) {
     260                FunctionType *ftype = genCopyType( paramType, maybePolymorphic );
    258261                ObjectDecl *returnVal = new ObjectDecl( "_ret", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, paramType->clone(), nullptr );
    259262                ftype->returnVals.push_back( returnVal );
     
    313316                for ( const FuncData & data : data ) {
    314317                        // generate a function (?{}, ?=?, ^?{}) based on the current FuncData.
    315                         FunctionType * ftype = data.genType( type );
     318                        FunctionType * ftype = data.genType( type, true );
    316319
    317320                        // destructor for concurrent type must be mutex
Note: See TracChangeset for help on using the changeset viewer.