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