1 /* valaenum.c generated by valac, the Vala compiler
2 * generated from valaenum.vala, do not modify */
3
4 /* valaenum.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 <string.h>
31 #include <stdlib.h>
32
33 #define _g_free0(var) ((var == NULL) ? NULL : (var = (g_free (var), NULL)))
34 #define _vala_iterable_unref0(var) ((var == NULL) ? NULL : (var = (vala_iterable_unref (var), NULL)))
35 #define _vala_code_node_unref0(var) ((var == NULL) ? NULL : (var = (vala_code_node_unref (var), NULL)))
36 #define _vala_source_file_unref0(var) ((var == NULL) ? NULL : (var = (vala_source_file_unref (var), NULL)))
37
38 struct _ValaEnumPrivate {
39 ValaList* values;
40 ValaList* methods;
41 ValaList* constants;
42 gboolean* _is_flags;
43 };
44
45 static gint ValaEnum_private_offset;
46 static gpointer vala_enum_parent_class = NULL;
47
48 static gboolean* _bool_dup (gboolean* self);
49 static void vala_enum_real_add_method (ValaSymbol* base,
50 ValaMethod* m);
51 static void vala_enum_real_add_constant (ValaSymbol* base,
52 ValaConstant* c);
53 static void vala_enum_real_accept (ValaCodeNode* base,
54 ValaCodeVisitor* visitor);
55 static void vala_enum_real_accept_children (ValaCodeNode* base,
56 ValaCodeVisitor* visitor);
57 static gboolean vala_enum_real_is_reference_type (ValaTypeSymbol* base);
58 static gboolean vala_enum_real_check (ValaCodeNode* base,
59 ValaCodeContext* context);
60 static void vala_enum_finalize (ValaCodeNode * obj);
61 static GType vala_enum_get_type_once (void);
62
63 static inline gpointer
vala_enum_get_instance_private(ValaEnum * self)64 vala_enum_get_instance_private (ValaEnum* self)
65 {
66 return G_STRUCT_MEMBER_P (self, ValaEnum_private_offset);
67 }
68
69 static gboolean*
_bool_dup(gboolean * self)70 _bool_dup (gboolean* self)
71 {
72 gboolean* dup;
73 dup = g_new0 (gboolean, 1);
74 memcpy (dup, self, sizeof (gboolean));
75 return dup;
76 }
77
78 static gpointer
__bool_dup0(gpointer self)79 __bool_dup0 (gpointer self)
80 {
81 return self ? _bool_dup (self) : NULL;
82 }
83
84 gboolean
vala_enum_get_is_flags(ValaEnum * self)85 vala_enum_get_is_flags (ValaEnum* self)
86 {
87 gboolean result;
88 gboolean* _tmp0_;
89 gboolean* _tmp4_;
90 g_return_val_if_fail (self != NULL, FALSE);
91 _tmp0_ = self->priv->_is_flags;
92 if (_tmp0_ == NULL) {
93 ValaAttribute* _tmp1_;
94 gboolean _tmp2_;
95 gboolean* _tmp3_;
96 _tmp1_ = vala_code_node_get_attribute ((ValaCodeNode*) self, "Flags");
97 _tmp2_ = _tmp1_ != NULL;
98 _tmp3_ = __bool_dup0 (&_tmp2_);
99 _g_free0 (self->priv->_is_flags);
100 self->priv->_is_flags = _tmp3_;
101 }
102 _tmp4_ = self->priv->_is_flags;
103 result = *_tmp4_;
104 return result;
105 }
106
107 /**
108 * Creates a new enum.
109 *
110 * @param name type name
111 * @param source_reference reference to source code
112 * @return newly created enum
113 */
114 ValaEnum*
vala_enum_construct(GType object_type,const gchar * name,ValaSourceReference * source_reference,ValaComment * comment)115 vala_enum_construct (GType object_type,
116 const gchar* name,
117 ValaSourceReference* source_reference,
118 ValaComment* comment)
119 {
120 ValaEnum* self = NULL;
121 g_return_val_if_fail (name != NULL, NULL);
122 self = (ValaEnum*) vala_typesymbol_construct (object_type, name, source_reference, comment);
123 return self;
124 }
125
126 ValaEnum*
vala_enum_new(const gchar * name,ValaSourceReference * source_reference,ValaComment * comment)127 vala_enum_new (const gchar* name,
128 ValaSourceReference* source_reference,
129 ValaComment* comment)
130 {
131 return vala_enum_construct (VALA_TYPE_ENUM, name, source_reference, comment);
132 }
133
134 /**
135 * Appends the specified enum value to the list of values.
136 *
137 * @param value an enum value
138 */
139 void
vala_enum_add_value(ValaEnum * self,ValaEnumValue * value)140 vala_enum_add_value (ValaEnum* self,
141 ValaEnumValue* value)
142 {
143 ValaList* _tmp0_;
144 ValaScope* _tmp1_;
145 ValaScope* _tmp2_;
146 const gchar* _tmp3_;
147 const gchar* _tmp4_;
148 g_return_if_fail (self != NULL);
149 g_return_if_fail (value != NULL);
150 vala_symbol_set_access ((ValaSymbol*) value, VALA_SYMBOL_ACCESSIBILITY_PUBLIC);
151 _tmp0_ = self->priv->values;
152 vala_collection_add ((ValaCollection*) _tmp0_, value);
153 _tmp1_ = vala_symbol_get_scope ((ValaSymbol*) self);
154 _tmp2_ = _tmp1_;
155 _tmp3_ = vala_symbol_get_name ((ValaSymbol*) value);
156 _tmp4_ = _tmp3_;
157 vala_scope_add (_tmp2_, _tmp4_, (ValaSymbol*) value);
158 }
159
160 /**
161 * Adds the specified method as a member to this enum.
162 *
163 * @param m a method
164 */
165 static void
vala_enum_real_add_method(ValaSymbol * base,ValaMethod * m)166 vala_enum_real_add_method (ValaSymbol* base,
167 ValaMethod* m)
168 {
169 ValaEnum * self;
170 ValaMemberBinding _tmp2_;
171 ValaMemberBinding _tmp3_;
172 gboolean _tmp18_ = FALSE;
173 ValaDataType* _tmp19_;
174 ValaDataType* _tmp20_;
175 ValaList* _tmp34_;
176 ValaScope* _tmp35_;
177 ValaScope* _tmp36_;
178 const gchar* _tmp37_;
179 const gchar* _tmp38_;
180 self = (ValaEnum*) base;
181 g_return_if_fail (m != NULL);
182 if (VALA_IS_CREATION_METHOD (m)) {
183 ValaSourceReference* _tmp0_;
184 ValaSourceReference* _tmp1_;
185 _tmp0_ = vala_code_node_get_source_reference ((ValaCodeNode*) m);
186 _tmp1_ = _tmp0_;
187 vala_report_error (_tmp1_, "construction methods may only be declared within classes and structs");
188 vala_code_node_set_error ((ValaCodeNode*) m, TRUE);
189 return;
190 }
191 _tmp2_ = vala_method_get_binding (m);
192 _tmp3_ = _tmp2_;
193 if (_tmp3_ == VALA_MEMBER_BINDING_INSTANCE) {
194 ValaEnumValueType* _tmp4_;
195 ValaEnumValueType* _tmp5_;
196 ValaSourceReference* _tmp6_;
197 ValaSourceReference* _tmp7_;
198 ValaParameter* _tmp8_;
199 ValaParameter* _tmp9_;
200 ValaScope* _tmp10_;
201 ValaScope* _tmp11_;
202 ValaParameter* _tmp12_;
203 ValaParameter* _tmp13_;
204 const gchar* _tmp14_;
205 const gchar* _tmp15_;
206 ValaParameter* _tmp16_;
207 ValaParameter* _tmp17_;
208 _tmp4_ = vala_enum_value_type_new (self);
209 _tmp5_ = _tmp4_;
210 _tmp6_ = vala_code_node_get_source_reference ((ValaCodeNode*) m);
211 _tmp7_ = _tmp6_;
212 _tmp8_ = vala_parameter_new ("this", (ValaDataType*) _tmp5_, _tmp7_);
213 _tmp9_ = _tmp8_;
214 vala_method_set_this_parameter (m, _tmp9_);
215 _vala_code_node_unref0 (_tmp9_);
216 _vala_code_node_unref0 (_tmp5_);
217 _tmp10_ = vala_symbol_get_scope ((ValaSymbol*) m);
218 _tmp11_ = _tmp10_;
219 _tmp12_ = vala_method_get_this_parameter (m);
220 _tmp13_ = _tmp12_;
221 _tmp14_ = vala_symbol_get_name ((ValaSymbol*) _tmp13_);
222 _tmp15_ = _tmp14_;
223 _tmp16_ = vala_method_get_this_parameter (m);
224 _tmp17_ = _tmp16_;
225 vala_scope_add (_tmp11_, _tmp15_, (ValaSymbol*) _tmp17_);
226 }
227 _tmp19_ = vala_callable_get_return_type ((ValaCallable*) m);
228 _tmp20_ = _tmp19_;
229 if (!VALA_IS_VOID_TYPE (_tmp20_)) {
230 ValaList* _tmp21_;
231 gint _tmp22_;
232 gint _tmp23_;
233 _tmp21_ = vala_method_get_postconditions (m);
234 _tmp22_ = vala_collection_get_size ((ValaCollection*) _tmp21_);
235 _tmp23_ = _tmp22_;
236 _tmp18_ = _tmp23_ > 0;
237 } else {
238 _tmp18_ = FALSE;
239 }
240 if (_tmp18_) {
241 ValaDataType* _tmp24_;
242 ValaDataType* _tmp25_;
243 ValaDataType* _tmp26_;
244 ValaDataType* _tmp27_;
245 ValaSourceReference* _tmp28_;
246 ValaSourceReference* _tmp29_;
247 ValaLocalVariable* _tmp30_;
248 ValaLocalVariable* _tmp31_;
249 ValaLocalVariable* _tmp32_;
250 ValaLocalVariable* _tmp33_;
251 _tmp24_ = vala_callable_get_return_type ((ValaCallable*) m);
252 _tmp25_ = _tmp24_;
253 _tmp26_ = vala_data_type_copy (_tmp25_);
254 _tmp27_ = _tmp26_;
255 _tmp28_ = vala_code_node_get_source_reference ((ValaCodeNode*) m);
256 _tmp29_ = _tmp28_;
257 _tmp30_ = vala_local_variable_new (_tmp27_, "result", NULL, _tmp29_);
258 _tmp31_ = _tmp30_;
259 vala_subroutine_set_result_var ((ValaSubroutine*) m, _tmp31_);
260 _vala_code_node_unref0 (_tmp31_);
261 _vala_code_node_unref0 (_tmp27_);
262 _tmp32_ = vala_subroutine_get_result_var ((ValaSubroutine*) m);
263 _tmp33_ = _tmp32_;
264 vala_local_variable_set_is_result (_tmp33_, TRUE);
265 }
266 _tmp34_ = self->priv->methods;
267 vala_collection_add ((ValaCollection*) _tmp34_, m);
268 _tmp35_ = vala_symbol_get_scope ((ValaSymbol*) self);
269 _tmp36_ = _tmp35_;
270 _tmp37_ = vala_symbol_get_name ((ValaSymbol*) m);
271 _tmp38_ = _tmp37_;
272 vala_scope_add (_tmp36_, _tmp38_, (ValaSymbol*) m);
273 }
274
275 /**
276 * Adds the specified constant as a member to this enum.
277 *
278 * @param c a constant
279 */
280 static void
vala_enum_real_add_constant(ValaSymbol * base,ValaConstant * c)281 vala_enum_real_add_constant (ValaSymbol* base,
282 ValaConstant* c)
283 {
284 ValaEnum * self;
285 ValaList* _tmp0_;
286 ValaScope* _tmp1_;
287 ValaScope* _tmp2_;
288 const gchar* _tmp3_;
289 const gchar* _tmp4_;
290 self = (ValaEnum*) base;
291 g_return_if_fail (c != NULL);
292 _tmp0_ = self->priv->constants;
293 vala_collection_add ((ValaCollection*) _tmp0_, c);
294 _tmp1_ = vala_symbol_get_scope ((ValaSymbol*) self);
295 _tmp2_ = _tmp1_;
296 _tmp3_ = vala_symbol_get_name ((ValaSymbol*) c);
297 _tmp4_ = _tmp3_;
298 vala_scope_add (_tmp2_, _tmp4_, (ValaSymbol*) c);
299 }
300
301 /**
302 * Returns the list of enum values.
303 *
304 * @return list of enum values
305 */
306 ValaList*
vala_enum_get_values(ValaEnum * self)307 vala_enum_get_values (ValaEnum* self)
308 {
309 ValaList* _tmp0_;
310 ValaList* result = NULL;
311 g_return_val_if_fail (self != NULL, NULL);
312 _tmp0_ = self->priv->values;
313 result = _tmp0_;
314 return result;
315 }
316
317 /**
318 * Returns the list of methods.
319 *
320 * @return list of methods
321 */
322 ValaList*
vala_enum_get_methods(ValaEnum * self)323 vala_enum_get_methods (ValaEnum* self)
324 {
325 ValaList* _tmp0_;
326 ValaList* result = NULL;
327 g_return_val_if_fail (self != NULL, NULL);
328 _tmp0_ = self->priv->methods;
329 result = _tmp0_;
330 return result;
331 }
332
333 /**
334 * Returns the list of constants.
335 *
336 * @return list of constants
337 */
338 ValaList*
vala_enum_get_constants(ValaEnum * self)339 vala_enum_get_constants (ValaEnum* self)
340 {
341 ValaList* _tmp0_;
342 ValaList* result = NULL;
343 g_return_val_if_fail (self != NULL, NULL);
344 _tmp0_ = self->priv->constants;
345 result = _tmp0_;
346 return result;
347 }
348
349 static void
vala_enum_real_accept(ValaCodeNode * base,ValaCodeVisitor * visitor)350 vala_enum_real_accept (ValaCodeNode* base,
351 ValaCodeVisitor* visitor)
352 {
353 ValaEnum * self;
354 self = (ValaEnum*) base;
355 g_return_if_fail (visitor != NULL);
356 vala_code_visitor_visit_enum (visitor, self);
357 }
358
359 static gpointer
_vala_iterable_ref0(gpointer self)360 _vala_iterable_ref0 (gpointer self)
361 {
362 return self ? vala_iterable_ref (self) : NULL;
363 }
364
365 static void
vala_enum_real_accept_children(ValaCodeNode * base,ValaCodeVisitor * visitor)366 vala_enum_real_accept_children (ValaCodeNode* base,
367 ValaCodeVisitor* visitor)
368 {
369 ValaEnum * self;
370 self = (ValaEnum*) base;
371 g_return_if_fail (visitor != NULL);
372 {
373 ValaList* _value_list = NULL;
374 ValaList* _tmp0_;
375 ValaList* _tmp1_;
376 gint _value_size = 0;
377 ValaList* _tmp2_;
378 gint _tmp3_;
379 gint _tmp4_;
380 gint _value_index = 0;
381 _tmp0_ = self->priv->values;
382 _tmp1_ = _vala_iterable_ref0 (_tmp0_);
383 _value_list = _tmp1_;
384 _tmp2_ = _value_list;
385 _tmp3_ = vala_collection_get_size ((ValaCollection*) _tmp2_);
386 _tmp4_ = _tmp3_;
387 _value_size = _tmp4_;
388 _value_index = -1;
389 while (TRUE) {
390 gint _tmp5_;
391 gint _tmp6_;
392 ValaEnumValue* value = NULL;
393 ValaList* _tmp7_;
394 gpointer _tmp8_;
395 ValaEnumValue* _tmp9_;
396 _value_index = _value_index + 1;
397 _tmp5_ = _value_index;
398 _tmp6_ = _value_size;
399 if (!(_tmp5_ < _tmp6_)) {
400 break;
401 }
402 _tmp7_ = _value_list;
403 _tmp8_ = vala_list_get (_tmp7_, _value_index);
404 value = (ValaEnumValue*) _tmp8_;
405 _tmp9_ = value;
406 vala_code_node_accept ((ValaCodeNode*) _tmp9_, visitor);
407 _vala_code_node_unref0 (value);
408 }
409 _vala_iterable_unref0 (_value_list);
410 }
411 {
412 ValaList* _m_list = NULL;
413 ValaList* _tmp10_;
414 ValaList* _tmp11_;
415 gint _m_size = 0;
416 ValaList* _tmp12_;
417 gint _tmp13_;
418 gint _tmp14_;
419 gint _m_index = 0;
420 _tmp10_ = self->priv->methods;
421 _tmp11_ = _vala_iterable_ref0 (_tmp10_);
422 _m_list = _tmp11_;
423 _tmp12_ = _m_list;
424 _tmp13_ = vala_collection_get_size ((ValaCollection*) _tmp12_);
425 _tmp14_ = _tmp13_;
426 _m_size = _tmp14_;
427 _m_index = -1;
428 while (TRUE) {
429 gint _tmp15_;
430 gint _tmp16_;
431 ValaMethod* m = NULL;
432 ValaList* _tmp17_;
433 gpointer _tmp18_;
434 ValaMethod* _tmp19_;
435 _m_index = _m_index + 1;
436 _tmp15_ = _m_index;
437 _tmp16_ = _m_size;
438 if (!(_tmp15_ < _tmp16_)) {
439 break;
440 }
441 _tmp17_ = _m_list;
442 _tmp18_ = vala_list_get (_tmp17_, _m_index);
443 m = (ValaMethod*) _tmp18_;
444 _tmp19_ = m;
445 vala_code_node_accept ((ValaCodeNode*) _tmp19_, visitor);
446 _vala_code_node_unref0 (m);
447 }
448 _vala_iterable_unref0 (_m_list);
449 }
450 {
451 ValaList* _c_list = NULL;
452 ValaList* _tmp20_;
453 ValaList* _tmp21_;
454 gint _c_size = 0;
455 ValaList* _tmp22_;
456 gint _tmp23_;
457 gint _tmp24_;
458 gint _c_index = 0;
459 _tmp20_ = self->priv->constants;
460 _tmp21_ = _vala_iterable_ref0 (_tmp20_);
461 _c_list = _tmp21_;
462 _tmp22_ = _c_list;
463 _tmp23_ = vala_collection_get_size ((ValaCollection*) _tmp22_);
464 _tmp24_ = _tmp23_;
465 _c_size = _tmp24_;
466 _c_index = -1;
467 while (TRUE) {
468 gint _tmp25_;
469 gint _tmp26_;
470 ValaConstant* c = NULL;
471 ValaList* _tmp27_;
472 gpointer _tmp28_;
473 ValaConstant* _tmp29_;
474 _c_index = _c_index + 1;
475 _tmp25_ = _c_index;
476 _tmp26_ = _c_size;
477 if (!(_tmp25_ < _tmp26_)) {
478 break;
479 }
480 _tmp27_ = _c_list;
481 _tmp28_ = vala_list_get (_tmp27_, _c_index);
482 c = (ValaConstant*) _tmp28_;
483 _tmp29_ = c;
484 vala_code_node_accept ((ValaCodeNode*) _tmp29_, visitor);
485 _vala_code_node_unref0 (c);
486 }
487 _vala_iterable_unref0 (_c_list);
488 }
489 }
490
491 static gboolean
vala_enum_real_is_reference_type(ValaTypeSymbol * base)492 vala_enum_real_is_reference_type (ValaTypeSymbol* base)
493 {
494 ValaEnum * self;
495 gboolean result = FALSE;
496 self = (ValaEnum*) base;
497 result = FALSE;
498 return result;
499 }
500
501 static gpointer
_vala_source_file_ref0(gpointer self)502 _vala_source_file_ref0 (gpointer self)
503 {
504 return self ? vala_source_file_ref (self) : NULL;
505 }
506
507 static gpointer
_vala_code_node_ref0(gpointer self)508 _vala_code_node_ref0 (gpointer self)
509 {
510 return self ? vala_code_node_ref (self) : NULL;
511 }
512
513 static gboolean
vala_enum_real_check(ValaCodeNode * base,ValaCodeContext * context)514 vala_enum_real_check (ValaCodeNode* base,
515 ValaCodeContext* context)
516 {
517 ValaEnum * self;
518 gboolean _tmp0_;
519 gboolean _tmp1_;
520 ValaSourceFile* old_source_file = NULL;
521 ValaSemanticAnalyzer* _tmp4_;
522 ValaSemanticAnalyzer* _tmp5_;
523 ValaSourceFile* _tmp6_;
524 ValaSourceFile* _tmp7_;
525 ValaSourceFile* _tmp8_;
526 ValaSymbol* old_symbol = NULL;
527 ValaSemanticAnalyzer* _tmp9_;
528 ValaSemanticAnalyzer* _tmp10_;
529 ValaSymbol* _tmp11_;
530 ValaSymbol* _tmp12_;
531 ValaSymbol* _tmp13_;
532 ValaSourceReference* _tmp14_;
533 ValaSourceReference* _tmp15_;
534 ValaSemanticAnalyzer* _tmp22_;
535 ValaSemanticAnalyzer* _tmp23_;
536 ValaList* _tmp24_;
537 gint _tmp25_;
538 gint _tmp26_;
539 ValaSemanticAnalyzer* _tmp63_;
540 ValaSemanticAnalyzer* _tmp64_;
541 ValaSourceFile* _tmp65_;
542 ValaSemanticAnalyzer* _tmp66_;
543 ValaSemanticAnalyzer* _tmp67_;
544 ValaSymbol* _tmp68_;
545 gboolean _tmp69_;
546 gboolean _tmp70_;
547 gboolean result = FALSE;
548 self = (ValaEnum*) base;
549 g_return_val_if_fail (context != NULL, FALSE);
550 _tmp0_ = vala_code_node_get_checked ((ValaCodeNode*) self);
551 _tmp1_ = _tmp0_;
552 if (_tmp1_) {
553 gboolean _tmp2_;
554 gboolean _tmp3_;
555 _tmp2_ = vala_code_node_get_error ((ValaCodeNode*) self);
556 _tmp3_ = _tmp2_;
557 result = !_tmp3_;
558 return result;
559 }
560 vala_code_node_set_checked ((ValaCodeNode*) self, TRUE);
561 _tmp4_ = vala_code_context_get_analyzer (context);
562 _tmp5_ = _tmp4_;
563 _tmp6_ = vala_semantic_analyzer_get_current_source_file (_tmp5_);
564 _tmp7_ = _tmp6_;
565 _tmp8_ = _vala_source_file_ref0 (_tmp7_);
566 old_source_file = _tmp8_;
567 _tmp9_ = vala_code_context_get_analyzer (context);
568 _tmp10_ = _tmp9_;
569 _tmp11_ = vala_semantic_analyzer_get_current_symbol (_tmp10_);
570 _tmp12_ = _tmp11_;
571 _tmp13_ = _vala_code_node_ref0 (_tmp12_);
572 old_symbol = _tmp13_;
573 _tmp14_ = vala_code_node_get_source_reference ((ValaCodeNode*) self);
574 _tmp15_ = _tmp14_;
575 if (_tmp15_ != NULL) {
576 ValaSemanticAnalyzer* _tmp16_;
577 ValaSemanticAnalyzer* _tmp17_;
578 ValaSourceReference* _tmp18_;
579 ValaSourceReference* _tmp19_;
580 ValaSourceFile* _tmp20_;
581 ValaSourceFile* _tmp21_;
582 _tmp16_ = vala_code_context_get_analyzer (context);
583 _tmp17_ = _tmp16_;
584 _tmp18_ = vala_code_node_get_source_reference ((ValaCodeNode*) self);
585 _tmp19_ = _tmp18_;
586 _tmp20_ = vala_source_reference_get_file (_tmp19_);
587 _tmp21_ = _tmp20_;
588 vala_semantic_analyzer_set_current_source_file (_tmp17_, _tmp21_);
589 }
590 _tmp22_ = vala_code_context_get_analyzer (context);
591 _tmp23_ = _tmp22_;
592 vala_semantic_analyzer_set_current_symbol (_tmp23_, (ValaSymbol*) self);
593 _tmp24_ = self->priv->values;
594 _tmp25_ = vala_collection_get_size ((ValaCollection*) _tmp24_);
595 _tmp26_ = _tmp25_;
596 if (_tmp26_ <= 0) {
597 ValaSourceReference* _tmp27_;
598 ValaSourceReference* _tmp28_;
599 gchar* _tmp29_;
600 gchar* _tmp30_;
601 gchar* _tmp31_;
602 gchar* _tmp32_;
603 _tmp27_ = vala_code_node_get_source_reference ((ValaCodeNode*) self);
604 _tmp28_ = _tmp27_;
605 _tmp29_ = vala_symbol_get_full_name ((ValaSymbol*) self);
606 _tmp30_ = _tmp29_;
607 _tmp31_ = g_strdup_printf ("Enum `%s' requires at least one value", _tmp30_);
608 _tmp32_ = _tmp31_;
609 vala_report_error (_tmp28_, _tmp32_);
610 _g_free0 (_tmp32_);
611 _g_free0 (_tmp30_);
612 vala_code_node_set_error ((ValaCodeNode*) self, TRUE);
613 result = FALSE;
614 _vala_code_node_unref0 (old_symbol);
615 _vala_source_file_unref0 (old_source_file);
616 return result;
617 }
618 {
619 ValaList* _value_list = NULL;
620 ValaList* _tmp33_;
621 ValaList* _tmp34_;
622 gint _value_size = 0;
623 ValaList* _tmp35_;
624 gint _tmp36_;
625 gint _tmp37_;
626 gint _value_index = 0;
627 _tmp33_ = self->priv->values;
628 _tmp34_ = _vala_iterable_ref0 (_tmp33_);
629 _value_list = _tmp34_;
630 _tmp35_ = _value_list;
631 _tmp36_ = vala_collection_get_size ((ValaCollection*) _tmp35_);
632 _tmp37_ = _tmp36_;
633 _value_size = _tmp37_;
634 _value_index = -1;
635 while (TRUE) {
636 gint _tmp38_;
637 gint _tmp39_;
638 ValaEnumValue* value = NULL;
639 ValaList* _tmp40_;
640 gpointer _tmp41_;
641 ValaEnumValue* _tmp42_;
642 _value_index = _value_index + 1;
643 _tmp38_ = _value_index;
644 _tmp39_ = _value_size;
645 if (!(_tmp38_ < _tmp39_)) {
646 break;
647 }
648 _tmp40_ = _value_list;
649 _tmp41_ = vala_list_get (_tmp40_, _value_index);
650 value = (ValaEnumValue*) _tmp41_;
651 _tmp42_ = value;
652 vala_code_node_check ((ValaCodeNode*) _tmp42_, context);
653 _vala_code_node_unref0 (value);
654 }
655 _vala_iterable_unref0 (_value_list);
656 }
657 {
658 ValaList* _m_list = NULL;
659 ValaList* _tmp43_;
660 ValaList* _tmp44_;
661 gint _m_size = 0;
662 ValaList* _tmp45_;
663 gint _tmp46_;
664 gint _tmp47_;
665 gint _m_index = 0;
666 _tmp43_ = self->priv->methods;
667 _tmp44_ = _vala_iterable_ref0 (_tmp43_);
668 _m_list = _tmp44_;
669 _tmp45_ = _m_list;
670 _tmp46_ = vala_collection_get_size ((ValaCollection*) _tmp45_);
671 _tmp47_ = _tmp46_;
672 _m_size = _tmp47_;
673 _m_index = -1;
674 while (TRUE) {
675 gint _tmp48_;
676 gint _tmp49_;
677 ValaMethod* m = NULL;
678 ValaList* _tmp50_;
679 gpointer _tmp51_;
680 ValaMethod* _tmp52_;
681 _m_index = _m_index + 1;
682 _tmp48_ = _m_index;
683 _tmp49_ = _m_size;
684 if (!(_tmp48_ < _tmp49_)) {
685 break;
686 }
687 _tmp50_ = _m_list;
688 _tmp51_ = vala_list_get (_tmp50_, _m_index);
689 m = (ValaMethod*) _tmp51_;
690 _tmp52_ = m;
691 vala_code_node_check ((ValaCodeNode*) _tmp52_, context);
692 _vala_code_node_unref0 (m);
693 }
694 _vala_iterable_unref0 (_m_list);
695 }
696 {
697 ValaList* _c_list = NULL;
698 ValaList* _tmp53_;
699 ValaList* _tmp54_;
700 gint _c_size = 0;
701 ValaList* _tmp55_;
702 gint _tmp56_;
703 gint _tmp57_;
704 gint _c_index = 0;
705 _tmp53_ = self->priv->constants;
706 _tmp54_ = _vala_iterable_ref0 (_tmp53_);
707 _c_list = _tmp54_;
708 _tmp55_ = _c_list;
709 _tmp56_ = vala_collection_get_size ((ValaCollection*) _tmp55_);
710 _tmp57_ = _tmp56_;
711 _c_size = _tmp57_;
712 _c_index = -1;
713 while (TRUE) {
714 gint _tmp58_;
715 gint _tmp59_;
716 ValaConstant* c = NULL;
717 ValaList* _tmp60_;
718 gpointer _tmp61_;
719 ValaConstant* _tmp62_;
720 _c_index = _c_index + 1;
721 _tmp58_ = _c_index;
722 _tmp59_ = _c_size;
723 if (!(_tmp58_ < _tmp59_)) {
724 break;
725 }
726 _tmp60_ = _c_list;
727 _tmp61_ = vala_list_get (_tmp60_, _c_index);
728 c = (ValaConstant*) _tmp61_;
729 _tmp62_ = c;
730 vala_code_node_check ((ValaCodeNode*) _tmp62_, context);
731 _vala_code_node_unref0 (c);
732 }
733 _vala_iterable_unref0 (_c_list);
734 }
735 _tmp63_ = vala_code_context_get_analyzer (context);
736 _tmp64_ = _tmp63_;
737 _tmp65_ = old_source_file;
738 vala_semantic_analyzer_set_current_source_file (_tmp64_, _tmp65_);
739 _tmp66_ = vala_code_context_get_analyzer (context);
740 _tmp67_ = _tmp66_;
741 _tmp68_ = old_symbol;
742 vala_semantic_analyzer_set_current_symbol (_tmp67_, _tmp68_);
743 _tmp69_ = vala_code_node_get_error ((ValaCodeNode*) self);
744 _tmp70_ = _tmp69_;
745 result = !_tmp70_;
746 _vala_code_node_unref0 (old_symbol);
747 _vala_source_file_unref0 (old_source_file);
748 return result;
749 }
750
751 static void
vala_enum_class_init(ValaEnumClass * klass,gpointer klass_data)752 vala_enum_class_init (ValaEnumClass * klass,
753 gpointer klass_data)
754 {
755 vala_enum_parent_class = g_type_class_peek_parent (klass);
756 ((ValaCodeNodeClass *) klass)->finalize = vala_enum_finalize;
757 g_type_class_adjust_private_offset (klass, &ValaEnum_private_offset);
758 ((ValaSymbolClass *) klass)->add_method = (void (*) (ValaSymbol*, ValaMethod*)) vala_enum_real_add_method;
759 ((ValaSymbolClass *) klass)->add_constant = (void (*) (ValaSymbol*, ValaConstant*)) vala_enum_real_add_constant;
760 ((ValaCodeNodeClass *) klass)->accept = (void (*) (ValaCodeNode*, ValaCodeVisitor*)) vala_enum_real_accept;
761 ((ValaCodeNodeClass *) klass)->accept_children = (void (*) (ValaCodeNode*, ValaCodeVisitor*)) vala_enum_real_accept_children;
762 ((ValaTypeSymbolClass *) klass)->is_reference_type = (gboolean (*) (ValaTypeSymbol*)) vala_enum_real_is_reference_type;
763 ((ValaCodeNodeClass *) klass)->check = (gboolean (*) (ValaCodeNode*, ValaCodeContext*)) vala_enum_real_check;
764 }
765
766 static void
vala_enum_instance_init(ValaEnum * self,gpointer klass)767 vala_enum_instance_init (ValaEnum * self,
768 gpointer klass)
769 {
770 GEqualFunc _tmp0_;
771 ValaArrayList* _tmp1_;
772 GEqualFunc _tmp2_;
773 ValaArrayList* _tmp3_;
774 GEqualFunc _tmp4_;
775 ValaArrayList* _tmp5_;
776 self->priv = vala_enum_get_instance_private (self);
777 _tmp0_ = g_direct_equal;
778 _tmp1_ = vala_array_list_new (VALA_TYPE_ENUM_VALUE, (GBoxedCopyFunc) vala_code_node_ref, (GDestroyNotify) vala_code_node_unref, _tmp0_);
779 self->priv->values = (ValaList*) _tmp1_;
780 _tmp2_ = g_direct_equal;
781 _tmp3_ = vala_array_list_new (VALA_TYPE_METHOD, (GBoxedCopyFunc) vala_code_node_ref, (GDestroyNotify) vala_code_node_unref, _tmp2_);
782 self->priv->methods = (ValaList*) _tmp3_;
783 _tmp4_ = g_direct_equal;
784 _tmp5_ = vala_array_list_new (VALA_TYPE_CONSTANT, (GBoxedCopyFunc) vala_code_node_ref, (GDestroyNotify) vala_code_node_unref, _tmp4_);
785 self->priv->constants = (ValaList*) _tmp5_;
786 }
787
788 static void
vala_enum_finalize(ValaCodeNode * obj)789 vala_enum_finalize (ValaCodeNode * obj)
790 {
791 ValaEnum * self;
792 self = G_TYPE_CHECK_INSTANCE_CAST (obj, VALA_TYPE_ENUM, ValaEnum);
793 _vala_iterable_unref0 (self->priv->values);
794 _vala_iterable_unref0 (self->priv->methods);
795 _vala_iterable_unref0 (self->priv->constants);
796 _g_free0 (self->priv->_is_flags);
797 VALA_CODE_NODE_CLASS (vala_enum_parent_class)->finalize (obj);
798 }
799
800 /**
801 * Represents an enum declaration in the source code.
802 */
803 static GType
vala_enum_get_type_once(void)804 vala_enum_get_type_once (void)
805 {
806 static const GTypeInfo g_define_type_info = { sizeof (ValaEnumClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) vala_enum_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ValaEnum), 0, (GInstanceInitFunc) vala_enum_instance_init, NULL };
807 GType vala_enum_type_id;
808 vala_enum_type_id = g_type_register_static (VALA_TYPE_TYPESYMBOL, "ValaEnum", &g_define_type_info, 0);
809 ValaEnum_private_offset = g_type_add_instance_private (vala_enum_type_id, sizeof (ValaEnumPrivate));
810 return vala_enum_type_id;
811 }
812
813 GType
vala_enum_get_type(void)814 vala_enum_get_type (void)
815 {
816 static volatile gsize vala_enum_type_id__volatile = 0;
817 if (g_once_init_enter (&vala_enum_type_id__volatile)) {
818 GType vala_enum_type_id;
819 vala_enum_type_id = vala_enum_get_type_once ();
820 g_once_init_leave (&vala_enum_type_id__volatile, vala_enum_type_id);
821 }
822 return vala_enum_type_id__volatile;
823 }
824
825