File: valaconstructor.c

package info (click to toggle)
vala 0.56.18-7
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 57,520 kB
  • sloc: ansic: 581,293; sh: 5,357; makefile: 3,980; xml: 3,161; yacc: 1,219; lex: 374; javascript: 23
file content (390 lines) | stat: -rw-r--r-- 12,696 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
/* valaconstructor.c generated by valac, the Vala compiler
 * generated from valaconstructor.vala, do not modify */

/* valaconstructor.vala
 *
 * Copyright (C) 2006-2010  Jürg Billeter
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.

 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.

 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301  USA
 *
 * Author:
 * 	Jürg Billeter <j@bitron.ch>
 */

#include "vala.h"
#include <glib.h>
#include <glib-object.h>
#include <valagee.h>
#include <stdlib.h>
#include <string.h>

#if !defined(VALA_STRICT_C)
#if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ >= 14)
#pragma GCC diagnostic warning "-Wincompatible-pointer-types"
#elif defined(__clang__) && (__clang_major__ >= 16)
#pragma clang diagnostic ignored "-Wincompatible-function-pointer-types"
#pragma clang diagnostic ignored "-Wincompatible-pointer-types"
#endif
#endif

#define _vala_code_node_unref0(var) ((var == NULL) ? NULL : (var = (vala_code_node_unref (var), NULL)))
#define _g_free0(var) (var = (g_free (var), NULL))
#define _vala_iterable_unref0(var) ((var == NULL) ? NULL : (var = (vala_iterable_unref (var), NULL)))

struct _ValaConstructorPrivate {
	ValaParameter* _this_parameter;
	ValaMemberBinding _binding;
};

static gint ValaConstructor_private_offset;
static gpointer vala_constructor_parent_class = NULL;

static void vala_constructor_real_accept (ValaCodeNode* base,
                                   ValaCodeVisitor* visitor);
static void vala_constructor_real_accept_children (ValaCodeNode* base,
                                            ValaCodeVisitor* visitor);
static gboolean vala_constructor_real_check (ValaCodeNode* base,
                                      ValaCodeContext* context);
static void vala_constructor_finalize (ValaCodeNode * obj);
static GType vala_constructor_get_type_once (void);

static inline gpointer
vala_constructor_get_instance_private (ValaConstructor* self)
{
	return G_STRUCT_MEMBER_P (self, ValaConstructor_private_offset);
}

ValaParameter*
vala_constructor_get_this_parameter (ValaConstructor* self)
{
	ValaParameter* result;
	ValaParameter* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_this_parameter;
	result = _tmp0_;
	return result;
}

static gpointer
_vala_code_node_ref0 (gpointer self)
{
	return self ? vala_code_node_ref (self) : NULL;
}

void
vala_constructor_set_this_parameter (ValaConstructor* self,
                                     ValaParameter* value)
{
	ValaParameter* _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = _vala_code_node_ref0 (value);
	_vala_code_node_unref0 (self->priv->_this_parameter);
	self->priv->_this_parameter = _tmp0_;
}

ValaMemberBinding
vala_constructor_get_binding (ValaConstructor* self)
{
	ValaMemberBinding result;
	g_return_val_if_fail (self != NULL, 0);
	result = self->priv->_binding;
	return result;
}

void
vala_constructor_set_binding (ValaConstructor* self,
                              ValaMemberBinding value)
{
	g_return_if_fail (self != NULL);
	self->priv->_binding = value;
}

static gboolean
vala_constructor_real_get_has_result (ValaSubroutine* base)
{
	gboolean result;
	ValaConstructor* self;
	self = (ValaConstructor*) base;
	result = FALSE;
	return result;
}

/**
 * Creates a new constructor.
 *
 * @param source reference to source code
 * @return       newly created constructor
 */
ValaConstructor*
vala_constructor_construct (GType object_type,
                            ValaSourceReference* source)
{
	ValaConstructor* self = NULL;
	self = (ValaConstructor*) vala_subroutine_construct (object_type, NULL, source, NULL);
	return self;
}

ValaConstructor*
vala_constructor_new (ValaSourceReference* source)
{
	return vala_constructor_construct (VALA_TYPE_CONSTRUCTOR, source);
}

static void
vala_constructor_real_accept (ValaCodeNode* base,
                              ValaCodeVisitor* visitor)
{
	ValaConstructor * self;
	self = (ValaConstructor*) base;
	g_return_if_fail (visitor != NULL);
	vala_code_visitor_visit_constructor (visitor, self);
}

static void
vala_constructor_real_accept_children (ValaCodeNode* base,
                                       ValaCodeVisitor* visitor)
{
	ValaConstructor * self;
	ValaBlock* _tmp0_;
	ValaBlock* _tmp1_;
	self = (ValaConstructor*) base;
	g_return_if_fail (visitor != NULL);
	_tmp0_ = vala_subroutine_get_body ((ValaSubroutine*) self);
	_tmp1_ = _tmp0_;
	if (_tmp1_ != NULL) {
		ValaBlock* _tmp2_;
		ValaBlock* _tmp3_;
		_tmp2_ = vala_subroutine_get_body ((ValaSubroutine*) self);
		_tmp3_ = _tmp2_;
		vala_code_node_accept ((ValaCodeNode*) _tmp3_, visitor);
	}
}

static gboolean
vala_constructor_real_check (ValaCodeNode* base,
                             ValaCodeContext* context)
{
	ValaConstructor * self;
	gboolean _tmp0_;
	gboolean _tmp1_;
	ValaParameter* _tmp4_;
	ValaSymbol* old_symbol = NULL;
	ValaSemanticAnalyzer* _tmp6_;
	ValaSemanticAnalyzer* _tmp7_;
	ValaSymbol* _tmp8_;
	ValaSymbol* _tmp9_;
	ValaSymbol* _tmp10_;
	ValaSemanticAnalyzer* _tmp11_;
	ValaSemanticAnalyzer* _tmp12_;
	ValaBlock* _tmp13_;
	ValaBlock* _tmp14_;
	gboolean _tmp17_ = FALSE;
	ValaBlock* _tmp18_;
	ValaBlock* _tmp19_;
	ValaSemanticAnalyzer* _tmp46_;
	ValaSemanticAnalyzer* _tmp47_;
	ValaSymbol* _tmp48_;
	gboolean _tmp49_;
	gboolean _tmp50_;
	gboolean result;
	self = (ValaConstructor*) base;
	g_return_val_if_fail (context != NULL, FALSE);
	_tmp0_ = vala_code_node_get_checked ((ValaCodeNode*) self);
	_tmp1_ = _tmp0_;
	if (_tmp1_) {
		gboolean _tmp2_;
		gboolean _tmp3_;
		_tmp2_ = vala_code_node_get_error ((ValaCodeNode*) self);
		_tmp3_ = _tmp2_;
		result = !_tmp3_;
		return result;
	}
	vala_code_node_set_checked ((ValaCodeNode*) self, TRUE);
	_tmp4_ = self->priv->_this_parameter;
	if (_tmp4_ != NULL) {
		ValaParameter* _tmp5_;
		_tmp5_ = self->priv->_this_parameter;
		vala_code_node_check ((ValaCodeNode*) _tmp5_, context);
	}
	_tmp6_ = vala_code_context_get_analyzer (context);
	_tmp7_ = _tmp6_;
	_tmp8_ = vala_semantic_analyzer_get_current_symbol (_tmp7_);
	_tmp9_ = _tmp8_;
	_tmp10_ = _vala_code_node_ref0 (_tmp9_);
	old_symbol = _tmp10_;
	_tmp11_ = vala_code_context_get_analyzer (context);
	_tmp12_ = _tmp11_;
	vala_semantic_analyzer_set_current_symbol (_tmp12_, (ValaSymbol*) self);
	_tmp13_ = vala_subroutine_get_body ((ValaSubroutine*) self);
	_tmp14_ = _tmp13_;
	if (_tmp14_ != NULL) {
		ValaBlock* _tmp15_;
		ValaBlock* _tmp16_;
		_tmp15_ = vala_subroutine_get_body ((ValaSubroutine*) self);
		_tmp16_ = _tmp15_;
		vala_code_node_check ((ValaCodeNode*) _tmp16_, context);
	}
	_tmp18_ = vala_subroutine_get_body ((ValaSubroutine*) self);
	_tmp19_ = _tmp18_;
	if (_tmp19_ != NULL) {
		ValaBlock* _tmp20_;
		ValaBlock* _tmp21_;
		gboolean _tmp22_;
		gboolean _tmp23_;
		_tmp20_ = vala_subroutine_get_body ((ValaSubroutine*) self);
		_tmp21_ = _tmp20_;
		_tmp22_ = vala_code_node_get_error ((ValaCodeNode*) _tmp21_);
		_tmp23_ = _tmp22_;
		_tmp17_ = !_tmp23_;
	} else {
		_tmp17_ = FALSE;
	}
	if (_tmp17_) {
		ValaArrayList* body_errors = NULL;
		GEqualFunc _tmp24_;
		ValaArrayList* _tmp25_;
		ValaBlock* _tmp26_;
		ValaBlock* _tmp27_;
		ValaArrayList* _tmp28_;
		_tmp24_ = g_direct_equal;
		_tmp25_ = vala_array_list_new (VALA_TYPE_DATA_TYPE, (GBoxedCopyFunc) vala_code_node_ref, (GDestroyNotify) vala_code_node_unref, _tmp24_);
		body_errors = _tmp25_;
		_tmp26_ = vala_subroutine_get_body ((ValaSubroutine*) self);
		_tmp27_ = _tmp26_;
		_tmp28_ = body_errors;
		vala_code_node_get_error_types ((ValaCodeNode*) _tmp27_, (ValaCollection*) _tmp28_, NULL);
		{
			ValaArrayList* _body_error_type_list = NULL;
			ValaArrayList* _tmp29_;
			gint _body_error_type_size = 0;
			ValaArrayList* _tmp30_;
			gint _tmp31_;
			gint _tmp32_;
			gint _body_error_type_index = 0;
			_tmp29_ = body_errors;
			_body_error_type_list = _tmp29_;
			_tmp30_ = _body_error_type_list;
			_tmp31_ = vala_collection_get_size ((ValaCollection*) _tmp30_);
			_tmp32_ = _tmp31_;
			_body_error_type_size = _tmp32_;
			_body_error_type_index = -1;
			while (TRUE) {
				gint _tmp33_;
				gint _tmp34_;
				ValaDataType* body_error_type = NULL;
				ValaArrayList* _tmp35_;
				gpointer _tmp36_;
				ValaDataType* _tmp37_;
				gboolean _tmp38_;
				gboolean _tmp39_;
				_body_error_type_index = _body_error_type_index + 1;
				_tmp33_ = _body_error_type_index;
				_tmp34_ = _body_error_type_size;
				if (!(_tmp33_ < _tmp34_)) {
					break;
				}
				_tmp35_ = _body_error_type_list;
				_tmp36_ = vala_list_get ((ValaList*) _tmp35_, _body_error_type_index);
				body_error_type = (ValaDataType*) _tmp36_;
				_tmp37_ = body_error_type;
				_tmp38_ = vala_error_type_get_dynamic_error (G_TYPE_CHECK_INSTANCE_CAST (_tmp37_, VALA_TYPE_ERROR_TYPE, ValaErrorType));
				_tmp39_ = _tmp38_;
				if (!_tmp39_) {
					ValaDataType* _tmp40_;
					ValaSourceReference* _tmp41_;
					ValaSourceReference* _tmp42_;
					ValaDataType* _tmp43_;
					gchar* _tmp44_;
					gchar* _tmp45_;
					_tmp40_ = body_error_type;
					_tmp41_ = vala_code_node_get_source_reference ((ValaCodeNode*) _tmp40_);
					_tmp42_ = _tmp41_;
					_tmp43_ = body_error_type;
					_tmp44_ = vala_code_node_to_string ((ValaCodeNode*) _tmp43_);
					_tmp45_ = _tmp44_;
					vala_report_warning (_tmp42_, "unhandled error `%s'", _tmp45_);
					_g_free0 (_tmp45_);
				}
				_vala_code_node_unref0 (body_error_type);
			}
		}
		_vala_iterable_unref0 (body_errors);
	}
	_tmp46_ = vala_code_context_get_analyzer (context);
	_tmp47_ = _tmp46_;
	_tmp48_ = old_symbol;
	vala_semantic_analyzer_set_current_symbol (_tmp47_, _tmp48_);
	_tmp49_ = vala_code_node_get_error ((ValaCodeNode*) self);
	_tmp50_ = _tmp49_;
	result = !_tmp50_;
	_vala_code_node_unref0 (old_symbol);
	return result;
}

static void
vala_constructor_class_init (ValaConstructorClass * klass,
                             gpointer klass_data)
{
	vala_constructor_parent_class = g_type_class_peek_parent (klass);
	((ValaCodeNodeClass *) klass)->finalize = vala_constructor_finalize;
	g_type_class_adjust_private_offset (klass, &ValaConstructor_private_offset);
	((ValaCodeNodeClass *) klass)->accept = (void (*) (ValaCodeNode*, ValaCodeVisitor*)) vala_constructor_real_accept;
	((ValaCodeNodeClass *) klass)->accept_children = (void (*) (ValaCodeNode*, ValaCodeVisitor*)) vala_constructor_real_accept_children;
	((ValaCodeNodeClass *) klass)->check = (gboolean (*) (ValaCodeNode*, ValaCodeContext*)) vala_constructor_real_check;
	VALA_SUBROUTINE_CLASS (klass)->get_has_result = (gboolean (*) (ValaSubroutine*)) vala_constructor_real_get_has_result;
}

static void
vala_constructor_instance_init (ValaConstructor * self,
                                gpointer klass)
{
	self->priv = vala_constructor_get_instance_private (self);
	self->priv->_binding = VALA_MEMBER_BINDING_INSTANCE;
}

static void
vala_constructor_finalize (ValaCodeNode * obj)
{
	ValaConstructor * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, VALA_TYPE_CONSTRUCTOR, ValaConstructor);
	_vala_code_node_unref0 (self->priv->_this_parameter);
	VALA_CODE_NODE_CLASS (vala_constructor_parent_class)->finalize (obj);
}

/**
 * Represents a class or instance constructor.
 */
static GType
vala_constructor_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ValaConstructorClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) vala_constructor_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ValaConstructor), 0, (GInstanceInitFunc) vala_constructor_instance_init, NULL };
	GType vala_constructor_type_id;
	vala_constructor_type_id = g_type_register_static (VALA_TYPE_SUBROUTINE, "ValaConstructor", &g_define_type_info, 0);
	ValaConstructor_private_offset = g_type_add_instance_private (vala_constructor_type_id, sizeof (ValaConstructorPrivate));
	return vala_constructor_type_id;
}

GType
vala_constructor_get_type (void)
{
	static volatile gsize vala_constructor_type_id__once = 0;
	if (g_once_init_enter (&vala_constructor_type_id__once)) {
		GType vala_constructor_type_id;
		vala_constructor_type_id = vala_constructor_get_type_once ();
		g_once_init_leave (&vala_constructor_type_id__once, vala_constructor_type_id);
	}
	return vala_constructor_type_id__once;
}