Changeset b067d9b for src/SymTab/Autogen.cc
- Timestamp:
- Oct 29, 2019, 4:01:24 PM (6 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 773db65, 9421f3d8
- Parents:
- 7951100 (diff), 8364209 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SymTab/Autogen.cc
r7951100 rb067d9b 24 24 #include <vector> // for vector 25 25 26 #include "AST/Decl.hpp" 26 27 #include "CodeGen/OperatorTable.h" // for isCtorDtor, isCtorDtorAssign 27 28 #include "Common/PassVisitor.h" // for PassVisitor … … 41 42 42 43 namespace SymTab { 43 Type * SizeType = 0;44 45 44 /// Data used to generate functions generically. Specifically, the name of the generated function and a function which generates the routine protoype 46 45 struct FuncData { 47 typedef FunctionType * (*TypeGen)( Type * );46 typedef FunctionType * (*TypeGen)( Type *, bool ); 48 47 FuncData( const std::string & fname, const TypeGen & genType ) : fname( fname ), genType( genType ) {} 49 48 std::string fname; … … 211 210 } 212 211 212 bool isUnnamedBitfield( const ast::ObjectDecl * obj ) { 213 return obj && obj->name.empty() && obj->bitfieldWidth; 214 } 215 213 216 /// inserts a forward declaration for functionDecl into declsToAdd 214 217 void addForwardDecl( FunctionDecl * functionDecl, std::list< Declaration * > & declsToAdd ) { … … 231 234 232 235 /// 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 ); 236 FunctionType * genDefaultType( Type * paramType, bool maybePolymorphic ) { 235 237 FunctionType *ftype = new FunctionType( Type::Qualifiers(), false ); 236 cloneAll( typeParams, ftype->forall ); 238 if ( maybePolymorphic ) { 239 // only copy in 240 const auto & typeParams = getGenericParams( paramType ); 241 cloneAll( typeParams, ftype->forall ); 242 } 237 243 ObjectDecl *dstParam = new ObjectDecl( "_dst", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, new ReferenceType( Type::Qualifiers(), paramType->clone() ), nullptr ); 238 244 ftype->parameters.push_back( dstParam ); … … 241 247 242 248 /// 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 );249 FunctionType * genCopyType( Type * paramType, bool maybePolymorphic ) { 250 FunctionType *ftype = genDefaultType( paramType, maybePolymorphic ); 245 251 ObjectDecl *srcParam = new ObjectDecl( "_src", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, paramType->clone(), nullptr ); 246 252 ftype->parameters.push_back( srcParam ); … … 249 255 250 256 /// given type T, generate type of assignment, i.e. function type T (*) (T *, T) 251 FunctionType * genAssignType( Type * paramType ) {252 FunctionType *ftype = genCopyType( paramType );257 FunctionType * genAssignType( Type * paramType, bool maybePolymorphic ) { 258 FunctionType *ftype = genCopyType( paramType, maybePolymorphic ); 253 259 ObjectDecl *returnVal = new ObjectDecl( "_ret", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, paramType->clone(), nullptr ); 254 260 ftype->returnVals.push_back( returnVal ); … … 308 314 for ( const FuncData & d : data ) { 309 315 // generate a function (?{}, ?=?, ^?{}) based on the current FuncData. 310 FunctionType * ftype = d.genType( type );316 FunctionType * ftype = d.genType( type, true ); 311 317 312 318 // destructor for concurrent type must be mutex … … 387 393 388 394 void StructFuncGenerator::makeMemberOp( ObjectDecl * dstParam, Expression * src, DeclarationWithType * field, FunctionDecl * func, bool forward ) { 389 InitTweak::InitExpander srcParam( src );395 InitTweak::InitExpander_old srcParam( src ); 390 396 391 397 // assign to destination
Note:
See TracChangeset
for help on using the changeset viewer.