5fa7c2e4003a152a9aeaf6a1605c759776d5dc03
[nit.git] / c_src / sorter._sep.c
1 /* This C file is generated by NIT to compile module sorter. */
2 #include "sorter._sep.h"
3 val_t sorter___AbstractSorter___compare(val_t self, val_t param0, val_t param1) {
4 struct trace_t trace = {NULL, NULL, 22, LOCATE_sorter___AbstractSorter___compare};
5 trace.prev = tracehead; tracehead = &trace;
6 trace.file = LOCATE_sorter;
7 fprintf(stderr, "Deferred method %s called");
8 fprintf(stderr, " (%s:%d)\n", LOCATE_sorter, 22);
9 nit_exit(1);
10 tracehead = trace.prev;
11 return NIT_NULL;
12 }
13 void sorter___AbstractSorter___sort(val_t self, val_t param0) {
14 struct trace_t trace = {NULL, NULL, 29, LOCATE_sorter___AbstractSorter___sort};
15 val_t variable0;
16 val_t variable1;
17 trace.prev = tracehead; tracehead = &trace;
18 trace.file = LOCATE_sorter;
19 variable0 = param0;
20 variable1 = ((array___AbstractArray___length_t)CALL( variable0 /*array*/,COLOR_abstract_collection___Collection___length))( variable0 /*array*/) /*AbstractArray::length*/;
21 variable1 = TAG_Int(UNTAG_Int(variable1)-UNTAG_Int( TAG_Int(1)));
22 ((sorter___AbstractSorter___sub_sort_t)CALL( self,COLOR_sorter___AbstractSorter___sub_sort))( self, variable0 /*array*/, TAG_Int(0), variable1) /*AbstractSorter::sub_sort*/;
23 tracehead = trace.prev;
24 return;
25 }
26 void sorter___AbstractSorter___sub_sort(val_t self, val_t param0, val_t param1, val_t param2) {
27 struct trace_t trace = {NULL, NULL, 32, LOCATE_sorter___AbstractSorter___sub_sort};
28 val_t variable0;
29 val_t variable1;
30 val_t variable2;
31 val_t variable3;
32 trace.prev = tracehead; tracehead = &trace;
33 trace.file = LOCATE_sorter;
34 variable0 = param0;
35 variable1 = param1;
36 variable2 = param2;
37 variable3 = TAG_Bool(UNTAG_Int( variable1 /*from*/)>=UNTAG_Int( variable2 /*to*/));
38 if (UNTAG_Bool(variable3)) { /*if*/
39 goto return_label1;
40 } else { /*if*/
41 variable3 = TAG_Int(UNTAG_Int( variable1 /*from*/)+UNTAG_Int( TAG_Int(7)));
42 variable3 = TAG_Bool(UNTAG_Int(variable3)<UNTAG_Int( variable2 /*to*/));
43 if (UNTAG_Bool(variable3)) { /*if*/
44 ((sorter___AbstractSorter___quick_sort_t)CALL( self,COLOR_sorter___AbstractSorter___quick_sort))( self, variable0 /*array*/, variable1 /*from*/, variable2 /*to*/) /*AbstractSorter::quick_sort*/;
45 } else { /*if*/
46 ((sorter___AbstractSorter___bubble_sort_t)CALL( self,COLOR_sorter___AbstractSorter___bubble_sort))( self, variable0 /*array*/, variable1 /*from*/, variable2 /*to*/) /*AbstractSorter::bubble_sort*/;
47 }
48 }
49 return_label1: while(false);
50 tracehead = trace.prev;
51 return;
52 }
53 void sorter___AbstractSorter___quick_sort(val_t self, val_t param0, val_t param1, val_t param2) {
54 struct trace_t trace = {NULL, NULL, 44, LOCATE_sorter___AbstractSorter___quick_sort};
55 val_t variable0;
56 val_t variable1;
57 val_t variable2;
58 val_t variable3;
59 val_t variable4;
60 val_t variable5;
61 val_t variable6;
62 val_t variable7;
63 val_t variable8;
64 val_t variable9;
65 trace.prev = tracehead; tracehead = &trace;
66 trace.file = LOCATE_sorter;
67 variable0 = param0;
68 variable1 = param1;
69 variable2 = param2;
70 variable4 = variable1 /*from*/;
71 variable5 = TAG_Bool(UNTAG_Int( variable4 /*index*/)>=UNTAG_Int( TAG_Int(0)));
72 variable6 = variable5;
73 if (UNTAG_Bool(variable6)) { /* and */
74 variable6 = ATTR_array___AbstractArray____length( variable0 /*array*/) /*AbstractArray::_length*/;
75 variable6 = TAG_Bool(UNTAG_Int( variable4 /*index*/)<UNTAG_Int(variable6));
76 }
77 variable5 = variable6;
78 if (!UNTAG_Bool(variable5)) { fprintf(stderr, "Assert%s failed", " 'index' "); fprintf(stderr, " in %s (%s:%d)\n", LOCATE_array___Array_____bra, LOCATE_sorter, 229); nit_exit(1);}
79 variable5 = ATTR_array___Array____items( variable0 /*array*/) /*Array::_items*/;
80 variable5 = UNBOX_NativeArray(variable5)[UNTAG_Int( variable4 /*index*/)];
81 goto return_label3;
82 return_label3: while(false);
83 variable4 = variable5;
84 variable3 = variable4;
85 variable4 = variable1 /*from*/;
86 variable5 = variable2 /*to*/;
87 while (true) { /*while*/
88 variable6 = TAG_Bool(UNTAG_Int( variable5 /*j*/)>UNTAG_Int( variable4 /*i*/));
89 if (!UNTAG_Bool(variable6)) break; /* while*/
90 while (true) { /*while*/
91 variable6 = TAG_Bool(UNTAG_Int( variable4 /*i*/)<=UNTAG_Int( variable2 /*to*/));
92 variable7 = variable6;
93 if (UNTAG_Bool(variable7)) { /* and */
94 variable7 = variable4 /*i*/;
95 variable8 = TAG_Bool(UNTAG_Int( variable7 /*index*/)>=UNTAG_Int( TAG_Int(0)));
96 variable9 = variable8;
97 if (UNTAG_Bool(variable9)) { /* and */
98 variable9 = ATTR_array___AbstractArray____length( variable0 /*array*/) /*AbstractArray::_length*/;
99 variable9 = TAG_Bool(UNTAG_Int( variable7 /*index*/)<UNTAG_Int(variable9));
100 }
101 variable8 = variable9;
102 if (!UNTAG_Bool(variable8)) { fprintf(stderr, "Assert%s failed", " 'index' "); fprintf(stderr, " in %s (%s:%d)\n", LOCATE_array___Array_____bra, LOCATE_sorter, 229); nit_exit(1);}
103 variable8 = ATTR_array___Array____items( variable0 /*array*/) /*Array::_items*/;
104 variable8 = UNBOX_NativeArray(variable8)[UNTAG_Int( variable7 /*index*/)];
105 goto return_label6;
106 return_label6: while(false);
107 variable7 = variable8;
108 variable7 = ((sorter___AbstractSorter___compare_t)CALL( self,COLOR_sorter___AbstractSorter___compare))( self, variable7, variable3 /*pivot*/) /*AbstractSorter::compare*/;
109 variable7 = TAG_Bool(UNTAG_Int(variable7)<=UNTAG_Int( TAG_Int(0)));
110 }
111 variable6 = variable7;
112 if (!UNTAG_Bool(variable6)) break; /* while*/
113 variable4 = TAG_Int(UNTAG_Int(variable4)+UNTAG_Int( TAG_Int(1))) /*i*/;
114 continue_5: while(0);
115 }
116 break_5: while(0);
117 while (true) { /*while*/
118 variable6 = TAG_Bool(UNTAG_Int( variable5 /*j*/)>UNTAG_Int( variable4 /*i*/));
119 variable7 = variable6;
120 if (UNTAG_Bool(variable7)) { /* and */
121 variable7 = variable5 /*j*/;
122 variable8 = TAG_Bool(UNTAG_Int( variable7 /*index*/)>=UNTAG_Int( TAG_Int(0)));
123 variable9 = variable8;
124 if (UNTAG_Bool(variable9)) { /* and */
125 variable9 = ATTR_array___AbstractArray____length( variable0 /*array*/) /*AbstractArray::_length*/;
126 variable9 = TAG_Bool(UNTAG_Int( variable7 /*index*/)<UNTAG_Int(variable9));
127 }
128 variable8 = variable9;
129 if (!UNTAG_Bool(variable8)) { fprintf(stderr, "Assert%s failed", " 'index' "); fprintf(stderr, " in %s (%s:%d)\n", LOCATE_array___Array_____bra, LOCATE_sorter, 229); nit_exit(1);}
130 variable8 = ATTR_array___Array____items( variable0 /*array*/) /*Array::_items*/;
131 variable8 = UNBOX_NativeArray(variable8)[UNTAG_Int( variable7 /*index*/)];
132 goto return_label8;
133 return_label8: while(false);
134 variable7 = variable8;
135 variable7 = ((sorter___AbstractSorter___compare_t)CALL( self,COLOR_sorter___AbstractSorter___compare))( self, variable7, variable3 /*pivot*/) /*AbstractSorter::compare*/;
136 variable7 = TAG_Bool(UNTAG_Int(variable7)>=UNTAG_Int( TAG_Int(0)));
137 }
138 variable6 = variable7;
139 if (!UNTAG_Bool(variable6)) break; /* while*/
140 variable5 = TAG_Int(UNTAG_Int(variable5)-UNTAG_Int( TAG_Int(1))) /*j*/;
141 continue_7: while(0);
142 }
143 break_7: while(0);
144 variable6 = TAG_Bool(UNTAG_Int( variable5 /*j*/)>UNTAG_Int( variable4 /*i*/));
145 if (UNTAG_Bool(variable6)) { /*if*/
146 variable7 = variable4 /*i*/;
147 variable8 = TAG_Bool(UNTAG_Int( variable7 /*index*/)>=UNTAG_Int( TAG_Int(0)));
148 variable9 = variable8;
149 if (UNTAG_Bool(variable9)) { /* and */
150 variable9 = ATTR_array___AbstractArray____length( variable0 /*array*/) /*AbstractArray::_length*/;
151 variable9 = TAG_Bool(UNTAG_Int( variable7 /*index*/)<UNTAG_Int(variable9));
152 }
153 variable8 = variable9;
154 if (!UNTAG_Bool(variable8)) { fprintf(stderr, "Assert%s failed", " 'index' "); fprintf(stderr, " in %s (%s:%d)\n", LOCATE_array___Array_____bra, LOCATE_sorter, 229); nit_exit(1);}
155 variable8 = ATTR_array___Array____items( variable0 /*array*/) /*Array::_items*/;
156 variable8 = UNBOX_NativeArray(variable8)[UNTAG_Int( variable7 /*index*/)];
157 goto return_label9;
158 return_label9: while(false);
159 variable7 = variable8;
160 variable6 = variable7;
161 variable7 = variable5 /*j*/;
162 variable8 = TAG_Bool(UNTAG_Int( variable7 /*index*/)>=UNTAG_Int( TAG_Int(0)));
163 variable9 = variable8;
164 if (UNTAG_Bool(variable9)) { /* and */
165 variable9 = ATTR_array___AbstractArray____length( variable0 /*array*/) /*AbstractArray::_length*/;
166 variable9 = TAG_Bool(UNTAG_Int( variable7 /*index*/)<UNTAG_Int(variable9));
167 }
168 variable8 = variable9;
169 if (!UNTAG_Bool(variable8)) { fprintf(stderr, "Assert%s failed", " 'index' "); fprintf(stderr, " in %s (%s:%d)\n", LOCATE_array___Array_____bra, LOCATE_sorter, 229); nit_exit(1);}
170 variable8 = ATTR_array___Array____items( variable0 /*array*/) /*Array::_items*/;
171 variable8 = UNBOX_NativeArray(variable8)[UNTAG_Int( variable7 /*index*/)];
172 goto return_label10;
173 return_label10: while(false);
174 variable7 = variable8;
175 ((array___Array_____braeq_t)CALL( variable0 /*array*/,COLOR_abstract_collection___Map_____braeq))( variable0 /*array*/, variable4 /*i*/, variable7) /*Array::[]=*/;
176 ((array___Array_____braeq_t)CALL( variable0 /*array*/,COLOR_abstract_collection___Map_____braeq))( variable0 /*array*/, variable5 /*j*/, variable6 /*t*/) /*Array::[]=*/;
177 }
178 continue_4: while(0);
179 }
180 break_4: while(0);
181 variable6 = TAG_Int(UNTAG_Int( variable4 /*i*/)-UNTAG_Int( TAG_Int(1)));
182 variable7 = variable6;
183 variable8 = TAG_Bool(UNTAG_Int( variable7 /*index*/)>=UNTAG_Int( TAG_Int(0)));
184 variable9 = variable8;
185 if (UNTAG_Bool(variable9)) { /* and */
186 variable9 = ATTR_array___AbstractArray____length( variable0 /*array*/) /*AbstractArray::_length*/;
187 variable9 = TAG_Bool(UNTAG_Int( variable7 /*index*/)<UNTAG_Int(variable9));
188 }
189 variable8 = variable9;
190 if (!UNTAG_Bool(variable8)) { fprintf(stderr, "Assert%s failed", " 'index' "); fprintf(stderr, " in %s (%s:%d)\n", LOCATE_array___Array_____bra, LOCATE_sorter, 229); nit_exit(1);}
191 variable8 = ATTR_array___Array____items( variable0 /*array*/) /*Array::_items*/;
192 variable8 = UNBOX_NativeArray(variable8)[UNTAG_Int( variable7 /*index*/)];
193 goto return_label11;
194 return_label11: while(false);
195 variable6 = variable8;
196 ((array___Array_____braeq_t)CALL( variable0 /*array*/,COLOR_abstract_collection___Map_____braeq))( variable0 /*array*/, variable1 /*from*/, variable6) /*Array::[]=*/;
197 variable6 = TAG_Int(UNTAG_Int( variable4 /*i*/)-UNTAG_Int( TAG_Int(1)));
198 ((array___Array_____braeq_t)CALL( variable0 /*array*/,COLOR_abstract_collection___Map_____braeq))( variable0 /*array*/, variable6, variable3 /*pivot*/) /*Array::[]=*/;
199 variable6 = TAG_Int(UNTAG_Int( variable4 /*i*/)-UNTAG_Int( TAG_Int(2)));
200 ((sorter___AbstractSorter___sub_sort_t)CALL( self,COLOR_sorter___AbstractSorter___sub_sort))( self, variable0 /*array*/, variable1 /*from*/, variable6) /*AbstractSorter::sub_sort*/;
201 ((sorter___AbstractSorter___sub_sort_t)CALL( self,COLOR_sorter___AbstractSorter___sub_sort))( self, variable0 /*array*/, variable4 /*i*/, variable2 /*to*/) /*AbstractSorter::sub_sort*/;
202 tracehead = trace.prev;
203 return;
204 }
205 void sorter___AbstractSorter___bubble_sort(val_t self, val_t param0, val_t param1, val_t param2) {
206 struct trace_t trace = {NULL, NULL, 65, LOCATE_sorter___AbstractSorter___bubble_sort};
207 val_t variable0;
208 val_t variable1;
209 val_t variable2;
210 val_t variable3;
211 val_t variable4;
212 val_t variable5;
213 val_t variable6;
214 val_t variable7;
215 val_t variable8;
216 val_t variable9;
217 trace.prev = tracehead; tracehead = &trace;
218 trace.file = LOCATE_sorter;
219 variable0 = param0;
220 variable1 = param1;
221 variable2 = param2;
222 variable3 = variable1 /*from*/;
223 while (true) { /*while*/
224 variable4 = TAG_Bool(UNTAG_Int( variable3 /*i*/)<UNTAG_Int( variable2 /*to*/));
225 if (!UNTAG_Bool(variable4)) break; /* while*/
226 variable4 = variable3 /*i*/;
227 variable6 = variable3 /*i*/;
228 variable7 = TAG_Bool(UNTAG_Int( variable6 /*index*/)>=UNTAG_Int( TAG_Int(0)));
229 variable8 = variable7;
230 if (UNTAG_Bool(variable8)) { /* and */
231 variable8 = ATTR_array___AbstractArray____length( variable0 /*array*/) /*AbstractArray::_length*/;
232 variable8 = TAG_Bool(UNTAG_Int( variable6 /*index*/)<UNTAG_Int(variable8));
233 }
234 variable7 = variable8;
235 if (!UNTAG_Bool(variable7)) { fprintf(stderr, "Assert%s failed", " 'index' "); fprintf(stderr, " in %s (%s:%d)\n", LOCATE_array___Array_____bra, LOCATE_sorter, 229); nit_exit(1);}
236 variable7 = ATTR_array___Array____items( variable0 /*array*/) /*Array::_items*/;
237 variable7 = UNBOX_NativeArray(variable7)[UNTAG_Int( variable6 /*index*/)];
238 goto return_label14;
239 return_label14: while(false);
240 variable6 = variable7;
241 variable5 = variable6;
242 variable6 = variable3 /*i*/;
243 while (true) { /*while*/
244 variable7 = TAG_Bool(UNTAG_Int( variable6 /*j*/)<=UNTAG_Int( variable2 /*to*/));
245 if (!UNTAG_Bool(variable7)) break; /* while*/
246 variable7 = variable6 /*j*/;
247 variable8 = TAG_Bool(UNTAG_Int( variable7 /*index*/)>=UNTAG_Int( TAG_Int(0)));
248 variable9 = variable8;
249 if (UNTAG_Bool(variable9)) { /* and */
250 variable9 = ATTR_array___AbstractArray____length( variable0 /*array*/) /*AbstractArray::_length*/;
251 variable9 = TAG_Bool(UNTAG_Int( variable7 /*index*/)<UNTAG_Int(variable9));
252 }
253 variable8 = variable9;
254 if (!UNTAG_Bool(variable8)) { fprintf(stderr, "Assert%s failed", " 'index' "); fprintf(stderr, " in %s (%s:%d)\n", LOCATE_array___Array_____bra, LOCATE_sorter, 229); nit_exit(1);}
255 variable8 = ATTR_array___Array____items( variable0 /*array*/) /*Array::_items*/;
256 variable8 = UNBOX_NativeArray(variable8)[UNTAG_Int( variable7 /*index*/)];
257 goto return_label16;
258 return_label16: while(false);
259 variable7 = variable8;
260 variable7 = ((sorter___AbstractSorter___compare_t)CALL( self,COLOR_sorter___AbstractSorter___compare))( self, variable5 /*min_v*/, variable7) /*AbstractSorter::compare*/;
261 variable7 = TAG_Bool(UNTAG_Int(variable7)>UNTAG_Int( TAG_Int(0)));
262 if (UNTAG_Bool(variable7)) { /*if*/
263 variable4 = variable6 /*j*/ /*min=*/;
264 variable7 = variable6 /*j*/;
265 variable8 = TAG_Bool(UNTAG_Int( variable7 /*index*/)>=UNTAG_Int( TAG_Int(0)));
266 variable9 = variable8;
267 if (UNTAG_Bool(variable9)) { /* and */
268 variable9 = ATTR_array___AbstractArray____length( variable0 /*array*/) /*AbstractArray::_length*/;
269 variable9 = TAG_Bool(UNTAG_Int( variable7 /*index*/)<UNTAG_Int(variable9));
270 }
271 variable8 = variable9;
272 if (!UNTAG_Bool(variable8)) { fprintf(stderr, "Assert%s failed", " 'index' "); fprintf(stderr, " in %s (%s:%d)\n", LOCATE_array___Array_____bra, LOCATE_sorter, 229); nit_exit(1);}
273 variable8 = ATTR_array___Array____items( variable0 /*array*/) /*Array::_items*/;
274 variable8 = UNBOX_NativeArray(variable8)[UNTAG_Int( variable7 /*index*/)];
275 goto return_label17;
276 return_label17: while(false);
277 variable7 = variable8;
278 variable5 = variable7 /*min_v=*/;
279 }
280 variable6 = TAG_Int(UNTAG_Int(variable6)+UNTAG_Int( TAG_Int(1))) /*j*/;
281 continue_15: while(0);
282 }
283 break_15: while(0);
284 variable7 = TAG_Bool(( variable4 /*min*/)!=( variable3 /*i*/));
285 if (UNTAG_Bool(variable7)) { /*if*/
286 variable7 = variable3 /*i*/;
287 variable8 = TAG_Bool(UNTAG_Int( variable7 /*index*/)>=UNTAG_Int( TAG_Int(0)));
288 variable9 = variable8;
289 if (UNTAG_Bool(variable9)) { /* and */
290 variable9 = ATTR_array___AbstractArray____length( variable0 /*array*/) /*AbstractArray::_length*/;
291 variable9 = TAG_Bool(UNTAG_Int( variable7 /*index*/)<UNTAG_Int(variable9));
292 }
293 variable8 = variable9;
294 if (!UNTAG_Bool(variable8)) { fprintf(stderr, "Assert%s failed", " 'index' "); fprintf(stderr, " in %s (%s:%d)\n", LOCATE_array___Array_____bra, LOCATE_sorter, 229); nit_exit(1);}
295 variable8 = ATTR_array___Array____items( variable0 /*array*/) /*Array::_items*/;
296 variable8 = UNBOX_NativeArray(variable8)[UNTAG_Int( variable7 /*index*/)];
297 goto return_label18;
298 return_label18: while(false);
299 variable7 = variable8;
300 ((array___Array_____braeq_t)CALL( variable0 /*array*/,COLOR_abstract_collection___Map_____braeq))( variable0 /*array*/, variable4 /*min*/, variable7) /*Array::[]=*/;
301 ((array___Array_____braeq_t)CALL( variable0 /*array*/,COLOR_abstract_collection___Map_____braeq))( variable0 /*array*/, variable3 /*i*/, variable5 /*min_v*/) /*Array::[]=*/;
302 }
303 variable3 = TAG_Int(UNTAG_Int(variable3)+UNTAG_Int( TAG_Int(1))) /*i*/;
304 continue_13: while(0);
305 }
306 break_13: while(0);
307 tracehead = trace.prev;
308 return;
309 }
310 val_t sorter___ComparableSorter___compare(val_t self, val_t param0, val_t param1) {
311 struct trace_t trace = {NULL, NULL, 93, LOCATE_sorter___ComparableSorter___compare};
312 val_t variable0;
313 val_t variable1;
314 val_t variable2;
315 trace.prev = tracehead; tracehead = &trace;
316 trace.file = LOCATE_sorter;
317 variable0 = param0;
318 variable1 = param1;
319 variable2 = ((kernel___Comparable_____leqg_t)CALL( variable0 /*a*/,COLOR_kernel___Comparable_____leqg))( variable0 /*a*/, variable1 /*b*/) /*Comparable::<=>*/;
320 goto return_label19;
321 return_label19: while(false);
322 tracehead = trace.prev;
323 return variable2;
324 }
325 void sorter___ComparableSorter___init(val_t self, int* init_table) {
326 struct trace_t trace = {NULL, NULL, 96, LOCATE_sorter___ComparableSorter___init};
327 trace.prev = tracehead; tracehead = &trace;
328 trace.file = LOCATE_sorter;
329 if (init_table[VAL2OBJ( self)->vft[INIT_TABLE_POS_ComparableSorter].i]) return;
330 init_table[VAL2OBJ( self)->vft[INIT_TABLE_POS_ComparableSorter].i] = 1;
331 tracehead = trace.prev;
332 return;
333 }