1 /* valacodecontext.c generated by valac, the Vala compiler
2  * generated from valacodecontext.vala, do not modify */
3 
4 /* valacodecontext.vala
5  *
6  * Copyright (C) 2006-2012  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 #include <glib-object.h>
32 #include <stdio.h>
33 #include <glib/gstdio.h>
34 #include <config.h>
35 #include <gobject/gvaluecollector.h>
36 
37 #define _g_free0(var) (var = (g_free (var), NULL))
38 #define _vala_code_node_unref0(var) ((var == NULL) ? NULL : (var = (vala_code_node_unref (var), NULL)))
39 #define _vala_report_unref0(var) ((var == NULL) ? NULL : (var = (vala_report_unref (var), NULL)))
40 #define _vala_iterable_unref0(var) ((var == NULL) ? NULL : (var = (vala_iterable_unref (var), NULL)))
41 #define _vala_map_unref0(var) ((var == NULL) ? NULL : (var = (vala_map_unref (var), NULL)))
42 #define _vala_code_visitor_unref0(var) ((var == NULL) ? NULL : (var = (vala_code_visitor_unref (var), NULL)))
43 #define _vala_code_context_unref0(var) ((var == NULL) ? NULL : (var = (vala_code_context_unref (var), NULL)))
44 #define _vala_source_file_unref0(var) ((var == NULL) ? NULL : (var = (vala_source_file_unref (var), NULL)))
45 #define _g_error_free0(var) ((var == NULL) ? NULL : (var = (g_error_free (var), NULL)))
46 #define _fclose0(var) ((var == NULL) ? NULL : (var = (fclose (var), NULL)))
47 typedef struct _ValaParamSpecCodeContext ValaParamSpecCodeContext;
48 
49 struct _ValaCodeContextPrivate {
50 	gboolean _assert;
51 	gboolean _checking;
52 	gboolean _deprecated;
53 	gboolean _hide_internal;
54 	gboolean _since_check;
55 	gboolean _experimental;
56 	gboolean _experimental_non_null;
57 	gboolean _gobject_tracing;
58 	gboolean _ccode_only;
59 	gchar* _pkg_config_command;
60 	gboolean _abi_stability;
61 	gchar* _header_filename;
62 	gchar* _internal_header_filename;
63 	gboolean _use_header;
64 	gchar* _includedir;
65 	gchar* _symbols_filename;
66 	gboolean _compile_only;
67 	gchar* _output;
68 	gchar* _basedir;
69 	gchar* _directory;
70 	gchar** _vapi_directories;
71 	gint _vapi_directories_length1;
72 	gint __vapi_directories_size_;
73 	gchar** _gir_directories;
74 	gint _gir_directories_length1;
75 	gint __gir_directories_size_;
76 	gchar** _metadata_directories;
77 	gint _metadata_directories_length1;
78 	gint __metadata_directories_size_;
79 	gboolean _debug;
80 	gint _optlevel;
81 	gboolean _mem_profiler;
82 	ValaMethod* _module_init_method;
83 	gboolean _save_temps;
84 	ValaProfile _profile;
85 	gboolean _verbose_mode;
86 	gboolean _version_header;
87 	gboolean _nostdpkg;
88 	gboolean _use_fast_vapi;
89 	gboolean _keep_going;
90 	gboolean _vapi_comments;
91 	ValaReport* _report;
92 	ValaMethod* _entry_point;
93 	gchar* _entry_point_name;
94 	gboolean _run_output;
95 	gchar** _gresources;
96 	gint _gresources_length1;
97 	gint __gresources_size_;
98 	gchar** _gresources_directories;
99 	gint _gresources_directories_length1;
100 	gint __gresources_directories_size_;
101 	ValaList* source_files;
102 	ValaMap* source_files_map;
103 	ValaList* c_source_files;
104 	ValaNamespace* _root;
105 	ValaList* packages;
106 	ValaSet* defines;
107 	gint target_glib_major;
108 	gint target_glib_minor;
109 	ValaSymbolResolver* _resolver;
110 	ValaSemanticAnalyzer* _analyzer;
111 	ValaFlowAnalyzer* _flow_analyzer;
112 	ValaCodeGenerator* _codegen;
113 	ValaUsedAttr* _used_attr;
114 };
115 
116 struct _ValaParamSpecCodeContext {
117 	GParamSpec parent_instance;
118 };
119 
120 static gint ValaCodeContext_private_offset;
121 static gpointer vala_code_context_parent_class = NULL;
122 static GStaticPrivate vala_code_context_context_stack_key;
123 static GStaticPrivate vala_code_context_context_stack_key = G_STATIC_PRIVATE_INIT;
124 
125 static gchar** _vala_array_dup1 (gchar** self,
126                           gint length);
127 static gchar** _vala_array_dup2 (gchar** self,
128                           gint length);
129 static gchar** _vala_array_dup3 (gchar** self,
130                           gint length);
131 static gchar** _vala_array_dup4 (gchar** self,
132                           gint length);
133 static gchar** _vala_array_dup5 (gchar** self,
134                           gint length);
135 static void vala_code_context_set_resolver (ValaCodeContext* self,
136                                      ValaSymbolResolver* value);
137 static void vala_code_context_set_analyzer (ValaCodeContext* self,
138                                      ValaSemanticAnalyzer* value);
139 static void vala_code_context_set_flow_analyzer (ValaCodeContext* self,
140                                           ValaFlowAnalyzer* value);
141 static void vala_code_context_add_default_defines (ValaCodeContext* self);
142 static gchar* vala_code_context_get_file_path (ValaCodeContext* self,
143                                         const gchar* basename,
144                                         const gchar* versioned_data_dir,
145                                         const gchar* data_dir,
146                                         gchar** directories,
147                                         gint directories_length1);
148 static gboolean vala_code_context_ends_with_dir_separator (const gchar* s);
149 static void vala_code_context_finalize (ValaCodeContext * obj);
150 static GType vala_code_context_get_type_once (void);
151 static void _vala_array_destroy (gpointer array,
152                           gint array_length,
153                           GDestroyNotify destroy_func);
154 static void _vala_array_free (gpointer array,
155                        gint array_length,
156                        GDestroyNotify destroy_func);
157 static gint _vala_array_length (gpointer array);
158 
159 static GRegex* _tmp_regex_0 = NULL;
160 static GRegex* _tmp_regex_1 = NULL;
161 
162 static inline gpointer
vala_code_context_get_instance_private(ValaCodeContext * self)163 vala_code_context_get_instance_private (ValaCodeContext* self)
164 {
165 	return G_STRUCT_MEMBER_P (self, ValaCodeContext_private_offset);
166 }
167 
168 gboolean
vala_code_context_get_assert(ValaCodeContext * self)169 vala_code_context_get_assert (ValaCodeContext* self)
170 {
171 	gboolean result;
172 	g_return_val_if_fail (self != NULL, FALSE);
173 	result = self->priv->_assert;
174 	return result;
175 }
176 
177 void
vala_code_context_set_assert(ValaCodeContext * self,gboolean value)178 vala_code_context_set_assert (ValaCodeContext* self,
179                               gboolean value)
180 {
181 	g_return_if_fail (self != NULL);
182 	self->priv->_assert = value;
183 }
184 
185 gboolean
vala_code_context_get_checking(ValaCodeContext * self)186 vala_code_context_get_checking (ValaCodeContext* self)
187 {
188 	gboolean result;
189 	g_return_val_if_fail (self != NULL, FALSE);
190 	result = self->priv->_checking;
191 	return result;
192 }
193 
194 void
vala_code_context_set_checking(ValaCodeContext * self,gboolean value)195 vala_code_context_set_checking (ValaCodeContext* self,
196                                 gboolean value)
197 {
198 	g_return_if_fail (self != NULL);
199 	self->priv->_checking = value;
200 }
201 
202 gboolean
vala_code_context_get_deprecated(ValaCodeContext * self)203 vala_code_context_get_deprecated (ValaCodeContext* self)
204 {
205 	gboolean result;
206 	g_return_val_if_fail (self != NULL, FALSE);
207 	result = self->priv->_deprecated;
208 	return result;
209 }
210 
211 void
vala_code_context_set_deprecated(ValaCodeContext * self,gboolean value)212 vala_code_context_set_deprecated (ValaCodeContext* self,
213                                   gboolean value)
214 {
215 	g_return_if_fail (self != NULL);
216 	self->priv->_deprecated = value;
217 }
218 
219 gboolean
vala_code_context_get_hide_internal(ValaCodeContext * self)220 vala_code_context_get_hide_internal (ValaCodeContext* self)
221 {
222 	gboolean result;
223 	g_return_val_if_fail (self != NULL, FALSE);
224 	result = self->priv->_hide_internal;
225 	return result;
226 }
227 
228 void
vala_code_context_set_hide_internal(ValaCodeContext * self,gboolean value)229 vala_code_context_set_hide_internal (ValaCodeContext* self,
230                                      gboolean value)
231 {
232 	g_return_if_fail (self != NULL);
233 	self->priv->_hide_internal = value;
234 }
235 
236 gboolean
vala_code_context_get_since_check(ValaCodeContext * self)237 vala_code_context_get_since_check (ValaCodeContext* self)
238 {
239 	gboolean result;
240 	g_return_val_if_fail (self != NULL, FALSE);
241 	result = self->priv->_since_check;
242 	return result;
243 }
244 
245 void
vala_code_context_set_since_check(ValaCodeContext * self,gboolean value)246 vala_code_context_set_since_check (ValaCodeContext* self,
247                                    gboolean value)
248 {
249 	g_return_if_fail (self != NULL);
250 	self->priv->_since_check = value;
251 }
252 
253 gboolean
vala_code_context_get_experimental(ValaCodeContext * self)254 vala_code_context_get_experimental (ValaCodeContext* self)
255 {
256 	gboolean result;
257 	g_return_val_if_fail (self != NULL, FALSE);
258 	result = self->priv->_experimental;
259 	return result;
260 }
261 
262 void
vala_code_context_set_experimental(ValaCodeContext * self,gboolean value)263 vala_code_context_set_experimental (ValaCodeContext* self,
264                                     gboolean value)
265 {
266 	g_return_if_fail (self != NULL);
267 	self->priv->_experimental = value;
268 }
269 
270 gboolean
vala_code_context_get_experimental_non_null(ValaCodeContext * self)271 vala_code_context_get_experimental_non_null (ValaCodeContext* self)
272 {
273 	gboolean result;
274 	g_return_val_if_fail (self != NULL, FALSE);
275 	result = self->priv->_experimental_non_null;
276 	return result;
277 }
278 
279 void
vala_code_context_set_experimental_non_null(ValaCodeContext * self,gboolean value)280 vala_code_context_set_experimental_non_null (ValaCodeContext* self,
281                                              gboolean value)
282 {
283 	g_return_if_fail (self != NULL);
284 	self->priv->_experimental_non_null = value;
285 }
286 
287 gboolean
vala_code_context_get_gobject_tracing(ValaCodeContext * self)288 vala_code_context_get_gobject_tracing (ValaCodeContext* self)
289 {
290 	gboolean result;
291 	g_return_val_if_fail (self != NULL, FALSE);
292 	result = self->priv->_gobject_tracing;
293 	return result;
294 }
295 
296 void
vala_code_context_set_gobject_tracing(ValaCodeContext * self,gboolean value)297 vala_code_context_set_gobject_tracing (ValaCodeContext* self,
298                                        gboolean value)
299 {
300 	g_return_if_fail (self != NULL);
301 	self->priv->_gobject_tracing = value;
302 }
303 
304 gboolean
vala_code_context_get_ccode_only(ValaCodeContext * self)305 vala_code_context_get_ccode_only (ValaCodeContext* self)
306 {
307 	gboolean result;
308 	g_return_val_if_fail (self != NULL, FALSE);
309 	result = self->priv->_ccode_only;
310 	return result;
311 }
312 
313 void
vala_code_context_set_ccode_only(ValaCodeContext * self,gboolean value)314 vala_code_context_set_ccode_only (ValaCodeContext* self,
315                                   gboolean value)
316 {
317 	g_return_if_fail (self != NULL);
318 	self->priv->_ccode_only = value;
319 }
320 
321 const gchar*
vala_code_context_get_pkg_config_command(ValaCodeContext * self)322 vala_code_context_get_pkg_config_command (ValaCodeContext* self)
323 {
324 	const gchar* result;
325 	const gchar* _tmp0_;
326 	g_return_val_if_fail (self != NULL, NULL);
327 	_tmp0_ = self->priv->_pkg_config_command;
328 	result = _tmp0_;
329 	return result;
330 }
331 
332 void
vala_code_context_set_pkg_config_command(ValaCodeContext * self,const gchar * value)333 vala_code_context_set_pkg_config_command (ValaCodeContext* self,
334                                           const gchar* value)
335 {
336 	gchar* _tmp0_;
337 	g_return_if_fail (self != NULL);
338 	_tmp0_ = g_strdup (value);
339 	_g_free0 (self->priv->_pkg_config_command);
340 	self->priv->_pkg_config_command = _tmp0_;
341 }
342 
343 gboolean
vala_code_context_get_abi_stability(ValaCodeContext * self)344 vala_code_context_get_abi_stability (ValaCodeContext* self)
345 {
346 	gboolean result;
347 	g_return_val_if_fail (self != NULL, FALSE);
348 	result = self->priv->_abi_stability;
349 	return result;
350 }
351 
352 void
vala_code_context_set_abi_stability(ValaCodeContext * self,gboolean value)353 vala_code_context_set_abi_stability (ValaCodeContext* self,
354                                      gboolean value)
355 {
356 	g_return_if_fail (self != NULL);
357 	self->priv->_abi_stability = value;
358 }
359 
360 const gchar*
vala_code_context_get_header_filename(ValaCodeContext * self)361 vala_code_context_get_header_filename (ValaCodeContext* self)
362 {
363 	const gchar* result;
364 	const gchar* _tmp0_;
365 	g_return_val_if_fail (self != NULL, NULL);
366 	_tmp0_ = self->priv->_header_filename;
367 	result = _tmp0_;
368 	return result;
369 }
370 
371 void
vala_code_context_set_header_filename(ValaCodeContext * self,const gchar * value)372 vala_code_context_set_header_filename (ValaCodeContext* self,
373                                        const gchar* value)
374 {
375 	gchar* _tmp0_;
376 	g_return_if_fail (self != NULL);
377 	_tmp0_ = g_strdup (value);
378 	_g_free0 (self->priv->_header_filename);
379 	self->priv->_header_filename = _tmp0_;
380 }
381 
382 const gchar*
vala_code_context_get_internal_header_filename(ValaCodeContext * self)383 vala_code_context_get_internal_header_filename (ValaCodeContext* self)
384 {
385 	const gchar* result;
386 	const gchar* _tmp0_;
387 	g_return_val_if_fail (self != NULL, NULL);
388 	_tmp0_ = self->priv->_internal_header_filename;
389 	result = _tmp0_;
390 	return result;
391 }
392 
393 void
vala_code_context_set_internal_header_filename(ValaCodeContext * self,const gchar * value)394 vala_code_context_set_internal_header_filename (ValaCodeContext* self,
395                                                 const gchar* value)
396 {
397 	gchar* _tmp0_;
398 	g_return_if_fail (self != NULL);
399 	_tmp0_ = g_strdup (value);
400 	_g_free0 (self->priv->_internal_header_filename);
401 	self->priv->_internal_header_filename = _tmp0_;
402 }
403 
404 gboolean
vala_code_context_get_use_header(ValaCodeContext * self)405 vala_code_context_get_use_header (ValaCodeContext* self)
406 {
407 	gboolean result;
408 	g_return_val_if_fail (self != NULL, FALSE);
409 	result = self->priv->_use_header;
410 	return result;
411 }
412 
413 void
vala_code_context_set_use_header(ValaCodeContext * self,gboolean value)414 vala_code_context_set_use_header (ValaCodeContext* self,
415                                   gboolean value)
416 {
417 	g_return_if_fail (self != NULL);
418 	self->priv->_use_header = value;
419 }
420 
421 const gchar*
vala_code_context_get_includedir(ValaCodeContext * self)422 vala_code_context_get_includedir (ValaCodeContext* self)
423 {
424 	const gchar* result;
425 	const gchar* _tmp0_;
426 	g_return_val_if_fail (self != NULL, NULL);
427 	_tmp0_ = self->priv->_includedir;
428 	result = _tmp0_;
429 	return result;
430 }
431 
432 void
vala_code_context_set_includedir(ValaCodeContext * self,const gchar * value)433 vala_code_context_set_includedir (ValaCodeContext* self,
434                                   const gchar* value)
435 {
436 	gchar* _tmp0_;
437 	g_return_if_fail (self != NULL);
438 	_tmp0_ = g_strdup (value);
439 	_g_free0 (self->priv->_includedir);
440 	self->priv->_includedir = _tmp0_;
441 }
442 
443 const gchar*
vala_code_context_get_symbols_filename(ValaCodeContext * self)444 vala_code_context_get_symbols_filename (ValaCodeContext* self)
445 {
446 	const gchar* result;
447 	const gchar* _tmp0_;
448 	g_return_val_if_fail (self != NULL, NULL);
449 	_tmp0_ = self->priv->_symbols_filename;
450 	result = _tmp0_;
451 	return result;
452 }
453 
454 void
vala_code_context_set_symbols_filename(ValaCodeContext * self,const gchar * value)455 vala_code_context_set_symbols_filename (ValaCodeContext* self,
456                                         const gchar* value)
457 {
458 	gchar* _tmp0_;
459 	g_return_if_fail (self != NULL);
460 	_tmp0_ = g_strdup (value);
461 	_g_free0 (self->priv->_symbols_filename);
462 	self->priv->_symbols_filename = _tmp0_;
463 }
464 
465 gboolean
vala_code_context_get_compile_only(ValaCodeContext * self)466 vala_code_context_get_compile_only (ValaCodeContext* self)
467 {
468 	gboolean result;
469 	g_return_val_if_fail (self != NULL, FALSE);
470 	result = self->priv->_compile_only;
471 	return result;
472 }
473 
474 void
vala_code_context_set_compile_only(ValaCodeContext * self,gboolean value)475 vala_code_context_set_compile_only (ValaCodeContext* self,
476                                     gboolean value)
477 {
478 	g_return_if_fail (self != NULL);
479 	self->priv->_compile_only = value;
480 }
481 
482 const gchar*
vala_code_context_get_output(ValaCodeContext * self)483 vala_code_context_get_output (ValaCodeContext* self)
484 {
485 	const gchar* result;
486 	const gchar* _tmp0_;
487 	g_return_val_if_fail (self != NULL, NULL);
488 	_tmp0_ = self->priv->_output;
489 	result = _tmp0_;
490 	return result;
491 }
492 
493 void
vala_code_context_set_output(ValaCodeContext * self,const gchar * value)494 vala_code_context_set_output (ValaCodeContext* self,
495                               const gchar* value)
496 {
497 	gchar* _tmp0_;
498 	g_return_if_fail (self != NULL);
499 	_tmp0_ = g_strdup (value);
500 	_g_free0 (self->priv->_output);
501 	self->priv->_output = _tmp0_;
502 }
503 
504 const gchar*
vala_code_context_get_basedir(ValaCodeContext * self)505 vala_code_context_get_basedir (ValaCodeContext* self)
506 {
507 	const gchar* result;
508 	const gchar* _tmp0_;
509 	g_return_val_if_fail (self != NULL, NULL);
510 	_tmp0_ = self->priv->_basedir;
511 	result = _tmp0_;
512 	return result;
513 }
514 
515 void
vala_code_context_set_basedir(ValaCodeContext * self,const gchar * value)516 vala_code_context_set_basedir (ValaCodeContext* self,
517                                const gchar* value)
518 {
519 	gchar* _tmp0_;
520 	g_return_if_fail (self != NULL);
521 	_tmp0_ = g_strdup (value);
522 	_g_free0 (self->priv->_basedir);
523 	self->priv->_basedir = _tmp0_;
524 }
525 
526 const gchar*
vala_code_context_get_directory(ValaCodeContext * self)527 vala_code_context_get_directory (ValaCodeContext* self)
528 {
529 	const gchar* result;
530 	const gchar* _tmp0_;
531 	g_return_val_if_fail (self != NULL, NULL);
532 	_tmp0_ = self->priv->_directory;
533 	result = _tmp0_;
534 	return result;
535 }
536 
537 void
vala_code_context_set_directory(ValaCodeContext * self,const gchar * value)538 vala_code_context_set_directory (ValaCodeContext* self,
539                                  const gchar* value)
540 {
541 	gchar* _tmp0_;
542 	g_return_if_fail (self != NULL);
543 	_tmp0_ = g_strdup (value);
544 	_g_free0 (self->priv->_directory);
545 	self->priv->_directory = _tmp0_;
546 }
547 
548 gchar**
vala_code_context_get_vapi_directories(ValaCodeContext * self,gint * result_length1)549 vala_code_context_get_vapi_directories (ValaCodeContext* self,
550                                         gint* result_length1)
551 {
552 	gchar** result;
553 	gchar** _tmp0_;
554 	gint _tmp0__length1;
555 	gchar** _tmp1_;
556 	gint _tmp1__length1;
557 	g_return_val_if_fail (self != NULL, NULL);
558 	_tmp0_ = self->priv->_vapi_directories;
559 	_tmp0__length1 = self->priv->_vapi_directories_length1;
560 	_tmp1_ = _tmp0_;
561 	_tmp1__length1 = _tmp0__length1;
562 	if (result_length1) {
563 		*result_length1 = _tmp1__length1;
564 	}
565 	result = _tmp1_;
566 	return result;
567 }
568 
569 static gchar**
_vala_array_dup1(gchar ** self,gint length)570 _vala_array_dup1 (gchar** self,
571                   gint length)
572 {
573 	if (length >= 0) {
574 		gchar** result;
575 		gint i;
576 		result = g_new0 (gchar*, length + 1);
577 		for (i = 0; i < length; i++) {
578 			gchar* _tmp0_;
579 			_tmp0_ = g_strdup (self[i]);
580 			result[i] = _tmp0_;
581 		}
582 		return result;
583 	}
584 	return NULL;
585 }
586 
587 void
vala_code_context_set_vapi_directories(ValaCodeContext * self,gchar ** value,gint value_length1)588 vala_code_context_set_vapi_directories (ValaCodeContext* self,
589                                         gchar** value,
590                                         gint value_length1)
591 {
592 	gchar** _tmp0_;
593 	gint _tmp0__length1;
594 	g_return_if_fail (self != NULL);
595 	_tmp0_ = (value != NULL) ? _vala_array_dup1 (value, value_length1) : value;
596 	_tmp0__length1 = value_length1;
597 	self->priv->_vapi_directories = (_vala_array_free (self->priv->_vapi_directories, self->priv->_vapi_directories_length1, (GDestroyNotify) g_free), NULL);
598 	self->priv->_vapi_directories = _tmp0_;
599 	self->priv->_vapi_directories_length1 = _tmp0__length1;
600 	self->priv->__vapi_directories_size_ = self->priv->_vapi_directories_length1;
601 }
602 
603 gchar**
vala_code_context_get_gir_directories(ValaCodeContext * self,gint * result_length1)604 vala_code_context_get_gir_directories (ValaCodeContext* self,
605                                        gint* result_length1)
606 {
607 	gchar** result;
608 	gchar** _tmp0_;
609 	gint _tmp0__length1;
610 	gchar** _tmp1_;
611 	gint _tmp1__length1;
612 	g_return_val_if_fail (self != NULL, NULL);
613 	_tmp0_ = self->priv->_gir_directories;
614 	_tmp0__length1 = self->priv->_gir_directories_length1;
615 	_tmp1_ = _tmp0_;
616 	_tmp1__length1 = _tmp0__length1;
617 	if (result_length1) {
618 		*result_length1 = _tmp1__length1;
619 	}
620 	result = _tmp1_;
621 	return result;
622 }
623 
624 static gchar**
_vala_array_dup2(gchar ** self,gint length)625 _vala_array_dup2 (gchar** self,
626                   gint length)
627 {
628 	if (length >= 0) {
629 		gchar** result;
630 		gint i;
631 		result = g_new0 (gchar*, length + 1);
632 		for (i = 0; i < length; i++) {
633 			gchar* _tmp0_;
634 			_tmp0_ = g_strdup (self[i]);
635 			result[i] = _tmp0_;
636 		}
637 		return result;
638 	}
639 	return NULL;
640 }
641 
642 void
vala_code_context_set_gir_directories(ValaCodeContext * self,gchar ** value,gint value_length1)643 vala_code_context_set_gir_directories (ValaCodeContext* self,
644                                        gchar** value,
645                                        gint value_length1)
646 {
647 	gchar** _tmp0_;
648 	gint _tmp0__length1;
649 	g_return_if_fail (self != NULL);
650 	_tmp0_ = (value != NULL) ? _vala_array_dup2 (value, value_length1) : value;
651 	_tmp0__length1 = value_length1;
652 	self->priv->_gir_directories = (_vala_array_free (self->priv->_gir_directories, self->priv->_gir_directories_length1, (GDestroyNotify) g_free), NULL);
653 	self->priv->_gir_directories = _tmp0_;
654 	self->priv->_gir_directories_length1 = _tmp0__length1;
655 	self->priv->__gir_directories_size_ = self->priv->_gir_directories_length1;
656 }
657 
658 gchar**
vala_code_context_get_metadata_directories(ValaCodeContext * self,gint * result_length1)659 vala_code_context_get_metadata_directories (ValaCodeContext* self,
660                                             gint* result_length1)
661 {
662 	gchar** result;
663 	gchar** _tmp0_;
664 	gint _tmp0__length1;
665 	gchar** _tmp1_;
666 	gint _tmp1__length1;
667 	g_return_val_if_fail (self != NULL, NULL);
668 	_tmp0_ = self->priv->_metadata_directories;
669 	_tmp0__length1 = self->priv->_metadata_directories_length1;
670 	_tmp1_ = _tmp0_;
671 	_tmp1__length1 = _tmp0__length1;
672 	if (result_length1) {
673 		*result_length1 = _tmp1__length1;
674 	}
675 	result = _tmp1_;
676 	return result;
677 }
678 
679 static gchar**
_vala_array_dup3(gchar ** self,gint length)680 _vala_array_dup3 (gchar** self,
681                   gint length)
682 {
683 	if (length >= 0) {
684 		gchar** result;
685 		gint i;
686 		result = g_new0 (gchar*, length + 1);
687 		for (i = 0; i < length; i++) {
688 			gchar* _tmp0_;
689 			_tmp0_ = g_strdup (self[i]);
690 			result[i] = _tmp0_;
691 		}
692 		return result;
693 	}
694 	return NULL;
695 }
696 
697 void
vala_code_context_set_metadata_directories(ValaCodeContext * self,gchar ** value,gint value_length1)698 vala_code_context_set_metadata_directories (ValaCodeContext* self,
699                                             gchar** value,
700                                             gint value_length1)
701 {
702 	gchar** _tmp0_;
703 	gint _tmp0__length1;
704 	g_return_if_fail (self != NULL);
705 	_tmp0_ = (value != NULL) ? _vala_array_dup3 (value, value_length1) : value;
706 	_tmp0__length1 = value_length1;
707 	self->priv->_metadata_directories = (_vala_array_free (self->priv->_metadata_directories, self->priv->_metadata_directories_length1, (GDestroyNotify) g_free), NULL);
708 	self->priv->_metadata_directories = _tmp0_;
709 	self->priv->_metadata_directories_length1 = _tmp0__length1;
710 	self->priv->__metadata_directories_size_ = self->priv->_metadata_directories_length1;
711 }
712 
713 gboolean
vala_code_context_get_debug(ValaCodeContext * self)714 vala_code_context_get_debug (ValaCodeContext* self)
715 {
716 	gboolean result;
717 	g_return_val_if_fail (self != NULL, FALSE);
718 	result = self->priv->_debug;
719 	return result;
720 }
721 
722 void
vala_code_context_set_debug(ValaCodeContext * self,gboolean value)723 vala_code_context_set_debug (ValaCodeContext* self,
724                              gboolean value)
725 {
726 	g_return_if_fail (self != NULL);
727 	self->priv->_debug = value;
728 }
729 
730 gint
vala_code_context_get_optlevel(ValaCodeContext * self)731 vala_code_context_get_optlevel (ValaCodeContext* self)
732 {
733 	gint result;
734 	g_return_val_if_fail (self != NULL, 0);
735 	result = self->priv->_optlevel;
736 	return result;
737 }
738 
739 void
vala_code_context_set_optlevel(ValaCodeContext * self,gint value)740 vala_code_context_set_optlevel (ValaCodeContext* self,
741                                 gint value)
742 {
743 	g_return_if_fail (self != NULL);
744 	self->priv->_optlevel = value;
745 }
746 
747 gboolean
vala_code_context_get_mem_profiler(ValaCodeContext * self)748 vala_code_context_get_mem_profiler (ValaCodeContext* self)
749 {
750 	gboolean result;
751 	g_return_val_if_fail (self != NULL, FALSE);
752 	result = self->priv->_mem_profiler;
753 	return result;
754 }
755 
756 void
vala_code_context_set_mem_profiler(ValaCodeContext * self,gboolean value)757 vala_code_context_set_mem_profiler (ValaCodeContext* self,
758                                     gboolean value)
759 {
760 	g_return_if_fail (self != NULL);
761 	self->priv->_mem_profiler = value;
762 }
763 
764 ValaMethod*
vala_code_context_get_module_init_method(ValaCodeContext * self)765 vala_code_context_get_module_init_method (ValaCodeContext* self)
766 {
767 	ValaMethod* result;
768 	ValaMethod* _tmp0_;
769 	g_return_val_if_fail (self != NULL, NULL);
770 	_tmp0_ = self->priv->_module_init_method;
771 	result = _tmp0_;
772 	return result;
773 }
774 
775 static gpointer
_vala_code_node_ref0(gpointer self)776 _vala_code_node_ref0 (gpointer self)
777 {
778 	return self ? vala_code_node_ref (self) : NULL;
779 }
780 
781 void
vala_code_context_set_module_init_method(ValaCodeContext * self,ValaMethod * value)782 vala_code_context_set_module_init_method (ValaCodeContext* self,
783                                           ValaMethod* value)
784 {
785 	ValaMethod* _tmp0_;
786 	g_return_if_fail (self != NULL);
787 	_tmp0_ = _vala_code_node_ref0 (value);
788 	_vala_code_node_unref0 (self->priv->_module_init_method);
789 	self->priv->_module_init_method = _tmp0_;
790 }
791 
792 gboolean
vala_code_context_get_save_temps(ValaCodeContext * self)793 vala_code_context_get_save_temps (ValaCodeContext* self)
794 {
795 	gboolean result;
796 	g_return_val_if_fail (self != NULL, FALSE);
797 	result = self->priv->_save_temps;
798 	return result;
799 }
800 
801 void
vala_code_context_set_save_temps(ValaCodeContext * self,gboolean value)802 vala_code_context_set_save_temps (ValaCodeContext* self,
803                                   gboolean value)
804 {
805 	g_return_if_fail (self != NULL);
806 	self->priv->_save_temps = value;
807 }
808 
809 ValaProfile
vala_code_context_get_profile(ValaCodeContext * self)810 vala_code_context_get_profile (ValaCodeContext* self)
811 {
812 	ValaProfile result;
813 	ValaProfile _tmp0_;
814 	g_return_val_if_fail (self != NULL, 0);
815 	_tmp0_ = self->priv->_profile;
816 	result = _tmp0_;
817 	return result;
818 }
819 
820 void
vala_code_context_set_profile(ValaCodeContext * self,ValaProfile value)821 vala_code_context_set_profile (ValaCodeContext* self,
822                                ValaProfile value)
823 {
824 	g_return_if_fail (self != NULL);
825 	self->priv->_profile = value;
826 }
827 
828 gboolean
vala_code_context_get_verbose_mode(ValaCodeContext * self)829 vala_code_context_get_verbose_mode (ValaCodeContext* self)
830 {
831 	gboolean result;
832 	g_return_val_if_fail (self != NULL, FALSE);
833 	result = self->priv->_verbose_mode;
834 	return result;
835 }
836 
837 void
vala_code_context_set_verbose_mode(ValaCodeContext * self,gboolean value)838 vala_code_context_set_verbose_mode (ValaCodeContext* self,
839                                     gboolean value)
840 {
841 	g_return_if_fail (self != NULL);
842 	self->priv->_verbose_mode = value;
843 }
844 
845 gboolean
vala_code_context_get_version_header(ValaCodeContext * self)846 vala_code_context_get_version_header (ValaCodeContext* self)
847 {
848 	gboolean result;
849 	g_return_val_if_fail (self != NULL, FALSE);
850 	result = self->priv->_version_header;
851 	return result;
852 }
853 
854 void
vala_code_context_set_version_header(ValaCodeContext * self,gboolean value)855 vala_code_context_set_version_header (ValaCodeContext* self,
856                                       gboolean value)
857 {
858 	g_return_if_fail (self != NULL);
859 	self->priv->_version_header = value;
860 }
861 
862 gboolean
vala_code_context_get_nostdpkg(ValaCodeContext * self)863 vala_code_context_get_nostdpkg (ValaCodeContext* self)
864 {
865 	gboolean result;
866 	g_return_val_if_fail (self != NULL, FALSE);
867 	result = self->priv->_nostdpkg;
868 	return result;
869 }
870 
871 void
vala_code_context_set_nostdpkg(ValaCodeContext * self,gboolean value)872 vala_code_context_set_nostdpkg (ValaCodeContext* self,
873                                 gboolean value)
874 {
875 	g_return_if_fail (self != NULL);
876 	self->priv->_nostdpkg = value;
877 }
878 
879 gboolean
vala_code_context_get_use_fast_vapi(ValaCodeContext * self)880 vala_code_context_get_use_fast_vapi (ValaCodeContext* self)
881 {
882 	gboolean result;
883 	g_return_val_if_fail (self != NULL, FALSE);
884 	result = self->priv->_use_fast_vapi;
885 	return result;
886 }
887 
888 void
vala_code_context_set_use_fast_vapi(ValaCodeContext * self,gboolean value)889 vala_code_context_set_use_fast_vapi (ValaCodeContext* self,
890                                      gboolean value)
891 {
892 	g_return_if_fail (self != NULL);
893 	self->priv->_use_fast_vapi = value;
894 }
895 
896 gboolean
vala_code_context_get_keep_going(ValaCodeContext * self)897 vala_code_context_get_keep_going (ValaCodeContext* self)
898 {
899 	gboolean result;
900 	g_return_val_if_fail (self != NULL, FALSE);
901 	result = self->priv->_keep_going;
902 	return result;
903 }
904 
905 void
vala_code_context_set_keep_going(ValaCodeContext * self,gboolean value)906 vala_code_context_set_keep_going (ValaCodeContext* self,
907                                   gboolean value)
908 {
909 	g_return_if_fail (self != NULL);
910 	self->priv->_keep_going = value;
911 }
912 
913 gboolean
vala_code_context_get_vapi_comments(ValaCodeContext * self)914 vala_code_context_get_vapi_comments (ValaCodeContext* self)
915 {
916 	gboolean result;
917 	g_return_val_if_fail (self != NULL, FALSE);
918 	result = self->priv->_vapi_comments;
919 	return result;
920 }
921 
922 void
vala_code_context_set_vapi_comments(ValaCodeContext * self,gboolean value)923 vala_code_context_set_vapi_comments (ValaCodeContext* self,
924                                      gboolean value)
925 {
926 	g_return_if_fail (self != NULL);
927 	self->priv->_vapi_comments = value;
928 }
929 
930 /**
931  * Returns true if the target version of glib is greater than or
932  * equal to the specified version.
933  */
934 gboolean
vala_code_context_require_glib_version(ValaCodeContext * self,gint major,gint minor)935 vala_code_context_require_glib_version (ValaCodeContext* self,
936                                         gint major,
937                                         gint minor)
938 {
939 	gboolean _tmp0_ = FALSE;
940 	gboolean result = FALSE;
941 	g_return_val_if_fail (self != NULL, FALSE);
942 	if (self->priv->target_glib_major > major) {
943 		_tmp0_ = TRUE;
944 	} else {
945 		gboolean _tmp1_ = FALSE;
946 		if (self->priv->target_glib_major == major) {
947 			_tmp1_ = self->priv->target_glib_minor >= minor;
948 		} else {
949 			_tmp1_ = FALSE;
950 		}
951 		_tmp0_ = _tmp1_;
952 	}
953 	result = _tmp0_;
954 	return result;
955 }
956 
957 gboolean
vala_code_context_get_save_csources(ValaCodeContext * self)958 vala_code_context_get_save_csources (ValaCodeContext* self)
959 {
960 	gboolean result;
961 	gboolean _tmp0_;
962 	g_return_val_if_fail (self != NULL, FALSE);
963 	_tmp0_ = self->priv->_save_temps;
964 	result = _tmp0_;
965 	return result;
966 }
967 
968 ValaReport*
vala_code_context_get_report(ValaCodeContext * self)969 vala_code_context_get_report (ValaCodeContext* self)
970 {
971 	ValaReport* result;
972 	ValaReport* _tmp0_;
973 	g_return_val_if_fail (self != NULL, NULL);
974 	_tmp0_ = self->priv->_report;
975 	result = _tmp0_;
976 	return result;
977 }
978 
979 static gpointer
_vala_report_ref0(gpointer self)980 _vala_report_ref0 (gpointer self)
981 {
982 	return self ? vala_report_ref (self) : NULL;
983 }
984 
985 void
vala_code_context_set_report(ValaCodeContext * self,ValaReport * value)986 vala_code_context_set_report (ValaCodeContext* self,
987                               ValaReport* value)
988 {
989 	ValaReport* _tmp0_;
990 	g_return_if_fail (self != NULL);
991 	_tmp0_ = _vala_report_ref0 (value);
992 	_vala_report_unref0 (self->priv->_report);
993 	self->priv->_report = _tmp0_;
994 }
995 
996 ValaMethod*
vala_code_context_get_entry_point(ValaCodeContext * self)997 vala_code_context_get_entry_point (ValaCodeContext* self)
998 {
999 	ValaMethod* result;
1000 	ValaMethod* _tmp0_;
1001 	g_return_val_if_fail (self != NULL, NULL);
1002 	_tmp0_ = self->priv->_entry_point;
1003 	result = _tmp0_;
1004 	return result;
1005 }
1006 
1007 void
vala_code_context_set_entry_point(ValaCodeContext * self,ValaMethod * value)1008 vala_code_context_set_entry_point (ValaCodeContext* self,
1009                                    ValaMethod* value)
1010 {
1011 	ValaMethod* _tmp0_;
1012 	g_return_if_fail (self != NULL);
1013 	_tmp0_ = _vala_code_node_ref0 (value);
1014 	_vala_code_node_unref0 (self->priv->_entry_point);
1015 	self->priv->_entry_point = _tmp0_;
1016 }
1017 
1018 const gchar*
vala_code_context_get_entry_point_name(ValaCodeContext * self)1019 vala_code_context_get_entry_point_name (ValaCodeContext* self)
1020 {
1021 	const gchar* result;
1022 	const gchar* _tmp0_;
1023 	g_return_val_if_fail (self != NULL, NULL);
1024 	_tmp0_ = self->priv->_entry_point_name;
1025 	result = _tmp0_;
1026 	return result;
1027 }
1028 
1029 void
vala_code_context_set_entry_point_name(ValaCodeContext * self,const gchar * value)1030 vala_code_context_set_entry_point_name (ValaCodeContext* self,
1031                                         const gchar* value)
1032 {
1033 	gchar* _tmp0_;
1034 	g_return_if_fail (self != NULL);
1035 	_tmp0_ = g_strdup (value);
1036 	_g_free0 (self->priv->_entry_point_name);
1037 	self->priv->_entry_point_name = _tmp0_;
1038 }
1039 
1040 gboolean
vala_code_context_get_run_output(ValaCodeContext * self)1041 vala_code_context_get_run_output (ValaCodeContext* self)
1042 {
1043 	gboolean result;
1044 	g_return_val_if_fail (self != NULL, FALSE);
1045 	result = self->priv->_run_output;
1046 	return result;
1047 }
1048 
1049 void
vala_code_context_set_run_output(ValaCodeContext * self,gboolean value)1050 vala_code_context_set_run_output (ValaCodeContext* self,
1051                                   gboolean value)
1052 {
1053 	g_return_if_fail (self != NULL);
1054 	self->priv->_run_output = value;
1055 }
1056 
1057 gchar**
vala_code_context_get_gresources(ValaCodeContext * self,gint * result_length1)1058 vala_code_context_get_gresources (ValaCodeContext* self,
1059                                   gint* result_length1)
1060 {
1061 	gchar** result;
1062 	gchar** _tmp0_;
1063 	gint _tmp0__length1;
1064 	gchar** _tmp1_;
1065 	gint _tmp1__length1;
1066 	g_return_val_if_fail (self != NULL, NULL);
1067 	_tmp0_ = self->priv->_gresources;
1068 	_tmp0__length1 = self->priv->_gresources_length1;
1069 	_tmp1_ = _tmp0_;
1070 	_tmp1__length1 = _tmp0__length1;
1071 	if (result_length1) {
1072 		*result_length1 = _tmp1__length1;
1073 	}
1074 	result = _tmp1_;
1075 	return result;
1076 }
1077 
1078 static gchar**
_vala_array_dup4(gchar ** self,gint length)1079 _vala_array_dup4 (gchar** self,
1080                   gint length)
1081 {
1082 	if (length >= 0) {
1083 		gchar** result;
1084 		gint i;
1085 		result = g_new0 (gchar*, length + 1);
1086 		for (i = 0; i < length; i++) {
1087 			gchar* _tmp0_;
1088 			_tmp0_ = g_strdup (self[i]);
1089 			result[i] = _tmp0_;
1090 		}
1091 		return result;
1092 	}
1093 	return NULL;
1094 }
1095 
1096 void
vala_code_context_set_gresources(ValaCodeContext * self,gchar ** value,gint value_length1)1097 vala_code_context_set_gresources (ValaCodeContext* self,
1098                                   gchar** value,
1099                                   gint value_length1)
1100 {
1101 	gchar** _tmp0_;
1102 	gint _tmp0__length1;
1103 	g_return_if_fail (self != NULL);
1104 	_tmp0_ = (value != NULL) ? _vala_array_dup4 (value, value_length1) : value;
1105 	_tmp0__length1 = value_length1;
1106 	self->priv->_gresources = (_vala_array_free (self->priv->_gresources, self->priv->_gresources_length1, (GDestroyNotify) g_free), NULL);
1107 	self->priv->_gresources = _tmp0_;
1108 	self->priv->_gresources_length1 = _tmp0__length1;
1109 	self->priv->__gresources_size_ = self->priv->_gresources_length1;
1110 }
1111 
1112 gchar**
vala_code_context_get_gresources_directories(ValaCodeContext * self,gint * result_length1)1113 vala_code_context_get_gresources_directories (ValaCodeContext* self,
1114                                               gint* result_length1)
1115 {
1116 	gchar** result;
1117 	gchar** _tmp0_;
1118 	gint _tmp0__length1;
1119 	gchar** _tmp1_;
1120 	gint _tmp1__length1;
1121 	g_return_val_if_fail (self != NULL, NULL);
1122 	_tmp0_ = self->priv->_gresources_directories;
1123 	_tmp0__length1 = self->priv->_gresources_directories_length1;
1124 	_tmp1_ = _tmp0_;
1125 	_tmp1__length1 = _tmp0__length1;
1126 	if (result_length1) {
1127 		*result_length1 = _tmp1__length1;
1128 	}
1129 	result = _tmp1_;
1130 	return result;
1131 }
1132 
1133 static gchar**
_vala_array_dup5(gchar ** self,gint length)1134 _vala_array_dup5 (gchar** self,
1135                   gint length)
1136 {
1137 	if (length >= 0) {
1138 		gchar** result;
1139 		gint i;
1140 		result = g_new0 (gchar*, length + 1);
1141 		for (i = 0; i < length; i++) {
1142 			gchar* _tmp0_;
1143 			_tmp0_ = g_strdup (self[i]);
1144 			result[i] = _tmp0_;
1145 		}
1146 		return result;
1147 	}
1148 	return NULL;
1149 }
1150 
1151 void
vala_code_context_set_gresources_directories(ValaCodeContext * self,gchar ** value,gint value_length1)1152 vala_code_context_set_gresources_directories (ValaCodeContext* self,
1153                                               gchar** value,
1154                                               gint value_length1)
1155 {
1156 	gchar** _tmp0_;
1157 	gint _tmp0__length1;
1158 	g_return_if_fail (self != NULL);
1159 	_tmp0_ = (value != NULL) ? _vala_array_dup5 (value, value_length1) : value;
1160 	_tmp0__length1 = value_length1;
1161 	self->priv->_gresources_directories = (_vala_array_free (self->priv->_gresources_directories, self->priv->_gresources_directories_length1, (GDestroyNotify) g_free), NULL);
1162 	self->priv->_gresources_directories = _tmp0_;
1163 	self->priv->_gresources_directories_length1 = _tmp0__length1;
1164 	self->priv->__gresources_directories_size_ = self->priv->_gresources_directories_length1;
1165 }
1166 
1167 ValaNamespace*
vala_code_context_get_root(ValaCodeContext * self)1168 vala_code_context_get_root (ValaCodeContext* self)
1169 {
1170 	ValaNamespace* result;
1171 	ValaNamespace* _tmp0_;
1172 	g_return_val_if_fail (self != NULL, NULL);
1173 	_tmp0_ = self->priv->_root;
1174 	result = _tmp0_;
1175 	return result;
1176 }
1177 
1178 ValaSymbolResolver*
vala_code_context_get_resolver(ValaCodeContext * self)1179 vala_code_context_get_resolver (ValaCodeContext* self)
1180 {
1181 	ValaSymbolResolver* result;
1182 	ValaSymbolResolver* _tmp0_;
1183 	g_return_val_if_fail (self != NULL, NULL);
1184 	_tmp0_ = self->priv->_resolver;
1185 	result = _tmp0_;
1186 	return result;
1187 }
1188 
1189 static gpointer
_vala_code_visitor_ref0(gpointer self)1190 _vala_code_visitor_ref0 (gpointer self)
1191 {
1192 	return self ? vala_code_visitor_ref (self) : NULL;
1193 }
1194 
1195 static void
vala_code_context_set_resolver(ValaCodeContext * self,ValaSymbolResolver * value)1196 vala_code_context_set_resolver (ValaCodeContext* self,
1197                                 ValaSymbolResolver* value)
1198 {
1199 	ValaSymbolResolver* _tmp0_;
1200 	g_return_if_fail (self != NULL);
1201 	_tmp0_ = _vala_code_visitor_ref0 (value);
1202 	_vala_code_visitor_unref0 (self->priv->_resolver);
1203 	self->priv->_resolver = _tmp0_;
1204 }
1205 
1206 ValaSemanticAnalyzer*
vala_code_context_get_analyzer(ValaCodeContext * self)1207 vala_code_context_get_analyzer (ValaCodeContext* self)
1208 {
1209 	ValaSemanticAnalyzer* result;
1210 	ValaSemanticAnalyzer* _tmp0_;
1211 	g_return_val_if_fail (self != NULL, NULL);
1212 	_tmp0_ = self->priv->_analyzer;
1213 	result = _tmp0_;
1214 	return result;
1215 }
1216 
1217 static void
vala_code_context_set_analyzer(ValaCodeContext * self,ValaSemanticAnalyzer * value)1218 vala_code_context_set_analyzer (ValaCodeContext* self,
1219                                 ValaSemanticAnalyzer* value)
1220 {
1221 	ValaSemanticAnalyzer* _tmp0_;
1222 	g_return_if_fail (self != NULL);
1223 	_tmp0_ = _vala_code_visitor_ref0 (value);
1224 	_vala_code_visitor_unref0 (self->priv->_analyzer);
1225 	self->priv->_analyzer = _tmp0_;
1226 }
1227 
1228 ValaFlowAnalyzer*
vala_code_context_get_flow_analyzer(ValaCodeContext * self)1229 vala_code_context_get_flow_analyzer (ValaCodeContext* self)
1230 {
1231 	ValaFlowAnalyzer* result;
1232 	ValaFlowAnalyzer* _tmp0_;
1233 	g_return_val_if_fail (self != NULL, NULL);
1234 	_tmp0_ = self->priv->_flow_analyzer;
1235 	result = _tmp0_;
1236 	return result;
1237 }
1238 
1239 static void
vala_code_context_set_flow_analyzer(ValaCodeContext * self,ValaFlowAnalyzer * value)1240 vala_code_context_set_flow_analyzer (ValaCodeContext* self,
1241                                      ValaFlowAnalyzer* value)
1242 {
1243 	ValaFlowAnalyzer* _tmp0_;
1244 	g_return_if_fail (self != NULL);
1245 	_tmp0_ = _vala_code_visitor_ref0 (value);
1246 	_vala_code_visitor_unref0 (self->priv->_flow_analyzer);
1247 	self->priv->_flow_analyzer = _tmp0_;
1248 }
1249 
1250 ValaCodeGenerator*
vala_code_context_get_codegen(ValaCodeContext * self)1251 vala_code_context_get_codegen (ValaCodeContext* self)
1252 {
1253 	ValaCodeGenerator* result;
1254 	ValaCodeGenerator* _tmp0_;
1255 	g_return_val_if_fail (self != NULL, NULL);
1256 	_tmp0_ = self->priv->_codegen;
1257 	result = _tmp0_;
1258 	return result;
1259 }
1260 
1261 void
vala_code_context_set_codegen(ValaCodeContext * self,ValaCodeGenerator * value)1262 vala_code_context_set_codegen (ValaCodeContext* self,
1263                                ValaCodeGenerator* value)
1264 {
1265 	ValaCodeGenerator* _tmp0_;
1266 	g_return_if_fail (self != NULL);
1267 	_tmp0_ = _vala_code_visitor_ref0 (value);
1268 	_vala_code_visitor_unref0 (self->priv->_codegen);
1269 	self->priv->_codegen = _tmp0_;
1270 }
1271 
1272 ValaUsedAttr*
vala_code_context_get_used_attr(ValaCodeContext * self)1273 vala_code_context_get_used_attr (ValaCodeContext* self)
1274 {
1275 	ValaUsedAttr* result;
1276 	ValaUsedAttr* _tmp0_;
1277 	g_return_val_if_fail (self != NULL, NULL);
1278 	_tmp0_ = self->priv->_used_attr;
1279 	result = _tmp0_;
1280 	return result;
1281 }
1282 
1283 void
vala_code_context_set_used_attr(ValaCodeContext * self,ValaUsedAttr * value)1284 vala_code_context_set_used_attr (ValaCodeContext* self,
1285                                  ValaUsedAttr* value)
1286 {
1287 	ValaUsedAttr* _tmp0_;
1288 	g_return_if_fail (self != NULL);
1289 	_tmp0_ = _vala_code_visitor_ref0 (value);
1290 	_vala_code_visitor_unref0 (self->priv->_used_attr);
1291 	self->priv->_used_attr = _tmp0_;
1292 }
1293 
1294 ValaCodeContext*
vala_code_context_construct(GType object_type)1295 vala_code_context_construct (GType object_type)
1296 {
1297 	ValaCodeContext* self = NULL;
1298 	ValaSymbolResolver* _tmp0_;
1299 	ValaSymbolResolver* _tmp1_;
1300 	ValaSemanticAnalyzer* _tmp2_;
1301 	ValaSemanticAnalyzer* _tmp3_;
1302 	ValaFlowAnalyzer* _tmp4_;
1303 	ValaFlowAnalyzer* _tmp5_;
1304 	ValaUsedAttr* _tmp6_;
1305 	ValaUsedAttr* _tmp7_;
1306 	self = (ValaCodeContext*) g_type_create_instance (object_type);
1307 	vala_code_context_add_default_defines (self);
1308 	_tmp0_ = vala_symbol_resolver_new ();
1309 	_tmp1_ = _tmp0_;
1310 	vala_code_context_set_resolver (self, _tmp1_);
1311 	_vala_code_visitor_unref0 (_tmp1_);
1312 	_tmp2_ = vala_semantic_analyzer_new ();
1313 	_tmp3_ = _tmp2_;
1314 	vala_code_context_set_analyzer (self, _tmp3_);
1315 	_vala_code_visitor_unref0 (_tmp3_);
1316 	_tmp4_ = vala_flow_analyzer_new ();
1317 	_tmp5_ = _tmp4_;
1318 	vala_code_context_set_flow_analyzer (self, _tmp5_);
1319 	_vala_code_visitor_unref0 (_tmp5_);
1320 	_tmp6_ = vala_used_attr_new ();
1321 	_tmp7_ = _tmp6_;
1322 	vala_code_context_set_used_attr (self, _tmp7_);
1323 	_vala_code_visitor_unref0 (_tmp7_);
1324 	return self;
1325 }
1326 
1327 ValaCodeContext*
vala_code_context_new(void)1328 vala_code_context_new (void)
1329 {
1330 	return vala_code_context_construct (VALA_TYPE_CODE_CONTEXT);
1331 }
1332 
1333 /**
1334  * Return the topmost context from the context stack.
1335  */
1336 ValaCodeContext*
vala_code_context_get(void)1337 vala_code_context_get (void)
1338 {
1339 	ValaList* context_stack = NULL;
1340 	void* _tmp0_;
1341 	gboolean _tmp1_ = FALSE;
1342 	ValaList* _tmp2_;
1343 	ValaList* _tmp6_;
1344 	ValaList* _tmp7_;
1345 	gint _tmp8_;
1346 	gint _tmp9_;
1347 	gpointer _tmp10_;
1348 	ValaCodeContext* result = NULL;
1349 	_tmp0_ = g_static_private_get (&vala_code_context_context_stack_key);
1350 	context_stack = _tmp0_;
1351 	_tmp2_ = context_stack;
1352 	if (_tmp2_ == NULL) {
1353 		_tmp1_ = TRUE;
1354 	} else {
1355 		ValaList* _tmp3_;
1356 		gint _tmp4_;
1357 		gint _tmp5_;
1358 		_tmp3_ = context_stack;
1359 		_tmp4_ = vala_collection_get_size ((ValaCollection*) _tmp3_);
1360 		_tmp5_ = _tmp4_;
1361 		_tmp1_ = _tmp5_ == 0;
1362 	}
1363 	if (_tmp1_) {
1364 		g_error ("valacodecontext.vala:263: internal: No context available to get");
1365 	}
1366 	_tmp6_ = context_stack;
1367 	_tmp7_ = context_stack;
1368 	_tmp8_ = vala_collection_get_size ((ValaCollection*) _tmp7_);
1369 	_tmp9_ = _tmp8_;
1370 	_tmp10_ = vala_list_get (_tmp6_, _tmp9_ - 1);
1371 	result = (ValaCodeContext*) _tmp10_;
1372 	return result;
1373 }
1374 
1375 /**
1376  * Push the specified context to the context stack.
1377  */
1378 void
vala_code_context_push(ValaCodeContext * context)1379 vala_code_context_push (ValaCodeContext* context)
1380 {
1381 	ValaArrayList* context_stack = NULL;
1382 	void* _tmp0_;
1383 	ValaArrayList* _tmp1_;
1384 	ValaArrayList* _tmp5_;
1385 	g_return_if_fail (context != NULL);
1386 	_tmp0_ = g_static_private_get (&vala_code_context_context_stack_key);
1387 	context_stack = _tmp0_;
1388 	_tmp1_ = context_stack;
1389 	if (_tmp1_ == NULL) {
1390 		GEqualFunc _tmp2_;
1391 		ValaArrayList* _tmp3_;
1392 		ValaArrayList* _tmp4_;
1393 		_tmp2_ = g_direct_equal;
1394 		_tmp3_ = vala_array_list_new (VALA_TYPE_CODE_CONTEXT, (GBoxedCopyFunc) vala_code_context_ref, (GDestroyNotify) vala_code_context_unref, _tmp2_);
1395 		context_stack = _tmp3_;
1396 		_tmp4_ = context_stack;
1397 		g_static_private_set (&vala_code_context_context_stack_key, _tmp4_, NULL);
1398 	}
1399 	_tmp5_ = context_stack;
1400 	vala_collection_add ((ValaCollection*) _tmp5_, context);
1401 }
1402 
1403 /**
1404  * Remove the topmost context from the context stack.
1405  */
1406 void
vala_code_context_pop(void)1407 vala_code_context_pop (void)
1408 {
1409 	ValaList* context_stack = NULL;
1410 	void* _tmp0_;
1411 	gboolean _tmp1_ = FALSE;
1412 	ValaList* _tmp2_;
1413 	ValaList* _tmp6_;
1414 	ValaList* _tmp7_;
1415 	gint _tmp8_;
1416 	gint _tmp9_;
1417 	gpointer _tmp10_;
1418 	ValaCodeContext* _tmp11_;
1419 	_tmp0_ = g_static_private_get (&vala_code_context_context_stack_key);
1420 	context_stack = _tmp0_;
1421 	_tmp2_ = context_stack;
1422 	if (_tmp2_ == NULL) {
1423 		_tmp1_ = TRUE;
1424 	} else {
1425 		ValaList* _tmp3_;
1426 		gint _tmp4_;
1427 		gint _tmp5_;
1428 		_tmp3_ = context_stack;
1429 		_tmp4_ = vala_collection_get_size ((ValaCollection*) _tmp3_);
1430 		_tmp5_ = _tmp4_;
1431 		_tmp1_ = _tmp5_ == 0;
1432 	}
1433 	if (_tmp1_) {
1434 		g_error ("valacodecontext.vala:289: internal: No context available to pop");
1435 	}
1436 	_tmp6_ = context_stack;
1437 	_tmp7_ = context_stack;
1438 	_tmp8_ = vala_collection_get_size ((ValaCollection*) _tmp7_);
1439 	_tmp9_ = _tmp8_;
1440 	_tmp10_ = vala_list_remove_at (_tmp6_, _tmp9_ - 1);
1441 	_tmp11_ = (ValaCodeContext*) _tmp10_;
1442 	_vala_code_context_unref0 (_tmp11_);
1443 }
1444 
1445 /**
1446  * Returns the list of source files.
1447  *
1448  * @return list of source files
1449  */
1450 ValaList*
vala_code_context_get_source_files(ValaCodeContext * self)1451 vala_code_context_get_source_files (ValaCodeContext* self)
1452 {
1453 	ValaList* _tmp0_;
1454 	ValaList* result = NULL;
1455 	g_return_val_if_fail (self != NULL, NULL);
1456 	_tmp0_ = self->priv->source_files;
1457 	result = _tmp0_;
1458 	return result;
1459 }
1460 
1461 /**
1462  * Returns the list of C source files.
1463  *
1464  * @return list of C source files
1465  */
1466 ValaList*
vala_code_context_get_c_source_files(ValaCodeContext * self)1467 vala_code_context_get_c_source_files (ValaCodeContext* self)
1468 {
1469 	ValaList* _tmp0_;
1470 	ValaList* result = NULL;
1471 	g_return_val_if_fail (self != NULL, NULL);
1472 	_tmp0_ = self->priv->c_source_files;
1473 	result = _tmp0_;
1474 	return result;
1475 }
1476 
1477 /**
1478  * Adds the specified file to the list of source files.
1479  *
1480  * @param file a source file
1481  */
1482 void
vala_code_context_add_source_file(ValaCodeContext * self,ValaSourceFile * file)1483 vala_code_context_add_source_file (ValaCodeContext* self,
1484                                    ValaSourceFile* file)
1485 {
1486 	ValaMap* _tmp0_;
1487 	const gchar* _tmp1_;
1488 	const gchar* _tmp2_;
1489 	ValaList* _tmp7_;
1490 	ValaMap* _tmp8_;
1491 	const gchar* _tmp9_;
1492 	const gchar* _tmp10_;
1493 	g_return_if_fail (self != NULL);
1494 	g_return_if_fail (file != NULL);
1495 	_tmp0_ = self->priv->source_files_map;
1496 	_tmp1_ = vala_source_file_get_filename (file);
1497 	_tmp2_ = _tmp1_;
1498 	if (vala_map_contains (_tmp0_, _tmp2_)) {
1499 		const gchar* _tmp3_;
1500 		const gchar* _tmp4_;
1501 		gchar* _tmp5_;
1502 		gchar* _tmp6_;
1503 		_tmp3_ = vala_source_file_get_filename (file);
1504 		_tmp4_ = _tmp3_;
1505 		_tmp5_ = g_strdup_printf ("Ignoring source file `%s', which was already added to this context", _tmp4_);
1506 		_tmp6_ = _tmp5_;
1507 		vala_report_warning (NULL, _tmp6_);
1508 		_g_free0 (_tmp6_);
1509 		return;
1510 	}
1511 	_tmp7_ = self->priv->source_files;
1512 	vala_collection_add ((ValaCollection*) _tmp7_, file);
1513 	_tmp8_ = self->priv->source_files_map;
1514 	_tmp9_ = vala_source_file_get_filename (file);
1515 	_tmp10_ = _tmp9_;
1516 	vala_map_set (_tmp8_, _tmp10_, file);
1517 }
1518 
1519 /**
1520  * Returns the source file for a given path.
1521  *
1522  * @param filename a path to a source file
1523  * @return the source file if found
1524  */
1525 ValaSourceFile*
vala_code_context_get_source_file(ValaCodeContext * self,const gchar * filename)1526 vala_code_context_get_source_file (ValaCodeContext* self,
1527                                    const gchar* filename)
1528 {
1529 	ValaMap* _tmp0_;
1530 	gpointer _tmp1_;
1531 	ValaSourceFile* result = NULL;
1532 	g_return_val_if_fail (self != NULL, NULL);
1533 	g_return_val_if_fail (filename != NULL, NULL);
1534 	_tmp0_ = self->priv->source_files_map;
1535 	_tmp1_ = vala_map_get (_tmp0_, filename);
1536 	result = (ValaSourceFile*) _tmp1_;
1537 	return result;
1538 }
1539 
1540 /**
1541  * Adds the specified file to the list of C source files.
1542  *
1543  * @param file a C source file
1544  */
1545 void
vala_code_context_add_c_source_file(ValaCodeContext * self,const gchar * file)1546 vala_code_context_add_c_source_file (ValaCodeContext* self,
1547                                      const gchar* file)
1548 {
1549 	ValaList* _tmp0_;
1550 	g_return_if_fail (self != NULL);
1551 	g_return_if_fail (file != NULL);
1552 	_tmp0_ = self->priv->c_source_files;
1553 	vala_collection_add ((ValaCollection*) _tmp0_, file);
1554 }
1555 
1556 /**
1557  * Returns the list of used packages.
1558  *
1559  * @return list of used packages
1560  */
1561 ValaList*
vala_code_context_get_packages(ValaCodeContext * self)1562 vala_code_context_get_packages (ValaCodeContext* self)
1563 {
1564 	ValaList* _tmp0_;
1565 	ValaList* result = NULL;
1566 	g_return_val_if_fail (self != NULL, NULL);
1567 	_tmp0_ = self->priv->packages;
1568 	result = _tmp0_;
1569 	return result;
1570 }
1571 
1572 /**
1573  * Returns whether the specified package is being used.
1574  *
1575  * @param pkg a package name
1576  * @return    true if the specified package is being used
1577  */
1578 gboolean
vala_code_context_has_package(ValaCodeContext * self,const gchar * pkg)1579 vala_code_context_has_package (ValaCodeContext* self,
1580                                const gchar* pkg)
1581 {
1582 	ValaList* _tmp0_;
1583 	gboolean result = FALSE;
1584 	g_return_val_if_fail (self != NULL, FALSE);
1585 	g_return_val_if_fail (pkg != NULL, FALSE);
1586 	_tmp0_ = self->priv->packages;
1587 	result = vala_collection_contains ((ValaCollection*) _tmp0_, pkg);
1588 	return result;
1589 }
1590 
1591 /**
1592  * Adds the specified package to the list of used packages.
1593  *
1594  * @param pkg a package name
1595  */
1596 void
vala_code_context_add_package(ValaCodeContext * self,const gchar * pkg)1597 vala_code_context_add_package (ValaCodeContext* self,
1598                                const gchar* pkg)
1599 {
1600 	ValaList* _tmp0_;
1601 	g_return_if_fail (self != NULL);
1602 	g_return_if_fail (pkg != NULL);
1603 	_tmp0_ = self->priv->packages;
1604 	vala_collection_add ((ValaCollection*) _tmp0_, pkg);
1605 }
1606 
1607 /**
1608  * Pull the specified package into the context.
1609  * The method is tolerant if the package has been already loaded.
1610  *
1611  * @param pkg a package name
1612  * @return false if the package could not be loaded
1613  *
1614  */
1615 gboolean
vala_code_context_add_external_package(ValaCodeContext * self,const gchar * pkg)1616 vala_code_context_add_external_package (ValaCodeContext* self,
1617                                         const gchar* pkg)
1618 {
1619 	gchar* path = NULL;
1620 	gchar* _tmp0_;
1621 	const gchar* _tmp1_;
1622 	const gchar* _tmp3_;
1623 	gchar* rpath = NULL;
1624 	const gchar* _tmp6_;
1625 	gchar* _tmp7_;
1626 	ValaSourceFile* source_file = NULL;
1627 	const gchar* _tmp8_;
1628 	ValaSourceFile* _tmp9_;
1629 	ValaSourceFile* _tmp10_;
1630 	const gchar* _tmp11_;
1631 	const gchar* _tmp12_;
1632 	gboolean _tmp16_;
1633 	gchar* deps_filename = NULL;
1634 	const gchar* _tmp19_;
1635 	gchar* _tmp20_;
1636 	gchar* _tmp21_;
1637 	gchar* _tmp22_;
1638 	gchar* _tmp23_;
1639 	gchar* _tmp24_;
1640 	gchar* _tmp25_;
1641 	const gchar* _tmp26_;
1642 	gboolean result = FALSE;
1643 	g_return_val_if_fail (self != NULL, FALSE);
1644 	g_return_val_if_fail (pkg != NULL, FALSE);
1645 	if (vala_code_context_has_package (self, pkg)) {
1646 		result = TRUE;
1647 		return result;
1648 	}
1649 	_tmp0_ = vala_code_context_get_vapi_path (self, pkg);
1650 	path = _tmp0_;
1651 	_tmp1_ = path;
1652 	if (_tmp1_ == NULL) {
1653 		gchar* _tmp2_;
1654 		_tmp2_ = vala_code_context_get_gir_path (self, pkg);
1655 		_g_free0 (path);
1656 		path = _tmp2_;
1657 	}
1658 	_tmp3_ = path;
1659 	if (_tmp3_ == NULL) {
1660 		gchar* _tmp4_;
1661 		gchar* _tmp5_;
1662 		_tmp4_ = g_strdup_printf ("Package `%s' not found in specified Vala API directories or GObject-In" \
1663 "trospection GIR directories", pkg);
1664 		_tmp5_ = _tmp4_;
1665 		vala_report_error (NULL, _tmp5_);
1666 		_g_free0 (_tmp5_);
1667 		result = FALSE;
1668 		_g_free0 (path);
1669 		return result;
1670 	}
1671 	vala_code_context_add_package (self, pkg);
1672 	_tmp6_ = path;
1673 	_tmp7_ = vala_code_context_realpath (_tmp6_);
1674 	rpath = _tmp7_;
1675 	_tmp8_ = path;
1676 	_tmp9_ = vala_source_file_new (self, VALA_SOURCE_FILE_TYPE_PACKAGE, _tmp8_, NULL, FALSE);
1677 	source_file = _tmp9_;
1678 	_tmp10_ = source_file;
1679 	vala_code_context_add_source_file (self, _tmp10_);
1680 	_tmp11_ = rpath;
1681 	_tmp12_ = path;
1682 	if (g_strcmp0 (_tmp11_, _tmp12_) != 0) {
1683 		ValaMap* _tmp13_;
1684 		const gchar* _tmp14_;
1685 		ValaSourceFile* _tmp15_;
1686 		_tmp13_ = self->priv->source_files_map;
1687 		_tmp14_ = rpath;
1688 		_tmp15_ = source_file;
1689 		vala_map_set (_tmp13_, _tmp14_, _tmp15_);
1690 	}
1691 	_tmp16_ = self->priv->_verbose_mode;
1692 	if (_tmp16_) {
1693 		FILE* _tmp17_;
1694 		const gchar* _tmp18_;
1695 		_tmp17_ = stdout;
1696 		_tmp18_ = path;
1697 		fprintf (_tmp17_, "Loaded package `%s'\n", _tmp18_);
1698 	}
1699 	_tmp19_ = path;
1700 	_tmp20_ = g_path_get_dirname (_tmp19_);
1701 	_tmp21_ = _tmp20_;
1702 	_tmp22_ = g_strconcat (pkg, ".deps", NULL);
1703 	_tmp23_ = _tmp22_;
1704 	_tmp24_ = g_build_path ("/", _tmp21_, _tmp23_, NULL);
1705 	_tmp25_ = _tmp24_;
1706 	_g_free0 (_tmp23_);
1707 	_g_free0 (_tmp21_);
1708 	deps_filename = _tmp25_;
1709 	_tmp26_ = deps_filename;
1710 	if (!vala_code_context_add_packages_from_file (self, _tmp26_)) {
1711 		result = FALSE;
1712 		_g_free0 (deps_filename);
1713 		_vala_source_file_unref0 (source_file);
1714 		_g_free0 (rpath);
1715 		_g_free0 (path);
1716 		return result;
1717 	}
1718 	result = TRUE;
1719 	_g_free0 (deps_filename);
1720 	_vala_source_file_unref0 (source_file);
1721 	_g_free0 (rpath);
1722 	_g_free0 (path);
1723 	return result;
1724 }
1725 
1726 /**
1727  * Read the given filename and pull in packages.
1728  * The method is tolerant if the file does not exist.
1729  *
1730  * @param filename a filename
1731  * @return false if an error occurs while reading the file or if a package could not be added
1732  */
1733 static gchar*
string_strip(const gchar * self)1734 string_strip (const gchar* self)
1735 {
1736 	gchar* _result_ = NULL;
1737 	gchar* _tmp0_;
1738 	gchar* result = NULL;
1739 	g_return_val_if_fail (self != NULL, NULL);
1740 	_tmp0_ = g_strdup (self);
1741 	_result_ = _tmp0_;
1742 	g_strstrip (_result_);
1743 	result = _result_;
1744 	return result;
1745 }
1746 
1747 gboolean
vala_code_context_add_packages_from_file(ValaCodeContext * self,const gchar * filename)1748 vala_code_context_add_packages_from_file (ValaCodeContext* self,
1749                                           const gchar* filename)
1750 {
1751 	GError* _inner_error0_ = NULL;
1752 	gboolean result = FALSE;
1753 	g_return_val_if_fail (self != NULL, FALSE);
1754 	g_return_val_if_fail (filename != NULL, FALSE);
1755 	if (!g_file_test (filename, G_FILE_TEST_EXISTS)) {
1756 		result = TRUE;
1757 		return result;
1758 	}
1759 	{
1760 		gchar* contents = NULL;
1761 		gchar* _tmp0_ = NULL;
1762 		const gchar* _tmp2_;
1763 		gchar** _tmp3_;
1764 		gchar** _tmp4_;
1765 		g_file_get_contents (filename, &_tmp0_, NULL, &_inner_error0_);
1766 		_g_free0 (contents);
1767 		contents = _tmp0_;
1768 		if (G_UNLIKELY (_inner_error0_ != NULL)) {
1769 			gboolean _tmp1_ = FALSE;
1770 			_g_free0 (contents);
1771 			if (_inner_error0_->domain == G_FILE_ERROR) {
1772 				goto __catch0_g_file_error;
1773 			}
1774 			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
1775 			g_clear_error (&_inner_error0_);
1776 			return _tmp1_;
1777 		}
1778 		_tmp2_ = contents;
1779 		_tmp4_ = _tmp3_ = g_strsplit (_tmp2_, "\n", 0);
1780 		{
1781 			gchar** package_collection = NULL;
1782 			gint package_collection_length1 = 0;
1783 			gint _package_collection_size_ = 0;
1784 			gint package_it = 0;
1785 			package_collection = _tmp4_;
1786 			package_collection_length1 = _vala_array_length (_tmp3_);
1787 			for (package_it = 0; package_it < package_collection_length1; package_it = package_it + 1) {
1788 				gchar* _tmp5_;
1789 				gchar* package = NULL;
1790 				_tmp5_ = g_strdup (package_collection[package_it]);
1791 				package = _tmp5_;
1792 				{
1793 					const gchar* _tmp6_;
1794 					gchar* _tmp7_;
1795 					const gchar* _tmp8_;
1796 					_tmp6_ = package;
1797 					_tmp7_ = string_strip (_tmp6_);
1798 					_g_free0 (package);
1799 					package = _tmp7_;
1800 					_tmp8_ = package;
1801 					if (g_strcmp0 (_tmp8_, "") != 0) {
1802 						const gchar* _tmp9_;
1803 						_tmp9_ = package;
1804 						vala_code_context_add_external_package (self, _tmp9_);
1805 					}
1806 					_g_free0 (package);
1807 				}
1808 			}
1809 			package_collection = (_vala_array_free (package_collection, package_collection_length1, (GDestroyNotify) g_free), NULL);
1810 		}
1811 		_g_free0 (contents);
1812 	}
1813 	goto __finally0;
1814 	__catch0_g_file_error:
1815 	{
1816 		GError* e = NULL;
1817 		GError* _tmp10_;
1818 		const gchar* _tmp11_;
1819 		gchar* _tmp12_;
1820 		gchar* _tmp13_;
1821 		e = _inner_error0_;
1822 		_inner_error0_ = NULL;
1823 		_tmp10_ = e;
1824 		_tmp11_ = _tmp10_->message;
1825 		_tmp12_ = g_strdup_printf ("Unable to read dependency file: %s", _tmp11_);
1826 		_tmp13_ = _tmp12_;
1827 		vala_report_error (NULL, _tmp13_);
1828 		_g_free0 (_tmp13_);
1829 		result = FALSE;
1830 		_g_error_free0 (e);
1831 		return result;
1832 	}
1833 	__finally0:
1834 	if (G_UNLIKELY (_inner_error0_ != NULL)) {
1835 		gboolean _tmp14_ = FALSE;
1836 		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
1837 		g_clear_error (&_inner_error0_);
1838 		return _tmp14_;
1839 	}
1840 	result = TRUE;
1841 	return result;
1842 }
1843 
1844 /**
1845  * Add the specified source file to the context. Only .vala, .vapi, .gs,
1846  * and .c extensions are supported.
1847  *
1848  * @param filename a filename
1849  * @param is_source true to force adding the file as .vala or .gs
1850  * @param cmdline true if the file came from the command line.
1851  * @return false if the file is not recognized or the file does not exist
1852  */
1853 gboolean
vala_code_context_add_source_filename(ValaCodeContext * self,const gchar * filename,gboolean is_source,gboolean cmdline)1854 vala_code_context_add_source_filename (ValaCodeContext* self,
1855                                        const gchar* filename,
1856                                        gboolean is_source,
1857                                        gboolean cmdline)
1858 {
1859 	gchar* rpath = NULL;
1860 	gchar* _tmp2_;
1861 	gboolean _tmp3_ = FALSE;
1862 	gboolean _tmp4_ = FALSE;
1863 	gboolean result = FALSE;
1864 	g_return_val_if_fail (self != NULL, FALSE);
1865 	g_return_val_if_fail (filename != NULL, FALSE);
1866 	if (!g_file_test (filename, G_FILE_TEST_EXISTS)) {
1867 		gchar* _tmp0_;
1868 		gchar* _tmp1_;
1869 		_tmp0_ = g_strdup_printf ("%s not found", filename);
1870 		_tmp1_ = _tmp0_;
1871 		vala_report_error (NULL, _tmp1_);
1872 		_g_free0 (_tmp1_);
1873 		result = FALSE;
1874 		return result;
1875 	}
1876 	_tmp2_ = vala_code_context_realpath (filename);
1877 	rpath = _tmp2_;
1878 	if (is_source) {
1879 		_tmp4_ = TRUE;
1880 	} else {
1881 		_tmp4_ = g_str_has_suffix (filename, ".vala");
1882 	}
1883 	if (_tmp4_) {
1884 		_tmp3_ = TRUE;
1885 	} else {
1886 		_tmp3_ = g_str_has_suffix (filename, ".gs");
1887 	}
1888 	if (_tmp3_) {
1889 		ValaSourceFile* source_file = NULL;
1890 		const gchar* _tmp5_;
1891 		ValaSourceFile* _tmp6_;
1892 		ValaSourceFile* _tmp7_;
1893 		ValaProfile _tmp8_;
1894 		ValaSourceFile* _tmp28_;
1895 		const gchar* _tmp29_;
1896 		_tmp5_ = rpath;
1897 		_tmp6_ = vala_source_file_new (self, VALA_SOURCE_FILE_TYPE_SOURCE, _tmp5_, NULL, cmdline);
1898 		source_file = _tmp6_;
1899 		_tmp7_ = source_file;
1900 		vala_source_file_set_relative_filename (_tmp7_, filename);
1901 		_tmp8_ = self->priv->_profile;
1902 		if (_tmp8_ == VALA_PROFILE_POSIX) {
1903 			ValaUsingDirective* ns_ref = NULL;
1904 			ValaUnresolvedSymbol* _tmp9_;
1905 			ValaUnresolvedSymbol* _tmp10_;
1906 			ValaUsingDirective* _tmp11_;
1907 			ValaUsingDirective* _tmp12_;
1908 			ValaSourceFile* _tmp13_;
1909 			ValaUsingDirective* _tmp14_;
1910 			ValaNamespace* _tmp15_;
1911 			ValaNamespace* _tmp16_;
1912 			ValaUsingDirective* _tmp17_;
1913 			_tmp9_ = vala_unresolved_symbol_new (NULL, "Posix", NULL);
1914 			_tmp10_ = _tmp9_;
1915 			_tmp11_ = vala_using_directive_new ((ValaSymbol*) _tmp10_, NULL);
1916 			_tmp12_ = _tmp11_;
1917 			_vala_code_node_unref0 (_tmp10_);
1918 			ns_ref = _tmp12_;
1919 			_tmp13_ = source_file;
1920 			_tmp14_ = ns_ref;
1921 			vala_source_file_add_using_directive (_tmp13_, _tmp14_);
1922 			_tmp15_ = vala_code_context_get_root (self);
1923 			_tmp16_ = _tmp15_;
1924 			_tmp17_ = ns_ref;
1925 			vala_namespace_add_using_directive (_tmp16_, _tmp17_);
1926 			_vala_code_node_unref0 (ns_ref);
1927 		} else {
1928 			ValaProfile _tmp18_;
1929 			_tmp18_ = self->priv->_profile;
1930 			if (_tmp18_ == VALA_PROFILE_GOBJECT) {
1931 				ValaUsingDirective* ns_ref = NULL;
1932 				ValaUnresolvedSymbol* _tmp19_;
1933 				ValaUnresolvedSymbol* _tmp20_;
1934 				ValaUsingDirective* _tmp21_;
1935 				ValaUsingDirective* _tmp22_;
1936 				ValaSourceFile* _tmp23_;
1937 				ValaUsingDirective* _tmp24_;
1938 				ValaNamespace* _tmp25_;
1939 				ValaNamespace* _tmp26_;
1940 				ValaUsingDirective* _tmp27_;
1941 				_tmp19_ = vala_unresolved_symbol_new (NULL, "GLib", NULL);
1942 				_tmp20_ = _tmp19_;
1943 				_tmp21_ = vala_using_directive_new ((ValaSymbol*) _tmp20_, NULL);
1944 				_tmp22_ = _tmp21_;
1945 				_vala_code_node_unref0 (_tmp20_);
1946 				ns_ref = _tmp22_;
1947 				_tmp23_ = source_file;
1948 				_tmp24_ = ns_ref;
1949 				vala_source_file_add_using_directive (_tmp23_, _tmp24_);
1950 				_tmp25_ = vala_code_context_get_root (self);
1951 				_tmp26_ = _tmp25_;
1952 				_tmp27_ = ns_ref;
1953 				vala_namespace_add_using_directive (_tmp26_, _tmp27_);
1954 				_vala_code_node_unref0 (ns_ref);
1955 			}
1956 		}
1957 		_tmp28_ = source_file;
1958 		vala_code_context_add_source_file (self, _tmp28_);
1959 		_tmp29_ = rpath;
1960 		if (g_strcmp0 (_tmp29_, filename) != 0) {
1961 			ValaMap* _tmp30_;
1962 			ValaSourceFile* _tmp31_;
1963 			_tmp30_ = self->priv->source_files_map;
1964 			_tmp31_ = source_file;
1965 			vala_map_set (_tmp30_, filename, _tmp31_);
1966 		}
1967 		_vala_source_file_unref0 (source_file);
1968 	} else {
1969 		gboolean _tmp32_ = FALSE;
1970 		if (g_str_has_suffix (filename, ".vapi")) {
1971 			_tmp32_ = TRUE;
1972 		} else {
1973 			_tmp32_ = g_str_has_suffix (filename, ".gir");
1974 		}
1975 		if (_tmp32_) {
1976 			ValaSourceFile* source_file = NULL;
1977 			const gchar* _tmp33_;
1978 			ValaSourceFile* _tmp34_;
1979 			ValaSourceFile* _tmp35_;
1980 			ValaSourceFile* _tmp36_;
1981 			const gchar* _tmp37_;
1982 			_tmp33_ = rpath;
1983 			_tmp34_ = vala_source_file_new (self, VALA_SOURCE_FILE_TYPE_PACKAGE, _tmp33_, NULL, cmdline);
1984 			source_file = _tmp34_;
1985 			_tmp35_ = source_file;
1986 			vala_source_file_set_relative_filename (_tmp35_, filename);
1987 			_tmp36_ = source_file;
1988 			vala_code_context_add_source_file (self, _tmp36_);
1989 			_tmp37_ = rpath;
1990 			if (g_strcmp0 (_tmp37_, filename) != 0) {
1991 				ValaMap* _tmp38_;
1992 				ValaSourceFile* _tmp39_;
1993 				_tmp38_ = self->priv->source_files_map;
1994 				_tmp39_ = source_file;
1995 				vala_map_set (_tmp38_, filename, _tmp39_);
1996 			}
1997 			_vala_source_file_unref0 (source_file);
1998 		} else {
1999 			if (g_str_has_suffix (filename, ".c")) {
2000 				const gchar* _tmp40_;
2001 				_tmp40_ = rpath;
2002 				vala_code_context_add_c_source_file (self, _tmp40_);
2003 			} else {
2004 				if (g_str_has_suffix (filename, ".h")) {
2005 				} else {
2006 					gchar* _tmp41_;
2007 					gchar* _tmp42_;
2008 					_tmp41_ = g_strdup_printf ("%s is not a supported source file type. Only .vala, .vapi, .gs, and .c" \
2009 " files are supported.", filename);
2010 					_tmp42_ = _tmp41_;
2011 					vala_report_error (NULL, _tmp42_);
2012 					_g_free0 (_tmp42_);
2013 					result = FALSE;
2014 					_g_free0 (rpath);
2015 					return result;
2016 				}
2017 			}
2018 		}
2019 	}
2020 	result = TRUE;
2021 	_g_free0 (rpath);
2022 	return result;
2023 }
2024 
2025 /**
2026  * Visits the complete code tree file by file.
2027  * It is possible to add new source files while visiting the tree.
2028  *
2029  * @param visitor the visitor to be called when traversing
2030  */
2031 void
vala_code_context_accept(ValaCodeContext * self,ValaCodeVisitor * visitor)2032 vala_code_context_accept (ValaCodeContext* self,
2033                           ValaCodeVisitor* visitor)
2034 {
2035 	ValaNamespace* _tmp0_;
2036 	ValaNamespace* _tmp1_;
2037 	gint index = 0;
2038 	g_return_if_fail (self != NULL);
2039 	g_return_if_fail (visitor != NULL);
2040 	_tmp0_ = vala_code_context_get_root (self);
2041 	_tmp1_ = _tmp0_;
2042 	vala_code_node_accept ((ValaCodeNode*) _tmp1_, visitor);
2043 	index = 0;
2044 	while (TRUE) {
2045 		ValaList* _tmp2_;
2046 		gint _tmp3_;
2047 		gint _tmp4_;
2048 		ValaSourceFile* source_file = NULL;
2049 		ValaList* _tmp5_;
2050 		gpointer _tmp6_;
2051 		ValaSourceFile* _tmp7_;
2052 		gint _tmp8_;
2053 		_tmp2_ = self->priv->source_files;
2054 		_tmp3_ = vala_collection_get_size ((ValaCollection*) _tmp2_);
2055 		_tmp4_ = _tmp3_;
2056 		if (!(index < _tmp4_)) {
2057 			break;
2058 		}
2059 		_tmp5_ = self->priv->source_files;
2060 		_tmp6_ = vala_list_get (_tmp5_, index);
2061 		source_file = (ValaSourceFile*) _tmp6_;
2062 		_tmp7_ = source_file;
2063 		vala_source_file_accept (_tmp7_, visitor);
2064 		_tmp8_ = index;
2065 		index = _tmp8_ + 1;
2066 		_vala_source_file_unref0 (source_file);
2067 	}
2068 }
2069 
2070 /**
2071  * Resolve and analyze.
2072  */
2073 void
vala_code_context_check(ValaCodeContext * self)2074 vala_code_context_check (ValaCodeContext* self)
2075 {
2076 	ValaSymbolResolver* _tmp0_;
2077 	gboolean _tmp1_ = FALSE;
2078 	gboolean _tmp2_;
2079 	ValaSemanticAnalyzer* _tmp4_;
2080 	ValaReport* _tmp5_;
2081 	ValaFlowAnalyzer* _tmp6_;
2082 	ValaReport* _tmp7_;
2083 	ValaUsedAttr* _tmp8_;
2084 	g_return_if_fail (self != NULL);
2085 	_tmp0_ = self->priv->_resolver;
2086 	vala_symbol_resolver_resolve (_tmp0_, self);
2087 	_tmp2_ = self->priv->_keep_going;
2088 	if (!_tmp2_) {
2089 		ValaReport* _tmp3_;
2090 		_tmp3_ = self->priv->_report;
2091 		_tmp1_ = vala_report_get_errors (_tmp3_) > 0;
2092 	} else {
2093 		_tmp1_ = FALSE;
2094 	}
2095 	if (_tmp1_) {
2096 		return;
2097 	}
2098 	_tmp4_ = self->priv->_analyzer;
2099 	vala_semantic_analyzer_analyze (_tmp4_, self);
2100 	_tmp5_ = self->priv->_report;
2101 	if (vala_report_get_errors (_tmp5_) > 0) {
2102 		return;
2103 	}
2104 	_tmp6_ = self->priv->_flow_analyzer;
2105 	vala_flow_analyzer_analyze (_tmp6_, self);
2106 	_tmp7_ = self->priv->_report;
2107 	if (vala_report_get_errors (_tmp7_) > 0) {
2108 		return;
2109 	}
2110 	_tmp8_ = self->priv->_used_attr;
2111 	vala_used_attr_check_unused (_tmp8_, self);
2112 }
2113 
2114 static inline GRegex*
_thread_safe_regex_init(GRegex ** re,const gchar * pattern,GRegexCompileFlags compile_flags)2115 _thread_safe_regex_init (GRegex** re,
2116                          const gchar * pattern,
2117                          GRegexCompileFlags compile_flags)
2118 {
2119 	if (g_once_init_enter ((volatile gsize*) re)) {
2120 		GRegex* val = g_regex_new (pattern, compile_flags, 0, NULL);
2121 		g_once_init_leave ((volatile gsize*) re, (gsize) val);
2122 	}
2123 	return *re;
2124 }
2125 
2126 void
vala_code_context_add_define(ValaCodeContext * self,const gchar * define)2127 vala_code_context_add_define (ValaCodeContext* self,
2128                               const gchar* define)
2129 {
2130 	ValaSet* _tmp2_;
2131 	g_return_if_fail (self != NULL);
2132 	g_return_if_fail (define != NULL);
2133 	if (vala_code_context_is_defined (self, define)) {
2134 		gchar* _tmp0_;
2135 		gchar* _tmp1_;
2136 		_tmp0_ = g_strdup_printf ("`%s' is already defined", define);
2137 		_tmp1_ = _tmp0_;
2138 		vala_report_warning (NULL, _tmp1_);
2139 		_g_free0 (_tmp1_);
2140 		if (g_regex_match_all (_thread_safe_regex_init (&_tmp_regex_0, "VALA_0_\\d+", 0), define, 0, NULL)) {
2141 			vala_report_warning (NULL, "`VALA_0_XX' defines are automatically added up to current compiler ver" \
2142 "sion in use");
2143 		} else {
2144 			if (g_regex_match_all (_thread_safe_regex_init (&_tmp_regex_1, "GLIB_2_\\d+", 0), define, 0, NULL)) {
2145 				vala_report_warning (NULL, "`GLIB_2_XX' defines are automatically added up to targeted glib versio" \
2146 "n");
2147 			}
2148 		}
2149 	}
2150 	_tmp2_ = self->priv->defines;
2151 	vala_collection_add ((ValaCollection*) _tmp2_, define);
2152 }
2153 
2154 gboolean
vala_code_context_is_defined(ValaCodeContext * self,const gchar * define)2155 vala_code_context_is_defined (ValaCodeContext* self,
2156                               const gchar* define)
2157 {
2158 	ValaSet* _tmp0_;
2159 	gboolean result = FALSE;
2160 	g_return_val_if_fail (self != NULL, FALSE);
2161 	g_return_val_if_fail (define != NULL, FALSE);
2162 	_tmp0_ = self->priv->defines;
2163 	result = vala_collection_contains ((ValaCollection*) _tmp0_, define);
2164 	return result;
2165 }
2166 
2167 static void
vala_code_context_add_default_defines(ValaCodeContext * self)2168 vala_code_context_add_default_defines (ValaCodeContext* self)
2169 {
2170 	gint api_major = 0;
2171 	gint api_minor = 0;
2172 	gboolean _tmp0_ = FALSE;
2173 	gboolean _tmp1_ = FALSE;
2174 	gint _tmp2_ = 0;
2175 	gint _tmp3_ = 0;
2176 	gint _tmp4_;
2177 	g_return_if_fail (self != NULL);
2178 	api_major = 0;
2179 	api_minor = 0;
2180 	_tmp4_ = sscanf (VALA_API_VERSION, "%d.%d", &_tmp2_, &_tmp3_);
2181 	api_major = _tmp2_;
2182 	api_minor = _tmp3_;
2183 	if (_tmp4_ != 2) {
2184 		_tmp1_ = TRUE;
2185 	} else {
2186 		_tmp1_ = api_major > 0;
2187 	}
2188 	if (_tmp1_) {
2189 		_tmp0_ = TRUE;
2190 	} else {
2191 		_tmp0_ = (api_minor % 2) != 0;
2192 	}
2193 	if (_tmp0_) {
2194 		vala_report_error (NULL, "Invalid format for Vala.API_VERSION");
2195 		return;
2196 	}
2197 	{
2198 		gint i = 0;
2199 		i = 2;
2200 		{
2201 			gboolean _tmp5_ = FALSE;
2202 			_tmp5_ = TRUE;
2203 			while (TRUE) {
2204 				ValaSet* _tmp6_;
2205 				gchar* _tmp7_;
2206 				gchar* _tmp8_;
2207 				if (!_tmp5_) {
2208 					i += 2;
2209 				}
2210 				_tmp5_ = FALSE;
2211 				if (!(i <= api_minor)) {
2212 					break;
2213 				}
2214 				_tmp6_ = self->priv->defines;
2215 				_tmp7_ = g_strdup_printf ("VALA_0_%d", i);
2216 				_tmp8_ = _tmp7_;
2217 				vala_collection_add ((ValaCollection*) _tmp6_, _tmp8_);
2218 				_g_free0 (_tmp8_);
2219 			}
2220 		}
2221 	}
2222 	self->priv->target_glib_major = 2;
2223 	self->priv->target_glib_minor = 48;
2224 	{
2225 		gint i = 0;
2226 		i = 16;
2227 		{
2228 			gboolean _tmp9_ = FALSE;
2229 			_tmp9_ = TRUE;
2230 			while (TRUE) {
2231 				ValaSet* _tmp10_;
2232 				gchar* _tmp11_;
2233 				gchar* _tmp12_;
2234 				if (!_tmp9_) {
2235 					i += 2;
2236 				}
2237 				_tmp9_ = FALSE;
2238 				if (!(i <= self->priv->target_glib_minor)) {
2239 					break;
2240 				}
2241 				_tmp10_ = self->priv->defines;
2242 				_tmp11_ = g_strdup_printf ("GLIB_2_%d", i);
2243 				_tmp12_ = _tmp11_;
2244 				vala_collection_add ((ValaCollection*) _tmp10_, _tmp12_);
2245 				_g_free0 (_tmp12_);
2246 			}
2247 		}
2248 	}
2249 }
2250 
2251 /**
2252  * Set the target version of glib for code generation.
2253  *
2254  * This may be called once or not at all.
2255  *
2256  * @param target_glib a string of the format "%d.%d"
2257  */
2258 void
vala_code_context_set_target_glib_version(ValaCodeContext * self,const gchar * target_glib)2259 vala_code_context_set_target_glib_version (ValaCodeContext* self,
2260                                            const gchar* target_glib)
2261 {
2262 	gint glib_major = 0;
2263 	gint glib_minor = 0;
2264 	gboolean _tmp10_ = FALSE;
2265 	gboolean _tmp11_ = FALSE;
2266 	g_return_if_fail (self != NULL);
2267 	g_return_if_fail (target_glib != NULL);
2268 	glib_major = 0;
2269 	glib_minor = 0;
2270 	if (g_strcmp0 (target_glib, "auto") == 0) {
2271 		gchar* available_glib = NULL;
2272 		gchar* _tmp0_;
2273 		gboolean _tmp1_ = FALSE;
2274 		const gchar* _tmp2_;
2275 		_tmp0_ = vala_code_context_pkg_config_modversion (self, "glib-2.0");
2276 		available_glib = _tmp0_;
2277 		_tmp2_ = available_glib;
2278 		if (_tmp2_ != NULL) {
2279 			const gchar* _tmp3_;
2280 			gint _tmp4_ = 0;
2281 			gint _tmp5_ = 0;
2282 			gint _tmp6_;
2283 			_tmp3_ = available_glib;
2284 			_tmp6_ = sscanf (_tmp3_, "%d.%d", &_tmp4_, &_tmp5_);
2285 			glib_major = _tmp4_;
2286 			glib_minor = _tmp5_;
2287 			_tmp1_ = _tmp6_ >= 2;
2288 		} else {
2289 			_tmp1_ = FALSE;
2290 		}
2291 		if (_tmp1_) {
2292 			gint _tmp7_;
2293 			gchar* _tmp8_;
2294 			gchar* _tmp9_;
2295 			_tmp7_ = glib_minor;
2296 			glib_minor = _tmp7_ + 1;
2297 			glib_minor -= glib_minor % 2;
2298 			_tmp8_ = g_strdup_printf ("%d.%d", glib_major, glib_minor);
2299 			_tmp9_ = _tmp8_;
2300 			vala_code_context_set_target_glib_version (self, _tmp9_);
2301 			_g_free0 (_tmp9_);
2302 		} else {
2303 			vala_report_warning (NULL, "Could not determine the version of `glib-2.0', target version of glib " \
2304 "was not set");
2305 		}
2306 		_g_free0 (available_glib);
2307 		return;
2308 	}
2309 	glib_major = self->priv->target_glib_major;
2310 	glib_minor = self->priv->target_glib_minor;
2311 	if (target_glib != NULL) {
2312 		gint _tmp12_ = 0;
2313 		gint _tmp13_ = 0;
2314 		gint _tmp14_;
2315 		_tmp14_ = sscanf (target_glib, "%d.%d", &_tmp12_, &_tmp13_);
2316 		glib_major = _tmp12_;
2317 		glib_minor = _tmp13_;
2318 		_tmp11_ = _tmp14_ != 2;
2319 	} else {
2320 		_tmp11_ = FALSE;
2321 	}
2322 	if (_tmp11_) {
2323 		_tmp10_ = TRUE;
2324 	} else {
2325 		_tmp10_ = (glib_minor % 2) != 0;
2326 	}
2327 	if (_tmp10_) {
2328 		vala_report_error (NULL, "Only a stable version of GLib can be targeted, use MAJOR.MINOR format " \
2329 "with MINOR as an even number");
2330 	}
2331 	if (glib_major != 2) {
2332 		vala_report_error (NULL, "This version of valac only supports GLib 2");
2333 	}
2334 	if (glib_minor <= self->priv->target_glib_minor) {
2335 		return;
2336 	}
2337 	{
2338 		gint i = 0;
2339 		i = self->priv->target_glib_major + 2;
2340 		{
2341 			gboolean _tmp15_ = FALSE;
2342 			_tmp15_ = TRUE;
2343 			while (TRUE) {
2344 				ValaSet* _tmp16_;
2345 				gchar* _tmp17_;
2346 				gchar* _tmp18_;
2347 				if (!_tmp15_) {
2348 					i += 2;
2349 				}
2350 				_tmp15_ = FALSE;
2351 				if (!(i <= glib_minor)) {
2352 					break;
2353 				}
2354 				_tmp16_ = self->priv->defines;
2355 				_tmp17_ = g_strdup_printf ("GLIB_2_%d", i);
2356 				_tmp18_ = _tmp17_;
2357 				vala_collection_add ((ValaCollection*) _tmp16_, _tmp18_);
2358 				_g_free0 (_tmp18_);
2359 			}
2360 		}
2361 	}
2362 	self->priv->target_glib_major = glib_major;
2363 	self->priv->target_glib_minor = glib_minor;
2364 }
2365 
2366 gchar*
vala_code_context_get_vapi_path(ValaCodeContext * self,const gchar * pkg)2367 vala_code_context_get_vapi_path (ValaCodeContext* self,
2368                                  const gchar* pkg)
2369 {
2370 	gchar* path = NULL;
2371 	gchar* _tmp0_;
2372 	gchar* _tmp1_;
2373 	gchar** _tmp2_;
2374 	gint _tmp2__length1;
2375 	gint _tmp3_ = 0;
2376 	gchar** _tmp4_;
2377 	gint _tmp4__length1;
2378 	gchar* _tmp5_;
2379 	gchar* _tmp6_;
2380 	const gchar* _tmp7_;
2381 	gchar* result = NULL;
2382 	g_return_val_if_fail (self != NULL, NULL);
2383 	g_return_val_if_fail (pkg != NULL, NULL);
2384 	_tmp0_ = g_strconcat (pkg, ".vapi", NULL);
2385 	_tmp1_ = _tmp0_;
2386 	_tmp2_ = vala_code_context_get_vapi_directories (self, &_tmp3_);
2387 	_tmp2__length1 = _tmp3_;
2388 	_tmp4_ = _tmp2_;
2389 	_tmp4__length1 = _tmp2__length1;
2390 	_tmp5_ = vala_code_context_get_file_path (self, _tmp1_, "vala" PACKAGE_SUFFIX "/vapi", "vala/vapi", _tmp4_, (gint) _tmp4__length1);
2391 	_tmp6_ = _tmp5_;
2392 	_g_free0 (_tmp1_);
2393 	path = _tmp6_;
2394 	_tmp7_ = path;
2395 	if (_tmp7_ == NULL) {
2396 		gchar* filename = NULL;
2397 		gchar* _tmp8_;
2398 		gchar* _tmp9_;
2399 		gchar* _tmp10_;
2400 		gchar* _tmp11_;
2401 		const gchar* _tmp12_;
2402 		_tmp8_ = g_strconcat (pkg, ".vapi", NULL);
2403 		_tmp9_ = _tmp8_;
2404 		_tmp10_ = g_build_path ("/", PACKAGE_DATADIR, "vapi", _tmp9_, NULL);
2405 		_tmp11_ = _tmp10_;
2406 		_g_free0 (_tmp9_);
2407 		filename = _tmp11_;
2408 		_tmp12_ = filename;
2409 		if (g_file_test (_tmp12_, G_FILE_TEST_EXISTS)) {
2410 			const gchar* _tmp13_;
2411 			gchar* _tmp14_;
2412 			_tmp13_ = filename;
2413 			_tmp14_ = g_strdup (_tmp13_);
2414 			_g_free0 (path);
2415 			path = _tmp14_;
2416 		}
2417 		_g_free0 (filename);
2418 	}
2419 	result = path;
2420 	return result;
2421 }
2422 
2423 gchar*
vala_code_context_get_gir_path(ValaCodeContext * self,const gchar * gir)2424 vala_code_context_get_gir_path (ValaCodeContext* self,
2425                                 const gchar* gir)
2426 {
2427 	gchar* _tmp0_;
2428 	gchar* _tmp1_;
2429 	gchar** _tmp2_;
2430 	gint _tmp2__length1;
2431 	gint _tmp3_ = 0;
2432 	gchar** _tmp4_;
2433 	gint _tmp4__length1;
2434 	gchar* _tmp5_;
2435 	gchar* _tmp6_;
2436 	gchar* result = NULL;
2437 	g_return_val_if_fail (self != NULL, NULL);
2438 	g_return_val_if_fail (gir != NULL, NULL);
2439 	_tmp0_ = g_strconcat (gir, ".gir", NULL);
2440 	_tmp1_ = _tmp0_;
2441 	_tmp2_ = vala_code_context_get_gir_directories (self, &_tmp3_);
2442 	_tmp2__length1 = _tmp3_;
2443 	_tmp4_ = _tmp2_;
2444 	_tmp4__length1 = _tmp2__length1;
2445 	_tmp5_ = vala_code_context_get_file_path (self, _tmp1_, "gir-1.0", NULL, _tmp4_, (gint) _tmp4__length1);
2446 	_tmp6_ = _tmp5_;
2447 	_g_free0 (_tmp1_);
2448 	result = _tmp6_;
2449 	return result;
2450 }
2451 
2452 gchar*
vala_code_context_get_gresource_path(ValaCodeContext * self,const gchar * gresource,const gchar * resource)2453 vala_code_context_get_gresource_path (ValaCodeContext* self,
2454                                       const gchar* gresource,
2455                                       const gchar* resource)
2456 {
2457 	gchar* filename = NULL;
2458 	gchar* _tmp0_;
2459 	gchar** _tmp1_;
2460 	gchar** _tmp2_;
2461 	gint _tmp2__length1;
2462 	gchar* _tmp3_;
2463 	gchar* _tmp4_;
2464 	const gchar* _tmp5_;
2465 	gchar* result = NULL;
2466 	g_return_val_if_fail (self != NULL, NULL);
2467 	g_return_val_if_fail (gresource != NULL, NULL);
2468 	g_return_val_if_fail (resource != NULL, NULL);
2469 	_tmp0_ = g_path_get_dirname (gresource);
2470 	_tmp1_ = g_new0 (gchar*, 1 + 1);
2471 	_tmp1_[0] = _tmp0_;
2472 	_tmp2_ = _tmp1_;
2473 	_tmp2__length1 = 1;
2474 	_tmp3_ = vala_code_context_get_file_path (self, resource, NULL, NULL, _tmp2_, (gint) 1);
2475 	_tmp4_ = _tmp3_;
2476 	_tmp2_ = (_vala_array_free (_tmp2_, _tmp2__length1, (GDestroyNotify) g_free), NULL);
2477 	filename = _tmp4_;
2478 	_tmp5_ = filename;
2479 	if (_tmp5_ == NULL) {
2480 		gchar** _tmp6_;
2481 		gint _tmp6__length1;
2482 		gint _tmp7_ = 0;
2483 		gchar** _tmp8_;
2484 		gint _tmp8__length1;
2485 		gchar* _tmp9_;
2486 		_tmp6_ = vala_code_context_get_gresources_directories (self, &_tmp7_);
2487 		_tmp6__length1 = _tmp7_;
2488 		_tmp8_ = _tmp6_;
2489 		_tmp8__length1 = _tmp6__length1;
2490 		_tmp9_ = vala_code_context_get_file_path (self, resource, NULL, NULL, _tmp8_, (gint) _tmp8__length1);
2491 		_g_free0 (filename);
2492 		filename = _tmp9_;
2493 	}
2494 	result = filename;
2495 	return result;
2496 }
2497 
2498 static glong
string_strnlen(gchar * str,glong maxlen)2499 string_strnlen (gchar* str,
2500                 glong maxlen)
2501 {
2502 	gchar* end = NULL;
2503 	gchar* _tmp0_;
2504 	gchar* _tmp1_;
2505 	glong result = 0L;
2506 	_tmp0_ = memchr (str, 0, (gsize) maxlen);
2507 	end = _tmp0_;
2508 	_tmp1_ = end;
2509 	if (_tmp1_ == NULL) {
2510 		result = maxlen;
2511 		return result;
2512 	} else {
2513 		gchar* _tmp2_;
2514 		_tmp2_ = end;
2515 		result = (glong) (_tmp2_ - str);
2516 		return result;
2517 	}
2518 }
2519 
2520 static gchar*
string_substring(const gchar * self,glong offset,glong len)2521 string_substring (const gchar* self,
2522                   glong offset,
2523                   glong len)
2524 {
2525 	glong string_length = 0L;
2526 	gboolean _tmp0_ = FALSE;
2527 	gchar* _tmp3_;
2528 	gchar* result = NULL;
2529 	g_return_val_if_fail (self != NULL, NULL);
2530 	if (offset >= ((glong) 0)) {
2531 		_tmp0_ = len >= ((glong) 0);
2532 	} else {
2533 		_tmp0_ = FALSE;
2534 	}
2535 	if (_tmp0_) {
2536 		string_length = string_strnlen ((gchar*) self, offset + len);
2537 	} else {
2538 		gint _tmp1_;
2539 		gint _tmp2_;
2540 		_tmp1_ = strlen (self);
2541 		_tmp2_ = _tmp1_;
2542 		string_length = (glong) _tmp2_;
2543 	}
2544 	if (offset < ((glong) 0)) {
2545 		offset = string_length + offset;
2546 		g_return_val_if_fail (offset >= ((glong) 0), NULL);
2547 	} else {
2548 		g_return_val_if_fail (offset <= string_length, NULL);
2549 	}
2550 	if (len < ((glong) 0)) {
2551 		len = string_length - offset;
2552 	}
2553 	g_return_val_if_fail ((offset + len) <= string_length, NULL);
2554 	_tmp3_ = g_strndup (((gchar*) self) + offset, (gsize) len);
2555 	result = _tmp3_;
2556 	return result;
2557 }
2558 
2559 gchar*
vala_code_context_get_metadata_path(ValaCodeContext * self,const gchar * gir_filename)2560 vala_code_context_get_metadata_path (ValaCodeContext* self,
2561                                      const gchar* gir_filename)
2562 {
2563 	gchar* basename = NULL;
2564 	gchar* _tmp0_;
2565 	gchar* metadata_basename = NULL;
2566 	const gchar* _tmp1_;
2567 	const gchar* _tmp2_;
2568 	gint _tmp3_;
2569 	gint _tmp4_;
2570 	gint _tmp5_;
2571 	gint _tmp6_;
2572 	gchar* _tmp7_;
2573 	gchar* _tmp8_;
2574 	gchar* _tmp9_;
2575 	gchar* _tmp10_;
2576 	gchar* metadata_filename = NULL;
2577 	const gchar* _tmp11_;
2578 	gchar** _tmp12_;
2579 	gint _tmp12__length1;
2580 	gint _tmp13_ = 0;
2581 	gchar** _tmp14_;
2582 	gint _tmp14__length1;
2583 	gchar* _tmp15_;
2584 	const gchar* _tmp16_;
2585 	gchar* _tmp17_;
2586 	gchar* _tmp18_;
2587 	const gchar* _tmp19_;
2588 	gchar* _tmp20_;
2589 	const gchar* _tmp21_;
2590 	gchar* result = NULL;
2591 	g_return_val_if_fail (self != NULL, NULL);
2592 	g_return_val_if_fail (gir_filename != NULL, NULL);
2593 	_tmp0_ = g_path_get_basename (gir_filename);
2594 	basename = _tmp0_;
2595 	_tmp1_ = basename;
2596 	_tmp2_ = basename;
2597 	_tmp3_ = strlen (_tmp2_);
2598 	_tmp4_ = _tmp3_;
2599 	_tmp5_ = strlen (".gir");
2600 	_tmp6_ = _tmp5_;
2601 	_tmp7_ = string_substring (_tmp1_, (glong) 0, (glong) (_tmp4_ - _tmp6_));
2602 	_tmp8_ = _tmp7_;
2603 	_tmp9_ = g_strdup_printf ("%s.metadata", _tmp8_);
2604 	_tmp10_ = _tmp9_;
2605 	_g_free0 (_tmp8_);
2606 	metadata_basename = _tmp10_;
2607 	_tmp11_ = metadata_basename;
2608 	_tmp12_ = vala_code_context_get_metadata_directories (self, &_tmp13_);
2609 	_tmp12__length1 = _tmp13_;
2610 	_tmp14_ = _tmp12_;
2611 	_tmp14__length1 = _tmp12__length1;
2612 	_tmp15_ = vala_code_context_get_file_path (self, _tmp11_, NULL, NULL, _tmp14_, (gint) _tmp14__length1);
2613 	metadata_filename = _tmp15_;
2614 	_tmp16_ = metadata_filename;
2615 	if (_tmp16_ != NULL) {
2616 		result = metadata_filename;
2617 		_g_free0 (metadata_basename);
2618 		_g_free0 (basename);
2619 		return result;
2620 	}
2621 	_tmp17_ = g_path_get_dirname (gir_filename);
2622 	_tmp18_ = _tmp17_;
2623 	_tmp19_ = metadata_basename;
2624 	_tmp20_ = g_build_path ("/", _tmp18_, _tmp19_, NULL);
2625 	_g_free0 (metadata_filename);
2626 	metadata_filename = _tmp20_;
2627 	_g_free0 (_tmp18_);
2628 	_tmp21_ = metadata_filename;
2629 	if (g_file_test (_tmp21_, G_FILE_TEST_EXISTS)) {
2630 		result = metadata_filename;
2631 		_g_free0 (metadata_basename);
2632 		_g_free0 (basename);
2633 		return result;
2634 	}
2635 	result = NULL;
2636 	_g_free0 (metadata_filename);
2637 	_g_free0 (metadata_basename);
2638 	_g_free0 (basename);
2639 	return result;
2640 }
2641 
2642 static gchar*
vala_code_context_get_file_path(ValaCodeContext * self,const gchar * basename,const gchar * versioned_data_dir,const gchar * data_dir,gchar ** directories,gint directories_length1)2643 vala_code_context_get_file_path (ValaCodeContext* self,
2644                                  const gchar* basename,
2645                                  const gchar* versioned_data_dir,
2646                                  const gchar* data_dir,
2647                                  gchar** directories,
2648                                  gint directories_length1)
2649 {
2650 	gchar* filename = NULL;
2651 	gchar* result = NULL;
2652 	g_return_val_if_fail (self != NULL, NULL);
2653 	g_return_val_if_fail (basename != NULL, NULL);
2654 	filename = NULL;
2655 	if (directories != NULL) {
2656 		{
2657 			gchar** dir_collection = NULL;
2658 			gint dir_collection_length1 = 0;
2659 			gint _dir_collection_size_ = 0;
2660 			gint dir_it = 0;
2661 			dir_collection = directories;
2662 			dir_collection_length1 = directories_length1;
2663 			for (dir_it = 0; dir_it < dir_collection_length1; dir_it = dir_it + 1) {
2664 				const gchar* dir = NULL;
2665 				dir = dir_collection[dir_it];
2666 				{
2667 					const gchar* _tmp0_;
2668 					gchar* _tmp1_;
2669 					const gchar* _tmp2_;
2670 					_tmp0_ = dir;
2671 					_tmp1_ = g_build_path ("/", _tmp0_, basename, NULL);
2672 					_g_free0 (filename);
2673 					filename = _tmp1_;
2674 					_tmp2_ = filename;
2675 					if (g_file_test (_tmp2_, G_FILE_TEST_EXISTS)) {
2676 						result = filename;
2677 						return result;
2678 					}
2679 				}
2680 			}
2681 		}
2682 	}
2683 	if (data_dir != NULL) {
2684 		gchar** _tmp3_;
2685 		gchar** _tmp4_;
2686 		_tmp4_ = _tmp3_ = g_get_system_data_dirs ();
2687 		{
2688 			gchar** dir_collection = NULL;
2689 			gint dir_collection_length1 = 0;
2690 			gint _dir_collection_size_ = 0;
2691 			gint dir_it = 0;
2692 			dir_collection = _tmp4_;
2693 			dir_collection_length1 = _vala_array_length (_tmp3_);
2694 			for (dir_it = 0; dir_it < dir_collection_length1; dir_it = dir_it + 1) {
2695 				const gchar* dir = NULL;
2696 				dir = dir_collection[dir_it];
2697 				{
2698 					const gchar* _tmp5_;
2699 					gchar* _tmp6_;
2700 					const gchar* _tmp7_;
2701 					_tmp5_ = dir;
2702 					_tmp6_ = g_build_path ("/", _tmp5_, data_dir, basename, NULL);
2703 					_g_free0 (filename);
2704 					filename = _tmp6_;
2705 					_tmp7_ = filename;
2706 					if (g_file_test (_tmp7_, G_FILE_TEST_EXISTS)) {
2707 						result = filename;
2708 						return result;
2709 					}
2710 				}
2711 			}
2712 		}
2713 	}
2714 	if (versioned_data_dir != NULL) {
2715 		gchar** _tmp8_;
2716 		gchar** _tmp9_;
2717 		_tmp9_ = _tmp8_ = g_get_system_data_dirs ();
2718 		{
2719 			gchar** dir_collection = NULL;
2720 			gint dir_collection_length1 = 0;
2721 			gint _dir_collection_size_ = 0;
2722 			gint dir_it = 0;
2723 			dir_collection = _tmp9_;
2724 			dir_collection_length1 = _vala_array_length (_tmp8_);
2725 			for (dir_it = 0; dir_it < dir_collection_length1; dir_it = dir_it + 1) {
2726 				const gchar* dir = NULL;
2727 				dir = dir_collection[dir_it];
2728 				{
2729 					const gchar* _tmp10_;
2730 					gchar* _tmp11_;
2731 					const gchar* _tmp12_;
2732 					_tmp10_ = dir;
2733 					_tmp11_ = g_build_path ("/", _tmp10_, versioned_data_dir, basename, NULL);
2734 					_g_free0 (filename);
2735 					filename = _tmp11_;
2736 					_tmp12_ = filename;
2737 					if (g_file_test (_tmp12_, G_FILE_TEST_EXISTS)) {
2738 						result = filename;
2739 						return result;
2740 					}
2741 				}
2742 			}
2743 		}
2744 	}
2745 	result = NULL;
2746 	_g_free0 (filename);
2747 	return result;
2748 }
2749 
2750 static gpointer
_vala_iterable_ref0(gpointer self)2751 _vala_iterable_ref0 (gpointer self)
2752 {
2753 	return self ? vala_iterable_ref (self) : NULL;
2754 }
2755 
2756 void
vala_code_context_write_dependencies(ValaCodeContext * self,const gchar * filename)2757 vala_code_context_write_dependencies (ValaCodeContext* self,
2758                                       const gchar* filename)
2759 {
2760 	FILE* stream = NULL;
2761 	FILE* _tmp0_;
2762 	FILE* _tmp1_;
2763 	FILE* _tmp4_;
2764 	FILE* _tmp25_;
2765 	g_return_if_fail (self != NULL);
2766 	g_return_if_fail (filename != NULL);
2767 	_tmp0_ = g_fopen (filename, "w");
2768 	stream = _tmp0_;
2769 	_tmp1_ = stream;
2770 	if (_tmp1_ == NULL) {
2771 		gchar* _tmp2_;
2772 		gchar* _tmp3_;
2773 		_tmp2_ = g_strdup_printf ("unable to open `%s' for writing", filename);
2774 		_tmp3_ = _tmp2_;
2775 		vala_report_error (NULL, _tmp3_);
2776 		_g_free0 (_tmp3_);
2777 		_fclose0 (stream);
2778 		return;
2779 	}
2780 	_tmp4_ = stream;
2781 	fprintf (_tmp4_, "%s:", filename);
2782 	{
2783 		ValaList* _src_list = NULL;
2784 		ValaList* _tmp5_;
2785 		ValaList* _tmp6_;
2786 		gint _src_size = 0;
2787 		ValaList* _tmp7_;
2788 		gint _tmp8_;
2789 		gint _tmp9_;
2790 		gint _src_index = 0;
2791 		_tmp5_ = self->priv->source_files;
2792 		_tmp6_ = _vala_iterable_ref0 (_tmp5_);
2793 		_src_list = _tmp6_;
2794 		_tmp7_ = _src_list;
2795 		_tmp8_ = vala_collection_get_size ((ValaCollection*) _tmp7_);
2796 		_tmp9_ = _tmp8_;
2797 		_src_size = _tmp9_;
2798 		_src_index = -1;
2799 		while (TRUE) {
2800 			gint _tmp10_;
2801 			gint _tmp11_;
2802 			ValaSourceFile* src = NULL;
2803 			ValaList* _tmp12_;
2804 			gpointer _tmp13_;
2805 			gboolean _tmp14_ = FALSE;
2806 			ValaSourceFile* _tmp15_;
2807 			ValaSourceFileType _tmp16_;
2808 			ValaSourceFileType _tmp17_;
2809 			_src_index = _src_index + 1;
2810 			_tmp10_ = _src_index;
2811 			_tmp11_ = _src_size;
2812 			if (!(_tmp10_ < _tmp11_)) {
2813 				break;
2814 			}
2815 			_tmp12_ = _src_list;
2816 			_tmp13_ = vala_list_get (_tmp12_, _src_index);
2817 			src = (ValaSourceFile*) _tmp13_;
2818 			_tmp15_ = src;
2819 			_tmp16_ = vala_source_file_get_file_type (_tmp15_);
2820 			_tmp17_ = _tmp16_;
2821 			if (_tmp17_ == VALA_SOURCE_FILE_TYPE_FAST) {
2822 				ValaSourceFile* _tmp18_;
2823 				gboolean _tmp19_;
2824 				gboolean _tmp20_;
2825 				_tmp18_ = src;
2826 				_tmp19_ = vala_source_file_get_used (_tmp18_);
2827 				_tmp20_ = _tmp19_;
2828 				_tmp14_ = _tmp20_;
2829 			} else {
2830 				_tmp14_ = FALSE;
2831 			}
2832 			if (_tmp14_) {
2833 				FILE* _tmp21_;
2834 				ValaSourceFile* _tmp22_;
2835 				const gchar* _tmp23_;
2836 				const gchar* _tmp24_;
2837 				_tmp21_ = stream;
2838 				_tmp22_ = src;
2839 				_tmp23_ = vala_source_file_get_filename (_tmp22_);
2840 				_tmp24_ = _tmp23_;
2841 				fprintf (_tmp21_, " %s", _tmp24_);
2842 			}
2843 			_vala_source_file_unref0 (src);
2844 		}
2845 		_vala_iterable_unref0 (_src_list);
2846 	}
2847 	_tmp25_ = stream;
2848 	fprintf (_tmp25_, "\n\n");
2849 	_fclose0 (stream);
2850 }
2851 
2852 void
vala_code_context_write_external_dependencies(ValaCodeContext * self,const gchar * filename)2853 vala_code_context_write_external_dependencies (ValaCodeContext* self,
2854                                                const gchar* filename)
2855 {
2856 	FILE* stream = NULL;
2857 	FILE* _tmp0_;
2858 	FILE* _tmp1_;
2859 	gboolean first = FALSE;
2860 	FILE* _tmp26_;
2861 	g_return_if_fail (self != NULL);
2862 	g_return_if_fail (filename != NULL);
2863 	_tmp0_ = g_fopen (filename, "w");
2864 	stream = _tmp0_;
2865 	_tmp1_ = stream;
2866 	if (_tmp1_ == NULL) {
2867 		gchar* _tmp2_;
2868 		gchar* _tmp3_;
2869 		_tmp2_ = g_strdup_printf ("unable to open `%s' for writing", filename);
2870 		_tmp3_ = _tmp2_;
2871 		vala_report_error (NULL, _tmp3_);
2872 		_g_free0 (_tmp3_);
2873 		_fclose0 (stream);
2874 		return;
2875 	}
2876 	first = TRUE;
2877 	{
2878 		ValaList* _src_list = NULL;
2879 		ValaList* _tmp4_;
2880 		ValaList* _tmp5_;
2881 		gint _src_size = 0;
2882 		ValaList* _tmp6_;
2883 		gint _tmp7_;
2884 		gint _tmp8_;
2885 		gint _src_index = 0;
2886 		_tmp4_ = self->priv->source_files;
2887 		_tmp5_ = _vala_iterable_ref0 (_tmp4_);
2888 		_src_list = _tmp5_;
2889 		_tmp6_ = _src_list;
2890 		_tmp7_ = vala_collection_get_size ((ValaCollection*) _tmp6_);
2891 		_tmp8_ = _tmp7_;
2892 		_src_size = _tmp8_;
2893 		_src_index = -1;
2894 		while (TRUE) {
2895 			gint _tmp9_;
2896 			gint _tmp10_;
2897 			ValaSourceFile* src = NULL;
2898 			ValaList* _tmp11_;
2899 			gpointer _tmp12_;
2900 			gboolean _tmp13_ = FALSE;
2901 			ValaSourceFile* _tmp14_;
2902 			ValaSourceFileType _tmp15_;
2903 			ValaSourceFileType _tmp16_;
2904 			_src_index = _src_index + 1;
2905 			_tmp9_ = _src_index;
2906 			_tmp10_ = _src_size;
2907 			if (!(_tmp9_ < _tmp10_)) {
2908 				break;
2909 			}
2910 			_tmp11_ = _src_list;
2911 			_tmp12_ = vala_list_get (_tmp11_, _src_index);
2912 			src = (ValaSourceFile*) _tmp12_;
2913 			_tmp14_ = src;
2914 			_tmp15_ = vala_source_file_get_file_type (_tmp14_);
2915 			_tmp16_ = _tmp15_;
2916 			if (_tmp16_ != VALA_SOURCE_FILE_TYPE_SOURCE) {
2917 				ValaSourceFile* _tmp17_;
2918 				gboolean _tmp18_;
2919 				gboolean _tmp19_;
2920 				_tmp17_ = src;
2921 				_tmp18_ = vala_source_file_get_used (_tmp17_);
2922 				_tmp19_ = _tmp18_;
2923 				_tmp13_ = _tmp19_;
2924 			} else {
2925 				_tmp13_ = FALSE;
2926 			}
2927 			if (_tmp13_) {
2928 				FILE* _tmp22_;
2929 				ValaSourceFile* _tmp23_;
2930 				const gchar* _tmp24_;
2931 				const gchar* _tmp25_;
2932 				if (first) {
2933 					FILE* _tmp20_;
2934 					first = FALSE;
2935 					_tmp20_ = stream;
2936 					fprintf (_tmp20_, "%s: ", filename);
2937 				} else {
2938 					FILE* _tmp21_;
2939 					_tmp21_ = stream;
2940 					fputs (" \\\n\t", _tmp21_);
2941 				}
2942 				_tmp22_ = stream;
2943 				_tmp23_ = src;
2944 				_tmp24_ = vala_source_file_get_filename (_tmp23_);
2945 				_tmp25_ = _tmp24_;
2946 				fprintf (_tmp22_, "%s", _tmp25_);
2947 			}
2948 			_vala_source_file_unref0 (src);
2949 		}
2950 		_vala_iterable_unref0 (_src_list);
2951 	}
2952 	_tmp26_ = stream;
2953 	fputs ("\n\n", _tmp26_);
2954 	_fclose0 (stream);
2955 }
2956 
2957 static gunichar
string_get_char(const gchar * self,glong index)2958 string_get_char (const gchar* self,
2959                  glong index)
2960 {
2961 	gunichar result = 0U;
2962 	g_return_val_if_fail (self != NULL, 0U);
2963 	result = g_utf8_get_char (((gchar*) self) + index);
2964 	return result;
2965 }
2966 
2967 static gboolean
vala_code_context_ends_with_dir_separator(const gchar * s)2968 vala_code_context_ends_with_dir_separator (const gchar* s)
2969 {
2970 	gint _tmp0_;
2971 	gint _tmp1_;
2972 	gboolean result = FALSE;
2973 	g_return_val_if_fail (s != NULL, FALSE);
2974 	_tmp0_ = strlen (s);
2975 	_tmp1_ = _tmp0_;
2976 	result = G_IS_DIR_SEPARATOR (string_get_char (s, (glong) (_tmp1_ - 1)));
2977 	return result;
2978 }
2979 
2980 /**
2981  * Returns canonicalized absolute pathname
2982  * ported from glibc
2983  *
2984  * @param name the path being checked
2985  * @return a canonicalized absolute pathname
2986  */
2987 static gchar*
_vala_g_strjoinv(const gchar * separator,gchar ** str_array,gint str_array_length1)2988 _vala_g_strjoinv (const gchar* separator,
2989                   gchar** str_array,
2990                   gint str_array_length1)
2991 {
2992 	gboolean _tmp0_ = FALSE;
2993 	gchar* result = NULL;
2994 	if (separator == NULL) {
2995 		separator = "";
2996 	}
2997 	if (str_array != NULL) {
2998 		gboolean _tmp1_ = FALSE;
2999 		if (str_array_length1 > 0) {
3000 			_tmp1_ = TRUE;
3001 		} else {
3002 			gboolean _tmp2_ = FALSE;
3003 			if (str_array_length1 == -1) {
3004 				const gchar* _tmp3_;
3005 				_tmp3_ = str_array[0];
3006 				_tmp2_ = _tmp3_ != NULL;
3007 			} else {
3008 				_tmp2_ = FALSE;
3009 			}
3010 			_tmp1_ = _tmp2_;
3011 		}
3012 		_tmp0_ = _tmp1_;
3013 	} else {
3014 		_tmp0_ = FALSE;
3015 	}
3016 	if (_tmp0_) {
3017 		gint i = 0;
3018 		gsize len = 0UL;
3019 		gint _tmp16_;
3020 		gint _tmp17_;
3021 		const gchar* res = NULL;
3022 		void* _tmp18_;
3023 		void* ptr = NULL;
3024 		const gchar* _tmp19_;
3025 		const gchar* _tmp20_;
3026 		void* _tmp21_;
3027 		const gchar* _tmp31_;
3028 		len = (gsize) 1;
3029 		{
3030 			gboolean _tmp4_ = FALSE;
3031 			i = 0;
3032 			_tmp4_ = TRUE;
3033 			while (TRUE) {
3034 				gboolean _tmp6_ = FALSE;
3035 				gboolean _tmp7_ = FALSE;
3036 				gint _tmp10_ = 0;
3037 				const gchar* _tmp11_;
3038 				if (!_tmp4_) {
3039 					gint _tmp5_;
3040 					_tmp5_ = i;
3041 					i = _tmp5_ + 1;
3042 				}
3043 				_tmp4_ = FALSE;
3044 				if (str_array_length1 != -1) {
3045 					_tmp7_ = i < str_array_length1;
3046 				} else {
3047 					_tmp7_ = FALSE;
3048 				}
3049 				if (_tmp7_) {
3050 					_tmp6_ = TRUE;
3051 				} else {
3052 					gboolean _tmp8_ = FALSE;
3053 					if (str_array_length1 == -1) {
3054 						const gchar* _tmp9_;
3055 						_tmp9_ = str_array[i];
3056 						_tmp8_ = _tmp9_ != NULL;
3057 					} else {
3058 						_tmp8_ = FALSE;
3059 					}
3060 					_tmp6_ = _tmp8_;
3061 				}
3062 				if (!_tmp6_) {
3063 					break;
3064 				}
3065 				_tmp11_ = str_array[i];
3066 				if (_tmp11_ != NULL) {
3067 					const gchar* _tmp12_;
3068 					gint _tmp13_;
3069 					gint _tmp14_;
3070 					_tmp12_ = str_array[i];
3071 					_tmp13_ = strlen ((const gchar*) _tmp12_);
3072 					_tmp14_ = _tmp13_;
3073 					_tmp10_ = _tmp14_;
3074 				} else {
3075 					_tmp10_ = 0;
3076 				}
3077 				len += (gsize) _tmp10_;
3078 			}
3079 		}
3080 		if (i == 0) {
3081 			gchar* _tmp15_;
3082 			_tmp15_ = g_strdup ("");
3083 			result = _tmp15_;
3084 			return result;
3085 		}
3086 		str_array_length1 = i;
3087 		_tmp16_ = strlen ((const gchar*) separator);
3088 		_tmp17_ = _tmp16_;
3089 		len += (gsize) (_tmp17_ * (i - 1));
3090 		_tmp18_ = g_malloc (len);
3091 		res = _tmp18_;
3092 		_tmp19_ = res;
3093 		_tmp20_ = str_array[0];
3094 		_tmp21_ = g_stpcpy ((void*) _tmp19_, (const gchar*) _tmp20_);
3095 		ptr = _tmp21_;
3096 		{
3097 			gboolean _tmp22_ = FALSE;
3098 			i = 1;
3099 			_tmp22_ = TRUE;
3100 			while (TRUE) {
3101 				void* _tmp24_;
3102 				void* _tmp25_;
3103 				const gchar* _tmp26_ = NULL;
3104 				const gchar* _tmp27_;
3105 				void* _tmp29_;
3106 				void* _tmp30_;
3107 				if (!_tmp22_) {
3108 					gint _tmp23_;
3109 					_tmp23_ = i;
3110 					i = _tmp23_ + 1;
3111 				}
3112 				_tmp22_ = FALSE;
3113 				if (!(i < str_array_length1)) {
3114 					break;
3115 				}
3116 				_tmp24_ = ptr;
3117 				_tmp25_ = g_stpcpy (_tmp24_, (const gchar*) separator);
3118 				ptr = _tmp25_;
3119 				_tmp27_ = str_array[i];
3120 				if (_tmp27_ != NULL) {
3121 					const gchar* _tmp28_;
3122 					_tmp28_ = str_array[i];
3123 					_tmp26_ = (const gchar*) _tmp28_;
3124 				} else {
3125 					_tmp26_ = "";
3126 				}
3127 				_tmp29_ = ptr;
3128 				_tmp30_ = g_stpcpy (_tmp29_, _tmp26_);
3129 				ptr = _tmp30_;
3130 			}
3131 		}
3132 		_tmp31_ = res;
3133 		res = NULL;
3134 		result = (gchar*) _tmp31_;
3135 		return result;
3136 	} else {
3137 		gchar* _tmp32_;
3138 		_tmp32_ = g_strdup ("");
3139 		result = _tmp32_;
3140 		return result;
3141 	}
3142 }
3143 
3144 gchar*
vala_code_context_realpath(const gchar * name)3145 vala_code_context_realpath (const gchar* name)
3146 {
3147 	gchar* rpath = NULL;
3148 	const gchar* start = NULL;
3149 	const gchar* end = NULL;
3150 	glong root_len = 0L;
3151 	const gchar* _tmp6_;
3152 	const gchar* _tmp7_;
3153 	const gchar* _tmp8_;
3154 	gboolean _tmp47_ = FALSE;
3155 	const gchar* _tmp48_;
3156 	gint _tmp49_;
3157 	gint _tmp50_;
3158 	gchar* result = NULL;
3159 	g_return_val_if_fail (name != NULL, NULL);
3160 	if (!g_path_is_absolute (name)) {
3161 		gchar* _tmp0_;
3162 		const gchar* _tmp1_;
3163 		_tmp0_ = g_get_current_dir ();
3164 		_g_free0 (rpath);
3165 		rpath = _tmp0_;
3166 		end = name;
3167 		_tmp1_ = end;
3168 		start = _tmp1_;
3169 	} else {
3170 		const gchar* _tmp2_;
3171 		const gchar* _tmp3_;
3172 		const gchar* _tmp4_;
3173 		gchar* _tmp5_;
3174 		_tmp2_ = g_path_skip_root (name);
3175 		end = _tmp2_;
3176 		_tmp3_ = end;
3177 		start = _tmp3_;
3178 		_tmp4_ = start;
3179 		_tmp5_ = string_substring (name, (glong) 0, (glong) ((gint) (((gchar*) _tmp4_) - ((gchar*) name))));
3180 		_g_free0 (rpath);
3181 		rpath = _tmp5_;
3182 	}
3183 	_tmp6_ = rpath;
3184 	_tmp7_ = g_path_skip_root (_tmp6_);
3185 	_tmp8_ = rpath;
3186 	root_len = (glong) (((gchar*) _tmp7_) - ((gchar*) _tmp8_));
3187 	{
3188 		gboolean _tmp9_ = FALSE;
3189 		_tmp9_ = TRUE;
3190 		while (TRUE) {
3191 			const gchar* _tmp11_;
3192 			glong len = 0L;
3193 			if (!_tmp9_) {
3194 				const gchar* _tmp10_;
3195 				_tmp10_ = end;
3196 				start = _tmp10_;
3197 			}
3198 			_tmp9_ = FALSE;
3199 			_tmp11_ = start;
3200 			if (!(string_get_char (_tmp11_, (glong) 0) != ((gunichar) 0))) {
3201 				break;
3202 			}
3203 			while (TRUE) {
3204 				const gchar* _tmp12_;
3205 				const gchar* _tmp13_;
3206 				const gchar* _tmp14_;
3207 				_tmp12_ = start;
3208 				if (!G_IS_DIR_SEPARATOR (string_get_char (_tmp12_, (glong) 0))) {
3209 					break;
3210 				}
3211 				_tmp13_ = start;
3212 				_tmp14_ = g_utf8_next_char (_tmp13_);
3213 				start = _tmp14_;
3214 			}
3215 			len = (glong) 0;
3216 			{
3217 				const gchar* _tmp15_;
3218 				gboolean _tmp16_ = FALSE;
3219 				_tmp15_ = start;
3220 				end = _tmp15_;
3221 				_tmp16_ = TRUE;
3222 				while (TRUE) {
3223 					gboolean _tmp19_ = FALSE;
3224 					const gchar* _tmp20_;
3225 					glong _tmp22_;
3226 					if (!_tmp16_) {
3227 						const gchar* _tmp17_;
3228 						const gchar* _tmp18_;
3229 						_tmp17_ = end;
3230 						_tmp18_ = g_utf8_next_char (_tmp17_);
3231 						end = _tmp18_;
3232 					}
3233 					_tmp16_ = FALSE;
3234 					_tmp20_ = end;
3235 					if (string_get_char (_tmp20_, (glong) 0) != ((gunichar) 0)) {
3236 						const gchar* _tmp21_;
3237 						_tmp21_ = end;
3238 						_tmp19_ = !G_IS_DIR_SEPARATOR (string_get_char (_tmp21_, (glong) 0));
3239 					} else {
3240 						_tmp19_ = FALSE;
3241 					}
3242 					if (!_tmp19_) {
3243 						break;
3244 					}
3245 					_tmp22_ = len;
3246 					len = _tmp22_ + 1;
3247 				}
3248 			}
3249 			if (len == ((glong) 0)) {
3250 				break;
3251 			} else {
3252 				gboolean _tmp23_ = FALSE;
3253 				if (len == ((glong) 1)) {
3254 					const gchar* _tmp24_;
3255 					_tmp24_ = start;
3256 					_tmp23_ = string_get_char (_tmp24_, (glong) 0) == ((gunichar) '.');
3257 				} else {
3258 					_tmp23_ = FALSE;
3259 				}
3260 				if (_tmp23_) {
3261 				} else {
3262 					gboolean _tmp25_ = FALSE;
3263 					if (len == ((glong) 2)) {
3264 						const gchar* _tmp26_;
3265 						_tmp26_ = start;
3266 						_tmp25_ = g_str_has_prefix (_tmp26_, "..");
3267 					} else {
3268 						_tmp25_ = FALSE;
3269 					}
3270 					if (_tmp25_) {
3271 						const gchar* _tmp27_;
3272 						gint _tmp28_;
3273 						gint _tmp29_;
3274 						_tmp27_ = rpath;
3275 						_tmp28_ = strlen (_tmp27_);
3276 						_tmp29_ = _tmp28_;
3277 						if (((glong) _tmp29_) > root_len) {
3278 							{
3279 								gboolean _tmp30_ = FALSE;
3280 								_tmp30_ = TRUE;
3281 								while (TRUE) {
3282 									const gchar* _tmp32_;
3283 									const gchar* _tmp33_;
3284 									gint _tmp34_;
3285 									gint _tmp35_;
3286 									gchar* _tmp36_;
3287 									if (!_tmp30_) {
3288 										const gchar* _tmp31_;
3289 										_tmp31_ = rpath;
3290 										if (!(!vala_code_context_ends_with_dir_separator (_tmp31_))) {
3291 											break;
3292 										}
3293 									}
3294 									_tmp30_ = FALSE;
3295 									_tmp32_ = rpath;
3296 									_tmp33_ = rpath;
3297 									_tmp34_ = strlen (_tmp33_);
3298 									_tmp35_ = _tmp34_;
3299 									_tmp36_ = string_substring (_tmp32_, (glong) 0, (glong) (_tmp35_ - 1));
3300 									_g_free0 (rpath);
3301 									rpath = _tmp36_;
3302 								}
3303 							}
3304 						}
3305 					} else {
3306 						const gchar* _tmp37_;
3307 						const gchar* _tmp40_;
3308 						const gchar* _tmp41_;
3309 						const gchar* _tmp42_;
3310 						const gchar* _tmp43_;
3311 						gchar* _tmp44_;
3312 						gchar* _tmp45_;
3313 						gchar* _tmp46_;
3314 						_tmp37_ = rpath;
3315 						if (!vala_code_context_ends_with_dir_separator (_tmp37_)) {
3316 							const gchar* _tmp38_;
3317 							gchar* _tmp39_;
3318 							_tmp38_ = rpath;
3319 							_tmp39_ = g_strconcat (_tmp38_, G_DIR_SEPARATOR_S, NULL);
3320 							_g_free0 (rpath);
3321 							rpath = _tmp39_;
3322 						}
3323 						_tmp40_ = rpath;
3324 						_tmp41_ = start;
3325 						_tmp42_ = end;
3326 						_tmp43_ = start;
3327 						_tmp44_ = string_substring (_tmp41_, (glong) 0, (glong) (((gchar*) _tmp42_) - ((gchar*) _tmp43_)));
3328 						_tmp45_ = _tmp44_;
3329 						_tmp46_ = g_strconcat (_tmp40_, _tmp45_, NULL);
3330 						_g_free0 (rpath);
3331 						rpath = _tmp46_;
3332 						_g_free0 (_tmp45_);
3333 					}
3334 				}
3335 			}
3336 		}
3337 	}
3338 	_tmp48_ = rpath;
3339 	_tmp49_ = strlen (_tmp48_);
3340 	_tmp50_ = _tmp49_;
3341 	if (((glong) _tmp50_) > root_len) {
3342 		const gchar* _tmp51_;
3343 		_tmp51_ = rpath;
3344 		_tmp47_ = vala_code_context_ends_with_dir_separator (_tmp51_);
3345 	} else {
3346 		_tmp47_ = FALSE;
3347 	}
3348 	if (_tmp47_) {
3349 		const gchar* _tmp52_;
3350 		const gchar* _tmp53_;
3351 		gint _tmp54_;
3352 		gint _tmp55_;
3353 		gchar* _tmp56_;
3354 		_tmp52_ = rpath;
3355 		_tmp53_ = rpath;
3356 		_tmp54_ = strlen (_tmp53_);
3357 		_tmp55_ = _tmp54_;
3358 		_tmp56_ = string_substring (_tmp52_, (glong) 0, (glong) (_tmp55_ - 1));
3359 		_g_free0 (rpath);
3360 		rpath = _tmp56_;
3361 	}
3362 	if (G_DIR_SEPARATOR != '/') {
3363 		gchar** components = NULL;
3364 		const gchar* _tmp57_;
3365 		gchar** _tmp58_;
3366 		gchar** _tmp59_;
3367 		gint components_length1;
3368 		gint _components_size_;
3369 		gchar** _tmp60_;
3370 		gint _tmp60__length1;
3371 		gchar* _tmp61_;
3372 		_tmp57_ = rpath;
3373 		_tmp59_ = _tmp58_ = g_strsplit (_tmp57_, "\\", 0);
3374 		components = _tmp59_;
3375 		components_length1 = _vala_array_length (_tmp58_);
3376 		_components_size_ = components_length1;
3377 		_tmp60_ = components;
3378 		_tmp60__length1 = components_length1;
3379 		_tmp61_ = _vala_g_strjoinv ("/", _tmp60_, (gint) _tmp60__length1);
3380 		_g_free0 (rpath);
3381 		rpath = _tmp61_;
3382 		components = (_vala_array_free (components, components_length1, (GDestroyNotify) g_free), NULL);
3383 	}
3384 	result = rpath;
3385 	return result;
3386 }
3387 
3388 gboolean
vala_code_context_pkg_config_exists(ValaCodeContext * self,const gchar * package_name)3389 vala_code_context_pkg_config_exists (ValaCodeContext* self,
3390                                      const gchar* package_name)
3391 {
3392 	gchar* pc = NULL;
3393 	const gchar* _tmp0_;
3394 	gchar* _tmp1_;
3395 	gchar* _tmp2_;
3396 	gchar* _tmp3_;
3397 	gchar* _tmp4_;
3398 	gint exit_status = 0;
3399 	gboolean _tmp9_ = FALSE;
3400 	GError* _inner_error0_ = NULL;
3401 	gboolean result = FALSE;
3402 	g_return_val_if_fail (self != NULL, FALSE);
3403 	g_return_val_if_fail (package_name != NULL, FALSE);
3404 	_tmp0_ = self->priv->_pkg_config_command;
3405 	_tmp1_ = g_strconcat (_tmp0_, " --exists ", NULL);
3406 	_tmp2_ = _tmp1_;
3407 	_tmp3_ = g_strconcat (_tmp2_, package_name, NULL);
3408 	_tmp4_ = _tmp3_;
3409 	_g_free0 (_tmp2_);
3410 	pc = _tmp4_;
3411 	{
3412 		gint _tmp5_ = 0;
3413 		g_spawn_command_line_sync (pc, NULL, NULL, &_tmp5_, &_inner_error0_);
3414 		exit_status = _tmp5_;
3415 		if (G_UNLIKELY (_inner_error0_ != NULL)) {
3416 			gboolean _tmp6_ = FALSE;
3417 			if (_inner_error0_->domain == G_SPAWN_ERROR) {
3418 				goto __catch0_g_spawn_error;
3419 			}
3420 			_g_free0 (pc);
3421 			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
3422 			g_clear_error (&_inner_error0_);
3423 			return _tmp6_;
3424 		}
3425 		result = 0 == exit_status;
3426 		_g_free0 (pc);
3427 		return result;
3428 	}
3429 	goto __finally0;
3430 	__catch0_g_spawn_error:
3431 	{
3432 		GError* e = NULL;
3433 		GError* _tmp7_;
3434 		const gchar* _tmp8_;
3435 		e = _inner_error0_;
3436 		_inner_error0_ = NULL;
3437 		_tmp7_ = e;
3438 		_tmp8_ = _tmp7_->message;
3439 		vala_report_error (NULL, _tmp8_);
3440 		result = FALSE;
3441 		_g_error_free0 (e);
3442 		_g_free0 (pc);
3443 		return result;
3444 	}
3445 	__finally0:
3446 	_g_free0 (pc);
3447 	g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
3448 	g_clear_error (&_inner_error0_);
3449 	return _tmp9_;
3450 }
3451 
3452 static gchar*
string_slice(const gchar * self,glong start,glong end)3453 string_slice (const gchar* self,
3454               glong start,
3455               glong end)
3456 {
3457 	glong string_length = 0L;
3458 	gint _tmp0_;
3459 	gint _tmp1_;
3460 	gboolean _tmp2_ = FALSE;
3461 	gboolean _tmp3_ = FALSE;
3462 	gchar* _tmp4_;
3463 	gchar* result = NULL;
3464 	g_return_val_if_fail (self != NULL, NULL);
3465 	_tmp0_ = strlen (self);
3466 	_tmp1_ = _tmp0_;
3467 	string_length = (glong) _tmp1_;
3468 	if (start < ((glong) 0)) {
3469 		start = string_length + start;
3470 	}
3471 	if (end < ((glong) 0)) {
3472 		end = string_length + end;
3473 	}
3474 	if (start >= ((glong) 0)) {
3475 		_tmp2_ = start <= string_length;
3476 	} else {
3477 		_tmp2_ = FALSE;
3478 	}
3479 	g_return_val_if_fail (_tmp2_, NULL);
3480 	if (end >= ((glong) 0)) {
3481 		_tmp3_ = end <= string_length;
3482 	} else {
3483 		_tmp3_ = FALSE;
3484 	}
3485 	g_return_val_if_fail (_tmp3_, NULL);
3486 	g_return_val_if_fail (start <= end, NULL);
3487 	_tmp4_ = g_strndup (((gchar*) self) + start, (gsize) (end - start));
3488 	result = _tmp4_;
3489 	return result;
3490 }
3491 
3492 gchar*
vala_code_context_pkg_config_modversion(ValaCodeContext * self,const gchar * package_name)3493 vala_code_context_pkg_config_modversion (ValaCodeContext* self,
3494                                          const gchar* package_name)
3495 {
3496 	gchar* pc = NULL;
3497 	const gchar* _tmp0_;
3498 	gchar* _tmp1_;
3499 	gchar* _tmp2_;
3500 	gchar* _tmp3_;
3501 	gchar* _tmp4_;
3502 	gchar* output = NULL;
3503 	gint exit_status = 0;
3504 	GError* _inner_error0_ = NULL;
3505 	gchar* result = NULL;
3506 	g_return_val_if_fail (self != NULL, NULL);
3507 	g_return_val_if_fail (package_name != NULL, NULL);
3508 	_tmp0_ = self->priv->_pkg_config_command;
3509 	_tmp1_ = g_strconcat (_tmp0_, " --silence-errors --modversion ", NULL);
3510 	_tmp2_ = _tmp1_;
3511 	_tmp3_ = g_strconcat (_tmp2_, package_name, NULL);
3512 	_tmp4_ = _tmp3_;
3513 	_g_free0 (_tmp2_);
3514 	pc = _tmp4_;
3515 	output = NULL;
3516 	{
3517 		gchar* _tmp5_ = NULL;
3518 		gint _tmp6_ = 0;
3519 		g_spawn_command_line_sync (pc, &_tmp5_, NULL, &_tmp6_, &_inner_error0_);
3520 		_g_free0 (output);
3521 		output = _tmp5_;
3522 		exit_status = _tmp6_;
3523 		if (G_UNLIKELY (_inner_error0_ != NULL)) {
3524 			if (_inner_error0_->domain == G_SPAWN_ERROR) {
3525 				goto __catch0_g_spawn_error;
3526 			}
3527 			_g_free0 (output);
3528 			_g_free0 (pc);
3529 			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
3530 			g_clear_error (&_inner_error0_);
3531 			return NULL;
3532 		}
3533 		if (exit_status == 0) {
3534 			const gchar* _tmp7_;
3535 			gchar* _tmp8_;
3536 			const gchar* _tmp9_;
3537 			_tmp7_ = output;
3538 			_tmp8_ = string_slice (_tmp7_, (glong) 0, (glong) -1);
3539 			_g_free0 (output);
3540 			output = _tmp8_;
3541 			_tmp9_ = output;
3542 			if (g_strcmp0 (_tmp9_, "") == 0) {
3543 				_g_free0 (output);
3544 				output = NULL;
3545 			}
3546 		} else {
3547 			_g_free0 (output);
3548 			output = NULL;
3549 		}
3550 	}
3551 	goto __finally0;
3552 	__catch0_g_spawn_error:
3553 	{
3554 		g_clear_error (&_inner_error0_);
3555 		_g_free0 (output);
3556 		output = NULL;
3557 	}
3558 	__finally0:
3559 	if (G_UNLIKELY (_inner_error0_ != NULL)) {
3560 		_g_free0 (output);
3561 		_g_free0 (pc);
3562 		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
3563 		g_clear_error (&_inner_error0_);
3564 		return NULL;
3565 	}
3566 	result = output;
3567 	_g_free0 (pc);
3568 	return result;
3569 }
3570 
3571 gchar*
vala_code_context_pkg_config_compile_flags(ValaCodeContext * self,const gchar * package_name)3572 vala_code_context_pkg_config_compile_flags (ValaCodeContext* self,
3573                                             const gchar* package_name)
3574 {
3575 	gchar* pc = NULL;
3576 	const gchar* _tmp0_;
3577 	gchar* _tmp1_;
3578 	gboolean _tmp2_;
3579 	const gchar* _tmp5_;
3580 	gchar* _tmp6_;
3581 	gchar* output = NULL;
3582 	gint exit_status = 0;
3583 	GError* _inner_error0_ = NULL;
3584 	gchar* result = NULL;
3585 	g_return_val_if_fail (self != NULL, NULL);
3586 	g_return_val_if_fail (package_name != NULL, NULL);
3587 	_tmp0_ = self->priv->_pkg_config_command;
3588 	_tmp1_ = g_strconcat (_tmp0_, " --cflags", NULL);
3589 	pc = _tmp1_;
3590 	_tmp2_ = self->priv->_compile_only;
3591 	if (!_tmp2_) {
3592 		const gchar* _tmp3_;
3593 		gchar* _tmp4_;
3594 		_tmp3_ = pc;
3595 		_tmp4_ = g_strconcat (_tmp3_, " --libs", NULL);
3596 		_g_free0 (pc);
3597 		pc = _tmp4_;
3598 	}
3599 	_tmp5_ = pc;
3600 	_tmp6_ = g_strconcat (_tmp5_, package_name, NULL);
3601 	_g_free0 (pc);
3602 	pc = _tmp6_;
3603 	output = NULL;
3604 	{
3605 		const gchar* _tmp7_;
3606 		gchar* _tmp8_ = NULL;
3607 		gint _tmp9_ = 0;
3608 		_tmp7_ = pc;
3609 		g_spawn_command_line_sync (_tmp7_, &_tmp8_, NULL, &_tmp9_, &_inner_error0_);
3610 		_g_free0 (output);
3611 		output = _tmp8_;
3612 		exit_status = _tmp9_;
3613 		if (G_UNLIKELY (_inner_error0_ != NULL)) {
3614 			if (_inner_error0_->domain == G_SPAWN_ERROR) {
3615 				goto __catch0_g_spawn_error;
3616 			}
3617 			_g_free0 (output);
3618 			_g_free0 (pc);
3619 			g_critical ("file %s: line %d: unexpected error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
3620 			g_clear_error (&_inner_error0_);
3621 			return NULL;
3622 		}
3623 		if (exit_status != 0) {
3624 			const gchar* _tmp10_;
3625 			gchar* _tmp11_;
3626 			gchar* _tmp12_;
3627 			_tmp10_ = self->priv->_pkg_config_command;
3628 			_tmp11_ = g_strdup_printf ("%s exited with status %d", _tmp10_, exit_status);
3629 			_tmp12_ = _tmp11_;
3630 			vala_report_error (NULL, _tmp12_);
3631 			_g_free0 (_tmp12_);
3632 			result = NULL;
3633 			_g_free0 (output);
3634 			_g_free0 (pc);
3635 			return result;
3636 		}
3637 	}
3638 	goto __finally0;
3639 	__catch0_g_spawn_error:
3640 	{
3641 		GError* e = NULL;
3642 		GError* _tmp13_;
3643 		const gchar* _tmp14_;
3644 		e = _inner_error0_;
3645 		_inner_error0_ = NULL;
3646 		_tmp13_ = e;
3647 		_tmp14_ = _tmp13_->message;
3648 		vala_report_error (NULL, _tmp14_);
3649 		_g_free0 (output);
3650 		output = NULL;
3651 		_g_error_free0 (e);
3652 	}
3653 	__finally0:
3654 	if (G_UNLIKELY (_inner_error0_ != NULL)) {
3655 		_g_free0 (output);
3656 		_g_free0 (pc);
3657 		g_critical ("file %s: line %d: uncaught error: %s (%s, %d)", __FILE__, __LINE__, _inner_error0_->message, g_quark_to_string (_inner_error0_->domain), _inner_error0_->code);
3658 		g_clear_error (&_inner_error0_);
3659 		return NULL;
3660 	}
3661 	result = output;
3662 	_g_free0 (pc);
3663 	return result;
3664 }
3665 
3666 static void
vala_value_code_context_init(GValue * value)3667 vala_value_code_context_init (GValue* value)
3668 {
3669 	value->data[0].v_pointer = NULL;
3670 }
3671 
3672 static void
vala_value_code_context_free_value(GValue * value)3673 vala_value_code_context_free_value (GValue* value)
3674 {
3675 	if (value->data[0].v_pointer) {
3676 		vala_code_context_unref (value->data[0].v_pointer);
3677 	}
3678 }
3679 
3680 static void
vala_value_code_context_copy_value(const GValue * src_value,GValue * dest_value)3681 vala_value_code_context_copy_value (const GValue* src_value,
3682                                     GValue* dest_value)
3683 {
3684 	if (src_value->data[0].v_pointer) {
3685 		dest_value->data[0].v_pointer = vala_code_context_ref (src_value->data[0].v_pointer);
3686 	} else {
3687 		dest_value->data[0].v_pointer = NULL;
3688 	}
3689 }
3690 
3691 static gpointer
vala_value_code_context_peek_pointer(const GValue * value)3692 vala_value_code_context_peek_pointer (const GValue* value)
3693 {
3694 	return value->data[0].v_pointer;
3695 }
3696 
3697 static gchar*
vala_value_code_context_collect_value(GValue * value,guint n_collect_values,GTypeCValue * collect_values,guint collect_flags)3698 vala_value_code_context_collect_value (GValue* value,
3699                                        guint n_collect_values,
3700                                        GTypeCValue* collect_values,
3701                                        guint collect_flags)
3702 {
3703 	if (collect_values[0].v_pointer) {
3704 		ValaCodeContext * object;
3705 		object = collect_values[0].v_pointer;
3706 		if (object->parent_instance.g_class == NULL) {
3707 			return g_strconcat ("invalid unclassed object pointer for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
3708 		} else if (!g_value_type_compatible (G_TYPE_FROM_INSTANCE (object), G_VALUE_TYPE (value))) {
3709 			return g_strconcat ("invalid object type `", g_type_name (G_TYPE_FROM_INSTANCE (object)), "' for value type `", G_VALUE_TYPE_NAME (value), "'", NULL);
3710 		}
3711 		value->data[0].v_pointer = vala_code_context_ref (object);
3712 	} else {
3713 		value->data[0].v_pointer = NULL;
3714 	}
3715 	return NULL;
3716 }
3717 
3718 static gchar*
vala_value_code_context_lcopy_value(const GValue * value,guint n_collect_values,GTypeCValue * collect_values,guint collect_flags)3719 vala_value_code_context_lcopy_value (const GValue* value,
3720                                      guint n_collect_values,
3721                                      GTypeCValue* collect_values,
3722                                      guint collect_flags)
3723 {
3724 	ValaCodeContext ** object_p;
3725 	object_p = collect_values[0].v_pointer;
3726 	if (!object_p) {
3727 		return g_strdup_printf ("value location for `%s' passed as NULL", G_VALUE_TYPE_NAME (value));
3728 	}
3729 	if (!value->data[0].v_pointer) {
3730 		*object_p = NULL;
3731 	} else if (collect_flags & G_VALUE_NOCOPY_CONTENTS) {
3732 		*object_p = value->data[0].v_pointer;
3733 	} else {
3734 		*object_p = vala_code_context_ref (value->data[0].v_pointer);
3735 	}
3736 	return NULL;
3737 }
3738 
3739 GParamSpec*
vala_param_spec_code_context(const gchar * name,const gchar * nick,const gchar * blurb,GType object_type,GParamFlags flags)3740 vala_param_spec_code_context (const gchar* name,
3741                               const gchar* nick,
3742                               const gchar* blurb,
3743                               GType object_type,
3744                               GParamFlags flags)
3745 {
3746 	ValaParamSpecCodeContext* spec;
3747 	g_return_val_if_fail (g_type_is_a (object_type, VALA_TYPE_CODE_CONTEXT), NULL);
3748 	spec = g_param_spec_internal (G_TYPE_PARAM_OBJECT, name, nick, blurb, flags);
3749 	G_PARAM_SPEC (spec)->value_type = object_type;
3750 	return G_PARAM_SPEC (spec);
3751 }
3752 
3753 gpointer
vala_value_get_code_context(const GValue * value)3754 vala_value_get_code_context (const GValue* value)
3755 {
3756 	g_return_val_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, VALA_TYPE_CODE_CONTEXT), NULL);
3757 	return value->data[0].v_pointer;
3758 }
3759 
3760 void
vala_value_set_code_context(GValue * value,gpointer v_object)3761 vala_value_set_code_context (GValue* value,
3762                              gpointer v_object)
3763 {
3764 	ValaCodeContext * old;
3765 	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, VALA_TYPE_CODE_CONTEXT));
3766 	old = value->data[0].v_pointer;
3767 	if (v_object) {
3768 		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, VALA_TYPE_CODE_CONTEXT));
3769 		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
3770 		value->data[0].v_pointer = v_object;
3771 		vala_code_context_ref (value->data[0].v_pointer);
3772 	} else {
3773 		value->data[0].v_pointer = NULL;
3774 	}
3775 	if (old) {
3776 		vala_code_context_unref (old);
3777 	}
3778 }
3779 
3780 void
vala_value_take_code_context(GValue * value,gpointer v_object)3781 vala_value_take_code_context (GValue* value,
3782                               gpointer v_object)
3783 {
3784 	ValaCodeContext * old;
3785 	g_return_if_fail (G_TYPE_CHECK_VALUE_TYPE (value, VALA_TYPE_CODE_CONTEXT));
3786 	old = value->data[0].v_pointer;
3787 	if (v_object) {
3788 		g_return_if_fail (G_TYPE_CHECK_INSTANCE_TYPE (v_object, VALA_TYPE_CODE_CONTEXT));
3789 		g_return_if_fail (g_value_type_compatible (G_TYPE_FROM_INSTANCE (v_object), G_VALUE_TYPE (value)));
3790 		value->data[0].v_pointer = v_object;
3791 	} else {
3792 		value->data[0].v_pointer = NULL;
3793 	}
3794 	if (old) {
3795 		vala_code_context_unref (old);
3796 	}
3797 }
3798 
3799 static void
vala_code_context_class_init(ValaCodeContextClass * klass,gpointer klass_data)3800 vala_code_context_class_init (ValaCodeContextClass * klass,
3801                               gpointer klass_data)
3802 {
3803 	vala_code_context_parent_class = g_type_class_peek_parent (klass);
3804 	((ValaCodeContextClass *) klass)->finalize = vala_code_context_finalize;
3805 	g_type_class_adjust_private_offset (klass, &ValaCodeContext_private_offset);
3806 	g_static_private_init (&vala_code_context_context_stack_key);
3807 	vala_code_context_context_stack_key = vala_code_context_context_stack_key;
3808 }
3809 
3810 static void
vala_code_context_instance_init(ValaCodeContext * self,gpointer klass)3811 vala_code_context_instance_init (ValaCodeContext * self,
3812                                  gpointer klass)
3813 {
3814 	gchar* _tmp0_;
3815 	gchar** _tmp1_;
3816 	gchar** _tmp2_;
3817 	gchar** _tmp3_;
3818 	ValaReport* _tmp4_;
3819 	gchar** _tmp5_;
3820 	gchar** _tmp6_;
3821 	GEqualFunc _tmp7_;
3822 	ValaArrayList* _tmp8_;
3823 	GHashFunc _tmp9_;
3824 	GEqualFunc _tmp10_;
3825 	GEqualFunc _tmp11_;
3826 	ValaHashMap* _tmp12_;
3827 	GEqualFunc _tmp13_;
3828 	ValaArrayList* _tmp14_;
3829 	ValaNamespace* _tmp15_;
3830 	GEqualFunc _tmp16_;
3831 	ValaArrayList* _tmp17_;
3832 	GHashFunc _tmp18_;
3833 	GEqualFunc _tmp19_;
3834 	ValaHashSet* _tmp20_;
3835 	self->priv = vala_code_context_get_instance_private (self);
3836 	_tmp0_ = g_strdup ("pkg-config");
3837 	self->priv->_pkg_config_command = _tmp0_;
3838 	_tmp1_ = g_new0 (gchar*, 0 + 1);
3839 	self->priv->_vapi_directories = _tmp1_;
3840 	self->priv->_vapi_directories_length1 = 0;
3841 	self->priv->__vapi_directories_size_ = self->priv->_vapi_directories_length1;
3842 	_tmp2_ = g_new0 (gchar*, 0 + 1);
3843 	self->priv->_gir_directories = _tmp2_;
3844 	self->priv->_gir_directories_length1 = 0;
3845 	self->priv->__gir_directories_size_ = self->priv->_gir_directories_length1;
3846 	_tmp3_ = g_new0 (gchar*, 0 + 1);
3847 	self->priv->_metadata_directories = _tmp3_;
3848 	self->priv->_metadata_directories_length1 = 0;
3849 	self->priv->__metadata_directories_size_ = self->priv->_metadata_directories_length1;
3850 	_tmp4_ = vala_report_new ();
3851 	self->priv->_report = _tmp4_;
3852 	_tmp5_ = g_new0 (gchar*, 0 + 1);
3853 	self->priv->_gresources = _tmp5_;
3854 	self->priv->_gresources_length1 = 0;
3855 	self->priv->__gresources_size_ = self->priv->_gresources_length1;
3856 	_tmp6_ = g_new0 (gchar*, 0 + 1);
3857 	self->priv->_gresources_directories = _tmp6_;
3858 	self->priv->_gresources_directories_length1 = 0;
3859 	self->priv->__gresources_directories_size_ = self->priv->_gresources_directories_length1;
3860 	_tmp7_ = g_direct_equal;
3861 	_tmp8_ = vala_array_list_new (VALA_TYPE_SOURCE_FILE, (GBoxedCopyFunc) vala_source_file_ref, (GDestroyNotify) vala_source_file_unref, _tmp7_);
3862 	self->priv->source_files = (ValaList*) _tmp8_;
3863 	_tmp9_ = g_str_hash;
3864 	_tmp10_ = g_str_equal;
3865 	_tmp11_ = g_direct_equal;
3866 	_tmp12_ = vala_hash_map_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, VALA_TYPE_SOURCE_FILE, NULL, NULL, _tmp9_, _tmp10_, _tmp11_);
3867 	self->priv->source_files_map = (ValaMap*) _tmp12_;
3868 	_tmp13_ = g_str_equal;
3869 	_tmp14_ = vala_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _tmp13_);
3870 	self->priv->c_source_files = (ValaList*) _tmp14_;
3871 	_tmp15_ = vala_namespace_new (NULL, NULL);
3872 	self->priv->_root = _tmp15_;
3873 	_tmp16_ = g_str_equal;
3874 	_tmp17_ = vala_array_list_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _tmp16_);
3875 	self->priv->packages = (ValaList*) _tmp17_;
3876 	_tmp18_ = g_str_hash;
3877 	_tmp19_ = g_str_equal;
3878 	_tmp20_ = vala_hash_set_new (G_TYPE_STRING, (GBoxedCopyFunc) g_strdup, (GDestroyNotify) g_free, _tmp18_, _tmp19_);
3879 	self->priv->defines = (ValaSet*) _tmp20_;
3880 	self->ref_count = 1;
3881 }
3882 
3883 static void
vala_code_context_finalize(ValaCodeContext * obj)3884 vala_code_context_finalize (ValaCodeContext * obj)
3885 {
3886 	ValaCodeContext * self;
3887 	self = G_TYPE_CHECK_INSTANCE_CAST (obj, VALA_TYPE_CODE_CONTEXT, ValaCodeContext);
3888 	g_signal_handlers_destroy (self);
3889 	_g_free0 (self->priv->_pkg_config_command);
3890 	_g_free0 (self->priv->_header_filename);
3891 	_g_free0 (self->priv->_internal_header_filename);
3892 	_g_free0 (self->priv->_includedir);
3893 	_g_free0 (self->priv->_symbols_filename);
3894 	_g_free0 (self->priv->_output);
3895 	_g_free0 (self->priv->_basedir);
3896 	_g_free0 (self->priv->_directory);
3897 	self->priv->_vapi_directories = (_vala_array_free (self->priv->_vapi_directories, self->priv->_vapi_directories_length1, (GDestroyNotify) g_free), NULL);
3898 	self->priv->_gir_directories = (_vala_array_free (self->priv->_gir_directories, self->priv->_gir_directories_length1, (GDestroyNotify) g_free), NULL);
3899 	self->priv->_metadata_directories = (_vala_array_free (self->priv->_metadata_directories, self->priv->_metadata_directories_length1, (GDestroyNotify) g_free), NULL);
3900 	_vala_code_node_unref0 (self->priv->_module_init_method);
3901 	_vala_report_unref0 (self->priv->_report);
3902 	_vala_code_node_unref0 (self->priv->_entry_point);
3903 	_g_free0 (self->priv->_entry_point_name);
3904 	self->priv->_gresources = (_vala_array_free (self->priv->_gresources, self->priv->_gresources_length1, (GDestroyNotify) g_free), NULL);
3905 	self->priv->_gresources_directories = (_vala_array_free (self->priv->_gresources_directories, self->priv->_gresources_directories_length1, (GDestroyNotify) g_free), NULL);
3906 	_vala_iterable_unref0 (self->priv->source_files);
3907 	_vala_map_unref0 (self->priv->source_files_map);
3908 	_vala_iterable_unref0 (self->priv->c_source_files);
3909 	_vala_code_node_unref0 (self->priv->_root);
3910 	_vala_iterable_unref0 (self->priv->packages);
3911 	_vala_iterable_unref0 (self->priv->defines);
3912 	_vala_code_visitor_unref0 (self->priv->_resolver);
3913 	_vala_code_visitor_unref0 (self->priv->_analyzer);
3914 	_vala_code_visitor_unref0 (self->priv->_flow_analyzer);
3915 	_vala_code_visitor_unref0 (self->priv->_codegen);
3916 	_vala_code_visitor_unref0 (self->priv->_used_attr);
3917 }
3918 
3919 /**
3920  * The root of the code tree.
3921  */
3922 static GType
vala_code_context_get_type_once(void)3923 vala_code_context_get_type_once (void)
3924 {
3925 	static const GTypeValueTable g_define_type_value_table = { vala_value_code_context_init, vala_value_code_context_free_value, vala_value_code_context_copy_value, vala_value_code_context_peek_pointer, "p", vala_value_code_context_collect_value, "p", vala_value_code_context_lcopy_value };
3926 	static const GTypeInfo g_define_type_info = { sizeof (ValaCodeContextClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) vala_code_context_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ValaCodeContext), 0, (GInstanceInitFunc) vala_code_context_instance_init, &g_define_type_value_table };
3927 	static const GTypeFundamentalInfo g_define_type_fundamental_info = { (G_TYPE_FLAG_CLASSED | G_TYPE_FLAG_INSTANTIATABLE | G_TYPE_FLAG_DERIVABLE | G_TYPE_FLAG_DEEP_DERIVABLE) };
3928 	GType vala_code_context_type_id;
3929 	vala_code_context_type_id = g_type_register_fundamental (g_type_fundamental_next (), "ValaCodeContext", &g_define_type_info, &g_define_type_fundamental_info, 0);
3930 	ValaCodeContext_private_offset = g_type_add_instance_private (vala_code_context_type_id, sizeof (ValaCodeContextPrivate));
3931 	return vala_code_context_type_id;
3932 }
3933 
3934 GType
vala_code_context_get_type(void)3935 vala_code_context_get_type (void)
3936 {
3937 	static volatile gsize vala_code_context_type_id__volatile = 0;
3938 	if (g_once_init_enter (&vala_code_context_type_id__volatile)) {
3939 		GType vala_code_context_type_id;
3940 		vala_code_context_type_id = vala_code_context_get_type_once ();
3941 		g_once_init_leave (&vala_code_context_type_id__volatile, vala_code_context_type_id);
3942 	}
3943 	return vala_code_context_type_id__volatile;
3944 }
3945 
3946 gpointer
vala_code_context_ref(gpointer instance)3947 vala_code_context_ref (gpointer instance)
3948 {
3949 	ValaCodeContext * self;
3950 	self = instance;
3951 	g_atomic_int_inc (&self->ref_count);
3952 	return instance;
3953 }
3954 
3955 void
vala_code_context_unref(gpointer instance)3956 vala_code_context_unref (gpointer instance)
3957 {
3958 	ValaCodeContext * self;
3959 	self = instance;
3960 	if (g_atomic_int_dec_and_test (&self->ref_count)) {
3961 		VALA_CODE_CONTEXT_GET_CLASS (self)->finalize (self);
3962 		g_type_free_instance ((GTypeInstance *) self);
3963 	}
3964 }
3965 
3966 static void
_vala_array_destroy(gpointer array,gint array_length,GDestroyNotify destroy_func)3967 _vala_array_destroy (gpointer array,
3968                      gint array_length,
3969                      GDestroyNotify destroy_func)
3970 {
3971 	if ((array != NULL) && (destroy_func != NULL)) {
3972 		gint i;
3973 		for (i = 0; i < array_length; i = i + 1) {
3974 			if (((gpointer*) array)[i] != NULL) {
3975 				destroy_func (((gpointer*) array)[i]);
3976 			}
3977 		}
3978 	}
3979 }
3980 
3981 static void
_vala_array_free(gpointer array,gint array_length,GDestroyNotify destroy_func)3982 _vala_array_free (gpointer array,
3983                   gint array_length,
3984                   GDestroyNotify destroy_func)
3985 {
3986 	_vala_array_destroy (array, array_length, destroy_func);
3987 	g_free (array);
3988 }
3989 
3990 static gint
_vala_array_length(gpointer array)3991 _vala_array_length (gpointer array)
3992 {
3993 	gint length;
3994 	length = 0;
3995 	if (array) {
3996 		while (((gpointer*) array)[length]) {
3997 			length++;
3998 		}
3999 	}
4000 	return length;
4001 }
4002 
4003