- Timestamp:
- Apr 3, 2017, 12:00:50 PM (8 years ago)
- 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. - Location:
- src
- Files:
-
- 7 edited
Legend:
- Unmodified
- Added
- Removed
-
src/GenPoly/InstantiateGeneric.cc
r23063ea r727cf70f 255 255 } 256 256 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" ); 258 258 return gt; 259 259 } -
src/ResolvExpr/PtrsCastable.cc
r23063ea r727cf70f 68 68 return 1; 69 69 } 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 } 70 73 71 74 int ptrsCastable( Type *src, Type *dest, const TypeEnvironment &env, const SymTab::Indexer &indexer ) { … … 106 109 107 110 void PtrsCastable::visit(FunctionType *functionType) { 108 result = -1; 111 // result = -1; 112 result = functionCast( dest, env, indexer ); 109 113 } 110 114 … … 136 140 137 141 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; 139 144 } 140 145 -
src/ResolvExpr/Unify.cc
r23063ea r727cf70f 134 134 case TypeDecl::Ftype: 135 135 return isFtype( type, indexer ); 136 136 case TypeDecl::Ttype: 137 137 // ttype unifies with any tuple type 138 138 return dynamic_cast< TupleType * >( type ) || Tuples::isTtype( type ); … … 592 592 for ( ; it != params.end() && jt != otherParams.end(); ++it, ++jt ) { 593 593 TypeExpr *param = dynamic_cast< TypeExpr* >(*it); 594 assert (param &&"Aggregate parameters should be type expressions");594 assertf(param, "Aggregate parameters should be type expressions"); 595 595 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 ) ) { 599 641 result = false; 600 642 return; 601 643 } 644 645 // ttype parameter should be last 646 if ( tupleParam || otherTupleParam ) break; 602 647 } 603 648 result = ( it == params.end() && jt == otherParams.end() ); -
src/libcfa/stdlib
r23063ea r727cf70f 10 10 // Created On : Thu Jan 28 17:12:35 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Mar 4 22:03:54 201713 // Update Count : 10 212 // Last Modified On : Sat Apr 1 17:35:24 2017 13 // Update Count : 104 14 14 // 15 15 … … 84 84 forall( otype T | { int ?<?( T, T ); } ) 85 85 T * bsearch( T key, const T * arr, size_t dimension ); 86 forall( otype T | { int ?<?( T, T ); } ) 87 unsigned int bsearch( T key, const T * arr, size_t dimension ); 86 88 87 89 forall( otype T | { int ?<?( T, T ); } ) -
src/libcfa/stdlib.c
r23063ea r727cf70f 10 10 // Created On : Thu Jan 28 17:10:29 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Sat Mar 4 22:02:22201713 // Update Count : 1 7212 // Last Modified On : Sat Apr 1 18:31:26 2017 13 // Update Count : 181 14 14 // 15 15 … … 228 228 229 229 forall( otype T | { int ?<?( T, T ); } ) 230 unsigned 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 236 forall( otype T | { int ?<?( T, T ); } ) 230 237 void qsort( const T * arr, size_t dimension ) { 231 238 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,3 1 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 4 2 5 3 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 4 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 5 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 6 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 7 8 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 9 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 6 10 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, 7 11 10, 9, 8, 7, 6, 5, 4, 3, 2, 1, … … 10 14 1.5, 2.5, 3.5, 4.5, 5.5, 6.5, 7.5, 8.5, 9.5, 10.5, 11 15 10.5, 9.5, 8.5, 7.5, 6.5, 5.5, 4.5, 3.5, 2.5, 1.5, 16 10.5, 9.5, 8.5, 7.5, 6.5, 5.5, 4.5, 3.5, 2.5, 1.5, 12 17 13 18 10 11, 9 10, 8 9, 7 8, 6 7, 5 6, 4 5, 3 4, 2 3, 1 2, 14 19 1 2, 2 3, 3 4, 4 5, 5 6, 6 7, 7 8, 8 9, 9 10, 10 11, 15 20 10 11, 9 10, 8 9, 7 8, 6 7, 5 6, 4 5, 3 4, 2 3, 1 2, 21 10 11, 9 10, 8 9, 7 8, 6 7, 5 6, 4 5, 3 4, 2 3, 1 2, 16 22 -
src/tests/searchsort.c
r23063ea r727cf70f 10 10 // Created On : Thu Feb 4 18:17:50 2016 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Jul 5 18:06:07 201613 // Update Count : 5612 // Last Modified On : Sun Apr 2 11:29:30 2017 13 // Update Count : 76 14 14 // 15 15 16 16 #include <fstream> 17 17 #include <stdlib> // bsearch, qsort 18 #include <stdlib.h> // C version of bsearch 19 20 int comp( const void * t1, const void * t2 ) { return *(int *)t1 < *(int *)t2 ? -1 : *(int *)t2 < *(int *)t1 ? 1 : 0; } 18 21 19 22 int main( void ) { … … 25 28 sout | iarr[i] | ", "; 26 29 } // for 27 sout | endl; 30 sout | endl | endl; 31 32 // ascending sort/search by changing < to > 28 33 qsort( iarr, size ); 29 34 for ( unsigned int i = 0; i < size; i += 1 ) { … … 31 36 } // for 32 37 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; 33 44 for ( unsigned int i = 0; i < size; i += 1 ) { 34 45 int *v = bsearch( size - i, iarr, size ); 35 46 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] | ", "; 36 52 } // for 37 53 sout | endl | endl; … … 54 70 sout | *v | ", "; 55 71 } // 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 56 77 } 57 78 sout | endl | endl; … … 71 92 double *v = bsearch( size - i + 0.5, darr, size ); 72 93 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] | ", "; 73 99 } // for 74 100 sout | endl | endl; … … 93 119 sout | *v | ", "; 94 120 } // 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 95 127 sout | endl | endl; 96 128 } // main
Note:
See TracChangeset
for help on using the changeset viewer.