comparison test/test.c @ 11:3021dac0d8f5

Stack unwind is so close I can almost taste it
author Mike Pavone <pavone@retrodev.com>
date Tue, 19 May 2009 23:29:55 -0400
parents 8d74ef7fa357
children 31f8182f3433
comparison
equal deleted inserted replaced
10:0f2c4ee070fe 11:3021dac0d8f5
3 #include "object.h" 3 #include "object.h"
4 #include "integer.h" 4 #include "integer.h"
5 #include "context.h" 5 #include "context.h"
6 #include "func.h" 6 #include "func.h"
7 7
8 FuncNoLocals(Main,0) 8 FuncNoLocals(Main,
9 call = alloc_cdata(cdata->ct,2); 9 NumParams 0,
10 CallSpace 2)
10 call->params[0] = make_Int32(2); 11 call->params[0] = make_Int32(2);
11 call->params[1] = make_Int32(3); 12 call->params[1] = make_Int32(3);
12 call->num_params = 2; 13 MCall(METHOD_ADD, 2)
13 ret = call_method(METHOD_ADD, call); 14
14 while(ret == TAIL_RETURN)
15 ret = call->tail_func(call);
16 if(ret == EXCEPTION_RETURN) {
17 Ret(0,call->params[0]);
18 return ret;
19 }
20 call->params[1] = make_Int32(1); 15 call->params[1] = make_Int32(1);
21 ret = call_method(METHOD_SUB, call); 16 MCall(METHOD_SUB, 2)
22 while(ret == TAIL_RETURN)
23 ret = call->tail_func(call);
24 if(ret == EXCEPTION_RETURN) {
25 Ret(0,call->params[0]);
26 return ret;
27 }
28 Ret(0,call->params[0]) 17 Ret(0,call->params[0])
29 EndFunc 18 EndFunc
30 19
31 20
32 int main(int argc, char ** argv) 21 int main(int argc, char ** argv)
36 context * ct; 25 context * ct;
37 register_builtin_types(); 26 register_builtin_types();
38 ct = new_context(); 27 ct = new_context();
39 cdata = alloc_cdata(ct, 1); 28 cdata = alloc_cdata(ct, 1);
40 cdata->num_params = 0; 29 cdata->num_params = 0;
30 cdata->resume = 0;
41 ret = _f_Main(cdata); 31 ret = _f_Main(cdata);
42 while(ret == TAIL_RETURN) 32 while(ret == TAIL_RETURN)
43 ret = cdata->tail_func(cdata); 33 ret = cdata->tail_func(cdata);
44 if(ret == EXCEPTION_RETURN) { 34 if(ret == EXCEPTION_RETURN) {
45 puts("Exception!"); 35 puts("Exception!");