# HG changeset patch # User anatofuz # Date 1541653607 -32400 # Node ID d236158257422c76990f57987dddfe8b56455b88 # Parent 71d4882a9ac3a3462c43d976004c0a4a17d7a101 fix _CbC_return for c-next.c diff -r 71d4882a9ac3 -r d23615825742 CbC-examples/c-next.c --- a/CbC-examples/c-next.c Thu Nov 08 06:52:59 2018 +0900 +++ b/CbC-examples/c-next.c Thu Nov 08 14:06:47 2018 +0900 @@ -5,7 +5,7 @@ typedef long* MVMRegister; typedef void* MVMCompUnit; typedef void* MVMCallsite; -typedef void* MVMThreadContext; +//typedef void* MVMThreadContext; typedef struct MVMThreadContext { MVMuint8 **interp_cur_op; @@ -14,6 +14,7 @@ MVMCompUnit **interp_cu; } MVMThreadContext; + typedef struct interp { MVMuint16 op; /* Points to the place in the bytecode right after the current opcode. */ @@ -35,21 +36,18 @@ MVMThreadContext *tc; + //__code (*ret)(); + //__code (*main_ret)(); __code (*ret)(int, void*); __code (*main_ret)(int, void*); void *env; } INTER,*INTERP; -__code cbc_no_op(INTERP i){ - goto cbc_next(i); -} +__code cbc_no_op(INTERP); +__code cbc_exit(INTERP); -__code cbc_exit(INTERP i){ - goto i->main_ret(0,i->env); -} - - __code (* CODES[])(INTERP) = { +__code (* CODES[])(INTERP) = { cbc_no_op, cbc_no_op, cbc_exit, @@ -61,22 +59,41 @@ goto c(i); } -int interp_run(MVMThreadContext *tc){ +__code cbc_no_op(INTERP i){ + goto cbc_next(i); +} + +__code cbc_exit(INTERP i){ + goto i->main_ret(0,i->env); } -int main(int argc, char **argv){ +//__code main_return(int i,stack sp) { +// if (loop-->0) +// goto f(233,sp); +// printf("#0103:%d\n",i); +// goto (( (struct main_continuation *)sp)->main_ret)(0, +// ((struct main_continuation *)sp)->env); +//} + +int interp_run(MVMThreadContext *tc){ INTER inter = {0,0,0,0,0,0,0,0,0}; INTERP i = &inter; - MVMuint8 cur_ops = {0,1,2,0,3,2}; - + MVMuint8 cur_op[] = {0,1,1,0,1,2}; +// i->ret = main_return; i->main_ret = _CbC_return; i->env = _CbC_environment; - i->cur_op = &cur_ops; + i->cur_op = cur_op; tc->interp_cur_op = &i->cur_op; tc->interp_bytecode_start = &i->bytecode_start; tc->interp_reg_base = &i->reg_base; tc->interp_cu = &i->cu; goto cbc_next(i); - // return 0; + return 0; } + +int main(int argc, char **argv){ + MVMThreadContext tct = {0,0,0,0}; + MVMThreadContext* tc = &tct; + interp_run(tc); +}