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