Mercurial > repos > rhope
annotate runtime/func.h @ 24:8b2b3f4a2a58
Some fixes to parser_old.rhope
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Wed, 24 Jun 2009 23:56:49 -0400 |
parents | 31f8182f3433 |
children | 3498713c3dc9 |
rev | line source |
---|---|
7
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
1 #ifndef _FUNC_H_ |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
2 #define _FUNC_H_ |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
3 |
8
8d74ef7fa357
Improved helper macros and added separate Rhope stack in runtime
Mike Pavone <pavone@retrodev.com>
parents:
7
diff
changeset
|
4 typedef enum { |
8d74ef7fa357
Improved helper macros and added separate Rhope stack in runtime
Mike Pavone <pavone@retrodev.com>
parents:
7
diff
changeset
|
5 NORMAL_RETURN=0, |
8d74ef7fa357
Improved helper macros and added separate Rhope stack in runtime
Mike Pavone <pavone@retrodev.com>
parents:
7
diff
changeset
|
6 EXCEPTION_RETURN, |
8d74ef7fa357
Improved helper macros and added separate Rhope stack in runtime
Mike Pavone <pavone@retrodev.com>
parents:
7
diff
changeset
|
7 TAIL_RETURN, |
8d74ef7fa357
Improved helper macros and added separate Rhope stack in runtime
Mike Pavone <pavone@retrodev.com>
parents:
7
diff
changeset
|
8 NO_CONVERSION, |
8d74ef7fa357
Improved helper macros and added separate Rhope stack in runtime
Mike Pavone <pavone@retrodev.com>
parents:
7
diff
changeset
|
9 STACK_UNWIND |
8d74ef7fa357
Improved helper macros and added separate Rhope stack in runtime
Mike Pavone <pavone@retrodev.com>
parents:
7
diff
changeset
|
10 } returntype; |
8d74ef7fa357
Improved helper macros and added separate Rhope stack in runtime
Mike Pavone <pavone@retrodev.com>
parents:
7
diff
changeset
|
11 |
8d74ef7fa357
Improved helper macros and added separate Rhope stack in runtime
Mike Pavone <pavone@retrodev.com>
parents:
7
diff
changeset
|
12 |
8d74ef7fa357
Improved helper macros and added separate Rhope stack in runtime
Mike Pavone <pavone@retrodev.com>
parents:
7
diff
changeset
|
13 typedef returntype (*rhope_func)(struct calldata *); |
8d74ef7fa357
Improved helper macros and added separate Rhope stack in runtime
Mike Pavone <pavone@retrodev.com>
parents:
7
diff
changeset
|
14 typedef void (*special_func) (struct object *); |
8d74ef7fa357
Improved helper macros and added separate Rhope stack in runtime
Mike Pavone <pavone@retrodev.com>
parents:
7
diff
changeset
|
15 |
12
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
16 #define MethodName(name,type) f_ ## name ## _AT_ ## type |
7
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
17 |
11
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
18 #define Func(name,numparams,callspace,localtype) \ |
12
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
19 returntype f_ ## name (calldata * cdata)\ |
11
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
20 {\ |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
21 localtype *locals;\ |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
22 calldata *call;\ |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
23 returntype ret;\ |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
24 int idx;\ |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
25 if(cdata->resume)\ |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
26 {\ |
12
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
27 call = cdata->call;\ |
11
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
28 locals = cdata->locals;\ |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
29 }\ |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
30 switch(cdata->resume)\ |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
31 {\ |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
32 case 0:\ |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
33 for(idx = numparams; idx < cdata->num_params; ++idx)\ |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
34 release_ref(cdata->params[idx]); cdata->num_params = numparams;\ |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
35 cdata->num_params = numparams;\ |
12
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
36 cdata->call = call = alloc_cdata(cdata->ct, callspace);\ |
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
37 cdata->locals = locals = alloc_stack(cdata->ct, sizeof(localtype)); |
11
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
38 |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
39 #define FuncNoLocals(name,numparams,callspace) \ |
12
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
40 returntype f_ ## name (calldata * cdata)\ |
11
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
41 {\ |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
42 calldata *call;\ |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
43 returntype ret;\ |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
44 int idx;\ |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
45 if(cdata->resume)\ |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
46 call = cdata->locals;\ |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
47 switch(cdata->resume)\ |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
48 {\ |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
49 case 0:\ |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
50 for(idx = numparams; idx < cdata->num_params; ++idx)\ |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
51 release_ref(cdata->params[idx]);\ |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
52 cdata->num_params = numparams;\ |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
53 cdata->locals = call = alloc_cdata(cdata->ct, callspace); |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
54 |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
55 #define EndFunc \ |
12
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
56 free_stack(cdata->ct, call);\ |
11
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
57 return NORMAL_RETURN;\ |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
58 }\ |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
59 } |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
60 |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
61 #define Method(name,type,numparams,callspace,localtype) \ |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
62 returntype MethodName(name,type) (calldata * cdata)\ |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
63 {\ |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
64 localtype *locals;\ |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
65 calldata *call;\ |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
66 returntype ret;\ |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
67 int idx;\ |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
68 if(cdata->resume)\ |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
69 {\ |
12
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
70 call = cdata->call;\ |
11
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
71 locals = cdata->locals;\ |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
72 }\ |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
73 switch(cdata->resume)\ |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
74 {\ |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
75 case 0:\ |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
76 for(idx = numparams; idx < cdata->num_params; ++idx)\ |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
77 release_ref(cdata->params[idx]); cdata->num_params = numparams;\ |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
78 cdata->num_params = numparams;\ |
12
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
79 cdata->call = call = alloc_cdata(cdata->ct, callspace);\ |
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
80 cdata->locals = locals = alloc_stack(cdata->ct, sizeof(localtype)); |
11
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
81 |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
82 #define MethodNoLocals(name,type,numparams,callspace) \ |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
83 returntype MethodName(name,type) (calldata * cdata)\ |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
84 {\ |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
85 calldata *call;\ |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
86 returntype ret;\ |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
87 int idx;\ |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
88 if(cdata->resume)\ |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
89 call = cdata->locals;\ |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
90 switch(cdata->resume)\ |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
91 {\ |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
92 case 0:\ |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
93 for(idx = numparams; idx < cdata->num_params; ++idx)\ |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
94 release_ref(cdata->params[idx]);\ |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
95 cdata->num_params = numparams;\ |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
96 cdata->locals = call = alloc_cdata(cdata->ct, callspace); |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
97 |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
98 #define NumParams |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
99 #define CallSpace |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
100 |
12
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
101 #define Param(num,convtypeid) \ |
11
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
102 call->params[0] = cdata->params[num];\ |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
103 call->resume = 0;\ |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
104 ret = coerce_value(convtypeid, call);\ |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
105 while(ret == TAIL_RETURN)\ |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
106 ret = call->tail_func(call);\ |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
107 if(ret == EXCEPTION_RETURN)\ |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
108 {\ |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
109 for(idx = 0; idx < cdata->num_params; ++idx)\ |
12
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
110 if(idx != num && cdata->params[idx])\ |
11
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
111 release_ref(cdata->params[idx]);\ |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
112 cdata->params[0] = call->params[0];\ |
12
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
113 free_stack(cdata->ct, call);\ |
11
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
114 return ret;\ |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
115 }\ |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
116 cdata->params[num] = call->params[0]; |
8
8d74ef7fa357
Improved helper macros and added separate Rhope stack in runtime
Mike Pavone <pavone@retrodev.com>
parents:
7
diff
changeset
|
117 |
12
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
118 #define CopiedParam(num,convtypeid) Param(num,convtypeid) cdata->params[num] = copy_object(cdata->params[num]); |
7
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
119 #define Ret(num,val) cdata->params[num] = (object *)(val); |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
120 #define Return return NORMAL_RETURN; |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
121 #define Exception |
12
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
122 #define FuncDef(name) returntype f_ ## name (calldata * cdata); |
7
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
123 #define MethodDef(name,type) returntype MethodName(name,type) (calldata * cdata); |
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
124 |
11
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
125 #define Call(func, numparams)\ |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
126 call->num_params = numparams;\ |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
127 call->resume = 0;\ |
12
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
128 ret = f_ ## func (call);\ |
11
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
129 while(ret == TAIL_RETURN)\ |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
130 ret = call->tail_func(call);\ |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
131 if(ret == EXCEPTION_RETURN)\ |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
132 {\ |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
133 for(idx = 0; idx < cdata->num_params; ++idx)\ |
12
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
134 if(cdata->params[idx])\ |
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
135 release_ref(cdata->params[idx]);\ |
11
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
136 cdata->params[0] = call->params[0];\ |
12
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
137 free_stack(cdata->ct, call);\ |
11
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
138 return ret;\ |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
139 } |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
140 |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
141 #define MCall(methodid, numparams)\ |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
142 call->num_params = numparams;\ |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
143 call->resume = 0;\ |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
144 ret = call_method(methodid, call);\ |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
145 while(ret == TAIL_RETURN)\ |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
146 ret = call->tail_func(call);\ |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
147 if(ret == EXCEPTION_RETURN)\ |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
148 {\ |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
149 for(idx = 0; idx < cdata->num_params; ++idx)\ |
12
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
150 if(cdata->params[idx])\ |
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
151 release_ref(cdata->params[idx]);\ |
11
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
152 cdata->params[0] = call->params[0];\ |
12
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
153 free_stack(cdata->ct, call);\ |
11
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
154 return ret;\ |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
155 } |
7
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
156 |
12
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
157 #define TMCall(methodid, numparams)\ |
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
158 free_stack(cdata->ct, call);\ |
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
159 cdata->num_params = numparams;\ |
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
160 cdata->resume = 0;\ |
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
161 ret = call_method(methodid, cdata);\ |
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
162 return ret; |
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
163 |
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
164 #define TCall(func, numparams)\ |
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
165 free_stack(cdata->ct, call);\ |
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
166 cdata->num_params = numparams;\ |
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
167 cdata->resume = 0;\ |
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
168 cdata->tail_func = f_ ## func;\ |
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
169 return TAIL_RETURN; |
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
170 |
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
171 |
7
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
172 #endif //_FUNC_H_ |