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