Ignore:
Timestamp:
Jan 7, 2021, 2:55:57 PM (5 years ago)
Author:
Thierry Delisle <tdelisle@…>
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.
Message:

Merge branch 'master' into dkobets-vector

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SymTab/Autogen.cc

    rbdfc032 reef8dfb  
    3838#include "SynTree/Type.h"          // for FunctionType, Type, TypeInstType
    3939#include "SynTree/Visitor.h"       // for maybeAccept, Visitor, acceptAll
     40#include "CompilationState.h"
    4041
    4142class Attribute;
     
    233234        }
    234235
     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
    235247        /// given type T, generate type of default ctor/dtor, i.e. function type void (*) (T *)
    236248        FunctionType * genDefaultType( Type * paramType, bool maybePolymorphic ) {
     
    244256                ftype->parameters.push_back( dstParam );
    245257                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));
    246266        }
    247267
     
    327347        void FuncGenerator::resolve( FunctionDecl * dcl ) {
    328348                try {
    329                         ResolvExpr::resolveDecl( dcl, indexer );
     349                        if (!useNewAST) // attempt to delay resolver call
     350                                ResolvExpr::resolveDecl( dcl, indexer );
    330351                        if ( functionNesting == 0 ) {
    331352                                // forward declare if top-level struct, so that
     
    339360                } catch ( SemanticErrorException & ) {
    340361                        // 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 );
    342368                }
    343369        }
Note: See TracChangeset for help on using the changeset viewer.