Changes in src/SymTab/Autogen.cc [fb4dc28:3992098]
- File:
-
- 1 edited
-
src/SymTab/Autogen.cc (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/SymTab/Autogen.cc
rfb4dc28 r3992098 10 10 // Created On : Thu Mar 03 15:45:56 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Fri Apr 14 15:03:00 202313 // Update Count : 6 412 // Last Modified On : Fri Apr 27 14:39:06 2018 13 // Update Count : 63 14 14 // 15 15 … … 211 211 } 212 212 213 bool isUnnamedBitfield( const ast::ObjectDecl * obj ) { 214 return obj && obj->name.empty() && obj->bitfieldWidth; 215 } 216 213 217 /// inserts a forward declaration for functionDecl into declsToAdd 214 218 void addForwardDecl( FunctionDecl * functionDecl, std::list< Declaration * > & declsToAdd ) { … … 230 234 } 231 235 236 // shallow copy the pointer list for return 237 std::vector<ast::ptr<ast::TypeDecl>> getGenericParams (const ast::Type * t) { 238 if (auto structInst = dynamic_cast<const ast::StructInstType*>(t)) { 239 return structInst->base->params; 240 } 241 if (auto unionInst = dynamic_cast<const ast::UnionInstType*>(t)) { 242 return unionInst->base->params; 243 } 244 return {}; 245 } 246 232 247 /// given type T, generate type of default ctor/dtor, i.e. function type void (*) (T *) 233 248 FunctionType * genDefaultType( Type * paramType, bool maybePolymorphic ) { … … 241 256 ftype->parameters.push_back( dstParam ); 242 257 return ftype; 258 } 259 260 /// Given type T, generate type of default ctor/dtor, i.e. function type void (*) (T &). 261 ast::FunctionDecl * genDefaultFunc(const CodeLocation loc, const std::string fname, const ast::Type * paramType, bool maybePolymorphic) { 262 std::vector<ast::ptr<ast::TypeDecl>> typeParams; 263 if (maybePolymorphic) typeParams = getGenericParams(paramType); 264 auto dstParam = new ast::ObjectDecl(loc, "_dst", new ast::ReferenceType(paramType), nullptr, {}, ast::Linkage::Cforall); 265 return new ast::FunctionDecl(loc, fname, std::move(typeParams), {dstParam}, {}, new ast::CompoundStmt(loc), {}, ast::Linkage::Cforall); 243 266 } 244 267
Note:
See TracChangeset
for help on using the changeset viewer.