niti: add extern `file_realpath`
[nit.git] / c_src / div_by_zero.sep.1.c
1 #include "div_by_zero.sep.0.h"
2 /* method div_by_zero#ToolContext#div_by_zero_phase for (self: ToolContext): Phase */
3 val* div_by_zero__ToolContext__div_by_zero_phase(val* self) {
4 val* var /* : Phase */;
5 val* var1 /* : Phase */;
6 var1 = self->attrs[COLOR_div_by_zero__ToolContext___64ddiv_by_zero_phase].val; /* @div_by_zero_phase on <self:ToolContext> */
7 if (var1 == NULL) {
8 fprintf(stderr, "Runtime error: %s", "Uninitialized attribute @div_by_zero_phase");
9 fprintf(stderr, " (%s:%d)\n", "src/div_by_zero.nit", 26);
10 exit(1);
11 }
12 var = var1;
13 RET_LABEL:;
14 return var;
15 }
16 /* method div_by_zero#ToolContext#div_by_zero_phase for (self: Object): Phase */
17 val* VIRTUAL_div_by_zero__ToolContext__div_by_zero_phase(val* self) {
18 val* var /* : Phase */;
19 val* var1 /* : Phase */;
20 var1 = div_by_zero__ToolContext__div_by_zero_phase(self);
21 var = var1;
22 RET_LABEL:;
23 return var;
24 }
25 /* method div_by_zero#ToolContext#div_by_zero_phase= for (self: ToolContext, Phase) */
26 void div_by_zero__ToolContext__div_by_zero_phase_61d(val* self, val* p0) {
27 self->attrs[COLOR_div_by_zero__ToolContext___64ddiv_by_zero_phase].val = p0; /* @div_by_zero_phase on <self:ToolContext> */
28 RET_LABEL:;
29 }
30 /* method div_by_zero#ToolContext#div_by_zero_phase= for (self: Object, Phase) */
31 void VIRTUAL_div_by_zero__ToolContext__div_by_zero_phase_61d(val* self, val* p0) {
32 div_by_zero__ToolContext__div_by_zero_phase_61d(self, p0);
33 RET_LABEL:;
34 }
35 /* method div_by_zero#DivByZeroPhase#process_nmodule for (self: DivByZeroPhase, AModule) */
36 void div_by_zero__DivByZeroPhase__process_nmodule(val* self, val* p0) {
37 val* var_nmodule /* var nmodule: AModule */;
38 val* var /* : nullable MModule */;
39 val* var_mmodule /* var mmodule: MModule */;
40 val* var1 /* : DivByZeroVisitor */;
41 val* var2 /* : ToolContext */;
42 val* var_visitor /* var visitor: DivByZeroVisitor */;
43 var_nmodule = p0;
44 var = ((val* (*)(val*))(var_nmodule->class->vft[COLOR_modelbuilder__AModule__mmodule]))(var_nmodule) /* mmodule on <var_nmodule:AModule>*/;
45 if (var == NULL) {
46 fprintf(stderr, "Runtime error: %s", "Cast failed");
47 fprintf(stderr, " (%s:%d)\n", "src/div_by_zero.nit", 41);
48 exit(1);
49 }
50 var_mmodule = var;
51 var1 = NEW_div_by_zero__DivByZeroVisitor(&type_div_by_zero__DivByZeroVisitor);
52 var2 = ((val* (*)(val*))(self->class->vft[COLOR_phase__Phase__toolcontext]))(self) /* toolcontext on <self:DivByZeroPhase>*/;
53 ((void (*)(val*, val*, val*))(var1->class->vft[COLOR_div_by_zero__DivByZeroVisitor__init]))(var1, var2, var_mmodule) /* init on <var1:DivByZeroVisitor>*/;
54 CHECK_NEW_div_by_zero__DivByZeroVisitor(var1);
55 var_visitor = var1;
56 ((void (*)(val*, val*))(var_visitor->class->vft[COLOR_parser_nodes__Visitor__enter_visit]))(var_visitor, var_nmodule) /* enter_visit on <var_visitor:DivByZeroVisitor>*/;
57 RET_LABEL:;
58 }
59 /* method div_by_zero#DivByZeroPhase#process_nmodule for (self: Object, AModule) */
60 void VIRTUAL_div_by_zero__DivByZeroPhase__process_nmodule(val* self, val* p0) {
61 div_by_zero__DivByZeroPhase__process_nmodule(self, p0);
62 RET_LABEL:;
63 }
64 /* method div_by_zero#DivByZeroVisitor#toolcontext for (self: DivByZeroVisitor): ToolContext */
65 val* div_by_zero__DivByZeroVisitor__toolcontext(val* self) {
66 val* var /* : ToolContext */;
67 val* var1 /* : ToolContext */;
68 var1 = self->attrs[COLOR_div_by_zero__DivByZeroVisitor___64dtoolcontext].val; /* @toolcontext on <self:DivByZeroVisitor> */
69 if (var1 == NULL) {
70 fprintf(stderr, "Runtime error: %s", "Uninitialized attribute @toolcontext");
71 fprintf(stderr, " (%s:%d)\n", "src/div_by_zero.nit", 53);
72 exit(1);
73 }
74 var = var1;
75 RET_LABEL:;
76 return var;
77 }
78 /* method div_by_zero#DivByZeroVisitor#toolcontext for (self: Object): ToolContext */
79 val* VIRTUAL_div_by_zero__DivByZeroVisitor__toolcontext(val* self) {
80 val* var /* : ToolContext */;
81 val* var1 /* : ToolContext */;
82 var1 = div_by_zero__DivByZeroVisitor__toolcontext(self);
83 var = var1;
84 RET_LABEL:;
85 return var;
86 }
87 /* method div_by_zero#DivByZeroVisitor#toolcontext= for (self: DivByZeroVisitor, ToolContext) */
88 void div_by_zero__DivByZeroVisitor__toolcontext_61d(val* self, val* p0) {
89 self->attrs[COLOR_div_by_zero__DivByZeroVisitor___64dtoolcontext].val = p0; /* @toolcontext on <self:DivByZeroVisitor> */
90 RET_LABEL:;
91 }
92 /* method div_by_zero#DivByZeroVisitor#toolcontext= for (self: Object, ToolContext) */
93 void VIRTUAL_div_by_zero__DivByZeroVisitor__toolcontext_61d(val* self, val* p0) {
94 div_by_zero__DivByZeroVisitor__toolcontext_61d(self, p0);
95 RET_LABEL:;
96 }
97 /* method div_by_zero#DivByZeroVisitor#mmodule for (self: DivByZeroVisitor): MModule */
98 val* div_by_zero__DivByZeroVisitor__mmodule(val* self) {
99 val* var /* : MModule */;
100 val* var1 /* : MModule */;
101 var1 = self->attrs[COLOR_div_by_zero__DivByZeroVisitor___64dmmodule].val; /* @mmodule on <self:DivByZeroVisitor> */
102 if (var1 == NULL) {
103 fprintf(stderr, "Runtime error: %s", "Uninitialized attribute @mmodule");
104 fprintf(stderr, " (%s:%d)\n", "src/div_by_zero.nit", 56);
105 exit(1);
106 }
107 var = var1;
108 RET_LABEL:;
109 return var;
110 }
111 /* method div_by_zero#DivByZeroVisitor#mmodule for (self: Object): MModule */
112 val* VIRTUAL_div_by_zero__DivByZeroVisitor__mmodule(val* self) {
113 val* var /* : MModule */;
114 val* var1 /* : MModule */;
115 var1 = div_by_zero__DivByZeroVisitor__mmodule(self);
116 var = var1;
117 RET_LABEL:;
118 return var;
119 }
120 /* method div_by_zero#DivByZeroVisitor#mmodule= for (self: DivByZeroVisitor, MModule) */
121 void div_by_zero__DivByZeroVisitor__mmodule_61d(val* self, val* p0) {
122 self->attrs[COLOR_div_by_zero__DivByZeroVisitor___64dmmodule].val = p0; /* @mmodule on <self:DivByZeroVisitor> */
123 RET_LABEL:;
124 }
125 /* method div_by_zero#DivByZeroVisitor#mmodule= for (self: Object, MModule) */
126 void VIRTUAL_div_by_zero__DivByZeroVisitor__mmodule_61d(val* self, val* p0) {
127 div_by_zero__DivByZeroVisitor__mmodule_61d(self, p0);
128 RET_LABEL:;
129 }
130 /* method div_by_zero#DivByZeroVisitor#init for (self: DivByZeroVisitor, ToolContext, MModule) */
131 void div_by_zero__DivByZeroVisitor__init(val* self, val* p0, val* p1) {
132 val* var_toolcontext /* var toolcontext: ToolContext */;
133 val* var_mmodule /* var mmodule: MModule */;
134 var_toolcontext = p0;
135 var_mmodule = p1;
136 ((void (*)(val*))(self->class->vft[COLOR_parser_nodes__Visitor__init]))(self) /* init on <self:DivByZeroVisitor>*/;
137 ((void (*)(val*, val*))(self->class->vft[COLOR_div_by_zero__DivByZeroVisitor__toolcontext_61d]))(self, var_toolcontext) /* toolcontext= on <self:DivByZeroVisitor>*/;
138 ((void (*)(val*, val*))(self->class->vft[COLOR_div_by_zero__DivByZeroVisitor__mmodule_61d]))(self, var_mmodule) /* mmodule= on <self:DivByZeroVisitor>*/;
139 RET_LABEL:;
140 }
141 /* method div_by_zero#DivByZeroVisitor#init for (self: Object, ToolContext, MModule) */
142 void VIRTUAL_div_by_zero__DivByZeroVisitor__init(val* self, val* p0, val* p1) {
143 div_by_zero__DivByZeroVisitor__init(self, p0, p1);
144 RET_LABEL:;
145 }
146 /* method div_by_zero#DivByZeroVisitor#visit for (self: DivByZeroVisitor, ANode) */
147 void div_by_zero__DivByZeroVisitor__visit(val* self, val* p0) {
148 val* var_node /* var node: ANode */;
149 short int var /* : Bool */;
150 int cltype;
151 int idtype;
152 short int var1 /* : Bool */;
153 val* var2 /* : AExpr */;
154 val* var_op2 /* var op2: AExpr */;
155 short int var3 /* : Bool */;
156 int cltype4;
157 int idtype5;
158 short int var6 /* : Bool */;
159 val* var7 /* : nullable Int */;
160 long var8 /* : Int */;
161 short int var9 /* : Bool */;
162 val* var10 /* : nullable Object */;
163 val* var11 /* : AExpr */;
164 val* var_op1 /* var op1: AExpr */;
165 val* var12 /* : MModule */;
166 static val* varonce;
167 val* var13 /* : String */;
168 char* var14 /* : NativeString */;
169 long var15 /* : Int */;
170 val* var16 /* : String */;
171 val* var17 /* : MClass */;
172 val* var18 /* : MClassType */;
173 val* var_int_type /* var int_type: MClassType */;
174 val* var19 /* : nullable MType */;
175 val* var20 /* : MModule */;
176 val* var21 /* : null */;
177 short int var22 /* : Bool */;
178 short int var23 /* : Bool */;
179 val* var24 /* : ToolContext */;
180 val* var25 /* : Location */;
181 static val* varonce26;
182 val* var27 /* : String */;
183 char* var28 /* : NativeString */;
184 long var29 /* : Int */;
185 val* var30 /* : String */;
186 var_node = p0;
187 ((void (*)(val*, val*))(var_node->class->vft[COLOR_parser_nodes__ANode__visit_all]))(var_node, self) /* visit_all on <var_node:ANode>*/;
188 /* <var_node:ANode> isa ASlashExpr */
189 cltype = type_parser_nodes__ASlashExpr.color;
190 idtype = type_parser_nodes__ASlashExpr.id;
191 if(cltype >= var_node->type->table_size) {
192 var = 0;
193 } else {
194 var = var_node->type->type_table[cltype] == idtype;
195 }
196 var1 = !var;
197 if (var1){
198 goto RET_LABEL;
199 } else {
200 }
201 var2 = ((val* (*)(val*))(var_node->class->vft[COLOR_parser_nodes__ABinopExpr__n_expr2]))(var_node) /* n_expr2 on <var_node:ANode(ASlashExpr)>*/;
202 var_op2 = var2;
203 /* <var_op2:AExpr> isa AIntExpr */
204 cltype4 = type_parser_nodes__AIntExpr.color;
205 idtype5 = type_parser_nodes__AIntExpr.id;
206 if(cltype4 >= var_op2->type->table_size) {
207 var3 = 0;
208 } else {
209 var3 = var_op2->type->type_table[cltype4] == idtype5;
210 }
211 var6 = !var3;
212 if (var6){
213 goto RET_LABEL;
214 } else {
215 }
216 var7 = ((val* (*)(val*))(var_op2->class->vft[COLOR_literal__AIntExpr__value]))(var_op2) /* value on <var_op2:AExpr(AIntExpr)>*/;
217 var8 = 0;
218 var10 = BOX_kernel__Int(var8); /* autobox from Int to nullable Object */
219 if (var7 == NULL) {
220 var9 = 1; /* <var8:Int> cannot be null */
221 } else {
222 var9 = ((short int (*)(val*, val*))(var7->class->vft[COLOR_kernel__Object___33d_61d]))(var7, var10) /* != on <var7:nullable Int>*/;
223 }
224 if (var9){
225 goto RET_LABEL;
226 } else {
227 }
228 var11 = ((val* (*)(val*))(var_node->class->vft[COLOR_parser_nodes__ASendExpr__n_expr]))(var_node) /* n_expr on <var_node:ANode(ASlashExpr)>*/;
229 var_op1 = var11;
230 var12 = ((val* (*)(val*))(self->class->vft[COLOR_div_by_zero__DivByZeroVisitor__mmodule]))(self) /* mmodule on <self:DivByZeroVisitor>*/;
231 if (varonce) {
232 var13 = varonce;
233 } else {
234 var14 = "Int";
235 var15 = 3;
236 var16 = string__NativeString__to_s_with_length(var14, var15);
237 var13 = var16;
238 varonce = var13;
239 }
240 var17 = ((val* (*)(val*, val*))(var12->class->vft[COLOR_model__MModule__get_primitive_class]))(var12, var13) /* get_primitive_class on <var12:MModule>*/;
241 var18 = ((val* (*)(val*))(var17->class->vft[COLOR_model__MClass__mclass_type]))(var17) /* mclass_type on <var17:MClass>*/;
242 var_int_type = var18;
243 var19 = ((val* (*)(val*))(var_op1->class->vft[COLOR_typing__AExpr__mtype]))(var_op1) /* mtype on <var_op1:AExpr>*/;
244 var20 = ((val* (*)(val*))(self->class->vft[COLOR_div_by_zero__DivByZeroVisitor__mmodule]))(self) /* mmodule on <self:DivByZeroVisitor>*/;
245 var21 = NULL;
246 if (var19 == NULL) {
247 fprintf(stderr, "Runtime error: %s", "Reciever is null");
248 fprintf(stderr, " (%s:%d)\n", "src/div_by_zero.nit", 86);
249 exit(1);
250 } else {
251 var22 = ((short int (*)(val*, val*, val*, val*))(var19->class->vft[COLOR_model__MType__is_subtype]))(var19, var20, var21, var_int_type) /* is_subtype on <var19:nullable MType>*/;
252 }
253 var23 = !var22;
254 if (var23){
255 goto RET_LABEL;
256 } else {
257 }
258 var24 = ((val* (*)(val*))(self->class->vft[COLOR_div_by_zero__DivByZeroVisitor__toolcontext]))(self) /* toolcontext on <self:DivByZeroVisitor>*/;
259 var25 = ((val* (*)(val*))(var_node->class->vft[COLOR_parser_nodes__ANode__location]))(var_node) /* location on <var_node:ANode(ASlashExpr)>*/;
260 if (varonce26) {
261 var27 = varonce26;
262 } else {
263 var28 = "Error: Definitely division by zero";
264 var29 = 34;
265 var30 = string__NativeString__to_s_with_length(var28, var29);
266 var27 = var30;
267 varonce26 = var27;
268 }
269 ((void (*)(val*, val*, val*))(var24->class->vft[COLOR_toolcontext__ToolContext__error]))(var24, var25, var27) /* error on <var24:ToolContext>*/;
270 RET_LABEL:;
271 }
272 /* method div_by_zero#DivByZeroVisitor#visit for (self: Object, ANode) */
273 void VIRTUAL_div_by_zero__DivByZeroVisitor__visit(val* self, val* p0) {
274 div_by_zero__DivByZeroVisitor__visit(self, p0);
275 RET_LABEL:;
276 }