Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SymTab/Autogen.cc

    r837ce06 re220391  
    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 *, bool );
     48                typedef FunctionType * (*TypeGen)( Type * );
    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, bool maybePolymorphic ) {
     238        FunctionType * genDefaultType( Type * paramType ) {
     239                const auto & typeParams = getGenericParams( paramType );
    239240                FunctionType *ftype = new FunctionType( Type::Qualifiers(), false );
    240                 if ( maybePolymorphic ) {
    241                         // only copy in
    242                         const auto & typeParams = getGenericParams( paramType );
    243                         cloneAll( typeParams, ftype->forall );
    244                 }
     241                cloneAll( typeParams, ftype->forall );
    245242                ObjectDecl *dstParam = new ObjectDecl( "_dst", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, new ReferenceType( Type::Qualifiers(), paramType->clone() ), nullptr );
    246243                ftype->parameters.push_back( dstParam );
     
    249246
    250247        /// given type T, generate type of copy ctor, i.e. function type void (*) (T *, T)
    251         FunctionType * genCopyType( Type * paramType, bool maybePolymorphic ) {
    252                 FunctionType *ftype = genDefaultType( paramType, maybePolymorphic );
     248        FunctionType * genCopyType( Type * paramType ) {
     249                FunctionType *ftype = genDefaultType( paramType );
    253250                ObjectDecl *srcParam = new ObjectDecl( "_src", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, paramType->clone(), nullptr );
    254251                ftype->parameters.push_back( srcParam );
     
    257254
    258255        /// given type T, generate type of assignment, i.e. function type T (*) (T *, T)
    259         FunctionType * genAssignType( Type * paramType, bool maybePolymorphic ) {
    260                 FunctionType *ftype = genCopyType( paramType, maybePolymorphic );
     256        FunctionType * genAssignType( Type * paramType ) {
     257                FunctionType *ftype = genCopyType( paramType );
    261258                ObjectDecl *returnVal = new ObjectDecl( "_ret", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, paramType->clone(), nullptr );
    262259                ftype->returnVals.push_back( returnVal );
     
    314311        void FuncGenerator::generatePrototypes( std::list< FunctionDecl * > & newFuncs ) {
    315312                bool concurrent_type = isConcurrentType();
    316                 for ( const FuncData & data : data ) {
     313                for ( const FuncData & d : data ) {
    317314                        // generate a function (?{}, ?=?, ^?{}) based on the current FuncData.
    318                         FunctionType * ftype = data.genType( type, true );
     315                        FunctionType * ftype = d.genType( type );
    319316
    320317                        // destructor for concurrent type must be mutex
    321                         if ( concurrent_type && CodeGen::isDestructor( data.fname ) ) {
     318                        if ( concurrent_type && CodeGen::isDestructor( d.fname ) ) {
    322319                                ftype->parameters.front()->get_type()->set_mutex( true );
    323320                        }
    324321
    325                         newFuncs.push_back( genFunc( data.fname, ftype, functionNesting ) );
     322                        newFuncs.push_back( genFunc( d.fname, ftype, functionNesting ) );
    326323                }
    327324        }
Note: See TracChangeset for help on using the changeset viewer.