view test/ret_check.c @ 684:6e2f1e7f9fc3

*** empty log message ***
author kono
date Tue, 02 Oct 2007 21:18:12 +0900
parents 682c8ec38d45
children 3f1f6c0610c1
line wrap: on
line source

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

#ifdef __micro_c__

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

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

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

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

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

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

#else

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

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

#endif

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

int
g_incl2_test(float a0)
{
    printf("#0058:%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("#0066:%d\n",f0);
    printf("#0066:%d\n",f_incl0_test(11));
    printf("#0067:%d\n",g_incl1(12,g_incl2));
    printf("#0068:%d\n",g_incl1(13,g_incl2_test));
    return 0;
}

/* end */