- Timestamp:
- Dec 12, 2018, 9:16:12 AM (6 years ago)
- Branches:
- ADT, aaron-thesis, arm-eh, ast-experimental, cleanup-dtors, deferred_resn, enum, forall-pointer-decay, jacob/cs343-translation, jenkins-sandbox, master, new-ast, new-ast-unique-expr, no_list, persistent-indexer, pthread-emulation, qualifiedEnum
- Children:
- 5ebb1368
- Parents:
- 3d99498
- Location:
- examples
- Files:
-
- 12 edited
Legend:
- Unmodified
- Added
- Removed
-
examples/ArrayN.c
r3d99498 r200fcb3 7 7 8 8 forall(otype index_t) 9 index_t offset_to_index(unsigned offset, index_t size) 10 { 9 index_t offset_to_index(unsigned offset, index_t size) { 11 10 return [offset / size.0, offset % size.1]; 12 11 } 13 12 14 int main(int argc, char* argv[]) 15 { 13 int main(int argc, char* argv[]) { 16 14 unsigned x = 0, y = 0, i = 0; 17 15 unsigned sx = 4, sy = 4; … … 20 18 [x, y] = offset_to_index(6, [sx, sy]); 21 19 22 sout | x | ' ' | y | endl;20 sout | x | ' ' | y; 23 21 24 22 return 0; -
examples/gc_no_raii/src/internal/collector.c
r3d99498 r200fcb3 38 38 void* gc_allocate(size_t target_size) 39 39 { 40 // sout | "Allocating " | target_size | " bytes" | endl;40 // sout | "Allocating " | target_size | " bytes"; 41 41 42 42 size_t size = gc_compute_size(target_size + sizeof(gc_object_header)); 43 43 44 // sout | "Object header size: " | sizeof(gc_object_header) | " bytes" | endl;45 // sout | "Actual allocation size: " | size | " bytes" | endl;44 // sout | "Object header size: " | sizeof(gc_object_header) | " bytes"; 45 // sout | "Actual allocation size: " | size | " bytes"; 46 46 47 47 check(size < POOL_SIZE_BYTES); -
examples/gc_no_raii/src/internal/state.h
r3d99498 r200fcb3 38 38 static inline bool gc_needs_collect(gc_state* state) 39 39 { 40 // sout | "Used Space: " | state->used_space | " bytes" | endl;40 // sout | "Used Space: " | state->used_space | " bytes"; 41 41 return state->used_space * 2 > state->total_space; 42 42 } -
examples/gc_no_raii/src/tools/print.h
r3d99498 r200fcb3 5 5 // #include <fstream.hfa> 6 6 // 7 // #define DEBUG_OUT(x) sout | x | endl;7 // #define DEBUG_OUT(x) sout | x; 8 8 // 9 9 // #else -
examples/multicore.c
r3d99498 r200fcb3 15 15 16 16 int main(int argc, char* argv[]) { 17 // sout | "User main begin" | endl;17 // sout | "User main begin"; 18 18 { 19 19 processor p; … … 22 22 } 23 23 } 24 // sout | "User main end" | endl;24 // sout | "User main end"; 25 25 } -
examples/prolog.c
r3d99498 r200fcb3 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Mar 8 22:09:39 201613 // Update Count : 512 // Last Modified On : Tue Dec 11 23:27:19 2018 13 // Update Count : 6 14 14 // 15 15 16 16 #include <fstream.hfa> 17 17 18 void printResult( int x ) { sout | "int" | endl; }19 void printResult( double x ) { sout | "double" | endl; }20 void printResult( char * x ) { sout | "char*" | endl; }18 void printResult( int x ) { sout | "int"; } 19 void printResult( double x ) { sout | "double"; } 20 void printResult( char * x ) { sout | "char*"; } 21 21 22 22 void is_arithmetic( int x ) {} -
examples/quad.c
r3d99498 r200fcb3 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Mar 8 22:07:02 201613 // Update Count : 812 // Last Modified On : Tue Dec 11 23:26:58 2018 13 // Update Count : 9 14 14 // 15 15 … … 28 28 int main() { 29 29 int N = 2; 30 sout | "result of quad of" | N | "is" | quad( N ) | endl;30 sout | "result of quad of" | N | "is" | quad( N ); 31 31 } 32 32 -
examples/square.c
r3d99498 r200fcb3 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : Tue Mar 8 22:05:48 201613 // Update Count : 2 712 // Last Modified On : Tue Dec 11 23:28:24 2018 13 // Update Count : 28 14 14 // 15 15 … … 23 23 int main() { 24 24 #if 0 25 sout | "result of squaring 9 is " | endl;25 sout | "result of squaring 9 is "; 26 26 27 27 // char does not have multiplication. … … 30 30 } // ?*? 31 31 char c = 9; 32 sout | "char\t\t\t" | square( c ) | endl;32 sout | "char\t\t\t" | square( c ); 33 33 34 sout | square( s ) | endl;34 sout | square( s ); 35 35 #endif 36 36 short s = 9; … … 38 38 #if 0 39 39 signed int i = 9; 40 sout | "signed int\t\t" | square( i ) | endl;40 sout | "signed int\t\t" | square( i ); 41 41 42 42 unsigned int ui = 9; 43 sout | "unsigned int\t\t" | square( ui ) | endl;43 sout | "unsigned int\t\t" | square( ui ); 44 44 45 45 long int li = 9; 46 sout | "signed long int\t\t" | square( li ) | endl;46 sout | "signed long int\t\t" | square( li ); 47 47 48 48 unsigned long int uli = 9; 49 sout | "unsigned long int\t" | square( uli ) | endl;49 sout | "unsigned long int\t" | square( uli ); 50 50 51 51 signed long long int lli = 9; 52 sout | "signed long long int\t" | square( lli ) | endl;52 sout | "signed long long int\t" | square( lli ); 53 53 54 54 unsigned long long int ulli = 9; 55 sout | "unsigned long long int\t" | square( ulli ) | endl;55 sout | "unsigned long long int\t" | square( ulli ); 56 56 57 57 float f = 9.0; 58 sout | "float\t\t\t" | square( f ) | endl;58 sout | "float\t\t\t" | square( f ); 59 59 60 60 double d = 9.0; 61 sout | "double\t\t\t" | square( d ) | endl;61 sout | "double\t\t\t" | square( d ); 62 62 63 63 long double ld = 9.0; 64 sout | "long double\t\t" | square( ld ) | endl;64 sout | "long double\t\t" | square( ld ); 65 65 #endif 66 66 } // main -
examples/twice.c
r3d99498 r200fcb3 10 10 // Created On : Wed May 27 17:56:53 2015 11 11 // Last Modified By : Peter A. Buhr 12 // Last Modified On : T hu Oct 19 21:52:57 201713 // Update Count : 4 612 // Last Modified On : Tue Dec 11 23:28:08 2018 13 // Update Count : 47 14 14 // 15 15 … … 28 28 29 29 int main( void ) { 30 sout | twice( ' ' ) | ' ' | twice( (signed char)0 ) | twice( (int)1 ) | twice( 3.2 ) | endl;30 sout | twice( ' ' ) | ' ' | twice( (signed char)0 ) | twice( (int)1 ) | twice( 3.2 ); 31 31 } 32 32 -
examples/wrapper/src/main.c
r3d99498 r200fcb3 1 1 #include "pointer.h" 2 2 3 wrapper_t make_copy(wrapper_t copy) 4 { 3 wrapper_t make_copy(wrapper_t copy) { 5 4 return copy; 6 5 } 7 6 8 int main(int argc, char const *argv[]) 9 { 7 int main(int argc, char const *argv[]) { 10 8 wrapper_t p = wrap(6); 11 12 sout | endl | "test started" | endl; 13 9 sout | nl | "test started"; 14 10 wrapper_t p2 = p; 15 16 11 clear(&p); 17 18 12 p = p2; 19 20 13 wrapper_t p3 = make_copy(p2); 21 22 sout | endl | "test ended" | endl; 23 14 sout | nl | "test ended"; 24 15 return 0; 25 16 } -
examples/wrapper/src/pointer.h
r3d99498 r200fcb3 34 34 void ?{}(content_t* this) 35 35 { 36 sout | "Constructing content" | endl;36 sout | "Constructing content"; 37 37 this->count = 0; 38 38 } … … 40 40 void ^?{}(content_t* this) 41 41 { 42 sout | "Destroying content" | endl;42 sout | "Destroying content"; 43 43 } 44 44 … … 53 53 void ?{}(wrapper_t* this) 54 54 { 55 sout | "Constructing empty ref pointer" | endl | endl;55 sout | "Constructing empty ref pointer" | nl; 56 56 this->ptr = NULL; 57 57 } … … 59 59 void ?{}(wrapper_t* this, wrapper_t rhs) 60 60 { 61 sout | "Constructing ref pointer from copy" | endl;61 sout | "Constructing ref pointer from copy"; 62 62 this->ptr = rhs.ptr; 63 63 this->ptr->count++; 64 sout | "Reference is " | this->ptr->count | endl | endl;64 sout | "Reference is " | this->ptr->count | nl; 65 65 } 66 66 … … 69 69 if(this->ptr) 70 70 { 71 sout | "Destroying ref pointer" | endl;71 sout | "Destroying ref pointer"; 72 72 this->ptr->count--; 73 sout | "Reference is " | this->ptr->count | endl | endl;73 sout | "Reference is " | this->ptr->count | nl; 74 74 if(!this->ptr->count) delete(this->ptr); 75 75 } 76 76 else 77 77 { 78 sout | "Destroying empty ref pointer" | endl | endl;78 sout | "Destroying empty ref pointer" | nl; 79 79 } 80 80 } … … 82 82 wrapper_t ?=?(wrapper_t* this, wrapper_t rhs) 83 83 { 84 sout | "Setting ref pointer" | endl;84 sout | "Setting ref pointer"; 85 85 if(this->ptr) 86 86 { 87 87 this->ptr->count--; 88 sout | "Reference is " | this->ptr->count | endl | endl;88 sout | "Reference is " | this->ptr->count | nl; 89 89 if(!this->ptr->count) delete(this->ptr); 90 90 } 91 91 this->ptr = rhs.ptr; 92 92 this->ptr->count++; 93 sout | "Reference is " | this->ptr->count | endl | endl;93 sout | "Reference is " | this->ptr->count | nl; 94 94 } 95 95 … … 98 98 this->ptr = c; 99 99 this->ptr->count++; 100 sout | "Setting ref pointer" | endl;101 sout | "Reference is " | this->ptr->count | endl | endl;100 sout | "Setting ref pointer"; 101 sout | "Reference is " | this->ptr->count | nl; 102 102 } 103 103 104 104 void clear(wrapper_t* this) 105 105 { 106 sout | "Clearing ref pointer" | endl;106 sout | "Clearing ref pointer"; 107 107 this->ptr->count--; 108 sout | "Reference is " | this->ptr->count | endl | endl;108 sout | "Reference is " | this->ptr->count | nl; 109 109 if(!this->ptr->count) delete(this->ptr); 110 110 this->ptr = NULL; -
examples/zero_one.c
r3d99498 r200fcb3 3 3 void foo(zero_t o) 4 4 { 5 sout | "It's a Zero!" | endl;5 sout | "It's a Zero!"; 6 6 } 7 7 8 8 void foo(one_t o) 9 9 { 10 sout | "It's a One!" | endl;10 sout | "It's a One!"; 11 11 } 12 12 13 13 void foo(int o) 14 14 { 15 sout | "It's a Number!" | endl;15 sout | "It's a Number!"; 16 16 } 17 17
Note: See TracChangeset
for help on using the changeset viewer.