Changeset 837ce06
- 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
- Location:
- src
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
src/InitTweak/FixInit.cc
r6840e7c r837ce06 653 653 // wraps the more complicated code. 654 654 static UniqueName dtorNamer( "__cleanup_dtor" ); 655 FunctionDecl * dtorFunc = FunctionDecl::newFunction( dtorNamer.newName(), SymTab::genDefaultType( objDecl->type ), new CompoundStmt( noLabels ) );655 FunctionDecl * dtorFunc = FunctionDecl::newFunction( dtorNamer.newName(), SymTab::genDefaultType( objDecl->type, false ), new CompoundStmt( noLabels ) ); 656 656 stmtsToAddBefore.push_back( new DeclStmt( noLabels, dtorFunc ) ); 657 657 658 658 // the original code contains uses of objDecl - replace them with the newly generated 'this' parameter. 659 ObjectDecl * thisParam = get ThisParam( dtorFunc->type );659 ObjectDecl * thisParam = getParamThis( dtorFunc->type ); 660 660 VarExprReplacer::replace( dtor, { std::make_pair( objDecl, thisParam ) } ); 661 661 dtorFunc->statements->push_back( dtor ); -
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 -
src/SymTab/Autogen.h
r6840e7c r837ce06 45 45 extern FunctionDecl * dereferenceOperator; 46 46 47 // generate the type of an assignment function for paramType 48 FunctionType * genAssignType( Type * paramType ); 49 50 // generate the type of a default constructor or destructor for paramType 51 FunctionType * genDefaultType( Type * paramType ); 52 53 // generate the type of a copy constructor for paramType 54 FunctionType * genCopyType( Type * paramType ); 47 /// generate the type of an assignment function for paramType. 48 /// maybePolymorphic is true if the resulting FunctionType is allowed to be polymorphic 49 FunctionType * genAssignType( Type * paramType, bool maybePolymorphic = true ); 50 51 /// generate the type of a default constructor or destructor for paramType. 52 /// maybePolymorphic is true if the resulting FunctionType is allowed to be polymorphic 53 FunctionType * genDefaultType( Type * paramType, bool maybePolymorphic = true ); 54 55 /// generate the type of a copy constructor for paramType. 56 /// maybePolymorphic is true if the resulting FunctionType is allowed to be polymorphic 57 FunctionType * genCopyType( Type * paramType, bool maybePolymorphic = true ); 55 58 56 59 /// inserts into out a generated call expression to function fname with arguments dstParam and srcParam. Intended to be used with generated ?=?, ?{}, and ^?{} calls.
Note: See TracChangeset
for help on using the changeset viewer.