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