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);
10 tracehead
= trace
.prev
;
13 void sorter___AbstractSorter___sort(val_t self
, val_t param0
) {
14 struct trace_t trace
= {NULL
, NULL
, 29, LOCATE_sorter___AbstractSorter___sort
};
17 trace
.prev
= tracehead
; tracehead
= &trace
;
18 trace
.file
= LOCATE_sorter
;
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
;
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
};
32 trace
.prev
= tracehead
; tracehead
= &trace
;
33 trace
.file
= LOCATE_sorter
;
37 variable3
= TAG_Bool(UNTAG_Int( variable1
/*from*/)>=UNTAG_Int( variable2
/*to*/));
38 if (UNTAG_Bool(variable3
)) { /*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*/;
46 ((sorter___AbstractSorter___bubble_sort_t
)CALL( self
,COLOR_sorter___AbstractSorter___bubble_sort
))( self
, variable0
/*array*/, variable1
/*from*/, variable2
/*to*/) /*AbstractSorter::bubble_sort*/;
49 return_label1
: while(false);
50 tracehead
= trace
.prev
;
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
};
65 trace
.prev
= tracehead
; tracehead
= &trace
;
66 trace
.file
= LOCATE_sorter
;
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
));
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*/)];
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
));
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*/)];
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)));
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);
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
));
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*/)];
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)));
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);
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
));
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*/)];
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
));
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*/)];
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::[]=*/;
178 continue_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
));
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*/)];
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
;
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
};
217 trace
.prev
= tracehead
; tracehead
= &trace
;
218 trace
.file
= LOCATE_sorter
;
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
));
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*/)];
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
));
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*/)];
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
));
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*/)];
276 return_label17
: while(false);
277 variable7
= variable8
;
278 variable5
= variable7
/*min_v=*/;
280 variable6
= TAG_Int(UNTAG_Int(variable6
)+UNTAG_Int( TAG_Int(1))) /*j*/;
281 continue_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
));
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*/)];
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::[]=*/;
303 variable3
= TAG_Int(UNTAG_Int(variable3
)+UNTAG_Int( TAG_Int(1))) /*i*/;
304 continue_13
: while(0);
307 tracehead
= trace
.prev
;
310 void sorter___AbstractSorter___init(val_t self
, int* init_table
) {
311 struct trace_t trace
= {NULL
, NULL
, 0, LOCATE_sorter___AbstractSorter___init
};
312 trace
.prev
= tracehead
; tracehead
= &trace
;
313 trace
.file
= LOCATE_sorter
;
314 tracehead
= trace
.prev
;
317 val_t
sorter___ComparableSorter___compare(val_t self
, val_t param0
, val_t param1
) {
318 struct trace_t trace
= {NULL
, NULL
, 93, LOCATE_sorter___ComparableSorter___compare
};
322 trace
.prev
= tracehead
; tracehead
= &trace
;
323 trace
.file
= LOCATE_sorter
;
326 variable2
= ((kernel___Comparable_____leqg_t
)CALL( variable0
/*a*/,COLOR_kernel___Comparable_____leqg
))( variable0
/*a*/, variable1
/*b*/) /*Comparable::<=>*/;
328 return_label19
: while(false);
329 tracehead
= trace
.prev
;
332 void sorter___ComparableSorter___init(val_t self
, int* init_table
) {
333 struct trace_t trace
= {NULL
, NULL
, 96, LOCATE_sorter___ComparableSorter___init
};
334 trace
.prev
= tracehead
; tracehead
= &trace
;
335 trace
.file
= LOCATE_sorter
;
336 if (init_table
[VAL2OBJ( self
)->vft
[INIT_TABLE_POS_ComparableSorter
].i
]) return;
337 init_table
[VAL2OBJ( self
)->vft
[INIT_TABLE_POS_ComparableSorter
].i
] = 1;
338 tracehead
= trace
.prev
;