1 /* valainitializerlist.c generated by valac, the Vala compiler
2 * generated from valainitializerlist.vala, do not modify */
3
4 /* valainitializerlist.vala
5 *
6 * Copyright (C) 2006-2011 Jürg Billeter
7 * Copyright (C) 2006-2008 Raffaele Sandrini
8 *
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
13
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
18
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22 *
23 * Author:
24 * Jürg Billeter <j@bitron.ch>
25 * Raffaele Sandrini <raffaele@sandrini.ch>
26 */
27
28 #include "vala.h"
29 #include <valagee.h>
30 #include <glib-object.h>
31 #include <glib.h>
32 #include <stdlib.h>
33 #include <string.h>
34
35 #define _vala_iterable_unref0(var) ((var == NULL) ? NULL : (var = (vala_iterable_unref (var), NULL)))
36 #define _vala_code_node_unref0(var) ((var == NULL) ? NULL : (var = (vala_code_node_unref (var), NULL)))
37 #define _g_free0(var) (var = (g_free (var), NULL))
38 #define _g_string_free0(var) ((var == NULL) ? NULL : (var = (g_string_free (var, TRUE), NULL)))
39 #define _vala_iterator_unref0(var) ((var == NULL) ? NULL : (var = (vala_iterator_unref (var), NULL)))
40
41 struct _ValaInitializerListPrivate {
42 ValaList* initializers;
43 };
44
45 static gint ValaInitializerList_private_offset;
46 static gpointer vala_initializer_list_parent_class = NULL;
47
48 static void vala_initializer_list_real_accept_children (ValaCodeNode* base,
49 ValaCodeVisitor* visitor);
50 static void vala_initializer_list_real_accept (ValaCodeNode* base,
51 ValaCodeVisitor* visitor);
52 static gboolean vala_initializer_list_real_is_constant (ValaExpression* base);
53 static gboolean vala_initializer_list_real_is_pure (ValaExpression* base);
54 static gboolean vala_initializer_list_real_is_accessible (ValaExpression* base,
55 ValaSymbol* sym);
56 static gchar* vala_initializer_list_real_to_string (ValaCodeNode* base);
57 static void vala_initializer_list_real_replace_expression (ValaCodeNode* base,
58 ValaExpression* old_node,
59 ValaExpression* new_node);
60 static gboolean vala_initializer_list_real_check (ValaCodeNode* base,
61 ValaCodeContext* context);
62 static void vala_initializer_list_real_emit (ValaCodeNode* base,
63 ValaCodeGenerator* codegen);
64 static void vala_initializer_list_real_get_used_variables (ValaCodeNode* base,
65 ValaCollection* collection);
66 static void vala_initializer_list_finalize (ValaCodeNode * obj);
67 static GType vala_initializer_list_get_type_once (void);
68
69 static inline gpointer
vala_initializer_list_get_instance_private(ValaInitializerList * self)70 vala_initializer_list_get_instance_private (ValaInitializerList* self)
71 {
72 return G_STRUCT_MEMBER_P (self, ValaInitializerList_private_offset);
73 }
74
75 /**
76 * Appends the specified expression to this initializer
77 *
78 * @param expr an expression
79 */
80 void
vala_initializer_list_append(ValaInitializerList * self,ValaExpression * expr)81 vala_initializer_list_append (ValaInitializerList* self,
82 ValaExpression* expr)
83 {
84 ValaList* _tmp0_;
85 g_return_if_fail (self != NULL);
86 g_return_if_fail (expr != NULL);
87 _tmp0_ = self->priv->initializers;
88 vala_collection_add ((ValaCollection*) _tmp0_, expr);
89 vala_code_node_set_parent_node ((ValaCodeNode*) expr, (ValaCodeNode*) self);
90 }
91
92 /**
93 * Returns the initializer expression list
94 *
95 * @return expression list
96 */
97 ValaList*
vala_initializer_list_get_initializers(ValaInitializerList * self)98 vala_initializer_list_get_initializers (ValaInitializerList* self)
99 {
100 ValaList* _tmp0_;
101 ValaList* result = NULL;
102 g_return_val_if_fail (self != NULL, NULL);
103 _tmp0_ = self->priv->initializers;
104 result = _tmp0_;
105 return result;
106 }
107
108 gint
vala_initializer_list_get_size(ValaInitializerList * self)109 vala_initializer_list_get_size (ValaInitializerList* self)
110 {
111 gint result;
112 ValaList* _tmp0_;
113 gint _tmp1_;
114 gint _tmp2_;
115 g_return_val_if_fail (self != NULL, 0);
116 _tmp0_ = self->priv->initializers;
117 _tmp1_ = vala_collection_get_size ((ValaCollection*) _tmp0_);
118 _tmp2_ = _tmp1_;
119 result = _tmp2_;
120 return result;
121 }
122
123 /**
124 * Creates a new initializer
125 *
126 * @param source_reference reference to source code
127 * @return newly created initializer list
128 */
129 ValaInitializerList*
vala_initializer_list_construct(GType object_type,ValaSourceReference * source_reference)130 vala_initializer_list_construct (GType object_type,
131 ValaSourceReference* source_reference)
132 {
133 ValaInitializerList* self = NULL;
134 self = (ValaInitializerList*) vala_expression_construct (object_type);
135 vala_code_node_set_source_reference ((ValaCodeNode*) self, source_reference);
136 return self;
137 }
138
139 ValaInitializerList*
vala_initializer_list_new(ValaSourceReference * source_reference)140 vala_initializer_list_new (ValaSourceReference* source_reference)
141 {
142 return vala_initializer_list_construct (VALA_TYPE_INITIALIZER_LIST, source_reference);
143 }
144
145 static gpointer
_vala_iterable_ref0(gpointer self)146 _vala_iterable_ref0 (gpointer self)
147 {
148 return self ? vala_iterable_ref (self) : NULL;
149 }
150
151 static void
vala_initializer_list_real_accept_children(ValaCodeNode * base,ValaCodeVisitor * visitor)152 vala_initializer_list_real_accept_children (ValaCodeNode* base,
153 ValaCodeVisitor* visitor)
154 {
155 ValaInitializerList * self;
156 self = (ValaInitializerList*) base;
157 g_return_if_fail (visitor != NULL);
158 {
159 ValaList* _expr_list = NULL;
160 ValaList* _tmp0_;
161 ValaList* _tmp1_;
162 gint _expr_size = 0;
163 ValaList* _tmp2_;
164 gint _tmp3_;
165 gint _tmp4_;
166 gint _expr_index = 0;
167 _tmp0_ = self->priv->initializers;
168 _tmp1_ = _vala_iterable_ref0 (_tmp0_);
169 _expr_list = _tmp1_;
170 _tmp2_ = _expr_list;
171 _tmp3_ = vala_collection_get_size ((ValaCollection*) _tmp2_);
172 _tmp4_ = _tmp3_;
173 _expr_size = _tmp4_;
174 _expr_index = -1;
175 while (TRUE) {
176 gint _tmp5_;
177 gint _tmp6_;
178 ValaExpression* expr = NULL;
179 ValaList* _tmp7_;
180 gpointer _tmp8_;
181 ValaExpression* _tmp9_;
182 _expr_index = _expr_index + 1;
183 _tmp5_ = _expr_index;
184 _tmp6_ = _expr_size;
185 if (!(_tmp5_ < _tmp6_)) {
186 break;
187 }
188 _tmp7_ = _expr_list;
189 _tmp8_ = vala_list_get (_tmp7_, _expr_index);
190 expr = (ValaExpression*) _tmp8_;
191 _tmp9_ = expr;
192 vala_code_node_accept ((ValaCodeNode*) _tmp9_, visitor);
193 _vala_code_node_unref0 (expr);
194 }
195 _vala_iterable_unref0 (_expr_list);
196 }
197 }
198
199 static void
vala_initializer_list_real_accept(ValaCodeNode * base,ValaCodeVisitor * visitor)200 vala_initializer_list_real_accept (ValaCodeNode* base,
201 ValaCodeVisitor* visitor)
202 {
203 ValaInitializerList * self;
204 self = (ValaInitializerList*) base;
205 g_return_if_fail (visitor != NULL);
206 vala_code_visitor_visit_initializer_list (visitor, self);
207 vala_code_visitor_visit_expression (visitor, (ValaExpression*) self);
208 }
209
210 static gboolean
vala_initializer_list_real_is_constant(ValaExpression * base)211 vala_initializer_list_real_is_constant (ValaExpression* base)
212 {
213 ValaInitializerList * self;
214 gboolean result = FALSE;
215 self = (ValaInitializerList*) base;
216 {
217 ValaList* _initializer_list = NULL;
218 ValaList* _tmp0_;
219 ValaList* _tmp1_;
220 gint _initializer_size = 0;
221 ValaList* _tmp2_;
222 gint _tmp3_;
223 gint _tmp4_;
224 gint _initializer_index = 0;
225 _tmp0_ = self->priv->initializers;
226 _tmp1_ = _vala_iterable_ref0 (_tmp0_);
227 _initializer_list = _tmp1_;
228 _tmp2_ = _initializer_list;
229 _tmp3_ = vala_collection_get_size ((ValaCollection*) _tmp2_);
230 _tmp4_ = _tmp3_;
231 _initializer_size = _tmp4_;
232 _initializer_index = -1;
233 while (TRUE) {
234 gint _tmp5_;
235 gint _tmp6_;
236 ValaExpression* initializer = NULL;
237 ValaList* _tmp7_;
238 gpointer _tmp8_;
239 ValaExpression* _tmp9_;
240 _initializer_index = _initializer_index + 1;
241 _tmp5_ = _initializer_index;
242 _tmp6_ = _initializer_size;
243 if (!(_tmp5_ < _tmp6_)) {
244 break;
245 }
246 _tmp7_ = _initializer_list;
247 _tmp8_ = vala_list_get (_tmp7_, _initializer_index);
248 initializer = (ValaExpression*) _tmp8_;
249 _tmp9_ = initializer;
250 if (!vala_expression_is_constant (_tmp9_)) {
251 result = FALSE;
252 _vala_code_node_unref0 (initializer);
253 _vala_iterable_unref0 (_initializer_list);
254 return result;
255 }
256 _vala_code_node_unref0 (initializer);
257 }
258 _vala_iterable_unref0 (_initializer_list);
259 }
260 result = TRUE;
261 return result;
262 }
263
264 static gboolean
vala_initializer_list_real_is_pure(ValaExpression * base)265 vala_initializer_list_real_is_pure (ValaExpression* base)
266 {
267 ValaInitializerList * self;
268 gboolean result = FALSE;
269 self = (ValaInitializerList*) base;
270 {
271 ValaList* _initializer_list = NULL;
272 ValaList* _tmp0_;
273 ValaList* _tmp1_;
274 gint _initializer_size = 0;
275 ValaList* _tmp2_;
276 gint _tmp3_;
277 gint _tmp4_;
278 gint _initializer_index = 0;
279 _tmp0_ = self->priv->initializers;
280 _tmp1_ = _vala_iterable_ref0 (_tmp0_);
281 _initializer_list = _tmp1_;
282 _tmp2_ = _initializer_list;
283 _tmp3_ = vala_collection_get_size ((ValaCollection*) _tmp2_);
284 _tmp4_ = _tmp3_;
285 _initializer_size = _tmp4_;
286 _initializer_index = -1;
287 while (TRUE) {
288 gint _tmp5_;
289 gint _tmp6_;
290 ValaExpression* initializer = NULL;
291 ValaList* _tmp7_;
292 gpointer _tmp8_;
293 ValaExpression* _tmp9_;
294 _initializer_index = _initializer_index + 1;
295 _tmp5_ = _initializer_index;
296 _tmp6_ = _initializer_size;
297 if (!(_tmp5_ < _tmp6_)) {
298 break;
299 }
300 _tmp7_ = _initializer_list;
301 _tmp8_ = vala_list_get (_tmp7_, _initializer_index);
302 initializer = (ValaExpression*) _tmp8_;
303 _tmp9_ = initializer;
304 if (!vala_expression_is_pure (_tmp9_)) {
305 result = FALSE;
306 _vala_code_node_unref0 (initializer);
307 _vala_iterable_unref0 (_initializer_list);
308 return result;
309 }
310 _vala_code_node_unref0 (initializer);
311 }
312 _vala_iterable_unref0 (_initializer_list);
313 }
314 result = TRUE;
315 return result;
316 }
317
318 static gboolean
vala_initializer_list_real_is_accessible(ValaExpression * base,ValaSymbol * sym)319 vala_initializer_list_real_is_accessible (ValaExpression* base,
320 ValaSymbol* sym)
321 {
322 ValaInitializerList * self;
323 gboolean result = FALSE;
324 self = (ValaInitializerList*) base;
325 g_return_val_if_fail (sym != NULL, FALSE);
326 {
327 ValaList* _initializer_list = NULL;
328 ValaList* _tmp0_;
329 ValaList* _tmp1_;
330 gint _initializer_size = 0;
331 ValaList* _tmp2_;
332 gint _tmp3_;
333 gint _tmp4_;
334 gint _initializer_index = 0;
335 _tmp0_ = self->priv->initializers;
336 _tmp1_ = _vala_iterable_ref0 (_tmp0_);
337 _initializer_list = _tmp1_;
338 _tmp2_ = _initializer_list;
339 _tmp3_ = vala_collection_get_size ((ValaCollection*) _tmp2_);
340 _tmp4_ = _tmp3_;
341 _initializer_size = _tmp4_;
342 _initializer_index = -1;
343 while (TRUE) {
344 gint _tmp5_;
345 gint _tmp6_;
346 ValaExpression* initializer = NULL;
347 ValaList* _tmp7_;
348 gpointer _tmp8_;
349 ValaExpression* _tmp9_;
350 _initializer_index = _initializer_index + 1;
351 _tmp5_ = _initializer_index;
352 _tmp6_ = _initializer_size;
353 if (!(_tmp5_ < _tmp6_)) {
354 break;
355 }
356 _tmp7_ = _initializer_list;
357 _tmp8_ = vala_list_get (_tmp7_, _initializer_index);
358 initializer = (ValaExpression*) _tmp8_;
359 _tmp9_ = initializer;
360 if (!vala_expression_is_accessible (_tmp9_, sym)) {
361 result = FALSE;
362 _vala_code_node_unref0 (initializer);
363 _vala_iterable_unref0 (_initializer_list);
364 return result;
365 }
366 _vala_code_node_unref0 (initializer);
367 }
368 _vala_iterable_unref0 (_initializer_list);
369 }
370 result = TRUE;
371 return result;
372 }
373
374 static gchar*
vala_initializer_list_real_to_string(ValaCodeNode * base)375 vala_initializer_list_real_to_string (ValaCodeNode* base)
376 {
377 ValaInitializerList * self;
378 GString* builder = NULL;
379 GString* _tmp0_;
380 gboolean first = FALSE;
381 GString* _tmp18_;
382 GString* _tmp19_;
383 const gchar* _tmp20_;
384 gchar* _tmp21_;
385 gchar* result = NULL;
386 self = (ValaInitializerList*) base;
387 _tmp0_ = g_string_new ("{");
388 builder = _tmp0_;
389 first = TRUE;
390 {
391 ValaList* _initializer_list = NULL;
392 ValaList* _tmp1_;
393 ValaList* _tmp2_;
394 gint _initializer_size = 0;
395 ValaList* _tmp3_;
396 gint _tmp4_;
397 gint _tmp5_;
398 gint _initializer_index = 0;
399 _tmp1_ = self->priv->initializers;
400 _tmp2_ = _vala_iterable_ref0 (_tmp1_);
401 _initializer_list = _tmp2_;
402 _tmp3_ = _initializer_list;
403 _tmp4_ = vala_collection_get_size ((ValaCollection*) _tmp3_);
404 _tmp5_ = _tmp4_;
405 _initializer_size = _tmp5_;
406 _initializer_index = -1;
407 while (TRUE) {
408 gint _tmp6_;
409 gint _tmp7_;
410 ValaExpression* initializer = NULL;
411 ValaList* _tmp8_;
412 gpointer _tmp9_;
413 _initializer_index = _initializer_index + 1;
414 _tmp6_ = _initializer_index;
415 _tmp7_ = _initializer_size;
416 if (!(_tmp6_ < _tmp7_)) {
417 break;
418 }
419 _tmp8_ = _initializer_list;
420 _tmp9_ = vala_list_get (_tmp8_, _initializer_index);
421 initializer = (ValaExpression*) _tmp9_;
422 if (first) {
423 GString* _tmp10_;
424 ValaExpression* _tmp11_;
425 gchar* _tmp12_;
426 gchar* _tmp13_;
427 _tmp10_ = builder;
428 _tmp11_ = initializer;
429 _tmp12_ = vala_code_node_to_string ((ValaCodeNode*) _tmp11_);
430 _tmp13_ = _tmp12_;
431 g_string_append (_tmp10_, _tmp13_);
432 _g_free0 (_tmp13_);
433 first = FALSE;
434 } else {
435 GString* _tmp14_;
436 ValaExpression* _tmp15_;
437 gchar* _tmp16_;
438 gchar* _tmp17_;
439 _tmp14_ = builder;
440 _tmp15_ = initializer;
441 _tmp16_ = vala_code_node_to_string ((ValaCodeNode*) _tmp15_);
442 _tmp17_ = _tmp16_;
443 g_string_append_printf (_tmp14_, ", %s", _tmp17_);
444 _g_free0 (_tmp17_);
445 }
446 _vala_code_node_unref0 (initializer);
447 }
448 _vala_iterable_unref0 (_initializer_list);
449 }
450 _tmp18_ = builder;
451 g_string_append_c (_tmp18_, '}');
452 _tmp19_ = builder;
453 _tmp20_ = _tmp19_->str;
454 _tmp21_ = g_strdup (_tmp20_);
455 result = _tmp21_;
456 _g_string_free0 (builder);
457 return result;
458 }
459
460 static void
vala_initializer_list_real_replace_expression(ValaCodeNode * base,ValaExpression * old_node,ValaExpression * new_node)461 vala_initializer_list_real_replace_expression (ValaCodeNode* base,
462 ValaExpression* old_node,
463 ValaExpression* new_node)
464 {
465 ValaInitializerList * self;
466 self = (ValaInitializerList*) base;
467 g_return_if_fail (old_node != NULL);
468 g_return_if_fail (new_node != NULL);
469 {
470 gint i = 0;
471 i = 0;
472 {
473 gboolean _tmp0_ = FALSE;
474 _tmp0_ = TRUE;
475 while (TRUE) {
476 ValaList* _tmp2_;
477 gint _tmp3_;
478 gint _tmp4_;
479 ValaList* _tmp5_;
480 gpointer _tmp6_;
481 ValaExpression* _tmp7_;
482 gboolean _tmp8_;
483 if (!_tmp0_) {
484 gint _tmp1_;
485 _tmp1_ = i;
486 i = _tmp1_ + 1;
487 }
488 _tmp0_ = FALSE;
489 _tmp2_ = self->priv->initializers;
490 _tmp3_ = vala_collection_get_size ((ValaCollection*) _tmp2_);
491 _tmp4_ = _tmp3_;
492 if (!(i < _tmp4_)) {
493 break;
494 }
495 _tmp5_ = self->priv->initializers;
496 _tmp6_ = vala_list_get (_tmp5_, i);
497 _tmp7_ = (ValaExpression*) _tmp6_;
498 _tmp8_ = _tmp7_ == old_node;
499 _vala_code_node_unref0 (_tmp7_);
500 if (_tmp8_) {
501 ValaList* _tmp9_;
502 _tmp9_ = self->priv->initializers;
503 vala_list_set (_tmp9_, i, new_node);
504 vala_code_node_set_parent_node ((ValaCodeNode*) new_node, (ValaCodeNode*) self);
505 }
506 }
507 }
508 }
509 }
510
511 static gpointer
_vala_code_node_ref0(gpointer self)512 _vala_code_node_ref0 (gpointer self)
513 {
514 return self ? vala_code_node_ref (self) : NULL;
515 }
516
517 static gboolean
vala_initializer_list_real_check(ValaCodeNode * base,ValaCodeContext * context)518 vala_initializer_list_real_check (ValaCodeNode* base,
519 ValaCodeContext* context)
520 {
521 ValaInitializerList * self;
522 gboolean _tmp0_;
523 gboolean _tmp1_;
524 ValaDataType* _tmp4_;
525 ValaDataType* _tmp5_;
526 gboolean _tmp229_;
527 gboolean _tmp230_;
528 gboolean _tmp278_;
529 gboolean _tmp279_;
530 ValaDataType* _tmp286_;
531 ValaDataType* _tmp287_;
532 gboolean _tmp290_;
533 gboolean _tmp291_;
534 gboolean result = FALSE;
535 self = (ValaInitializerList*) base;
536 g_return_val_if_fail (context != NULL, FALSE);
537 _tmp0_ = vala_code_node_get_checked ((ValaCodeNode*) self);
538 _tmp1_ = _tmp0_;
539 if (_tmp1_) {
540 gboolean _tmp2_;
541 gboolean _tmp3_;
542 _tmp2_ = vala_code_node_get_error ((ValaCodeNode*) self);
543 _tmp3_ = _tmp2_;
544 result = !_tmp3_;
545 return result;
546 }
547 vala_code_node_set_checked ((ValaCodeNode*) self, TRUE);
548 _tmp4_ = vala_expression_get_target_type ((ValaExpression*) self);
549 _tmp5_ = _tmp4_;
550 if (_tmp5_ == NULL) {
551 ValaSourceReference* _tmp6_;
552 ValaSourceReference* _tmp7_;
553 vala_code_node_set_error ((ValaCodeNode*) self, TRUE);
554 _tmp6_ = vala_code_node_get_source_reference ((ValaCodeNode*) self);
555 _tmp7_ = _tmp6_;
556 vala_report_error (_tmp7_, "initializer list used for unknown type");
557 result = FALSE;
558 return result;
559 } else {
560 ValaDataType* _tmp8_;
561 ValaDataType* _tmp9_;
562 gboolean _tmp10_;
563 gboolean _tmp11_;
564 _tmp8_ = vala_expression_get_target_type ((ValaExpression*) self);
565 _tmp9_ = _tmp8_;
566 _tmp10_ = vala_code_node_get_error ((ValaCodeNode*) _tmp9_);
567 _tmp11_ = _tmp10_;
568 if (_tmp11_) {
569 vala_code_node_set_error ((ValaCodeNode*) self, TRUE);
570 result = FALSE;
571 return result;
572 } else {
573 ValaDataType* _tmp12_;
574 ValaDataType* _tmp13_;
575 _tmp12_ = vala_expression_get_target_type ((ValaExpression*) self);
576 _tmp13_ = _tmp12_;
577 if (VALA_IS_ARRAY_TYPE (_tmp13_)) {
578 ValaArrayType* array_type = NULL;
579 ValaDataType* _tmp14_;
580 ValaDataType* _tmp15_;
581 gboolean requires_constants_only = FALSE;
582 ValaCodeNode* node = NULL;
583 ValaCodeNode* _tmp16_;
584 ValaCodeNode* _tmp17_;
585 gboolean _tmp23_ = FALSE;
586 gboolean _tmp24_ = FALSE;
587 ValaCodeNode* _tmp25_;
588 ValaCodeNode* _tmp26_;
589 ValaDataType* inner_target_type = NULL;
590 ValaArrayType* _tmp66_;
591 gint _tmp67_;
592 gint _tmp68_;
593 _tmp14_ = vala_expression_get_target_type ((ValaExpression*) self);
594 _tmp15_ = _tmp14_;
595 array_type = G_TYPE_CHECK_INSTANCE_CAST (_tmp15_, VALA_TYPE_ARRAY_TYPE, ValaArrayType);
596 requires_constants_only = FALSE;
597 _tmp16_ = vala_code_node_get_parent_node ((ValaCodeNode*) self);
598 _tmp17_ = _tmp16_;
599 node = _tmp17_;
600 while (TRUE) {
601 ValaCodeNode* _tmp18_;
602 ValaCodeNode* _tmp19_;
603 ValaCodeNode* _tmp20_;
604 ValaCodeNode* _tmp21_;
605 ValaCodeNode* _tmp22_;
606 _tmp18_ = node;
607 if (!(_tmp18_ != NULL)) {
608 break;
609 }
610 _tmp19_ = node;
611 if (VALA_IS_CONSTANT (_tmp19_)) {
612 requires_constants_only = TRUE;
613 break;
614 }
615 _tmp20_ = node;
616 _tmp21_ = vala_code_node_get_parent_node (_tmp20_);
617 _tmp22_ = _tmp21_;
618 node = _tmp22_;
619 }
620 _tmp25_ = vala_code_node_get_parent_node ((ValaCodeNode*) self);
621 _tmp26_ = _tmp25_;
622 if (!VALA_IS_ARRAY_CREATION_EXPRESSION (_tmp26_)) {
623 _tmp24_ = !requires_constants_only;
624 } else {
625 _tmp24_ = FALSE;
626 }
627 if (_tmp24_) {
628 gboolean _tmp27_ = FALSE;
629 ValaCodeNode* _tmp28_;
630 ValaCodeNode* _tmp29_;
631 _tmp28_ = vala_code_node_get_parent_node ((ValaCodeNode*) self);
632 _tmp29_ = _tmp28_;
633 if (!VALA_IS_INITIALIZER_LIST (_tmp29_)) {
634 _tmp27_ = TRUE;
635 } else {
636 ValaCodeNode* _tmp30_;
637 ValaCodeNode* _tmp31_;
638 ValaDataType* _tmp32_;
639 ValaDataType* _tmp33_;
640 ValaTypeSymbol* _tmp34_;
641 ValaTypeSymbol* _tmp35_;
642 _tmp30_ = vala_code_node_get_parent_node ((ValaCodeNode*) self);
643 _tmp31_ = _tmp30_;
644 _tmp32_ = vala_expression_get_target_type ((ValaExpression*) G_TYPE_CHECK_INSTANCE_CAST (_tmp31_, VALA_TYPE_INITIALIZER_LIST, ValaInitializerList));
645 _tmp33_ = _tmp32_;
646 _tmp34_ = vala_data_type_get_type_symbol (_tmp33_);
647 _tmp35_ = _tmp34_;
648 _tmp27_ = VALA_IS_STRUCT (_tmp35_);
649 }
650 _tmp23_ = _tmp27_;
651 } else {
652 _tmp23_ = FALSE;
653 }
654 if (_tmp23_) {
655 ValaCodeNode* old_parent_node = NULL;
656 ValaCodeNode* _tmp36_;
657 ValaCodeNode* _tmp37_;
658 ValaCodeNode* _tmp38_;
659 ValaArrayCreationExpression* array_creation = NULL;
660 ValaArrayType* _tmp39_;
661 ValaDataType* _tmp40_;
662 ValaDataType* _tmp41_;
663 ValaDataType* _tmp42_;
664 ValaDataType* _tmp43_;
665 ValaArrayType* _tmp44_;
666 gint _tmp45_;
667 gint _tmp46_;
668 ValaSourceReference* _tmp47_;
669 ValaSourceReference* _tmp48_;
670 ValaArrayCreationExpression* _tmp49_;
671 ValaArrayCreationExpression* _tmp50_;
672 ValaArrayCreationExpression* _tmp51_;
673 ValaArrayType* _tmp52_;
674 ValaDataType* _tmp53_;
675 ValaDataType* _tmp54_;
676 ValaDataType* _tmp55_;
677 ValaDataType* _tmp56_;
678 ValaArrayCreationExpression* _tmp57_;
679 ValaDataType* _tmp58_;
680 ValaDataType* _tmp59_;
681 ValaArrayCreationExpression* _tmp60_;
682 ValaDataType* _tmp61_;
683 ValaDataType* _tmp62_;
684 ValaCodeNode* _tmp63_;
685 ValaArrayCreationExpression* _tmp64_;
686 ValaArrayCreationExpression* _tmp65_;
687 _tmp36_ = vala_code_node_get_parent_node ((ValaCodeNode*) self);
688 _tmp37_ = _tmp36_;
689 _tmp38_ = _vala_code_node_ref0 (_tmp37_);
690 old_parent_node = _tmp38_;
691 _tmp39_ = array_type;
692 _tmp40_ = vala_array_type_get_element_type (_tmp39_);
693 _tmp41_ = _tmp40_;
694 _tmp42_ = vala_data_type_copy (_tmp41_);
695 _tmp43_ = _tmp42_;
696 _tmp44_ = array_type;
697 _tmp45_ = vala_array_type_get_rank (_tmp44_);
698 _tmp46_ = _tmp45_;
699 _tmp47_ = vala_code_node_get_source_reference ((ValaCodeNode*) self);
700 _tmp48_ = _tmp47_;
701 _tmp49_ = vala_array_creation_expression_new (_tmp43_, _tmp46_, self, _tmp48_);
702 _tmp50_ = _tmp49_;
703 _vala_code_node_unref0 (_tmp43_);
704 array_creation = _tmp50_;
705 _tmp51_ = array_creation;
706 _tmp52_ = array_type;
707 _tmp53_ = vala_array_type_get_length_type (_tmp52_);
708 _tmp54_ = _tmp53_;
709 _tmp55_ = vala_data_type_copy (_tmp54_);
710 _tmp56_ = _tmp55_;
711 vala_array_creation_expression_set_length_type (_tmp51_, _tmp56_);
712 _vala_code_node_unref0 (_tmp56_);
713 _tmp57_ = array_creation;
714 _tmp58_ = vala_expression_get_target_type ((ValaExpression*) self);
715 _tmp59_ = _tmp58_;
716 vala_expression_set_target_type ((ValaExpression*) _tmp57_, _tmp59_);
717 _tmp60_ = array_creation;
718 _tmp61_ = vala_expression_get_formal_target_type ((ValaExpression*) self);
719 _tmp62_ = _tmp61_;
720 vala_expression_set_formal_target_type ((ValaExpression*) _tmp60_, _tmp62_);
721 _tmp63_ = old_parent_node;
722 _tmp64_ = array_creation;
723 vala_code_node_replace_expression (_tmp63_, (ValaExpression*) self, (ValaExpression*) _tmp64_);
724 vala_code_node_set_checked ((ValaCodeNode*) self, FALSE);
725 _tmp65_ = array_creation;
726 result = vala_code_node_check ((ValaCodeNode*) _tmp65_, context);
727 _vala_code_node_unref0 (array_creation);
728 _vala_code_node_unref0 (old_parent_node);
729 return result;
730 }
731 _tmp66_ = array_type;
732 _tmp67_ = vala_array_type_get_rank (_tmp66_);
733 _tmp68_ = _tmp67_;
734 if (_tmp68_ > 1) {
735 ValaArrayType* inner_array_type = NULL;
736 ValaArrayType* _tmp69_;
737 ValaDataType* _tmp70_;
738 ValaArrayType* _tmp71_;
739 gint _tmp72_;
740 gint _tmp73_;
741 ValaArrayType* _tmp74_;
742 ValaDataType* _tmp75_;
743 _tmp69_ = array_type;
744 _tmp70_ = vala_data_type_copy ((ValaDataType*) _tmp69_);
745 inner_array_type = G_TYPE_CHECK_INSTANCE_CAST (_tmp70_, VALA_TYPE_ARRAY_TYPE, ValaArrayType);
746 _tmp71_ = inner_array_type;
747 _tmp72_ = vala_array_type_get_rank (_tmp71_);
748 _tmp73_ = _tmp72_;
749 vala_array_type_set_rank (_tmp71_, _tmp73_ - 1);
750 _tmp74_ = inner_array_type;
751 _tmp75_ = _vala_code_node_ref0 ((ValaDataType*) _tmp74_);
752 _vala_code_node_unref0 (inner_target_type);
753 inner_target_type = _tmp75_;
754 _vala_code_node_unref0 (inner_array_type);
755 } else {
756 ValaArrayType* _tmp76_;
757 ValaDataType* _tmp77_;
758 ValaDataType* _tmp78_;
759 ValaDataType* _tmp79_;
760 _tmp76_ = array_type;
761 _tmp77_ = vala_array_type_get_element_type (_tmp76_);
762 _tmp78_ = _tmp77_;
763 _tmp79_ = vala_data_type_copy (_tmp78_);
764 _vala_code_node_unref0 (inner_target_type);
765 inner_target_type = _tmp79_;
766 }
767 {
768 ValaList* _e_list = NULL;
769 ValaList* _tmp80_;
770 ValaList* _tmp81_;
771 gint _e_size = 0;
772 ValaList* _tmp82_;
773 gint _tmp83_;
774 gint _tmp84_;
775 gint _e_index = 0;
776 _tmp80_ = vala_initializer_list_get_initializers (self);
777 _tmp81_ = _vala_iterable_ref0 (_tmp80_);
778 _e_list = _tmp81_;
779 _tmp82_ = _e_list;
780 _tmp83_ = vala_collection_get_size ((ValaCollection*) _tmp82_);
781 _tmp84_ = _tmp83_;
782 _e_size = _tmp84_;
783 _e_index = -1;
784 while (TRUE) {
785 gint _tmp85_;
786 gint _tmp86_;
787 ValaExpression* e = NULL;
788 ValaList* _tmp87_;
789 gpointer _tmp88_;
790 ValaExpression* _tmp89_;
791 ValaDataType* _tmp90_;
792 _e_index = _e_index + 1;
793 _tmp85_ = _e_index;
794 _tmp86_ = _e_size;
795 if (!(_tmp85_ < _tmp86_)) {
796 break;
797 }
798 _tmp87_ = _e_list;
799 _tmp88_ = vala_list_get (_tmp87_, _e_index);
800 e = (ValaExpression*) _tmp88_;
801 _tmp89_ = e;
802 _tmp90_ = inner_target_type;
803 vala_expression_set_target_type (_tmp89_, _tmp90_);
804 _vala_code_node_unref0 (e);
805 }
806 _vala_iterable_unref0 (_e_list);
807 }
808 _vala_code_node_unref0 (inner_target_type);
809 } else {
810 ValaDataType* _tmp91_;
811 ValaDataType* _tmp92_;
812 ValaTypeSymbol* _tmp93_;
813 ValaTypeSymbol* _tmp94_;
814 _tmp91_ = vala_expression_get_target_type ((ValaExpression*) self);
815 _tmp92_ = _tmp91_;
816 _tmp93_ = vala_data_type_get_type_symbol (_tmp92_);
817 _tmp94_ = _tmp93_;
818 if (VALA_IS_STRUCT (_tmp94_)) {
819 ValaStruct* st = NULL;
820 ValaDataType* _tmp95_;
821 ValaDataType* _tmp96_;
822 ValaTypeSymbol* _tmp97_;
823 ValaTypeSymbol* _tmp98_;
824 gboolean _tmp105_ = FALSE;
825 ValaCodeNode* _tmp106_;
826 ValaCodeNode* _tmp107_;
827 gboolean in_array_creation_initializer = FALSE;
828 ValaObjectCreationExpression* struct_creation = NULL;
829 ValaIterator* field_it = NULL;
830 ValaStruct* _tmp156_;
831 ValaList* _tmp157_;
832 ValaIterator* _tmp158_;
833 _tmp95_ = vala_expression_get_target_type ((ValaExpression*) self);
834 _tmp96_ = _tmp95_;
835 _tmp97_ = vala_data_type_get_type_symbol (_tmp96_);
836 _tmp98_ = _tmp97_;
837 st = G_TYPE_CHECK_INSTANCE_CAST (_tmp98_, VALA_TYPE_STRUCT, ValaStruct);
838 while (TRUE) {
839 ValaStruct* _tmp99_;
840 ValaStruct* _tmp100_;
841 ValaStruct* _tmp101_;
842 ValaStruct* _tmp102_;
843 ValaStruct* _tmp103_;
844 ValaStruct* _tmp104_;
845 _tmp99_ = st;
846 _tmp100_ = vala_struct_get_base_struct (_tmp99_);
847 _tmp101_ = _tmp100_;
848 if (!(_tmp101_ != NULL)) {
849 break;
850 }
851 _tmp102_ = st;
852 _tmp103_ = vala_struct_get_base_struct (_tmp102_);
853 _tmp104_ = _tmp103_;
854 st = _tmp104_;
855 }
856 _tmp106_ = vala_code_node_get_parent_node ((ValaCodeNode*) self);
857 _tmp107_ = _tmp106_;
858 if (VALA_IS_INITIALIZER_LIST (_tmp107_)) {
859 ValaCodeNode* _tmp108_;
860 ValaCodeNode* _tmp109_;
861 ValaCodeNode* _tmp110_;
862 ValaCodeNode* _tmp111_;
863 _tmp108_ = vala_code_node_get_parent_node ((ValaCodeNode*) self);
864 _tmp109_ = _tmp108_;
865 _tmp110_ = vala_code_node_get_parent_node (_tmp109_);
866 _tmp111_ = _tmp110_;
867 _tmp105_ = VALA_IS_ARRAY_CREATION_EXPRESSION (_tmp111_);
868 } else {
869 _tmp105_ = FALSE;
870 }
871 in_array_creation_initializer = _tmp105_;
872 struct_creation = NULL;
873 if (in_array_creation_initializer) {
874 ValaSymbol* sym = NULL;
875 ValaStruct* _tmp112_;
876 ValaMemberAccess* ma = NULL;
877 ValaSymbol* _tmp113_;
878 const gchar* _tmp114_;
879 const gchar* _tmp115_;
880 ValaSourceReference* _tmp116_;
881 ValaSourceReference* _tmp117_;
882 ValaMemberAccess* _tmp118_;
883 ValaMemberAccess* _tmp119_;
884 ValaMemberAccess* _tmp120_;
885 ValaSymbol* _tmp121_;
886 ValaMemberAccess* inner = NULL;
887 ValaMemberAccess* _tmp122_;
888 ValaMemberAccess* _tmp123_;
889 ValaMemberAccess* _tmp146_;
890 ValaSourceReference* _tmp147_;
891 ValaSourceReference* _tmp148_;
892 ValaObjectCreationExpression* _tmp149_;
893 ValaObjectCreationExpression* _tmp150_;
894 ValaDataType* _tmp151_;
895 ValaDataType* _tmp152_;
896 ValaDataType* _tmp153_;
897 ValaDataType* _tmp154_;
898 ValaObjectCreationExpression* _tmp155_;
899 _tmp112_ = st;
900 sym = (ValaSymbol*) _tmp112_;
901 _tmp113_ = sym;
902 _tmp114_ = vala_symbol_get_name (_tmp113_);
903 _tmp115_ = _tmp114_;
904 _tmp116_ = vala_code_node_get_source_reference ((ValaCodeNode*) self);
905 _tmp117_ = _tmp116_;
906 _tmp118_ = vala_member_access_new_simple (_tmp115_, _tmp117_);
907 ma = _tmp118_;
908 _tmp119_ = ma;
909 vala_member_access_set_creation_member (_tmp119_, TRUE);
910 _tmp120_ = ma;
911 _tmp121_ = sym;
912 vala_expression_set_symbol_reference ((ValaExpression*) _tmp120_, _tmp121_);
913 _tmp122_ = ma;
914 _tmp123_ = _vala_code_node_ref0 (_tmp122_);
915 inner = _tmp123_;
916 while (TRUE) {
917 gboolean _tmp124_ = FALSE;
918 ValaSymbol* _tmp125_;
919 ValaSymbol* _tmp126_;
920 ValaSymbol* _tmp127_;
921 ValaSymbol* _tmp133_;
922 ValaSymbol* _tmp134_;
923 ValaSymbol* _tmp135_;
924 ValaMemberAccess* ma_inner = NULL;
925 ValaSymbol* _tmp136_;
926 const gchar* _tmp137_;
927 const gchar* _tmp138_;
928 ValaSourceReference* _tmp139_;
929 ValaSourceReference* _tmp140_;
930 ValaMemberAccess* _tmp141_;
931 ValaMemberAccess* _tmp142_;
932 ValaMemberAccess* _tmp143_;
933 ValaMemberAccess* _tmp144_;
934 ValaMemberAccess* _tmp145_;
935 _tmp125_ = sym;
936 _tmp126_ = vala_symbol_get_parent_symbol (_tmp125_);
937 _tmp127_ = _tmp126_;
938 if (_tmp127_ != NULL) {
939 ValaSymbol* _tmp128_;
940 ValaSymbol* _tmp129_;
941 ValaSymbol* _tmp130_;
942 ValaNamespace* _tmp131_;
943 ValaNamespace* _tmp132_;
944 _tmp128_ = sym;
945 _tmp129_ = vala_symbol_get_parent_symbol (_tmp128_);
946 _tmp130_ = _tmp129_;
947 _tmp131_ = vala_code_context_get_root (context);
948 _tmp132_ = _tmp131_;
949 _tmp124_ = _tmp130_ != G_TYPE_CHECK_INSTANCE_CAST (_tmp132_, VALA_TYPE_SYMBOL, ValaSymbol);
950 } else {
951 _tmp124_ = FALSE;
952 }
953 if (!_tmp124_) {
954 break;
955 }
956 _tmp133_ = sym;
957 _tmp134_ = vala_symbol_get_parent_symbol (_tmp133_);
958 _tmp135_ = _tmp134_;
959 sym = _tmp135_;
960 _tmp136_ = sym;
961 _tmp137_ = vala_symbol_get_name (_tmp136_);
962 _tmp138_ = _tmp137_;
963 _tmp139_ = vala_code_node_get_source_reference ((ValaCodeNode*) self);
964 _tmp140_ = _tmp139_;
965 _tmp141_ = vala_member_access_new_simple (_tmp138_, _tmp140_);
966 ma_inner = _tmp141_;
967 _tmp142_ = inner;
968 _tmp143_ = ma_inner;
969 vala_member_access_set_inner (_tmp142_, (ValaExpression*) _tmp143_);
970 _tmp144_ = ma_inner;
971 _tmp145_ = _vala_code_node_ref0 (_tmp144_);
972 _vala_code_node_unref0 (inner);
973 inner = _tmp145_;
974 _vala_code_node_unref0 (ma_inner);
975 }
976 _tmp146_ = ma;
977 _tmp147_ = vala_code_node_get_source_reference ((ValaCodeNode*) self);
978 _tmp148_ = _tmp147_;
979 _tmp149_ = vala_object_creation_expression_new (_tmp146_, _tmp148_);
980 _vala_code_node_unref0 (struct_creation);
981 struct_creation = _tmp149_;
982 _tmp150_ = struct_creation;
983 _tmp151_ = vala_expression_get_target_type ((ValaExpression*) self);
984 _tmp152_ = _tmp151_;
985 _tmp153_ = vala_data_type_copy (_tmp152_);
986 _tmp154_ = _tmp153_;
987 vala_expression_set_target_type ((ValaExpression*) _tmp150_, _tmp154_);
988 _vala_code_node_unref0 (_tmp154_);
989 _tmp155_ = struct_creation;
990 vala_object_creation_expression_set_struct_creation (_tmp155_, TRUE);
991 _vala_code_node_unref0 (inner);
992 _vala_code_node_unref0 (ma);
993 }
994 _tmp156_ = st;
995 _tmp157_ = vala_struct_get_fields (_tmp156_);
996 _tmp158_ = vala_iterable_iterator ((ValaIterable*) _tmp157_);
997 field_it = _tmp158_;
998 {
999 ValaList* _e_list = NULL;
1000 ValaList* _tmp159_;
1001 ValaList* _tmp160_;
1002 gint _e_size = 0;
1003 ValaList* _tmp161_;
1004 gint _tmp162_;
1005 gint _tmp163_;
1006 gint _e_index = 0;
1007 _tmp159_ = vala_initializer_list_get_initializers (self);
1008 _tmp160_ = _vala_iterable_ref0 (_tmp159_);
1009 _e_list = _tmp160_;
1010 _tmp161_ = _e_list;
1011 _tmp162_ = vala_collection_get_size ((ValaCollection*) _tmp161_);
1012 _tmp163_ = _tmp162_;
1013 _e_size = _tmp163_;
1014 _e_index = -1;
1015 while (TRUE) {
1016 gint _tmp164_;
1017 gint _tmp165_;
1018 ValaExpression* e = NULL;
1019 ValaList* _tmp166_;
1020 gpointer _tmp167_;
1021 ValaField* field = NULL;
1022 _e_index = _e_index + 1;
1023 _tmp164_ = _e_index;
1024 _tmp165_ = _e_size;
1025 if (!(_tmp164_ < _tmp165_)) {
1026 break;
1027 }
1028 _tmp166_ = _e_list;
1029 _tmp167_ = vala_list_get (_tmp166_, _e_index);
1030 e = (ValaExpression*) _tmp167_;
1031 field = NULL;
1032 while (TRUE) {
1033 ValaField* _tmp168_;
1034 ValaIterator* _tmp169_;
1035 ValaIterator* _tmp179_;
1036 gpointer _tmp180_;
1037 ValaField* _tmp181_;
1038 ValaMemberBinding _tmp182_;
1039 ValaMemberBinding _tmp183_;
1040 _tmp168_ = field;
1041 if (!(_tmp168_ == NULL)) {
1042 break;
1043 }
1044 _tmp169_ = field_it;
1045 if (!vala_iterator_next (_tmp169_)) {
1046 ValaExpression* _tmp170_;
1047 ValaSourceReference* _tmp171_;
1048 ValaSourceReference* _tmp172_;
1049 ValaDataType* _tmp173_;
1050 ValaDataType* _tmp174_;
1051 gchar* _tmp175_;
1052 gchar* _tmp176_;
1053 gchar* _tmp177_;
1054 gchar* _tmp178_;
1055 vala_code_node_set_error ((ValaCodeNode*) self, TRUE);
1056 _tmp170_ = e;
1057 _tmp171_ = vala_code_node_get_source_reference ((ValaCodeNode*) _tmp170_);
1058 _tmp172_ = _tmp171_;
1059 _tmp173_ = vala_expression_get_target_type ((ValaExpression*) self);
1060 _tmp174_ = _tmp173_;
1061 _tmp175_ = vala_code_node_to_string ((ValaCodeNode*) _tmp174_);
1062 _tmp176_ = _tmp175_;
1063 _tmp177_ = g_strdup_printf ("too many expressions in initializer list for `%s'", _tmp176_);
1064 _tmp178_ = _tmp177_;
1065 vala_report_error (_tmp172_, _tmp178_);
1066 _g_free0 (_tmp178_);
1067 _g_free0 (_tmp176_);
1068 result = FALSE;
1069 _vala_code_node_unref0 (field);
1070 _vala_code_node_unref0 (e);
1071 _vala_iterable_unref0 (_e_list);
1072 _vala_iterator_unref0 (field_it);
1073 _vala_code_node_unref0 (struct_creation);
1074 return result;
1075 }
1076 _tmp179_ = field_it;
1077 _tmp180_ = vala_iterator_get (_tmp179_);
1078 _vala_code_node_unref0 (field);
1079 field = (ValaField*) _tmp180_;
1080 _tmp181_ = field;
1081 _tmp182_ = vala_field_get_binding (_tmp181_);
1082 _tmp183_ = _tmp182_;
1083 if (_tmp183_ != VALA_MEMBER_BINDING_INSTANCE) {
1084 _vala_code_node_unref0 (field);
1085 field = NULL;
1086 }
1087 }
1088 if (in_array_creation_initializer) {
1089 ValaMemberInitializer* member_init = NULL;
1090 ValaField* _tmp184_;
1091 const gchar* _tmp185_;
1092 const gchar* _tmp186_;
1093 ValaExpression* _tmp187_;
1094 ValaExpression* _tmp188_;
1095 ValaSourceReference* _tmp189_;
1096 ValaSourceReference* _tmp190_;
1097 ValaMemberInitializer* _tmp191_;
1098 ValaObjectCreationExpression* _tmp192_;
1099 ValaMemberInitializer* _tmp193_;
1100 _tmp184_ = field;
1101 _tmp185_ = vala_symbol_get_name ((ValaSymbol*) _tmp184_);
1102 _tmp186_ = _tmp185_;
1103 _tmp187_ = e;
1104 _tmp188_ = e;
1105 _tmp189_ = vala_code_node_get_source_reference ((ValaCodeNode*) _tmp188_);
1106 _tmp190_ = _tmp189_;
1107 _tmp191_ = vala_member_initializer_new (_tmp186_, _tmp187_, _tmp190_);
1108 member_init = _tmp191_;
1109 _tmp192_ = struct_creation;
1110 _tmp193_ = member_init;
1111 vala_object_creation_expression_add_member_initializer (_tmp192_, _tmp193_);
1112 _vala_code_node_unref0 (member_init);
1113 } else {
1114 ValaExpression* _tmp194_;
1115 ValaField* _tmp195_;
1116 ValaDataType* _tmp196_;
1117 ValaDataType* _tmp197_;
1118 ValaDataType* _tmp198_;
1119 ValaDataType* _tmp199_;
1120 ValaDataType* _tmp200_;
1121 ValaDataType* _tmp201_;
1122 gboolean _tmp202_;
1123 gboolean _tmp203_;
1124 _tmp194_ = e;
1125 _tmp195_ = field;
1126 _tmp196_ = vala_variable_get_variable_type ((ValaVariable*) _tmp195_);
1127 _tmp197_ = _tmp196_;
1128 _tmp198_ = vala_data_type_copy (_tmp197_);
1129 _tmp199_ = _tmp198_;
1130 vala_expression_set_target_type (_tmp194_, _tmp199_);
1131 _vala_code_node_unref0 (_tmp199_);
1132 _tmp200_ = vala_expression_get_target_type ((ValaExpression*) self);
1133 _tmp201_ = _tmp200_;
1134 _tmp202_ = vala_data_type_get_value_owned (_tmp201_);
1135 _tmp203_ = _tmp202_;
1136 if (!_tmp203_) {
1137 ValaExpression* _tmp204_;
1138 ValaDataType* _tmp205_;
1139 ValaDataType* _tmp206_;
1140 _tmp204_ = e;
1141 _tmp205_ = vala_expression_get_target_type (_tmp204_);
1142 _tmp206_ = _tmp205_;
1143 vala_data_type_set_value_owned (_tmp206_, FALSE);
1144 }
1145 }
1146 _vala_code_node_unref0 (field);
1147 _vala_code_node_unref0 (e);
1148 }
1149 _vala_iterable_unref0 (_e_list);
1150 }
1151 if (in_array_creation_initializer) {
1152 ValaCodeNode* _tmp207_;
1153 ValaCodeNode* _tmp208_;
1154 ValaObjectCreationExpression* _tmp209_;
1155 ValaObjectCreationExpression* _tmp210_;
1156 _tmp207_ = vala_code_node_get_parent_node ((ValaCodeNode*) self);
1157 _tmp208_ = _tmp207_;
1158 _tmp209_ = struct_creation;
1159 vala_code_node_replace_expression (_tmp208_, (ValaExpression*) self, (ValaExpression*) _tmp209_);
1160 vala_code_node_set_checked ((ValaCodeNode*) self, FALSE);
1161 _tmp210_ = struct_creation;
1162 result = vala_code_node_check ((ValaCodeNode*) _tmp210_, context);
1163 _vala_iterator_unref0 (field_it);
1164 _vala_code_node_unref0 (struct_creation);
1165 return result;
1166 }
1167 _vala_iterator_unref0 (field_it);
1168 _vala_code_node_unref0 (struct_creation);
1169 } else {
1170 ValaSourceReference* _tmp211_;
1171 ValaSourceReference* _tmp212_;
1172 ValaDataType* _tmp213_;
1173 ValaDataType* _tmp214_;
1174 gchar* _tmp215_;
1175 gchar* _tmp216_;
1176 gchar* _tmp217_;
1177 gchar* _tmp218_;
1178 vala_code_node_set_error ((ValaCodeNode*) self, TRUE);
1179 _tmp211_ = vala_code_node_get_source_reference ((ValaCodeNode*) self);
1180 _tmp212_ = _tmp211_;
1181 _tmp213_ = vala_expression_get_target_type ((ValaExpression*) self);
1182 _tmp214_ = _tmp213_;
1183 _tmp215_ = vala_code_node_to_string ((ValaCodeNode*) _tmp214_);
1184 _tmp216_ = _tmp215_;
1185 _tmp217_ = g_strdup_printf ("initializer list used for `%s', which is neither array nor struct", _tmp216_);
1186 _tmp218_ = _tmp217_;
1187 vala_report_error (_tmp212_, _tmp218_);
1188 _g_free0 (_tmp218_);
1189 _g_free0 (_tmp216_);
1190 result = FALSE;
1191 return result;
1192 }
1193 }
1194 }
1195 }
1196 {
1197 ValaList* _expr_list = NULL;
1198 ValaList* _tmp219_;
1199 ValaList* _tmp220_;
1200 gint _expr_size = 0;
1201 ValaList* _tmp221_;
1202 gint _tmp222_;
1203 gint _tmp223_;
1204 gint _expr_index = 0;
1205 _tmp219_ = self->priv->initializers;
1206 _tmp220_ = _vala_iterable_ref0 (_tmp219_);
1207 _expr_list = _tmp220_;
1208 _tmp221_ = _expr_list;
1209 _tmp222_ = vala_collection_get_size ((ValaCollection*) _tmp221_);
1210 _tmp223_ = _tmp222_;
1211 _expr_size = _tmp223_;
1212 _expr_index = -1;
1213 while (TRUE) {
1214 gint _tmp224_;
1215 gint _tmp225_;
1216 ValaExpression* expr = NULL;
1217 ValaList* _tmp226_;
1218 gpointer _tmp227_;
1219 ValaExpression* _tmp228_;
1220 _expr_index = _expr_index + 1;
1221 _tmp224_ = _expr_index;
1222 _tmp225_ = _expr_size;
1223 if (!(_tmp224_ < _tmp225_)) {
1224 break;
1225 }
1226 _tmp226_ = _expr_list;
1227 _tmp227_ = vala_list_get (_tmp226_, _expr_index);
1228 expr = (ValaExpression*) _tmp227_;
1229 _tmp228_ = expr;
1230 if (!vala_code_node_check ((ValaCodeNode*) _tmp228_, context)) {
1231 vala_code_node_set_error ((ValaCodeNode*) self, TRUE);
1232 }
1233 _vala_code_node_unref0 (expr);
1234 }
1235 _vala_iterable_unref0 (_expr_list);
1236 }
1237 _tmp229_ = vala_code_node_get_error ((ValaCodeNode*) self);
1238 _tmp230_ = _tmp229_;
1239 if (_tmp230_) {
1240 result = FALSE;
1241 return result;
1242 }
1243 {
1244 ValaList* _e_list = NULL;
1245 ValaList* _tmp231_;
1246 ValaList* _tmp232_;
1247 gint _e_size = 0;
1248 ValaList* _tmp233_;
1249 gint _tmp234_;
1250 gint _tmp235_;
1251 gint _e_index = 0;
1252 _tmp231_ = vala_initializer_list_get_initializers (self);
1253 _tmp232_ = _vala_iterable_ref0 (_tmp231_);
1254 _e_list = _tmp232_;
1255 _tmp233_ = _e_list;
1256 _tmp234_ = vala_collection_get_size ((ValaCollection*) _tmp233_);
1257 _tmp235_ = _tmp234_;
1258 _e_size = _tmp235_;
1259 _e_index = -1;
1260 while (TRUE) {
1261 gint _tmp236_;
1262 gint _tmp237_;
1263 ValaExpression* e = NULL;
1264 ValaList* _tmp238_;
1265 gpointer _tmp239_;
1266 ValaExpression* _tmp240_;
1267 ValaDataType* _tmp241_;
1268 ValaDataType* _tmp242_;
1269 ValaUnaryExpression* unary = NULL;
1270 ValaExpression* _tmp246_;
1271 gboolean _tmp247_ = FALSE;
1272 ValaUnaryExpression* _tmp248_;
1273 _e_index = _e_index + 1;
1274 _tmp236_ = _e_index;
1275 _tmp237_ = _e_size;
1276 if (!(_tmp236_ < _tmp237_)) {
1277 break;
1278 }
1279 _tmp238_ = _e_list;
1280 _tmp239_ = vala_list_get (_tmp238_, _e_index);
1281 e = (ValaExpression*) _tmp239_;
1282 _tmp240_ = e;
1283 _tmp241_ = vala_expression_get_value_type (_tmp240_);
1284 _tmp242_ = _tmp241_;
1285 if (_tmp242_ == NULL) {
1286 ValaExpression* _tmp243_;
1287 ValaSourceReference* _tmp244_;
1288 ValaSourceReference* _tmp245_;
1289 vala_code_node_set_error ((ValaCodeNode*) self, TRUE);
1290 _tmp243_ = e;
1291 _tmp244_ = vala_code_node_get_source_reference ((ValaCodeNode*) _tmp243_);
1292 _tmp245_ = _tmp244_;
1293 vala_report_error (_tmp245_, "expression type not allowed as initializer");
1294 _vala_code_node_unref0 (e);
1295 continue;
1296 }
1297 _tmp246_ = e;
1298 unary = VALA_IS_UNARY_EXPRESSION (_tmp246_) ? ((ValaUnaryExpression*) _tmp246_) : NULL;
1299 _tmp248_ = unary;
1300 if (_tmp248_ != NULL) {
1301 gboolean _tmp249_ = FALSE;
1302 ValaUnaryExpression* _tmp250_;
1303 ValaUnaryOperator _tmp251_;
1304 ValaUnaryOperator _tmp252_;
1305 _tmp250_ = unary;
1306 _tmp251_ = vala_unary_expression_get_operator (_tmp250_);
1307 _tmp252_ = _tmp251_;
1308 if (_tmp252_ == VALA_UNARY_OPERATOR_REF) {
1309 _tmp249_ = TRUE;
1310 } else {
1311 ValaUnaryExpression* _tmp253_;
1312 ValaUnaryOperator _tmp254_;
1313 ValaUnaryOperator _tmp255_;
1314 _tmp253_ = unary;
1315 _tmp254_ = vala_unary_expression_get_operator (_tmp253_);
1316 _tmp255_ = _tmp254_;
1317 _tmp249_ = _tmp255_ == VALA_UNARY_OPERATOR_OUT;
1318 }
1319 _tmp247_ = _tmp249_;
1320 } else {
1321 _tmp247_ = FALSE;
1322 }
1323 if (_tmp247_) {
1324 } else {
1325 ValaExpression* _tmp256_;
1326 ValaDataType* _tmp257_;
1327 ValaDataType* _tmp258_;
1328 ValaExpression* _tmp259_;
1329 ValaDataType* _tmp260_;
1330 ValaDataType* _tmp261_;
1331 _tmp256_ = e;
1332 _tmp257_ = vala_expression_get_value_type (_tmp256_);
1333 _tmp258_ = _tmp257_;
1334 _tmp259_ = e;
1335 _tmp260_ = vala_expression_get_target_type (_tmp259_);
1336 _tmp261_ = _tmp260_;
1337 if (!vala_data_type_compatible (_tmp258_, _tmp261_)) {
1338 ValaExpression* _tmp262_;
1339 ValaExpression* _tmp263_;
1340 ValaSourceReference* _tmp264_;
1341 ValaSourceReference* _tmp265_;
1342 ValaExpression* _tmp266_;
1343 ValaDataType* _tmp267_;
1344 ValaDataType* _tmp268_;
1345 gchar* _tmp269_;
1346 gchar* _tmp270_;
1347 ValaExpression* _tmp271_;
1348 ValaDataType* _tmp272_;
1349 ValaDataType* _tmp273_;
1350 gchar* _tmp274_;
1351 gchar* _tmp275_;
1352 gchar* _tmp276_;
1353 gchar* _tmp277_;
1354 vala_code_node_set_error ((ValaCodeNode*) self, TRUE);
1355 _tmp262_ = e;
1356 vala_code_node_set_error ((ValaCodeNode*) _tmp262_, TRUE);
1357 _tmp263_ = e;
1358 _tmp264_ = vala_code_node_get_source_reference ((ValaCodeNode*) _tmp263_);
1359 _tmp265_ = _tmp264_;
1360 _tmp266_ = e;
1361 _tmp267_ = vala_expression_get_target_type (_tmp266_);
1362 _tmp268_ = _tmp267_;
1363 _tmp269_ = vala_code_node_to_string ((ValaCodeNode*) _tmp268_);
1364 _tmp270_ = _tmp269_;
1365 _tmp271_ = e;
1366 _tmp272_ = vala_expression_get_value_type (_tmp271_);
1367 _tmp273_ = _tmp272_;
1368 _tmp274_ = vala_code_node_to_string ((ValaCodeNode*) _tmp273_);
1369 _tmp275_ = _tmp274_;
1370 _tmp276_ = g_strdup_printf ("Expected initializer of type `%s' but got `%s'", _tmp270_, _tmp275_);
1371 _tmp277_ = _tmp276_;
1372 vala_report_error (_tmp265_, _tmp277_);
1373 _g_free0 (_tmp277_);
1374 _g_free0 (_tmp275_);
1375 _g_free0 (_tmp270_);
1376 }
1377 }
1378 _vala_code_node_unref0 (e);
1379 }
1380 _vala_iterable_unref0 (_e_list);
1381 }
1382 _tmp278_ = vala_code_node_get_error ((ValaCodeNode*) self);
1383 _tmp279_ = _tmp278_;
1384 if (!_tmp279_) {
1385 ValaDataType* _tmp280_;
1386 ValaDataType* _tmp281_;
1387 ValaDataType* _tmp282_;
1388 ValaDataType* _tmp283_;
1389 ValaDataType* _tmp284_;
1390 ValaDataType* _tmp285_;
1391 _tmp280_ = vala_expression_get_target_type ((ValaExpression*) self);
1392 _tmp281_ = _tmp280_;
1393 _tmp282_ = vala_data_type_copy (_tmp281_);
1394 _tmp283_ = _tmp282_;
1395 vala_expression_set_value_type ((ValaExpression*) self, _tmp283_);
1396 _vala_code_node_unref0 (_tmp283_);
1397 _tmp284_ = vala_expression_get_value_type ((ValaExpression*) self);
1398 _tmp285_ = _tmp284_;
1399 vala_data_type_set_nullable (_tmp285_, FALSE);
1400 }
1401 _tmp286_ = vala_expression_get_value_type ((ValaExpression*) self);
1402 _tmp287_ = _tmp286_;
1403 if (_tmp287_ != NULL) {
1404 ValaDataType* _tmp288_;
1405 ValaDataType* _tmp289_;
1406 _tmp288_ = vala_expression_get_value_type ((ValaExpression*) self);
1407 _tmp289_ = _tmp288_;
1408 vala_code_node_check ((ValaCodeNode*) _tmp289_, context);
1409 }
1410 _tmp290_ = vala_code_node_get_error ((ValaCodeNode*) self);
1411 _tmp291_ = _tmp290_;
1412 result = !_tmp291_;
1413 return result;
1414 }
1415
1416 static void
vala_initializer_list_real_emit(ValaCodeNode * base,ValaCodeGenerator * codegen)1417 vala_initializer_list_real_emit (ValaCodeNode* base,
1418 ValaCodeGenerator* codegen)
1419 {
1420 ValaInitializerList * self;
1421 self = (ValaInitializerList*) base;
1422 g_return_if_fail (codegen != NULL);
1423 {
1424 ValaList* _expr_list = NULL;
1425 ValaList* _tmp0_;
1426 ValaList* _tmp1_;
1427 gint _expr_size = 0;
1428 ValaList* _tmp2_;
1429 gint _tmp3_;
1430 gint _tmp4_;
1431 gint _expr_index = 0;
1432 _tmp0_ = self->priv->initializers;
1433 _tmp1_ = _vala_iterable_ref0 (_tmp0_);
1434 _expr_list = _tmp1_;
1435 _tmp2_ = _expr_list;
1436 _tmp3_ = vala_collection_get_size ((ValaCollection*) _tmp2_);
1437 _tmp4_ = _tmp3_;
1438 _expr_size = _tmp4_;
1439 _expr_index = -1;
1440 while (TRUE) {
1441 gint _tmp5_;
1442 gint _tmp6_;
1443 ValaExpression* expr = NULL;
1444 ValaList* _tmp7_;
1445 gpointer _tmp8_;
1446 ValaExpression* _tmp9_;
1447 _expr_index = _expr_index + 1;
1448 _tmp5_ = _expr_index;
1449 _tmp6_ = _expr_size;
1450 if (!(_tmp5_ < _tmp6_)) {
1451 break;
1452 }
1453 _tmp7_ = _expr_list;
1454 _tmp8_ = vala_list_get (_tmp7_, _expr_index);
1455 expr = (ValaExpression*) _tmp8_;
1456 _tmp9_ = expr;
1457 vala_code_node_emit ((ValaCodeNode*) _tmp9_, codegen);
1458 _vala_code_node_unref0 (expr);
1459 }
1460 _vala_iterable_unref0 (_expr_list);
1461 }
1462 vala_code_visitor_visit_initializer_list ((ValaCodeVisitor*) codegen, self);
1463 vala_code_visitor_visit_expression ((ValaCodeVisitor*) codegen, (ValaExpression*) self);
1464 }
1465
1466 static void
vala_initializer_list_real_get_used_variables(ValaCodeNode * base,ValaCollection * collection)1467 vala_initializer_list_real_get_used_variables (ValaCodeNode* base,
1468 ValaCollection* collection)
1469 {
1470 ValaInitializerList * self;
1471 self = (ValaInitializerList*) base;
1472 g_return_if_fail (collection != NULL);
1473 {
1474 ValaList* _expr_list = NULL;
1475 ValaList* _tmp0_;
1476 ValaList* _tmp1_;
1477 gint _expr_size = 0;
1478 ValaList* _tmp2_;
1479 gint _tmp3_;
1480 gint _tmp4_;
1481 gint _expr_index = 0;
1482 _tmp0_ = self->priv->initializers;
1483 _tmp1_ = _vala_iterable_ref0 (_tmp0_);
1484 _expr_list = _tmp1_;
1485 _tmp2_ = _expr_list;
1486 _tmp3_ = vala_collection_get_size ((ValaCollection*) _tmp2_);
1487 _tmp4_ = _tmp3_;
1488 _expr_size = _tmp4_;
1489 _expr_index = -1;
1490 while (TRUE) {
1491 gint _tmp5_;
1492 gint _tmp6_;
1493 ValaExpression* expr = NULL;
1494 ValaList* _tmp7_;
1495 gpointer _tmp8_;
1496 ValaExpression* _tmp9_;
1497 _expr_index = _expr_index + 1;
1498 _tmp5_ = _expr_index;
1499 _tmp6_ = _expr_size;
1500 if (!(_tmp5_ < _tmp6_)) {
1501 break;
1502 }
1503 _tmp7_ = _expr_list;
1504 _tmp8_ = vala_list_get (_tmp7_, _expr_index);
1505 expr = (ValaExpression*) _tmp8_;
1506 _tmp9_ = expr;
1507 vala_code_node_get_used_variables ((ValaCodeNode*) _tmp9_, collection);
1508 _vala_code_node_unref0 (expr);
1509 }
1510 _vala_iterable_unref0 (_expr_list);
1511 }
1512 }
1513
1514 static void
vala_initializer_list_class_init(ValaInitializerListClass * klass,gpointer klass_data)1515 vala_initializer_list_class_init (ValaInitializerListClass * klass,
1516 gpointer klass_data)
1517 {
1518 vala_initializer_list_parent_class = g_type_class_peek_parent (klass);
1519 ((ValaCodeNodeClass *) klass)->finalize = vala_initializer_list_finalize;
1520 g_type_class_adjust_private_offset (klass, &ValaInitializerList_private_offset);
1521 ((ValaCodeNodeClass *) klass)->accept_children = (void (*) (ValaCodeNode*, ValaCodeVisitor*)) vala_initializer_list_real_accept_children;
1522 ((ValaCodeNodeClass *) klass)->accept = (void (*) (ValaCodeNode*, ValaCodeVisitor*)) vala_initializer_list_real_accept;
1523 ((ValaExpressionClass *) klass)->is_constant = (gboolean (*) (ValaExpression*)) vala_initializer_list_real_is_constant;
1524 ((ValaExpressionClass *) klass)->is_pure = (gboolean (*) (ValaExpression*)) vala_initializer_list_real_is_pure;
1525 ((ValaExpressionClass *) klass)->is_accessible = (gboolean (*) (ValaExpression*, ValaSymbol*)) vala_initializer_list_real_is_accessible;
1526 ((ValaCodeNodeClass *) klass)->to_string = (gchar* (*) (ValaCodeNode*)) vala_initializer_list_real_to_string;
1527 ((ValaCodeNodeClass *) klass)->replace_expression = (void (*) (ValaCodeNode*, ValaExpression*, ValaExpression*)) vala_initializer_list_real_replace_expression;
1528 ((ValaCodeNodeClass *) klass)->check = (gboolean (*) (ValaCodeNode*, ValaCodeContext*)) vala_initializer_list_real_check;
1529 ((ValaCodeNodeClass *) klass)->emit = (void (*) (ValaCodeNode*, ValaCodeGenerator*)) vala_initializer_list_real_emit;
1530 ((ValaCodeNodeClass *) klass)->get_used_variables = (void (*) (ValaCodeNode*, ValaCollection*)) vala_initializer_list_real_get_used_variables;
1531 }
1532
1533 static void
vala_initializer_list_instance_init(ValaInitializerList * self,gpointer klass)1534 vala_initializer_list_instance_init (ValaInitializerList * self,
1535 gpointer klass)
1536 {
1537 GEqualFunc _tmp0_;
1538 ValaArrayList* _tmp1_;
1539 self->priv = vala_initializer_list_get_instance_private (self);
1540 _tmp0_ = g_direct_equal;
1541 _tmp1_ = vala_array_list_new (VALA_TYPE_EXPRESSION, (GBoxedCopyFunc) vala_code_node_ref, (GDestroyNotify) vala_code_node_unref, _tmp0_);
1542 self->priv->initializers = (ValaList*) _tmp1_;
1543 }
1544
1545 static void
vala_initializer_list_finalize(ValaCodeNode * obj)1546 vala_initializer_list_finalize (ValaCodeNode * obj)
1547 {
1548 ValaInitializerList * self;
1549 self = G_TYPE_CHECK_INSTANCE_CAST (obj, VALA_TYPE_INITIALIZER_LIST, ValaInitializerList);
1550 _vala_iterable_unref0 (self->priv->initializers);
1551 VALA_CODE_NODE_CLASS (vala_initializer_list_parent_class)->finalize (obj);
1552 }
1553
1554 /**
1555 * Represents an array or struct initializer list in the source code.
1556 */
1557 static GType
vala_initializer_list_get_type_once(void)1558 vala_initializer_list_get_type_once (void)
1559 {
1560 static const GTypeInfo g_define_type_info = { sizeof (ValaInitializerListClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) vala_initializer_list_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ValaInitializerList), 0, (GInstanceInitFunc) vala_initializer_list_instance_init, NULL };
1561 GType vala_initializer_list_type_id;
1562 vala_initializer_list_type_id = g_type_register_static (VALA_TYPE_EXPRESSION, "ValaInitializerList", &g_define_type_info, 0);
1563 ValaInitializerList_private_offset = g_type_add_instance_private (vala_initializer_list_type_id, sizeof (ValaInitializerListPrivate));
1564 return vala_initializer_list_type_id;
1565 }
1566
1567 GType
vala_initializer_list_get_type(void)1568 vala_initializer_list_get_type (void)
1569 {
1570 static volatile gsize vala_initializer_list_type_id__volatile = 0;
1571 if (g_once_init_enter (&vala_initializer_list_type_id__volatile)) {
1572 GType vala_initializer_list_type_id;
1573 vala_initializer_list_type_id = vala_initializer_list_get_type_once ();
1574 g_once_init_leave (&vala_initializer_list_type_id__volatile, vala_initializer_list_type_id);
1575 }
1576 return vala_initializer_list_type_id__volatile;
1577 }
1578
1579