Ignore:
Timestamp:
Sep 4, 2021, 10:34:43 PM (3 years ago)
Author:
Peter A. Buhr <pabuhr@…>
Branches:
ADT, ast-experimental, enum, forall-pointer-decay, master, pthread-emulation, qualifiedEnum
Children:
49b3389
Parents:
f450f2f
Message:

attempt to remove tail-recursion optimization

File:
1 edited

Legend:

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

    rf450f2f r18783b4  
    44#include <stdlib.hfa>                                                                   // strto
    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                if ( frames == -1 ) printf( "42" );                             // prevent recursion optimizations
    1210        } else {
    1311                int fixup = 17;
    1412                raised_rtn(fixup);
    15                 return fixup;
    1613        }
    1714}
Note: See TracChangeset for help on using the changeset viewer.