1 /* valareturnstatement.c generated by valac, the Vala compiler
2 * generated from valareturnstatement.vala, do not modify */
3
4 /* valareturnstatement.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 _g_free0(var) (var = (g_free (var), NULL))
35
36 struct _ValaReturnStatementPrivate {
37 ValaExpression* _return_expression;
38 };
39
40 static gint ValaReturnStatement_private_offset;
41 static gpointer vala_return_statement_parent_class = NULL;
42 static ValaStatementIface * vala_return_statement_vala_statement_parent_iface = NULL;
43
44 static void vala_return_statement_real_accept (ValaCodeNode* base,
45 ValaCodeVisitor* visitor);
46 static void vala_return_statement_real_accept_children (ValaCodeNode* base,
47 ValaCodeVisitor* visitor);
48 static void vala_return_statement_real_replace_expression (ValaCodeNode* base,
49 ValaExpression* old_node,
50 ValaExpression* new_node);
51 static void vala_return_statement_real_get_error_types (ValaCodeNode* base,
52 ValaCollection* collection,
53 ValaSourceReference* source_reference);
54 static gboolean vala_return_statement_real_check (ValaCodeNode* base,
55 ValaCodeContext* context);
56 static void vala_return_statement_real_emit (ValaCodeNode* base,
57 ValaCodeGenerator* codegen);
58 static void vala_return_statement_real_get_defined_variables (ValaCodeNode* base,
59 ValaCollection* collection);
60 static void vala_return_statement_real_get_used_variables (ValaCodeNode* base,
61 ValaCollection* collection);
62 static void vala_return_statement_finalize (ValaCodeNode * obj);
63 static GType vala_return_statement_get_type_once (void);
64
65 static inline gpointer
vala_return_statement_get_instance_private(ValaReturnStatement * self)66 vala_return_statement_get_instance_private (ValaReturnStatement* self)
67 {
68 return G_STRUCT_MEMBER_P (self, ValaReturnStatement_private_offset);
69 }
70
71 ValaExpression*
vala_return_statement_get_return_expression(ValaReturnStatement * self)72 vala_return_statement_get_return_expression (ValaReturnStatement* self)
73 {
74 ValaExpression* result;
75 ValaExpression* _tmp0_;
76 g_return_val_if_fail (self != NULL, NULL);
77 _tmp0_ = self->priv->_return_expression;
78 result = _tmp0_;
79 return result;
80 }
81
82 static gpointer
_vala_code_node_ref0(gpointer self)83 _vala_code_node_ref0 (gpointer self)
84 {
85 return self ? vala_code_node_ref (self) : NULL;
86 }
87
88 void
vala_return_statement_set_return_expression(ValaReturnStatement * self,ValaExpression * value)89 vala_return_statement_set_return_expression (ValaReturnStatement* self,
90 ValaExpression* value)
91 {
92 ValaExpression* _tmp0_;
93 ValaExpression* _tmp1_;
94 g_return_if_fail (self != NULL);
95 _tmp0_ = _vala_code_node_ref0 (value);
96 _vala_code_node_unref0 (self->priv->_return_expression);
97 self->priv->_return_expression = _tmp0_;
98 _tmp1_ = self->priv->_return_expression;
99 if (_tmp1_ != NULL) {
100 ValaExpression* _tmp2_;
101 _tmp2_ = self->priv->_return_expression;
102 vala_code_node_set_parent_node ((ValaCodeNode*) _tmp2_, (ValaCodeNode*) self);
103 }
104 }
105
106 /**
107 * Creates a new return statement.
108 *
109 * @param return_expression the return expression
110 * @param source_reference reference to source code
111 * @return newly created return statement
112 */
113 ValaReturnStatement*
vala_return_statement_construct(GType object_type,ValaExpression * return_expression,ValaSourceReference * source_reference)114 vala_return_statement_construct (GType object_type,
115 ValaExpression* return_expression,
116 ValaSourceReference* source_reference)
117 {
118 ValaReturnStatement* self = NULL;
119 self = (ValaReturnStatement*) vala_code_node_construct (object_type);
120 vala_code_node_set_source_reference ((ValaCodeNode*) self, source_reference);
121 vala_return_statement_set_return_expression (self, return_expression);
122 return self;
123 }
124
125 ValaReturnStatement*
vala_return_statement_new(ValaExpression * return_expression,ValaSourceReference * source_reference)126 vala_return_statement_new (ValaExpression* return_expression,
127 ValaSourceReference* source_reference)
128 {
129 return vala_return_statement_construct (VALA_TYPE_RETURN_STATEMENT, return_expression, source_reference);
130 }
131
132 static void
vala_return_statement_real_accept(ValaCodeNode * base,ValaCodeVisitor * visitor)133 vala_return_statement_real_accept (ValaCodeNode* base,
134 ValaCodeVisitor* visitor)
135 {
136 ValaReturnStatement * self;
137 self = (ValaReturnStatement*) base;
138 g_return_if_fail (visitor != NULL);
139 vala_code_visitor_visit_return_statement (visitor, self);
140 }
141
142 static void
vala_return_statement_real_accept_children(ValaCodeNode * base,ValaCodeVisitor * visitor)143 vala_return_statement_real_accept_children (ValaCodeNode* base,
144 ValaCodeVisitor* visitor)
145 {
146 ValaReturnStatement * self;
147 ValaExpression* _tmp0_;
148 ValaExpression* _tmp1_;
149 self = (ValaReturnStatement*) base;
150 g_return_if_fail (visitor != NULL);
151 _tmp0_ = vala_return_statement_get_return_expression (self);
152 _tmp1_ = _tmp0_;
153 if (_tmp1_ != NULL) {
154 ValaExpression* _tmp2_;
155 ValaExpression* _tmp3_;
156 ValaExpression* _tmp4_;
157 ValaExpression* _tmp5_;
158 _tmp2_ = vala_return_statement_get_return_expression (self);
159 _tmp3_ = _tmp2_;
160 vala_code_node_accept ((ValaCodeNode*) _tmp3_, visitor);
161 _tmp4_ = vala_return_statement_get_return_expression (self);
162 _tmp5_ = _tmp4_;
163 vala_code_visitor_visit_end_full_expression (visitor, _tmp5_);
164 }
165 }
166
167 static void
vala_return_statement_real_replace_expression(ValaCodeNode * base,ValaExpression * old_node,ValaExpression * new_node)168 vala_return_statement_real_replace_expression (ValaCodeNode* base,
169 ValaExpression* old_node,
170 ValaExpression* new_node)
171 {
172 ValaReturnStatement * self;
173 ValaExpression* _tmp0_;
174 ValaExpression* _tmp1_;
175 self = (ValaReturnStatement*) base;
176 g_return_if_fail (old_node != NULL);
177 g_return_if_fail (new_node != NULL);
178 _tmp0_ = vala_return_statement_get_return_expression (self);
179 _tmp1_ = _tmp0_;
180 if (_tmp1_ == old_node) {
181 vala_return_statement_set_return_expression (self, new_node);
182 }
183 }
184
185 static void
vala_return_statement_real_get_error_types(ValaCodeNode * base,ValaCollection * collection,ValaSourceReference * source_reference)186 vala_return_statement_real_get_error_types (ValaCodeNode* base,
187 ValaCollection* collection,
188 ValaSourceReference* source_reference)
189 {
190 ValaReturnStatement * self;
191 ValaExpression* _tmp0_;
192 ValaExpression* _tmp1_;
193 self = (ValaReturnStatement*) base;
194 g_return_if_fail (collection != NULL);
195 _tmp0_ = vala_return_statement_get_return_expression (self);
196 _tmp1_ = _tmp0_;
197 if (_tmp1_ != NULL) {
198 ValaExpression* _tmp2_;
199 ValaExpression* _tmp3_;
200 _tmp2_ = vala_return_statement_get_return_expression (self);
201 _tmp3_ = _tmp2_;
202 vala_code_node_get_error_types ((ValaCodeNode*) _tmp3_, collection, source_reference);
203 }
204 }
205
206 static gboolean
vala_return_statement_real_check(ValaCodeNode * base,ValaCodeContext * context)207 vala_return_statement_real_check (ValaCodeNode* base,
208 ValaCodeContext* context)
209 {
210 ValaReturnStatement * self;
211 gboolean _tmp0_;
212 gboolean _tmp1_;
213 ValaSemanticAnalyzer* _tmp4_;
214 ValaSemanticAnalyzer* _tmp5_;
215 ValaDataType* _tmp6_;
216 ValaDataType* _tmp7_;
217 ValaExpression* _tmp10_;
218 ValaExpression* _tmp11_;
219 ValaSemanticAnalyzer* _tmp20_;
220 ValaSemanticAnalyzer* _tmp21_;
221 ValaDataType* _tmp22_;
222 ValaDataType* _tmp23_;
223 ValaExpression* _tmp26_;
224 ValaExpression* _tmp27_;
225 ValaSemanticAnalyzer* _tmp28_;
226 ValaSemanticAnalyzer* _tmp29_;
227 ValaDataType* _tmp30_;
228 ValaDataType* _tmp31_;
229 ValaDataType* _tmp32_;
230 ValaDataType* _tmp33_;
231 ValaExpression* _tmp34_;
232 ValaExpression* _tmp35_;
233 ValaExpression* _tmp36_;
234 ValaExpression* _tmp37_;
235 ValaDataType* _tmp38_;
236 ValaDataType* _tmp39_;
237 ValaExpression* _tmp42_;
238 ValaExpression* _tmp43_;
239 ValaDataType* _tmp44_;
240 ValaDataType* _tmp45_;
241 ValaSemanticAnalyzer* _tmp46_;
242 ValaSemanticAnalyzer* _tmp47_;
243 ValaDataType* _tmp48_;
244 ValaDataType* _tmp49_;
245 gboolean _tmp66_ = FALSE;
246 ValaExpression* _tmp67_;
247 ValaExpression* _tmp68_;
248 ValaDataType* _tmp69_;
249 ValaDataType* _tmp70_;
250 ValaLocalVariable* local = NULL;
251 ValaExpression* _tmp79_;
252 ValaExpression* _tmp80_;
253 ValaSymbol* _tmp81_;
254 ValaSymbol* _tmp82_;
255 gboolean _tmp83_ = FALSE;
256 gboolean _tmp84_ = FALSE;
257 ValaLocalVariable* _tmp85_;
258 gboolean _tmp97_ = FALSE;
259 ValaExpression* _tmp98_;
260 ValaExpression* _tmp99_;
261 gboolean _tmp116_;
262 gboolean _tmp117_;
263 gboolean result = FALSE;
264 self = (ValaReturnStatement*) base;
265 g_return_val_if_fail (context != NULL, FALSE);
266 _tmp0_ = vala_code_node_get_checked ((ValaCodeNode*) self);
267 _tmp1_ = _tmp0_;
268 if (_tmp1_) {
269 gboolean _tmp2_;
270 gboolean _tmp3_;
271 _tmp2_ = vala_code_node_get_error ((ValaCodeNode*) self);
272 _tmp3_ = _tmp2_;
273 result = !_tmp3_;
274 return result;
275 }
276 vala_code_node_set_checked ((ValaCodeNode*) self, TRUE);
277 _tmp4_ = vala_code_context_get_analyzer (context);
278 _tmp5_ = _tmp4_;
279 _tmp6_ = vala_semantic_analyzer_get_current_return_type (_tmp5_);
280 _tmp7_ = _tmp6_;
281 if (_tmp7_ == NULL) {
282 ValaSourceReference* _tmp8_;
283 ValaSourceReference* _tmp9_;
284 vala_code_node_set_error ((ValaCodeNode*) self, TRUE);
285 _tmp8_ = vala_code_node_get_source_reference ((ValaCodeNode*) self);
286 _tmp9_ = _tmp8_;
287 vala_report_error (_tmp9_, "Return not allowed in this context");
288 result = FALSE;
289 return result;
290 }
291 _tmp10_ = vala_return_statement_get_return_expression (self);
292 _tmp11_ = _tmp10_;
293 if (_tmp11_ == NULL) {
294 ValaSemanticAnalyzer* _tmp12_;
295 ValaSemanticAnalyzer* _tmp13_;
296 ValaDataType* _tmp14_;
297 ValaDataType* _tmp15_;
298 gboolean _tmp18_;
299 gboolean _tmp19_;
300 _tmp12_ = vala_code_context_get_analyzer (context);
301 _tmp13_ = _tmp12_;
302 _tmp14_ = vala_semantic_analyzer_get_current_return_type (_tmp13_);
303 _tmp15_ = _tmp14_;
304 if (!VALA_IS_VOID_TYPE (_tmp15_)) {
305 ValaSourceReference* _tmp16_;
306 ValaSourceReference* _tmp17_;
307 vala_code_node_set_error ((ValaCodeNode*) self, TRUE);
308 _tmp16_ = vala_code_node_get_source_reference ((ValaCodeNode*) self);
309 _tmp17_ = _tmp16_;
310 vala_report_error (_tmp17_, "Return without value in non-void function");
311 }
312 _tmp18_ = vala_code_node_get_error ((ValaCodeNode*) self);
313 _tmp19_ = _tmp18_;
314 result = !_tmp19_;
315 return result;
316 }
317 _tmp20_ = vala_code_context_get_analyzer (context);
318 _tmp21_ = _tmp20_;
319 _tmp22_ = vala_semantic_analyzer_get_current_return_type (_tmp21_);
320 _tmp23_ = _tmp22_;
321 if (VALA_IS_VOID_TYPE (_tmp23_)) {
322 ValaSourceReference* _tmp24_;
323 ValaSourceReference* _tmp25_;
324 vala_code_node_set_error ((ValaCodeNode*) self, TRUE);
325 _tmp24_ = vala_code_node_get_source_reference ((ValaCodeNode*) self);
326 _tmp25_ = _tmp24_;
327 vala_report_error (_tmp25_, "Return with value in void function");
328 result = FALSE;
329 return result;
330 }
331 _tmp26_ = vala_return_statement_get_return_expression (self);
332 _tmp27_ = _tmp26_;
333 _tmp28_ = vala_code_context_get_analyzer (context);
334 _tmp29_ = _tmp28_;
335 _tmp30_ = vala_semantic_analyzer_get_current_return_type (_tmp29_);
336 _tmp31_ = _tmp30_;
337 _tmp32_ = vala_data_type_copy (_tmp31_);
338 _tmp33_ = _tmp32_;
339 vala_expression_set_target_type (_tmp27_, _tmp33_);
340 _vala_code_node_unref0 (_tmp33_);
341 _tmp34_ = vala_return_statement_get_return_expression (self);
342 _tmp35_ = _tmp34_;
343 if (!vala_code_node_check ((ValaCodeNode*) _tmp35_, context)) {
344 vala_code_node_set_error ((ValaCodeNode*) self, TRUE);
345 result = FALSE;
346 return result;
347 }
348 _tmp36_ = vala_return_statement_get_return_expression (self);
349 _tmp37_ = _tmp36_;
350 _tmp38_ = vala_expression_get_value_type (_tmp37_);
351 _tmp39_ = _tmp38_;
352 if (_tmp39_ == NULL) {
353 ValaSourceReference* _tmp40_;
354 ValaSourceReference* _tmp41_;
355 vala_code_node_set_error ((ValaCodeNode*) self, TRUE);
356 _tmp40_ = vala_code_node_get_source_reference ((ValaCodeNode*) self);
357 _tmp41_ = _tmp40_;
358 vala_report_error (_tmp41_, "Invalid expression in return value");
359 result = FALSE;
360 return result;
361 }
362 _tmp42_ = vala_return_statement_get_return_expression (self);
363 _tmp43_ = _tmp42_;
364 _tmp44_ = vala_expression_get_value_type (_tmp43_);
365 _tmp45_ = _tmp44_;
366 _tmp46_ = vala_code_context_get_analyzer (context);
367 _tmp47_ = _tmp46_;
368 _tmp48_ = vala_semantic_analyzer_get_current_return_type (_tmp47_);
369 _tmp49_ = _tmp48_;
370 if (!vala_data_type_compatible (_tmp45_, _tmp49_)) {
371 ValaSourceReference* _tmp50_;
372 ValaSourceReference* _tmp51_;
373 ValaExpression* _tmp52_;
374 ValaExpression* _tmp53_;
375 ValaDataType* _tmp54_;
376 ValaDataType* _tmp55_;
377 gchar* _tmp56_;
378 gchar* _tmp57_;
379 ValaSemanticAnalyzer* _tmp58_;
380 ValaSemanticAnalyzer* _tmp59_;
381 ValaDataType* _tmp60_;
382 ValaDataType* _tmp61_;
383 gchar* _tmp62_;
384 gchar* _tmp63_;
385 gchar* _tmp64_;
386 gchar* _tmp65_;
387 vala_code_node_set_error ((ValaCodeNode*) self, TRUE);
388 _tmp50_ = vala_code_node_get_source_reference ((ValaCodeNode*) self);
389 _tmp51_ = _tmp50_;
390 _tmp52_ = vala_return_statement_get_return_expression (self);
391 _tmp53_ = _tmp52_;
392 _tmp54_ = vala_expression_get_value_type (_tmp53_);
393 _tmp55_ = _tmp54_;
394 _tmp56_ = vala_code_node_to_string ((ValaCodeNode*) _tmp55_);
395 _tmp57_ = _tmp56_;
396 _tmp58_ = vala_code_context_get_analyzer (context);
397 _tmp59_ = _tmp58_;
398 _tmp60_ = vala_semantic_analyzer_get_current_return_type (_tmp59_);
399 _tmp61_ = _tmp60_;
400 _tmp62_ = vala_code_node_to_string ((ValaCodeNode*) _tmp61_);
401 _tmp63_ = _tmp62_;
402 _tmp64_ = g_strdup_printf ("Return: Cannot convert from `%s' to `%s'", _tmp57_, _tmp63_);
403 _tmp65_ = _tmp64_;
404 vala_report_error (_tmp51_, _tmp65_);
405 _g_free0 (_tmp65_);
406 _g_free0 (_tmp63_);
407 _g_free0 (_tmp57_);
408 result = FALSE;
409 return result;
410 }
411 _tmp67_ = vala_return_statement_get_return_expression (self);
412 _tmp68_ = _tmp67_;
413 _tmp69_ = vala_expression_get_value_type (_tmp68_);
414 _tmp70_ = _tmp69_;
415 if (vala_data_type_is_disposable (_tmp70_)) {
416 ValaSemanticAnalyzer* _tmp71_;
417 ValaSemanticAnalyzer* _tmp72_;
418 ValaDataType* _tmp73_;
419 ValaDataType* _tmp74_;
420 gboolean _tmp75_;
421 gboolean _tmp76_;
422 _tmp71_ = vala_code_context_get_analyzer (context);
423 _tmp72_ = _tmp71_;
424 _tmp73_ = vala_semantic_analyzer_get_current_return_type (_tmp72_);
425 _tmp74_ = _tmp73_;
426 _tmp75_ = vala_data_type_get_value_owned (_tmp74_);
427 _tmp76_ = _tmp75_;
428 _tmp66_ = !_tmp76_;
429 } else {
430 _tmp66_ = FALSE;
431 }
432 if (_tmp66_) {
433 ValaSourceReference* _tmp77_;
434 ValaSourceReference* _tmp78_;
435 vala_code_node_set_error ((ValaCodeNode*) self, TRUE);
436 _tmp77_ = vala_code_node_get_source_reference ((ValaCodeNode*) self);
437 _tmp78_ = _tmp77_;
438 vala_report_error (_tmp78_, "Return value transfers ownership but method return type hasn't been de" \
439 "clared to transfer ownership");
440 result = FALSE;
441 return result;
442 }
443 _tmp79_ = vala_return_statement_get_return_expression (self);
444 _tmp80_ = _tmp79_;
445 _tmp81_ = vala_expression_get_symbol_reference (_tmp80_);
446 _tmp82_ = _tmp81_;
447 local = VALA_IS_LOCAL_VARIABLE (_tmp82_) ? ((ValaLocalVariable*) _tmp82_) : NULL;
448 _tmp85_ = local;
449 if (_tmp85_ != NULL) {
450 ValaLocalVariable* _tmp86_;
451 ValaDataType* _tmp87_;
452 ValaDataType* _tmp88_;
453 _tmp86_ = local;
454 _tmp87_ = vala_variable_get_variable_type ((ValaVariable*) _tmp86_);
455 _tmp88_ = _tmp87_;
456 _tmp84_ = vala_data_type_is_disposable (_tmp88_);
457 } else {
458 _tmp84_ = FALSE;
459 }
460 if (_tmp84_) {
461 ValaSemanticAnalyzer* _tmp89_;
462 ValaSemanticAnalyzer* _tmp90_;
463 ValaDataType* _tmp91_;
464 ValaDataType* _tmp92_;
465 gboolean _tmp93_;
466 gboolean _tmp94_;
467 _tmp89_ = vala_code_context_get_analyzer (context);
468 _tmp90_ = _tmp89_;
469 _tmp91_ = vala_semantic_analyzer_get_current_return_type (_tmp90_);
470 _tmp92_ = _tmp91_;
471 _tmp93_ = vala_data_type_get_value_owned (_tmp92_);
472 _tmp94_ = _tmp93_;
473 _tmp83_ = !_tmp94_;
474 } else {
475 _tmp83_ = FALSE;
476 }
477 if (_tmp83_) {
478 ValaSourceReference* _tmp95_;
479 ValaSourceReference* _tmp96_;
480 vala_code_node_set_error ((ValaCodeNode*) self, TRUE);
481 _tmp95_ = vala_code_node_get_source_reference ((ValaCodeNode*) self);
482 _tmp96_ = _tmp95_;
483 vala_report_error (_tmp96_, "Local variable with strong reference used as return value and method r" \
484 "eturn type has not been declared to transfer ownership");
485 result = FALSE;
486 return result;
487 }
488 _tmp98_ = vala_return_statement_get_return_expression (self);
489 _tmp99_ = _tmp98_;
490 if (VALA_IS_NULL_LITERAL (_tmp99_)) {
491 ValaSemanticAnalyzer* _tmp100_;
492 ValaSemanticAnalyzer* _tmp101_;
493 ValaDataType* _tmp102_;
494 ValaDataType* _tmp103_;
495 gboolean _tmp104_;
496 gboolean _tmp105_;
497 _tmp100_ = vala_code_context_get_analyzer (context);
498 _tmp101_ = _tmp100_;
499 _tmp102_ = vala_semantic_analyzer_get_current_return_type (_tmp101_);
500 _tmp103_ = _tmp102_;
501 _tmp104_ = vala_data_type_get_nullable (_tmp103_);
502 _tmp105_ = _tmp104_;
503 _tmp97_ = !_tmp105_;
504 } else {
505 _tmp97_ = FALSE;
506 }
507 if (_tmp97_) {
508 ValaSourceReference* _tmp106_;
509 ValaSourceReference* _tmp107_;
510 ValaSemanticAnalyzer* _tmp108_;
511 ValaSemanticAnalyzer* _tmp109_;
512 ValaDataType* _tmp110_;
513 ValaDataType* _tmp111_;
514 gchar* _tmp112_;
515 gchar* _tmp113_;
516 gchar* _tmp114_;
517 gchar* _tmp115_;
518 _tmp106_ = vala_code_node_get_source_reference ((ValaCodeNode*) self);
519 _tmp107_ = _tmp106_;
520 _tmp108_ = vala_code_context_get_analyzer (context);
521 _tmp109_ = _tmp108_;
522 _tmp110_ = vala_semantic_analyzer_get_current_return_type (_tmp109_);
523 _tmp111_ = _tmp110_;
524 _tmp112_ = vala_code_node_to_string ((ValaCodeNode*) _tmp111_);
525 _tmp113_ = _tmp112_;
526 _tmp114_ = g_strdup_printf ("`null' incompatible with return type `%s'", _tmp113_);
527 _tmp115_ = _tmp114_;
528 vala_report_warning (_tmp107_, _tmp115_);
529 _g_free0 (_tmp115_);
530 _g_free0 (_tmp113_);
531 }
532 _tmp116_ = vala_code_node_get_error ((ValaCodeNode*) self);
533 _tmp117_ = _tmp116_;
534 result = !_tmp117_;
535 return result;
536 }
537
538 static void
vala_return_statement_real_emit(ValaCodeNode * base,ValaCodeGenerator * codegen)539 vala_return_statement_real_emit (ValaCodeNode* base,
540 ValaCodeGenerator* codegen)
541 {
542 ValaReturnStatement * self;
543 ValaExpression* _tmp0_;
544 ValaExpression* _tmp1_;
545 self = (ValaReturnStatement*) base;
546 g_return_if_fail (codegen != NULL);
547 _tmp0_ = vala_return_statement_get_return_expression (self);
548 _tmp1_ = _tmp0_;
549 if (_tmp1_ != NULL) {
550 ValaExpression* _tmp2_;
551 ValaExpression* _tmp3_;
552 ValaExpression* _tmp4_;
553 ValaExpression* _tmp5_;
554 _tmp2_ = vala_return_statement_get_return_expression (self);
555 _tmp3_ = _tmp2_;
556 vala_code_node_emit ((ValaCodeNode*) _tmp3_, codegen);
557 _tmp4_ = vala_return_statement_get_return_expression (self);
558 _tmp5_ = _tmp4_;
559 vala_code_visitor_visit_end_full_expression ((ValaCodeVisitor*) codegen, _tmp5_);
560 }
561 vala_code_visitor_visit_return_statement ((ValaCodeVisitor*) codegen, self);
562 }
563
564 static void
vala_return_statement_real_get_defined_variables(ValaCodeNode * base,ValaCollection * collection)565 vala_return_statement_real_get_defined_variables (ValaCodeNode* base,
566 ValaCollection* collection)
567 {
568 ValaReturnStatement * self;
569 ValaExpression* _tmp0_;
570 ValaExpression* _tmp1_;
571 self = (ValaReturnStatement*) base;
572 g_return_if_fail (collection != NULL);
573 _tmp0_ = vala_return_statement_get_return_expression (self);
574 _tmp1_ = _tmp0_;
575 if (_tmp1_ != NULL) {
576 ValaExpression* _tmp2_;
577 ValaExpression* _tmp3_;
578 _tmp2_ = vala_return_statement_get_return_expression (self);
579 _tmp3_ = _tmp2_;
580 vala_code_node_get_defined_variables ((ValaCodeNode*) _tmp3_, collection);
581 }
582 }
583
584 static void
vala_return_statement_real_get_used_variables(ValaCodeNode * base,ValaCollection * collection)585 vala_return_statement_real_get_used_variables (ValaCodeNode* base,
586 ValaCollection* collection)
587 {
588 ValaReturnStatement * self;
589 ValaExpression* _tmp0_;
590 ValaExpression* _tmp1_;
591 self = (ValaReturnStatement*) base;
592 g_return_if_fail (collection != NULL);
593 _tmp0_ = vala_return_statement_get_return_expression (self);
594 _tmp1_ = _tmp0_;
595 if (_tmp1_ != NULL) {
596 ValaExpression* _tmp2_;
597 ValaExpression* _tmp3_;
598 _tmp2_ = vala_return_statement_get_return_expression (self);
599 _tmp3_ = _tmp2_;
600 vala_code_node_get_used_variables ((ValaCodeNode*) _tmp3_, collection);
601 }
602 }
603
604 static void
vala_return_statement_class_init(ValaReturnStatementClass * klass,gpointer klass_data)605 vala_return_statement_class_init (ValaReturnStatementClass * klass,
606 gpointer klass_data)
607 {
608 vala_return_statement_parent_class = g_type_class_peek_parent (klass);
609 ((ValaCodeNodeClass *) klass)->finalize = vala_return_statement_finalize;
610 g_type_class_adjust_private_offset (klass, &ValaReturnStatement_private_offset);
611 ((ValaCodeNodeClass *) klass)->accept = (void (*) (ValaCodeNode*, ValaCodeVisitor*)) vala_return_statement_real_accept;
612 ((ValaCodeNodeClass *) klass)->accept_children = (void (*) (ValaCodeNode*, ValaCodeVisitor*)) vala_return_statement_real_accept_children;
613 ((ValaCodeNodeClass *) klass)->replace_expression = (void (*) (ValaCodeNode*, ValaExpression*, ValaExpression*)) vala_return_statement_real_replace_expression;
614 ((ValaCodeNodeClass *) klass)->get_error_types = (void (*) (ValaCodeNode*, ValaCollection*, ValaSourceReference*)) vala_return_statement_real_get_error_types;
615 ((ValaCodeNodeClass *) klass)->check = (gboolean (*) (ValaCodeNode*, ValaCodeContext*)) vala_return_statement_real_check;
616 ((ValaCodeNodeClass *) klass)->emit = (void (*) (ValaCodeNode*, ValaCodeGenerator*)) vala_return_statement_real_emit;
617 ((ValaCodeNodeClass *) klass)->get_defined_variables = (void (*) (ValaCodeNode*, ValaCollection*)) vala_return_statement_real_get_defined_variables;
618 ((ValaCodeNodeClass *) klass)->get_used_variables = (void (*) (ValaCodeNode*, ValaCollection*)) vala_return_statement_real_get_used_variables;
619 }
620
621 static void
vala_return_statement_vala_statement_interface_init(ValaStatementIface * iface,gpointer iface_data)622 vala_return_statement_vala_statement_interface_init (ValaStatementIface * iface,
623 gpointer iface_data)
624 {
625 vala_return_statement_vala_statement_parent_iface = g_type_interface_peek_parent (iface);
626 }
627
628 static void
vala_return_statement_instance_init(ValaReturnStatement * self,gpointer klass)629 vala_return_statement_instance_init (ValaReturnStatement * self,
630 gpointer klass)
631 {
632 self->priv = vala_return_statement_get_instance_private (self);
633 }
634
635 static void
vala_return_statement_finalize(ValaCodeNode * obj)636 vala_return_statement_finalize (ValaCodeNode * obj)
637 {
638 ValaReturnStatement * self;
639 self = G_TYPE_CHECK_INSTANCE_CAST (obj, VALA_TYPE_RETURN_STATEMENT, ValaReturnStatement);
640 _vala_code_node_unref0 (self->priv->_return_expression);
641 VALA_CODE_NODE_CLASS (vala_return_statement_parent_class)->finalize (obj);
642 }
643
644 /**
645 * Represents a return statement in the source code.
646 */
647 static GType
vala_return_statement_get_type_once(void)648 vala_return_statement_get_type_once (void)
649 {
650 static const GTypeInfo g_define_type_info = { sizeof (ValaReturnStatementClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) vala_return_statement_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ValaReturnStatement), 0, (GInstanceInitFunc) vala_return_statement_instance_init, NULL };
651 static const GInterfaceInfo vala_statement_info = { (GInterfaceInitFunc) vala_return_statement_vala_statement_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
652 GType vala_return_statement_type_id;
653 vala_return_statement_type_id = g_type_register_static (VALA_TYPE_CODE_NODE, "ValaReturnStatement", &g_define_type_info, 0);
654 g_type_add_interface_static (vala_return_statement_type_id, VALA_TYPE_STATEMENT, &vala_statement_info);
655 ValaReturnStatement_private_offset = g_type_add_instance_private (vala_return_statement_type_id, sizeof (ValaReturnStatementPrivate));
656 return vala_return_statement_type_id;
657 }
658
659 GType
vala_return_statement_get_type(void)660 vala_return_statement_get_type (void)
661 {
662 static volatile gsize vala_return_statement_type_id__volatile = 0;
663 if (g_once_init_enter (&vala_return_statement_type_id__volatile)) {
664 GType vala_return_statement_type_id;
665 vala_return_statement_type_id = vala_return_statement_get_type_once ();
666 g_once_init_leave (&vala_return_statement_type_id__volatile, vala_return_statement_type_id);
667 }
668 return vala_return_statement_type_id__volatile;
669 }
670
671