Changeset 2bfee8e
- Timestamp:
- Sep 7, 2021, 12:26:06 PM (3 years ago)
- Branches:
- ADT, ast-experimental, enum, forall-pointer-decay, master, pthread-emulation, qualifiedEnum
- Children:
- 031453c
- Parents:
- 1341ce1 (diff), 812ba3d (diff)
Note: this is a merge changeset, the changes displayed below correspond to the merge itself.
Use the(diff)
links above to see all the changes relative to each parent. - Files:
-
- 6 added
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
TabularUnified doc/theses/andrew_beach_MMath/code/fixup-empty-f.cfa ¶
r1341ce1 r2bfee8e 2 2 #include <clock.hfa> 3 3 #include <fstream.hfa> 4 #include <stdlib.hfa> // strto4 #include <stdlib.hfa> 5 5 6 intnounwind_fixup(unsigned int frames, void (*raised_rtn)(int &)) {6 void nounwind_fixup(unsigned int frames, void (*raised_rtn)(int &)) { 7 7 if (frames) { 8 int rtn = nounwind_fixup(frames - 1, raised_rtn); 9 if ( rtn == 42 ) printf( "42" ); // make non-tail recursive 10 return rtn; 11 8 nounwind_fixup(frames - 1, raised_rtn); 9 // "Always" false, but prevents recursion elimination. 10 if (-1 == frames) printf("~"); 12 11 } else { 13 12 int fixup = 17; 14 13 raised_rtn(fixup); 15 return fixup;16 14 } 17 15 } … … 27 25 } 28 26 27 // Closures at the top level are allowed to be true closures. 29 28 void raised(int & fixup) { 30 fixup = total_frames + 42; // use local scope => lexical link31 if ( total_frames == 42 ) printf( "42");29 fixup = total_frames + 42; 30 if (total_frames == 42) printf("42"); 32 31 } 33 32 -
TabularUnified doc/theses/andrew_beach_MMath/code/fixup-empty-r.cfa ¶
r1341ce1 r2bfee8e 3 3 #include <exception.hfa> 4 4 #include <fstream.hfa> 5 #include <stdlib.hfa> // strto5 #include <stdlib.hfa> 6 6 7 7 exception fixup_exception { … … 10 10 vtable(fixup_exception) fixup_vt; 11 11 12 intnounwind_empty(unsigned int frames) {12 void nounwind_empty(unsigned int frames) { 13 13 if (frames) { 14 int rtn =nounwind_empty(frames - 1);15 if ( rtn == 42 ) printf( "42" ); // make non-tail recursive16 return rtn;14 nounwind_empty(frames - 1); 15 // "Always" false, but prevents recursion elimination. 16 if (-1 == frames) printf("~"); 17 17 } else { 18 18 int fixup = 17; 19 throwResume (fixup_exception){&fixup_vt, fixup}; // change bad fixup 20 return fixup; 19 throwResume (fixup_exception){&fixup_vt, fixup}; 21 20 } 22 21 } -
TabularUnified doc/theses/andrew_beach_MMath/code/fixup-other-f.cfa ¶
r1341ce1 r2bfee8e 2 2 #include <clock.hfa> 3 3 #include <fstream.hfa> 4 #include <stdlib.hfa> // strto4 #include <stdlib.hfa> 5 5 6 unsigned int frames; // use global because of gcc thunk problem 6 // Using a global value to allow hoisting (and avoid thunks). 7 unsigned int frames; 7 8 8 9 void nounwind_fixup(unsigned int dummy, void (*raised_rtn)(int &), void (*not_raised_rtn)(int &)) { 9 10 void not_raised(int & fixup) { 10 fixup = frames + 42; // use local scope => lexical link11 fixup = frames + 42; 11 12 } 12 13 … … 14 15 frames -= 1; 15 16 nounwind_fixup(42, raised_rtn, not_raised); 17 // Always false, but prevents recursion elimination. 18 if (-1 == frames) printf("~"); 16 19 } else { 17 20 int fixup = dummy; … … 31 34 frames = total_frames; 32 35 36 // Closures at the top level are allowed to be true closures. 33 37 void raised(int & fixup) { 34 fixup = total_frames + 42; // use local scope => lexical link38 fixup = total_frames + 42; 35 39 } 36 40 void not_raised(int & fixup) { 37 fixup = total_frames + 42; // use local scope => lexical link41 fixup = total_frames + 42; 38 42 } 39 43 -
TabularUnified doc/theses/andrew_beach_MMath/code/fixup-other-r.cfa ¶
r1341ce1 r2bfee8e 3 3 #include <exception.hfa> 4 4 #include <fstream.hfa> 5 #include <stdlib.hfa> // strto5 #include <stdlib.hfa> 6 6 7 7 exception fixup_exception { … … 13 13 }; 14 14 15 unsigned int frames; // use global because of gcc thunk problem 15 // Using a global value to allow hoisting (and avoid thunks). 16 unsigned int frames; 16 17 17 18 void nounwind_other(unsigned int dummy) { … … 20 21 try { 21 22 nounwind_other(42); 23 // Always false, but prevents recursion elimination. 24 if (-1 == frames) printf("~"); 22 25 } catchResume (not_raised_exception * ex) { 23 ex->fixup = frames + 42; // use local scope => lexical link26 ex->fixup = frames + 42; 24 27 } 25 28 } else { 26 29 int fixup = dummy; 27 throwResume (fixup_exception){&fixup_vt, fixup}; // change bad fixup30 throwResume (fixup_exception){&fixup_vt, fixup}; 28 31 } 29 32 } -
TabularUnified doc/theses/andrew_beach_MMath/code/resume-empty.cfa ¶
r1341ce1 r2bfee8e 11 11 if (frames) { 12 12 nounwind_empty(frames - 1); 13 if ( frames == -1 ) printf( "42" ); // prevent recursion optimizations 13 14 } else { 14 15 throwResume (empty_exception){&empty_vt}; -
TabularUnified doc/theses/andrew_beach_MMath/code/test.sh ¶
r1341ce1 r2bfee8e 12 12 # test.sh -v LANGUAGE TEST FILE 13 13 # View the result from TEST in LANGUAGE stored in FILE. 14 15 readonly DIR=$(dirname "$(readlink -f "$0")") 16 cd $DIR 14 17 15 18 readonly MIL=000000 -
TabularUnified doc/theses/andrew_beach_MMath/code/throw-empty.cpp ¶
r1341ce1 r2bfee8e 1 1 // Throw Across Empty Function 2 2 #include <chrono> 3 #include <cstdio> 3 4 #include <cstdlib> 4 5 #include <exception> … … 14 15 if (frames) { 15 16 unwind_empty(frames - 1); 17 if (-1 == frames) printf("~"); 16 18 } else { 17 19 throw (EmptyException){}; -
TabularUnified libcfa/src/Makefile.am ¶
r1341ce1 r2bfee8e 87 87 containers/pair.hfa \ 88 88 containers/result.hfa \ 89 containers/string.hfa \ 90 containers/string_res.hfa \ 89 91 containers/vector.hfa \ 90 92 device/cpu.hfa
Note: See TracChangeset
for help on using the changeset viewer.