Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SymTab/Autogen.h

    r8404321 rd180746  
    4040        extern Type * SizeType;
    4141
    42         /// intrinsic dereference operator for unqualified types - set when *? function is seen in FindSpecialDeclarations.
    43         /// Useful for creating dereference ApplicationExprs without a full resolver pass.
    44         extern FunctionDecl * dereferenceOperator;
    45 
    46         // generate the type of an assignment function for paramType
    47         FunctionType * genAssignType( Type * paramType );
    48 
    49         // generate the type of a default constructor or destructor for paramType
    50         FunctionType * genDefaultType( Type * paramType );
    51 
    52         // generate the type of a copy constructor for paramType
    53         FunctionType * genCopyType( Type * paramType );
    54 
    5542        /// inserts into out a generated call expression to function fname with arguments dstParam and srcParam. Intended to be used with generated ?=?, ?{}, and ^?{} calls.
    5643        template< typename OutputIterator >
     
    6148        template< typename OutputIterator >
    6249        Statement * genScalarCall( InitTweak::InitExpander & srcParam, Expression *dstParam, const std::string & fname, OutputIterator out, Type * type, bool addCast = false ) {
    63                 // want to be able to generate assignment, ctor, and dtor generically,
    64                 // so fname is either ?=?, ?{}, or ^?{}
    65                 UntypedExpr *fExpr = new UntypedExpr( new NameExpr( fname ) );
     50        // want to be able to generate assignment, ctor, and dtor generically,
     51        // so fname is either ?=?, ?{}, or ^?{}
     52        UntypedExpr *fExpr = new UntypedExpr( new NameExpr( fname ) );
    6653
    67                 if ( addCast ) {
    68                         // cast to T& with qualifiers removed, so that qualified objects can be constructed
    69                         // and destructed with the same functions as non-qualified objects.
    70                         // unfortunately, lvalue is considered a qualifier. For AddressExpr to resolve, its argument
    71                         // must have an lvalue qualified type, so remove all qualifiers except lvalue. If we ever
    72                         // remove lvalue as a qualifier, this can change to
    73                         //   type->get_qualifiers() = Type::Qualifiers();
    74                         assert( type );
    75                         Type * castType = type->clone();
    76                         castType->get_qualifiers() -= Type::Qualifiers( Type::Lvalue | Type::Const | Type::Volatile | Type::Restrict | Type::Atomic );
    77                         // castType->set_lvalue( true ); // xxx - might not need this
    78                         dstParam = new CastExpr( dstParam, new ReferenceType( Type::Qualifiers(), castType ) );
    79                 }
    80                 fExpr->get_args().push_back( dstParam );
     54        // do something special for unnamed members
     55        dstParam = new AddressExpr( dstParam );
     56        if ( addCast ) {
     57                // cast to T* with qualifiers removed, so that qualified objects can be constructed
     58                // and destructed with the same functions as non-qualified objects.
     59                // unfortunately, lvalue is considered a qualifier. For AddressExpr to resolve, its argument
     60                // must have an lvalue qualified type, so remove all qualifiers except lvalue. If we ever
     61                // remove lvalue as a qualifier, this can change to
     62                //   type->get_qualifiers() = Type::Qualifiers();
     63                assert( type );
     64                Type * castType = type->clone();
     65                castType->get_qualifiers() -= Type::Qualifiers( Type::Const | Type::Volatile | Type::Restrict | Type::Atomic );
     66                castType->set_lvalue( true ); // xxx - might not need this
     67                dstParam = new CastExpr( dstParam, new PointerType( Type::Qualifiers(), castType ) );
     68        }
     69        fExpr->get_args().push_back( dstParam );
    8170
    82                 Statement * listInit = srcParam.buildListInit( fExpr );
     71        Statement * listInit = srcParam.buildListInit( fExpr );
    8372
    84                 std::list< Expression * > args = *++srcParam;
    85                 fExpr->get_args().splice( fExpr->get_args().end(), args );
     73        std::list< Expression * > args = *++srcParam;
     74        fExpr->get_args().splice( fExpr->get_args().end(), args );
    8675
    87                 *out++ = new ExprStmt( noLabels, fExpr );
     76        *out++ = new ExprStmt( noLabels, fExpr );
    8877
    89                 srcParam.clearArrayIndices();
     78        srcParam.clearArrayIndices();
    9079
    91                 return listInit;
     80        return listInit;
    9281        }
    9382
     
    125114
    126115                UntypedExpr *inc = new UntypedExpr( update );
    127                 inc->get_args().push_back( new VariableExpr( index ) );
     116                inc->get_args().push_back( new AddressExpr( new VariableExpr( index ) ) );
    128117
    129118                UntypedExpr *dstIndex = new UntypedExpr( new NameExpr( "?[?]" ) );
Note: See TracChangeset for help on using the changeset viewer.