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

/* valadestructor.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"

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

struct _ValaDestructorPrivate {
	ValaParameter* _this_parameter;
	ValaMemberBinding _binding;
};


static gpointer vala_destructor_parent_class = NULL;

#define VALA_DESTRUCTOR_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), VALA_TYPE_DESTRUCTOR, ValaDestructorPrivate))
static void vala_destructor_real_accept (ValaCodeNode* base, ValaCodeVisitor* visitor);
static void vala_destructor_real_accept_children (ValaCodeNode* base, ValaCodeVisitor* visitor);
static gboolean vala_destructor_real_check (ValaCodeNode* base, ValaCodeContext* context);
static void vala_destructor_finalize (ValaCodeNode * obj);


/**
 * Creates a new destructor.
 *
 * @param source_reference reference to source code
 * @return                 newly created destructor
 */
ValaDestructor* vala_destructor_construct (GType object_type, ValaSourceReference* source_reference) {
	ValaDestructor* self = NULL;
	ValaSourceReference* _tmp0_;
	_tmp0_ = source_reference;
	self = (ValaDestructor*) vala_subroutine_construct (object_type, NULL, _tmp0_, NULL);
	return self;
}


ValaDestructor* vala_destructor_new (ValaSourceReference* source_reference) {
	return vala_destructor_construct (VALA_TYPE_DESTRUCTOR, source_reference);
}


static void vala_destructor_real_accept (ValaCodeNode* base, ValaCodeVisitor* visitor) {
	ValaDestructor * self;
	ValaCodeVisitor* _tmp0_;
	self = (ValaDestructor*) base;
	g_return_if_fail (visitor != NULL);
	_tmp0_ = visitor;
	vala_code_visitor_visit_destructor (_tmp0_, self);
}


static void vala_destructor_real_accept_children (ValaCodeNode* base, ValaCodeVisitor* visitor) {
	ValaDestructor * self;
	ValaBlock* _tmp0_;
	ValaBlock* _tmp1_;
	self = (ValaDestructor*) 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_destructor_real_check (ValaCodeNode* base, ValaCodeContext* context) {
	ValaDestructor * self;
	gboolean result = FALSE;
	gboolean _tmp0_;
	gboolean _tmp1_;
	ValaCodeContext* _tmp4_;
	ValaSemanticAnalyzer* _tmp5_;
	ValaSemanticAnalyzer* _tmp6_;
	ValaSymbol* _tmp7_;
	ValaSymbol* _tmp8_;
	ValaScope* _tmp9_;
	ValaScope* _tmp10_;
	ValaCodeContext* _tmp11_;
	ValaSemanticAnalyzer* _tmp12_;
	ValaSemanticAnalyzer* _tmp13_;
	ValaBlock* _tmp14_;
	ValaBlock* _tmp15_;
	ValaCodeContext* _tmp19_;
	ValaSemanticAnalyzer* _tmp20_;
	ValaSemanticAnalyzer* _tmp21_;
	ValaCodeContext* _tmp22_;
	ValaSemanticAnalyzer* _tmp23_;
	ValaSemanticAnalyzer* _tmp24_;
	ValaSymbol* _tmp25_;
	ValaSymbol* _tmp26_;
	ValaSymbol* _tmp27_;
	ValaSymbol* _tmp28_;
	gboolean _tmp29_;
	gboolean _tmp30_;
	self = (ValaDestructor*) 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_symbol (_tmp6_);
	_tmp8_ = _tmp7_;
	_tmp9_ = vala_symbol_get_scope (_tmp8_);
	_tmp10_ = _tmp9_;
	vala_symbol_set_owner ((ValaSymbol*) self, _tmp10_);
	_tmp11_ = context;
	_tmp12_ = vala_code_context_get_analyzer (_tmp11_);
	_tmp13_ = _tmp12_;
	vala_semantic_analyzer_set_current_symbol (_tmp13_, (ValaSymbol*) self);
	_tmp14_ = vala_subroutine_get_body ((ValaSubroutine*) self);
	_tmp15_ = _tmp14_;
	if (_tmp15_ != NULL) {
		ValaBlock* _tmp16_;
		ValaBlock* _tmp17_;
		ValaCodeContext* _tmp18_;
		_tmp16_ = vala_subroutine_get_body ((ValaSubroutine*) self);
		_tmp17_ = _tmp16_;
		_tmp18_ = context;
		vala_code_node_check ((ValaCodeNode*) _tmp17_, _tmp18_);
	}
	_tmp19_ = context;
	_tmp20_ = vala_code_context_get_analyzer (_tmp19_);
	_tmp21_ = _tmp20_;
	_tmp22_ = context;
	_tmp23_ = vala_code_context_get_analyzer (_tmp22_);
	_tmp24_ = _tmp23_;
	_tmp25_ = vala_semantic_analyzer_get_current_symbol (_tmp24_);
	_tmp26_ = _tmp25_;
	_tmp27_ = vala_symbol_get_parent_symbol (_tmp26_);
	_tmp28_ = _tmp27_;
	vala_semantic_analyzer_set_current_symbol (_tmp21_, _tmp28_);
	_tmp29_ = vala_code_node_get_error ((ValaCodeNode*) self);
	_tmp30_ = _tmp29_;
	result = !_tmp30_;
	return result;
}


ValaParameter* vala_destructor_get_this_parameter (ValaDestructor* 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_destructor_set_this_parameter (ValaDestructor* 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_destructor_get_binding (ValaDestructor* self) {
	ValaMemberBinding result;
	ValaMemberBinding _tmp0_;
	g_return_val_if_fail (self != NULL, 0);
	_tmp0_ = self->priv->_binding;
	result = _tmp0_;
	return result;
}


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


static gboolean vala_destructor_real_get_has_result (ValaSubroutine* base) {
	gboolean result;
	ValaDestructor* self;
	self = (ValaDestructor*) base;
	result = FALSE;
	return result;
}


static void vala_destructor_class_init (ValaDestructorClass * klass) {
	vala_destructor_parent_class = g_type_class_peek_parent (klass);
	((ValaCodeNodeClass *) klass)->finalize = vala_destructor_finalize;
	g_type_class_add_private (klass, sizeof (ValaDestructorPrivate));
	((ValaCodeNodeClass *) klass)->accept = (void (*) (ValaCodeNode *, ValaCodeVisitor*)) vala_destructor_real_accept;
	((ValaCodeNodeClass *) klass)->accept_children = (void (*) (ValaCodeNode *, ValaCodeVisitor*)) vala_destructor_real_accept_children;
	((ValaCodeNodeClass *) klass)->check = (gboolean (*) (ValaCodeNode *, ValaCodeContext*)) vala_destructor_real_check;
	VALA_SUBROUTINE_CLASS (klass)->get_has_result = vala_destructor_real_get_has_result;
}


static void vala_destructor_instance_init (ValaDestructor * self) {
	self->priv = VALA_DESTRUCTOR_GET_PRIVATE (self);
	self->priv->_binding = VALA_MEMBER_BINDING_INSTANCE;
}


static void vala_destructor_finalize (ValaCodeNode * obj) {
	ValaDestructor * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, VALA_TYPE_DESTRUCTOR, ValaDestructor);
	_vala_code_node_unref0 (self->priv->_this_parameter);
	VALA_CODE_NODE_CLASS (vala_destructor_parent_class)->finalize (obj);
}


/**
 * Represents a class or instance destructor.
 */
GType vala_destructor_get_type (void) {
	static volatile gsize vala_destructor_type_id__volatile = 0;
	if (g_once_init_enter (&vala_destructor_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (ValaDestructorClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) vala_destructor_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ValaDestructor), 0, (GInstanceInitFunc) vala_destructor_instance_init, NULL };
		GType vala_destructor_type_id;
		vala_destructor_type_id = g_type_register_static (VALA_TYPE_SUBROUTINE, "ValaDestructor", &g_define_type_info, 0);
		g_once_init_leave (&vala_destructor_type_id__volatile, vala_destructor_type_id);
	}
	return vala_destructor_type_id__volatile;
}



