Changes in src/SymTab/Autogen.cc [837ce06:e220391]
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SymTab/Autogen.cc
r837ce06 re220391 46 46 /// Data used to generate functions generically. Specifically, the name of the generated function and a function which generates the routine protoype 47 47 struct FuncData { 48 typedef FunctionType * (*TypeGen)( Type * , bool);48 typedef FunctionType * (*TypeGen)( Type * ); 49 49 FuncData( const std::string & fname, const TypeGen & genType ) : fname( fname ), genType( genType ) {} 50 50 std::string fname; … … 236 236 237 237 /// 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 ); 239 240 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 ); 245 242 ObjectDecl *dstParam = new ObjectDecl( "_dst", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, new ReferenceType( Type::Qualifiers(), paramType->clone() ), nullptr ); 246 243 ftype->parameters.push_back( dstParam ); … … 249 246 250 247 /// 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 ); 253 250 ObjectDecl *srcParam = new ObjectDecl( "_src", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, paramType->clone(), nullptr ); 254 251 ftype->parameters.push_back( srcParam ); … … 257 254 258 255 /// 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 ); 261 258 ObjectDecl *returnVal = new ObjectDecl( "_ret", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, paramType->clone(), nullptr ); 262 259 ftype->returnVals.push_back( returnVal ); … … 314 311 void FuncGenerator::generatePrototypes( std::list< FunctionDecl * > & newFuncs ) { 315 312 bool concurrent_type = isConcurrentType(); 316 for ( const FuncData & d ata: data ) {313 for ( const FuncData & d : data ) { 317 314 // generate a function (?{}, ?=?, ^?{}) based on the current FuncData. 318 FunctionType * ftype = d ata.genType( type, true );315 FunctionType * ftype = d.genType( type ); 319 316 320 317 // destructor for concurrent type must be mutex 321 if ( concurrent_type && CodeGen::isDestructor( d ata.fname ) ) {318 if ( concurrent_type && CodeGen::isDestructor( d.fname ) ) { 322 319 ftype->parameters.front()->get_type()->set_mutex( true ); 323 320 } 324 321 325 newFuncs.push_back( genFunc( d ata.fname, ftype, functionNesting ) );322 newFuncs.push_back( genFunc( d.fname, ftype, functionNesting ) ); 326 323 } 327 324 }
Note: See TracChangeset
for help on using the changeset viewer.