1 /* valaforstatement.c generated by valac, the Vala compiler
2 * generated from valaforstatement.vala, do not modify */
3
4 /* valaforstatement.vala
5 *
6 * Copyright (C) 2006-2010 Jürg Billeter
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 *
22 * Author:
23 * Jürg Billeter <j@bitron.ch>
24 */
25
26 #include "vala.h"
27 #include <valagee.h>
28 #include <glib-object.h>
29 #include <glib.h>
30
31 #define _vala_code_node_unref0(var) ((var == NULL) ? NULL : (var = (vala_code_node_unref (var), NULL)))
32 #define _vala_iterable_unref0(var) ((var == NULL) ? NULL : (var = (vala_iterable_unref (var), NULL)))
33 #define _g_free0(var) (var = (g_free (var), NULL))
34
35 struct _ValaForStatementPrivate {
36 ValaList* initializer;
37 ValaList* iterator;
38 ValaExpression* _condition;
39 ValaBlock* _body;
40 };
41
42 static gint ValaForStatement_private_offset;
43 static gpointer vala_for_statement_parent_class = NULL;
44 static ValaStatementIface * vala_for_statement_vala_statement_parent_iface = NULL;
45
46 static void vala_for_statement_real_accept (ValaCodeNode* base,
47 ValaCodeVisitor* visitor);
48 static void vala_for_statement_real_accept_children (ValaCodeNode* base,
49 ValaCodeVisitor* visitor);
50 static void vala_for_statement_real_replace_expression (ValaCodeNode* base,
51 ValaExpression* old_node,
52 ValaExpression* new_node);
53 static gboolean vala_for_statement_always_true (ValaForStatement* self,
54 ValaExpression* condition);
55 static gboolean vala_for_statement_always_false (ValaForStatement* self,
56 ValaExpression* condition);
57 static gboolean vala_for_statement_real_check (ValaCodeNode* base,
58 ValaCodeContext* context);
59 static void vala_for_statement_finalize (ValaCodeNode * obj);
60 static GType vala_for_statement_get_type_once (void);
61
62 static inline gpointer
vala_for_statement_get_instance_private(ValaForStatement * self)63 vala_for_statement_get_instance_private (ValaForStatement* self)
64 {
65 return G_STRUCT_MEMBER_P (self, ValaForStatement_private_offset);
66 }
67
68 ValaExpression*
vala_for_statement_get_condition(ValaForStatement * self)69 vala_for_statement_get_condition (ValaForStatement* self)
70 {
71 ValaExpression* result;
72 ValaExpression* _tmp0_;
73 g_return_val_if_fail (self != NULL, NULL);
74 _tmp0_ = self->priv->_condition;
75 result = _tmp0_;
76 return result;
77 }
78
79 static gpointer
_vala_code_node_ref0(gpointer self)80 _vala_code_node_ref0 (gpointer self)
81 {
82 return self ? vala_code_node_ref (self) : NULL;
83 }
84
85 void
vala_for_statement_set_condition(ValaForStatement * self,ValaExpression * value)86 vala_for_statement_set_condition (ValaForStatement* self,
87 ValaExpression* value)
88 {
89 ValaExpression* _tmp0_;
90 ValaExpression* _tmp1_;
91 g_return_if_fail (self != NULL);
92 _tmp0_ = _vala_code_node_ref0 (value);
93 _vala_code_node_unref0 (self->priv->_condition);
94 self->priv->_condition = _tmp0_;
95 _tmp1_ = self->priv->_condition;
96 if (_tmp1_ != NULL) {
97 ValaExpression* _tmp2_;
98 _tmp2_ = self->priv->_condition;
99 vala_code_node_set_parent_node ((ValaCodeNode*) _tmp2_, (ValaCodeNode*) self);
100 }
101 }
102
103 ValaBlock*
vala_for_statement_get_body(ValaForStatement * self)104 vala_for_statement_get_body (ValaForStatement* self)
105 {
106 ValaBlock* result;
107 ValaBlock* _tmp0_;
108 g_return_val_if_fail (self != NULL, NULL);
109 _tmp0_ = self->priv->_body;
110 result = _tmp0_;
111 return result;
112 }
113
114 void
vala_for_statement_set_body(ValaForStatement * self,ValaBlock * value)115 vala_for_statement_set_body (ValaForStatement* self,
116 ValaBlock* value)
117 {
118 ValaBlock* _tmp0_;
119 ValaBlock* _tmp1_;
120 g_return_if_fail (self != NULL);
121 _tmp0_ = _vala_code_node_ref0 (value);
122 _vala_code_node_unref0 (self->priv->_body);
123 self->priv->_body = _tmp0_;
124 _tmp1_ = self->priv->_body;
125 vala_code_node_set_parent_node ((ValaCodeNode*) _tmp1_, (ValaCodeNode*) self);
126 }
127
128 /**
129 * Creates a new for statement.
130 *
131 * @param condition loop condition
132 * @param body loop body
133 * @param source_reference reference to source code
134 * @return newly created for statement
135 */
136 ValaForStatement*
vala_for_statement_construct(GType object_type,ValaExpression * condition,ValaBlock * body,ValaSourceReference * source_reference)137 vala_for_statement_construct (GType object_type,
138 ValaExpression* condition,
139 ValaBlock* body,
140 ValaSourceReference* source_reference)
141 {
142 ValaForStatement* self = NULL;
143 g_return_val_if_fail (body != NULL, NULL);
144 self = (ValaForStatement*) vala_code_node_construct (object_type);
145 vala_for_statement_set_condition (self, condition);
146 vala_for_statement_set_body (self, body);
147 vala_code_node_set_source_reference ((ValaCodeNode*) self, source_reference);
148 return self;
149 }
150
151 ValaForStatement*
vala_for_statement_new(ValaExpression * condition,ValaBlock * body,ValaSourceReference * source_reference)152 vala_for_statement_new (ValaExpression* condition,
153 ValaBlock* body,
154 ValaSourceReference* source_reference)
155 {
156 return vala_for_statement_construct (VALA_TYPE_FOR_STATEMENT, condition, body, source_reference);
157 }
158
159 /**
160 * Appends the specified expression to the list of initializers.
161 *
162 * @param init an initializer expression
163 */
164 void
vala_for_statement_add_initializer(ValaForStatement * self,ValaExpression * init)165 vala_for_statement_add_initializer (ValaForStatement* self,
166 ValaExpression* init)
167 {
168 ValaList* _tmp0_;
169 g_return_if_fail (self != NULL);
170 g_return_if_fail (init != NULL);
171 vala_code_node_set_parent_node ((ValaCodeNode*) init, (ValaCodeNode*) self);
172 _tmp0_ = self->priv->initializer;
173 vala_collection_add ((ValaCollection*) _tmp0_, init);
174 }
175
176 /**
177 * Returns the list of initializers.
178 *
179 * @return initializer list
180 */
181 ValaList*
vala_for_statement_get_initializer(ValaForStatement * self)182 vala_for_statement_get_initializer (ValaForStatement* self)
183 {
184 ValaList* _tmp0_;
185 ValaList* result = NULL;
186 g_return_val_if_fail (self != NULL, NULL);
187 _tmp0_ = self->priv->initializer;
188 result = _tmp0_;
189 return result;
190 }
191
192 /**
193 * Appends the specified expression to the iterator.
194 *
195 * @param iter an iterator expression
196 */
197 void
vala_for_statement_add_iterator(ValaForStatement * self,ValaExpression * iter)198 vala_for_statement_add_iterator (ValaForStatement* self,
199 ValaExpression* iter)
200 {
201 ValaList* _tmp0_;
202 g_return_if_fail (self != NULL);
203 g_return_if_fail (iter != NULL);
204 vala_code_node_set_parent_node ((ValaCodeNode*) iter, (ValaCodeNode*) self);
205 _tmp0_ = self->priv->iterator;
206 vala_collection_add ((ValaCollection*) _tmp0_, iter);
207 }
208
209 /**
210 * Returns the iterator.
211 *
212 * @return iterator
213 */
214 ValaList*
vala_for_statement_get_iterator(ValaForStatement * self)215 vala_for_statement_get_iterator (ValaForStatement* self)
216 {
217 ValaList* _tmp0_;
218 ValaList* result = NULL;
219 g_return_val_if_fail (self != NULL, NULL);
220 _tmp0_ = self->priv->iterator;
221 result = _tmp0_;
222 return result;
223 }
224
225 static void
vala_for_statement_real_accept(ValaCodeNode * base,ValaCodeVisitor * visitor)226 vala_for_statement_real_accept (ValaCodeNode* base,
227 ValaCodeVisitor* visitor)
228 {
229 ValaForStatement * self;
230 self = (ValaForStatement*) base;
231 g_return_if_fail (visitor != NULL);
232 vala_code_visitor_visit_for_statement (visitor, self);
233 }
234
235 static gpointer
_vala_iterable_ref0(gpointer self)236 _vala_iterable_ref0 (gpointer self)
237 {
238 return self ? vala_iterable_ref (self) : NULL;
239 }
240
241 static void
vala_for_statement_real_accept_children(ValaCodeNode * base,ValaCodeVisitor * visitor)242 vala_for_statement_real_accept_children (ValaCodeNode* base,
243 ValaCodeVisitor* visitor)
244 {
245 ValaForStatement * self;
246 ValaExpression* _tmp11_;
247 ValaExpression* _tmp12_;
248 ValaBlock* _tmp28_;
249 ValaBlock* _tmp29_;
250 self = (ValaForStatement*) base;
251 g_return_if_fail (visitor != NULL);
252 {
253 ValaList* _init_expr_list = NULL;
254 ValaList* _tmp0_;
255 ValaList* _tmp1_;
256 gint _init_expr_size = 0;
257 ValaList* _tmp2_;
258 gint _tmp3_;
259 gint _tmp4_;
260 gint _init_expr_index = 0;
261 _tmp0_ = self->priv->initializer;
262 _tmp1_ = _vala_iterable_ref0 (_tmp0_);
263 _init_expr_list = _tmp1_;
264 _tmp2_ = _init_expr_list;
265 _tmp3_ = vala_collection_get_size ((ValaCollection*) _tmp2_);
266 _tmp4_ = _tmp3_;
267 _init_expr_size = _tmp4_;
268 _init_expr_index = -1;
269 while (TRUE) {
270 gint _tmp5_;
271 gint _tmp6_;
272 ValaExpression* init_expr = NULL;
273 ValaList* _tmp7_;
274 gpointer _tmp8_;
275 ValaExpression* _tmp9_;
276 ValaExpression* _tmp10_;
277 _init_expr_index = _init_expr_index + 1;
278 _tmp5_ = _init_expr_index;
279 _tmp6_ = _init_expr_size;
280 if (!(_tmp5_ < _tmp6_)) {
281 break;
282 }
283 _tmp7_ = _init_expr_list;
284 _tmp8_ = vala_list_get (_tmp7_, _init_expr_index);
285 init_expr = (ValaExpression*) _tmp8_;
286 _tmp9_ = init_expr;
287 vala_code_node_accept ((ValaCodeNode*) _tmp9_, visitor);
288 _tmp10_ = init_expr;
289 vala_code_visitor_visit_end_full_expression (visitor, _tmp10_);
290 _vala_code_node_unref0 (init_expr);
291 }
292 _vala_iterable_unref0 (_init_expr_list);
293 }
294 _tmp11_ = vala_for_statement_get_condition (self);
295 _tmp12_ = _tmp11_;
296 if (_tmp12_ != NULL) {
297 ValaExpression* _tmp13_;
298 ValaExpression* _tmp14_;
299 ValaExpression* _tmp15_;
300 ValaExpression* _tmp16_;
301 _tmp13_ = vala_for_statement_get_condition (self);
302 _tmp14_ = _tmp13_;
303 vala_code_node_accept ((ValaCodeNode*) _tmp14_, visitor);
304 _tmp15_ = vala_for_statement_get_condition (self);
305 _tmp16_ = _tmp15_;
306 vala_code_visitor_visit_end_full_expression (visitor, _tmp16_);
307 }
308 {
309 ValaList* _it_expr_list = NULL;
310 ValaList* _tmp17_;
311 ValaList* _tmp18_;
312 gint _it_expr_size = 0;
313 ValaList* _tmp19_;
314 gint _tmp20_;
315 gint _tmp21_;
316 gint _it_expr_index = 0;
317 _tmp17_ = self->priv->iterator;
318 _tmp18_ = _vala_iterable_ref0 (_tmp17_);
319 _it_expr_list = _tmp18_;
320 _tmp19_ = _it_expr_list;
321 _tmp20_ = vala_collection_get_size ((ValaCollection*) _tmp19_);
322 _tmp21_ = _tmp20_;
323 _it_expr_size = _tmp21_;
324 _it_expr_index = -1;
325 while (TRUE) {
326 gint _tmp22_;
327 gint _tmp23_;
328 ValaExpression* it_expr = NULL;
329 ValaList* _tmp24_;
330 gpointer _tmp25_;
331 ValaExpression* _tmp26_;
332 ValaExpression* _tmp27_;
333 _it_expr_index = _it_expr_index + 1;
334 _tmp22_ = _it_expr_index;
335 _tmp23_ = _it_expr_size;
336 if (!(_tmp22_ < _tmp23_)) {
337 break;
338 }
339 _tmp24_ = _it_expr_list;
340 _tmp25_ = vala_list_get (_tmp24_, _it_expr_index);
341 it_expr = (ValaExpression*) _tmp25_;
342 _tmp26_ = it_expr;
343 vala_code_node_accept ((ValaCodeNode*) _tmp26_, visitor);
344 _tmp27_ = it_expr;
345 vala_code_visitor_visit_end_full_expression (visitor, _tmp27_);
346 _vala_code_node_unref0 (it_expr);
347 }
348 _vala_iterable_unref0 (_it_expr_list);
349 }
350 _tmp28_ = vala_for_statement_get_body (self);
351 _tmp29_ = _tmp28_;
352 vala_code_node_accept ((ValaCodeNode*) _tmp29_, visitor);
353 }
354
355 static void
vala_for_statement_real_replace_expression(ValaCodeNode * base,ValaExpression * old_node,ValaExpression * new_node)356 vala_for_statement_real_replace_expression (ValaCodeNode* base,
357 ValaExpression* old_node,
358 ValaExpression* new_node)
359 {
360 ValaForStatement * self;
361 ValaExpression* _tmp0_;
362 ValaExpression* _tmp1_;
363 self = (ValaForStatement*) base;
364 g_return_if_fail (old_node != NULL);
365 g_return_if_fail (new_node != NULL);
366 _tmp0_ = vala_for_statement_get_condition (self);
367 _tmp1_ = _tmp0_;
368 if (_tmp1_ == old_node) {
369 vala_for_statement_set_condition (self, new_node);
370 }
371 {
372 gint i = 0;
373 i = 0;
374 {
375 gboolean _tmp2_ = FALSE;
376 _tmp2_ = TRUE;
377 while (TRUE) {
378 ValaList* _tmp4_;
379 gint _tmp5_;
380 gint _tmp6_;
381 ValaList* _tmp7_;
382 gpointer _tmp8_;
383 ValaExpression* _tmp9_;
384 gboolean _tmp10_;
385 if (!_tmp2_) {
386 gint _tmp3_;
387 _tmp3_ = i;
388 i = _tmp3_ + 1;
389 }
390 _tmp2_ = FALSE;
391 _tmp4_ = self->priv->initializer;
392 _tmp5_ = vala_collection_get_size ((ValaCollection*) _tmp4_);
393 _tmp6_ = _tmp5_;
394 if (!(i < _tmp6_)) {
395 break;
396 }
397 _tmp7_ = self->priv->initializer;
398 _tmp8_ = vala_list_get (_tmp7_, i);
399 _tmp9_ = (ValaExpression*) _tmp8_;
400 _tmp10_ = _tmp9_ == old_node;
401 _vala_code_node_unref0 (_tmp9_);
402 if (_tmp10_) {
403 ValaList* _tmp11_;
404 _tmp11_ = self->priv->initializer;
405 vala_list_set (_tmp11_, i, new_node);
406 vala_code_node_set_parent_node ((ValaCodeNode*) new_node, (ValaCodeNode*) self);
407 }
408 }
409 }
410 }
411 {
412 gint i = 0;
413 i = 0;
414 {
415 gboolean _tmp12_ = FALSE;
416 _tmp12_ = TRUE;
417 while (TRUE) {
418 ValaList* _tmp14_;
419 gint _tmp15_;
420 gint _tmp16_;
421 ValaList* _tmp17_;
422 gpointer _tmp18_;
423 ValaExpression* _tmp19_;
424 gboolean _tmp20_;
425 if (!_tmp12_) {
426 gint _tmp13_;
427 _tmp13_ = i;
428 i = _tmp13_ + 1;
429 }
430 _tmp12_ = FALSE;
431 _tmp14_ = self->priv->iterator;
432 _tmp15_ = vala_collection_get_size ((ValaCollection*) _tmp14_);
433 _tmp16_ = _tmp15_;
434 if (!(i < _tmp16_)) {
435 break;
436 }
437 _tmp17_ = self->priv->iterator;
438 _tmp18_ = vala_list_get (_tmp17_, i);
439 _tmp19_ = (ValaExpression*) _tmp18_;
440 _tmp20_ = _tmp19_ == old_node;
441 _vala_code_node_unref0 (_tmp19_);
442 if (_tmp20_) {
443 ValaList* _tmp21_;
444 _tmp21_ = self->priv->iterator;
445 vala_list_set (_tmp21_, i, new_node);
446 vala_code_node_set_parent_node ((ValaCodeNode*) new_node, (ValaCodeNode*) self);
447 }
448 }
449 }
450 }
451 }
452
453 static gboolean
vala_for_statement_always_true(ValaForStatement * self,ValaExpression * condition)454 vala_for_statement_always_true (ValaForStatement* self,
455 ValaExpression* condition)
456 {
457 ValaBooleanLiteral* literal = NULL;
458 gboolean _tmp0_ = FALSE;
459 ValaBooleanLiteral* _tmp1_;
460 gboolean result = FALSE;
461 g_return_val_if_fail (self != NULL, FALSE);
462 g_return_val_if_fail (condition != NULL, FALSE);
463 literal = VALA_IS_BOOLEAN_LITERAL (condition) ? ((ValaBooleanLiteral*) condition) : NULL;
464 _tmp1_ = literal;
465 if (_tmp1_ != NULL) {
466 ValaBooleanLiteral* _tmp2_;
467 gboolean _tmp3_;
468 gboolean _tmp4_;
469 _tmp2_ = literal;
470 _tmp3_ = vala_boolean_literal_get_value (_tmp2_);
471 _tmp4_ = _tmp3_;
472 _tmp0_ = _tmp4_;
473 } else {
474 _tmp0_ = FALSE;
475 }
476 result = _tmp0_;
477 return result;
478 }
479
480 static gboolean
vala_for_statement_always_false(ValaForStatement * self,ValaExpression * condition)481 vala_for_statement_always_false (ValaForStatement* self,
482 ValaExpression* condition)
483 {
484 ValaBooleanLiteral* literal = NULL;
485 gboolean _tmp0_ = FALSE;
486 ValaBooleanLiteral* _tmp1_;
487 gboolean result = FALSE;
488 g_return_val_if_fail (self != NULL, FALSE);
489 g_return_val_if_fail (condition != NULL, FALSE);
490 literal = VALA_IS_BOOLEAN_LITERAL (condition) ? ((ValaBooleanLiteral*) condition) : NULL;
491 _tmp1_ = literal;
492 if (_tmp1_ != NULL) {
493 ValaBooleanLiteral* _tmp2_;
494 gboolean _tmp3_;
495 gboolean _tmp4_;
496 _tmp2_ = literal;
497 _tmp3_ = vala_boolean_literal_get_value (_tmp2_);
498 _tmp4_ = _tmp3_;
499 _tmp0_ = !_tmp4_;
500 } else {
501 _tmp0_ = FALSE;
502 }
503 result = _tmp0_;
504 return result;
505 }
506
507 static gboolean
vala_for_statement_real_check(ValaCodeNode * base,ValaCodeContext * context)508 vala_for_statement_real_check (ValaCodeNode* base,
509 ValaCodeContext* context)
510 {
511 ValaForStatement * self;
512 gboolean _tmp0_;
513 gboolean _tmp1_;
514 ValaBlock* block = NULL;
515 ValaSourceReference* _tmp4_;
516 ValaSourceReference* _tmp5_;
517 ValaBlock* _tmp6_;
518 gboolean _tmp23_ = FALSE;
519 ValaExpression* _tmp24_;
520 ValaExpression* _tmp25_;
521 ValaLocalVariable* first_local = NULL;
522 ValaSemanticAnalyzer* _tmp67_;
523 ValaSemanticAnalyzer* _tmp68_;
524 ValaDataType* _tmp69_;
525 ValaDataType* _tmp70_;
526 ValaDataType* _tmp71_;
527 gchar* _tmp72_;
528 gchar* _tmp73_;
529 ValaSourceReference* _tmp74_;
530 ValaSourceReference* _tmp75_;
531 ValaBooleanLiteral* _tmp76_;
532 ValaBooleanLiteral* _tmp77_;
533 ValaSourceReference* _tmp78_;
534 ValaSourceReference* _tmp79_;
535 ValaLocalVariable* _tmp80_;
536 ValaLocalVariable* _tmp81_;
537 ValaBlock* _tmp82_;
538 ValaLocalVariable* _tmp83_;
539 ValaSourceReference* _tmp84_;
540 ValaSourceReference* _tmp85_;
541 ValaDeclarationStatement* _tmp86_;
542 ValaDeclarationStatement* _tmp87_;
543 ValaBlock* iterator_block = NULL;
544 ValaSourceReference* _tmp88_;
545 ValaSourceReference* _tmp89_;
546 ValaBlock* _tmp90_;
547 ValaIfStatement* first_if = NULL;
548 ValaLocalVariable* _tmp107_;
549 const gchar* _tmp108_;
550 const gchar* _tmp109_;
551 ValaSourceReference* _tmp110_;
552 ValaSourceReference* _tmp111_;
553 ValaMemberAccess* _tmp112_;
554 ValaMemberAccess* _tmp113_;
555 ValaSourceReference* _tmp114_;
556 ValaSourceReference* _tmp115_;
557 ValaUnaryExpression* _tmp116_;
558 ValaUnaryExpression* _tmp117_;
559 ValaBlock* _tmp118_;
560 ValaSourceReference* _tmp119_;
561 ValaSourceReference* _tmp120_;
562 ValaIfStatement* _tmp121_;
563 ValaIfStatement* _tmp122_;
564 ValaBlock* _tmp123_;
565 ValaBlock* _tmp124_;
566 ValaIfStatement* _tmp125_;
567 ValaBlock* _tmp126_;
568 ValaBlock* _tmp127_;
569 ValaLocalVariable* _tmp128_;
570 const gchar* _tmp129_;
571 const gchar* _tmp130_;
572 ValaSourceReference* _tmp131_;
573 ValaSourceReference* _tmp132_;
574 ValaMemberAccess* _tmp133_;
575 ValaMemberAccess* _tmp134_;
576 ValaSourceReference* _tmp135_;
577 ValaSourceReference* _tmp136_;
578 ValaBooleanLiteral* _tmp137_;
579 ValaBooleanLiteral* _tmp138_;
580 ValaSourceReference* _tmp139_;
581 ValaSourceReference* _tmp140_;
582 ValaAssignment* _tmp141_;
583 ValaAssignment* _tmp142_;
584 ValaSourceReference* _tmp143_;
585 ValaSourceReference* _tmp144_;
586 ValaExpressionStatement* _tmp145_;
587 ValaExpressionStatement* _tmp146_;
588 ValaBlock* _tmp147_;
589 ValaBlock* _tmp148_;
590 ValaBlock* _tmp149_;
591 ValaSourceReference* _tmp150_;
592 ValaSourceReference* _tmp151_;
593 ValaLoop* _tmp152_;
594 ValaLoop* _tmp153_;
595 ValaBlock* parent_block = NULL;
596 ValaCodeNode* _tmp154_;
597 ValaCodeNode* _tmp155_;
598 ValaBlock* _tmp156_;
599 ValaBlock* _tmp157_;
600 ValaBlock* _tmp158_;
601 gboolean _tmp159_;
602 gboolean _tmp160_;
603 gboolean result = FALSE;
604 self = (ValaForStatement*) base;
605 g_return_val_if_fail (context != NULL, FALSE);
606 _tmp0_ = vala_code_node_get_checked ((ValaCodeNode*) self);
607 _tmp1_ = _tmp0_;
608 if (_tmp1_) {
609 gboolean _tmp2_;
610 gboolean _tmp3_;
611 _tmp2_ = vala_code_node_get_error ((ValaCodeNode*) self);
612 _tmp3_ = _tmp2_;
613 result = !_tmp3_;
614 return result;
615 }
616 vala_code_node_set_checked ((ValaCodeNode*) self, TRUE);
617 _tmp4_ = vala_code_node_get_source_reference ((ValaCodeNode*) self);
618 _tmp5_ = _tmp4_;
619 _tmp6_ = vala_block_new (_tmp5_);
620 block = _tmp6_;
621 {
622 ValaList* _init_expr_list = NULL;
623 ValaList* _tmp7_;
624 ValaList* _tmp8_;
625 gint _init_expr_size = 0;
626 ValaList* _tmp9_;
627 gint _tmp10_;
628 gint _tmp11_;
629 gint _init_expr_index = 0;
630 _tmp7_ = self->priv->initializer;
631 _tmp8_ = _vala_iterable_ref0 (_tmp7_);
632 _init_expr_list = _tmp8_;
633 _tmp9_ = _init_expr_list;
634 _tmp10_ = vala_collection_get_size ((ValaCollection*) _tmp9_);
635 _tmp11_ = _tmp10_;
636 _init_expr_size = _tmp11_;
637 _init_expr_index = -1;
638 while (TRUE) {
639 gint _tmp12_;
640 gint _tmp13_;
641 ValaExpression* init_expr = NULL;
642 ValaList* _tmp14_;
643 gpointer _tmp15_;
644 ValaBlock* _tmp16_;
645 ValaExpression* _tmp17_;
646 ValaExpression* _tmp18_;
647 ValaSourceReference* _tmp19_;
648 ValaSourceReference* _tmp20_;
649 ValaExpressionStatement* _tmp21_;
650 ValaExpressionStatement* _tmp22_;
651 _init_expr_index = _init_expr_index + 1;
652 _tmp12_ = _init_expr_index;
653 _tmp13_ = _init_expr_size;
654 if (!(_tmp12_ < _tmp13_)) {
655 break;
656 }
657 _tmp14_ = _init_expr_list;
658 _tmp15_ = vala_list_get (_tmp14_, _init_expr_index);
659 init_expr = (ValaExpression*) _tmp15_;
660 _tmp16_ = block;
661 _tmp17_ = init_expr;
662 _tmp18_ = init_expr;
663 _tmp19_ = vala_code_node_get_source_reference ((ValaCodeNode*) _tmp18_);
664 _tmp20_ = _tmp19_;
665 _tmp21_ = vala_expression_statement_new (_tmp17_, _tmp20_);
666 _tmp22_ = _tmp21_;
667 vala_block_add_statement (_tmp16_, (ValaStatement*) _tmp22_);
668 _vala_code_node_unref0 (_tmp22_);
669 _vala_code_node_unref0 (init_expr);
670 }
671 _vala_iterable_unref0 (_init_expr_list);
672 }
673 _tmp24_ = vala_for_statement_get_condition (self);
674 _tmp25_ = _tmp24_;
675 if (_tmp25_ == NULL) {
676 _tmp23_ = TRUE;
677 } else {
678 ValaExpression* _tmp26_;
679 ValaExpression* _tmp27_;
680 _tmp26_ = vala_for_statement_get_condition (self);
681 _tmp27_ = _tmp26_;
682 _tmp23_ = vala_for_statement_always_true (self, _tmp27_);
683 }
684 if (_tmp23_) {
685 } else {
686 ValaExpression* _tmp28_;
687 ValaExpression* _tmp29_;
688 _tmp28_ = vala_for_statement_get_condition (self);
689 _tmp29_ = _tmp28_;
690 if (vala_for_statement_always_false (self, _tmp29_)) {
691 ValaBlock* _tmp30_;
692 ValaBlock* _tmp31_;
693 ValaExpression* _tmp32_;
694 ValaExpression* _tmp33_;
695 ValaSourceReference* _tmp34_;
696 ValaSourceReference* _tmp35_;
697 ValaBreakStatement* _tmp36_;
698 ValaBreakStatement* _tmp37_;
699 _tmp30_ = vala_for_statement_get_body (self);
700 _tmp31_ = _tmp30_;
701 _tmp32_ = vala_for_statement_get_condition (self);
702 _tmp33_ = _tmp32_;
703 _tmp34_ = vala_code_node_get_source_reference ((ValaCodeNode*) _tmp33_);
704 _tmp35_ = _tmp34_;
705 _tmp36_ = vala_break_statement_new (_tmp35_);
706 _tmp37_ = _tmp36_;
707 vala_block_insert_statement (_tmp31_, 0, (ValaStatement*) _tmp37_);
708 _vala_code_node_unref0 (_tmp37_);
709 } else {
710 ValaUnaryExpression* if_condition = NULL;
711 ValaExpression* _tmp38_;
712 ValaExpression* _tmp39_;
713 ValaExpression* _tmp40_;
714 ValaExpression* _tmp41_;
715 ValaSourceReference* _tmp42_;
716 ValaSourceReference* _tmp43_;
717 ValaUnaryExpression* _tmp44_;
718 ValaBlock* true_block = NULL;
719 ValaExpression* _tmp45_;
720 ValaExpression* _tmp46_;
721 ValaSourceReference* _tmp47_;
722 ValaSourceReference* _tmp48_;
723 ValaBlock* _tmp49_;
724 ValaBlock* _tmp50_;
725 ValaExpression* _tmp51_;
726 ValaExpression* _tmp52_;
727 ValaSourceReference* _tmp53_;
728 ValaSourceReference* _tmp54_;
729 ValaBreakStatement* _tmp55_;
730 ValaBreakStatement* _tmp56_;
731 ValaIfStatement* if_stmt = NULL;
732 ValaUnaryExpression* _tmp57_;
733 ValaBlock* _tmp58_;
734 ValaExpression* _tmp59_;
735 ValaExpression* _tmp60_;
736 ValaSourceReference* _tmp61_;
737 ValaSourceReference* _tmp62_;
738 ValaIfStatement* _tmp63_;
739 ValaBlock* _tmp64_;
740 ValaBlock* _tmp65_;
741 ValaIfStatement* _tmp66_;
742 _tmp38_ = vala_for_statement_get_condition (self);
743 _tmp39_ = _tmp38_;
744 _tmp40_ = vala_for_statement_get_condition (self);
745 _tmp41_ = _tmp40_;
746 _tmp42_ = vala_code_node_get_source_reference ((ValaCodeNode*) _tmp41_);
747 _tmp43_ = _tmp42_;
748 _tmp44_ = vala_unary_expression_new (VALA_UNARY_OPERATOR_LOGICAL_NEGATION, _tmp39_, _tmp43_);
749 if_condition = _tmp44_;
750 _tmp45_ = vala_for_statement_get_condition (self);
751 _tmp46_ = _tmp45_;
752 _tmp47_ = vala_code_node_get_source_reference ((ValaCodeNode*) _tmp46_);
753 _tmp48_ = _tmp47_;
754 _tmp49_ = vala_block_new (_tmp48_);
755 true_block = _tmp49_;
756 _tmp50_ = true_block;
757 _tmp51_ = vala_for_statement_get_condition (self);
758 _tmp52_ = _tmp51_;
759 _tmp53_ = vala_code_node_get_source_reference ((ValaCodeNode*) _tmp52_);
760 _tmp54_ = _tmp53_;
761 _tmp55_ = vala_break_statement_new (_tmp54_);
762 _tmp56_ = _tmp55_;
763 vala_block_add_statement (_tmp50_, (ValaStatement*) _tmp56_);
764 _vala_code_node_unref0 (_tmp56_);
765 _tmp57_ = if_condition;
766 _tmp58_ = true_block;
767 _tmp59_ = vala_for_statement_get_condition (self);
768 _tmp60_ = _tmp59_;
769 _tmp61_ = vala_code_node_get_source_reference ((ValaCodeNode*) _tmp60_);
770 _tmp62_ = _tmp61_;
771 _tmp63_ = vala_if_statement_new ((ValaExpression*) _tmp57_, _tmp58_, NULL, _tmp62_);
772 if_stmt = _tmp63_;
773 _tmp64_ = vala_for_statement_get_body (self);
774 _tmp65_ = _tmp64_;
775 _tmp66_ = if_stmt;
776 vala_block_insert_statement (_tmp65_, 0, (ValaStatement*) _tmp66_);
777 _vala_code_node_unref0 (if_stmt);
778 _vala_code_node_unref0 (true_block);
779 _vala_code_node_unref0 (if_condition);
780 }
781 }
782 _tmp67_ = vala_code_context_get_analyzer (context);
783 _tmp68_ = _tmp67_;
784 _tmp69_ = _tmp68_->bool_type;
785 _tmp70_ = vala_data_type_copy (_tmp69_);
786 _tmp71_ = _tmp70_;
787 _tmp72_ = vala_code_node_get_temp_name ();
788 _tmp73_ = _tmp72_;
789 _tmp74_ = vala_code_node_get_source_reference ((ValaCodeNode*) self);
790 _tmp75_ = _tmp74_;
791 _tmp76_ = vala_boolean_literal_new (TRUE, _tmp75_);
792 _tmp77_ = _tmp76_;
793 _tmp78_ = vala_code_node_get_source_reference ((ValaCodeNode*) self);
794 _tmp79_ = _tmp78_;
795 _tmp80_ = vala_local_variable_new (_tmp71_, _tmp73_, (ValaExpression*) _tmp77_, _tmp79_);
796 _tmp81_ = _tmp80_;
797 _vala_code_node_unref0 (_tmp77_);
798 _g_free0 (_tmp73_);
799 _vala_code_node_unref0 (_tmp71_);
800 first_local = _tmp81_;
801 _tmp82_ = block;
802 _tmp83_ = first_local;
803 _tmp84_ = vala_code_node_get_source_reference ((ValaCodeNode*) self);
804 _tmp85_ = _tmp84_;
805 _tmp86_ = vala_declaration_statement_new ((ValaSymbol*) _tmp83_, _tmp85_);
806 _tmp87_ = _tmp86_;
807 vala_block_add_statement (_tmp82_, (ValaStatement*) _tmp87_);
808 _vala_code_node_unref0 (_tmp87_);
809 _tmp88_ = vala_code_node_get_source_reference ((ValaCodeNode*) self);
810 _tmp89_ = _tmp88_;
811 _tmp90_ = vala_block_new (_tmp89_);
812 iterator_block = _tmp90_;
813 {
814 ValaList* _it_expr_list = NULL;
815 ValaList* _tmp91_;
816 ValaList* _tmp92_;
817 gint _it_expr_size = 0;
818 ValaList* _tmp93_;
819 gint _tmp94_;
820 gint _tmp95_;
821 gint _it_expr_index = 0;
822 _tmp91_ = self->priv->iterator;
823 _tmp92_ = _vala_iterable_ref0 (_tmp91_);
824 _it_expr_list = _tmp92_;
825 _tmp93_ = _it_expr_list;
826 _tmp94_ = vala_collection_get_size ((ValaCollection*) _tmp93_);
827 _tmp95_ = _tmp94_;
828 _it_expr_size = _tmp95_;
829 _it_expr_index = -1;
830 while (TRUE) {
831 gint _tmp96_;
832 gint _tmp97_;
833 ValaExpression* it_expr = NULL;
834 ValaList* _tmp98_;
835 gpointer _tmp99_;
836 ValaBlock* _tmp100_;
837 ValaExpression* _tmp101_;
838 ValaExpression* _tmp102_;
839 ValaSourceReference* _tmp103_;
840 ValaSourceReference* _tmp104_;
841 ValaExpressionStatement* _tmp105_;
842 ValaExpressionStatement* _tmp106_;
843 _it_expr_index = _it_expr_index + 1;
844 _tmp96_ = _it_expr_index;
845 _tmp97_ = _it_expr_size;
846 if (!(_tmp96_ < _tmp97_)) {
847 break;
848 }
849 _tmp98_ = _it_expr_list;
850 _tmp99_ = vala_list_get (_tmp98_, _it_expr_index);
851 it_expr = (ValaExpression*) _tmp99_;
852 _tmp100_ = iterator_block;
853 _tmp101_ = it_expr;
854 _tmp102_ = it_expr;
855 _tmp103_ = vala_code_node_get_source_reference ((ValaCodeNode*) _tmp102_);
856 _tmp104_ = _tmp103_;
857 _tmp105_ = vala_expression_statement_new (_tmp101_, _tmp104_);
858 _tmp106_ = _tmp105_;
859 vala_block_add_statement (_tmp100_, (ValaStatement*) _tmp106_);
860 _vala_code_node_unref0 (_tmp106_);
861 _vala_code_node_unref0 (it_expr);
862 }
863 _vala_iterable_unref0 (_it_expr_list);
864 }
865 _tmp107_ = first_local;
866 _tmp108_ = vala_symbol_get_name ((ValaSymbol*) _tmp107_);
867 _tmp109_ = _tmp108_;
868 _tmp110_ = vala_code_node_get_source_reference ((ValaCodeNode*) self);
869 _tmp111_ = _tmp110_;
870 _tmp112_ = vala_member_access_new_simple (_tmp109_, _tmp111_);
871 _tmp113_ = _tmp112_;
872 _tmp114_ = vala_code_node_get_source_reference ((ValaCodeNode*) self);
873 _tmp115_ = _tmp114_;
874 _tmp116_ = vala_unary_expression_new (VALA_UNARY_OPERATOR_LOGICAL_NEGATION, (ValaExpression*) _tmp113_, _tmp115_);
875 _tmp117_ = _tmp116_;
876 _tmp118_ = iterator_block;
877 _tmp119_ = vala_code_node_get_source_reference ((ValaCodeNode*) self);
878 _tmp120_ = _tmp119_;
879 _tmp121_ = vala_if_statement_new ((ValaExpression*) _tmp117_, _tmp118_, NULL, _tmp120_);
880 _tmp122_ = _tmp121_;
881 _vala_code_node_unref0 (_tmp117_);
882 _vala_code_node_unref0 (_tmp113_);
883 first_if = _tmp122_;
884 _tmp123_ = vala_for_statement_get_body (self);
885 _tmp124_ = _tmp123_;
886 _tmp125_ = first_if;
887 vala_block_insert_statement (_tmp124_, 0, (ValaStatement*) _tmp125_);
888 _tmp126_ = vala_for_statement_get_body (self);
889 _tmp127_ = _tmp126_;
890 _tmp128_ = first_local;
891 _tmp129_ = vala_symbol_get_name ((ValaSymbol*) _tmp128_);
892 _tmp130_ = _tmp129_;
893 _tmp131_ = vala_code_node_get_source_reference ((ValaCodeNode*) self);
894 _tmp132_ = _tmp131_;
895 _tmp133_ = vala_member_access_new_simple (_tmp130_, _tmp132_);
896 _tmp134_ = _tmp133_;
897 _tmp135_ = vala_code_node_get_source_reference ((ValaCodeNode*) self);
898 _tmp136_ = _tmp135_;
899 _tmp137_ = vala_boolean_literal_new (FALSE, _tmp136_);
900 _tmp138_ = _tmp137_;
901 _tmp139_ = vala_code_node_get_source_reference ((ValaCodeNode*) self);
902 _tmp140_ = _tmp139_;
903 _tmp141_ = vala_assignment_new ((ValaExpression*) _tmp134_, (ValaExpression*) _tmp138_, VALA_ASSIGNMENT_OPERATOR_SIMPLE, _tmp140_);
904 _tmp142_ = _tmp141_;
905 _tmp143_ = vala_code_node_get_source_reference ((ValaCodeNode*) self);
906 _tmp144_ = _tmp143_;
907 _tmp145_ = vala_expression_statement_new ((ValaExpression*) _tmp142_, _tmp144_);
908 _tmp146_ = _tmp145_;
909 vala_block_insert_statement (_tmp127_, 1, (ValaStatement*) _tmp146_);
910 _vala_code_node_unref0 (_tmp146_);
911 _vala_code_node_unref0 (_tmp142_);
912 _vala_code_node_unref0 (_tmp138_);
913 _vala_code_node_unref0 (_tmp134_);
914 _tmp147_ = block;
915 _tmp148_ = vala_for_statement_get_body (self);
916 _tmp149_ = _tmp148_;
917 _tmp150_ = vala_code_node_get_source_reference ((ValaCodeNode*) self);
918 _tmp151_ = _tmp150_;
919 _tmp152_ = vala_loop_new (_tmp149_, _tmp151_);
920 _tmp153_ = _tmp152_;
921 vala_block_add_statement (_tmp147_, (ValaStatement*) _tmp153_);
922 _vala_code_node_unref0 (_tmp153_);
923 _tmp154_ = vala_code_node_get_parent_node ((ValaCodeNode*) self);
924 _tmp155_ = _tmp154_;
925 parent_block = G_TYPE_CHECK_INSTANCE_CAST (_tmp155_, VALA_TYPE_BLOCK, ValaBlock);
926 _tmp156_ = parent_block;
927 _tmp157_ = block;
928 vala_block_replace_statement (_tmp156_, (ValaStatement*) self, (ValaStatement*) _tmp157_);
929 _tmp158_ = block;
930 if (!vala_code_node_check ((ValaCodeNode*) _tmp158_, context)) {
931 vala_code_node_set_error ((ValaCodeNode*) self, TRUE);
932 }
933 _tmp159_ = vala_code_node_get_error ((ValaCodeNode*) self);
934 _tmp160_ = _tmp159_;
935 result = !_tmp160_;
936 _vala_code_node_unref0 (first_if);
937 _vala_code_node_unref0 (iterator_block);
938 _vala_code_node_unref0 (first_local);
939 _vala_code_node_unref0 (block);
940 return result;
941 }
942
943 static void
vala_for_statement_class_init(ValaForStatementClass * klass,gpointer klass_data)944 vala_for_statement_class_init (ValaForStatementClass * klass,
945 gpointer klass_data)
946 {
947 vala_for_statement_parent_class = g_type_class_peek_parent (klass);
948 ((ValaCodeNodeClass *) klass)->finalize = vala_for_statement_finalize;
949 g_type_class_adjust_private_offset (klass, &ValaForStatement_private_offset);
950 ((ValaCodeNodeClass *) klass)->accept = (void (*) (ValaCodeNode*, ValaCodeVisitor*)) vala_for_statement_real_accept;
951 ((ValaCodeNodeClass *) klass)->accept_children = (void (*) (ValaCodeNode*, ValaCodeVisitor*)) vala_for_statement_real_accept_children;
952 ((ValaCodeNodeClass *) klass)->replace_expression = (void (*) (ValaCodeNode*, ValaExpression*, ValaExpression*)) vala_for_statement_real_replace_expression;
953 ((ValaCodeNodeClass *) klass)->check = (gboolean (*) (ValaCodeNode*, ValaCodeContext*)) vala_for_statement_real_check;
954 }
955
956 static void
vala_for_statement_vala_statement_interface_init(ValaStatementIface * iface,gpointer iface_data)957 vala_for_statement_vala_statement_interface_init (ValaStatementIface * iface,
958 gpointer iface_data)
959 {
960 vala_for_statement_vala_statement_parent_iface = g_type_interface_peek_parent (iface);
961 }
962
963 static void
vala_for_statement_instance_init(ValaForStatement * self,gpointer klass)964 vala_for_statement_instance_init (ValaForStatement * self,
965 gpointer klass)
966 {
967 GEqualFunc _tmp0_;
968 ValaArrayList* _tmp1_;
969 GEqualFunc _tmp2_;
970 ValaArrayList* _tmp3_;
971 self->priv = vala_for_statement_get_instance_private (self);
972 _tmp0_ = g_direct_equal;
973 _tmp1_ = vala_array_list_new (VALA_TYPE_EXPRESSION, (GBoxedCopyFunc) vala_code_node_ref, (GDestroyNotify) vala_code_node_unref, _tmp0_);
974 self->priv->initializer = (ValaList*) _tmp1_;
975 _tmp2_ = g_direct_equal;
976 _tmp3_ = vala_array_list_new (VALA_TYPE_EXPRESSION, (GBoxedCopyFunc) vala_code_node_ref, (GDestroyNotify) vala_code_node_unref, _tmp2_);
977 self->priv->iterator = (ValaList*) _tmp3_;
978 }
979
980 static void
vala_for_statement_finalize(ValaCodeNode * obj)981 vala_for_statement_finalize (ValaCodeNode * obj)
982 {
983 ValaForStatement * self;
984 self = G_TYPE_CHECK_INSTANCE_CAST (obj, VALA_TYPE_FOR_STATEMENT, ValaForStatement);
985 _vala_iterable_unref0 (self->priv->initializer);
986 _vala_iterable_unref0 (self->priv->iterator);
987 _vala_code_node_unref0 (self->priv->_condition);
988 _vala_code_node_unref0 (self->priv->_body);
989 VALA_CODE_NODE_CLASS (vala_for_statement_parent_class)->finalize (obj);
990 }
991
992 /**
993 * Represents a for iteration statement in the source code.
994 */
995 static GType
vala_for_statement_get_type_once(void)996 vala_for_statement_get_type_once (void)
997 {
998 static const GTypeInfo g_define_type_info = { sizeof (ValaForStatementClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) vala_for_statement_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ValaForStatement), 0, (GInstanceInitFunc) vala_for_statement_instance_init, NULL };
999 static const GInterfaceInfo vala_statement_info = { (GInterfaceInitFunc) vala_for_statement_vala_statement_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
1000 GType vala_for_statement_type_id;
1001 vala_for_statement_type_id = g_type_register_static (VALA_TYPE_CODE_NODE, "ValaForStatement", &g_define_type_info, 0);
1002 g_type_add_interface_static (vala_for_statement_type_id, VALA_TYPE_STATEMENT, &vala_statement_info);
1003 ValaForStatement_private_offset = g_type_add_instance_private (vala_for_statement_type_id, sizeof (ValaForStatementPrivate));
1004 return vala_for_statement_type_id;
1005 }
1006
1007 GType
vala_for_statement_get_type(void)1008 vala_for_statement_get_type (void)
1009 {
1010 static volatile gsize vala_for_statement_type_id__volatile = 0;
1011 if (g_once_init_enter (&vala_for_statement_type_id__volatile)) {
1012 GType vala_for_statement_type_id;
1013 vala_for_statement_type_id = vala_for_statement_get_type_once ();
1014 g_once_init_leave (&vala_for_statement_type_id__volatile, vala_for_statement_type_id);
1015 }
1016 return vala_for_statement_type_id__volatile;
1017 }
1018
1019