Changeset 490fb92e for src/SymTab
- Timestamp:
- Oct 23, 2020, 9:06:16 PM (4 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 37b7d95
- Parents:
- 41b8ea4
- Location:
- src/SymTab
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
src/SymTab/Autogen.cc
r41b8ea4 r490fb92e 233 233 } 234 234 235 // shallow copy the pointer list for return 236 std::vector<ast::ptr<ast::TypeDecl>> getGenericParams (const ast::Type * t) { 237 if (auto structInst = dynamic_cast<const ast::StructInstType*>(t)) { 238 return structInst->base->params; 239 } 240 if (auto unionInst = dynamic_cast<const ast::UnionInstType*>(t)) { 241 return unionInst->base->params; 242 } 243 return {}; 244 } 245 235 246 /// given type T, generate type of default ctor/dtor, i.e. function type void (*) (T *) 236 247 FunctionType * genDefaultType( Type * paramType, bool maybePolymorphic ) { … … 244 255 ftype->parameters.push_back( dstParam ); 245 256 return ftype; 257 } 258 259 /// 260 ast::FunctionDecl * genDefaultFunc(const CodeLocation loc, const std::string fname, const ast::Type * paramType, bool maybePolymorphic) { 261 std::vector<ast::ptr<ast::TypeDecl>> typeParams; 262 if (maybePolymorphic) typeParams = getGenericParams(paramType); 263 auto dstParam = new ast::ObjectDecl(loc, "_dst", new ast::ReferenceType(paramType), nullptr, {}, ast::Linkage::Cforall); 264 return new ast::FunctionDecl(loc, fname, std::move(typeParams), {dstParam}, {}, new ast::CompoundStmt(loc)); 246 265 } 247 266 -
src/SymTab/Autogen.h
r41b8ea4 r490fb92e 55 55 /// maybePolymorphic is true if the resulting FunctionType is allowed to be polymorphic 56 56 FunctionType * genDefaultType( Type * paramType, bool maybePolymorphic = true ); 57 58 ast::FunctionDecl * genDefaultFunc(const CodeLocation loc, const std::string fname, const ast::Type * paramType, bool maybePolymorphic = true); 57 59 58 60 /// generate the type of a copy constructor for paramType.
Note: See TracChangeset
for help on using the changeset viewer.