1 /* valaswitchstatement.c generated by valac, the Vala compiler
2  * generated from valaswitchstatement.vala, do not modify */
3 
4 /* valaswitchstatement.vala
5  *
6  * Copyright (C) 2006-2010  Jürg Billeter
7  *
8  * This library is free software; you can redistribute it and/or
9  * modify it under the terms of the GNU Lesser General Public
10  * License as published by the Free Software Foundation; either
11  * version 2.1 of the License, or (at your option) any later version.
12 
13  * This library is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16  * Lesser General Public License for more details.
17 
18  * You should have received a copy of the GNU Lesser General Public
19  * License along with this library; if not, write to the Free Software
20  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
21  *
22  * Author:
23  * 	Jürg Billeter <j@bitron.ch>
24  */
25 
26 #include "vala.h"
27 #include <valagee.h>
28 #include <glib-object.h>
29 #include <glib.h>
30 #include <stdlib.h>
31 #include <string.h>
32 
33 #define _vala_code_node_unref0(var) ((var == NULL) ? NULL : (var = (vala_code_node_unref (var), NULL)))
34 #define _vala_iterable_unref0(var) ((var == NULL) ? NULL : (var = (vala_iterable_unref (var), NULL)))
35 #define _g_free0(var) (var = (g_free (var), NULL))
36 
37 struct _ValaSwitchStatementPrivate {
38 	ValaExpression* _expression;
39 	ValaList* sections;
40 };
41 
42 static gint ValaSwitchStatement_private_offset;
43 static gpointer vala_switch_statement_parent_class = NULL;
44 static ValaStatementIface * vala_switch_statement_vala_statement_parent_iface = NULL;
45 
46 static void vala_switch_statement_real_accept (ValaCodeNode* base,
47                                         ValaCodeVisitor* visitor);
48 static void vala_switch_statement_real_accept_children (ValaCodeNode* base,
49                                                  ValaCodeVisitor* visitor);
50 static void vala_switch_statement_real_replace_expression (ValaCodeNode* base,
51                                                     ValaExpression* old_node,
52                                                     ValaExpression* new_node);
53 static void vala_switch_statement_real_get_error_types (ValaCodeNode* base,
54                                                  ValaCollection* collection,
55                                                  ValaSourceReference* source_reference);
56 static gboolean vala_switch_statement_real_check (ValaCodeNode* base,
57                                            ValaCodeContext* context);
58 static void vala_switch_statement_real_emit (ValaCodeNode* base,
59                                       ValaCodeGenerator* codegen);
60 static void vala_switch_statement_finalize (ValaCodeNode * obj);
61 static GType vala_switch_statement_get_type_once (void);
62 
63 static inline gpointer
vala_switch_statement_get_instance_private(ValaSwitchStatement * self)64 vala_switch_statement_get_instance_private (ValaSwitchStatement* self)
65 {
66 	return G_STRUCT_MEMBER_P (self, ValaSwitchStatement_private_offset);
67 }
68 
69 ValaExpression*
vala_switch_statement_get_expression(ValaSwitchStatement * self)70 vala_switch_statement_get_expression (ValaSwitchStatement* self)
71 {
72 	ValaExpression* result;
73 	ValaExpression* _tmp0_;
74 	g_return_val_if_fail (self != NULL, NULL);
75 	_tmp0_ = self->priv->_expression;
76 	result = _tmp0_;
77 	return result;
78 }
79 
80 static gpointer
_vala_code_node_ref0(gpointer self)81 _vala_code_node_ref0 (gpointer self)
82 {
83 	return self ? vala_code_node_ref (self) : NULL;
84 }
85 
86 void
vala_switch_statement_set_expression(ValaSwitchStatement * self,ValaExpression * value)87 vala_switch_statement_set_expression (ValaSwitchStatement* self,
88                                       ValaExpression* value)
89 {
90 	ValaExpression* _tmp0_;
91 	ValaExpression* _tmp1_;
92 	g_return_if_fail (self != NULL);
93 	_tmp0_ = _vala_code_node_ref0 (value);
94 	_vala_code_node_unref0 (self->priv->_expression);
95 	self->priv->_expression = _tmp0_;
96 	_tmp1_ = self->priv->_expression;
97 	vala_code_node_set_parent_node ((ValaCodeNode*) _tmp1_, (ValaCodeNode*) self);
98 }
99 
100 /**
101  * Creates a new switch statement.
102  *
103  * @param expression       switch expression
104  * @param source_reference reference to source code
105  * @return                 newly created switch statement
106  */
107 ValaSwitchStatement*
vala_switch_statement_construct(GType object_type,ValaExpression * expression,ValaSourceReference * source_reference)108 vala_switch_statement_construct (GType object_type,
109                                  ValaExpression* expression,
110                                  ValaSourceReference* source_reference)
111 {
112 	ValaSwitchStatement* self = NULL;
113 	g_return_val_if_fail (expression != NULL, NULL);
114 	self = (ValaSwitchStatement*) vala_code_node_construct (object_type);
115 	vala_code_node_set_source_reference ((ValaCodeNode*) self, source_reference);
116 	vala_switch_statement_set_expression (self, expression);
117 	return self;
118 }
119 
120 ValaSwitchStatement*
vala_switch_statement_new(ValaExpression * expression,ValaSourceReference * source_reference)121 vala_switch_statement_new (ValaExpression* expression,
122                            ValaSourceReference* source_reference)
123 {
124 	return vala_switch_statement_construct (VALA_TYPE_SWITCH_STATEMENT, expression, source_reference);
125 }
126 
127 /**
128  * Appends the specified section to the list of switch sections.
129  *
130  * @param section a switch section
131  */
132 void
vala_switch_statement_add_section(ValaSwitchStatement * self,ValaSwitchSection * section)133 vala_switch_statement_add_section (ValaSwitchStatement* self,
134                                    ValaSwitchSection* section)
135 {
136 	ValaList* _tmp0_;
137 	g_return_if_fail (self != NULL);
138 	g_return_if_fail (section != NULL);
139 	vala_code_node_set_parent_node ((ValaCodeNode*) section, (ValaCodeNode*) self);
140 	_tmp0_ = self->priv->sections;
141 	vala_collection_add ((ValaCollection*) _tmp0_, section);
142 }
143 
144 /**
145  * Returns the list of switch sections.
146  *
147  * @return section list
148  */
149 ValaList*
vala_switch_statement_get_sections(ValaSwitchStatement * self)150 vala_switch_statement_get_sections (ValaSwitchStatement* self)
151 {
152 	ValaList* _tmp0_;
153 	ValaList* result = NULL;
154 	g_return_val_if_fail (self != NULL, NULL);
155 	_tmp0_ = self->priv->sections;
156 	result = _tmp0_;
157 	return result;
158 }
159 
160 static void
vala_switch_statement_real_accept(ValaCodeNode * base,ValaCodeVisitor * visitor)161 vala_switch_statement_real_accept (ValaCodeNode* base,
162                                    ValaCodeVisitor* visitor)
163 {
164 	ValaSwitchStatement * self;
165 	self = (ValaSwitchStatement*) base;
166 	g_return_if_fail (visitor != NULL);
167 	vala_code_visitor_visit_switch_statement (visitor, self);
168 }
169 
170 static gpointer
_vala_iterable_ref0(gpointer self)171 _vala_iterable_ref0 (gpointer self)
172 {
173 	return self ? vala_iterable_ref (self) : NULL;
174 }
175 
176 static void
vala_switch_statement_real_accept_children(ValaCodeNode * base,ValaCodeVisitor * visitor)177 vala_switch_statement_real_accept_children (ValaCodeNode* base,
178                                             ValaCodeVisitor* visitor)
179 {
180 	ValaSwitchStatement * self;
181 	ValaExpression* _tmp0_;
182 	ValaExpression* _tmp1_;
183 	ValaExpression* _tmp2_;
184 	ValaExpression* _tmp3_;
185 	self = (ValaSwitchStatement*) base;
186 	g_return_if_fail (visitor != NULL);
187 	_tmp0_ = vala_switch_statement_get_expression (self);
188 	_tmp1_ = _tmp0_;
189 	vala_code_node_accept ((ValaCodeNode*) _tmp1_, visitor);
190 	_tmp2_ = vala_switch_statement_get_expression (self);
191 	_tmp3_ = _tmp2_;
192 	vala_code_visitor_visit_end_full_expression (visitor, _tmp3_);
193 	{
194 		ValaList* _section_list = NULL;
195 		ValaList* _tmp4_;
196 		ValaList* _tmp5_;
197 		gint _section_size = 0;
198 		ValaList* _tmp6_;
199 		gint _tmp7_;
200 		gint _tmp8_;
201 		gint _section_index = 0;
202 		_tmp4_ = self->priv->sections;
203 		_tmp5_ = _vala_iterable_ref0 (_tmp4_);
204 		_section_list = _tmp5_;
205 		_tmp6_ = _section_list;
206 		_tmp7_ = vala_collection_get_size ((ValaCollection*) _tmp6_);
207 		_tmp8_ = _tmp7_;
208 		_section_size = _tmp8_;
209 		_section_index = -1;
210 		while (TRUE) {
211 			gint _tmp9_;
212 			gint _tmp10_;
213 			ValaSwitchSection* section = NULL;
214 			ValaList* _tmp11_;
215 			gpointer _tmp12_;
216 			ValaSwitchSection* _tmp13_;
217 			_section_index = _section_index + 1;
218 			_tmp9_ = _section_index;
219 			_tmp10_ = _section_size;
220 			if (!(_tmp9_ < _tmp10_)) {
221 				break;
222 			}
223 			_tmp11_ = _section_list;
224 			_tmp12_ = vala_list_get (_tmp11_, _section_index);
225 			section = (ValaSwitchSection*) _tmp12_;
226 			_tmp13_ = section;
227 			vala_code_node_accept ((ValaCodeNode*) _tmp13_, visitor);
228 			_vala_code_node_unref0 (section);
229 		}
230 		_vala_iterable_unref0 (_section_list);
231 	}
232 }
233 
234 static void
vala_switch_statement_real_replace_expression(ValaCodeNode * base,ValaExpression * old_node,ValaExpression * new_node)235 vala_switch_statement_real_replace_expression (ValaCodeNode* base,
236                                                ValaExpression* old_node,
237                                                ValaExpression* new_node)
238 {
239 	ValaSwitchStatement * self;
240 	ValaExpression* _tmp0_;
241 	ValaExpression* _tmp1_;
242 	self = (ValaSwitchStatement*) base;
243 	g_return_if_fail (old_node != NULL);
244 	g_return_if_fail (new_node != NULL);
245 	_tmp0_ = vala_switch_statement_get_expression (self);
246 	_tmp1_ = _tmp0_;
247 	if (_tmp1_ == old_node) {
248 		vala_switch_statement_set_expression (self, new_node);
249 	}
250 }
251 
252 static void
vala_switch_statement_real_get_error_types(ValaCodeNode * base,ValaCollection * collection,ValaSourceReference * source_reference)253 vala_switch_statement_real_get_error_types (ValaCodeNode* base,
254                                             ValaCollection* collection,
255                                             ValaSourceReference* source_reference)
256 {
257 	ValaSwitchStatement * self;
258 	self = (ValaSwitchStatement*) base;
259 	g_return_if_fail (collection != NULL);
260 	{
261 		ValaList* _section_list = NULL;
262 		ValaList* _tmp0_;
263 		ValaList* _tmp1_;
264 		gint _section_size = 0;
265 		ValaList* _tmp2_;
266 		gint _tmp3_;
267 		gint _tmp4_;
268 		gint _section_index = 0;
269 		_tmp0_ = self->priv->sections;
270 		_tmp1_ = _vala_iterable_ref0 (_tmp0_);
271 		_section_list = _tmp1_;
272 		_tmp2_ = _section_list;
273 		_tmp3_ = vala_collection_get_size ((ValaCollection*) _tmp2_);
274 		_tmp4_ = _tmp3_;
275 		_section_size = _tmp4_;
276 		_section_index = -1;
277 		while (TRUE) {
278 			gint _tmp5_;
279 			gint _tmp6_;
280 			ValaSwitchSection* section = NULL;
281 			ValaList* _tmp7_;
282 			gpointer _tmp8_;
283 			ValaSwitchSection* _tmp9_;
284 			_section_index = _section_index + 1;
285 			_tmp5_ = _section_index;
286 			_tmp6_ = _section_size;
287 			if (!(_tmp5_ < _tmp6_)) {
288 				break;
289 			}
290 			_tmp7_ = _section_list;
291 			_tmp8_ = vala_list_get (_tmp7_, _section_index);
292 			section = (ValaSwitchSection*) _tmp8_;
293 			_tmp9_ = section;
294 			vala_code_node_get_error_types ((ValaCodeNode*) _tmp9_, collection, source_reference);
295 			_vala_code_node_unref0 (section);
296 		}
297 		_vala_iterable_unref0 (_section_list);
298 	}
299 }
300 
301 static gboolean
vala_switch_statement_real_check(ValaCodeNode * base,ValaCodeContext * context)302 vala_switch_statement_real_check (ValaCodeNode* base,
303                                   ValaCodeContext* context)
304 {
305 	ValaSwitchStatement * self;
306 	gboolean _tmp0_;
307 	gboolean _tmp1_;
308 	ValaExpression* _tmp4_;
309 	ValaExpression* _tmp5_;
310 	gboolean _tmp6_ = FALSE;
311 	ValaExpression* _tmp7_;
312 	ValaExpression* _tmp8_;
313 	ValaDataType* _tmp9_;
314 	ValaDataType* _tmp10_;
315 	ValaExpression* _tmp32_;
316 	ValaExpression* _tmp33_;
317 	ValaExpression* _tmp34_;
318 	ValaExpression* _tmp35_;
319 	ValaDataType* _tmp36_;
320 	ValaDataType* _tmp37_;
321 	ValaDataType* _tmp38_;
322 	ValaDataType* _tmp39_;
323 	ValaExpression* _tmp40_;
324 	ValaExpression* _tmp41_;
325 	ValaDataType* _tmp42_;
326 	ValaDataType* _tmp43_;
327 	ValaHashSet* labelset = NULL;
328 	GHashFunc _tmp44_;
329 	GEqualFunc _tmp45_;
330 	ValaHashSet* _tmp46_;
331 	gboolean _tmp100_;
332 	gboolean _tmp101_;
333 	gboolean result = FALSE;
334 	self = (ValaSwitchStatement*) base;
335 	g_return_val_if_fail (context != NULL, FALSE);
336 	_tmp0_ = vala_code_node_get_checked ((ValaCodeNode*) self);
337 	_tmp1_ = _tmp0_;
338 	if (_tmp1_) {
339 		gboolean _tmp2_;
340 		gboolean _tmp3_;
341 		_tmp2_ = vala_code_node_get_error ((ValaCodeNode*) self);
342 		_tmp3_ = _tmp2_;
343 		result = !_tmp3_;
344 		return result;
345 	}
346 	vala_code_node_set_checked ((ValaCodeNode*) self, TRUE);
347 	_tmp4_ = vala_switch_statement_get_expression (self);
348 	_tmp5_ = _tmp4_;
349 	if (!vala_code_node_check ((ValaCodeNode*) _tmp5_, context)) {
350 		vala_code_node_set_error ((ValaCodeNode*) self, TRUE);
351 		result = FALSE;
352 		return result;
353 	}
354 	_tmp7_ = vala_switch_statement_get_expression (self);
355 	_tmp8_ = _tmp7_;
356 	_tmp9_ = vala_expression_get_value_type (_tmp8_);
357 	_tmp10_ = _tmp9_;
358 	if (_tmp10_ == NULL) {
359 		_tmp6_ = TRUE;
360 	} else {
361 		gboolean _tmp11_ = FALSE;
362 		gboolean _tmp12_ = FALSE;
363 		ValaExpression* _tmp13_;
364 		ValaExpression* _tmp14_;
365 		ValaDataType* _tmp15_;
366 		ValaDataType* _tmp16_;
367 		_tmp13_ = vala_switch_statement_get_expression (self);
368 		_tmp14_ = _tmp13_;
369 		_tmp15_ = vala_expression_get_value_type (_tmp14_);
370 		_tmp16_ = _tmp15_;
371 		if (!VALA_IS_INTEGER_TYPE (_tmp16_)) {
372 			ValaExpression* _tmp17_;
373 			ValaExpression* _tmp18_;
374 			ValaDataType* _tmp19_;
375 			ValaDataType* _tmp20_;
376 			_tmp17_ = vala_switch_statement_get_expression (self);
377 			_tmp18_ = _tmp17_;
378 			_tmp19_ = vala_expression_get_value_type (_tmp18_);
379 			_tmp20_ = _tmp19_;
380 			_tmp12_ = !VALA_IS_ENUM_VALUE_TYPE (_tmp20_);
381 		} else {
382 			_tmp12_ = FALSE;
383 		}
384 		if (_tmp12_) {
385 			ValaExpression* _tmp21_;
386 			ValaExpression* _tmp22_;
387 			ValaDataType* _tmp23_;
388 			ValaDataType* _tmp24_;
389 			ValaSemanticAnalyzer* _tmp25_;
390 			ValaSemanticAnalyzer* _tmp26_;
391 			ValaDataType* _tmp27_;
392 			_tmp21_ = vala_switch_statement_get_expression (self);
393 			_tmp22_ = _tmp21_;
394 			_tmp23_ = vala_expression_get_value_type (_tmp22_);
395 			_tmp24_ = _tmp23_;
396 			_tmp25_ = vala_code_context_get_analyzer (context);
397 			_tmp26_ = _tmp25_;
398 			_tmp27_ = _tmp26_->string_type;
399 			_tmp11_ = !vala_data_type_compatible (_tmp24_, _tmp27_);
400 		} else {
401 			_tmp11_ = FALSE;
402 		}
403 		_tmp6_ = _tmp11_;
404 	}
405 	if (_tmp6_) {
406 		ValaExpression* _tmp28_;
407 		ValaExpression* _tmp29_;
408 		ValaSourceReference* _tmp30_;
409 		ValaSourceReference* _tmp31_;
410 		_tmp28_ = vala_switch_statement_get_expression (self);
411 		_tmp29_ = _tmp28_;
412 		_tmp30_ = vala_code_node_get_source_reference ((ValaCodeNode*) _tmp29_);
413 		_tmp31_ = _tmp30_;
414 		vala_report_error (_tmp31_, "Integer or string expression expected");
415 		vala_code_node_set_error ((ValaCodeNode*) self, TRUE);
416 		result = FALSE;
417 		return result;
418 	}
419 	_tmp32_ = vala_switch_statement_get_expression (self);
420 	_tmp33_ = _tmp32_;
421 	_tmp34_ = vala_switch_statement_get_expression (self);
422 	_tmp35_ = _tmp34_;
423 	_tmp36_ = vala_expression_get_value_type (_tmp35_);
424 	_tmp37_ = _tmp36_;
425 	_tmp38_ = vala_data_type_copy (_tmp37_);
426 	_tmp39_ = _tmp38_;
427 	vala_expression_set_target_type (_tmp33_, _tmp39_);
428 	_vala_code_node_unref0 (_tmp39_);
429 	_tmp40_ = vala_switch_statement_get_expression (self);
430 	_tmp41_ = _tmp40_;
431 	_tmp42_ = vala_expression_get_target_type (_tmp41_);
432 	_tmp43_ = _tmp42_;
433 	vala_data_type_set_nullable (_tmp43_, FALSE);
434 	_tmp44_ = g_str_hash;
435 	_tmp45_ = g_str_equal;
436 	_tmp46_ = vala_hash_set_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _tmp44_, _tmp45_);
437 	labelset = _tmp46_;
438 	{
439 		ValaList* _section_list = NULL;
440 		ValaList* _tmp47_;
441 		ValaList* _tmp48_;
442 		gint _section_size = 0;
443 		ValaList* _tmp49_;
444 		gint _tmp50_;
445 		gint _tmp51_;
446 		gint _section_index = 0;
447 		_tmp47_ = self->priv->sections;
448 		_tmp48_ = _vala_iterable_ref0 (_tmp47_);
449 		_section_list = _tmp48_;
450 		_tmp49_ = _section_list;
451 		_tmp50_ = vala_collection_get_size ((ValaCollection*) _tmp49_);
452 		_tmp51_ = _tmp50_;
453 		_section_size = _tmp51_;
454 		_section_index = -1;
455 		while (TRUE) {
456 			gint _tmp52_;
457 			gint _tmp53_;
458 			ValaSwitchSection* section = NULL;
459 			ValaList* _tmp54_;
460 			gpointer _tmp55_;
461 			ValaSwitchSection* _tmp56_;
462 			_section_index = _section_index + 1;
463 			_tmp52_ = _section_index;
464 			_tmp53_ = _section_size;
465 			if (!(_tmp52_ < _tmp53_)) {
466 				break;
467 			}
468 			_tmp54_ = _section_list;
469 			_tmp55_ = vala_list_get (_tmp54_, _section_index);
470 			section = (ValaSwitchSection*) _tmp55_;
471 			_tmp56_ = section;
472 			vala_code_node_check ((ValaCodeNode*) _tmp56_, context);
473 			{
474 				ValaList* _label_list = NULL;
475 				ValaSwitchSection* _tmp57_;
476 				ValaList* _tmp58_;
477 				ValaList* _tmp59_;
478 				gint _label_size = 0;
479 				ValaList* _tmp60_;
480 				gint _tmp61_;
481 				gint _tmp62_;
482 				gint _label_index = 0;
483 				_tmp57_ = section;
484 				_tmp58_ = vala_switch_section_get_labels (_tmp57_);
485 				_tmp59_ = _vala_iterable_ref0 (_tmp58_);
486 				_label_list = _tmp59_;
487 				_tmp60_ = _label_list;
488 				_tmp61_ = vala_collection_get_size ((ValaCollection*) _tmp60_);
489 				_tmp62_ = _tmp61_;
490 				_label_size = _tmp62_;
491 				_label_index = -1;
492 				while (TRUE) {
493 					gint _tmp63_;
494 					gint _tmp64_;
495 					ValaSwitchLabel* label = NULL;
496 					ValaList* _tmp65_;
497 					gpointer _tmp66_;
498 					ValaSwitchLabel* _tmp67_;
499 					ValaExpression* _tmp68_;
500 					ValaExpression* _tmp69_;
501 					_label_index = _label_index + 1;
502 					_tmp63_ = _label_index;
503 					_tmp64_ = _label_size;
504 					if (!(_tmp63_ < _tmp64_)) {
505 						break;
506 					}
507 					_tmp65_ = _label_list;
508 					_tmp66_ = vala_list_get (_tmp65_, _label_index);
509 					label = (ValaSwitchLabel*) _tmp66_;
510 					_tmp67_ = label;
511 					_tmp68_ = vala_switch_label_get_expression (_tmp67_);
512 					_tmp69_ = _tmp68_;
513 					if (_tmp69_ != NULL) {
514 						gchar* value = NULL;
515 						ValaSwitchLabel* _tmp70_;
516 						ValaExpression* _tmp71_;
517 						ValaExpression* _tmp72_;
518 						gboolean _tmp91_ = FALSE;
519 						const gchar* _tmp92_;
520 						value = NULL;
521 						_tmp70_ = label;
522 						_tmp71_ = vala_switch_label_get_expression (_tmp70_);
523 						_tmp72_ = _tmp71_;
524 						if (VALA_IS_STRING_LITERAL (_tmp72_)) {
525 							ValaSwitchLabel* _tmp73_;
526 							ValaExpression* _tmp74_;
527 							ValaExpression* _tmp75_;
528 							gchar* _tmp76_;
529 							_tmp73_ = label;
530 							_tmp74_ = vala_switch_label_get_expression (_tmp73_);
531 							_tmp75_ = _tmp74_;
532 							_tmp76_ = vala_string_literal_eval (G_TYPE_CHECK_INSTANCE_CAST (_tmp75_, VALA_TYPE_STRING_LITERAL, ValaStringLiteral));
533 							_g_free0 (value);
534 							value = _tmp76_;
535 						} else {
536 							ValaSwitchLabel* _tmp77_;
537 							ValaExpression* _tmp78_;
538 							ValaExpression* _tmp79_;
539 							_tmp77_ = label;
540 							_tmp78_ = vala_switch_label_get_expression (_tmp77_);
541 							_tmp79_ = _tmp78_;
542 							if (VALA_IS_LITERAL (_tmp79_)) {
543 								ValaSwitchLabel* _tmp80_;
544 								ValaExpression* _tmp81_;
545 								ValaExpression* _tmp82_;
546 								gchar* _tmp83_;
547 								_tmp80_ = label;
548 								_tmp81_ = vala_switch_label_get_expression (_tmp80_);
549 								_tmp82_ = _tmp81_;
550 								_tmp83_ = vala_code_node_to_string ((ValaCodeNode*) G_TYPE_CHECK_INSTANCE_CAST (_tmp82_, VALA_TYPE_LITERAL, ValaLiteral));
551 								_g_free0 (value);
552 								value = _tmp83_;
553 							} else {
554 								ValaSwitchLabel* _tmp84_;
555 								ValaExpression* _tmp85_;
556 								ValaExpression* _tmp86_;
557 								_tmp84_ = label;
558 								_tmp85_ = vala_switch_label_get_expression (_tmp84_);
559 								_tmp86_ = _tmp85_;
560 								if (vala_expression_is_constant (_tmp86_)) {
561 									ValaSwitchLabel* _tmp87_;
562 									ValaExpression* _tmp88_;
563 									ValaExpression* _tmp89_;
564 									gchar* _tmp90_;
565 									_tmp87_ = label;
566 									_tmp88_ = vala_switch_label_get_expression (_tmp87_);
567 									_tmp89_ = _tmp88_;
568 									_tmp90_ = vala_code_node_to_string ((ValaCodeNode*) _tmp89_);
569 									_g_free0 (value);
570 									value = _tmp90_;
571 								}
572 							}
573 						}
574 						_tmp92_ = value;
575 						if (_tmp92_ != NULL) {
576 							ValaHashSet* _tmp93_;
577 							const gchar* _tmp94_;
578 							_tmp93_ = labelset;
579 							_tmp94_ = value;
580 							_tmp91_ = !vala_collection_add ((ValaCollection*) _tmp93_, _tmp94_);
581 						} else {
582 							_tmp91_ = FALSE;
583 						}
584 						if (_tmp91_) {
585 							ValaSwitchLabel* _tmp95_;
586 							ValaExpression* _tmp96_;
587 							ValaExpression* _tmp97_;
588 							ValaSourceReference* _tmp98_;
589 							ValaSourceReference* _tmp99_;
590 							vala_code_node_set_error ((ValaCodeNode*) self, TRUE);
591 							_tmp95_ = label;
592 							_tmp96_ = vala_switch_label_get_expression (_tmp95_);
593 							_tmp97_ = _tmp96_;
594 							_tmp98_ = vala_code_node_get_source_reference ((ValaCodeNode*) _tmp97_);
595 							_tmp99_ = _tmp98_;
596 							vala_report_error (_tmp99_, "Switch statement already contains this label");
597 						}
598 						_g_free0 (value);
599 					}
600 					_vala_code_node_unref0 (label);
601 				}
602 				_vala_iterable_unref0 (_label_list);
603 			}
604 			_vala_code_node_unref0 (section);
605 		}
606 		_vala_iterable_unref0 (_section_list);
607 	}
608 	_tmp100_ = vala_code_node_get_error ((ValaCodeNode*) self);
609 	_tmp101_ = _tmp100_;
610 	result = !_tmp101_;
611 	_vala_iterable_unref0 (labelset);
612 	return result;
613 }
614 
615 static void
vala_switch_statement_real_emit(ValaCodeNode * base,ValaCodeGenerator * codegen)616 vala_switch_statement_real_emit (ValaCodeNode* base,
617                                  ValaCodeGenerator* codegen)
618 {
619 	ValaSwitchStatement * self;
620 	ValaExpression* _tmp0_;
621 	ValaExpression* _tmp1_;
622 	ValaExpression* _tmp2_;
623 	ValaExpression* _tmp3_;
624 	self = (ValaSwitchStatement*) base;
625 	g_return_if_fail (codegen != NULL);
626 	_tmp0_ = vala_switch_statement_get_expression (self);
627 	_tmp1_ = _tmp0_;
628 	vala_code_node_emit ((ValaCodeNode*) _tmp1_, codegen);
629 	_tmp2_ = vala_switch_statement_get_expression (self);
630 	_tmp3_ = _tmp2_;
631 	vala_code_visitor_visit_end_full_expression ((ValaCodeVisitor*) codegen, _tmp3_);
632 	vala_code_visitor_visit_switch_statement ((ValaCodeVisitor*) codegen, self);
633 }
634 
635 static void
vala_switch_statement_class_init(ValaSwitchStatementClass * klass,gpointer klass_data)636 vala_switch_statement_class_init (ValaSwitchStatementClass * klass,
637                                   gpointer klass_data)
638 {
639 	vala_switch_statement_parent_class = g_type_class_peek_parent (klass);
640 	((ValaCodeNodeClass *) klass)->finalize = vala_switch_statement_finalize;
641 	g_type_class_adjust_private_offset (klass, &ValaSwitchStatement_private_offset);
642 	((ValaCodeNodeClass *) klass)->accept = (void (*) (ValaCodeNode*, ValaCodeVisitor*)) vala_switch_statement_real_accept;
643 	((ValaCodeNodeClass *) klass)->accept_children = (void (*) (ValaCodeNode*, ValaCodeVisitor*)) vala_switch_statement_real_accept_children;
644 	((ValaCodeNodeClass *) klass)->replace_expression = (void (*) (ValaCodeNode*, ValaExpression*, ValaExpression*)) vala_switch_statement_real_replace_expression;
645 	((ValaCodeNodeClass *) klass)->get_error_types = (void (*) (ValaCodeNode*, ValaCollection*, ValaSourceReference*)) vala_switch_statement_real_get_error_types;
646 	((ValaCodeNodeClass *) klass)->check = (gboolean (*) (ValaCodeNode*, ValaCodeContext*)) vala_switch_statement_real_check;
647 	((ValaCodeNodeClass *) klass)->emit = (void (*) (ValaCodeNode*, ValaCodeGenerator*)) vala_switch_statement_real_emit;
648 }
649 
650 static void
vala_switch_statement_vala_statement_interface_init(ValaStatementIface * iface,gpointer iface_data)651 vala_switch_statement_vala_statement_interface_init (ValaStatementIface * iface,
652                                                      gpointer iface_data)
653 {
654 	vala_switch_statement_vala_statement_parent_iface = g_type_interface_peek_parent (iface);
655 }
656 
657 static void
vala_switch_statement_instance_init(ValaSwitchStatement * self,gpointer klass)658 vala_switch_statement_instance_init (ValaSwitchStatement * self,
659                                      gpointer klass)
660 {
661 	GEqualFunc _tmp0_;
662 	ValaArrayList* _tmp1_;
663 	self->priv = vala_switch_statement_get_instance_private (self);
664 	_tmp0_ = g_direct_equal;
665 	_tmp1_ = vala_array_list_new (VALA_TYPE_SWITCH_SECTION, (GBoxedCopyFunc) vala_code_node_ref, (GDestroyNotify) vala_code_node_unref, _tmp0_);
666 	self->priv->sections = (ValaList*) _tmp1_;
667 }
668 
669 static void
vala_switch_statement_finalize(ValaCodeNode * obj)670 vala_switch_statement_finalize (ValaCodeNode * obj)
671 {
672 	ValaSwitchStatement * self;
673 	self = G_TYPE_CHECK_INSTANCE_CAST (obj, VALA_TYPE_SWITCH_STATEMENT, ValaSwitchStatement);
674 	_vala_code_node_unref0 (self->priv->_expression);
675 	_vala_iterable_unref0 (self->priv->sections);
676 	VALA_CODE_NODE_CLASS (vala_switch_statement_parent_class)->finalize (obj);
677 }
678 
679 /**
680  * Represents a switch selection statement in the source code.
681  */
682 static GType
vala_switch_statement_get_type_once(void)683 vala_switch_statement_get_type_once (void)
684 {
685 	static const GTypeInfo g_define_type_info = { sizeof (ValaSwitchStatementClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) vala_switch_statement_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ValaSwitchStatement), 0, (GInstanceInitFunc) vala_switch_statement_instance_init, NULL };
686 	static const GInterfaceInfo vala_statement_info = { (GInterfaceInitFunc) vala_switch_statement_vala_statement_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
687 	GType vala_switch_statement_type_id;
688 	vala_switch_statement_type_id = g_type_register_static (VALA_TYPE_CODE_NODE, "ValaSwitchStatement", &g_define_type_info, 0);
689 	g_type_add_interface_static (vala_switch_statement_type_id, VALA_TYPE_STATEMENT, &vala_statement_info);
690 	ValaSwitchStatement_private_offset = g_type_add_instance_private (vala_switch_statement_type_id, sizeof (ValaSwitchStatementPrivate));
691 	return vala_switch_statement_type_id;
692 }
693 
694 GType
vala_switch_statement_get_type(void)695 vala_switch_statement_get_type (void)
696 {
697 	static volatile gsize vala_switch_statement_type_id__volatile = 0;
698 	if (g_once_init_enter (&vala_switch_statement_type_id__volatile)) {
699 		GType vala_switch_statement_type_id;
700 		vala_switch_statement_type_id = vala_switch_statement_get_type_once ();
701 		g_once_init_leave (&vala_switch_statement_type_id__volatile, vala_switch_statement_type_id);
702 	}
703 	return vala_switch_statement_type_id__volatile;
704 }
705 
706