Changeset 2bfee8e for doc/theses


Ignore:
Timestamp:
Sep 7, 2021, 12:26:06 PM (3 years ago)
Author:
Thierry Delisle <tdelisle@…>
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.
Message:

Merge branch 'master' of plg.uwaterloo.ca:software/cfa/cfa-cc

Location:
doc/theses/andrew_beach_MMath/code
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • doc/theses/andrew_beach_MMath/code/fixup-empty-f.cfa

    r1341ce1 r2bfee8e  
    22#include <clock.hfa>
    33#include <fstream.hfa>
    4 #include <stdlib.hfa>                                                                   // strto
     4#include <stdlib.hfa>
    55
    6 int nounwind_fixup(unsigned int frames, void (*raised_rtn)(int &)) {
     6void nounwind_fixup(unsigned int frames, void (*raised_rtn)(int &)) {
    77        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("~");
    1211        } else {
    1312                int fixup = 17;
    1413                raised_rtn(fixup);
    15                 return fixup;
    1614        }
    1715}
     
    2725        }
    2826
     27        // Closures at the top level are allowed to be true closures.
    2928        void raised(int & fixup) {
    30                 fixup = total_frames + 42;                                              // use local scope => lexical link
    31                 if ( total_frames == 42 ) printf( "42" );
     29                fixup = total_frames + 42;
     30                if (total_frames == 42) printf("42");
    3231        }
    3332
  • doc/theses/andrew_beach_MMath/code/fixup-empty-r.cfa

    r1341ce1 r2bfee8e  
    33#include <exception.hfa>
    44#include <fstream.hfa>
    5 #include <stdlib.hfa>                                                                   // strto
     5#include <stdlib.hfa>
    66
    77exception fixup_exception {
     
    1010vtable(fixup_exception) fixup_vt;
    1111
    12 int nounwind_empty(unsigned int frames) {
     12void nounwind_empty(unsigned int frames) {
    1313        if (frames) {
    14                 int rtn = nounwind_empty(frames - 1);
    15                 if ( rtn == 42 ) printf( "42" );                                // make non-tail recursive
    16                 return rtn;
     14                nounwind_empty(frames - 1);
     15                // "Always" false, but prevents recursion elimination.
     16                if (-1 == frames) printf("~");
    1717        } else {
    1818                int fixup = 17;
    19                 throwResume (fixup_exception){&fixup_vt, fixup}; // change bad fixup
    20                 return fixup;
     19                throwResume (fixup_exception){&fixup_vt, fixup};
    2120        }
    2221}
  • doc/theses/andrew_beach_MMath/code/fixup-other-f.cfa

    r1341ce1 r2bfee8e  
    22#include <clock.hfa>
    33#include <fstream.hfa>
    4 #include <stdlib.hfa>                                                                   // strto
     4#include <stdlib.hfa>
    55
    6 unsigned int frames;                                                                    // use global because of gcc thunk problem
     6// Using a global value to allow hoisting (and avoid thunks).
     7unsigned int frames;
    78
    89void nounwind_fixup(unsigned int dummy, void (*raised_rtn)(int &), void (*not_raised_rtn)(int &)) {
    910        void not_raised(int & fixup) {
    10                 fixup = frames + 42;                                                    // use local scope => lexical link
     11                fixup = frames + 42;
    1112        }
    1213
     
    1415                frames -= 1;
    1516                nounwind_fixup(42, raised_rtn, not_raised);
     17                // Always false, but prevents recursion elimination.
     18                if (-1 == frames) printf("~");
    1619        } else {
    1720                int fixup = dummy;
     
    3134        frames = total_frames;
    3235
     36        // Closures at the top level are allowed to be true closures.
    3337        void raised(int & fixup) {
    34                 fixup = total_frames + 42;                                              // use local scope => lexical link
     38                fixup = total_frames + 42;
    3539        }
    3640        void not_raised(int & fixup) {
    37                 fixup = total_frames + 42;                                              // use local scope => lexical link
     41                fixup = total_frames + 42;
    3842        }
    3943
  • doc/theses/andrew_beach_MMath/code/fixup-other-r.cfa

    r1341ce1 r2bfee8e  
    33#include <exception.hfa>
    44#include <fstream.hfa>
    5 #include <stdlib.hfa>                                                                   // strto
     5#include <stdlib.hfa>
    66
    77exception fixup_exception {
     
    1313};
    1414
    15 unsigned int frames;                                                                    // use global because of gcc thunk problem
     15// Using a global value to allow hoisting (and avoid thunks).
     16unsigned int frames;
    1617
    1718void nounwind_other(unsigned int dummy) {
     
    2021                try {
    2122                        nounwind_other(42);
     23                        // Always false, but prevents recursion elimination.
     24                        if (-1 == frames) printf("~");
    2225                } catchResume (not_raised_exception * ex) {
    23                         ex->fixup = frames + 42;                                        // use local scope => lexical link
     26                        ex->fixup = frames + 42;
    2427                }
    2528        } else {
    2629                int fixup = dummy;
    27                 throwResume (fixup_exception){&fixup_vt, fixup}; // change bad fixup
     30                throwResume (fixup_exception){&fixup_vt, fixup};
    2831        }
    2932}
  • doc/theses/andrew_beach_MMath/code/resume-empty.cfa

    r1341ce1 r2bfee8e  
    1111        if (frames) {
    1212                nounwind_empty(frames - 1);
     13                if ( frames == -1 ) printf( "42" );                             // prevent recursion optimizations
    1314        } else {
    1415                throwResume (empty_exception){&empty_vt};
  • doc/theses/andrew_beach_MMath/code/test.sh

    r1341ce1 r2bfee8e  
    1212# test.sh -v LANGUAGE TEST FILE
    1313#   View the result from TEST in LANGUAGE stored in FILE.
     14
     15readonly DIR=$(dirname "$(readlink -f "$0")")
     16cd $DIR
    1417
    1518readonly MIL=000000
  • doc/theses/andrew_beach_MMath/code/throw-empty.cpp

    r1341ce1 r2bfee8e  
    11// Throw Across Empty Function
    22#include <chrono>
     3#include <cstdio>
    34#include <cstdlib>
    45#include <exception>
     
    1415        if (frames) {
    1516                unwind_empty(frames - 1);
     17                if (-1 == frames) printf("~");
    1618        } else {
    1719                throw (EmptyException){};
Note: See TracChangeset for help on using the changeset viewer.