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