- Timestamp:
- Apr 17, 2017, 7:58:50 AM (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:
- 2183e12, c87cd93
- Parents:
- 02d241f
- Location:
- doc/generic_types
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
doc/generic_types/acmart.cls
r02d241f r33e22da 401 401 \immediate\write\@auxout{\string\bibstyle{#1}}% 402 402 \fi}} 403 \RequirePackage{graphicx, xcolor}404 \definecolor[named]{ACMBlue}{cmyk}{1,0.1,0,0.1}405 \definecolor[named]{ACMYellow}{cmyk}{0,0.16,1,0}406 \definecolor[named]{ACMOrange}{cmyk}{0,0.42,1,0.01}407 \definecolor[named]{ACMRed}{cmyk}{0,0.90,0.86,0}408 \definecolor[named]{ACMLightBlue}{cmyk}{0.49,0.01,0,0}409 \definecolor[named]{ACMGreen}{cmyk}{0.20,0,1,0.19}410 \definecolor[named]{ACMPurple}{cmyk}{0.55,1,0,0.15}411 \definecolor[named]{ACMDarkBlue}{cmyk}{1,0.58,0,0.21}403 %\RequirePackage{graphicx, xcolor} 404 %\definecolor[named]{ACMBlue}{cmyk}{1,0.1,0,0.1} 405 %\definecolor[named]{ACMYellow}{cmyk}{0,0.16,1,0} 406 %\definecolor[named]{ACMOrange}{cmyk}{0,0.42,1,0.01} 407 %\definecolor[named]{ACMRed}{cmyk}{0,0.90,0.86,0} 408 %\definecolor[named]{ACMLightBlue}{cmyk}{0.49,0.01,0,0} 409 %\definecolor[named]{ACMGreen}{cmyk}{0.20,0,1,0.19} 410 %\definecolor[named]{ACMPurple}{cmyk}{0.55,1,0,0.15} 411 %\definecolor[named]{ACMDarkBlue}{cmyk}{1,0.58,0,0.21} 412 412 \RequirePackage{geometry} 413 413 \ifcase\ACM@format@nr -
doc/generic_types/generic_types.tex
r02d241f r33e22da 6 6 \usepackage{upquote} % switch curled `'" to straight 7 7 \usepackage{listings} % format program code 8 \usepackage[usenames]{color} 8 9 9 10 \makeatletter … … 244 245 return (T *)bsearch( &key, arr, size, sizeof(T), comp ); } 245 246 forall( otype T | { int ?<?( T, T ); } ) unsigned int bsearch( T key, const T * arr, size_t size ) { 246 T * result = bsearch( key, arr, size ); $\C{// call first version}$247 T * result = bsearch( key, arr, size ); $\C{// call first version}$ 247 248 return result ? result - arr : size; } $\C{// pointer subtraction includes sizeof(T)}$ 248 249 double * val = bsearch( 5.0, vals, 10 ); $\C{// selection based on return type}$ … … 356 357 % struct list { 357 358 % int value; 358 % list * next; $\C{// may omit "struct" on type names as in \CC}$359 % list * next; $\C{// may omit "struct" on type names as in \CC}$ 359 360 % }; 360 % typedef list * list_iterator;361 % typedef list * list_iterator; 361 362 % 362 363 % lvalue int *?( list_iterator it ) { return it->value; } … … 388 389 }; 389 390 forall( otype T ) T value( pair( const char *, T ) p ) { return p.second; } 390 forall( dtype F, otype T ) T value_p( pair( F *, T * ) p ) { return * p.second; }391 forall( dtype F, otype T ) T value_p( pair( F *, T * ) p ) { return * p.second; } 391 392 pair( const char *, int ) p = { "magic", 42 }; 392 393 int magic = value( p ); … … 549 550 The type-resolver only has the tuple return-types to resolve the call to @bar@ as the @foo@ parameters are identical, which involves unifying the possible @foo@ functions with @bar@'s parameter list. 550 551 No combination of @foo@s are an exact match with @bar@'s parameters, so the resolver applies C conversions. 551 The minimal cost is @bar( foo@$_1$@( 3 ), foo@$_2$@( 3 ) )@, giving (@int@, {\color{ green}@int@}, @double@) to (@int@, {\color{green}@double@}, @double@) with one {\color{green}safe} (widening) conversion from @int@ to @double@ versus ({\color{red}@double@}, {\color{green}@int@}, {\color{green}@int@}) to ({\color{red}@int@}, {\color{green}@double@}, {\color{green}@double@}) with one {\color{red}unsafe} (narrowing) conversion from @double@ to @int@ and two safe conversions.552 The minimal cost is @bar( foo@$_1$@( 3 ), foo@$_2$@( 3 ) )@, giving (@int@, {\color{ForestGreen}@int@}, @double@) to (@int@, {\color{ForestGreen}@double@}, @double@) with one {\color{ForestGreen}safe} (widening) conversion from @int@ to @double@ versus ({\color{red}@double@}, {\color{ForestGreen}@int@}, {\color{ForestGreen}@int@}) to ({\color{red}@int@}, {\color{ForestGreen}@double@}, {\color{ForestGreen}@double@}) with one {\color{red}unsafe} (narrowing) conversion from @double@ to @int@ and two safe conversions. 552 553 553 554 … … 963 964 \begin{figure} 964 965 \begin{lstlisting}[xleftmargin=3\parindentlnth,aboveskip=0pt,belowskip=0pt] 965 int main( int argc, char * argv[] ) {966 int main( int argc, char * argv[] ) { 966 967 FILE * out = fopen( "cfa-out.txt", "w" ); 967 968 int max = 0, vali = 42; … … 1102 1103 1103 1104 1104 \section{Conclusion \&Future Work}1105 \section{Conclusion and Future Work} 1105 1106 1106 1107 The goal of \CFA is to provide an evolutionary pathway for large C development-environments to be more productive and safer, while respecting the talent and skill of C programmers.
Note: See TracChangeset
for help on using the changeset viewer.