view CbC-examples/tmp2.c @ 127:4c56639505ff

fix function.c and add CbC-example Makefile
author mir3636
date Wed, 11 Apr 2018 18:46:58 +0900
parents 5d30d517ebed
children fe568345ddd5
line wrap: on
line source

#define __environment _CbC_environment
#define __return _CbC_return

#include "stdio.h"

int main0(int ac,char *av[]);
__code code0(char *av[],__code (*ret)(int),void *retenv);
__code code1(char *av[],__code (*ret)(int),void *retenv);

int
main(ac,av)
int ac;
char *av[];
{
    int i;
    i=main0(ac,av);
    fprintf(stdout,"#0012:1: %s %d\n",av[0],i);
    return 0;
}

int
main0(ac,av)
int ac;
char *av[];
{
    fprintf(stdout,"#0021:2: %s\n",av[0]);
    goto code0(av,_CbC_return,_CbC_environment);
}

__code code0(av,ret,retenv)
char *av[];
__code (*ret)();
void *retenv;
{
    char *p;
    p = av[0];
    fprintf(stdout,"#0032:3: %s\n",p);
    goto code1(av,ret,retenv);
}

__code code1(av,ret,retenv)
char *av[];
__code (*ret)();
void *retenv;
{
    fprintf(stdout,"#0041:4: %s\n",av[0]);
    goto (*ret)(1234,retenv);
}