/* valasubroutine.c generated by valac, the Vala compiler
 * generated from valasubroutine.vala, do not modify */

/* valasubroutine.vala
 *
 * Copyright (C) 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 <glib.h>
#include <glib-object.h>
#include "vala.h"
#include <stdlib.h>
#include <string.h>

#define _vala_code_node_unref0(var) ((var == NULL) ? NULL : (var = (vala_code_node_unref (var), NULL)))
#define _vala_basic_block_unref0(var) ((var == NULL) ? NULL : (var = (vala_basic_block_unref (var), NULL)))

struct _ValaSubroutinePrivate {
	ValaBlock* _body;
	ValaBasicBlock* _entry_block;
	ValaBasicBlock* _return_block;
	ValaBasicBlock* _exit_block;
	ValaLocalVariable* _result_var;
};


static gpointer vala_subroutine_parent_class = NULL;

#define VALA_SUBROUTINE_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), VALA_TYPE_SUBROUTINE, ValaSubroutinePrivate))
static void vala_subroutine_finalize (ValaCodeNode * obj);


ValaSubroutine* vala_subroutine_construct (GType object_type, const gchar* name, ValaSourceReference* source_reference, ValaComment* comment) {
	ValaSubroutine* self = NULL;
	const gchar* _tmp0_;
	ValaSourceReference* _tmp1_;
	ValaComment* _tmp2_;
	_tmp0_ = name;
	_tmp1_ = source_reference;
	_tmp2_ = comment;
	self = (ValaSubroutine*) vala_symbol_construct (object_type, _tmp0_, _tmp1_, _tmp2_);
	return self;
}


ValaBasicBlock* vala_subroutine_get_entry_block (ValaSubroutine* self) {
	ValaBasicBlock* result;
	ValaBasicBlock* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_entry_block;
	result = _tmp0_;
	return result;
}


static gpointer _vala_basic_block_ref0 (gpointer self) {
	return self ? vala_basic_block_ref (self) : NULL;
}


void vala_subroutine_set_entry_block (ValaSubroutine* self, ValaBasicBlock* value) {
	ValaBasicBlock* _tmp0_;
	ValaBasicBlock* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	_tmp1_ = _vala_basic_block_ref0 (_tmp0_);
	_vala_basic_block_unref0 (self->priv->_entry_block);
	self->priv->_entry_block = _tmp1_;
}


ValaBasicBlock* vala_subroutine_get_return_block (ValaSubroutine* self) {
	ValaBasicBlock* result;
	ValaBasicBlock* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_return_block;
	result = _tmp0_;
	return result;
}


void vala_subroutine_set_return_block (ValaSubroutine* self, ValaBasicBlock* value) {
	ValaBasicBlock* _tmp0_;
	ValaBasicBlock* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	_tmp1_ = _vala_basic_block_ref0 (_tmp0_);
	_vala_basic_block_unref0 (self->priv->_return_block);
	self->priv->_return_block = _tmp1_;
}


ValaBasicBlock* vala_subroutine_get_exit_block (ValaSubroutine* self) {
	ValaBasicBlock* result;
	ValaBasicBlock* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_exit_block;
	result = _tmp0_;
	return result;
}


void vala_subroutine_set_exit_block (ValaSubroutine* self, ValaBasicBlock* value) {
	ValaBasicBlock* _tmp0_;
	ValaBasicBlock* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	_tmp1_ = _vala_basic_block_ref0 (_tmp0_);
	_vala_basic_block_unref0 (self->priv->_exit_block);
	self->priv->_exit_block = _tmp1_;
}


ValaLocalVariable* vala_subroutine_get_result_var (ValaSubroutine* self) {
	ValaLocalVariable* result;
	ValaLocalVariable* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_result_var;
	result = _tmp0_;
	return result;
}


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


void vala_subroutine_set_result_var (ValaSubroutine* self, ValaLocalVariable* value) {
	ValaLocalVariable* _tmp0_;
	ValaLocalVariable* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	_tmp1_ = _vala_code_node_ref0 (_tmp0_);
	_vala_code_node_unref0 (self->priv->_result_var);
	self->priv->_result_var = _tmp1_;
}


gboolean vala_subroutine_get_has_result (ValaSubroutine* self) {
	g_return_val_if_fail (self != NULL, FALSE);
	return VALA_SUBROUTINE_GET_CLASS (self)->get_has_result (self);
}


ValaBlock* vala_subroutine_get_body (ValaSubroutine* self) {
	ValaBlock* result;
	ValaBlock* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_body;
	result = _tmp0_;
	return result;
}


void vala_subroutine_set_body (ValaSubroutine* self, ValaBlock* value) {
	ValaBlock* _tmp0_;
	ValaBlock* _tmp1_;
	ValaBlock* _tmp2_;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	_tmp1_ = _vala_code_node_ref0 (_tmp0_);
	_vala_code_node_unref0 (self->priv->_body);
	self->priv->_body = _tmp1_;
	_tmp2_ = self->priv->_body;
	if (_tmp2_ != NULL) {
		ValaBlock* _tmp3_;
		ValaScope* _tmp4_;
		ValaScope* _tmp5_;
		ValaBlock* _tmp6_;
		_tmp3_ = self->priv->_body;
		_tmp4_ = vala_symbol_get_scope ((ValaSymbol*) self);
		_tmp5_ = _tmp4_;
		vala_symbol_set_owner ((ValaSymbol*) _tmp3_, _tmp5_);
		_tmp6_ = self->priv->_body;
		vala_code_node_set_parent_node ((ValaCodeNode*) _tmp6_, (ValaCodeNode*) self);
	}
}


static void vala_subroutine_class_init (ValaSubroutineClass * klass) {
	vala_subroutine_parent_class = g_type_class_peek_parent (klass);
	((ValaCodeNodeClass *) klass)->finalize = vala_subroutine_finalize;
	g_type_class_add_private (klass, sizeof (ValaSubroutinePrivate));
}


static void vala_subroutine_instance_init (ValaSubroutine * self) {
	self->priv = VALA_SUBROUTINE_GET_PRIVATE (self);
}


static void vala_subroutine_finalize (ValaCodeNode * obj) {
	ValaSubroutine * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, VALA_TYPE_SUBROUTINE, ValaSubroutine);
	_vala_code_node_unref0 (self->priv->_body);
	_vala_basic_block_unref0 (self->priv->_entry_block);
	_vala_basic_block_unref0 (self->priv->_return_block);
	_vala_basic_block_unref0 (self->priv->_exit_block);
	_vala_code_node_unref0 (self->priv->_result_var);
	VALA_CODE_NODE_CLASS (vala_subroutine_parent_class)->finalize (obj);
}


GType vala_subroutine_get_type (void) {
	static volatile gsize vala_subroutine_type_id__volatile = 0;
	if (g_once_init_enter (&vala_subroutine_type_id__volatile)) {
		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 };
		GType vala_subroutine_type_id;
		vala_subroutine_type_id = g_type_register_static (VALA_TYPE_SYMBOL, "ValaSubroutine", &g_define_type_info, G_TYPE_FLAG_ABSTRACT);
		g_once_init_leave (&vala_subroutine_type_id__volatile, vala_subroutine_type_id);
	}
	return vala_subroutine_type_id__volatile;
}



