Mercurial > repos > rhope
annotate runtime/func.h @ 180:c40e0faa1c92
Add Call to Dict and List
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Sun, 19 Jun 2011 10:43:11 -0700 |
parents | d2b941f82d74 |
children | ba35ab624ec2 |
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 |
66
d4b44ae2e34a
New variant of C backend works now
Mike Pavone <pavone@retrodev.com>
parents:
65
diff
changeset
|
4 typedef struct object object; |
d4b44ae2e34a
New variant of C backend works now
Mike Pavone <pavone@retrodev.com>
parents:
65
diff
changeset
|
5 typedef struct calldata calldata; |
d4b44ae2e34a
New variant of C backend works now
Mike Pavone <pavone@retrodev.com>
parents:
65
diff
changeset
|
6 |
8
8d74ef7fa357
Improved helper macros and added separate Rhope stack in runtime
Mike Pavone <pavone@retrodev.com>
parents:
7
diff
changeset
|
7 typedef enum { |
8d74ef7fa357
Improved helper macros and added separate Rhope stack in runtime
Mike Pavone <pavone@retrodev.com>
parents:
7
diff
changeset
|
8 NORMAL_RETURN=0, |
8d74ef7fa357
Improved helper macros and added separate Rhope stack in runtime
Mike Pavone <pavone@retrodev.com>
parents:
7
diff
changeset
|
9 EXCEPTION_RETURN, |
8d74ef7fa357
Improved helper macros and added separate Rhope stack in runtime
Mike Pavone <pavone@retrodev.com>
parents:
7
diff
changeset
|
10 TAIL_RETURN, |
8d74ef7fa357
Improved helper macros and added separate Rhope stack in runtime
Mike Pavone <pavone@retrodev.com>
parents:
7
diff
changeset
|
11 NO_CONVERSION, |
8d74ef7fa357
Improved helper macros and added separate Rhope stack in runtime
Mike Pavone <pavone@retrodev.com>
parents:
7
diff
changeset
|
12 STACK_UNWIND |
8d74ef7fa357
Improved helper macros and added separate Rhope stack in runtime
Mike Pavone <pavone@retrodev.com>
parents:
7
diff
changeset
|
13 } returntype; |
8d74ef7fa357
Improved helper macros and added separate Rhope stack in runtime
Mike Pavone <pavone@retrodev.com>
parents:
7
diff
changeset
|
14 |
8d74ef7fa357
Improved helper macros and added separate Rhope stack in runtime
Mike Pavone <pavone@retrodev.com>
parents:
7
diff
changeset
|
15 |
53
70af7fa155d0
Cleaned up some C warnings and added a simple compile script
Mike Pavone <pavone@retrodev.com>
parents:
48
diff
changeset
|
16 typedef returntype (*rhope_func)(calldata *); |
100
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
85
diff
changeset
|
17 typedef void (*special_func) (object *); |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
85
diff
changeset
|
18 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
85
diff
changeset
|
19 #ifdef MULTI_SWITCH |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
85
diff
changeset
|
20 #define DispatchEntry(name) case FUNC_##name: goto f_##name; |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
85
diff
changeset
|
21 #define ResumeEntry(num,name) case RES_##num##_##name: goto r##num##_##name; |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
85
diff
changeset
|
22 #define DispatchVar |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
85
diff
changeset
|
23 #define DISPATCH switch(func) { DispatchEntries } |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
85
diff
changeset
|
24 #define EndEntry case END: goto DO_END; |
140
c14698c512f1
Untested addition of Pause/Resume
Mike Pavone <pavone@retrodev.com>
parents:
128
diff
changeset
|
25 #define EndThreadEntry case END_THREAD: goto DO_END_THREAD; |
100
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
85
diff
changeset
|
26 #else |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
85
diff
changeset
|
27 #define DispatchEntry(name) &&f_##name, |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
85
diff
changeset
|
28 #define ResumeEntry(num,name) &&r##num##_##name, |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
85
diff
changeset
|
29 #define DispatchVar void * funcs[] = { DispatchEntries }; |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
85
diff
changeset
|
30 #define DISPATCH goto *funcs[func]; |
141
f2cb85c53ced
Fix Pause/Resume and rewrite Call Async in Rhope rather than C
Mike Pavone <pavone@retrodev.com>
parents:
140
diff
changeset
|
31 #define EndEntry &&DO_END, |
f2cb85c53ced
Fix Pause/Resume and rewrite Call Async in Rhope rather than C
Mike Pavone <pavone@retrodev.com>
parents:
140
diff
changeset
|
32 #define EndThreadEntry &&DO_END_THREAD |
100
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
85
diff
changeset
|
33 #endif |
85
6d10b5b9ebc3
Make dispatch type selectable between replicated switch and computed goto
Mike Pavone <pavone@retrodev.com>
parents:
75
diff
changeset
|
34 |
8
8d74ef7fa357
Improved helper macros and added separate Rhope stack in runtime
Mike Pavone <pavone@retrodev.com>
parents:
7
diff
changeset
|
35 |
48
a24eb366195c
Fixed some bugs introduced in previous commit and moved definition of integer methods out of runtime and into the compiler
Mike Pavone <pavone@retrodev.com>
parents:
35
diff
changeset
|
36 #define MethodName(name,type) f_ ## name ## AT_ ## type |
7
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
37 |
105
43cc42df26cc
Various compiler improvements
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
38 #ifdef ENABLE_PROFILING |
43cc42df26cc
Various compiler improvements
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
39 |
43cc42df26cc
Various compiler improvements
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
40 #define START_PROFILE \ |
151
b75ec364cecc
Fix conflict between name of proviling variable and time function in C stdlib
Mike Pavone <pavone@retrodev.com>
parents:
142
diff
changeset
|
41 gettimeofday(&proftime, NULL);\ |
105
43cc42df26cc
Various compiler improvements
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
42 cdata->accum = cdata->self_accum = 0;\ |
151
b75ec364cecc
Fix conflict between name of proviling variable and time function in C stdlib
Mike Pavone <pavone@retrodev.com>
parents:
142
diff
changeset
|
43 cdata->self_start = cdata->start = ((uint64_t)proftime.tv_sec) * 1000000ULL + ((uint64_t)proftime.tv_usec); |
105
43cc42df26cc
Various compiler improvements
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
44 |
43cc42df26cc
Various compiler improvements
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
45 #define PAUSE_SELF \ |
151
b75ec364cecc
Fix conflict between name of proviling variable and time function in C stdlib
Mike Pavone <pavone@retrodev.com>
parents:
142
diff
changeset
|
46 gettimeofday(&proftime, NULL);\ |
b75ec364cecc
Fix conflict between name of proviling variable and time function in C stdlib
Mike Pavone <pavone@retrodev.com>
parents:
142
diff
changeset
|
47 my_cdata->self_accum += ((uint64_t)proftime.tv_sec) * 1000000ULL + ((uint64_t)proftime.tv_usec) - my_cdata->self_start; |
105
43cc42df26cc
Various compiler improvements
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
48 |
43cc42df26cc
Various compiler improvements
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
49 #define AND_TOTAL \ |
116 | 50 *(my_cdata->myactivationlevel)--;\ |
151
b75ec364cecc
Fix conflict between name of proviling variable and time function in C stdlib
Mike Pavone <pavone@retrodev.com>
parents:
142
diff
changeset
|
51 my_cdata->accum += ((uint64_t)proftime.tv_sec) * 1000000ULL + ((uint64_t)proftime.tv_usec) - my_cdata->start; |
105
43cc42df26cc
Various compiler improvements
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
52 |
43cc42df26cc
Various compiler improvements
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
53 #define RESUME_SELF \ |
151
b75ec364cecc
Fix conflict between name of proviling variable and time function in C stdlib
Mike Pavone <pavone@retrodev.com>
parents:
142
diff
changeset
|
54 gettimeofday(&proftime, NULL);\ |
b75ec364cecc
Fix conflict between name of proviling variable and time function in C stdlib
Mike Pavone <pavone@retrodev.com>
parents:
142
diff
changeset
|
55 my_cdata->self_start = ((uint64_t)proftime.tv_sec) * 1000000ULL + ((uint64_t)proftime.tv_usec); |
105
43cc42df26cc
Various compiler improvements
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
56 |
116 | 57 #define AND_RESUME_TOTAL \ |
58 *(my_cdata->myactivationlevel)++;\ | |
59 my_cdata->start = my_cdata->self_start; | |
105
43cc42df26cc
Various compiler improvements
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
60 |
43cc42df26cc
Various compiler improvements
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
61 #define EndFunc(name) \ |
43cc42df26cc
Various compiler improvements
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
62 free_stack(ct, lv_ ## name);\ |
43cc42df26cc
Various compiler improvements
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
63 func = cdata->func;\ |
116 | 64 profile_activationlevel[FUNC_ ## name]--;\ |
151
b75ec364cecc
Fix conflict between name of proviling variable and time function in C stdlib
Mike Pavone <pavone@retrodev.com>
parents:
142
diff
changeset
|
65 gettimeofday(&proftime, NULL);\ |
116 | 66 if(profile_activationlevel[FUNC_ ## name])\ |
67 {\ | |
68 profile_nestedcounts[FUNC_ ## name]++;\ | |
69 } else {\ | |
70 profile_counts[FUNC_ ## name]++;\ | |
151
b75ec364cecc
Fix conflict between name of proviling variable and time function in C stdlib
Mike Pavone <pavone@retrodev.com>
parents:
142
diff
changeset
|
71 profile_totals[FUNC_ ## name] += ((uint64_t)proftime.tv_sec) * 1000000ULL + ((uint64_t)proftime.tv_usec) - cdata->start + cdata->accum;\ |
116 | 72 }\ |
151
b75ec364cecc
Fix conflict between name of proviling variable and time function in C stdlib
Mike Pavone <pavone@retrodev.com>
parents:
142
diff
changeset
|
73 profile_selftotals[FUNC_ ## name] += ((uint64_t)proftime.tv_sec) * 1000000ULL + ((uint64_t)proftime.tv_usec) - cdata->self_start + cdata->self_accum; |
116 | 74 |
56
d2f9b0a9403d
Initial experiment with goto and switch
Mike Pavone <pavone@retrodev.com>
parents:
35
diff
changeset
|
75 #define Func(name,numparams) \ |
59
4f1ae6eb71d8
Use replicated switch statement for returns and late-bound calls
Mike Pavone <pavone@retrodev.com>
parents:
58
diff
changeset
|
76 f_ ## name:\ |
57
2174878a6e4b
Avoid unnecessary nested switch
Mike Pavone <pavone@retrodev.com>
parents:
56
diff
changeset
|
77 for(idx = numparams; idx < cdata->num_params; ++idx)\ |
66
d4b44ae2e34a
New variant of C backend works now
Mike Pavone <pavone@retrodev.com>
parents:
65
diff
changeset
|
78 release_ref(cdata->params[idx]); cdata->num_params = numparams;\ |
59
4f1ae6eb71d8
Use replicated switch statement for returns and late-bound calls
Mike Pavone <pavone@retrodev.com>
parents:
58
diff
changeset
|
79 sf_ ## name:\ |
116 | 80 profile_activationlevel[FUNC_ ## name]++;\ |
81 cdata->myactivationlevel = &profile_activationlevel[FUNC_ ## name];\ | |
105
43cc42df26cc
Various compiler improvements
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
82 START_PROFILE\ |
66
d4b44ae2e34a
New variant of C backend works now
Mike Pavone <pavone@retrodev.com>
parents:
65
diff
changeset
|
83 lv_ ## name = alloc_stack(ct, sizeof(lt_ ## name));\ |
d4b44ae2e34a
New variant of C backend works now
Mike Pavone <pavone@retrodev.com>
parents:
65
diff
changeset
|
84 my_cdata = cdata; |
56
d2f9b0a9403d
Initial experiment with goto and switch
Mike Pavone <pavone@retrodev.com>
parents:
35
diff
changeset
|
85 |
d2f9b0a9403d
Initial experiment with goto and switch
Mike Pavone <pavone@retrodev.com>
parents:
35
diff
changeset
|
86 #define MethodImpl(name,type_name,mytype_id,numparams) \ |
65
1db811fa4744
Handle native Rhope functions and plain C functions separately as part of move to new C strategy
Mike Pavone <pavone@retrodev.com>
parents:
63
diff
changeset
|
87 f_ ## name ## AT_ ## type_name:\ |
1db811fa4744
Handle native Rhope functions and plain C functions separately as part of move to new C strategy
Mike Pavone <pavone@retrodev.com>
parents:
63
diff
changeset
|
88 sf_ ## name ## AT_ ## type_name:\ |
57
2174878a6e4b
Avoid unnecessary nested switch
Mike Pavone <pavone@retrodev.com>
parents:
56
diff
changeset
|
89 if (cdata->num_params < 1)\ |
66
d4b44ae2e34a
New variant of C backend works now
Mike Pavone <pavone@retrodev.com>
parents:
65
diff
changeset
|
90 {\ |
d4b44ae2e34a
New variant of C backend works now
Mike Pavone <pavone@retrodev.com>
parents:
65
diff
changeset
|
91 cdata = alloc_cdata(ct, cdata, 0);\ |
d4b44ae2e34a
New variant of C backend works now
Mike Pavone <pavone@retrodev.com>
parents:
65
diff
changeset
|
92 cdata->func = FUNC_ ## name ## AT_ ## type_name;\ |
57
2174878a6e4b
Avoid unnecessary nested switch
Mike Pavone <pavone@retrodev.com>
parents:
56
diff
changeset
|
93 goto _exception;\ |
66
d4b44ae2e34a
New variant of C backend works now
Mike Pavone <pavone@retrodev.com>
parents:
65
diff
changeset
|
94 }\ |
57
2174878a6e4b
Avoid unnecessary nested switch
Mike Pavone <pavone@retrodev.com>
parents:
56
diff
changeset
|
95 if(get_blueprint(cdata->params[0])->type_id != mytype_id)\ |
11
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
96 {\ |
57
2174878a6e4b
Avoid unnecessary nested switch
Mike Pavone <pavone@retrodev.com>
parents:
56
diff
changeset
|
97 puts("uh oh, need conversion and that's not implemented yet!");\ |
2174878a6e4b
Avoid unnecessary nested switch
Mike Pavone <pavone@retrodev.com>
parents:
56
diff
changeset
|
98 exit(1);\ |
2174878a6e4b
Avoid unnecessary nested switch
Mike Pavone <pavone@retrodev.com>
parents:
56
diff
changeset
|
99 }\ |
65
1db811fa4744
Handle native Rhope functions and plain C functions separately as part of move to new C strategy
Mike Pavone <pavone@retrodev.com>
parents:
63
diff
changeset
|
100 m_ ## name ## AT_ ## type_name:\ |
116 | 101 profile_activationlevel[FUNC_ ## name ## AT_ ## type_name]++;\ |
102 cdata->myactivationlevel = &profile_activationlevel[FUNC_ ## name ## AT_ ## type_name];\ | |
105
43cc42df26cc
Various compiler improvements
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
103 START_PROFILE\ |
57
2174878a6e4b
Avoid unnecessary nested switch
Mike Pavone <pavone@retrodev.com>
parents:
56
diff
changeset
|
104 for(idx = numparams; idx < cdata->num_params; ++idx)\ |
66
d4b44ae2e34a
New variant of C backend works now
Mike Pavone <pavone@retrodev.com>
parents:
65
diff
changeset
|
105 release_ref(cdata->params[idx]); cdata->num_params = numparams;\ |
d4b44ae2e34a
New variant of C backend works now
Mike Pavone <pavone@retrodev.com>
parents:
65
diff
changeset
|
106 lv_ ## name ## AT_ ## type_name = alloc_stack(ct, sizeof(lt_ ## name ## AT_ ## type_name));\ |
d4b44ae2e34a
New variant of C backend works now
Mike Pavone <pavone@retrodev.com>
parents:
65
diff
changeset
|
107 my_cdata = cdata; |
116 | 108 |
109 #else | |
110 | |
111 #define START_PROFILE | |
112 #define PAUSE_SELF | |
113 #define RESUME_SELF | |
114 #define AND_TOTAL | |
115 #define AND_RESUME_TOTAL | |
116 | |
117 #define EndFunc(name) \ | |
118 free_stack(ct, lv_ ## name);\ | |
119 func = cdata->func; | |
120 | |
121 #define Func(name,numparams) \ | |
122 f_ ## name:\ | |
123 for(idx = numparams; idx < cdata->num_params; ++idx)\ | |
124 release_ref(cdata->params[idx]); cdata->num_params = numparams;\ | |
125 sf_ ## name:\ | |
126 lv_ ## name = alloc_stack(ct, sizeof(lt_ ## name));\ | |
127 my_cdata = cdata; | |
128 | |
129 #define MethodImpl(name,type_name,mytype_id,numparams) \ | |
130 f_ ## name ## AT_ ## type_name:\ | |
131 sf_ ## name ## AT_ ## type_name:\ | |
132 if (cdata->num_params < 1)\ | |
133 {\ | |
134 cdata = alloc_cdata(ct, cdata, 0);\ | |
135 cdata->func = FUNC_ ## name ## AT_ ## type_name;\ | |
136 goto _exception;\ | |
137 }\ | |
138 if(get_blueprint(cdata->params[0])->type_id != mytype_id)\ | |
139 {\ | |
168
d2b941f82d74
Fix type of list constants in inference pass and return type of some Array related workers
Mike Pavone <pavone@retrodev.com>
parents:
159
diff
changeset
|
140 printf("uh oh, need conversion from type %d to %s(%d) for %s and that's not implemented yet!\n", get_blueprint(cdata->params[0])->type_id, #type_name, mytype_id, #name);\ |
d2b941f82d74
Fix type of list constants in inference pass and return type of some Array related workers
Mike Pavone <pavone@retrodev.com>
parents:
159
diff
changeset
|
141 goto _exception;\ |
116 | 142 }\ |
143 m_ ## name ## AT_ ## type_name:\ | |
144 for(idx = numparams; idx < cdata->num_params; ++idx)\ | |
145 release_ref(cdata->params[idx]); cdata->num_params = numparams;\ | |
146 lv_ ## name ## AT_ ## type_name = alloc_stack(ct, sizeof(lt_ ## name ## AT_ ## type_name));\ | |
147 my_cdata = cdata; | |
148 | |
149 #endif | |
150 | |
151 #define EndFuncNoLocals \ | |
152 func = cdata->func; | |
153 | |
154 | |
155 #define FuncNoLocals(name,numparams) \ | |
156 f_ ## name:\ | |
157 for(idx = numparams; idx < cdata->num_params; ++idx)\ | |
158 release_ref(cdata->params[idx]); cdata->num_params = numparams;\ | |
159 sf_ ## name:\ | |
160 my_cdata = cdata; | |
56
d2f9b0a9403d
Initial experiment with goto and switch
Mike Pavone <pavone@retrodev.com>
parents:
35
diff
changeset
|
161 |
d2f9b0a9403d
Initial experiment with goto and switch
Mike Pavone <pavone@retrodev.com>
parents:
35
diff
changeset
|
162 |
d2f9b0a9403d
Initial experiment with goto and switch
Mike Pavone <pavone@retrodev.com>
parents:
35
diff
changeset
|
163 #define MethodImplNoLocals(name,type_name,mytype_id,numparams) \ |
65
1db811fa4744
Handle native Rhope functions and plain C functions separately as part of move to new C strategy
Mike Pavone <pavone@retrodev.com>
parents:
63
diff
changeset
|
164 f_ ## name ## AT_ ## type_name:\ |
1db811fa4744
Handle native Rhope functions and plain C functions separately as part of move to new C strategy
Mike Pavone <pavone@retrodev.com>
parents:
63
diff
changeset
|
165 sf_ ## name ## AT_ ## type_name:\ |
57
2174878a6e4b
Avoid unnecessary nested switch
Mike Pavone <pavone@retrodev.com>
parents:
56
diff
changeset
|
166 if (cdata->num_params < 1)\ |
66
d4b44ae2e34a
New variant of C backend works now
Mike Pavone <pavone@retrodev.com>
parents:
65
diff
changeset
|
167 cdata = alloc_cdata(ct, cdata, 0);\ |
d4b44ae2e34a
New variant of C backend works now
Mike Pavone <pavone@retrodev.com>
parents:
65
diff
changeset
|
168 cdata->func = FUNC_ ## name ## AT_ ## type_name;\ |
57
2174878a6e4b
Avoid unnecessary nested switch
Mike Pavone <pavone@retrodev.com>
parents:
56
diff
changeset
|
169 goto _exception;\ |
2174878a6e4b
Avoid unnecessary nested switch
Mike Pavone <pavone@retrodev.com>
parents:
56
diff
changeset
|
170 if(get_blueprint(cdata->params[0])->type_id != mytype_id)\ |
11
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
171 {\ |
57
2174878a6e4b
Avoid unnecessary nested switch
Mike Pavone <pavone@retrodev.com>
parents:
56
diff
changeset
|
172 puts("uh oh, need conversion and that's not implemented yet!");\ |
2174878a6e4b
Avoid unnecessary nested switch
Mike Pavone <pavone@retrodev.com>
parents:
56
diff
changeset
|
173 exit(1);\ |
2174878a6e4b
Avoid unnecessary nested switch
Mike Pavone <pavone@retrodev.com>
parents:
56
diff
changeset
|
174 }\ |
65
1db811fa4744
Handle native Rhope functions and plain C functions separately as part of move to new C strategy
Mike Pavone <pavone@retrodev.com>
parents:
63
diff
changeset
|
175 m_ ## name ## AT_ ## type_name:\ |
57
2174878a6e4b
Avoid unnecessary nested switch
Mike Pavone <pavone@retrodev.com>
parents:
56
diff
changeset
|
176 for(idx = numparams; idx < cdata->num_params; ++idx)\ |
66
d4b44ae2e34a
New variant of C backend works now
Mike Pavone <pavone@retrodev.com>
parents:
65
diff
changeset
|
177 release_ref(cdata->params[idx]); cdata->num_params = numparams;\ |
d4b44ae2e34a
New variant of C backend works now
Mike Pavone <pavone@retrodev.com>
parents:
65
diff
changeset
|
178 my_cdata = cdata; |
105
43cc42df26cc
Various compiler improvements
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
179 |
43cc42df26cc
Various compiler improvements
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
180 |
43cc42df26cc
Various compiler improvements
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
181 #define Method(name) \ |
43cc42df26cc
Various compiler improvements
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
182 f_ ## name:\ |
43cc42df26cc
Various compiler improvements
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
183 sf_ ## name:\ |
43cc42df26cc
Various compiler improvements
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
184 switch(get_blueprint(cdata->params[0])->type_id)\ |
43cc42df26cc
Various compiler improvements
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
185 { |
43cc42df26cc
Various compiler improvements
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
186 |
128
5eedee9063dc
Print type name in error message for a missing method
Mike Pavone <pavone@retrodev.com>
parents:
116
diff
changeset
|
187 #define EndMethod(mname) \ |
105
43cc42df26cc
Various compiler improvements
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
188 default:\ |
128
5eedee9063dc
Print type name in error message for a missing method
Mike Pavone <pavone@retrodev.com>
parents:
116
diff
changeset
|
189 printf("Type ");\ |
5eedee9063dc
Print type name in error message for a missing method
Mike Pavone <pavone@retrodev.com>
parents:
116
diff
changeset
|
190 fwrite( ((t_Array *)((t_String *)get_blueprint(cdata->params[0])->name)->payload.Buffer)+1, 1, ((t_Array *)((t_String *)get_blueprint(cdata->params[0])->name)->payload.Buffer)->payload.Length, stdout);\ |
5eedee9063dc
Print type name in error message for a missing method
Mike Pavone <pavone@retrodev.com>
parents:
116
diff
changeset
|
191 printf("(%d) does not implement method %s\n", get_blueprint(cdata->params[0])->type_id, #mname);\ |
105
43cc42df26cc
Various compiler improvements
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
192 cdata = alloc_cdata(ct, cdata, 0);\ |
128
5eedee9063dc
Print type name in error message for a missing method
Mike Pavone <pavone@retrodev.com>
parents:
116
diff
changeset
|
193 cdata->func = FUNC_ ## mname;\ |
105
43cc42df26cc
Various compiler improvements
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
194 goto _exception;\ |
43cc42df26cc
Various compiler improvements
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
195 } |
43cc42df26cc
Various compiler improvements
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
196 |
43cc42df26cc
Various compiler improvements
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
197 |
43cc42df26cc
Various compiler improvements
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
198 #define MethodDispatch(type_id,name,type_name) \ |
43cc42df26cc
Various compiler improvements
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
199 case type_id:\ |
43cc42df26cc
Various compiler improvements
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
200 goto m_ ## name ## AT_ ## type_name; |
56
d2f9b0a9403d
Initial experiment with goto and switch
Mike Pavone <pavone@retrodev.com>
parents:
35
diff
changeset
|
201 |
11
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
202 #define NumParams |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
203 #define CallSpace |
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
204 |
12
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
205 #define Param(num,convtypeid) \ |
66
d4b44ae2e34a
New variant of C backend works now
Mike Pavone <pavone@retrodev.com>
parents:
65
diff
changeset
|
206 if(get_blueprint(cdata->params[num])->type_id != convtypeid)\ |
11
3021dac0d8f5
Stack unwind is so close I can almost taste it
Mike Pavone <pavone@retrodev.com>
parents:
9
diff
changeset
|
207 {\ |
75
0083b2f7b3c7
Partially working implementation of List. Modified build scripts to allow use of other compilers. Fixed some bugs involving method implementations on different types returning different numbers of outputs. Added Fold to the 'builtins' in the comipler.
Mike Pavone <pavone@retrodev.com>
parents:
74
diff
changeset
|
208 printf("uh oh, need conversion from type %d to type %d for param %d and that's not implemented yet!", get_blueprint(cdata->params[num])->type_id, convtypeid, num);\ |
0083b2f7b3c7
Partially working implementation of List. Modified build scripts to allow use of other compilers. Fixed some bugs involving method implementations on different types returning different numbers of outputs. Added Fold to the 'builtins' in the comipler.
Mike Pavone <pavone@retrodev.com>
parents:
74
diff
changeset
|
209 goto _exception;\ |
56
d2f9b0a9403d
Initial experiment with goto and switch
Mike Pavone <pavone@retrodev.com>
parents:
35
diff
changeset
|
210 } |
8
8d74ef7fa357
Improved helper macros and added separate Rhope stack in runtime
Mike Pavone <pavone@retrodev.com>
parents:
7
diff
changeset
|
211 |
12
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
212 #define CopiedParam(num,convtypeid) Param(num,convtypeid) cdata->params[num] = copy_object(cdata->params[num]); |
66
d4b44ae2e34a
New variant of C backend works now
Mike Pavone <pavone@retrodev.com>
parents:
65
diff
changeset
|
213 #define Ret(num,val) cdata->params[num] = (object *)(val); |
101
f4fc0a98088a
Fixed some bugs that were preventing compiled compiler from working correctly. Need to address memory usage
Mike Pavone <pavone@retrodev.com>
parents:
100
diff
changeset
|
214 #define NumRet(num) cdata->num_params = num;\ |
f4fc0a98088a
Fixed some bugs that were preventing compiled compiler from working correctly. Need to address memory usage
Mike Pavone <pavone@retrodev.com>
parents:
100
diff
changeset
|
215 if (num == 1 && !cdata->params[0])\ |
f4fc0a98088a
Fixed some bugs that were preventing compiled compiler from working correctly. Need to address memory usage
Mike Pavone <pavone@retrodev.com>
parents:
100
diff
changeset
|
216 {\ |
f4fc0a98088a
Fixed some bugs that were preventing compiled compiler from working correctly. Need to address memory usage
Mike Pavone <pavone@retrodev.com>
parents:
100
diff
changeset
|
217 puts("Worker with only one output failed to produce data for that output!");\ |
f4fc0a98088a
Fixed some bugs that were preventing compiled compiler from working correctly. Need to address memory usage
Mike Pavone <pavone@retrodev.com>
parents:
100
diff
changeset
|
218 goto _exception;\ |
f4fc0a98088a
Fixed some bugs that were preventing compiled compiler from working correctly. Need to address memory usage
Mike Pavone <pavone@retrodev.com>
parents:
100
diff
changeset
|
219 } |
7
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
220 #define Exception |
56
d2f9b0a9403d
Initial experiment with goto and switch
Mike Pavone <pavone@retrodev.com>
parents:
35
diff
changeset
|
221 #define FuncDef(name) lt_ ## name * lv_ ## name; |
65
1db811fa4744
Handle native Rhope functions and plain C functions separately as part of move to new C strategy
Mike Pavone <pavone@retrodev.com>
parents:
63
diff
changeset
|
222 #define MethodDef(name) lt_ ## name ## AT_ ## type_name * lv_ ## name ## AT_ ## type_name; |
56
d2f9b0a9403d
Initial experiment with goto and switch
Mike Pavone <pavone@retrodev.com>
parents:
35
diff
changeset
|
223 |
d2f9b0a9403d
Initial experiment with goto and switch
Mike Pavone <pavone@retrodev.com>
parents:
35
diff
changeset
|
224 |
d2f9b0a9403d
Initial experiment with goto and switch
Mike Pavone <pavone@retrodev.com>
parents:
35
diff
changeset
|
225 #define PrepCall(callspace) cdata = alloc_cdata(ct, cdata, callspace); |
7
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
226 |
100
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
85
diff
changeset
|
227 #define SetParam(num,value) cdata->params[num] = value; |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
85
diff
changeset
|
228 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
85
diff
changeset
|
229 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
85
diff
changeset
|
230 #define VCRePrepCall(func,numparams,lastnumparams) \ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
85
diff
changeset
|
231 if(numparams + ((t_Worker *)func)->payload.Count > lastnumparams)\ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
85
diff
changeset
|
232 {\ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
85
diff
changeset
|
233 temp_cdata = cdata->lastframe;\ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
85
diff
changeset
|
234 free_stack(ct, cdata);\ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
85
diff
changeset
|
235 cdata = alloc_cdata(ct, temp_cdata, numparams + ((t_Worker *)func)->payload.Count);\ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
85
diff
changeset
|
236 }\ |
159
d1e206ff75f9
Fix some bugs involving calling a worker object
Mike Pavone <pavone@retrodev.com>
parents:
151
diff
changeset
|
237 vcparam_offset = 0;\ |
d1e206ff75f9
Fix some bugs involving calling a worker object
Mike Pavone <pavone@retrodev.com>
parents:
151
diff
changeset
|
238 last_vcparam = -1; |
100
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
85
diff
changeset
|
239 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
85
diff
changeset
|
240 #define VCPrepCall(func,numparams) \ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
85
diff
changeset
|
241 cdata = alloc_cdata(ct, cdata, numparams + ((t_Worker *)func)->payload.Count);\ |
159
d1e206ff75f9
Fix some bugs involving calling a worker object
Mike Pavone <pavone@retrodev.com>
parents:
151
diff
changeset
|
242 vcparam_offset = 0;\ |
d1e206ff75f9
Fix some bugs involving calling a worker object
Mike Pavone <pavone@retrodev.com>
parents:
151
diff
changeset
|
243 last_vcparam = -1; |
100
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
85
diff
changeset
|
244 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
85
diff
changeset
|
245 #define VCSetParam(func,num,value) \ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
85
diff
changeset
|
246 while((num+vcparam_offset) < ((t_Worker *)func)->payload.Size && ((object **)(((t_Worker *)func)+1))[num+vcparam_offset])\ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
85
diff
changeset
|
247 {\ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
85
diff
changeset
|
248 cdata->params[num+vcparam_offset] = add_ref(((object **)(((t_Worker *)func)+1))[num+vcparam_offset]);\ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
85
diff
changeset
|
249 ++vcparam_offset;\ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
85
diff
changeset
|
250 }\ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
85
diff
changeset
|
251 cdata->params[num+vcparam_offset] = value;\ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
85
diff
changeset
|
252 last_vcparam = num+vcparam_offset; |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
85
diff
changeset
|
253 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
85
diff
changeset
|
254 #define ValCall(tocall,numparams,resumeto,myname)\ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
85
diff
changeset
|
255 last_vcparam++;\ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
85
diff
changeset
|
256 while(last_vcparam < ((t_Worker *)tocall)->payload.Size)\ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
85
diff
changeset
|
257 {\ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
85
diff
changeset
|
258 if (((object **)(((t_Worker *)tocall)+1))[last_vcparam]) \ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
85
diff
changeset
|
259 cdata->params[last_vcparam] = add_ref(((object **)(((t_Worker *)tocall)+1))[last_vcparam]);\ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
85
diff
changeset
|
260 ++last_vcparam;\ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
85
diff
changeset
|
261 }\ |
74
a844c623c7df
Add support for Worker type
Mike Pavone <pavone@retrodev.com>
parents:
71
diff
changeset
|
262 cdata->func = RES_ ## resumeto ## _ ## myname;\ |
100
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
85
diff
changeset
|
263 cdata->num_params = numparams + ((t_Worker *)tocall)->payload.Count;\ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
85
diff
changeset
|
264 cdata->vars = lv_ ## myname;\ |
105
43cc42df26cc
Various compiler improvements
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
265 func = ((t_Worker *)tocall)->payload.Index;\ |
43cc42df26cc
Various compiler improvements
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
266 PAUSE_SELF |
100
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
85
diff
changeset
|
267 |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
85
diff
changeset
|
268 #define ValCallPostlude(resumeto,myname)\ |
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
85
diff
changeset
|
269 r ## resumeto ## _ ## myname:\ |
74
a844c623c7df
Add support for Worker type
Mike Pavone <pavone@retrodev.com>
parents:
71
diff
changeset
|
270 my_cdata = cdata->lastframe;\ |
105
43cc42df26cc
Various compiler improvements
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
271 RESUME_SELF\ |
100
f51c4c17457c
Broken port of parser to compiler
Mike Pavone <pavone@retrodev.com>
parents:
85
diff
changeset
|
272 lv_ ## myname = cdata->vars; |
141
f2cb85c53ced
Fix Pause/Resume and rewrite Call Async in Rhope rather than C
Mike Pavone <pavone@retrodev.com>
parents:
140
diff
changeset
|
273 |
f2cb85c53ced
Fix Pause/Resume and rewrite Call Async in Rhope rather than C
Mike Pavone <pavone@retrodev.com>
parents:
140
diff
changeset
|
274 #define ValCallNoLocals(tocall,numparams,resumeto,myname)\ |
f2cb85c53ced
Fix Pause/Resume and rewrite Call Async in Rhope rather than C
Mike Pavone <pavone@retrodev.com>
parents:
140
diff
changeset
|
275 last_vcparam++;\ |
f2cb85c53ced
Fix Pause/Resume and rewrite Call Async in Rhope rather than C
Mike Pavone <pavone@retrodev.com>
parents:
140
diff
changeset
|
276 while(last_vcparam < ((t_Worker *)tocall)->payload.Size)\ |
f2cb85c53ced
Fix Pause/Resume and rewrite Call Async in Rhope rather than C
Mike Pavone <pavone@retrodev.com>
parents:
140
diff
changeset
|
277 {\ |
f2cb85c53ced
Fix Pause/Resume and rewrite Call Async in Rhope rather than C
Mike Pavone <pavone@retrodev.com>
parents:
140
diff
changeset
|
278 if (((object **)(((t_Worker *)tocall)+1))[last_vcparam]) \ |
f2cb85c53ced
Fix Pause/Resume and rewrite Call Async in Rhope rather than C
Mike Pavone <pavone@retrodev.com>
parents:
140
diff
changeset
|
279 cdata->params[last_vcparam] = add_ref(((object **)(((t_Worker *)tocall)+1))[last_vcparam]);\ |
f2cb85c53ced
Fix Pause/Resume and rewrite Call Async in Rhope rather than C
Mike Pavone <pavone@retrodev.com>
parents:
140
diff
changeset
|
280 ++last_vcparam;\ |
f2cb85c53ced
Fix Pause/Resume and rewrite Call Async in Rhope rather than C
Mike Pavone <pavone@retrodev.com>
parents:
140
diff
changeset
|
281 }\ |
f2cb85c53ced
Fix Pause/Resume and rewrite Call Async in Rhope rather than C
Mike Pavone <pavone@retrodev.com>
parents:
140
diff
changeset
|
282 cdata->func = RES_ ## resumeto ## _ ## myname;\ |
f2cb85c53ced
Fix Pause/Resume and rewrite Call Async in Rhope rather than C
Mike Pavone <pavone@retrodev.com>
parents:
140
diff
changeset
|
283 cdata->num_params = numparams + ((t_Worker *)tocall)->payload.Count;\ |
f2cb85c53ced
Fix Pause/Resume and rewrite Call Async in Rhope rather than C
Mike Pavone <pavone@retrodev.com>
parents:
140
diff
changeset
|
284 func = ((t_Worker *)tocall)->payload.Index;\ |
f2cb85c53ced
Fix Pause/Resume and rewrite Call Async in Rhope rather than C
Mike Pavone <pavone@retrodev.com>
parents:
140
diff
changeset
|
285 PAUSE_SELF |
f2cb85c53ced
Fix Pause/Resume and rewrite Call Async in Rhope rather than C
Mike Pavone <pavone@retrodev.com>
parents:
140
diff
changeset
|
286 |
f2cb85c53ced
Fix Pause/Resume and rewrite Call Async in Rhope rather than C
Mike Pavone <pavone@retrodev.com>
parents:
140
diff
changeset
|
287 #define ValCallNoLocalsPostlude(resumeto,myname)\ |
f2cb85c53ced
Fix Pause/Resume and rewrite Call Async in Rhope rather than C
Mike Pavone <pavone@retrodev.com>
parents:
140
diff
changeset
|
288 r ## resumeto ## _ ## myname:\ |
f2cb85c53ced
Fix Pause/Resume and rewrite Call Async in Rhope rather than C
Mike Pavone <pavone@retrodev.com>
parents:
140
diff
changeset
|
289 my_cdata = cdata->lastframe;\ |
f2cb85c53ced
Fix Pause/Resume and rewrite Call Async in Rhope rather than C
Mike Pavone <pavone@retrodev.com>
parents:
140
diff
changeset
|
290 RESUME_SELF |
74
a844c623c7df
Add support for Worker type
Mike Pavone <pavone@retrodev.com>
parents:
71
diff
changeset
|
291 |
142
7bbdc034e347
Fix some bugs. Get basic network code working (epoll listener + accept connections). Start porting webserver.
Mike Pavone <pavone@retrodev.com>
parents:
141
diff
changeset
|
292 #define CallNoLocals(tocall, numparams, resumeto, myname)\ |
7bbdc034e347
Fix some bugs. Get basic network code working (epoll listener + accept connections). Start porting webserver.
Mike Pavone <pavone@retrodev.com>
parents:
141
diff
changeset
|
293 cdata->func = RES_ ## resumeto ## _ ## myname;\ |
7bbdc034e347
Fix some bugs. Get basic network code working (epoll listener + accept connections). Start porting webserver.
Mike Pavone <pavone@retrodev.com>
parents:
141
diff
changeset
|
294 cdata->num_params = numparams;\ |
7bbdc034e347
Fix some bugs. Get basic network code working (epoll listener + accept connections). Start porting webserver.
Mike Pavone <pavone@retrodev.com>
parents:
141
diff
changeset
|
295 if(FUNC_ ## tocall == FUNC_ ## myname) {\ |
7bbdc034e347
Fix some bugs. Get basic network code working (epoll listener + accept connections). Start porting webserver.
Mike Pavone <pavone@retrodev.com>
parents:
141
diff
changeset
|
296 PAUSE_SELF\ |
7bbdc034e347
Fix some bugs. Get basic network code working (epoll listener + accept connections). Start porting webserver.
Mike Pavone <pavone@retrodev.com>
parents:
141
diff
changeset
|
297 AND_TOTAL\ |
7bbdc034e347
Fix some bugs. Get basic network code working (epoll listener + accept connections). Start porting webserver.
Mike Pavone <pavone@retrodev.com>
parents:
141
diff
changeset
|
298 } else if (FUNC_ ## tocall != FUNC_PL_ && FUNC_ ## tocall != FUNC_MN_ && FUNC_ ## tocall != FUNC_TM_ && FUNC_ ## tocall != FUNC_DV_ && FUNC_ ## tocall != FUNC_If) {\ |
7bbdc034e347
Fix some bugs. Get basic network code working (epoll listener + accept connections). Start porting webserver.
Mike Pavone <pavone@retrodev.com>
parents:
141
diff
changeset
|
299 PAUSE_SELF\ |
7bbdc034e347
Fix some bugs. Get basic network code working (epoll listener + accept connections). Start porting webserver.
Mike Pavone <pavone@retrodev.com>
parents:
141
diff
changeset
|
300 }\ |
7bbdc034e347
Fix some bugs. Get basic network code working (epoll listener + accept connections). Start porting webserver.
Mike Pavone <pavone@retrodev.com>
parents:
141
diff
changeset
|
301 goto sf_ ## tocall;\ |
7bbdc034e347
Fix some bugs. Get basic network code working (epoll listener + accept connections). Start porting webserver.
Mike Pavone <pavone@retrodev.com>
parents:
141
diff
changeset
|
302 r ## resumeto ## _ ## myname:\ |
7bbdc034e347
Fix some bugs. Get basic network code working (epoll listener + accept connections). Start porting webserver.
Mike Pavone <pavone@retrodev.com>
parents:
141
diff
changeset
|
303 my_cdata = cdata->lastframe;\ |
7bbdc034e347
Fix some bugs. Get basic network code working (epoll listener + accept connections). Start porting webserver.
Mike Pavone <pavone@retrodev.com>
parents:
141
diff
changeset
|
304 if(FUNC_ ## tocall == FUNC_ ## myname) {\ |
7bbdc034e347
Fix some bugs. Get basic network code working (epoll listener + accept connections). Start porting webserver.
Mike Pavone <pavone@retrodev.com>
parents:
141
diff
changeset
|
305 RESUME_SELF\ |
7bbdc034e347
Fix some bugs. Get basic network code working (epoll listener + accept connections). Start porting webserver.
Mike Pavone <pavone@retrodev.com>
parents:
141
diff
changeset
|
306 AND_RESUME_TOTAL\ |
7bbdc034e347
Fix some bugs. Get basic network code working (epoll listener + accept connections). Start porting webserver.
Mike Pavone <pavone@retrodev.com>
parents:
141
diff
changeset
|
307 } else if (FUNC_ ## tocall != FUNC_PL_ && FUNC_ ## tocall != FUNC_MN_ && FUNC_ ## tocall != FUNC_TM_ && FUNC_ ## tocall != FUNC_DV_ && FUNC_ ## tocall != FUNC_If) {\ |
7bbdc034e347
Fix some bugs. Get basic network code working (epoll listener + accept connections). Start porting webserver.
Mike Pavone <pavone@retrodev.com>
parents:
141
diff
changeset
|
308 RESUME_SELF\ |
7bbdc034e347
Fix some bugs. Get basic network code working (epoll listener + accept connections). Start porting webserver.
Mike Pavone <pavone@retrodev.com>
parents:
141
diff
changeset
|
309 } |
56
d2f9b0a9403d
Initial experiment with goto and switch
Mike Pavone <pavone@retrodev.com>
parents:
35
diff
changeset
|
310 |
d2f9b0a9403d
Initial experiment with goto and switch
Mike Pavone <pavone@retrodev.com>
parents:
35
diff
changeset
|
311 #define Call(tocall, numparams, resumeto, myname)\ |
66
d4b44ae2e34a
New variant of C backend works now
Mike Pavone <pavone@retrodev.com>
parents:
65
diff
changeset
|
312 cdata->func = RES_ ## resumeto ## _ ## myname;\ |
57
2174878a6e4b
Avoid unnecessary nested switch
Mike Pavone <pavone@retrodev.com>
parents:
56
diff
changeset
|
313 cdata->num_params = numparams;\ |
71
c40c3d399133
Add Int32@String and Get Char. Fix stack bug
Mike Pavone <pavone@retrodev.com>
parents:
66
diff
changeset
|
314 cdata->vars = lv_ ## myname;\ |
105
43cc42df26cc
Various compiler improvements
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
315 if(FUNC_ ## tocall == FUNC_ ## myname) {\ |
43cc42df26cc
Various compiler improvements
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
316 PAUSE_SELF\ |
43cc42df26cc
Various compiler improvements
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
317 AND_TOTAL\ |
43cc42df26cc
Various compiler improvements
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
318 } else if (FUNC_ ## tocall != FUNC_PL_ && FUNC_ ## tocall != FUNC_MN_ && FUNC_ ## tocall != FUNC_TM_ && FUNC_ ## tocall != FUNC_DV_ && FUNC_ ## tocall != FUNC_If) {\ |
43cc42df26cc
Various compiler improvements
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
319 PAUSE_SELF\ |
43cc42df26cc
Various compiler improvements
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
320 }\ |
59
4f1ae6eb71d8
Use replicated switch statement for returns and late-bound calls
Mike Pavone <pavone@retrodev.com>
parents:
58
diff
changeset
|
321 goto sf_ ## tocall;\ |
4f1ae6eb71d8
Use replicated switch statement for returns and late-bound calls
Mike Pavone <pavone@retrodev.com>
parents:
58
diff
changeset
|
322 r ## resumeto ## _ ## myname:\ |
66
d4b44ae2e34a
New variant of C backend works now
Mike Pavone <pavone@retrodev.com>
parents:
65
diff
changeset
|
323 my_cdata = cdata->lastframe;\ |
105
43cc42df26cc
Various compiler improvements
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
324 if(FUNC_ ## tocall == FUNC_ ## myname) {\ |
43cc42df26cc
Various compiler improvements
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
325 RESUME_SELF\ |
43cc42df26cc
Various compiler improvements
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
326 AND_RESUME_TOTAL\ |
43cc42df26cc
Various compiler improvements
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
327 } else if (FUNC_ ## tocall != FUNC_PL_ && FUNC_ ## tocall != FUNC_MN_ && FUNC_ ## tocall != FUNC_TM_ && FUNC_ ## tocall != FUNC_DV_ && FUNC_ ## tocall != FUNC_If) {\ |
43cc42df26cc
Various compiler improvements
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
328 RESUME_SELF\ |
43cc42df26cc
Various compiler improvements
Mike Pavone <pavone@retrodev.com>
parents:
101
diff
changeset
|
329 }\ |
71
c40c3d399133
Add Int32@String and Get Char. Fix stack bug
Mike Pavone <pavone@retrodev.com>
parents:
66
diff
changeset
|
330 lv_ ## myname = cdata->vars; |
66
d4b44ae2e34a
New variant of C backend works now
Mike Pavone <pavone@retrodev.com>
parents:
65
diff
changeset
|
331 |
35
3498713c3dc9
C backend portion of supporting user defined types is done, but untested. Parser/NWorker still need a fair bit of work
Mike Pavone <pavone@retrodev.com>
parents:
12
diff
changeset
|
332 |
56
d2f9b0a9403d
Initial experiment with goto and switch
Mike Pavone <pavone@retrodev.com>
parents:
35
diff
changeset
|
333 #define FreeCall\ |
57
2174878a6e4b
Avoid unnecessary nested switch
Mike Pavone <pavone@retrodev.com>
parents:
56
diff
changeset
|
334 temp_cdata = cdata->lastframe;\ |
2174878a6e4b
Avoid unnecessary nested switch
Mike Pavone <pavone@retrodev.com>
parents:
56
diff
changeset
|
335 free_stack(ct, cdata);\ |
2174878a6e4b
Avoid unnecessary nested switch
Mike Pavone <pavone@retrodev.com>
parents:
56
diff
changeset
|
336 cdata = temp_cdata; |
7
d61550e2c001
Added current work on new runtime
Mike Pavone <pavone@retrodev.com>
parents:
diff
changeset
|
337 |
56
d2f9b0a9403d
Initial experiment with goto and switch
Mike Pavone <pavone@retrodev.com>
parents:
35
diff
changeset
|
338 #define FreeCallMethod(myname,mytype)\ |
57
2174878a6e4b
Avoid unnecessary nested switch
Mike Pavone <pavone@retrodev.com>
parents:
56
diff
changeset
|
339 temp_cdata = cdata->lastframe;\ |
2174878a6e4b
Avoid unnecessary nested switch
Mike Pavone <pavone@retrodev.com>
parents:
56
diff
changeset
|
340 free_stack(ct, cdata);\ |
2174878a6e4b
Avoid unnecessary nested switch
Mike Pavone <pavone@retrodev.com>
parents:
56
diff
changeset
|
341 cdata = temp_cdata;\ |
65
1db811fa4744
Handle native Rhope functions and plain C functions separately as part of move to new C strategy
Mike Pavone <pavone@retrodev.com>
parents:
63
diff
changeset
|
342 lv_ ## myname ## AT_ ## type_name = (lt_ ## myname ## AT_ ## type_name *)(cdata+1); |
61
fa24ef3b026f
Added macro for tail calls with new C strategy
Mike Pavone <pavone@retrodev.com>
parents:
59
diff
changeset
|
343 |
fa24ef3b026f
Added macro for tail calls with new C strategy
Mike Pavone <pavone@retrodev.com>
parents:
59
diff
changeset
|
344 #define TPrepCall(callspace) \ |
fa24ef3b026f
Added macro for tail calls with new C strategy
Mike Pavone <pavone@retrodev.com>
parents:
59
diff
changeset
|
345 func = cdata->lastframe->func;\ |
fa24ef3b026f
Added macro for tail calls with new C strategy
Mike Pavone <pavone@retrodev.com>
parents:
59
diff
changeset
|
346 temp_cdata = cdata->lastframe->lastframe;\ |
fa24ef3b026f
Added macro for tail calls with new C strategy
Mike Pavone <pavone@retrodev.com>
parents:
59
diff
changeset
|
347 free_stack(ct, cdata->lastframe);\ |
fa24ef3b026f
Added macro for tail calls with new C strategy
Mike Pavone <pavone@retrodev.com>
parents:
59
diff
changeset
|
348 cdata = alloc_cdata(ct, temp_cdata, callspace);\ |
fa24ef3b026f
Added macro for tail calls with new C strategy
Mike Pavone <pavone@retrodev.com>
parents:
59
diff
changeset
|
349 cdata->func = func; |
fa24ef3b026f
Added macro for tail calls with new C strategy
Mike Pavone <pavone@retrodev.com>
parents:
59
diff
changeset
|
350 |
fa24ef3b026f
Added macro for tail calls with new C strategy
Mike Pavone <pavone@retrodev.com>
parents:
59
diff
changeset
|
351 #define TCall(tocall, numparams)\ |
fa24ef3b026f
Added macro for tail calls with new C strategy
Mike Pavone <pavone@retrodev.com>
parents:
59
diff
changeset
|
352 cdata->num_params = numparams;\ |
fa24ef3b026f
Added macro for tail calls with new C strategy
Mike Pavone <pavone@retrodev.com>
parents:
59
diff
changeset
|
353 goto sf_ ## tocall; |
12
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
354 |
31f8182f3433
Finished fib test and did some small work on the c backend
Mike Pavone <pavone@retrodev.com>
parents:
11
diff
changeset
|
355 |
66
d4b44ae2e34a
New variant of C backend works now
Mike Pavone <pavone@retrodev.com>
parents:
65
diff
changeset
|
356 #endif //_FUNC_H_ |