1 /* valasubroutine.c generated by valac, the Vala compiler
2 * generated from valasubroutine.vala, do not modify */
3
4 /* valasubroutine.vala
5 *
6 * Copyright (C) 2010 Jürg Billeter
7 *
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
12
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
17
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
21 *
22 * Author:
23 * Jürg Billeter <j@bitron.ch>
24 */
25
26 #include "vala.h"
27 #include <glib.h>
28 #include <stdlib.h>
29 #include <string.h>
30
31 #define _vala_code_node_unref0(var) ((var == NULL) ? NULL : (var = (vala_code_node_unref (var), NULL)))
32 #define _vala_basic_block_unref0(var) ((var == NULL) ? NULL : (var = (vala_basic_block_unref (var), NULL)))
33
34 struct _ValaSubroutinePrivate {
35 ValaBlock* _body;
36 ValaBasicBlock* _entry_block;
37 ValaBasicBlock* _return_block;
38 ValaBasicBlock* _exit_block;
39 ValaLocalVariable* _result_var;
40 };
41
42 static gint ValaSubroutine_private_offset;
43 static gpointer vala_subroutine_parent_class = NULL;
44
45 static void vala_subroutine_finalize (ValaCodeNode * obj);
46 static GType vala_subroutine_get_type_once (void);
47
48 static inline gpointer
vala_subroutine_get_instance_private(ValaSubroutine * self)49 vala_subroutine_get_instance_private (ValaSubroutine* self)
50 {
51 return G_STRUCT_MEMBER_P (self, ValaSubroutine_private_offset);
52 }
53
54 ValaBasicBlock*
vala_subroutine_get_entry_block(ValaSubroutine * self)55 vala_subroutine_get_entry_block (ValaSubroutine* self)
56 {
57 ValaBasicBlock* result;
58 ValaBasicBlock* _tmp0_;
59 g_return_val_if_fail (self != NULL, NULL);
60 _tmp0_ = self->priv->_entry_block;
61 result = _tmp0_;
62 return result;
63 }
64
65 static gpointer
_vala_basic_block_ref0(gpointer self)66 _vala_basic_block_ref0 (gpointer self)
67 {
68 return self ? vala_basic_block_ref (self) : NULL;
69 }
70
71 void
vala_subroutine_set_entry_block(ValaSubroutine * self,ValaBasicBlock * value)72 vala_subroutine_set_entry_block (ValaSubroutine* self,
73 ValaBasicBlock* value)
74 {
75 ValaBasicBlock* _tmp0_;
76 g_return_if_fail (self != NULL);
77 _tmp0_ = _vala_basic_block_ref0 (value);
78 _vala_basic_block_unref0 (self->priv->_entry_block);
79 self->priv->_entry_block = _tmp0_;
80 }
81
82 ValaBasicBlock*
vala_subroutine_get_return_block(ValaSubroutine * self)83 vala_subroutine_get_return_block (ValaSubroutine* self)
84 {
85 ValaBasicBlock* result;
86 ValaBasicBlock* _tmp0_;
87 g_return_val_if_fail (self != NULL, NULL);
88 _tmp0_ = self->priv->_return_block;
89 result = _tmp0_;
90 return result;
91 }
92
93 void
vala_subroutine_set_return_block(ValaSubroutine * self,ValaBasicBlock * value)94 vala_subroutine_set_return_block (ValaSubroutine* self,
95 ValaBasicBlock* value)
96 {
97 ValaBasicBlock* _tmp0_;
98 g_return_if_fail (self != NULL);
99 _tmp0_ = _vala_basic_block_ref0 (value);
100 _vala_basic_block_unref0 (self->priv->_return_block);
101 self->priv->_return_block = _tmp0_;
102 }
103
104 ValaBasicBlock*
vala_subroutine_get_exit_block(ValaSubroutine * self)105 vala_subroutine_get_exit_block (ValaSubroutine* self)
106 {
107 ValaBasicBlock* result;
108 ValaBasicBlock* _tmp0_;
109 g_return_val_if_fail (self != NULL, NULL);
110 _tmp0_ = self->priv->_exit_block;
111 result = _tmp0_;
112 return result;
113 }
114
115 void
vala_subroutine_set_exit_block(ValaSubroutine * self,ValaBasicBlock * value)116 vala_subroutine_set_exit_block (ValaSubroutine* self,
117 ValaBasicBlock* value)
118 {
119 ValaBasicBlock* _tmp0_;
120 g_return_if_fail (self != NULL);
121 _tmp0_ = _vala_basic_block_ref0 (value);
122 _vala_basic_block_unref0 (self->priv->_exit_block);
123 self->priv->_exit_block = _tmp0_;
124 }
125
126 ValaLocalVariable*
vala_subroutine_get_result_var(ValaSubroutine * self)127 vala_subroutine_get_result_var (ValaSubroutine* self)
128 {
129 ValaLocalVariable* result;
130 ValaLocalVariable* _tmp0_;
131 g_return_val_if_fail (self != NULL, NULL);
132 _tmp0_ = self->priv->_result_var;
133 result = _tmp0_;
134 return result;
135 }
136
137 static gpointer
_vala_code_node_ref0(gpointer self)138 _vala_code_node_ref0 (gpointer self)
139 {
140 return self ? vala_code_node_ref (self) : NULL;
141 }
142
143 void
vala_subroutine_set_result_var(ValaSubroutine * self,ValaLocalVariable * value)144 vala_subroutine_set_result_var (ValaSubroutine* self,
145 ValaLocalVariable* value)
146 {
147 ValaLocalVariable* _tmp0_;
148 g_return_if_fail (self != NULL);
149 _tmp0_ = _vala_code_node_ref0 (value);
150 _vala_code_node_unref0 (self->priv->_result_var);
151 self->priv->_result_var = _tmp0_;
152 }
153
154 gboolean
vala_subroutine_get_has_result(ValaSubroutine * self)155 vala_subroutine_get_has_result (ValaSubroutine* self)
156 {
157 g_return_val_if_fail (self != NULL, FALSE);
158 return VALA_SUBROUTINE_GET_CLASS (self)->get_has_result (self);
159 }
160
161 ValaSubroutine*
vala_subroutine_construct(GType object_type,const gchar * name,ValaSourceReference * source_reference,ValaComment * comment)162 vala_subroutine_construct (GType object_type,
163 const gchar* name,
164 ValaSourceReference* source_reference,
165 ValaComment* comment)
166 {
167 ValaSubroutine* self = NULL;
168 self = (ValaSubroutine*) vala_symbol_construct (object_type, name, source_reference, comment);
169 return self;
170 }
171
172 ValaBlock*
vala_subroutine_get_body(ValaSubroutine * self)173 vala_subroutine_get_body (ValaSubroutine* self)
174 {
175 ValaBlock* result;
176 ValaBlock* _tmp0_;
177 g_return_val_if_fail (self != NULL, NULL);
178 _tmp0_ = self->priv->_body;
179 result = _tmp0_;
180 return result;
181 }
182
183 void
vala_subroutine_set_body(ValaSubroutine * self,ValaBlock * value)184 vala_subroutine_set_body (ValaSubroutine* self,
185 ValaBlock* value)
186 {
187 ValaBlock* _tmp0_;
188 ValaBlock* _tmp1_;
189 g_return_if_fail (self != NULL);
190 _tmp0_ = _vala_code_node_ref0 (value);
191 _vala_code_node_unref0 (self->priv->_body);
192 self->priv->_body = _tmp0_;
193 _tmp1_ = self->priv->_body;
194 if (_tmp1_ != NULL) {
195 ValaBlock* _tmp2_;
196 ValaScope* _tmp3_;
197 ValaScope* _tmp4_;
198 ValaBlock* _tmp5_;
199 _tmp2_ = self->priv->_body;
200 _tmp3_ = vala_symbol_get_scope ((ValaSymbol*) self);
201 _tmp4_ = _tmp3_;
202 vala_symbol_set_owner ((ValaSymbol*) _tmp2_, _tmp4_);
203 _tmp5_ = self->priv->_body;
204 vala_code_node_set_parent_node ((ValaCodeNode*) _tmp5_, (ValaCodeNode*) self);
205 }
206 }
207
208 static void
vala_subroutine_class_init(ValaSubroutineClass * klass,gpointer klass_data)209 vala_subroutine_class_init (ValaSubroutineClass * klass,
210 gpointer klass_data)
211 {
212 vala_subroutine_parent_class = g_type_class_peek_parent (klass);
213 ((ValaCodeNodeClass *) klass)->finalize = vala_subroutine_finalize;
214 g_type_class_adjust_private_offset (klass, &ValaSubroutine_private_offset);
215 }
216
217 static void
vala_subroutine_instance_init(ValaSubroutine * self,gpointer klass)218 vala_subroutine_instance_init (ValaSubroutine * self,
219 gpointer klass)
220 {
221 self->priv = vala_subroutine_get_instance_private (self);
222 }
223
224 static void
vala_subroutine_finalize(ValaCodeNode * obj)225 vala_subroutine_finalize (ValaCodeNode * obj)
226 {
227 ValaSubroutine * self;
228 self = G_TYPE_CHECK_INSTANCE_CAST (obj, VALA_TYPE_SUBROUTINE, ValaSubroutine);
229 _vala_code_node_unref0 (self->priv->_body);
230 _vala_basic_block_unref0 (self->priv->_entry_block);
231 _vala_basic_block_unref0 (self->priv->_return_block);
232 _vala_basic_block_unref0 (self->priv->_exit_block);
233 _vala_code_node_unref0 (self->priv->_result_var);
234 VALA_CODE_NODE_CLASS (vala_subroutine_parent_class)->finalize (obj);
235 }
236
237 static GType
vala_subroutine_get_type_once(void)238 vala_subroutine_get_type_once (void)
239 {
240 static const GTypeInfo g_define_type_info = { sizeof (ValaSubroutineClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) vala_subroutine_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ValaSubroutine), 0, (GInstanceInitFunc) vala_subroutine_instance_init, NULL };
241 GType vala_subroutine_type_id;
242 vala_subroutine_type_id = g_type_register_static (VALA_TYPE_SYMBOL, "ValaSubroutine", &g_define_type_info, G_TYPE_FLAG_ABSTRACT);
243 ValaSubroutine_private_offset = g_type_add_instance_private (vala_subroutine_type_id, sizeof (ValaSubroutinePrivate));
244 return vala_subroutine_type_id;
245 }
246
247 GType
vala_subroutine_get_type(void)248 vala_subroutine_get_type (void)
249 {
250 static volatile gsize vala_subroutine_type_id__volatile = 0;
251 if (g_once_init_enter (&vala_subroutine_type_id__volatile)) {
252 GType vala_subroutine_type_id;
253 vala_subroutine_type_id = vala_subroutine_get_type_once ();
254 g_once_init_leave (&vala_subroutine_type_id__volatile, vala_subroutine_type_id);
255 }
256 return vala_subroutine_type_id__volatile;
257 }
258
259