Changes in / [b10c9959:408d460]


Ignore:
Location:
src
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • src/GenPoly/Box.cc

    rb10c9959 r408d460  
    1010// Created On       : Mon May 18 07:44:20 2015
    1111// Last Modified By : Rob Schluntz
    12 // Last Modified On : Fri Dec 18 14:53:08 2015
    13 // Update Count     : 217
     12// Last Modified On : Fri Feb 05 12:23:10 2016
     13// Update Count     : 280
    1414//
    1515
     
    139139                        virtual Expression *mutate( OffsetofExpr *offsetofExpr );
    140140                };
    141                
     141
    142142                /// Replaces initialization of polymorphic values with alloca, declaration of dtype/ftype with appropriate void expression, and sizeof expressions of polymorphic types with the proper variable
    143143                class Pass3 : public PolyMutator {
     
    178178                                                seenIntrinsic = false; // break on this line when debugging for end of prelude
    179179                                        }
    180                                        
     180
    181181                                        *i = dynamic_cast< Declaration* >( (*i)->acceptMutator( mutator ) );
    182182                                        assert( *i );
     
    286286                                }
    287287                        }
    288                        
     288
    289289                        if ( functionDecl->get_statements() ) {         // empty routine body ?
    290290                                doBeginScope();
     
    320320                                        findFunction( (*arg)->get_type(), functions, scopeTyVars, needsAdapter );
    321321                                } // for
    322                                
     322
    323323                                AdapterMap & adapters = Pass1::adapters.top();
    324324                                for ( std::list< FunctionType *>::iterator funType = functions.begin(); funType != functions.end(); ++funType ) {
     
    373373                Expression *Pass1::makeOffsetArray( StructInstType *ty ) {
    374374                        std::list< Declaration* > &baseMembers = ty->get_baseStruct()->get_members();
    375                        
     375
    376376                        // make a new temporary array
    377377                        Type *offsetType = new BasicType( Type::Qualifiers(), BasicType::LongUnsignedInt );
     
    397397                        return new VariableExpr( arrayTemp );
    398398                }
    399                
     399
    400400                void Pass1::passTypeVars( ApplicationExpr *appExpr, std::list< Expression *>::iterator &arg, const TyVarMap &exprTyVars ) {
    401401                        // pass size/align for type variables
     
    493493                        }
    494494                }
    495                
     495
    496496                Type *Pass1::replaceWithConcrete( ApplicationExpr *appExpr, Type *type, bool doClone ) {
    497497                        if ( TypeInstType *typeInst = dynamic_cast< TypeInstType * >( type ) ) {
     
    531531                        std::string adapterName = makeAdapterName( mangleName );
    532532
    533                         appExpr->get_args().push_front( appExpr->get_function() );
     533                        // cast adaptee to void (*)(), since it may have any type inside a polymorphic function
     534                        Type * adapteeType = new PointerType( Type::Qualifiers(), new FunctionType( Type::Qualifiers(), true ) );
     535                        appExpr->get_args().push_front( new CastExpr( appExpr->get_function(), adapteeType ) );
    534536                        appExpr->set_function( new NameExpr( adapterName ) );
    535537
     
    559561                }
    560562
     563                /// cast parameters to polymorphic functions so that types are replaced with
     564                /// void * if they are type parameters in the formal type.
     565                /// this gets rid of warnings from gcc.
    561566                void addCast( Expression *&actual, Type *formal, const TyVarMap &tyVars ) {
    562                         Type *newType = formal->clone();
    563                         std::list< FunctionType *> functions;
    564                         // instead of functions needing adapters, this really ought to look for
    565                         // any function mentioning a polymorphic type
    566                         findAndReplaceFunction( newType, functions, tyVars, needsAdapter );
    567                         if ( ! functions.empty() ) {
     567                        Type * newType = formal->clone();
     568                        if ( getFunctionType( newType ) ) {
     569                                newType = ScrubTyVars::scrub( newType, tyVars );
    568570                                actual = new CastExpr( actual, newType );
    569                         } else {
    570                                 delete newType;
    571571                        } // if
    572572                }
  • src/GenPoly/FindFunction.cc

    rb10c9959 r408d460  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // FindFunction.cc -- 
     7// FindFunction.cc --
    88//
    99// Author           : Richard C. Bilson
    1010// Created On       : Mon May 18 07:44:20 2015
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue May 19 07:35:48 2015
    13 // Update Count     : 1
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Fri Feb 05 12:22:20 2016
     13// Update Count     : 6
    1414//
    1515
     
    1919#include "SynTree/Visitor.h"
    2020
     21#include "ScrubTyVars.h"
     22
    2123namespace GenPoly {
    2224        class FindFunction : public Mutator {
    2325          public:
    2426                FindFunction( std::list< FunctionType* > &functions, const TyVarMap &tyVars, bool replaceMode, FindFunctionPredicate predicate );
    25  
     27
    2628                virtual Type *mutate( FunctionType *functionType );
    2729                virtual Type *mutate( PointerType *pointerType );
     
    6668                        functions.push_back( functionType );
    6769                        if ( replaceMode ) {
    68                                 ret = new FunctionType( Type::Qualifiers(), true );
     70                                // replace type parameters in function type with void*
     71                                ret = ScrubTyVars::scrub( functionType->clone(), tyVars );
    6972                        } // if
    7073                } // if
  • src/libcfa/algorithm

    rb10c9959 r408d460  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // alorgithm -- 
     7// alorgithm --
    88//
    99// Author           : Peter A. Buhr
     
    1616//---------------------------------------
    1717
    18 forall( type T | { int ?<?( T, T ); } )
     18forall( type T | { int ?<?( const T, const T ); } )
    1919T min( const T t1, const T t2 );
    2020
    21 forall( type T | { int ?>?( T, T ); } )
     21forall( type T | { int ?>?( const T, const T ); } )
    2222T max( const T t1, const T t2 );
    2323
  • src/libcfa/algorithm.c

    rb10c9959 r408d460  
    55// file "LICENCE" distributed with Cforall.
    66//
    7 // algorithm.c -- 
     7// algorithm.c --
    88//
    99// Author           : Peter A. Buhr
    1010// Created On       : Thu Jan 28 17:10:29 2016
    11 // Last Modified By : Peter A. Buhr
    12 // Last Modified On : Mon Feb  1 13:42:05 2016
    13 // Update Count     : 52
     11// Last Modified By : Rob Schluntz
     12// Last Modified On : Thu Feb 04 17:19:12 2016
     13// Update Count     : 54
    1414//
    1515
    1616#include "algorithm"
    1717
    18 forall( type T | { int ?<?( T, T ); } )
     18forall( type T | { int ?<?( const T, const T ); } )
    1919T min( const T t1, const T t2 ) {
    2020        return t1 < t2 ? t1 : t2;
    2121} // min
    2222
    23 forall( type T | { int ?>?( T, T ); } )
     23forall( type T | { int ?>?( const T, const T ); } )
    2424T max( const T t1, const T t2 ) {
    2525        return t1 > t2 ? t1 : t2;
Note: See TracChangeset for help on using the changeset viewer.