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

/* valablock.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 <valagee.h>
#include <glib-object.h>
#include <stdlib.h>
#include <string.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 _ValaBlockPrivate {
	gboolean _contains_jump_statement;
	gboolean _unreachable_exit;
	gboolean _captured;
	ValaList* statement_list;
	ValaList* local_variables;
	ValaList* local_constants;
};

static gint ValaBlock_private_offset;
static gpointer vala_block_parent_class = NULL;
static ValaStatementIface * vala_block_vala_statement_parent_iface = NULL;

static void vala_block_real_accept (ValaCodeNode* base,
                             ValaCodeVisitor* visitor);
static void vala_block_real_accept_children (ValaCodeNode* base,
                                      ValaCodeVisitor* visitor);
static gboolean vala_block_real_check (ValaCodeNode* base,
                                ValaCodeContext* context);
static void vala_block_real_get_error_types (ValaCodeNode* base,
                                      ValaCollection* collection,
                                      ValaSourceReference* source_reference);
static void vala_block_real_emit (ValaCodeNode* base,
                           ValaCodeGenerator* codegen);
static void vala_block_finalize (ValaCodeNode * obj);
static GType vala_block_get_type_once (void);

static inline gpointer
vala_block_get_instance_private (ValaBlock* self)
{
	return G_STRUCT_MEMBER_P (self, ValaBlock_private_offset);
}

gboolean
vala_block_get_contains_jump_statement (ValaBlock* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_contains_jump_statement;
	return result;
}

void
vala_block_set_contains_jump_statement (ValaBlock* self,
                                        gboolean value)
{
	g_return_if_fail (self != NULL);
	self->priv->_contains_jump_statement = value;
}

gboolean
vala_block_get_unreachable_exit (ValaBlock* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_unreachable_exit;
	return result;
}

void
vala_block_set_unreachable_exit (ValaBlock* self,
                                 gboolean value)
{
	g_return_if_fail (self != NULL);
	self->priv->_unreachable_exit = value;
}

gboolean
vala_block_get_captured (ValaBlock* self)
{
	gboolean result;
	g_return_val_if_fail (self != NULL, FALSE);
	result = self->priv->_captured;
	return result;
}

void
vala_block_set_captured (ValaBlock* self,
                         gboolean value)
{
	g_return_if_fail (self != NULL);
	self->priv->_captured = value;
}

/**
 * Creates a new block.
 *
 * @param source_reference  reference to source code
 */
ValaBlock*
vala_block_construct (GType object_type,
                      ValaSourceReference* source_reference)
{
	ValaBlock* self = NULL;
	self = (ValaBlock*) vala_symbol_construct (object_type, NULL, source_reference, NULL);
	return self;
}

ValaBlock*
vala_block_new (ValaSourceReference* source_reference)
{
	return vala_block_construct (VALA_TYPE_BLOCK, source_reference);
}

/**
 * Append a statement to this block.
 *
 * @param stmt a statement
 */
void
vala_block_add_statement (ValaBlock* self,
                          ValaStatement* stmt)
{
	ValaList* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (stmt != NULL);
	vala_code_node_set_parent_node ((ValaCodeNode*) stmt, (ValaCodeNode*) self);
	_tmp0_ = self->priv->statement_list;
	vala_collection_add ((ValaCollection*) _tmp0_, stmt);
}

void
vala_block_insert_statement (ValaBlock* self,
                             gint index,
                             ValaStatement* stmt)
{
	ValaList* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (stmt != NULL);
	vala_code_node_set_parent_node ((ValaCodeNode*) stmt, (ValaCodeNode*) self);
	_tmp0_ = self->priv->statement_list;
	vala_list_insert (_tmp0_, index, stmt);
}

/**
 * Returns a copy of the list of statements.
 *
 * @return statement list
 */
ValaList*
vala_block_get_statements (ValaBlock* self)
{
	ValaArrayList* list = NULL;
	GEqualFunc _tmp0_;
	ValaArrayList* _tmp1_;
	ValaList* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = g_direct_equal;
	_tmp1_ = vala_array_list_new (VALA_TYPE_STATEMENT, (GBoxedCopyFunc) vala_code_node_ref, (GDestroyNotify) vala_code_node_unref, _tmp0_);
	list = _tmp1_;
	{
		ValaList* _stmt_list = NULL;
		ValaList* _tmp2_;
		gint _stmt_size = 0;
		ValaList* _tmp3_;
		gint _tmp4_;
		gint _tmp5_;
		gint _stmt_index = 0;
		_tmp2_ = self->priv->statement_list;
		_stmt_list = _tmp2_;
		_tmp3_ = _stmt_list;
		_tmp4_ = vala_collection_get_size ((ValaCollection*) _tmp3_);
		_tmp5_ = _tmp4_;
		_stmt_size = _tmp5_;
		_stmt_index = -1;
		while (TRUE) {
			gint _tmp6_;
			gint _tmp7_;
			ValaStatement* stmt = NULL;
			ValaList* _tmp8_;
			gpointer _tmp9_;
			ValaStatementList* stmt_list = NULL;
			ValaStatement* _tmp10_;
			ValaStatementList* _tmp11_;
			_stmt_index = _stmt_index + 1;
			_tmp6_ = _stmt_index;
			_tmp7_ = _stmt_size;
			if (!(_tmp6_ < _tmp7_)) {
				break;
			}
			_tmp8_ = _stmt_list;
			_tmp9_ = vala_list_get (_tmp8_, _stmt_index);
			stmt = (ValaStatement*) _tmp9_;
			_tmp10_ = stmt;
			stmt_list = VALA_IS_STATEMENT_LIST (_tmp10_) ? ((ValaStatementList*) _tmp10_) : NULL;
			_tmp11_ = stmt_list;
			if (_tmp11_ != NULL) {
				{
					gint i = 0;
					i = 0;
					{
						gboolean _tmp12_ = FALSE;
						_tmp12_ = TRUE;
						while (TRUE) {
							ValaStatementList* _tmp14_;
							gint _tmp15_;
							gint _tmp16_;
							ValaArrayList* _tmp17_;
							ValaStatementList* _tmp18_;
							ValaStatement* _tmp19_;
							ValaStatement* _tmp20_;
							if (!_tmp12_) {
								gint _tmp13_;
								_tmp13_ = i;
								i = _tmp13_ + 1;
							}
							_tmp12_ = FALSE;
							_tmp14_ = stmt_list;
							_tmp15_ = vala_statement_list_get_length (_tmp14_);
							_tmp16_ = _tmp15_;
							if (!(i < _tmp16_)) {
								break;
							}
							_tmp17_ = list;
							_tmp18_ = stmt_list;
							_tmp19_ = vala_statement_list_get (_tmp18_, i);
							_tmp20_ = _tmp19_;
							vala_collection_add ((ValaCollection*) _tmp17_, _tmp20_);
							_vala_code_node_unref0 (_tmp20_);
						}
					}
				}
			} else {
				ValaArrayList* _tmp21_;
				ValaStatement* _tmp22_;
				_tmp21_ = list;
				_tmp22_ = stmt;
				vala_collection_add ((ValaCollection*) _tmp21_, _tmp22_);
			}
			_vala_code_node_unref0 (stmt);
		}
	}
	result = (ValaList*) list;
	return result;
}

/**
 * Add a local variable to this block.
 *
 * @param local a variable declarator
 */
void
vala_block_add_local_variable (ValaBlock* self,
                               ValaLocalVariable* local)
{
	ValaSymbol* parent_block = NULL;
	ValaSymbol* _tmp0_;
	ValaSymbol* _tmp1_;
	ValaList* _tmp22_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (local != NULL);
	_tmp0_ = vala_symbol_get_parent_symbol ((ValaSymbol*) self);
	_tmp1_ = _tmp0_;
	parent_block = _tmp1_;
	while (TRUE) {
		gboolean _tmp2_ = FALSE;
		gboolean _tmp3_ = FALSE;
		ValaSymbol* _tmp4_;
		ValaSymbol* _tmp7_;
		ValaScope* _tmp8_;
		ValaScope* _tmp9_;
		const gchar* _tmp10_;
		const gchar* _tmp11_;
		ValaSymbol* _tmp12_;
		ValaSymbol* _tmp13_;
		gboolean _tmp14_;
		ValaSymbol* _tmp19_;
		ValaSymbol* _tmp20_;
		ValaSymbol* _tmp21_;
		_tmp4_ = parent_block;
		if (VALA_IS_BLOCK (_tmp4_)) {
			_tmp3_ = TRUE;
		} else {
			ValaSymbol* _tmp5_;
			_tmp5_ = parent_block;
			_tmp3_ = VALA_IS_METHOD (_tmp5_);
		}
		if (_tmp3_) {
			_tmp2_ = TRUE;
		} else {
			ValaSymbol* _tmp6_;
			_tmp6_ = parent_block;
			_tmp2_ = VALA_IS_PROPERTY_ACCESSOR (_tmp6_);
		}
		if (!_tmp2_) {
			break;
		}
		_tmp7_ = parent_block;
		_tmp8_ = vala_symbol_get_scope (_tmp7_);
		_tmp9_ = _tmp8_;
		_tmp10_ = vala_symbol_get_name ((ValaSymbol*) local);
		_tmp11_ = _tmp10_;
		_tmp12_ = vala_scope_lookup (_tmp9_, _tmp11_);
		_tmp13_ = _tmp12_;
		_tmp14_ = _tmp13_ != NULL;
		_vala_code_node_unref0 (_tmp13_);
		if (_tmp14_) {
			ValaSourceReference* _tmp15_;
			ValaSourceReference* _tmp16_;
			const gchar* _tmp17_;
			const gchar* _tmp18_;
			_tmp15_ = vala_code_node_get_source_reference ((ValaCodeNode*) local);
			_tmp16_ = _tmp15_;
			_tmp17_ = vala_symbol_get_name ((ValaSymbol*) local);
			_tmp18_ = _tmp17_;
			vala_report_error (_tmp16_, "Local variable `%s' conflicts with a local variable or constant declar" \
"ed in a parent scope", _tmp18_);
			break;
		}
		_tmp19_ = parent_block;
		_tmp20_ = vala_symbol_get_parent_symbol (_tmp19_);
		_tmp21_ = _tmp20_;
		parent_block = _tmp21_;
	}
	_tmp22_ = self->priv->local_variables;
	vala_collection_add ((ValaCollection*) _tmp22_, local);
}

void
vala_block_remove_local_variable (ValaBlock* self,
                                  ValaLocalVariable* local)
{
	ValaList* _tmp0_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (local != NULL);
	_tmp0_ = self->priv->local_variables;
	vala_collection_remove ((ValaCollection*) _tmp0_, local);
}

/**
 * Returns the list of local variables.
 *
 * @return variable declarator list
 */
ValaList*
vala_block_get_local_variables (ValaBlock* self)
{
	ValaList* _tmp0_;
	ValaList* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->local_variables;
	result = _tmp0_;
	return result;
}

void
vala_block_add_local_constant (ValaBlock* self,
                               ValaConstant* constant)
{
	ValaSymbol* parent_block = NULL;
	ValaSymbol* _tmp0_;
	ValaSymbol* _tmp1_;
	ValaList* _tmp22_;
	ValaScope* _tmp23_;
	ValaScope* _tmp24_;
	const gchar* _tmp25_;
	const gchar* _tmp26_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (constant != NULL);
	_tmp0_ = vala_symbol_get_parent_symbol ((ValaSymbol*) self);
	_tmp1_ = _tmp0_;
	parent_block = _tmp1_;
	while (TRUE) {
		gboolean _tmp2_ = FALSE;
		gboolean _tmp3_ = FALSE;
		ValaSymbol* _tmp4_;
		ValaSymbol* _tmp7_;
		ValaScope* _tmp8_;
		ValaScope* _tmp9_;
		const gchar* _tmp10_;
		const gchar* _tmp11_;
		ValaSymbol* _tmp12_;
		ValaSymbol* _tmp13_;
		gboolean _tmp14_;
		ValaSymbol* _tmp19_;
		ValaSymbol* _tmp20_;
		ValaSymbol* _tmp21_;
		_tmp4_ = parent_block;
		if (VALA_IS_BLOCK (_tmp4_)) {
			_tmp3_ = TRUE;
		} else {
			ValaSymbol* _tmp5_;
			_tmp5_ = parent_block;
			_tmp3_ = VALA_IS_METHOD (_tmp5_);
		}
		if (_tmp3_) {
			_tmp2_ = TRUE;
		} else {
			ValaSymbol* _tmp6_;
			_tmp6_ = parent_block;
			_tmp2_ = VALA_IS_PROPERTY_ACCESSOR (_tmp6_);
		}
		if (!_tmp2_) {
			break;
		}
		_tmp7_ = parent_block;
		_tmp8_ = vala_symbol_get_scope (_tmp7_);
		_tmp9_ = _tmp8_;
		_tmp10_ = vala_symbol_get_name ((ValaSymbol*) constant);
		_tmp11_ = _tmp10_;
		_tmp12_ = vala_scope_lookup (_tmp9_, _tmp11_);
		_tmp13_ = _tmp12_;
		_tmp14_ = _tmp13_ != NULL;
		_vala_code_node_unref0 (_tmp13_);
		if (_tmp14_) {
			ValaSourceReference* _tmp15_;
			ValaSourceReference* _tmp16_;
			const gchar* _tmp17_;
			const gchar* _tmp18_;
			_tmp15_ = vala_code_node_get_source_reference ((ValaCodeNode*) constant);
			_tmp16_ = _tmp15_;
			_tmp17_ = vala_symbol_get_name ((ValaSymbol*) constant);
			_tmp18_ = _tmp17_;
			vala_report_error (_tmp16_, "Local constant `%s' conflicts with a local variable or constant declar" \
"ed in a parent scope", _tmp18_);
			break;
		}
		_tmp19_ = parent_block;
		_tmp20_ = vala_symbol_get_parent_symbol (_tmp19_);
		_tmp21_ = _tmp20_;
		parent_block = _tmp21_;
	}
	_tmp22_ = self->priv->local_constants;
	vala_collection_add ((ValaCollection*) _tmp22_, constant);
	_tmp23_ = vala_symbol_get_scope ((ValaSymbol*) self);
	_tmp24_ = _tmp23_;
	_tmp25_ = vala_symbol_get_name ((ValaSymbol*) constant);
	_tmp26_ = _tmp25_;
	vala_scope_add (_tmp24_, _tmp26_, (ValaSymbol*) constant);
}

/**
 * Returns the list of local constants.
 *
 * @return constants list
 */
ValaList*
vala_block_get_local_constants (ValaBlock* self)
{
	ValaList* _tmp0_;
	ValaList* result;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->local_constants;
	result = _tmp0_;
	return result;
}

static void
vala_block_real_accept (ValaCodeNode* base,
                        ValaCodeVisitor* visitor)
{
	ValaBlock * self;
	self = (ValaBlock*) base;
	g_return_if_fail (visitor != NULL);
	vala_code_visitor_visit_block (visitor, self);
}

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

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

static gboolean
vala_block_real_check (ValaCodeNode* base,
                       ValaCodeContext* context)
{
	ValaBlock * self;
	gboolean _tmp0_;
	gboolean _tmp1_;
	ValaSemanticAnalyzer* _tmp4_;
	ValaSemanticAnalyzer* _tmp5_;
	ValaSymbol* _tmp6_;
	ValaSymbol* _tmp7_;
	ValaScope* _tmp8_;
	ValaScope* _tmp9_;
	ValaSymbol* old_symbol = NULL;
	ValaSemanticAnalyzer* _tmp10_;
	ValaSemanticAnalyzer* _tmp11_;
	ValaSymbol* _tmp12_;
	ValaSymbol* _tmp13_;
	ValaSymbol* _tmp14_;
	ValaBlock* old_insert_block = NULL;
	ValaSemanticAnalyzer* _tmp15_;
	ValaSemanticAnalyzer* _tmp16_;
	ValaBlock* _tmp17_;
	ValaBlock* _tmp18_;
	ValaSemanticAnalyzer* _tmp19_;
	ValaSemanticAnalyzer* _tmp20_;
	ValaSemanticAnalyzer* _tmp21_;
	ValaSemanticAnalyzer* _tmp22_;
	ValaBlock* _tmp23_;
	ValaSemanticAnalyzer* _tmp51_;
	ValaSemanticAnalyzer* _tmp52_;
	ValaSymbol* _tmp53_;
	ValaSemanticAnalyzer* _tmp54_;
	ValaSemanticAnalyzer* _tmp55_;
	ValaBlock* _tmp56_;
	ValaBlock* _tmp57_;
	gboolean _tmp58_;
	gboolean _tmp59_;
	gboolean result;
	self = (ValaBlock*) 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_ = vala_code_context_get_analyzer (context);
	_tmp5_ = _tmp4_;
	_tmp6_ = vala_semantic_analyzer_get_current_symbol (_tmp5_);
	_tmp7_ = _tmp6_;
	_tmp8_ = vala_symbol_get_scope (_tmp7_);
	_tmp9_ = _tmp8_;
	vala_symbol_set_owner ((ValaSymbol*) self, _tmp9_);
	_tmp10_ = vala_code_context_get_analyzer (context);
	_tmp11_ = _tmp10_;
	_tmp12_ = vala_semantic_analyzer_get_current_symbol (_tmp11_);
	_tmp13_ = _tmp12_;
	_tmp14_ = _vala_code_node_ref0 (_tmp13_);
	old_symbol = _tmp14_;
	_tmp15_ = vala_code_context_get_analyzer (context);
	_tmp16_ = _tmp15_;
	_tmp17_ = _tmp16_->insert_block;
	_tmp18_ = _vala_code_node_ref0 (_tmp17_);
	old_insert_block = _tmp18_;
	_tmp19_ = vala_code_context_get_analyzer (context);
	_tmp20_ = _tmp19_;
	vala_semantic_analyzer_set_current_symbol (_tmp20_, (ValaSymbol*) self);
	_tmp21_ = vala_code_context_get_analyzer (context);
	_tmp22_ = _tmp21_;
	_tmp23_ = _vala_code_node_ref0 (self);
	_vala_code_node_unref0 (_tmp22_->insert_block);
	_tmp22_->insert_block = _tmp23_;
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp24_ = FALSE;
			_tmp24_ = TRUE;
			while (TRUE) {
				ValaList* _tmp26_;
				gint _tmp27_;
				gint _tmp28_;
				ValaList* _tmp29_;
				gpointer _tmp30_;
				ValaStatement* _tmp31_;
				gboolean _tmp32_;
				if (!_tmp24_) {
					gint _tmp25_;
					_tmp25_ = i;
					i = _tmp25_ + 1;
				}
				_tmp24_ = FALSE;
				_tmp26_ = self->priv->statement_list;
				_tmp27_ = vala_collection_get_size ((ValaCollection*) _tmp26_);
				_tmp28_ = _tmp27_;
				if (!(i < _tmp28_)) {
					break;
				}
				_tmp29_ = self->priv->statement_list;
				_tmp30_ = vala_list_get (_tmp29_, i);
				_tmp31_ = (ValaStatement*) _tmp30_;
				_tmp32_ = !vala_code_node_check ((ValaCodeNode*) _tmp31_, context);
				_vala_code_node_unref0 (_tmp31_);
				if (_tmp32_) {
					vala_code_node_set_error ((ValaCodeNode*) self, TRUE);
				}
			}
		}
	}
	{
		ValaList* _local_list = NULL;
		ValaList* _tmp33_;
		gint _local_size = 0;
		ValaList* _tmp34_;
		gint _tmp35_;
		gint _tmp36_;
		gint _local_index = 0;
		_tmp33_ = vala_block_get_local_variables (self);
		_local_list = _tmp33_;
		_tmp34_ = _local_list;
		_tmp35_ = vala_collection_get_size ((ValaCollection*) _tmp34_);
		_tmp36_ = _tmp35_;
		_local_size = _tmp36_;
		_local_index = -1;
		while (TRUE) {
			gint _tmp37_;
			gint _tmp38_;
			ValaLocalVariable* local = NULL;
			ValaList* _tmp39_;
			gpointer _tmp40_;
			ValaLocalVariable* _tmp41_;
			_local_index = _local_index + 1;
			_tmp37_ = _local_index;
			_tmp38_ = _local_size;
			if (!(_tmp37_ < _tmp38_)) {
				break;
			}
			_tmp39_ = _local_list;
			_tmp40_ = vala_list_get (_tmp39_, _local_index);
			local = (ValaLocalVariable*) _tmp40_;
			_tmp41_ = local;
			vala_symbol_set_active ((ValaSymbol*) _tmp41_, FALSE);
			_vala_code_node_unref0 (local);
		}
	}
	{
		ValaList* _constant_list = NULL;
		ValaList* _tmp42_;
		gint _constant_size = 0;
		ValaList* _tmp43_;
		gint _tmp44_;
		gint _tmp45_;
		gint _constant_index = 0;
		_tmp42_ = self->priv->local_constants;
		_constant_list = _tmp42_;
		_tmp43_ = _constant_list;
		_tmp44_ = vala_collection_get_size ((ValaCollection*) _tmp43_);
		_tmp45_ = _tmp44_;
		_constant_size = _tmp45_;
		_constant_index = -1;
		while (TRUE) {
			gint _tmp46_;
			gint _tmp47_;
			ValaConstant* constant = NULL;
			ValaList* _tmp48_;
			gpointer _tmp49_;
			ValaConstant* _tmp50_;
			_constant_index = _constant_index + 1;
			_tmp46_ = _constant_index;
			_tmp47_ = _constant_size;
			if (!(_tmp46_ < _tmp47_)) {
				break;
			}
			_tmp48_ = _constant_list;
			_tmp49_ = vala_list_get (_tmp48_, _constant_index);
			constant = (ValaConstant*) _tmp49_;
			_tmp50_ = constant;
			vala_symbol_set_active ((ValaSymbol*) _tmp50_, FALSE);
			_vala_code_node_unref0 (constant);
		}
	}
	_tmp51_ = vala_code_context_get_analyzer (context);
	_tmp52_ = _tmp51_;
	_tmp53_ = old_symbol;
	vala_semantic_analyzer_set_current_symbol (_tmp52_, _tmp53_);
	_tmp54_ = vala_code_context_get_analyzer (context);
	_tmp55_ = _tmp54_;
	_tmp56_ = old_insert_block;
	_tmp57_ = _vala_code_node_ref0 (_tmp56_);
	_vala_code_node_unref0 (_tmp55_->insert_block);
	_tmp55_->insert_block = _tmp57_;
	_tmp58_ = vala_code_node_get_error ((ValaCodeNode*) self);
	_tmp59_ = _tmp58_;
	result = !_tmp59_;
	_vala_code_node_unref0 (old_insert_block);
	_vala_code_node_unref0 (old_symbol);
	return result;
}

static void
vala_block_real_get_error_types (ValaCodeNode* base,
                                 ValaCollection* collection,
                                 ValaSourceReference* source_reference)
{
	ValaBlock * self;
	self = (ValaBlock*) base;
	g_return_if_fail (collection != NULL);
	{
		ValaList* _stmt_list = NULL;
		ValaList* _tmp0_;
		gint _stmt_size = 0;
		ValaList* _tmp1_;
		gint _tmp2_;
		gint _tmp3_;
		gint _stmt_index = 0;
		_tmp0_ = vala_block_get_statements (self);
		_stmt_list = _tmp0_;
		_tmp1_ = _stmt_list;
		_tmp2_ = vala_collection_get_size ((ValaCollection*) _tmp1_);
		_tmp3_ = _tmp2_;
		_stmt_size = _tmp3_;
		_stmt_index = -1;
		while (TRUE) {
			gint _tmp4_;
			gint _tmp5_;
			ValaStatement* stmt = NULL;
			ValaList* _tmp6_;
			gpointer _tmp7_;
			ValaStatement* _tmp8_;
			_stmt_index = _stmt_index + 1;
			_tmp4_ = _stmt_index;
			_tmp5_ = _stmt_size;
			if (!(_tmp4_ < _tmp5_)) {
				break;
			}
			_tmp6_ = _stmt_list;
			_tmp7_ = vala_list_get (_tmp6_, _stmt_index);
			stmt = (ValaStatement*) _tmp7_;
			_tmp8_ = stmt;
			vala_code_node_get_error_types ((ValaCodeNode*) _tmp8_, collection, source_reference);
			_vala_code_node_unref0 (stmt);
		}
		_vala_iterable_unref0 (_stmt_list);
	}
}

static void
vala_block_real_emit (ValaCodeNode* base,
                      ValaCodeGenerator* codegen)
{
	ValaBlock * self;
	self = (ValaBlock*) base;
	g_return_if_fail (codegen != NULL);
	vala_code_visitor_visit_block ((ValaCodeVisitor*) codegen, self);
}

void
vala_block_insert_before (ValaBlock* self,
                          ValaStatement* stmt,
                          ValaStatement* new_stmt)
{
	g_return_if_fail (self != NULL);
	g_return_if_fail (stmt != NULL);
	g_return_if_fail (new_stmt != NULL);
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp0_ = FALSE;
			_tmp0_ = TRUE;
			while (TRUE) {
				ValaList* _tmp2_;
				gint _tmp3_;
				gint _tmp4_;
				ValaStatementList* stmt_list = NULL;
				ValaList* _tmp5_;
				gpointer _tmp6_;
				ValaStatement* _tmp7_;
				ValaStatementList* _tmp8_;
				ValaStatementList* _tmp9_;
				if (!_tmp0_) {
					gint _tmp1_;
					_tmp1_ = i;
					i = _tmp1_ + 1;
				}
				_tmp0_ = FALSE;
				_tmp2_ = self->priv->statement_list;
				_tmp3_ = vala_collection_get_size ((ValaCollection*) _tmp2_);
				_tmp4_ = _tmp3_;
				if (!(i < _tmp4_)) {
					break;
				}
				_tmp5_ = self->priv->statement_list;
				_tmp6_ = vala_list_get (_tmp5_, i);
				_tmp7_ = (ValaStatement*) _tmp6_;
				_tmp8_ = VALA_IS_STATEMENT_LIST (_tmp7_) ? ((ValaStatementList*) _tmp7_) : NULL;
				if (_tmp8_ == NULL) {
					_vala_code_node_unref0 (_tmp7_);
				}
				stmt_list = _tmp8_;
				_tmp9_ = stmt_list;
				if (_tmp9_ != NULL) {
					{
						gint j = 0;
						j = 0;
						{
							gboolean _tmp10_ = FALSE;
							_tmp10_ = TRUE;
							while (TRUE) {
								ValaStatementList* _tmp12_;
								gint _tmp13_;
								gint _tmp14_;
								ValaStatementList* _tmp15_;
								ValaStatement* _tmp16_;
								ValaStatement* _tmp17_;
								gboolean _tmp18_;
								if (!_tmp10_) {
									gint _tmp11_;
									_tmp11_ = j;
									j = _tmp11_ + 1;
								}
								_tmp10_ = FALSE;
								_tmp12_ = stmt_list;
								_tmp13_ = vala_statement_list_get_length (_tmp12_);
								_tmp14_ = _tmp13_;
								if (!(j < _tmp14_)) {
									break;
								}
								_tmp15_ = stmt_list;
								_tmp16_ = vala_statement_list_get (_tmp15_, j);
								_tmp17_ = _tmp16_;
								_tmp18_ = _tmp17_ == stmt;
								_vala_code_node_unref0 (_tmp17_);
								if (_tmp18_) {
									ValaStatementList* _tmp19_;
									_tmp19_ = stmt_list;
									vala_statement_list_insert (_tmp19_, j, new_stmt);
									vala_code_node_set_parent_node ((ValaCodeNode*) new_stmt, (ValaCodeNode*) self);
									break;
								}
							}
						}
					}
				} else {
					ValaList* _tmp20_;
					gpointer _tmp21_;
					ValaStatement* _tmp22_;
					gboolean _tmp23_;
					_tmp20_ = self->priv->statement_list;
					_tmp21_ = vala_list_get (_tmp20_, i);
					_tmp22_ = (ValaStatement*) _tmp21_;
					_tmp23_ = _tmp22_ == stmt;
					_vala_code_node_unref0 (_tmp22_);
					if (_tmp23_) {
						ValaSourceReference* _tmp24_;
						ValaSourceReference* _tmp25_;
						ValaStatementList* _tmp26_;
						ValaStatementList* _tmp27_;
						ValaStatementList* _tmp28_;
						ValaList* _tmp29_;
						ValaStatementList* _tmp30_;
						_tmp24_ = vala_code_node_get_source_reference ((ValaCodeNode*) self);
						_tmp25_ = _tmp24_;
						_tmp26_ = vala_statement_list_new (_tmp25_);
						_vala_code_node_unref0 (stmt_list);
						stmt_list = _tmp26_;
						_tmp27_ = stmt_list;
						vala_statement_list_add (_tmp27_, new_stmt);
						_tmp28_ = stmt_list;
						vala_statement_list_add (_tmp28_, stmt);
						_tmp29_ = self->priv->statement_list;
						_tmp30_ = stmt_list;
						vala_list_set (_tmp29_, i, (ValaStatement*) _tmp30_);
						vala_code_node_set_parent_node ((ValaCodeNode*) new_stmt, (ValaCodeNode*) self);
					}
				}
				_vala_code_node_unref0 (stmt_list);
			}
		}
	}
}

void
vala_block_replace_statement (ValaBlock* self,
                              ValaStatement* old_stmt,
                              ValaStatement* new_stmt)
{
	g_return_if_fail (self != NULL);
	g_return_if_fail (old_stmt != NULL);
	g_return_if_fail (new_stmt != NULL);
	{
		gint i = 0;
		i = 0;
		{
			gboolean _tmp0_ = FALSE;
			_tmp0_ = TRUE;
			while (TRUE) {
				ValaList* _tmp2_;
				gint _tmp3_;
				gint _tmp4_;
				ValaStatementList* stmt_list = NULL;
				ValaList* _tmp5_;
				gpointer _tmp6_;
				ValaStatement* _tmp7_;
				ValaStatementList* _tmp8_;
				ValaStatementList* _tmp9_;
				if (!_tmp0_) {
					gint _tmp1_;
					_tmp1_ = i;
					i = _tmp1_ + 1;
				}
				_tmp0_ = FALSE;
				_tmp2_ = self->priv->statement_list;
				_tmp3_ = vala_collection_get_size ((ValaCollection*) _tmp2_);
				_tmp4_ = _tmp3_;
				if (!(i < _tmp4_)) {
					break;
				}
				_tmp5_ = self->priv->statement_list;
				_tmp6_ = vala_list_get (_tmp5_, i);
				_tmp7_ = (ValaStatement*) _tmp6_;
				_tmp8_ = VALA_IS_STATEMENT_LIST (_tmp7_) ? ((ValaStatementList*) _tmp7_) : NULL;
				if (_tmp8_ == NULL) {
					_vala_code_node_unref0 (_tmp7_);
				}
				stmt_list = _tmp8_;
				_tmp9_ = stmt_list;
				if (_tmp9_ != NULL) {
					{
						gint j = 0;
						j = 0;
						{
							gboolean _tmp10_ = FALSE;
							_tmp10_ = TRUE;
							while (TRUE) {
								ValaStatementList* _tmp12_;
								gint _tmp13_;
								gint _tmp14_;
								ValaStatementList* _tmp15_;
								ValaStatement* _tmp16_;
								ValaStatement* _tmp17_;
								gboolean _tmp18_;
								if (!_tmp10_) {
									gint _tmp11_;
									_tmp11_ = j;
									j = _tmp11_ + 1;
								}
								_tmp10_ = FALSE;
								_tmp12_ = stmt_list;
								_tmp13_ = vala_statement_list_get_length (_tmp12_);
								_tmp14_ = _tmp13_;
								if (!(j < _tmp14_)) {
									break;
								}
								_tmp15_ = stmt_list;
								_tmp16_ = vala_statement_list_get (_tmp15_, j);
								_tmp17_ = _tmp16_;
								_tmp18_ = _tmp17_ == old_stmt;
								_vala_code_node_unref0 (_tmp17_);
								if (_tmp18_) {
									ValaStatementList* _tmp19_;
									_tmp19_ = stmt_list;
									vala_statement_list_set (_tmp19_, j, new_stmt);
									vala_code_node_set_parent_node ((ValaCodeNode*) new_stmt, (ValaCodeNode*) self);
									break;
								}
							}
						}
					}
				} else {
					ValaList* _tmp20_;
					gpointer _tmp21_;
					ValaStatement* _tmp22_;
					gboolean _tmp23_;
					_tmp20_ = self->priv->statement_list;
					_tmp21_ = vala_list_get (_tmp20_, i);
					_tmp22_ = (ValaStatement*) _tmp21_;
					_tmp23_ = _tmp22_ == old_stmt;
					_vala_code_node_unref0 (_tmp22_);
					if (_tmp23_) {
						ValaList* _tmp24_;
						_tmp24_ = self->priv->statement_list;
						vala_list_set (_tmp24_, i, new_stmt);
						vala_code_node_set_parent_node ((ValaCodeNode*) new_stmt, (ValaCodeNode*) self);
						_vala_code_node_unref0 (stmt_list);
						break;
					}
				}
				_vala_code_node_unref0 (stmt_list);
			}
		}
	}
}

static void
vala_block_class_init (ValaBlockClass * klass,
                       gpointer klass_data)
{
	vala_block_parent_class = g_type_class_peek_parent (klass);
	((ValaCodeNodeClass *) klass)->finalize = vala_block_finalize;
	g_type_class_adjust_private_offset (klass, &ValaBlock_private_offset);
	((ValaCodeNodeClass *) klass)->accept = (void (*) (ValaCodeNode*, ValaCodeVisitor*)) vala_block_real_accept;
	((ValaCodeNodeClass *) klass)->accept_children = (void (*) (ValaCodeNode*, ValaCodeVisitor*)) vala_block_real_accept_children;
	((ValaCodeNodeClass *) klass)->check = (gboolean (*) (ValaCodeNode*, ValaCodeContext*)) vala_block_real_check;
	((ValaCodeNodeClass *) klass)->get_error_types = (void (*) (ValaCodeNode*, ValaCollection*, ValaSourceReference*)) vala_block_real_get_error_types;
	((ValaCodeNodeClass *) klass)->emit = (void (*) (ValaCodeNode*, ValaCodeGenerator*)) vala_block_real_emit;
}

static void
vala_block_vala_statement_interface_init (ValaStatementIface * iface,
                                          gpointer iface_data)
{
	vala_block_vala_statement_parent_iface = g_type_interface_peek_parent (iface);
}

static void
vala_block_instance_init (ValaBlock * self,
                          gpointer klass)
{
	GEqualFunc _tmp0_;
	ValaArrayList* _tmp1_;
	GEqualFunc _tmp2_;
	ValaArrayList* _tmp3_;
	GEqualFunc _tmp4_;
	ValaArrayList* _tmp5_;
	self->priv = vala_block_get_instance_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->statement_list = (ValaList*) _tmp1_;
	_tmp2_ = g_direct_equal;
	_tmp3_ = vala_array_list_new (VALA_TYPE_LOCAL_VARIABLE, (GBoxedCopyFunc) vala_code_node_ref, (GDestroyNotify) vala_code_node_unref, _tmp2_);
	self->priv->local_variables = (ValaList*) _tmp3_;
	_tmp4_ = g_direct_equal;
	_tmp5_ = vala_array_list_new (VALA_TYPE_CONSTANT, (GBoxedCopyFunc) vala_code_node_ref, (GDestroyNotify) vala_code_node_unref, _tmp4_);
	self->priv->local_constants = (ValaList*) _tmp5_;
}

static void
vala_block_finalize (ValaCodeNode * obj)
{
	ValaBlock * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, VALA_TYPE_BLOCK, ValaBlock);
	_vala_iterable_unref0 (self->priv->statement_list);
	_vala_iterable_unref0 (self->priv->local_variables);
	_vala_iterable_unref0 (self->priv->local_constants);
	VALA_CODE_NODE_CLASS (vala_block_parent_class)->finalize (obj);
}

/**
 * Represents a source code block.
 */
static GType
vala_block_get_type_once (void)
{
	static const GTypeInfo g_define_type_info = { sizeof (ValaBlockClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) vala_block_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ValaBlock), 0, (GInstanceInitFunc) vala_block_instance_init, NULL };
	static const GInterfaceInfo vala_statement_info = { (GInterfaceInitFunc) vala_block_vala_statement_interface_init, (GInterfaceFinalizeFunc) NULL, NULL};
	GType vala_block_type_id;
	vala_block_type_id = g_type_register_static (VALA_TYPE_SYMBOL, "ValaBlock", &g_define_type_info, 0);
	g_type_add_interface_static (vala_block_type_id, VALA_TYPE_STATEMENT, &vala_statement_info);
	ValaBlock_private_offset = g_type_add_instance_private (vala_block_type_id, sizeof (ValaBlockPrivate));
	return vala_block_type_id;
}

GType
vala_block_get_type (void)
{
	static volatile gsize vala_block_type_id__once = 0;
	if (g_once_init_enter (&vala_block_type_id__once)) {
		GType vala_block_type_id;
		vala_block_type_id = vala_block_get_type_once ();
		g_once_init_leave (&vala_block_type_id__once, vala_block_type_id);
	}
	return vala_block_type_id__once;
}

