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

/* valastatementlist.vala
 *
 * Copyright (C) 2008-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 <valagee.h>

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

struct _ValaStatementListPrivate {
	ValaList* list;
};


static gpointer vala_statement_list_parent_class = NULL;
static ValaStatementIface * vala_statement_list_vala_statement_parent_iface = NULL;

#define VALA_STATEMENT_LIST_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), VALA_TYPE_STATEMENT_LIST, ValaStatementListPrivate))
static void vala_statement_list_real_accept (ValaCodeNode* base, ValaCodeVisitor* visitor);
static void vala_statement_list_real_emit (ValaCodeNode* base, ValaCodeGenerator* codegen);
static void vala_statement_list_finalize (ValaCodeNode * obj);


ValaStatementList* vala_statement_list_construct (GType object_type, ValaSourceReference* source_reference) {
	ValaStatementList* self = NULL;
	ValaSourceReference* _tmp0_;
	g_return_val_if_fail (source_reference != NULL, NULL);
	self = (ValaStatementList*) vala_code_node_construct (object_type);
	_tmp0_ = source_reference;
	vala_code_node_set_source_reference ((ValaCodeNode*) self, _tmp0_);
	return self;
}


ValaStatementList* vala_statement_list_new (ValaSourceReference* source_reference) {
	return vala_statement_list_construct (VALA_TYPE_STATEMENT_LIST, source_reference);
}


ValaStatement* vala_statement_list_get (ValaStatementList* self, gint index) {
	ValaStatement* result = NULL;
	ValaList* _tmp0_;
	gint _tmp1_;
	gpointer _tmp2_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->list;
	_tmp1_ = index;
	_tmp2_ = vala_list_get (_tmp0_, _tmp1_);
	result = (ValaStatement*) _tmp2_;
	return result;
}


void vala_statement_list_set (ValaStatementList* self, gint index, ValaStatement* stmt) {
	ValaList* _tmp0_;
	gint _tmp1_;
	ValaStatement* _tmp2_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (stmt != NULL);
	_tmp0_ = self->priv->list;
	_tmp1_ = index;
	_tmp2_ = stmt;
	vala_list_set (_tmp0_, _tmp1_, _tmp2_);
}


void vala_statement_list_add (ValaStatementList* self, ValaStatement* stmt) {
	ValaList* _tmp0_;
	ValaStatement* _tmp1_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (stmt != NULL);
	_tmp0_ = self->priv->list;
	_tmp1_ = stmt;
	vala_collection_add ((ValaCollection*) _tmp0_, _tmp1_);
}


void vala_statement_list_insert (ValaStatementList* self, gint index, ValaStatement* stmt) {
	ValaList* _tmp0_;
	gint _tmp1_;
	ValaStatement* _tmp2_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (stmt != NULL);
	_tmp0_ = self->priv->list;
	_tmp1_ = index;
	_tmp2_ = stmt;
	vala_list_insert (_tmp0_, _tmp1_, _tmp2_);
}


static gpointer _vala_iterable_ref0 (gpointer self) {
	return self ? vala_iterable_ref (self) : NULL;
}


static void vala_statement_list_real_accept (ValaCodeNode* base, ValaCodeVisitor* visitor) {
	ValaStatementList * self;
	self = (ValaStatementList*) base;
	g_return_if_fail (visitor != NULL);
	{
		ValaList* _stmt_list = NULL;
		ValaList* _tmp0_;
		ValaList* _tmp1_;
		gint _stmt_size = 0;
		ValaList* _tmp2_;
		gint _tmp3_;
		gint _tmp4_;
		gint _stmt_index = 0;
		_tmp0_ = self->priv->list;
		_tmp1_ = _vala_iterable_ref0 (_tmp0_);
		_stmt_list = _tmp1_;
		_tmp2_ = _stmt_list;
		_tmp3_ = vala_collection_get_size ((ValaCollection*) _tmp2_);
		_tmp4_ = _tmp3_;
		_stmt_size = _tmp4_;
		_stmt_index = -1;
		while (TRUE) {
			gint _tmp5_;
			gint _tmp6_;
			gint _tmp7_;
			ValaStatement* stmt = NULL;
			ValaList* _tmp8_;
			gint _tmp9_;
			gpointer _tmp10_;
			ValaStatement* _tmp11_;
			ValaCodeVisitor* _tmp12_;
			_tmp5_ = _stmt_index;
			_stmt_index = _tmp5_ + 1;
			_tmp6_ = _stmt_index;
			_tmp7_ = _stmt_size;
			if (!(_tmp6_ < _tmp7_)) {
				break;
			}
			_tmp8_ = _stmt_list;
			_tmp9_ = _stmt_index;
			_tmp10_ = vala_list_get (_tmp8_, _tmp9_);
			stmt = (ValaStatement*) _tmp10_;
			_tmp11_ = stmt;
			_tmp12_ = visitor;
			vala_code_node_accept ((ValaCodeNode*) _tmp11_, _tmp12_);
			_vala_code_node_unref0 (stmt);
		}
		_vala_iterable_unref0 (_stmt_list);
	}
}


static void vala_statement_list_real_emit (ValaCodeNode* base, ValaCodeGenerator* codegen) {
	ValaStatementList * self;
	self = (ValaStatementList*) base;
	g_return_if_fail (codegen != NULL);
	{
		ValaList* _stmt_list = NULL;
		ValaList* _tmp0_;
		ValaList* _tmp1_;
		gint _stmt_size = 0;
		ValaList* _tmp2_;
		gint _tmp3_;
		gint _tmp4_;
		gint _stmt_index = 0;
		_tmp0_ = self->priv->list;
		_tmp1_ = _vala_iterable_ref0 (_tmp0_);
		_stmt_list = _tmp1_;
		_tmp2_ = _stmt_list;
		_tmp3_ = vala_collection_get_size ((ValaCollection*) _tmp2_);
		_tmp4_ = _tmp3_;
		_stmt_size = _tmp4_;
		_stmt_index = -1;
		while (TRUE) {
			gint _tmp5_;
			gint _tmp6_;
			gint _tmp7_;
			ValaStatement* stmt = NULL;
			ValaList* _tmp8_;
			gint _tmp9_;
			gpointer _tmp10_;
			ValaStatement* _tmp11_;
			ValaCodeGenerator* _tmp12_;
			_tmp5_ = _stmt_index;
			_stmt_index = _tmp5_ + 1;
			_tmp6_ = _stmt_index;
			_tmp7_ = _stmt_size;
			if (!(_tmp6_ < _tmp7_)) {
				break;
			}
			_tmp8_ = _stmt_list;
			_tmp9_ = _stmt_index;
			_tmp10_ = vala_list_get (_tmp8_, _tmp9_);
			stmt = (ValaStatement*) _tmp10_;
			_tmp11_ = stmt;
			_tmp12_ = codegen;
			vala_code_node_emit ((ValaCodeNode*) _tmp11_, _tmp12_);
			_vala_code_node_unref0 (stmt);
		}
		_vala_iterable_unref0 (_stmt_list);
	}
}


gint vala_statement_list_get_length (ValaStatementList* self) {
	gint result;
	ValaList* _tmp0_;
	gint _tmp1_;
	gint _tmp2_;
	g_return_val_if_fail (self != NULL, 0);
	_tmp0_ = self->priv->list;
	_tmp1_ = vala_collection_get_size ((ValaCollection*) _tmp0_);
	_tmp2_ = _tmp1_;
	result = _tmp2_;
	return result;
}


static void vala_statement_list_class_init (ValaStatementListClass * klass) {
	vala_statement_list_parent_class = g_type_class_peek_parent (klass);
	((ValaCodeNodeClass *) klass)->finalize = vala_statement_list_finalize;
	g_type_class_add_private (klass, sizeof (ValaStatementListPrivate));
	((ValaCodeNodeClass *) klass)->accept = (void (*) (ValaCodeNode *, ValaCodeVisitor*)) vala_statement_list_real_accept;
	((ValaCodeNodeClass *) klass)->emit = (void (*) (ValaCodeNode *, ValaCodeGenerator*)) vala_statement_list_real_emit;
}


static void vala_statement_list_vala_statement_interface_init (ValaStatementIface * iface) {
	vala_statement_list_vala_statement_parent_iface = g_type_interface_peek_parent (iface);
}


static void vala_statement_list_instance_init (ValaStatementList * self) {
	GEqualFunc _tmp0_;
	ValaArrayList* _tmp1_;
	self->priv = VALA_STATEMENT_LIST_GET_PRIVATE (self);
	_tmp0_ = g_direct_equal;
	_tmp1_ = vala_array_list_new (VALA_TYPE_STATEMENT, (GBoxedCopyFunc) vala_code_node_ref, (GDestroyNotify) vala_code_node_unref, _tmp0_);
	self->priv->list = (ValaList*) _tmp1_;
}


static void vala_statement_list_finalize (ValaCodeNode * obj) {
	ValaStatementList * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, VALA_TYPE_STATEMENT_LIST, ValaStatementList);
	_vala_iterable_unref0 (self->priv->list);
	VALA_CODE_NODE_CLASS (vala_statement_list_parent_class)->finalize (obj);
}


GType vala_statement_list_get_type (void) {
	static volatile gsize vala_statement_list_type_id__volatile = 0;
	if (g_once_init_enter (&vala_statement_list_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (ValaStatementListClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) vala_statement_list_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ValaStatementList), 0, (GInstanceInitFunc) vala_statement_list_instance_init, NULL };
		static const GInterfaceInfo vala_statement_info = { (GInterfaceInitFunc) vala_statement_list_vala_statement_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
		GType vala_statement_list_type_id;
		vala_statement_list_type_id = g_type_register_static (VALA_TYPE_CODE_NODE, "ValaStatementList", &g_define_type_info, 0);
		g_type_add_interface_static (vala_statement_list_type_id, VALA_TYPE_STATEMENT, &vala_statement_info);
		g_once_init_leave (&vala_statement_list_type_id__volatile, vala_statement_list_type_id);
	}
	return vala_statement_list_type_id__volatile;
}



