view test/ret_check.c @ 856:d9dd3e6e7c5f

macro compatibility
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Tue, 22 Nov 2011 05:44:49 +0900
parents c2c709727221
children
line wrap: on
line source

#define __environment _CbC_environment
#define __return _CbC_return

extern int printf(char *,...);

#ifdef __micro_c__

____code(*f_incl_ret)(int,void *);
void *f_incl_env;

__code
f_incl2(int a0)
{   // 正しいのはコッチ
    printf("#0013:%d\n",a0);
    goto f_incl_ret(a0,f_incl_env);
}

__code
f_incl2_test(float a0)
{   // ret先のinterface型が異なる
    printf("#0020:%g\n",a0);
    goto f_incl_ret(a0,f_incl_env);
}

__code
f_incl1(int a0,__code(*ret)(int))
{
    printf("#0027:%d\n",a0);
    goto ret(a0*a0);
}

int
f_incl0(int a0)
{
    f_incl_ret=return;
    f_incl_env=environment;
    printf("#0036:%d\n",a0);
    goto f_incl1(a0,f_incl2);
}

int
f_incl0_test(int a0)
{
    f_incl_ret=return;
    f_incl_env=environment;
    printf("#0045:%d\n",a0);
    goto f_incl1(a0,f_incl2_test);
}

#else

int
f_incl0(int a0)
{
    printf("#0054:%d\n",a0);
    return a0;
}

int
f_incl0_test(int a0)
{
    printf("#0061:%d\n",a0);
    return a0;
}

#endif

int
g_incl2(int a0)
{
    printf("#0070:%d\n",a0);
    return a0;
}

int
g_incl2_test(float a0)
{
    printf("#0077:%g\n",a0);
    return (int) a0;
}

int
g_incl1(int a0,int (*ret)(int))
{
    return ret(a0);
}

int
main()
{
    int f0=f_incl0(10);
    printf("#0091:%d\n",f0);
    printf("#0092:%d\n",f_incl0_test(11));
    printf("#0093:%d\n",g_incl1(12,g_incl2));
    printf("#0094:%d\n",g_incl1(13,g_incl2_test));
    return 0;
}

/* end */