Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SymTab/Autogen.cc

    rfb4dc28 r3992098  
    1010// Created On       : Thu Mar 03 15:45:56 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Apr 14 15:03:00 2023
    13 // Update Count     : 64
     12// Last Modified On : Fri Apr 27 14:39:06 2018
     13// Update Count     : 63
    1414//
    1515
     
    211211        }
    212212
     213        bool isUnnamedBitfield( const ast::ObjectDecl * obj ) {
     214                return obj && obj->name.empty() && obj->bitfieldWidth;
     215        }
     216
    213217        /// inserts a forward declaration for functionDecl into declsToAdd
    214218        void addForwardDecl( FunctionDecl * functionDecl, std::list< Declaration * > & declsToAdd ) {
     
    230234        }
    231235
     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
    232247        /// given type T, generate type of default ctor/dtor, i.e. function type void (*) (T *)
    233248        FunctionType * genDefaultType( Type * paramType, bool maybePolymorphic ) {
     
    241256                ftype->parameters.push_back( dstParam );
    242257                return ftype;
     258        }
     259
     260        /// Given type T, generate type of default ctor/dtor, i.e. function type void (*) (T &).
     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), {}, ast::Linkage::Cforall);
    243266        }
    244267
Note: See TracChangeset for help on using the changeset viewer.