Changeset 837ce06 for src/SymTab/Autogen.cc
- Timestamp:
- Oct 19, 2017, 2:20:53 PM (7 years ago)
- 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
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SymTab/Autogen.cc
r6840e7c r837ce06 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 * );48 typedef FunctionType * (*TypeGen)( Type *, bool ); 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 ) { 239 const auto & typeParams = getGenericParams( paramType ); 238 FunctionType * genDefaultType( Type * paramType, bool maybePolymorphic ) { 240 239 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 } 242 245 ObjectDecl *dstParam = new ObjectDecl( "_dst", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, new ReferenceType( Type::Qualifiers(), paramType->clone() ), nullptr ); 243 246 ftype->parameters.push_back( dstParam ); … … 246 249 247 250 /// 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 ); 250 253 ObjectDecl *srcParam = new ObjectDecl( "_src", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, paramType->clone(), nullptr ); 251 254 ftype->parameters.push_back( srcParam ); … … 254 257 255 258 /// 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 ); 258 261 ObjectDecl *returnVal = new ObjectDecl( "_ret", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, paramType->clone(), nullptr ); 259 262 ftype->returnVals.push_back( returnVal ); … … 313 316 for ( const FuncData & data : data ) { 314 317 // generate a function (?{}, ?=?, ^?{}) based on the current FuncData. 315 FunctionType * ftype = data.genType( type );318 FunctionType * ftype = data.genType( type, true ); 316 319 317 320 // destructor for concurrent type must be mutex
Note: See TracChangeset
for help on using the changeset viewer.