Changeset eef8dfb for src/SymTab/Autogen.cc
- Timestamp:
- Jan 7, 2021, 2:55:57 PM (5 years ago)
- Branches:
- ADT, arm-eh, ast-experimental, enum, forall-pointer-decay, jacob/cs343-translation, master, new-ast-unique-expr, pthread-emulation, qualifiedEnum
- Children:
- 58fe85a
- Parents:
- bdfc032 (diff), 44e37ef (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
rbdfc032 reef8dfb 38 38 #include "SynTree/Type.h" // for FunctionType, Type, TypeInstType 39 39 #include "SynTree/Visitor.h" // for maybeAccept, Visitor, acceptAll 40 #include "CompilationState.h" 40 41 41 42 class Attribute; … … 233 234 } 234 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 235 247 /// given type T, generate type of default ctor/dtor, i.e. function type void (*) (T *) 236 248 FunctionType * genDefaultType( Type * paramType, bool maybePolymorphic ) { … … 244 256 ftype->parameters.push_back( dstParam ); 245 257 return ftype; 258 } 259 260 /// 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)); 246 266 } 247 267 … … 327 347 void FuncGenerator::resolve( FunctionDecl * dcl ) { 328 348 try { 329 ResolvExpr::resolveDecl( dcl, indexer ); 349 if (!useNewAST) // attempt to delay resolver call 350 ResolvExpr::resolveDecl( dcl, indexer ); 330 351 if ( functionNesting == 0 ) { 331 352 // forward declare if top-level struct, so that … … 339 360 } catch ( SemanticErrorException & ) { 340 361 // okay if decl does not resolve - that means the function should not be generated 341 delete dcl; 362 // delete dcl; 363 delete dcl->statements; 364 dcl->statements = nullptr; 365 dcl->isDeleted = true; 366 definitions.push_back( dcl ); 367 indexer.addId( dcl ); 342 368 } 343 369 }
Note:
See TracChangeset
for help on using the changeset viewer.