1 /* valaconstant.c generated by valac, the Vala compiler
2  * generated from valaconstant.vala, do not modify */
3 
4 /* valaconstant.vala
5  *
6  * Copyright (C) 2006-2011  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 <glib.h>
28 #include <stdlib.h>
29 #include <string.h>
30 #include <valagee.h>
31 
32 #define _vala_code_node_unref0(var) ((var == NULL) ? NULL : (var = (vala_code_node_unref (var), NULL)))
33 #define _g_free0(var) (var = (g_free (var), NULL))
34 #define _vala_source_file_unref0(var) ((var == NULL) ? NULL : (var = (vala_source_file_unref (var), NULL)))
35 
36 struct _ValaConstantPrivate {
37 	ValaDataType* _data_type;
38 	ValaExpression* _value;
39 };
40 
41 static gint ValaConstant_private_offset;
42 static gpointer vala_constant_parent_class = NULL;
43 
44 static void vala_constant_real_accept (ValaCodeNode* base,
45                                 ValaCodeVisitor* visitor);
46 static void vala_constant_real_accept_children (ValaCodeNode* base,
47                                          ValaCodeVisitor* visitor);
48 static void vala_constant_real_replace_expression (ValaCodeNode* base,
49                                             ValaExpression* old_node,
50                                             ValaExpression* new_node);
51 static void vala_constant_real_replace_type (ValaCodeNode* base,
52                                       ValaDataType* old_type,
53                                       ValaDataType* new_type);
54 static gboolean vala_constant_real_check (ValaCodeNode* base,
55                                    ValaCodeContext* context);
56 static gboolean vala_constant_check_const_type (ValaConstant* self,
57                                          ValaDataType* type,
58                                          ValaCodeContext* context);
59 static void vala_constant_finalize (ValaCodeNode * obj);
60 static GType vala_constant_get_type_once (void);
61 
62 static inline gpointer
vala_constant_get_instance_private(ValaConstant * self)63 vala_constant_get_instance_private (ValaConstant* self)
64 {
65 	return G_STRUCT_MEMBER_P (self, ValaConstant_private_offset);
66 }
67 
68 ValaDataType*
vala_constant_get_type_reference(ValaConstant * self)69 vala_constant_get_type_reference (ValaConstant* self)
70 {
71 	ValaDataType* result;
72 	ValaDataType* _tmp0_;
73 	g_return_val_if_fail (self != NULL, NULL);
74 	_tmp0_ = self->priv->_data_type;
75 	result = _tmp0_;
76 	return result;
77 }
78 
79 static gpointer
_vala_code_node_ref0(gpointer self)80 _vala_code_node_ref0 (gpointer self)
81 {
82 	return self ? vala_code_node_ref (self) : NULL;
83 }
84 
85 void
vala_constant_set_type_reference(ValaConstant * self,ValaDataType * value)86 vala_constant_set_type_reference (ValaConstant* self,
87                                   ValaDataType* value)
88 {
89 	ValaDataType* _tmp0_;
90 	ValaDataType* _tmp1_;
91 	g_return_if_fail (self != NULL);
92 	_tmp0_ = _vala_code_node_ref0 (value);
93 	_vala_code_node_unref0 (self->priv->_data_type);
94 	self->priv->_data_type = _tmp0_;
95 	_tmp1_ = self->priv->_data_type;
96 	vala_code_node_set_parent_node ((ValaCodeNode*) _tmp1_, (ValaCodeNode*) self);
97 }
98 
99 ValaExpression*
vala_constant_get_value(ValaConstant * self)100 vala_constant_get_value (ValaConstant* self)
101 {
102 	ValaExpression* result;
103 	ValaExpression* _tmp0_;
104 	g_return_val_if_fail (self != NULL, NULL);
105 	_tmp0_ = self->priv->_value;
106 	result = _tmp0_;
107 	return result;
108 }
109 
110 void
vala_constant_set_value(ValaConstant * self,ValaExpression * value)111 vala_constant_set_value (ValaConstant* self,
112                          ValaExpression* value)
113 {
114 	ValaExpression* _tmp0_;
115 	ValaExpression* _tmp1_;
116 	g_return_if_fail (self != NULL);
117 	_tmp0_ = _vala_code_node_ref0 (value);
118 	_vala_code_node_unref0 (self->priv->_value);
119 	self->priv->_value = _tmp0_;
120 	_tmp1_ = self->priv->_value;
121 	if (_tmp1_ != NULL) {
122 		ValaExpression* _tmp2_;
123 		_tmp2_ = self->priv->_value;
124 		vala_code_node_set_parent_node ((ValaCodeNode*) _tmp2_, (ValaCodeNode*) self);
125 	}
126 }
127 
128 /**
129  * Creates a new constant.
130  *
131  * @param name             constant name
132  * @param type_reference   constant type
133  * @param value            constant value
134  * @param source_reference reference to source code
135  * @return                 newly created constant
136  */
137 ValaConstant*
vala_constant_construct(GType object_type,const gchar * name,ValaDataType * type_reference,ValaExpression * value,ValaSourceReference * source_reference,ValaComment * comment)138 vala_constant_construct (GType object_type,
139                          const gchar* name,
140                          ValaDataType* type_reference,
141                          ValaExpression* value,
142                          ValaSourceReference* source_reference,
143                          ValaComment* comment)
144 {
145 	ValaConstant* self = NULL;
146 	g_return_val_if_fail (name != NULL, NULL);
147 	self = (ValaConstant*) vala_symbol_construct (object_type, name, source_reference, comment);
148 	if (type_reference != NULL) {
149 		vala_constant_set_type_reference (self, type_reference);
150 	}
151 	vala_constant_set_value (self, value);
152 	return self;
153 }
154 
155 ValaConstant*
vala_constant_new(const gchar * name,ValaDataType * type_reference,ValaExpression * value,ValaSourceReference * source_reference,ValaComment * comment)156 vala_constant_new (const gchar* name,
157                    ValaDataType* type_reference,
158                    ValaExpression* value,
159                    ValaSourceReference* source_reference,
160                    ValaComment* comment)
161 {
162 	return vala_constant_construct (VALA_TYPE_CONSTANT, name, type_reference, value, source_reference, comment);
163 }
164 
165 static void
vala_constant_real_accept(ValaCodeNode * base,ValaCodeVisitor * visitor)166 vala_constant_real_accept (ValaCodeNode* base,
167                            ValaCodeVisitor* visitor)
168 {
169 	ValaConstant * self;
170 	self = (ValaConstant*) base;
171 	g_return_if_fail (visitor != NULL);
172 	vala_code_visitor_visit_constant (visitor, self);
173 }
174 
175 static void
vala_constant_real_accept_children(ValaCodeNode * base,ValaCodeVisitor * visitor)176 vala_constant_real_accept_children (ValaCodeNode* base,
177                                     ValaCodeVisitor* visitor)
178 {
179 	ValaConstant * self;
180 	ValaDataType* _tmp0_;
181 	ValaDataType* _tmp1_;
182 	ValaExpression* _tmp2_;
183 	ValaExpression* _tmp3_;
184 	self = (ValaConstant*) base;
185 	g_return_if_fail (visitor != NULL);
186 	_tmp0_ = vala_constant_get_type_reference (self);
187 	_tmp1_ = _tmp0_;
188 	vala_code_node_accept ((ValaCodeNode*) _tmp1_, visitor);
189 	_tmp2_ = vala_constant_get_value (self);
190 	_tmp3_ = _tmp2_;
191 	if (_tmp3_ != NULL) {
192 		ValaExpression* _tmp4_;
193 		ValaExpression* _tmp5_;
194 		_tmp4_ = vala_constant_get_value (self);
195 		_tmp5_ = _tmp4_;
196 		vala_code_node_accept ((ValaCodeNode*) _tmp5_, visitor);
197 	}
198 }
199 
200 static void
vala_constant_real_replace_expression(ValaCodeNode * base,ValaExpression * old_node,ValaExpression * new_node)201 vala_constant_real_replace_expression (ValaCodeNode* base,
202                                        ValaExpression* old_node,
203                                        ValaExpression* new_node)
204 {
205 	ValaConstant * self;
206 	ValaExpression* _tmp0_;
207 	ValaExpression* _tmp1_;
208 	self = (ValaConstant*) base;
209 	g_return_if_fail (old_node != NULL);
210 	g_return_if_fail (new_node != NULL);
211 	_tmp0_ = vala_constant_get_value (self);
212 	_tmp1_ = _tmp0_;
213 	if (_tmp1_ == old_node) {
214 		vala_constant_set_value (self, new_node);
215 	}
216 }
217 
218 static void
vala_constant_real_replace_type(ValaCodeNode * base,ValaDataType * old_type,ValaDataType * new_type)219 vala_constant_real_replace_type (ValaCodeNode* base,
220                                  ValaDataType* old_type,
221                                  ValaDataType* new_type)
222 {
223 	ValaConstant * self;
224 	ValaDataType* _tmp0_;
225 	ValaDataType* _tmp1_;
226 	self = (ValaConstant*) base;
227 	g_return_if_fail (old_type != NULL);
228 	g_return_if_fail (new_type != NULL);
229 	_tmp0_ = vala_constant_get_type_reference (self);
230 	_tmp1_ = _tmp0_;
231 	if (_tmp1_ == old_type) {
232 		vala_constant_set_type_reference (self, new_type);
233 	}
234 }
235 
236 static gpointer
_vala_source_file_ref0(gpointer self)237 _vala_source_file_ref0 (gpointer self)
238 {
239 	return self ? vala_source_file_ref (self) : NULL;
240 }
241 
242 static gboolean
vala_constant_real_check(ValaCodeNode * base,ValaCodeContext * context)243 vala_constant_real_check (ValaCodeNode* base,
244                           ValaCodeContext* context)
245 {
246 	ValaConstant * self;
247 	gboolean _tmp0_;
248 	gboolean _tmp1_;
249 	ValaSourceFile* old_source_file = NULL;
250 	ValaSemanticAnalyzer* _tmp4_;
251 	ValaSemanticAnalyzer* _tmp5_;
252 	ValaSourceFile* _tmp6_;
253 	ValaSourceFile* _tmp7_;
254 	ValaSourceFile* _tmp8_;
255 	ValaSymbol* old_symbol = NULL;
256 	ValaSemanticAnalyzer* _tmp9_;
257 	ValaSemanticAnalyzer* _tmp10_;
258 	ValaSymbol* _tmp11_;
259 	ValaSymbol* _tmp12_;
260 	ValaSymbol* _tmp13_;
261 	ValaSourceReference* _tmp14_;
262 	ValaSourceReference* _tmp15_;
263 	ValaSymbol* _tmp22_;
264 	ValaSymbol* _tmp23_;
265 	ValaDataType* _tmp26_;
266 	ValaDataType* _tmp27_;
267 	ValaDataType* _tmp28_;
268 	ValaDataType* _tmp29_;
269 	gboolean _tmp38_;
270 	gboolean _tmp39_;
271 	gboolean _tmp110_ = FALSE;
272 	gboolean _tmp111_ = FALSE;
273 	gboolean _tmp112_;
274 	gboolean _tmp113_;
275 	ValaSemanticAnalyzer* _tmp128_;
276 	ValaSemanticAnalyzer* _tmp129_;
277 	ValaSourceFile* _tmp130_;
278 	ValaSemanticAnalyzer* _tmp131_;
279 	ValaSemanticAnalyzer* _tmp132_;
280 	ValaSymbol* _tmp133_;
281 	gboolean _tmp134_;
282 	gboolean _tmp135_;
283 	gboolean result = FALSE;
284 	self = (ValaConstant*) base;
285 	g_return_val_if_fail (context != NULL, FALSE);
286 	_tmp0_ = vala_code_node_get_checked ((ValaCodeNode*) self);
287 	_tmp1_ = _tmp0_;
288 	if (_tmp1_) {
289 		gboolean _tmp2_;
290 		gboolean _tmp3_;
291 		_tmp2_ = vala_code_node_get_error ((ValaCodeNode*) self);
292 		_tmp3_ = _tmp2_;
293 		result = !_tmp3_;
294 		return result;
295 	}
296 	vala_code_node_set_checked ((ValaCodeNode*) self, TRUE);
297 	_tmp4_ = vala_code_context_get_analyzer (context);
298 	_tmp5_ = _tmp4_;
299 	_tmp6_ = vala_semantic_analyzer_get_current_source_file (_tmp5_);
300 	_tmp7_ = _tmp6_;
301 	_tmp8_ = _vala_source_file_ref0 (_tmp7_);
302 	old_source_file = _tmp8_;
303 	_tmp9_ = vala_code_context_get_analyzer (context);
304 	_tmp10_ = _tmp9_;
305 	_tmp11_ = vala_semantic_analyzer_get_current_symbol (_tmp10_);
306 	_tmp12_ = _tmp11_;
307 	_tmp13_ = _vala_code_node_ref0 (_tmp12_);
308 	old_symbol = _tmp13_;
309 	_tmp14_ = vala_code_node_get_source_reference ((ValaCodeNode*) self);
310 	_tmp15_ = _tmp14_;
311 	if (_tmp15_ != NULL) {
312 		ValaSemanticAnalyzer* _tmp16_;
313 		ValaSemanticAnalyzer* _tmp17_;
314 		ValaSourceReference* _tmp18_;
315 		ValaSourceReference* _tmp19_;
316 		ValaSourceFile* _tmp20_;
317 		ValaSourceFile* _tmp21_;
318 		_tmp16_ = vala_code_context_get_analyzer (context);
319 		_tmp17_ = _tmp16_;
320 		_tmp18_ = vala_code_node_get_source_reference ((ValaCodeNode*) self);
321 		_tmp19_ = _tmp18_;
322 		_tmp20_ = vala_source_reference_get_file (_tmp19_);
323 		_tmp21_ = _tmp20_;
324 		vala_semantic_analyzer_set_current_source_file (_tmp17_, _tmp21_);
325 	}
326 	_tmp22_ = vala_symbol_get_parent_symbol ((ValaSymbol*) self);
327 	_tmp23_ = _tmp22_;
328 	if (!VALA_IS_BLOCK (_tmp23_)) {
329 		ValaSemanticAnalyzer* _tmp24_;
330 		ValaSemanticAnalyzer* _tmp25_;
331 		_tmp24_ = vala_code_context_get_analyzer (context);
332 		_tmp25_ = _tmp24_;
333 		vala_semantic_analyzer_set_current_symbol (_tmp25_, (ValaSymbol*) self);
334 	}
335 	_tmp26_ = vala_constant_get_type_reference (self);
336 	_tmp27_ = _tmp26_;
337 	vala_code_node_check ((ValaCodeNode*) _tmp27_, context);
338 	_tmp28_ = vala_constant_get_type_reference (self);
339 	_tmp29_ = _tmp28_;
340 	if (!vala_constant_check_const_type (self, _tmp29_, context)) {
341 		ValaSourceReference* _tmp30_;
342 		ValaSourceReference* _tmp31_;
343 		ValaDataType* _tmp32_;
344 		ValaDataType* _tmp33_;
345 		gchar* _tmp34_;
346 		gchar* _tmp35_;
347 		gchar* _tmp36_;
348 		gchar* _tmp37_;
349 		vala_code_node_set_error ((ValaCodeNode*) self, TRUE);
350 		_tmp30_ = vala_code_node_get_source_reference ((ValaCodeNode*) self);
351 		_tmp31_ = _tmp30_;
352 		_tmp32_ = vala_constant_get_type_reference (self);
353 		_tmp33_ = _tmp32_;
354 		_tmp34_ = vala_code_node_to_string ((ValaCodeNode*) _tmp33_);
355 		_tmp35_ = _tmp34_;
356 		_tmp36_ = g_strdup_printf ("`%s' not supported as type for constants", _tmp35_);
357 		_tmp37_ = _tmp36_;
358 		vala_report_error (_tmp31_, _tmp37_);
359 		_g_free0 (_tmp37_);
360 		_g_free0 (_tmp35_);
361 		result = FALSE;
362 		_vala_code_node_unref0 (old_symbol);
363 		_vala_source_file_unref0 (old_source_file);
364 		return result;
365 	}
366 	_tmp38_ = vala_symbol_get_external ((ValaSymbol*) self);
367 	_tmp39_ = _tmp38_;
368 	if (!_tmp39_) {
369 		ValaExpression* _tmp40_;
370 		ValaExpression* _tmp41_;
371 		_tmp40_ = vala_constant_get_value (self);
372 		_tmp41_ = _tmp40_;
373 		if (_tmp41_ == NULL) {
374 			ValaSourceFileType _tmp42_;
375 			ValaSourceFileType _tmp43_;
376 			_tmp42_ = vala_symbol_get_source_type ((ValaSymbol*) self);
377 			_tmp43_ = _tmp42_;
378 			if (_tmp43_ != VALA_SOURCE_FILE_TYPE_FAST) {
379 				ValaSourceReference* _tmp44_;
380 				ValaSourceReference* _tmp45_;
381 				vala_code_node_set_error ((ValaCodeNode*) self, TRUE);
382 				_tmp44_ = vala_code_node_get_source_reference ((ValaCodeNode*) self);
383 				_tmp45_ = _tmp44_;
384 				vala_report_error (_tmp45_, "A const field requires a value to be provided");
385 			}
386 		} else {
387 			ValaExpression* _tmp46_;
388 			ValaExpression* _tmp47_;
389 			ValaDataType* _tmp48_;
390 			ValaDataType* _tmp49_;
391 			gboolean _tmp50_ = FALSE;
392 			ValaExpression* _tmp51_;
393 			ValaExpression* _tmp52_;
394 			ValaExpression* _tmp57_;
395 			ValaExpression* _tmp58_;
396 			ValaDataType* _tmp59_;
397 			ValaDataType* _tmp60_;
398 			ValaDataType* _tmp61_;
399 			ValaDataType* _tmp62_;
400 			ValaMethodCall* call = NULL;
401 			ValaExpression* _tmp77_;
402 			ValaExpression* _tmp78_;
403 			ValaMethodCall* _tmp79_;
404 			ValaExpression* _tmp100_;
405 			ValaExpression* _tmp101_;
406 			_tmp46_ = vala_constant_get_value (self);
407 			_tmp47_ = _tmp46_;
408 			_tmp48_ = vala_constant_get_type_reference (self);
409 			_tmp49_ = _tmp48_;
410 			vala_expression_set_target_type (_tmp47_, _tmp49_);
411 			_tmp51_ = vala_constant_get_value (self);
412 			_tmp52_ = _tmp51_;
413 			if (!vala_code_node_check ((ValaCodeNode*) _tmp52_, context)) {
414 				_tmp50_ = TRUE;
415 			} else {
416 				ValaDataType* _tmp53_;
417 				ValaDataType* _tmp54_;
418 				gboolean _tmp55_;
419 				gboolean _tmp56_;
420 				_tmp53_ = vala_constant_get_type_reference (self);
421 				_tmp54_ = _tmp53_;
422 				_tmp55_ = vala_code_node_get_error ((ValaCodeNode*) _tmp54_);
423 				_tmp56_ = _tmp55_;
424 				_tmp50_ = _tmp56_;
425 			}
426 			if (_tmp50_) {
427 				vala_code_node_set_error ((ValaCodeNode*) self, TRUE);
428 				result = FALSE;
429 				_vala_code_node_unref0 (old_symbol);
430 				_vala_source_file_unref0 (old_source_file);
431 				return result;
432 			}
433 			_tmp57_ = vala_constant_get_value (self);
434 			_tmp58_ = _tmp57_;
435 			_tmp59_ = vala_expression_get_value_type (_tmp58_);
436 			_tmp60_ = _tmp59_;
437 			_tmp61_ = vala_constant_get_type_reference (self);
438 			_tmp62_ = _tmp61_;
439 			if (!vala_data_type_compatible (_tmp60_, _tmp62_)) {
440 				ValaSourceReference* _tmp63_;
441 				ValaSourceReference* _tmp64_;
442 				ValaExpression* _tmp65_;
443 				ValaExpression* _tmp66_;
444 				ValaDataType* _tmp67_;
445 				ValaDataType* _tmp68_;
446 				gchar* _tmp69_;
447 				gchar* _tmp70_;
448 				ValaDataType* _tmp71_;
449 				ValaDataType* _tmp72_;
450 				gchar* _tmp73_;
451 				gchar* _tmp74_;
452 				gchar* _tmp75_;
453 				gchar* _tmp76_;
454 				vala_code_node_set_error ((ValaCodeNode*) self, TRUE);
455 				_tmp63_ = vala_code_node_get_source_reference ((ValaCodeNode*) self);
456 				_tmp64_ = _tmp63_;
457 				_tmp65_ = vala_constant_get_value (self);
458 				_tmp66_ = _tmp65_;
459 				_tmp67_ = vala_expression_get_value_type (_tmp66_);
460 				_tmp68_ = _tmp67_;
461 				_tmp69_ = vala_code_node_to_string ((ValaCodeNode*) _tmp68_);
462 				_tmp70_ = _tmp69_;
463 				_tmp71_ = vala_constant_get_type_reference (self);
464 				_tmp72_ = _tmp71_;
465 				_tmp73_ = vala_code_node_to_string ((ValaCodeNode*) _tmp72_);
466 				_tmp74_ = _tmp73_;
467 				_tmp75_ = g_strdup_printf ("Cannot convert from `%s' to `%s'", _tmp70_, _tmp74_);
468 				_tmp76_ = _tmp75_;
469 				vala_report_error (_tmp64_, _tmp76_);
470 				_g_free0 (_tmp76_);
471 				_g_free0 (_tmp74_);
472 				_g_free0 (_tmp70_);
473 				result = FALSE;
474 				_vala_code_node_unref0 (old_symbol);
475 				_vala_source_file_unref0 (old_source_file);
476 				return result;
477 			}
478 			_tmp77_ = vala_constant_get_value (self);
479 			_tmp78_ = _tmp77_;
480 			call = VALA_IS_METHOD_CALL (_tmp78_) ? ((ValaMethodCall*) _tmp78_) : NULL;
481 			_tmp79_ = call;
482 			if (_tmp79_ != NULL) {
483 				ValaMethodType* method_type = NULL;
484 				ValaMethodCall* _tmp80_;
485 				ValaExpression* _tmp81_;
486 				ValaExpression* _tmp82_;
487 				ValaDataType* _tmp83_;
488 				ValaDataType* _tmp84_;
489 				gboolean _tmp85_ = FALSE;
490 				ValaMethodType* _tmp86_;
491 				_tmp80_ = call;
492 				_tmp81_ = vala_method_call_get_call (_tmp80_);
493 				_tmp82_ = _tmp81_;
494 				_tmp83_ = vala_expression_get_value_type (_tmp82_);
495 				_tmp84_ = _tmp83_;
496 				method_type = VALA_IS_METHOD_TYPE (_tmp84_) ? ((ValaMethodType*) _tmp84_) : NULL;
497 				_tmp86_ = method_type;
498 				if (_tmp86_ != NULL) {
499 					ValaMethodType* _tmp87_;
500 					ValaMethod* _tmp88_;
501 					ValaMethod* _tmp89_;
502 					gchar* _tmp90_;
503 					gchar* _tmp91_;
504 					_tmp87_ = method_type;
505 					_tmp88_ = vala_method_type_get_method_symbol (_tmp87_);
506 					_tmp89_ = _tmp88_;
507 					_tmp90_ = vala_symbol_get_full_name ((ValaSymbol*) _tmp89_);
508 					_tmp91_ = _tmp90_;
509 					_tmp85_ = g_strcmp0 (_tmp91_, "GLib._") == 0;
510 					_g_free0 (_tmp91_);
511 				} else {
512 					_tmp85_ = FALSE;
513 				}
514 				if (_tmp85_) {
515 					ValaStringLiteral* literal = NULL;
516 					ValaMethodCall* _tmp92_;
517 					ValaList* _tmp93_;
518 					gpointer _tmp94_;
519 					ValaExpression* _tmp95_;
520 					ValaStringLiteral* _tmp96_;
521 					ValaStringLiteral* _tmp97_;
522 					_tmp92_ = call;
523 					_tmp93_ = vala_method_call_get_argument_list (_tmp92_);
524 					_tmp94_ = vala_list_get (_tmp93_, 0);
525 					_tmp95_ = (ValaExpression*) _tmp94_;
526 					_tmp96_ = VALA_IS_STRING_LITERAL (_tmp95_) ? ((ValaStringLiteral*) _tmp95_) : NULL;
527 					if (_tmp96_ == NULL) {
528 						_vala_code_node_unref0 (_tmp95_);
529 					}
530 					literal = _tmp96_;
531 					_tmp97_ = literal;
532 					if (_tmp97_ != NULL) {
533 						ValaStringLiteral* _tmp98_;
534 						ValaStringLiteral* _tmp99_;
535 						_tmp98_ = literal;
536 						vala_constant_set_value (self, (ValaExpression*) _tmp98_);
537 						_tmp99_ = literal;
538 						vala_string_literal_set_translate (_tmp99_, TRUE);
539 					}
540 					_vala_code_node_unref0 (literal);
541 				}
542 			}
543 			_tmp100_ = vala_constant_get_value (self);
544 			_tmp101_ = _tmp100_;
545 			if (!vala_expression_is_constant (_tmp101_)) {
546 				ValaExpression* _tmp102_;
547 				ValaExpression* _tmp103_;
548 				ValaSourceReference* _tmp104_;
549 				ValaSourceReference* _tmp105_;
550 				vala_code_node_set_error ((ValaCodeNode*) self, TRUE);
551 				_tmp102_ = vala_constant_get_value (self);
552 				_tmp103_ = _tmp102_;
553 				_tmp104_ = vala_code_node_get_source_reference ((ValaCodeNode*) _tmp103_);
554 				_tmp105_ = _tmp104_;
555 				vala_report_error (_tmp105_, "Value must be constant");
556 				result = FALSE;
557 				_vala_code_node_unref0 (old_symbol);
558 				_vala_source_file_unref0 (old_source_file);
559 				return result;
560 			}
561 		}
562 	} else {
563 		ValaExpression* _tmp106_;
564 		ValaExpression* _tmp107_;
565 		_tmp106_ = vala_constant_get_value (self);
566 		_tmp107_ = _tmp106_;
567 		if (_tmp107_ != NULL) {
568 			ValaSourceReference* _tmp108_;
569 			ValaSourceReference* _tmp109_;
570 			vala_code_node_set_error ((ValaCodeNode*) self, TRUE);
571 			_tmp108_ = vala_code_node_get_source_reference ((ValaCodeNode*) self);
572 			_tmp109_ = _tmp108_;
573 			vala_report_error (_tmp109_, "External constants cannot use values");
574 		}
575 	}
576 	_tmp112_ = vala_symbol_get_external_package ((ValaSymbol*) self);
577 	_tmp113_ = _tmp112_;
578 	if (!_tmp113_) {
579 		gboolean _tmp114_;
580 		gboolean _tmp115_;
581 		_tmp114_ = vala_symbol_get_hides ((ValaSymbol*) self);
582 		_tmp115_ = _tmp114_;
583 		_tmp111_ = !_tmp115_;
584 	} else {
585 		_tmp111_ = FALSE;
586 	}
587 	if (_tmp111_) {
588 		ValaSymbol* _tmp116_;
589 		ValaSymbol* _tmp117_;
590 		_tmp116_ = vala_symbol_get_hidden_member ((ValaSymbol*) self);
591 		_tmp117_ = _tmp116_;
592 		_tmp110_ = _tmp117_ != NULL;
593 		_vala_code_node_unref0 (_tmp117_);
594 	} else {
595 		_tmp110_ = FALSE;
596 	}
597 	if (_tmp110_) {
598 		ValaSourceReference* _tmp118_;
599 		ValaSourceReference* _tmp119_;
600 		gchar* _tmp120_;
601 		gchar* _tmp121_;
602 		ValaSymbol* _tmp122_;
603 		ValaSymbol* _tmp123_;
604 		gchar* _tmp124_;
605 		gchar* _tmp125_;
606 		gchar* _tmp126_;
607 		gchar* _tmp127_;
608 		_tmp118_ = vala_code_node_get_source_reference ((ValaCodeNode*) self);
609 		_tmp119_ = _tmp118_;
610 		_tmp120_ = vala_symbol_get_full_name ((ValaSymbol*) self);
611 		_tmp121_ = _tmp120_;
612 		_tmp122_ = vala_symbol_get_hidden_member ((ValaSymbol*) self);
613 		_tmp123_ = _tmp122_;
614 		_tmp124_ = vala_symbol_get_full_name (_tmp123_);
615 		_tmp125_ = _tmp124_;
616 		_tmp126_ = g_strdup_printf ("%s hides inherited constant `%s'. Use the `new' keyword if hiding was " \
617 "intentional", _tmp121_, _tmp125_);
618 		_tmp127_ = _tmp126_;
619 		vala_report_warning (_tmp119_, _tmp127_);
620 		_g_free0 (_tmp127_);
621 		_g_free0 (_tmp125_);
622 		_vala_code_node_unref0 (_tmp123_);
623 		_g_free0 (_tmp121_);
624 	}
625 	_tmp128_ = vala_code_context_get_analyzer (context);
626 	_tmp129_ = _tmp128_;
627 	_tmp130_ = old_source_file;
628 	vala_semantic_analyzer_set_current_source_file (_tmp129_, _tmp130_);
629 	_tmp131_ = vala_code_context_get_analyzer (context);
630 	_tmp132_ = _tmp131_;
631 	_tmp133_ = old_symbol;
632 	vala_semantic_analyzer_set_current_symbol (_tmp132_, _tmp133_);
633 	vala_symbol_set_active ((ValaSymbol*) self, TRUE);
634 	_tmp134_ = vala_code_node_get_error ((ValaCodeNode*) self);
635 	_tmp135_ = _tmp134_;
636 	result = !_tmp135_;
637 	_vala_code_node_unref0 (old_symbol);
638 	_vala_source_file_unref0 (old_source_file);
639 	return result;
640 }
641 
642 static gboolean
vala_constant_check_const_type(ValaConstant * self,ValaDataType * type,ValaCodeContext * context)643 vala_constant_check_const_type (ValaConstant* self,
644                                 ValaDataType* type,
645                                 ValaCodeContext* context)
646 {
647 	gboolean result = FALSE;
648 	g_return_val_if_fail (self != NULL, FALSE);
649 	g_return_val_if_fail (type != NULL, FALSE);
650 	g_return_val_if_fail (context != NULL, FALSE);
651 	if (VALA_IS_VALUE_TYPE (type)) {
652 		result = TRUE;
653 		return result;
654 	} else {
655 		gboolean _tmp0_ = FALSE;
656 		if (VALA_IS_VOID_TYPE (type)) {
657 			_tmp0_ = TRUE;
658 		} else {
659 			_tmp0_ = VALA_IS_POINTER_TYPE (type);
660 		}
661 		if (_tmp0_) {
662 			result = FALSE;
663 			return result;
664 		} else {
665 			if (VALA_IS_ARRAY_TYPE (type)) {
666 				ValaArrayType* array_type = NULL;
667 				ValaArrayType* _tmp1_;
668 				ValaDataType* _tmp2_;
669 				ValaDataType* _tmp3_;
670 				array_type = G_TYPE_CHECK_INSTANCE_CAST (type, VALA_TYPE_ARRAY_TYPE, ValaArrayType);
671 				_tmp1_ = array_type;
672 				_tmp2_ = vala_array_type_get_element_type (_tmp1_);
673 				_tmp3_ = _tmp2_;
674 				result = vala_constant_check_const_type (self, _tmp3_, context);
675 				return result;
676 			} else {
677 				ValaTypeSymbol* _tmp4_;
678 				ValaTypeSymbol* _tmp5_;
679 				_tmp4_ = vala_data_type_get_type_symbol (type);
680 				_tmp5_ = _tmp4_;
681 				if (_tmp5_ != NULL) {
682 					ValaTypeSymbol* _tmp6_;
683 					ValaTypeSymbol* _tmp7_;
684 					ValaSemanticAnalyzer* _tmp8_;
685 					ValaSemanticAnalyzer* _tmp9_;
686 					ValaDataType* _tmp10_;
687 					ValaTypeSymbol* _tmp11_;
688 					ValaTypeSymbol* _tmp12_;
689 					_tmp6_ = vala_data_type_get_type_symbol (type);
690 					_tmp7_ = _tmp6_;
691 					_tmp8_ = vala_code_context_get_analyzer (context);
692 					_tmp9_ = _tmp8_;
693 					_tmp10_ = _tmp9_->string_type;
694 					_tmp11_ = vala_data_type_get_type_symbol (_tmp10_);
695 					_tmp12_ = _tmp11_;
696 					result = vala_typesymbol_is_subtype_of (_tmp7_, _tmp12_);
697 					return result;
698 				} else {
699 					result = FALSE;
700 					return result;
701 				}
702 			}
703 		}
704 	}
705 }
706 
707 static void
vala_constant_class_init(ValaConstantClass * klass,gpointer klass_data)708 vala_constant_class_init (ValaConstantClass * klass,
709                           gpointer klass_data)
710 {
711 	vala_constant_parent_class = g_type_class_peek_parent (klass);
712 	((ValaCodeNodeClass *) klass)->finalize = vala_constant_finalize;
713 	g_type_class_adjust_private_offset (klass, &ValaConstant_private_offset);
714 	((ValaCodeNodeClass *) klass)->accept = (void (*) (ValaCodeNode*, ValaCodeVisitor*)) vala_constant_real_accept;
715 	((ValaCodeNodeClass *) klass)->accept_children = (void (*) (ValaCodeNode*, ValaCodeVisitor*)) vala_constant_real_accept_children;
716 	((ValaCodeNodeClass *) klass)->replace_expression = (void (*) (ValaCodeNode*, ValaExpression*, ValaExpression*)) vala_constant_real_replace_expression;
717 	((ValaCodeNodeClass *) klass)->replace_type = (void (*) (ValaCodeNode*, ValaDataType*, ValaDataType*)) vala_constant_real_replace_type;
718 	((ValaCodeNodeClass *) klass)->check = (gboolean (*) (ValaCodeNode*, ValaCodeContext*)) vala_constant_real_check;
719 }
720 
721 static void
vala_constant_instance_init(ValaConstant * self,gpointer klass)722 vala_constant_instance_init (ValaConstant * self,
723                              gpointer klass)
724 {
725 	self->priv = vala_constant_get_instance_private (self);
726 }
727 
728 static void
vala_constant_finalize(ValaCodeNode * obj)729 vala_constant_finalize (ValaCodeNode * obj)
730 {
731 	ValaConstant * self;
732 	self = G_TYPE_CHECK_INSTANCE_CAST (obj, VALA_TYPE_CONSTANT, ValaConstant);
733 	_vala_code_node_unref0 (self->priv->_data_type);
734 	_vala_code_node_unref0 (self->priv->_value);
735 	VALA_CODE_NODE_CLASS (vala_constant_parent_class)->finalize (obj);
736 }
737 
738 /**
739  * Represents a type member with a constant value.
740  */
741 static GType
vala_constant_get_type_once(void)742 vala_constant_get_type_once (void)
743 {
744 	static const GTypeInfo g_define_type_info = { sizeof (ValaConstantClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) vala_constant_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ValaConstant), 0, (GInstanceInitFunc) vala_constant_instance_init, NULL };
745 	GType vala_constant_type_id;
746 	vala_constant_type_id = g_type_register_static (VALA_TYPE_SYMBOL, "ValaConstant", &g_define_type_info, 0);
747 	ValaConstant_private_offset = g_type_add_instance_private (vala_constant_type_id, sizeof (ValaConstantPrivate));
748 	return vala_constant_type_id;
749 }
750 
751 GType
vala_constant_get_type(void)752 vala_constant_get_type (void)
753 {
754 	static volatile gsize vala_constant_type_id__volatile = 0;
755 	if (g_once_init_enter (&vala_constant_type_id__volatile)) {
756 		GType vala_constant_type_id;
757 		vala_constant_type_id = vala_constant_get_type_once ();
758 		g_once_init_leave (&vala_constant_type_id__volatile, vala_constant_type_id);
759 	}
760 	return vala_constant_type_id__volatile;
761 }
762 
763