comparison CbC-examples/c-next.c @ 136:4627f235cf2a

fix c-next example
author Shinji KONO <kono@ie.u-ryukyu.ac.jp>
date Thu, 08 Nov 2018 14:11:56 +0900
parents 71d4882a9ac3
children d22083d7f10b
comparison
equal deleted inserted replaced
134:71d4882a9ac3 136:4627f235cf2a
3 typedef unsigned short MVMuint16; 3 typedef unsigned short MVMuint16;
4 typedef unsigned char MVMuint8; 4 typedef unsigned char MVMuint8;
5 typedef long* MVMRegister; 5 typedef long* MVMRegister;
6 typedef void* MVMCompUnit; 6 typedef void* MVMCompUnit;
7 typedef void* MVMCallsite; 7 typedef void* MVMCallsite;
8 typedef void* MVMThreadContext;
9 8
10 typedef struct MVMThreadContext { 9 typedef struct MVMThreadContext {
11 MVMuint8 **interp_cur_op; 10 MVMuint8 **interp_cur_op;
12 MVMuint8 **interp_bytecode_start; 11 MVMuint8 **interp_bytecode_start;
13 MVMRegister **interp_reg_base; 12 MVMRegister **interp_reg_base;
39 __code (*main_ret)(int, void*); 38 __code (*main_ret)(int, void*);
40 void *env; 39 void *env;
41 40
42 } INTER,*INTERP; 41 } INTER,*INTERP;
43 42
43 __code cbc_next(INTERP i);
44
44 __code cbc_no_op(INTERP i){ 45 __code cbc_no_op(INTERP i){
45 goto cbc_next(i); 46 goto cbc_next(i);
46 } 47 }
47 48
48 __code cbc_exit(INTERP i){ 49 __code cbc_exit(INTERP i){
60 c = CODES[NEXT_OP(i)]; 61 c = CODES[NEXT_OP(i)];
61 goto c(i); 62 goto c(i);
62 } 63 }
63 64
64 int interp_run(MVMThreadContext *tc){ 65 int interp_run(MVMThreadContext *tc){
66 return 0;
65 } 67 }
66 68
67 int main(int argc, char **argv){ 69 int main(int argc, char **argv){
68 INTER inter = {0,0,0,0,0,0,0,0,0}; 70 INTER inter = {0,0,0,0,0,0,0,0,0};
69 INTERP i = &inter; 71 INTERP i = &inter;
70 MVMuint8 cur_ops = {0,1,2,0,3,2}; 72 MVMuint8 cur_ops[] = {0,1,2,0,3,2};
71 73
72 i->main_ret = _CbC_return; 74 i->main_ret = _CbC_return;
73 i->env = _CbC_environment; 75 i->env = _CbC_environment;
74 i->cur_op = &cur_ops; 76 i->cur_op = cur_ops;
77
78 MVMThreadContext tc0, *tc;
79 tc = &tc0;
75 80
76 tc->interp_cur_op = &i->cur_op; 81 tc->interp_cur_op = &i->cur_op;
77 tc->interp_bytecode_start = &i->bytecode_start; 82 tc->interp_bytecode_start = &i->bytecode_start;
78 tc->interp_reg_base = &i->reg_base; 83 tc->interp_reg_base = &i->reg_base;
79 tc->interp_cu = &i->cu; 84 tc->interp_cu = &i->cu;