nitmetrics: refactor nullables metrics computation
[nit.git] / c_src / global___dead_method_removal._sep.c
1 /* This C file is generated by NIT to compile module global___dead_method_removal. */
2 #include "global___dead_method_removal._sep.h"
3 val_t global___dead_method_removal___Program___nb_removed_iroutines(val_t p0){
4 struct {struct stack_frame_t me;} fra;
5 val_t REGB0;
6 val_t tmp;
7 fra.me.prev = stack_frame_head; stack_frame_head = &fra.me;
8 fra.me.file = LOCATE_global___dead_method_removal;
9 fra.me.line = 23;
10 fra.me.meth = LOCATE_global___dead_method_removal___Program___nb_removed_iroutines;
11 fra.me.has_broke = 0;
12 fra.me.REG_size = 1;
13 fra.me.nitni_local_ref_head = NULL;
14 fra.me.REG[0] = NIT_NULL;
15 fra.me.REG[0] = p0;
16 /* global/dead_method_removal.nit:23 */
17 REGB0 = TAG_Bool(ATTR_global___dead_method_removal___Program____nb_removed_iroutines(fra.me.REG[0])!=NIT_NULL);
18 if (UNTAG_Bool(REGB0)) {
19 } else {
20 nit_abort("Uninitialized attribute %s", "_nb_removed_iroutines", LOCATE_global___dead_method_removal, 23);
21 }
22 REGB0 = ATTR_global___dead_method_removal___Program____nb_removed_iroutines(fra.me.REG[0]);
23 stack_frame_head = fra.me.prev;
24 return REGB0;
25 }
26 val_t global___dead_method_removal___Program___nb_not_removed_iroutines(val_t p0){
27 struct {struct stack_frame_t me;} fra;
28 val_t REGB0;
29 val_t tmp;
30 fra.me.prev = stack_frame_head; stack_frame_head = &fra.me;
31 fra.me.file = LOCATE_global___dead_method_removal;
32 fra.me.line = 24;
33 fra.me.meth = LOCATE_global___dead_method_removal___Program___nb_not_removed_iroutines;
34 fra.me.has_broke = 0;
35 fra.me.REG_size = 1;
36 fra.me.nitni_local_ref_head = NULL;
37 fra.me.REG[0] = NIT_NULL;
38 fra.me.REG[0] = p0;
39 /* global/dead_method_removal.nit:24 */
40 REGB0 = TAG_Bool(ATTR_global___dead_method_removal___Program____nb_not_removed_iroutines(fra.me.REG[0])!=NIT_NULL);
41 if (UNTAG_Bool(REGB0)) {
42 } else {
43 nit_abort("Uninitialized attribute %s", "_nb_not_removed_iroutines", LOCATE_global___dead_method_removal, 24);
44 }
45 REGB0 = ATTR_global___dead_method_removal___Program____nb_not_removed_iroutines(fra.me.REG[0]);
46 stack_frame_head = fra.me.prev;
47 return REGB0;
48 }
49 void global___dead_method_removal___Program___optimize_dead_methods(val_t p0){
50 struct {struct stack_frame_t me;} fra;
51 val_t tmp;
52 fra.me.prev = stack_frame_head; stack_frame_head = &fra.me;
53 fra.me.file = LOCATE_global___dead_method_removal;
54 fra.me.line = 26;
55 fra.me.meth = LOCATE_global___dead_method_removal___Program___optimize_dead_methods;
56 fra.me.has_broke = 0;
57 fra.me.REG_size = 1;
58 fra.me.nitni_local_ref_head = NULL;
59 fra.me.REG[0] = NIT_NULL;
60 fra.me.REG[0] = p0;
61 CALL_program___Program___with_each_iroutines(fra.me.REG[0])(fra.me.REG[0], (&(fra.me)), ((fun_t)OC_global___dead_method_removal___Program___optimize_dead_methods_1));
62 stack_frame_head = fra.me.prev;
63 return;
64 }
65 void OC_global___dead_method_removal___Program___optimize_dead_methods_1(struct stack_frame_t *closctx, val_t p0, val_t p1){
66 struct {struct stack_frame_t me; val_t MORE_REG[2];} fra;
67 val_t REGB0;
68 val_t REGB1;
69 val_t tmp;
70 /* global/dead_method_removal.nit:29 */
71 fra.me.prev = stack_frame_head; stack_frame_head = &fra.me;
72 fra.me.file = LOCATE_global___dead_method_removal;
73 fra.me.line = 29;
74 fra.me.meth = LOCATE_global___dead_method_removal___Program___optimize_dead_methods;
75 fra.me.has_broke = 0;
76 fra.me.REG_size = 3;
77 fra.me.nitni_local_ref_head = NULL;
78 fra.me.REG[0] = NIT_NULL;
79 fra.me.REG[1] = NIT_NULL;
80 fra.me.REG[2] = NIT_NULL;
81 fra.me.REG[0] = p0;
82 fra.me.REG[1] = p1;
83 /* global/dead_method_removal.nit:30 */
84 fra.me.REG[2] = CALL_global___reachable_method_analysis___Program___rma(closctx->REG[0])(closctx->REG[0]);
85 REGB0 = TAG_Bool(fra.me.REG[2]==NIT_NULL);
86 if (UNTAG_Bool(REGB0)) {
87 nit_abort("Reciever is null", NULL, LOCATE_global___dead_method_removal, 30);
88 }
89 REGB0 = CALL_global___reachable_method_analysis___ReachableMethodAnalysis___is_iroutine_reachable(fra.me.REG[2])(fra.me.REG[2], fra.me.REG[0]);
90 REGB0 = TAG_Bool(!UNTAG_Bool(REGB0));
91 if (UNTAG_Bool(REGB0)) {
92 /* global/dead_method_removal.nit:31 */
93 CALL_global___dead_method_removal___IRoutine___set_not_reachable(fra.me.REG[0])(fra.me.REG[0], fra.me.REG[1]);
94 /* global/dead_method_removal.nit:32 */
95 REGB0 = CALL_global___dead_method_removal___Program___nb_removed_iroutines(closctx->REG[0])(closctx->REG[0]);
96 REGB1 = TAG_Int(1);
97 /* ../lib/standard/kernel.nit:235 */
98 REGB1 = TAG_Int(UNTAG_Int(REGB0)+UNTAG_Int(REGB1));
99 /* global/dead_method_removal.nit:32 */
100 ATTR_global___dead_method_removal___Program____nb_removed_iroutines(closctx->REG[0]) = REGB1;
101 } else {
102 /* global/dead_method_removal.nit:34 */
103 REGB1 = CALL_global___dead_method_removal___Program___nb_not_removed_iroutines(closctx->REG[0])(closctx->REG[0]);
104 REGB0 = TAG_Int(1);
105 /* ../lib/standard/kernel.nit:235 */
106 REGB0 = TAG_Int(UNTAG_Int(REGB1)+UNTAG_Int(REGB0));
107 /* global/dead_method_removal.nit:34 */
108 ATTR_global___dead_method_removal___Program____nb_not_removed_iroutines(closctx->REG[0]) = REGB0;
109 }
110 stack_frame_head = fra.me.prev;
111 return;
112 }
113 void global___dead_method_removal___Program___dump_dead_method_optimization(val_t p0, val_t p1){
114 struct {struct stack_frame_t me; val_t MORE_REG[3];} fra;
115 val_t REGB0;
116 val_t tmp;
117 static val_t once_value_1; /* Once value */
118 static val_t once_value_2; /* Once value */
119 static val_t once_value_3; /* Once value */
120 static val_t once_value_4; /* Once value */
121 static val_t once_value_5; /* Once value */
122 static val_t once_value_6; /* Once value */
123 static val_t once_value_7; /* Once value */
124 fra.me.prev = stack_frame_head; stack_frame_head = &fra.me;
125 fra.me.file = LOCATE_global___dead_method_removal;
126 fra.me.line = 39;
127 fra.me.meth = LOCATE_global___dead_method_removal___Program___dump_dead_method_optimization;
128 fra.me.has_broke = 0;
129 fra.me.REG_size = 4;
130 fra.me.nitni_local_ref_head = NULL;
131 fra.me.REG[0] = NIT_NULL;
132 fra.me.REG[1] = NIT_NULL;
133 fra.me.REG[2] = NIT_NULL;
134 fra.me.REG[3] = NIT_NULL;
135 fra.me.REG[0] = p0;
136 fra.me.REG[1] = p1;
137 /* global/dead_method_removal.nit:41 */
138 REGB0 = TAG_Int(5);
139 fra.me.REG[2] = NEW_Array_standard___collection___array___Array___with_capacity(REGB0);
140 if (!once_value_1) {
141 fra.me.REG[3] = BOX_NativeString("");
142 REGB0 = TAG_Int(0);
143 fra.me.REG[3] = NEW_String_standard___string___String___with_native(fra.me.REG[3], REGB0);
144 once_value_1 = fra.me.REG[3];
145 register_static_object(&once_value_1);
146 } else fra.me.REG[3] = once_value_1;
147 fra.me.REG[3] = fra.me.REG[3];
148 CALL_standard___collection___abstract_collection___SimpleCollection___add(fra.me.REG[2])(fra.me.REG[2], fra.me.REG[3]);
149 CALL_standard___collection___abstract_collection___SimpleCollection___add(fra.me.REG[2])(fra.me.REG[2], fra.me.REG[1]);
150 if (!once_value_2) {
151 fra.me.REG[1] = BOX_NativeString("/");
152 REGB0 = TAG_Int(1);
153 fra.me.REG[1] = NEW_String_standard___string___String___with_native(fra.me.REG[1], REGB0);
154 once_value_2 = fra.me.REG[1];
155 register_static_object(&once_value_2);
156 } else fra.me.REG[1] = once_value_2;
157 fra.me.REG[1] = fra.me.REG[1];
158 CALL_standard___collection___abstract_collection___SimpleCollection___add(fra.me.REG[2])(fra.me.REG[2], fra.me.REG[1]);
159 fra.me.REG[1] = CALL_program___Program___main_module(fra.me.REG[0])(fra.me.REG[0]);
160 fra.me.REG[1] = CALL_metamodel___abstractmetamodel___MMModule___name(fra.me.REG[1])(fra.me.REG[1]);
161 fra.me.REG[1] = CALL_standard___string___Object___to_s(fra.me.REG[1])(fra.me.REG[1]);
162 CALL_standard___collection___abstract_collection___SimpleCollection___add(fra.me.REG[2])(fra.me.REG[2], fra.me.REG[1]);
163 if (!once_value_3) {
164 fra.me.REG[1] = BOX_NativeString(".dmr_opt.log");
165 REGB0 = TAG_Int(12);
166 fra.me.REG[1] = NEW_String_standard___string___String___with_native(fra.me.REG[1], REGB0);
167 once_value_3 = fra.me.REG[1];
168 register_static_object(&once_value_3);
169 } else fra.me.REG[1] = once_value_3;
170 fra.me.REG[1] = fra.me.REG[1];
171 CALL_standard___collection___abstract_collection___SimpleCollection___add(fra.me.REG[2])(fra.me.REG[2], fra.me.REG[1]);
172 fra.me.REG[2] = CALL_standard___string___Object___to_s(fra.me.REG[2])(fra.me.REG[2]);
173 fra.me.REG[2] = NEW_OFStream_standard___file___OFStream___open(fra.me.REG[2]);
174 /* global/dead_method_removal.nit:43 */
175 REGB0 = TAG_Int(3);
176 fra.me.REG[1] = NEW_Array_standard___collection___array___Array___with_capacity(REGB0);
177 if (!once_value_4) {
178 fra.me.REG[3] = BOX_NativeString("Nb. dead iroutines removed: ");
179 REGB0 = TAG_Int(28);
180 fra.me.REG[3] = NEW_String_standard___string___String___with_native(fra.me.REG[3], REGB0);
181 once_value_4 = fra.me.REG[3];
182 register_static_object(&once_value_4);
183 } else fra.me.REG[3] = once_value_4;
184 fra.me.REG[3] = fra.me.REG[3];
185 CALL_standard___collection___abstract_collection___SimpleCollection___add(fra.me.REG[1])(fra.me.REG[1], fra.me.REG[3]);
186 REGB0 = CALL_global___dead_method_removal___Program___nb_removed_iroutines(fra.me.REG[0])(fra.me.REG[0]);
187 fra.me.REG[3] = CALL_standard___string___Object___to_s(REGB0)(REGB0);
188 CALL_standard___collection___abstract_collection___SimpleCollection___add(fra.me.REG[1])(fra.me.REG[1], fra.me.REG[3]);
189 if (!once_value_5) {
190 fra.me.REG[3] = BOX_NativeString("\n");
191 REGB0 = TAG_Int(1);
192 fra.me.REG[3] = NEW_String_standard___string___String___with_native(fra.me.REG[3], REGB0);
193 once_value_5 = fra.me.REG[3];
194 register_static_object(&once_value_5);
195 } else fra.me.REG[3] = once_value_5;
196 fra.me.REG[3] = fra.me.REG[3];
197 CALL_standard___collection___abstract_collection___SimpleCollection___add(fra.me.REG[1])(fra.me.REG[1], fra.me.REG[3]);
198 fra.me.REG[1] = CALL_standard___string___Object___to_s(fra.me.REG[1])(fra.me.REG[1]);
199 CALL_standard___stream___OStream___write(fra.me.REG[2])(fra.me.REG[2], fra.me.REG[1]);
200 /* global/dead_method_removal.nit:44 */
201 REGB0 = TAG_Int(3);
202 fra.me.REG[1] = NEW_Array_standard___collection___array___Array___with_capacity(REGB0);
203 if (!once_value_6) {
204 fra.me.REG[3] = BOX_NativeString("Nb. live iroutines: ");
205 REGB0 = TAG_Int(20);
206 fra.me.REG[3] = NEW_String_standard___string___String___with_native(fra.me.REG[3], REGB0);
207 once_value_6 = fra.me.REG[3];
208 register_static_object(&once_value_6);
209 } else fra.me.REG[3] = once_value_6;
210 fra.me.REG[3] = fra.me.REG[3];
211 CALL_standard___collection___abstract_collection___SimpleCollection___add(fra.me.REG[1])(fra.me.REG[1], fra.me.REG[3]);
212 REGB0 = CALL_global___dead_method_removal___Program___nb_not_removed_iroutines(fra.me.REG[0])(fra.me.REG[0]);
213 fra.me.REG[0] = CALL_standard___string___Object___to_s(REGB0)(REGB0);
214 CALL_standard___collection___abstract_collection___SimpleCollection___add(fra.me.REG[1])(fra.me.REG[1], fra.me.REG[0]);
215 if (!once_value_7) {
216 fra.me.REG[0] = BOX_NativeString("\n");
217 REGB0 = TAG_Int(1);
218 fra.me.REG[0] = NEW_String_standard___string___String___with_native(fra.me.REG[0], REGB0);
219 once_value_7 = fra.me.REG[0];
220 register_static_object(&once_value_7);
221 } else fra.me.REG[0] = once_value_7;
222 fra.me.REG[0] = fra.me.REG[0];
223 CALL_standard___collection___abstract_collection___SimpleCollection___add(fra.me.REG[1])(fra.me.REG[1], fra.me.REG[0]);
224 fra.me.REG[1] = CALL_standard___string___Object___to_s(fra.me.REG[1])(fra.me.REG[1]);
225 CALL_standard___stream___OStream___write(fra.me.REG[2])(fra.me.REG[2], fra.me.REG[1]);
226 /* global/dead_method_removal.nit:46 */
227 CALL_standard___stream___IOS___close(fra.me.REG[2])(fra.me.REG[2]);
228 stack_frame_head = fra.me.prev;
229 return;
230 }
231 void global___dead_method_removal___IRoutine___set_not_reachable(val_t p0, val_t p1){
232 struct {struct stack_frame_t me; val_t MORE_REG[2];} fra;
233 val_t REGB0;
234 val_t tmp;
235 static val_t once_value_1; /* Once value */
236 fra.me.prev = stack_frame_head; stack_frame_head = &fra.me;
237 fra.me.file = LOCATE_global___dead_method_removal;
238 fra.me.line = 51;
239 fra.me.meth = LOCATE_global___dead_method_removal___IRoutine___set_not_reachable;
240 fra.me.has_broke = 0;
241 fra.me.REG_size = 3;
242 fra.me.nitni_local_ref_head = NULL;
243 fra.me.REG[0] = NIT_NULL;
244 fra.me.REG[1] = NIT_NULL;
245 fra.me.REG[2] = NIT_NULL;
246 fra.me.REG[0] = p0;
247 fra.me.REG[1] = p1;
248 /* global/dead_method_removal.nit:53 */
249 fra.me.REG[0] = NEW_ICodeBuilder_icode___icode_builder___ICodeBuilder___init(fra.me.REG[1], fra.me.REG[0]);
250 /* global/dead_method_removal.nit:54 */
251 fra.me.REG[1] = CALL_icode___icode_builder___ICodeBuilder___seq(fra.me.REG[0])(fra.me.REG[0]);
252 fra.me.REG[1] = CALL_icode___icode_base___ISeq___icodes(fra.me.REG[1])(fra.me.REG[1]);
253 CALL_standard___collection___abstract_collection___RemovableCollection___clear(fra.me.REG[1])(fra.me.REG[1]);
254 /* global/dead_method_removal.nit:55 */
255 REGB0 = TAG_Int(0);
256 fra.me.REG[1] = NEW_Array_standard___collection___array___Array___with_capacity(REGB0);
257 if (!once_value_1) {
258 fra.me.REG[2] = BOX_NativeString("This method should not be called !");
259 REGB0 = TAG_Int(34);
260 fra.me.REG[2] = NEW_String_standard___string___String___with_native(fra.me.REG[2], REGB0);
261 once_value_1 = fra.me.REG[2];
262 register_static_object(&once_value_1);
263 } else fra.me.REG[2] = once_value_1;
264 fra.me.REG[2] = fra.me.REG[2];
265 CALL_standard___collection___abstract_collection___SimpleCollection___add(fra.me.REG[1])(fra.me.REG[1], fra.me.REG[2]);
266 CALL_icode___icode_builder___ICodeBuilder___add_abort(fra.me.REG[0])(fra.me.REG[0], fra.me.REG[1]);
267 stack_frame_head = fra.me.prev;
268 return;
269 }