Changeset 727cf70f for src


Ignore:
Timestamp:
Apr 3, 2017, 12:00:50 PM (8 years ago)
Author:
Thierry Delisle <tdelisle@…>
Branches:
ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, demangler, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, with_gc
Children:
a6af031
Parents:
23063ea (diff), 1d29d46 (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the (diff) links above to see all the changes relative to each parent.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

Location:
src
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • src/GenPoly/InstantiateGeneric.cc

    r23063ea r727cf70f  
    255255                }
    256256
    257                 assert( baseParam == baseParams.end() && param == params.end() && "Type parameters should match type variables" );
     257                assertf( baseParam == baseParams.end() && param == params.end(), "Type parameters should match type variables" );
    258258                return gt;
    259259        }
  • src/ResolvExpr/PtrsCastable.cc

    r23063ea r727cf70f  
    6868                return 1;
    6969        }
     70        int functionCast( Type *src, const TypeEnvironment &env, const SymTab::Indexer &indexer ) {
     71                return -1 * objectCast( src, env, indexer );  // reverse the sense of objectCast
     72        }
    7073
    7174        int ptrsCastable( Type *src, Type *dest, const TypeEnvironment &env, const SymTab::Indexer &indexer ) {
     
    106109
    107110        void PtrsCastable::visit(FunctionType *functionType) {
    108                 result = -1;
     111                // result = -1;
     112                result = functionCast( dest, env, indexer );
    109113        }
    110114
     
    136140
    137141        void PtrsCastable::visit(TypeInstType *inst) {
    138                 result = objectCast( inst, env, indexer ) > 0 && objectCast( dest, env, indexer ) > 0 ? 1 : -1;
     142                //result = objectCast( inst, env, indexer ) > 0 && objectCast( dest, env, indexer ) > 0 ? 1 : -1;
     143                result = objectCast( inst, env, indexer ) == objectCast( dest, env, indexer ) ? 1 : -1;
    139144        }
    140145
  • src/ResolvExpr/Unify.cc

    r23063ea r727cf70f  
    134134                  case TypeDecl::Ftype:
    135135                        return isFtype( type, indexer );
    136                         case TypeDecl::Ttype:
     136                  case TypeDecl::Ttype:
    137137                        // ttype unifies with any tuple type
    138138                        return dynamic_cast< TupleType * >( type ) || Tuples::isTtype( type );
     
    592592                for ( ; it != params.end() && jt != otherParams.end(); ++it, ++jt ) {
    593593                        TypeExpr *param = dynamic_cast< TypeExpr* >(*it);
    594                         assert(param && "Aggregate parameters should be type expressions");
     594                        assertf(param, "Aggregate parameters should be type expressions");
    595595                        TypeExpr *otherParam = dynamic_cast< TypeExpr* >(*jt);
    596                         assert(otherParam && "Aggregate parameters should be type expressions");
    597 
    598                         if ( ! unifyExact( param->get_type(), otherParam->get_type(), env, needAssertions, haveAssertions, openVars, WidenMode(false, false), indexer ) ) {
     596                        assertf(otherParam, "Aggregate parameters should be type expressions");
     597                       
     598                        Type* paramTy = param->get_type();
     599                        Type* otherParamTy = otherParam->get_type();
     600
     601                        bool tupleParam = Tuples::isTtype( paramTy );
     602                        bool otherTupleParam = Tuples::isTtype( otherParamTy );
     603
     604                        if ( tupleParam && otherTupleParam ) {
     605                                ++it; ++jt;  // skip ttype parameters for break
     606                        } else if ( tupleParam ) {
     607                                // bundle other parameters into tuple to match
     608                                TupleType* binder = new TupleType{ paramTy->get_qualifiers() };
     609
     610                                do {
     611                                        binder->get_types().push_back( otherParam->get_type()->clone() );
     612                                        ++jt;
     613
     614                                        if ( jt == otherParams.end() ) break;
     615
     616                                        otherParam = dynamic_cast< TypeExpr* >(*jt);
     617                                        assertf(otherParam, "Aggregate parameters should be type expressions");
     618                                } while (true);
     619
     620                                otherParamTy = binder;
     621                                ++it;  // skip ttype parameter for break
     622                        } else if ( otherTupleParam ) {
     623                                // bundle parameters into tuple to match other
     624                                TupleType* binder = new TupleType{ otherParamTy->get_qualifiers() };
     625
     626                                do {
     627                                        binder->get_types().push_back( param->get_type()->clone() );
     628                                        ++it;
     629
     630                                        if ( it == params.end() ) break;
     631
     632                                        param = dynamic_cast< TypeExpr* >(*it);
     633                                        assertf(param, "Aggregate parameters should be type expressions");
     634                                } while (true);
     635
     636                                paramTy = binder;
     637                                ++jt;  // skip ttype parameter for break
     638                        }
     639
     640                        if ( ! unifyExact( paramTy, otherParamTy, env, needAssertions, haveAssertions, openVars, WidenMode(false, false), indexer ) ) {
    599641                                result = false;
    600642                                return;
    601643                        }
     644
     645                        // ttype parameter should be last
     646                        if ( tupleParam || otherTupleParam ) break;
    602647                }
    603648                result = ( it == params.end() && jt == otherParams.end() );
  • src/libcfa/stdlib

    r23063ea r727cf70f  
    1010// Created On       : Thu Jan 28 17:12:35 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Mar  4 22:03:54 2017
    13 // Update Count     : 102
     12// Last Modified On : Sat Apr  1 17:35:24 2017
     13// Update Count     : 104
    1414//
    1515
     
    8484forall( otype T | { int ?<?( T, T ); } )
    8585T * bsearch( T key, const T * arr, size_t dimension );
     86forall( otype T | { int ?<?( T, T ); } )
     87unsigned int bsearch( T key, const T * arr, size_t dimension );
    8688
    8789forall( otype T | { int ?<?( T, T ); } )
  • src/libcfa/stdlib.c

    r23063ea r727cf70f  
    1010// Created On       : Thu Jan 28 17:10:29 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Sat Mar  4 22:02:22 2017
    13 // Update Count     : 172
     12// Last Modified On : Sat Apr  1 18:31:26 2017
     13// Update Count     : 181
    1414//
    1515
     
    228228
    229229forall( otype T | { int ?<?( T, T ); } )
     230unsigned int bsearch( T key, const T * arr, size_t dimension ) {
     231        int comp( const void * t1, const void * t2 ) { return *(T *)t1 < *(T *)t2 ? -1 : *(T *)t2 < *(T *)t1 ? 1 : 0; }
     232        T *result = (T *)bsearch( &key, arr, dimension, sizeof(T), comp );
     233        return result ? result - arr : dimension;                       // pointer subtraction includes sizeof(T)
     234} // bsearch
     235
     236forall( otype T | { int ?<?( T, T ); } )
    230237void qsort( const T * arr, size_t dimension ) {
    231238        int comp( const void * t1, const void * t2 ) { return *(T *)t1 < *(T *)t2 ? -1 : *(T *)t2 < *(T *)t1 ? 1 : 0; }
  • src/tests/.expect/searchsort.txt

    r23063ea r727cf70f  
    1 10, 9, 8, 7, 6, 5, 4, 3, 2, 1,
    2 1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
    3110, 9, 8, 7, 6, 5, 4, 3, 2, 1,
    42
    531, 2, 3, 4, 5, 6, 7, 8, 9, 10,
     410, 9, 8, 7, 6, 5, 4, 3, 2, 1,
     510, 9, 8, 7, 6, 5, 4, 3, 2, 1,
     610, 9, 8, 7, 6, 5, 4, 3, 2, 1,
     7
     81, 2, 3, 4, 5, 6, 7, 8, 9, 10,
     910, 9, 8, 7, 6, 5, 4, 3, 2, 1,
    61010, 9, 8, 7, 6, 5, 4, 3, 2, 1,
    71110, 9, 8, 7, 6, 5, 4, 3, 2, 1,
     
    10141.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5,
    111510.5, 9.5, 8.5, 7.5, 6.5, 5.5, 4.5, 3.5, 2.5, 1.5,
     1610.5, 9.5, 8.5, 7.5, 6.5, 5.5, 4.5, 3.5, 2.5, 1.5,
    1217
    131810 11, 9 10, 8 9, 7 8, 6 7, 5 6, 4 5, 3 4, 2 3, 1 2,
    14191 2, 2 3, 3 4, 4 5, 5 6, 6 7, 7 8, 8 9, 9 10, 10 11,
    152010 11, 9 10, 8 9, 7 8, 6 7, 5 6, 4 5, 3 4, 2 3, 1 2,
     2110 11, 9 10, 8 9, 7 8, 6 7, 5 6, 4 5, 3 4, 2 3, 1 2,
    1622
  • src/tests/searchsort.c

    r23063ea r727cf70f  
    1010// Created On       : Thu Feb  4 18:17:50 2016
    1111// Last Modified By : Peter A. Buhr
    12 // Last Modified On : Tue Jul  5 18:06:07 2016
    13 // Update Count     : 56
     12// Last Modified On : Sun Apr  2 11:29:30 2017
     13// Update Count     : 76
    1414//
    1515
    1616#include <fstream>
    1717#include <stdlib>                                                                               // bsearch, qsort
     18#include <stdlib.h>                                                                             // C version of bsearch
     19
     20int comp( const void * t1, const void * t2 ) { return *(int *)t1 < *(int *)t2 ? -1 : *(int *)t2 < *(int *)t1 ? 1 : 0; }
    1821
    1922int main( void ) {
     
    2528                sout | iarr[i] | ", ";
    2629        } // for
    27         sout | endl;
     30        sout | endl | endl;
     31
     32        // ascending sort/search by changing < to >
    2833        qsort( iarr, size );
    2934        for ( unsigned int i = 0; i < size; i += 1 ) {
     
    3136        } // for
    3237        sout | endl;
     38        for ( unsigned int i = 0; i < size; i += 1 ) {          // C version
     39                int key = size - i;
     40                int *v = bsearch( &key, iarr, size, sizeof( iarr[0] ), comp );
     41                sout | *v | ", ";
     42        } // for
     43        sout | endl;
    3344        for ( unsigned int i = 0; i < size; i += 1 ) {
    3445                int *v = bsearch( size - i, iarr, size );
    3546                sout | *v | ", ";
     47        } // for
     48        sout | endl;
     49        for ( unsigned int i = 0; i < size; i += 1 ) {
     50                unsigned int posn = bsearch( size - i, iarr, size );
     51                sout | iarr[posn] | ", ";
    3652        } // for
    3753        sout | endl | endl;
     
    5470                        sout | *v | ", ";
    5571                } // for
     72                sout | endl;
     73                for ( unsigned int i = 0; i < size; i += 1 ) {
     74                        unsigned int posn = bsearch( size - i, iarr, size );
     75                        sout | iarr[posn] | ", ";
     76                } // for
    5677        }
    5778        sout | endl | endl;
     
    7192                double *v = bsearch( size - i + 0.5, darr, size );
    7293                sout | *v | ", ";
     94        } // for
     95        sout | endl;
     96        for ( unsigned int i = 0; i < size; i += 1 ) {
     97                unsigned int posn = bsearch( size - i + 0.5, darr, size );
     98                sout | darr[posn] | ", ";
    7399        } // for
    74100        sout | endl | endl;
     
    93119                sout | *v | ", ";
    94120        } // for
     121        sout | endl;
     122        for ( unsigned int i = 0; i < size; i += 1 ) {
     123                S temp = { size - i, size - i + 1 };
     124                unsigned int posn = bsearch( temp, sarr, size );
     125                sout | sarr[posn] | ", ";
     126        } // for
    95127        sout | endl | endl;
    96128} // main
Note: See TracChangeset for help on using the changeset viewer.