Changes in src/SymTab/Autogen.cc [0dd9a5e:b8524ca]
- File:
-
- 1 edited
-
src/SymTab/Autogen.cc (modified) (5 diffs)
Legend:
- Unmodified
- Added
- Removed
-
src/SymTab/Autogen.cc
r0dd9a5e rb8524ca 38 38 #include "SynTree/Type.h" // for FunctionType, Type, TypeInstType 39 39 #include "SynTree/Visitor.h" // for maybeAccept, Visitor, acceptAll 40 #include "CompilationState.h"41 40 42 41 class Attribute; … … 234 233 } 235 234 236 // shallow copy the pointer list for return237 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 247 235 /// given type T, generate type of default ctor/dtor, i.e. function type void (*) (T *) 248 236 FunctionType * genDefaultType( Type * paramType, bool maybePolymorphic ) { … … 256 244 ftype->parameters.push_back( dstParam ); 257 245 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));266 246 } 267 247 … … 347 327 void FuncGenerator::resolve( FunctionDecl * dcl ) { 348 328 try { 349 if (!useNewAST) // attempt to delay resolver call 350 ResolvExpr::resolveDecl( dcl, indexer ); 329 ResolvExpr::resolveDecl( dcl, indexer ); 351 330 if ( functionNesting == 0 ) { 352 331 // forward declare if top-level struct, so that … … 360 339 } catch ( SemanticErrorException & ) { 361 340 // okay if decl does not resolve - that means the function should not be generated 362 // delete dcl; 363 delete dcl->statements; 364 dcl->statements = nullptr; 365 dcl->isDeleted = true; 366 definitions.push_back( dcl ); 367 indexer.addId( dcl ); 341 delete dcl; 368 342 } 369 343 }
Note:
See TracChangeset
for help on using the changeset viewer.