Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SymTab/Autogen.cc

    r0dd9a5e rb8524ca  
    3838#include "SynTree/Type.h"          // for FunctionType, Type, TypeInstType
    3939#include "SynTree/Visitor.h"       // for maybeAccept, Visitor, acceptAll
    40 #include "CompilationState.h"
    4140
    4241class Attribute;
     
    234233        }
    235234
    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 
    247235        /// given type T, generate type of default ctor/dtor, i.e. function type void (*) (T *)
    248236        FunctionType * genDefaultType( Type * paramType, bool maybePolymorphic ) {
     
    256244                ftype->parameters.push_back( dstParam );
    257245                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));
    266246        }
    267247
     
    347327        void FuncGenerator::resolve( FunctionDecl * dcl ) {
    348328                try {
    349                         if (!useNewAST) // attempt to delay resolver call
    350                                 ResolvExpr::resolveDecl( dcl, indexer );
     329                        ResolvExpr::resolveDecl( dcl, indexer );
    351330                        if ( functionNesting == 0 ) {
    352331                                // forward declare if top-level struct, so that
     
    360339                } catch ( SemanticErrorException & ) {
    361340                        // 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;
    368342                }
    369343        }
Note: See TracChangeset for help on using the changeset viewer.