Changeset 17cd4eb for translator/examples
- Timestamp:
- Jan 7, 2015, 6:04:42 PM (11 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, 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:
- 0b8cd722
- Parents:
- d9a0e76
- Location:
- translator/examples
- Files:
-
- 4 edited
-
Makefile (modified) (1 diff)
-
includes.c (modified) (1 diff)
-
swap.c (modified) (1 diff)
-
vector_test.c (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
translator/examples/Makefile
rd9a0e76 r17cd4eb 20 20 21 21 ${EXEC1} : ${OBJECTS1} # link step 1st executable 22 ${CC} ${C CFLAGS} $^ -o $@ # additional object files before $^22 ${CC} ${CFLAGS} $^ -o $@ # additional object files before $^ 23 23 24 24 ${EXEC2} : ${OBJECTS2} # link step 2nd executable 25 ${CC} ${C CFLAGS} $^ -o $@ # additional object files before $^25 ${CC} ${CFLAGS} $^ -o $@ # additional object files before $^ 26 26 27 27 ${OBJECTS} : ${MAKEFILE_NAME} # OPTIONAL : changes to this file => recompile -
translator/examples/includes.c
rd9a0e76 r17cd4eb 25 25 //#include <wchar.h> // FAILS -- includes locale.h 26 26 //#include <wctype.h> // FAILS -- includes locale.h 27 #include <curses.h> 27 28 #else 28 #include < curses.h>29 #endif 29 #include <aio.h> 30 #endif // 0 30 31 31 32 // Local Variables: // -
translator/examples/swap.c
rd9a0e76 r17cd4eb 4 4 5 5 forall( type T ) 6 void swap( T left, T right ) { 7 T temp = left; 8 left = right; 9 right = temp; 6 T swap( T *left, T *right ) { 7 T temp; 8 temp = *left; 9 *left = *right; 10 *right = temp; 11 return *right; 10 12 } 11 13 12 14 int main() { 13 15 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 ); 17 20 } 18 21 -
translator/examples/vector_test.c
rd9a0e76 r17cd4eb 22 22 sout << "Array elements:\n"; 23 23 // write_all( begin( vec ), end( vec ), sout ); 24 sout << "\n"; 25 #if 0 26 write_reverse( begin( vec ), end( vec ), sout ); 27 sout << "\n"; 28 29 #endif 24 // sout << "\n"; 30 25 for ( int index = 0; index <= last( vec ); index += 1 ) { 31 26 sout << vec[ index ] << " "; 32 27 } 33 28 sout << "\n"; 29 #if 1 30 sout << "Array elements reversed:\n"; 31 write_reverse( begin( vec ), end( vec ), sout ); 32 sout << "\n"; 33 #endif 34 34 } 35 35
Note:
See TracChangeset
for help on using the changeset viewer.