Ignore:
Timestamp:
Jan 7, 2015, 6:04:42 PM (8 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
aaron-thesis, arm-eh, cleanup-dtors, ctor, deferred_resn, demangler, enum, forall-pointer-decay, gc_noraii, jacob/cs343-translation, jenkins-sandbox, master, memory, new-ast, new-ast-unique-expr, new-env, no_list, persistent-indexer, pthread-emulation, qualifiedEnum, resolv-new, string, with_gc
Children:
0b8cd72
Parents:
d9a0e76
Message:

fixed restrict, fixed parameter copy, introduced name table for types, changed variable after to string

File:
1 edited

Legend:

Unmodified
Added
Removed
  • translator/examples/swap.c

    rd9a0e76 r17cd4eb  
    44
    55forall( type T )
    6 void swap( T left, T right ) {
    7     T temp = left;
    8     left = right;
    9     right = temp;
     6T swap( T *left, T *right ) {
     7    T temp;
     8    temp = *left;
     9    *left = *right;
     10    *right = temp;
     11    return *right;
    1012}
    1113
    1214int main() {
    1315    int x = 1, y = 2;
    14     printf( "%d %d", x, y );
    15     swap( x, y );
    16     printf( "%d %d", x, y );
     16    printf( "%d %d\n", x, y );
     17    int w;
     18    w = swap( &x, &y );
     19    printf( "%d %d %d\n", w, x, y );
    1720}
    1821
Note: See TracChangeset for help on using the changeset viewer.