Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SymTab/Autogen.cc

    rce8c12f rfa4805f  
    99// Author           : Rob Schluntz
    1010// Created On       : Thu Mar 03 15:45:56 2016
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Fri Mar 17 09:41:08 2017
    13 // Update Count     : 60
     11// Last Modified By : Andrew Beach
     12// Last Modified On : Wed Jun 28 15:30:00 2017
     13// Update Count     : 61
    1414//
    1515
     
    176176                        FunctionType * ftype = funcDecl->get_functionType();
    177177                        assert( ! ftype->get_parameters().empty() );
    178                         Type * t = InitTweak::getPointerBase( ftype->get_parameters().front()->get_type() );
    179                         assert( t );
     178                        Type * t = safe_dynamic_cast< PointerType * >( ftype->get_parameters().front()->get_type() )->get_base();
    180179                        map.insert( Mangler::mangleType( t ), true );
    181180                }
     
    263262        // E ?=?(E volatile*, int),
    264263        //   ?=?(E _Atomic volatile*, int);
    265         void makeEnumFunctions( EnumDecl *enumDecl, EnumInstType *refType, unsigned int functionNesting, std::list< Declaration * > &declsToAdd ) {
     264        void makeEnumFunctions( EnumInstType *refType, unsigned int functionNesting, std::list< Declaration * > &declsToAdd ) {
    266265
    267266                // T ?=?(E *, E);
     
    401400        /// generates struct constructors, destructor, and assignment functions
    402401        void makeStructFunctions( StructDecl *aggregateDecl, StructInstType *refType, unsigned int functionNesting, std::list< Declaration * > & declsToAdd, const std::vector< FuncData > & data ) {
     402                // Builtins do not use autogeneration.
     403                if ( aggregateDecl->get_linkage() == LinkageSpec::Builtin ||
     404                         aggregateDecl->get_linkage() == LinkageSpec::BuiltinC ) {
     405                        return;
     406                }
     407
    403408                // Make function polymorphic in same parameters as generic struct, if applicable
    404409                const std::list< TypeDecl* > & typeParams = aggregateDecl->get_parameters(); // List of type variables to be placed on the generated functions
     
    487492
    488493        /// generates the body of a union assignment/copy constructor/field constructor
    489         void makeUnionAssignBody( FunctionDecl * funcDecl, bool isDynamicLayout ) {
     494        void makeUnionAssignBody( FunctionDecl * funcDecl ) {
    490495                FunctionType * ftype = funcDecl->get_functionType();
    491496                assert( ftype->get_parameters().size() == 2 );
     
    507512                // Make function polymorphic in same parameters as generic union, if applicable
    508513                const std::list< TypeDecl* > & typeParams = aggregateDecl->get_parameters(); // List of type variables to be placed on the generated functions
    509                 bool isDynamicLayout = hasDynamicLayout( aggregateDecl );  // NOTE this flag is an incredibly ugly kludge; we should fix the assignment signature instead (ditto for struct)
    510 
     514               
    511515                // default ctor/dtor need only first parameter
    512516                // void ?{}(T *); void ^?{}(T *);
     
    534538                FunctionDecl *dtorDecl = genFunc( "^?{}", dtorType, functionNesting );
    535539
    536                 makeUnionAssignBody( assignDecl, isDynamicLayout );
     540                makeUnionAssignBody( assignDecl );
    537541
    538542                // body of assignment and copy ctor is the same
    539                 makeUnionAssignBody( copyCtorDecl, isDynamicLayout );
     543                makeUnionAssignBody( copyCtorDecl );
    540544
    541545                // create a constructor which takes the first member type as a parameter.
     
    552556                                FunctionDecl * ctor = genFunc( "?{}", memCtorType, functionNesting );
    553557
    554                                 makeUnionAssignBody( ctor, isDynamicLayout );
     558                                makeUnionAssignBody( ctor );
    555559                                memCtors.push_back( ctor );
    556560                                // only generate a ctor for the first field
     
    579583                        EnumInstType *enumInst = new EnumInstType( Type::Qualifiers(), enumDecl->get_name() );
    580584                        // enumInst->set_baseEnum( enumDecl );
    581                         makeEnumFunctions( enumDecl, enumInst, functionNesting, declsToAddAfter );
     585                        makeEnumFunctions( enumInst, functionNesting, declsToAddAfter );
    582586                }
    583587        }
Note: See TracChangeset for help on using the changeset viewer.