Changes in src/SymTab/Autogen.cc [b8524ca:6926a6d]
- File:
-
- 1 edited
-
src/SymTab/Autogen.cc (modified) (8 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/SymTab/Autogen.cc
rb8524ca r6926a6d 24 24 #include <vector> // for vector 25 25 26 #include "AST/Decl.hpp"27 26 #include "CodeGen/OperatorTable.h" // for isCtorDtor, isCtorDtorAssign 28 27 #include "Common/PassVisitor.h" // for PassVisitor … … 42 41 43 42 namespace SymTab { 43 Type * SizeType = 0; 44 44 45 /// Data used to generate functions generically. Specifically, the name of the generated function and a function which generates the routine protoype 45 46 struct FuncData { 46 typedef FunctionType * (*TypeGen)( Type * , bool);47 typedef FunctionType * (*TypeGen)( Type * ); 47 48 FuncData( const std::string & fname, const TypeGen & genType ) : fname( fname ), genType( genType ) {} 48 49 std::string fname; … … 210 211 } 211 212 212 bool isUnnamedBitfield( const ast::ObjectDecl * obj ) {213 return obj && obj->name.empty() && obj->bitfieldWidth;214 }215 216 213 /// inserts a forward declaration for functionDecl into declsToAdd 217 214 void addForwardDecl( FunctionDecl * functionDecl, std::list< Declaration * > & declsToAdd ) { … … 234 231 235 232 /// given type T, generate type of default ctor/dtor, i.e. function type void (*) (T *) 236 FunctionType * genDefaultType( Type * paramType, bool maybePolymorphic ) { 233 FunctionType * genDefaultType( Type * paramType ) { 234 const auto & typeParams = getGenericParams( paramType ); 237 235 FunctionType *ftype = new FunctionType( Type::Qualifiers(), false ); 238 if ( maybePolymorphic ) { 239 // only copy in 240 const auto & typeParams = getGenericParams( paramType ); 241 cloneAll( typeParams, ftype->forall ); 242 } 236 cloneAll( typeParams, ftype->forall ); 243 237 ObjectDecl *dstParam = new ObjectDecl( "_dst", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, new ReferenceType( Type::Qualifiers(), paramType->clone() ), nullptr ); 244 238 ftype->parameters.push_back( dstParam ); … … 247 241 248 242 /// given type T, generate type of copy ctor, i.e. function type void (*) (T *, T) 249 FunctionType * genCopyType( Type * paramType , bool maybePolymorphic) {250 FunctionType *ftype = genDefaultType( paramType , maybePolymorphic);243 FunctionType * genCopyType( Type * paramType ) { 244 FunctionType *ftype = genDefaultType( paramType ); 251 245 ObjectDecl *srcParam = new ObjectDecl( "_src", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, paramType->clone(), nullptr ); 252 246 ftype->parameters.push_back( srcParam ); … … 255 249 256 250 /// given type T, generate type of assignment, i.e. function type T (*) (T *, T) 257 FunctionType * genAssignType( Type * paramType , bool maybePolymorphic) {258 FunctionType *ftype = genCopyType( paramType , maybePolymorphic);251 FunctionType * genAssignType( Type * paramType ) { 252 FunctionType *ftype = genCopyType( paramType ); 259 253 ObjectDecl *returnVal = new ObjectDecl( "_ret", Type::StorageClasses(), LinkageSpec::Cforall, nullptr, paramType->clone(), nullptr ); 260 254 ftype->returnVals.push_back( returnVal ); … … 314 308 for ( const FuncData & d : data ) { 315 309 // generate a function (?{}, ?=?, ^?{}) based on the current FuncData. 316 FunctionType * ftype = d.genType( type , true);310 FunctionType * ftype = d.genType( type ); 317 311 318 312 // destructor for concurrent type must be mutex … … 393 387 394 388 void StructFuncGenerator::makeMemberOp( ObjectDecl * dstParam, Expression * src, DeclarationWithType * field, FunctionDecl * func, bool forward ) { 395 InitTweak::InitExpander _oldsrcParam( src );389 InitTweak::InitExpander srcParam( src ); 396 390 397 391 // assign to destination
Note:
See TracChangeset
for help on using the changeset viewer.