Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SymTab/Autogen.h

    r837ce06 rb95fe40  
    4545        extern FunctionDecl * dereferenceOperator;
    4646
    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 );
     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 );
    5855
    5956        /// inserts into out a generated call expression to function fname with arguments dstParam and srcParam. Intended to be used with generated ?=?, ?{}, and ^?{} calls.
    6057        template< typename OutputIterator >
    61         Statement * genCall( InitTweak::InitExpander & srcParam, Expression * dstParam, const std::string & fname, OutputIterator out, Type * type, bool addCast = false, bool forward = true );
     58        Statement * genCall( InitTweak::InitExpander & srcParam, Expression * dstParam, const std::string & fname, OutputIterator out, Type * type, Type * addCast = nullptr, bool forward = true );
    6259
    6360        /// inserts into out a generated call expression to function fname with arguments dstParam and srcParam. Should only be called with non-array types.
    6461        /// optionally returns a statement which must be inserted prior to the containing loop, if there is one
    6562        template< typename OutputIterator >
    66         Statement * genScalarCall( InitTweak::InitExpander & srcParam, Expression * dstParam, std::string fname, OutputIterator out, Type * type, bool addCast = false ) {
     63        Statement * genScalarCall( InitTweak::InitExpander & srcParam, Expression * dstParam, std::string fname, OutputIterator out, Type * type, Type * addCast = nullptr ) {
    6764                bool isReferenceCtorDtor = false;
    6865                if ( dynamic_cast< ReferenceType * >( type ) && CodeGen::isCtorDtor( fname ) ) {
     
    7168                        fname = "?=?";
    7269                        dstParam = new AddressExpr( dstParam );
    73                         addCast = false;
     70                        addCast = nullptr;
    7471                        isReferenceCtorDtor = true;
    7572                }
     
    8683                        // remove lvalue as a qualifier, this can change to
    8784                        //   type->get_qualifiers() = Type::Qualifiers();
    88                         assert( type );
    89                         Type * castType = type->clone();
     85                        Type * castType = addCast->clone();
    9086                        castType->get_qualifiers() -= Type::Qualifiers( Type::Lvalue | Type::Const | Type::Volatile | Type::Restrict | Type::Atomic );
    9187                        // castType->set_lvalue( true ); // xxx - might not need this
     
    118114        /// If forward is true, loop goes from 0 to N-1, else N-1 to 0
    119115        template< typename OutputIterator >
    120         void genArrayCall( InitTweak::InitExpander & srcParam, Expression *dstParam, const std::string & fname, OutputIterator out, ArrayType *array, bool addCast = false, bool forward = true ) {
     116        void genArrayCall( InitTweak::InitExpander & srcParam, Expression *dstParam, const std::string & fname, OutputIterator out, ArrayType *array, Type * addCast = nullptr, bool forward = true ) {
    121117                static UniqueName indexName( "_index" );
    122118
    123119                // for a flexible array member nothing is done -- user must define own assignment
    124                 if ( ! array->get_dimension() ) return ;
     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                }
    125127
    126128                Expression * begin, * end, * update, * cmp;
     
    174176
    175177        template< typename OutputIterator >
    176         Statement * genCall( InitTweak::InitExpander & srcParam, Expression * dstParam, const std::string & fname, OutputIterator out, Type * type, bool addCast, bool forward ) {
     178        Statement * genCall( InitTweak::InitExpander & srcParam, Expression * dstParam, const std::string & fname, OutputIterator out, Type * type, Type * addCast, bool forward ) {
    177179                if ( ArrayType * at = dynamic_cast< ArrayType * >( type ) ) {
    178180                        genArrayCall( srcParam, dstParam, fname, out, at, addCast, forward );
     
    194196                if ( isUnnamedBitfield( obj ) ) return;
    195197
    196                 bool addCast = (fname == "?{}" || fname == "^?{}") && ( !obj || ( obj && ! obj->get_bitfieldWidth() ) );
     198                Type * addCast = nullptr;
     199                if ( (fname == "?{}" || fname == "^?{}") && ( !obj || ( obj && ! obj->get_bitfieldWidth() ) ) ) {
     200                        assert( dstParam->result );
     201                        addCast = dstParam->result;
     202                }
    197203                std::list< Statement * > stmts;
    198204                genCall( srcParam, dstParam, fname, back_inserter( stmts ), obj->type, addCast, forward );
Note: See TracChangeset for help on using the changeset viewer.