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