Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SymTab/Autogen.cc

    r6926a6d r2bfc6b2  
    4141
    4242namespace SymTab {
    43         Type * SizeType = 0;
    44 
    4543        /// Data used to generate functions generically. Specifically, the name of the generated function and a function which generates the routine protoype
    4644        struct FuncData {
    47                 typedef FunctionType * (*TypeGen)( Type * );
     45                typedef FunctionType * (*TypeGen)( Type *, bool );
    4846                FuncData( const std::string & fname, const TypeGen & genType ) : fname( fname ), genType( genType ) {}
    4947                std::string fname;
     
    231229
    232230        /// given type T, generate type of default ctor/dtor, i.e. function type void (*) (T *)
    233         FunctionType * genDefaultType( Type * paramType ) {
    234                 const auto & typeParams = getGenericParams( paramType );
     231        FunctionType * genDefaultType( Type * paramType, bool maybePolymorphic ) {
    235232                FunctionType *ftype = new FunctionType( Type::Qualifiers(), false );
    236                 cloneAll( typeParams, ftype->forall );
     233                if ( maybePolymorphic ) {
     234                        // only copy in
     235                        const auto & typeParams = getGenericParams( paramType );
     236                        cloneAll( typeParams, ftype->forall );
     237                }
    237238                ObjectDecl *dstParam = new ObjectDecl( "_dst", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, new ReferenceType( Type::Qualifiers(), paramType->clone() ), nullptr );
    238239                ftype->parameters.push_back( dstParam );
     
    241242
    242243        /// given type T, generate type of copy ctor, i.e. function type void (*) (T *, T)
    243         FunctionType * genCopyType( Type * paramType ) {
    244                 FunctionType *ftype = genDefaultType( paramType );
     244        FunctionType * genCopyType( Type * paramType, bool maybePolymorphic ) {
     245                FunctionType *ftype = genDefaultType( paramType, maybePolymorphic );
    245246                ObjectDecl *srcParam = new ObjectDecl( "_src", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, paramType->clone(), nullptr );
    246247                ftype->parameters.push_back( srcParam );
     
    249250
    250251        /// given type T, generate type of assignment, i.e. function type T (*) (T *, T)
    251         FunctionType * genAssignType( Type * paramType ) {
    252                 FunctionType *ftype = genCopyType( paramType );
     252        FunctionType * genAssignType( Type * paramType, bool maybePolymorphic ) {
     253                FunctionType *ftype = genCopyType( paramType, maybePolymorphic );
    253254                ObjectDecl *returnVal = new ObjectDecl( "_ret", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, paramType->clone(), nullptr );
    254255                ftype->returnVals.push_back( returnVal );
     
    308309                for ( const FuncData & d : data ) {
    309310                        // generate a function (?{}, ?=?, ^?{}) based on the current FuncData.
    310                         FunctionType * ftype = d.genType( type );
     311                        FunctionType * ftype = d.genType( type, true );
    311312
    312313                        // destructor for concurrent type must be mutex
Note: See TracChangeset for help on using the changeset viewer.