Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SymTab/Autogen.h

    rb95fe40 r837ce06  
    4545        extern FunctionDecl * dereferenceOperator;
    4646
    47         // generate the type of an assignment function for paramType
    48         FunctionType * genAssignType( Type * paramType );
    49 
    50         // generate the type of a default constructor or destructor for paramType
    51         FunctionType * genDefaultType( Type * paramType );
    52 
    53         // generate the type of a copy constructor for paramType
    54         FunctionType * genCopyType( Type * paramType );
     47        /// generate the type of an assignment function for paramType.
     48        /// maybePolymorphic is true if the resulting FunctionType is allowed to be polymorphic
     49        FunctionType * genAssignType( Type * paramType, bool maybePolymorphic = true );
     50
     51        /// generate the type of a default constructor or destructor for paramType.
     52        /// maybePolymorphic is true if the resulting FunctionType is allowed to be polymorphic
     53        FunctionType * genDefaultType( Type * paramType, bool maybePolymorphic = true );
     54
     55        /// generate the type of a copy constructor for paramType.
     56        /// maybePolymorphic is true if the resulting FunctionType is allowed to be polymorphic
     57        FunctionType * genCopyType( Type * paramType, bool maybePolymorphic = true );
    5558
    5659        /// inserts into out a generated call expression to function fname with arguments dstParam and srcParam. Intended to be used with generated ?=?, ?{}, and ^?{} calls.
    5760        template< typename OutputIterator >
    58         Statement * genCall( InitTweak::InitExpander & srcParam, Expression * dstParam, const std::string & fname, OutputIterator out, Type * type, Type * addCast = nullptr, bool forward = true );
     61        Statement * genCall( InitTweak::InitExpander & srcParam, Expression * dstParam, const std::string & fname, OutputIterator out, Type * type, bool addCast = false, bool forward = true );
    5962
    6063        /// inserts into out a generated call expression to function fname with arguments dstParam and srcParam. Should only be called with non-array types.
    6164        /// optionally returns a statement which must be inserted prior to the containing loop, if there is one
    6265        template< typename OutputIterator >
    63         Statement * genScalarCall( InitTweak::InitExpander & srcParam, Expression * dstParam, std::string fname, OutputIterator out, Type * type, Type * addCast = nullptr ) {
     66        Statement * genScalarCall( InitTweak::InitExpander & srcParam, Expression * dstParam, std::string fname, OutputIterator out, Type * type, bool addCast = false ) {
    6467                bool isReferenceCtorDtor = false;
    6568                if ( dynamic_cast< ReferenceType * >( type ) && CodeGen::isCtorDtor( fname ) ) {
     
    6871                        fname = "?=?";
    6972                        dstParam = new AddressExpr( dstParam );
    70                         addCast = nullptr;
     73                        addCast = false;
    7174                        isReferenceCtorDtor = true;
    7275                }
     
    8386                        // remove lvalue as a qualifier, this can change to
    8487                        //   type->get_qualifiers() = Type::Qualifiers();
    85                         Type * castType = addCast->clone();
     88                        assert( type );
     89                        Type * castType = type->clone();
    8690                        castType->get_qualifiers() -= Type::Qualifiers( Type::Lvalue | Type::Const | Type::Volatile | Type::Restrict | Type::Atomic );
    8791                        // castType->set_lvalue( true ); // xxx - might not need this
     
    114118        /// If forward is true, loop goes from 0 to N-1, else N-1 to 0
    115119        template< typename OutputIterator >
    116         void genArrayCall( InitTweak::InitExpander & srcParam, Expression *dstParam, const std::string & fname, OutputIterator out, ArrayType *array, Type * addCast = nullptr, bool forward = true ) {
     120        void genArrayCall( InitTweak::InitExpander & srcParam, Expression *dstParam, const std::string & fname, OutputIterator out, ArrayType *array, bool addCast = false, bool forward = true ) {
    117121                static UniqueName indexName( "_index" );
    118122
    119123                // for a flexible array member nothing is done -- user must define own assignment
    120                 if ( ! array->get_dimension() ) return;
    121 
    122                 if ( addCast ) {
    123                         // peel off array layer from cast
    124                         ArrayType * at = strict_dynamic_cast< ArrayType * >( addCast );
    125                         addCast = at->base;
    126                 }
     124                if ( ! array->get_dimension() ) return ;
    127125
    128126                Expression * begin, * end, * update, * cmp;
     
    176174
    177175        template< typename OutputIterator >
    178         Statement * genCall( InitTweak::InitExpander & srcParam, Expression * dstParam, const std::string & fname, OutputIterator out, Type * type, Type * addCast, bool forward ) {
     176        Statement * genCall( InitTweak::InitExpander & srcParam, Expression * dstParam, const std::string & fname, OutputIterator out, Type * type, bool addCast, bool forward ) {
    179177                if ( ArrayType * at = dynamic_cast< ArrayType * >( type ) ) {
    180178                        genArrayCall( srcParam, dstParam, fname, out, at, addCast, forward );
     
    196194                if ( isUnnamedBitfield( obj ) ) return;
    197195
    198                 Type * addCast = nullptr;
    199                 if ( (fname == "?{}" || fname == "^?{}") && ( !obj || ( obj && ! obj->get_bitfieldWidth() ) ) ) {
    200                         assert( dstParam->result );
    201                         addCast = dstParam->result;
    202                 }
     196                bool addCast = (fname == "?{}" || fname == "^?{}") && ( !obj || ( obj && ! obj->get_bitfieldWidth() ) );
    203197                std::list< Statement * > stmts;
    204198                genCall( srcParam, dstParam, fname, back_inserter( stmts ), obj->type, addCast, forward );
Note: See TracChangeset for help on using the changeset viewer.