/* 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 <glib.h>
#include <glib-object.h>
#include "vala.h"
#include <valagee.h>
#include <stdlib.h>
#include <string.h>

#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 gpointer vala_constructor_parent_class = NULL;

#define VALA_CONSTRUCTOR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), VALA_TYPE_CONSTRUCTOR, ValaConstructorPrivate))
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);


/**
 * 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;
	ValaSourceReference* _tmp0_;
	_tmp0_ = source;
	self = (ValaConstructor*) vala_subroutine_construct (object_type, NULL, _tmp0_, 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;
	ValaCodeVisitor* _tmp0_;
	self = (ValaConstructor*) base;
	g_return_if_fail (visitor != NULL);
	_tmp0_ = visitor;
	vala_code_visitor_visit_constructor (_tmp0_, 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_;
		ValaCodeVisitor* _tmp4_;
		_tmp2_ = vala_subroutine_get_body ((ValaSubroutine*) self);
		_tmp3_ = _tmp2_;
		_tmp4_ = visitor;
		vala_code_node_accept ((ValaCodeNode*) _tmp3_, _tmp4_);
	}
}


static gboolean vala_constructor_real_check (ValaCodeNode* base, ValaCodeContext* context) {
	ValaConstructor * self;
	gboolean result = FALSE;
	gboolean _tmp0_;
	gboolean _tmp1_;
	ValaCodeContext* _tmp4_;
	ValaSemanticAnalyzer* _tmp5_;
	ValaSemanticAnalyzer* _tmp6_;
	ValaClass* _tmp7_;
	ValaClass* _tmp8_;
	ValaObjectType* _tmp9_;
	ValaObjectType* _tmp10_;
	ValaParameter* _tmp11_;
	ValaParameter* _tmp12_;
	ValaScope* _tmp13_;
	ValaScope* _tmp14_;
	ValaParameter* _tmp15_;
	const gchar* _tmp16_;
	const gchar* _tmp17_;
	ValaParameter* _tmp18_;
	ValaCodeContext* _tmp19_;
	ValaSemanticAnalyzer* _tmp20_;
	ValaSemanticAnalyzer* _tmp21_;
	ValaSymbol* _tmp22_;
	ValaSymbol* _tmp23_;
	ValaScope* _tmp24_;
	ValaScope* _tmp25_;
	ValaCodeContext* _tmp26_;
	ValaSemanticAnalyzer* _tmp27_;
	ValaSemanticAnalyzer* _tmp28_;
	ValaBlock* _tmp29_;
	ValaBlock* _tmp30_;
	ValaCodeContext* _tmp57_;
	ValaSemanticAnalyzer* _tmp58_;
	ValaSemanticAnalyzer* _tmp59_;
	ValaCodeContext* _tmp60_;
	ValaSemanticAnalyzer* _tmp61_;
	ValaSemanticAnalyzer* _tmp62_;
	ValaSymbol* _tmp63_;
	ValaSymbol* _tmp64_;
	ValaSymbol* _tmp65_;
	ValaSymbol* _tmp66_;
	gboolean _tmp67_;
	gboolean _tmp68_;
	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_ = context;
	_tmp5_ = vala_code_context_get_analyzer (_tmp4_);
	_tmp6_ = _tmp5_;
	_tmp7_ = vala_semantic_analyzer_get_current_class (_tmp6_);
	_tmp8_ = _tmp7_;
	_tmp9_ = vala_object_type_new ((ValaObjectTypeSymbol*) _tmp8_);
	_tmp10_ = _tmp9_;
	_tmp11_ = vala_parameter_new ("this", (ValaDataType*) _tmp10_, NULL);
	_tmp12_ = _tmp11_;
	vala_constructor_set_this_parameter (self, _tmp12_);
	_vala_code_node_unref0 (_tmp12_);
	_vala_code_node_unref0 (_tmp10_);
	_tmp13_ = vala_symbol_get_scope ((ValaSymbol*) self);
	_tmp14_ = _tmp13_;
	_tmp15_ = self->priv->_this_parameter;
	_tmp16_ = vala_symbol_get_name ((ValaSymbol*) _tmp15_);
	_tmp17_ = _tmp16_;
	_tmp18_ = self->priv->_this_parameter;
	vala_scope_add (_tmp14_, _tmp17_, (ValaSymbol*) _tmp18_);
	_tmp19_ = context;
	_tmp20_ = vala_code_context_get_analyzer (_tmp19_);
	_tmp21_ = _tmp20_;
	_tmp22_ = vala_semantic_analyzer_get_current_symbol (_tmp21_);
	_tmp23_ = _tmp22_;
	_tmp24_ = vala_symbol_get_scope (_tmp23_);
	_tmp25_ = _tmp24_;
	vala_symbol_set_owner ((ValaSymbol*) self, _tmp25_);
	_tmp26_ = context;
	_tmp27_ = vala_code_context_get_analyzer (_tmp26_);
	_tmp28_ = _tmp27_;
	vala_semantic_analyzer_set_current_symbol (_tmp28_, (ValaSymbol*) self);
	_tmp29_ = vala_subroutine_get_body ((ValaSubroutine*) self);
	_tmp30_ = _tmp29_;
	if (_tmp30_ != NULL) {
		ValaBlock* _tmp31_;
		ValaBlock* _tmp32_;
		ValaCodeContext* _tmp33_;
		_tmp31_ = vala_subroutine_get_body ((ValaSubroutine*) self);
		_tmp32_ = _tmp31_;
		_tmp33_ = context;
		vala_code_node_check ((ValaCodeNode*) _tmp32_, _tmp33_);
	}
	{
		ValaList* _body_error_type_list = NULL;
		ValaBlock* _tmp34_;
		ValaBlock* _tmp35_;
		ValaList* _tmp36_;
		gint _body_error_type_size = 0;
		ValaList* _tmp37_;
		gint _tmp38_;
		gint _tmp39_;
		gint _body_error_type_index = 0;
		_tmp34_ = vala_subroutine_get_body ((ValaSubroutine*) self);
		_tmp35_ = _tmp34_;
		_tmp36_ = vala_code_node_get_error_types ((ValaCodeNode*) _tmp35_);
		_body_error_type_list = _tmp36_;
		_tmp37_ = _body_error_type_list;
		_tmp38_ = vala_collection_get_size ((ValaCollection*) _tmp37_);
		_tmp39_ = _tmp38_;
		_body_error_type_size = _tmp39_;
		_body_error_type_index = -1;
		while (TRUE) {
			gint _tmp40_;
			gint _tmp41_;
			gint _tmp42_;
			ValaDataType* body_error_type = NULL;
			ValaList* _tmp43_;
			gint _tmp44_;
			gpointer _tmp45_;
			ValaDataType* _tmp46_;
			gboolean _tmp47_;
			gboolean _tmp48_;
			_tmp40_ = _body_error_type_index;
			_body_error_type_index = _tmp40_ + 1;
			_tmp41_ = _body_error_type_index;
			_tmp42_ = _body_error_type_size;
			if (!(_tmp41_ < _tmp42_)) {
				break;
			}
			_tmp43_ = _body_error_type_list;
			_tmp44_ = _body_error_type_index;
			_tmp45_ = vala_list_get (_tmp43_, _tmp44_);
			body_error_type = (ValaDataType*) _tmp45_;
			_tmp46_ = body_error_type;
			_tmp47_ = vala_error_type_get_dynamic_error (G_TYPE_CHECK_INSTANCE_CAST (_tmp46_, VALA_TYPE_ERROR_TYPE, ValaErrorType));
			_tmp48_ = _tmp47_;
			if (!_tmp48_) {
				ValaDataType* _tmp49_;
				ValaSourceReference* _tmp50_;
				ValaSourceReference* _tmp51_;
				ValaDataType* _tmp52_;
				gchar* _tmp53_;
				gchar* _tmp54_;
				gchar* _tmp55_;
				gchar* _tmp56_;
				_tmp49_ = body_error_type;
				_tmp50_ = vala_code_node_get_source_reference ((ValaCodeNode*) _tmp49_);
				_tmp51_ = _tmp50_;
				_tmp52_ = body_error_type;
				_tmp53_ = vala_code_node_to_string ((ValaCodeNode*) _tmp52_);
				_tmp54_ = _tmp53_;
				_tmp55_ = g_strdup_printf ("unhandled error `%s'", _tmp54_);
				_tmp56_ = _tmp55_;
				vala_report_warning (_tmp51_, _tmp56_);
				_g_free0 (_tmp56_);
				_g_free0 (_tmp54_);
			}
			_vala_code_node_unref0 (body_error_type);
		}
		_vala_iterable_unref0 (_body_error_type_list);
	}
	_tmp57_ = context;
	_tmp58_ = vala_code_context_get_analyzer (_tmp57_);
	_tmp59_ = _tmp58_;
	_tmp60_ = context;
	_tmp61_ = vala_code_context_get_analyzer (_tmp60_);
	_tmp62_ = _tmp61_;
	_tmp63_ = vala_semantic_analyzer_get_current_symbol (_tmp62_);
	_tmp64_ = _tmp63_;
	_tmp65_ = vala_symbol_get_parent_symbol (_tmp64_);
	_tmp66_ = _tmp65_;
	vala_semantic_analyzer_set_current_symbol (_tmp59_, _tmp66_);
	_tmp67_ = vala_code_node_get_error ((ValaCodeNode*) self);
	_tmp68_ = _tmp67_;
	result = !_tmp68_;
	return result;
}


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_;
	ValaParameter* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	_tmp1_ = _vala_code_node_ref0 (_tmp0_);
	_vala_code_node_unref0 (self->priv->_this_parameter);
	self->priv->_this_parameter = _tmp1_;
}


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


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


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


static void vala_constructor_class_init (ValaConstructorClass * klass) {
	vala_constructor_parent_class = g_type_class_peek_parent (klass);
	((ValaCodeNodeClass *) klass)->finalize = vala_constructor_finalize;
	g_type_class_add_private (klass, sizeof (ValaConstructorPrivate));
	((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 = vala_constructor_real_get_has_result;
}


static void vala_constructor_instance_init (ValaConstructor * self) {
	self->priv = VALA_CONSTRUCTOR_GET_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.
 */
GType vala_constructor_get_type (void) {
	static volatile gsize vala_constructor_type_id__volatile = 0;
	if (g_once_init_enter (&vala_constructor_type_id__volatile)) {
		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);
		g_once_init_leave (&vala_constructor_type_id__volatile, vala_constructor_type_id);
	}
	return vala_constructor_type_id__volatile;
}



