Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SymTab/Autogen.cc

    rfa4805f rce8c12f  
    99// Author           : Rob Schluntz
    1010// Created On       : Thu Mar 03 15:45:56 2016
    11 // Last Modified By : Andrew Beach
    12 // Last Modified On : Wed Jun 28 15:30:00 2017
    13 // Update Count     : 61
     11// Last Modified By : Peter A. Buhr
     12// Last Modified On : Fri Mar 17 09:41:08 2017
     13// Update Count     : 60
    1414//
    1515
     
    176176                        FunctionType * ftype = funcDecl->get_functionType();
    177177                        assert( ! ftype->get_parameters().empty() );
    178                         Type * t = safe_dynamic_cast< PointerType * >( ftype->get_parameters().front()->get_type() )->get_base();
     178                        Type * t = InitTweak::getPointerBase( ftype->get_parameters().front()->get_type() );
     179                        assert( t );
    179180                        map.insert( Mangler::mangleType( t ), true );
    180181                }
     
    262263        // E ?=?(E volatile*, int),
    263264        //   ?=?(E _Atomic volatile*, int);
    264         void makeEnumFunctions( EnumInstType *refType, unsigned int functionNesting, std::list< Declaration * > &declsToAdd ) {
     265        void makeEnumFunctions( EnumDecl *enumDecl, EnumInstType *refType, unsigned int functionNesting, std::list< Declaration * > &declsToAdd ) {
    265266
    266267                // T ?=?(E *, E);
     
    400401        /// generates struct constructors, destructor, and assignment functions
    401402        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 
    408403                // Make function polymorphic in same parameters as generic struct, if applicable
    409404                const std::list< TypeDecl* > & typeParams = aggregateDecl->get_parameters(); // List of type variables to be placed on the generated functions
     
    492487
    493488        /// generates the body of a union assignment/copy constructor/field constructor
    494         void makeUnionAssignBody( FunctionDecl * funcDecl ) {
     489        void makeUnionAssignBody( FunctionDecl * funcDecl, bool isDynamicLayout ) {
    495490                FunctionType * ftype = funcDecl->get_functionType();
    496491                assert( ftype->get_parameters().size() == 2 );
     
    512507                // Make function polymorphic in same parameters as generic union, if applicable
    513508                const std::list< TypeDecl* > & typeParams = aggregateDecl->get_parameters(); // List of type variables to be placed on the generated functions
    514                
     509                bool isDynamicLayout = hasDynamicLayout( aggregateDecl );  // NOTE this flag is an incredibly ugly kludge; we should fix the assignment signature instead (ditto for struct)
     510
    515511                // default ctor/dtor need only first parameter
    516512                // void ?{}(T *); void ^?{}(T *);
     
    538534                FunctionDecl *dtorDecl = genFunc( "^?{}", dtorType, functionNesting );
    539535
    540                 makeUnionAssignBody( assignDecl );
     536                makeUnionAssignBody( assignDecl, isDynamicLayout );
    541537
    542538                // body of assignment and copy ctor is the same
    543                 makeUnionAssignBody( copyCtorDecl );
     539                makeUnionAssignBody( copyCtorDecl, isDynamicLayout );
    544540
    545541                // create a constructor which takes the first member type as a parameter.
     
    556552                                FunctionDecl * ctor = genFunc( "?{}", memCtorType, functionNesting );
    557553
    558                                 makeUnionAssignBody( ctor );
     554                                makeUnionAssignBody( ctor, isDynamicLayout );
    559555                                memCtors.push_back( ctor );
    560556                                // only generate a ctor for the first field
     
    583579                        EnumInstType *enumInst = new EnumInstType( Type::Qualifiers(), enumDecl->get_name() );
    584580                        // enumInst->set_baseEnum( enumDecl );
    585                         makeEnumFunctions( enumInst, functionNesting, declsToAddAfter );
     581                        makeEnumFunctions( enumDecl, enumInst, functionNesting, declsToAddAfter );
    586582                }
    587583        }
Note: See TracChangeset for help on using the changeset viewer.