Changes in / [38d70ab:b38225d]
- Files:
-
- 1 deleted
- 4 edited
-
doc/working/resolver_design.md (modified) (1 diff)
-
src/libcfa/iostream (modified) (4 diffs)
-
src/libcfa/iostream.c (modified) (3 diffs)
-
src/tests/.expect/div.txt (deleted)
-
src/tests/div.c (modified) (2 diffs)
Legend:
- Unmodified
- Added
- Removed
-
doc/working/resolver_design.md
r38d70ab rb38225d 91 91 ## Conversion Costs ## 92 92 Each possible resolution of an expression has a _cost_ tuple consisting of 93 the following components: 94 1. _unsafe_ conversion cost: summed degree of unsafe conversions; unlike CFA03, this is not a simple count of conversions (for symmetry with the safe conversions) 95 2. _polymorphic unifications_: count of parameters and return values bound to some polymorphic type for boxing 96 3. _type variables_: number of polymorphic type variables bound 97 4. negated _type specializations_: Each type assertion specializes the polymorphism, thus decreasing the cost; nested polymorphic types (e.g. `T*`) are also counted as specializations 98 5. _safe_ conversions: summed degree of safe conversions 99 6. _qualifier_ conversions: summed degree of qualifier and reference conversions 93 the following components: _unsafe_ conversion cost, _polymorphic_ 94 specialization cost, _safe_ conversion cost, a count of _explicit_ 95 conversions, and _qualifier_ conversion cost. 100 96 These components are lexically-ordered and can be summed element-wise; 101 97 summation starts at `(0, 0, 0, 0, 0)`. 102 103 **TODO** update below for consistency with this104 98 105 99 ### Lvalue and Qualifier Conversions ### -
src/libcfa/iostream
r38d70ab rb38225d 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Aug 9 16:42:47201713 // Update Count : 1 3112 // Last Modified On : Fri Jul 7 08:35:59 2017 13 // Update Count : 118 14 14 // 15 15 … … 46 46 }; // ostream 47 47 48 // trait writeable( otype T ) { 49 // forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, T ); 50 // }; // writeable 51 52 trait writeable( otype T, dtype ostype | ostream( ostype ) ) { 53 ostype * ?|?( ostype *, T ); 48 trait writeable( otype T ) { 49 forall( dtype ostype | ostream( ostype ) ) ostype * ?|?( ostype *, T ); 54 50 }; // writeable 55 51 … … 81 77 82 78 // tuples 83 forall( dtype ostype, otype T, ttype Params | writeable( T, ostype ) | { ostype * ?|?( ostype *, Params ); } ) 84 ostype * ?|?( ostype * os, T arg, Params rest ); 79 forall( dtype ostype, otype T, ttype Params | ostream( ostype ) | writeable( T ) | { ostype * ?|?( ostype *, Params ); } ) ostype * ?|?( ostype * os, T arg, Params rest ); 85 80 86 81 // manipulators … … 95 90 96 91 // writes the range [begin, end) to the given stream 97 forall( dtype ostype, otype elt_type | writeable( elt_type, ostype ), otype iterator_type | iterator( iterator_type, elt_type ) )98 void write( iterator_type begin, iterator_type end, os type *os );92 forall( otype elt_type | writeable( elt_type ), otype iterator_type | iterator( iterator_type, elt_type ), dtype os_type | ostream( os_type ) ) 93 void write( iterator_type begin, iterator_type end, os_type *os ); 99 94 100 forall( dtype ostype, otype elt_type | writeable( elt_type, ostype ), otype iterator_type | iterator( iterator_type, elt_type ) )101 void write_reverse( iterator_type begin, iterator_type end, os type *os );95 forall( otype elt_type | writeable( elt_type ), otype iterator_type | iterator( iterator_type, elt_type ), dtype os_type | ostream( os_type ) ) 96 void write_reverse( iterator_type begin, iterator_type end, os_type *os ); 102 97 103 98 //--------------------------------------- -
src/libcfa/iostream.c
r38d70ab rb38225d 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Wed Aug 9 16:46:51201713 // Update Count : 40112 // Last Modified On : Sun Jul 16 21:12:03 2017 13 // Update Count : 398 14 14 // 15 15 … … 193 193 194 194 // tuples 195 forall( dtype ostype, otype T, ttype Params | writeable( T, ostype) | { ostype * ?|?( ostype *, Params ); } )195 forall( dtype ostype, otype T, ttype Params | ostream( ostype ) | writeable( T ) | { ostype * ?|?( ostype *, Params ); } ) 196 196 ostype * ?|?( ostype * os, T arg, Params rest ) { 197 197 os | arg; // print first argument … … 256 256 //--------------------------------------- 257 257 258 forall( dtype ostype, otype elt_type | writeable( elt_type, ostype ), otype iterator_type | iterator( iterator_type, elt_type ) )259 void write( iterator _type begin, iterator_type end, ostype * os ) {260 void print( elt _type i ) { os | i; }258 forall( otype elttype | writeable( elttype ), otype iteratortype | iterator( iteratortype, elttype ), dtype ostype | ostream( ostype ) ) 259 void write( iteratortype begin, iteratortype end, ostype * os ) { 260 void print( elttype i ) { os | i; } 261 261 for_each( begin, end, print ); 262 262 } // ?|? 263 263 264 forall( dtype ostype, otype elt_type | writeable( elt_type, ostype ), otype iterator_type | iterator( iterator_type, elt_type ) )265 void write_reverse( iterator _type begin, iterator_type end, ostype * os ) {266 void print( elt _type i ) { os | i; }264 forall( otype elttype | writeable( elttype ), otype iteratortype | iterator( iteratortype, elttype ), dtype ostype | ostream( ostype ) ) 265 void write_reverse( iteratortype begin, iteratortype end, ostype * os ) { 266 void print( elttype i ) { os | i; } 267 267 for_each_reverse( begin, end, print ); 268 268 } // ?|? -
src/tests/div.c
r38d70ab rb38225d 11 11 // Created On : Tue Aug 8 16:28:43 2017 12 12 // Last Modified By : Peter A. Buhr 13 // Last Modified On : Wed Aug 9 17:09:40201714 // Update Count : 1 613 // Last Modified On : Tue Aug 8 18:02:44 2017 14 // Update Count : 14 15 15 // 16 16 … … 28 28 sout | "div" | div( s1, s2 ) | endl; 29 29 T t1 = { 13 }, t2 = { 5 }; 30 sout | "div" | div( t1, t2 ) | endl; // polymorphic div 30 [t1, t2] = div( t1, t2 ); // polymorphic div 31 sout | "div" | t1 | t2 | endl; 32 // sout | "div" | div( t1, t2 ) | endl; 31 33 } // main 32 34
Note:
See TracChangeset
for help on using the changeset viewer.