Changes in / [b11fac4:45161b4d]


Ignore:
Location:
src/GenPoly
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/GenPoly/Box.cc

    rb11fac4 r45161b4d  
    292292                        /// adds type parameters to the layout call; will generate the appropriate parameters if needed
    293293                        void addOtypeParamsToLayoutCall( UntypedExpr *layoutCall, const std::list< Type* > &otypeParams );
    294 
    295                         /// Enters a new scope for type-variables, adding the type variables from ty
    296                         void beginTypeScope( Type *ty );
    297                         /// Exits the type-variable scope
    298                         void endTypeScope();
    299294                       
    300295                        ScopedSet< std::string > knownLayouts;          ///< Set of generic type layouts known in the current scope, indexed by sizeofName
     
    18261821////////////////////////////////////////// PolyGenericCalculator ////////////////////////////////////////////////////
    18271822
    1828                 void PolyGenericCalculator::beginTypeScope( Type *ty ) {
    1829                         scopeTyVars.beginScope();
    1830                         makeTyVarMap( ty, scopeTyVars );
    1831                 }
    1832 
    1833                 void PolyGenericCalculator::endTypeScope() {
    1834                         scopeTyVars.endScope();
    1835                 }
    1836 
    18371823                template< typename DeclClass >
    18381824                DeclClass * PolyGenericCalculator::handleDecl( DeclClass *decl, Type *type ) {
    1839                         beginTypeScope( type );
    1840                         knownLayouts.beginScope();
    1841                         knownOffsets.beginScope();
     1825                        scopeTyVars.beginScope();
     1826                        makeTyVarMap( type, scopeTyVars );
    18421827
    18431828                        DeclClass *ret = static_cast< DeclClass *>( Mutator::mutate( decl ) );
    18441829
    1845                         knownOffsets.endScope();
    1846                         knownLayouts.endScope();
    1847                         endTypeScope();
     1830                        scopeTyVars.endScope();
    18481831                        return ret;
    18491832                }
     
    18671850
    18681851                Type * PolyGenericCalculator::mutate( PointerType *pointerType ) {
    1869                         beginTypeScope( pointerType );
     1852                        scopeTyVars.beginScope();
     1853                        makeTyVarMap( pointerType, scopeTyVars );
    18701854
    18711855                        Type *ret = Mutator::mutate( pointerType );
    18721856
    1873                         endTypeScope();
     1857                        scopeTyVars.endScope();
    18741858                        return ret;
    18751859                }
    18761860
    18771861                Type * PolyGenericCalculator::mutate( FunctionType *funcType ) {
    1878                         beginTypeScope( funcType );
     1862                        scopeTyVars.beginScope();
     1863                        makeTyVarMap( funcType, scopeTyVars );
    18791864
    18801865                        // make sure that any type information passed into the function is accounted for
     
    18891874                        Type *ret = Mutator::mutate( funcType );
    18901875
    1891                         endTypeScope();
     1876                        scopeTyVars.endScope();
    18921877                        return ret;
    18931878                }
  • src/GenPoly/Lvalue.cc

    rb11fac4 r45161b4d  
    1717
    1818#include "Lvalue.h"
    19 
    20 #include "GenPoly.h"
    2119
    2220#include "SynTree/Declaration.h"
     
    6563
    6664        namespace {
    67                 Type* isLvalueRet( FunctionType *function ) {
    68                         if ( function->get_returnVals().empty() ) return 0;
    69                         Type *ty = function->get_returnVals().front()->get_type();
    70                         return ty->get_isLvalue() ? ty : 0;
     65                bool isLvalueRet( FunctionType *function ) {
     66                        if ( ! function->get_returnVals().empty() ) {
     67                                return function->get_returnVals().front()->get_type()->get_isLvalue();
     68                        } else {
     69                                return false;
     70                        } // if
    7171                }
    7272
     
    107107                        assert( function );
    108108
    109                         Type *funType = isLvalueRet( function );
    110                         if ( funType && ! isIntrinsicApp( appExpr ) ) {
    111                                 Expression *expr = appExpr;
    112                                 Type *appType = appExpr->get_results().front();
    113                                 if ( isPolyType( funType ) ) {
    114                                         // make sure cast for polymorphic type is inside dereference
    115                                         expr = new CastExpr( appExpr, new PointerType( Type::Qualifiers(), appType->clone() ) );
    116                                 }
     109                        std::string typeName;
     110                        if ( isLvalueRet( function ) && ! isIntrinsicApp( appExpr ) ) {
    117111                                UntypedExpr *deref = new UntypedExpr( new NameExpr( "*?" ) );
    118                                 deref->get_results().push_back( appType->clone() );
    119                                 appExpr->get_results().front() = new PointerType( Type::Qualifiers(), appType );
    120                                 deref->get_args().push_back( expr );
     112                                deref->get_results().push_back( appExpr->get_results().front() );
     113                                appExpr->get_results().front() = new PointerType( Type::Qualifiers(), deref->get_results().front()->clone() );
     114                                deref->get_args().push_back( appExpr );
    121115                                return deref;
    122116                        } else {
Note: See TracChangeset for help on using the changeset viewer.