Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SymTab/Autogen.h

    r8a6cf7e r6b0b624  
    1010// Created On       : Sun May 17 21:53:34 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Wed Jun 21 17:25:26 2017
    13 // Update Count     : 14
     12// Last Modified On : Sat Jul 22 09:50:25 2017
     13// Update Count     : 15
    1414//
    1515
    16 #ifndef AUTOGEN_H
    17 #define AUTOGEN_H
     16#pragma once
    1817
    1918#include <string>
     
    3534        extern Type * SizeType;
    3635
    37         /// intrinsic dereference operator for unqualified types - set when *? function is seen in FindSpecialDeclarations.
    38         /// Useful for creating dereference ApplicationExprs without a full resolver pass.
    39         extern FunctionDecl * dereferenceOperator;
    40 
    41         // temporary
    42         FunctionType * genAssignType( Type * paramType );
    43 
    4436        /// inserts into out a generated call expression to function fname with arguments dstParam and srcParam. Intended to be used with generated ?=?, ?{}, and ^?{} calls.
    4537        template< typename OutputIterator >
     
    5042        template< typename OutputIterator >
    5143        Statement * genScalarCall( InitTweak::InitExpander & srcParam, Expression *dstParam, const std::string & fname, OutputIterator out, Type * type, bool addCast = false ) {
    52                 // want to be able to generate assignment, ctor, and dtor generically,
    53                 // so fname is either ?=?, ?{}, or ^?{}
    54                 UntypedExpr *fExpr = new UntypedExpr( new NameExpr( fname ) );
     44        // want to be able to generate assignment, ctor, and dtor generically,
     45        // so fname is either ?=?, ?{}, or ^?{}
     46        UntypedExpr *fExpr = new UntypedExpr( new NameExpr( fname ) );
    5547
    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::Lvalue | Type::Const | Type::Volatile | Type::Restrict | Type::Atomic );
    66                         // castType->set_lvalue( true ); // xxx - might not need this
    67                         dstParam = new CastExpr( dstParam, new ReferenceType( Type::Qualifiers(), castType ) );
    68                 }
    69                 fExpr->get_args().push_back( dstParam );
     48        // do something special for unnamed members
     49        dstParam = new AddressExpr( dstParam );
     50        if ( addCast ) {
     51                // cast to T* with qualifiers removed, so that qualified objects can be constructed
     52                // and destructed with the same functions as non-qualified objects.
     53                // unfortunately, lvalue is considered a qualifier. For AddressExpr to resolve, its argument
     54                // must have an lvalue qualified type, so remove all qualifiers except lvalue. If we ever
     55                // remove lvalue as a qualifier, this can change to
     56                //   type->get_qualifiers() = Type::Qualifiers();
     57                assert( type );
     58                Type * castType = type->clone();
     59                castType->get_qualifiers() -= Type::Qualifiers( Type::Const | Type::Volatile | Type::Restrict | Type::Atomic );
     60                castType->set_lvalue( true ); // xxx - might not need this
     61                dstParam = new CastExpr( dstParam, new PointerType( Type::Qualifiers(), castType ) );
     62        }
     63        fExpr->get_args().push_back( dstParam );
    7064
    71                 Statement * listInit = srcParam.buildListInit( fExpr );
     65        Statement * listInit = srcParam.buildListInit( fExpr );
    7266
    73                 std::list< Expression * > args = *++srcParam;
    74                 fExpr->get_args().splice( fExpr->get_args().end(), args );
     67        std::list< Expression * > args = *++srcParam;
     68        fExpr->get_args().splice( fExpr->get_args().end(), args );
    7569
    76                 *out++ = new ExprStmt( noLabels, fExpr );
     70        *out++ = new ExprStmt( noLabels, fExpr );
    7771
    78                 srcParam.clearArrayIndices();
     72        srcParam.clearArrayIndices();
    7973
    80                 return listInit;
     74        return listInit;
    8175        }
    8276
     
    114108
    115109                UntypedExpr *inc = new UntypedExpr( update );
    116                 inc->get_args().push_back( new VariableExpr( index ) );
     110                inc->get_args().push_back( new AddressExpr( new VariableExpr( index ) ) );
    117111
    118112                UntypedExpr *dstIndex = new UntypedExpr( new NameExpr( "?[?]" ) );
     
    179173        }
    180174} // namespace SymTab
    181 #endif // AUTOGEN_H
     175
     176// Local Variables: //
     177// tab-width: 4 //
     178// mode: c++ //
     179// compile-command: "make install" //
     180// End: //
     181
Note: See TracChangeset for help on using the changeset viewer.