Ignore:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/SymTab/Autogen.h

    r6b0b624 r8a6cf7e  
    1010// Created On       : Sun May 17 21:53:34 2015
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Jul 22 09:50:25 2017
    13 // Update Count     : 15
     12// Last Modified On : Wed Jun 21 17:25:26 2017
     13// Update Count     : 14
    1414//
    1515
    16 #pragma once
     16#ifndef AUTOGEN_H
     17#define AUTOGEN_H
    1718
    1819#include <string>
     
    3435        extern Type * SizeType;
    3536
     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
    3644        /// inserts into out a generated call expression to function fname with arguments dstParam and srcParam. Intended to be used with generated ?=?, ?{}, and ^?{} calls.
    3745        template< typename OutputIterator >
     
    4250        template< typename OutputIterator >
    4351        Statement * genScalarCall( InitTweak::InitExpander & srcParam, Expression *dstParam, const std::string & fname, OutputIterator out, Type * type, bool addCast = false ) {
    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 ) );
     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 ) );
    4755
    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 );
     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 );
    6470
    65         Statement * listInit = srcParam.buildListInit( fExpr );
     71                Statement * listInit = srcParam.buildListInit( fExpr );
    6672
    67         std::list< Expression * > args = *++srcParam;
    68         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 );
    6975
    70         *out++ = new ExprStmt( noLabels, fExpr );
     76                *out++ = new ExprStmt( noLabels, fExpr );
    7177
    72         srcParam.clearArrayIndices();
     78                srcParam.clearArrayIndices();
    7379
    74         return listInit;
     80                return listInit;
    7581        }
    7682
     
    108114
    109115                UntypedExpr *inc = new UntypedExpr( update );
    110                 inc->get_args().push_back( new AddressExpr( new VariableExpr( index ) ) );
     116                inc->get_args().push_back( new VariableExpr( index ) );
    111117
    112118                UntypedExpr *dstIndex = new UntypedExpr( new NameExpr( "?[?]" ) );
     
    173179        }
    174180} // namespace SymTab
    175 
    176 // Local Variables: //
    177 // tab-width: 4 //
    178 // mode: c++ //
    179 // compile-command: "make install" //
    180 // End: //
    181 
     181#endif // AUTOGEN_H
Note: See TracChangeset for help on using the changeset viewer.