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

/* valaunresolvedsymbol.vala
 *
 * Copyright (C) 2008-2009  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 _g_free0(var) (var = (g_free (var), NULL))

struct _ValaUnresolvedSymbolPrivate {
	ValaUnresolvedSymbol* _inner;
	gboolean _qualified;
};


static gpointer vala_unresolved_symbol_parent_class = NULL;

#define VALA_UNRESOLVED_SYMBOL_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), VALA_TYPE_UNRESOLVED_SYMBOL, ValaUnresolvedSymbolPrivate))
static gchar* vala_unresolved_symbol_real_to_string (ValaCodeNode* base);
static void vala_unresolved_symbol_finalize (ValaCodeNode * obj);


ValaUnresolvedSymbol* vala_unresolved_symbol_construct (GType object_type, ValaUnresolvedSymbol* inner, const gchar* name, ValaSourceReference* source_reference) {
	ValaUnresolvedSymbol* self = NULL;
	const gchar* _tmp0_;
	ValaSourceReference* _tmp1_;
	ValaUnresolvedSymbol* _tmp2_;
	g_return_val_if_fail (name != NULL, NULL);
	_tmp0_ = name;
	_tmp1_ = source_reference;
	self = (ValaUnresolvedSymbol*) vala_symbol_construct (object_type, _tmp0_, _tmp1_, NULL);
	_tmp2_ = inner;
	vala_unresolved_symbol_set_inner (self, _tmp2_);
	return self;
}


ValaUnresolvedSymbol* vala_unresolved_symbol_new (ValaUnresolvedSymbol* inner, const gchar* name, ValaSourceReference* source_reference) {
	return vala_unresolved_symbol_construct (VALA_TYPE_UNRESOLVED_SYMBOL, inner, name, source_reference);
}


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


ValaUnresolvedSymbol* vala_unresolved_symbol_new_from_expression (ValaExpression* expr) {
	ValaUnresolvedSymbol* result = NULL;
	ValaMemberAccess* ma = NULL;
	ValaExpression* _tmp0_;
	ValaMemberAccess* _tmp1_;
	ValaMemberAccess* _tmp2_;
	ValaExpression* _tmp26_;
	ValaSourceReference* _tmp27_;
	ValaSourceReference* _tmp28_;
	g_return_val_if_fail (expr != NULL, NULL);
	_tmp0_ = expr;
	_tmp1_ = _vala_code_node_ref0 (G_TYPE_CHECK_INSTANCE_TYPE (_tmp0_, VALA_TYPE_MEMBER_ACCESS) ? ((ValaMemberAccess*) _tmp0_) : NULL);
	ma = _tmp1_;
	_tmp2_ = ma;
	if (_tmp2_ != NULL) {
		ValaMemberAccess* _tmp3_;
		ValaExpression* _tmp4_;
		ValaExpression* _tmp5_;
		_tmp3_ = ma;
		_tmp4_ = vala_member_access_get_inner (_tmp3_);
		_tmp5_ = _tmp4_;
		if (_tmp5_ != NULL) {
			ValaMemberAccess* _tmp6_;
			ValaExpression* _tmp7_;
			ValaExpression* _tmp8_;
			ValaUnresolvedSymbol* _tmp9_;
			ValaUnresolvedSymbol* _tmp10_;
			ValaMemberAccess* _tmp11_;
			const gchar* _tmp12_;
			const gchar* _tmp13_;
			ValaMemberAccess* _tmp14_;
			ValaSourceReference* _tmp15_;
			ValaSourceReference* _tmp16_;
			ValaUnresolvedSymbol* _tmp17_;
			ValaUnresolvedSymbol* _tmp18_;
			_tmp6_ = ma;
			_tmp7_ = vala_member_access_get_inner (_tmp6_);
			_tmp8_ = _tmp7_;
			_tmp9_ = vala_unresolved_symbol_new_from_expression (_tmp8_);
			_tmp10_ = _tmp9_;
			_tmp11_ = ma;
			_tmp12_ = vala_member_access_get_member_name (_tmp11_);
			_tmp13_ = _tmp12_;
			_tmp14_ = ma;
			_tmp15_ = vala_code_node_get_source_reference ((ValaCodeNode*) _tmp14_);
			_tmp16_ = _tmp15_;
			_tmp17_ = vala_unresolved_symbol_new (_tmp10_, _tmp13_, _tmp16_);
			_tmp18_ = _tmp17_;
			_vala_code_node_unref0 (_tmp10_);
			result = _tmp18_;
			_vala_code_node_unref0 (ma);
			return result;
		} else {
			ValaMemberAccess* _tmp19_;
			const gchar* _tmp20_;
			const gchar* _tmp21_;
			ValaMemberAccess* _tmp22_;
			ValaSourceReference* _tmp23_;
			ValaSourceReference* _tmp24_;
			ValaUnresolvedSymbol* _tmp25_;
			_tmp19_ = ma;
			_tmp20_ = vala_member_access_get_member_name (_tmp19_);
			_tmp21_ = _tmp20_;
			_tmp22_ = ma;
			_tmp23_ = vala_code_node_get_source_reference ((ValaCodeNode*) _tmp22_);
			_tmp24_ = _tmp23_;
			_tmp25_ = vala_unresolved_symbol_new (NULL, _tmp21_, _tmp24_);
			result = _tmp25_;
			_vala_code_node_unref0 (ma);
			return result;
		}
	}
	_tmp26_ = expr;
	_tmp27_ = vala_code_node_get_source_reference ((ValaCodeNode*) _tmp26_);
	_tmp28_ = _tmp27_;
	vala_report_error (_tmp28_, "Type reference must be simple name or member access expression");
	result = NULL;
	_vala_code_node_unref0 (ma);
	return result;
}


static gchar* vala_unresolved_symbol_real_to_string (ValaCodeNode* base) {
	ValaUnresolvedSymbol * self;
	gchar* result = NULL;
	ValaUnresolvedSymbol* _tmp0_;
	self = (ValaUnresolvedSymbol*) base;
	_tmp0_ = self->priv->_inner;
	if (_tmp0_ == NULL) {
		const gchar* _tmp1_;
		const gchar* _tmp2_;
		gchar* _tmp3_;
		_tmp1_ = vala_symbol_get_name ((ValaSymbol*) self);
		_tmp2_ = _tmp1_;
		_tmp3_ = g_strdup (_tmp2_);
		result = _tmp3_;
		return result;
	} else {
		ValaUnresolvedSymbol* _tmp4_;
		gchar* _tmp5_;
		gchar* _tmp6_;
		const gchar* _tmp7_;
		const gchar* _tmp8_;
		gchar* _tmp9_;
		gchar* _tmp10_;
		_tmp4_ = self->priv->_inner;
		_tmp5_ = vala_code_node_to_string ((ValaCodeNode*) _tmp4_);
		_tmp6_ = _tmp5_;
		_tmp7_ = vala_symbol_get_name ((ValaSymbol*) self);
		_tmp8_ = _tmp7_;
		_tmp9_ = g_strdup_printf ("%s.%s", _tmp6_, _tmp8_);
		_tmp10_ = _tmp9_;
		_g_free0 (_tmp6_);
		result = _tmp10_;
		return result;
	}
}


ValaUnresolvedSymbol* vala_unresolved_symbol_copy (ValaUnresolvedSymbol* self) {
	ValaUnresolvedSymbol* result = NULL;
	ValaUnresolvedSymbol* _tmp0_;
	const gchar* _tmp1_;
	const gchar* _tmp2_;
	ValaSourceReference* _tmp3_;
	ValaSourceReference* _tmp4_;
	ValaUnresolvedSymbol* _tmp5_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_inner;
	_tmp1_ = vala_symbol_get_name ((ValaSymbol*) self);
	_tmp2_ = _tmp1_;
	_tmp3_ = vala_code_node_get_source_reference ((ValaCodeNode*) self);
	_tmp4_ = _tmp3_;
	_tmp5_ = vala_unresolved_symbol_new (_tmp0_, _tmp2_, _tmp4_);
	result = _tmp5_;
	return result;
}


ValaUnresolvedSymbol* vala_unresolved_symbol_get_inner (ValaUnresolvedSymbol* self) {
	ValaUnresolvedSymbol* result;
	ValaUnresolvedSymbol* _tmp0_;
	g_return_val_if_fail (self != NULL, NULL);
	_tmp0_ = self->priv->_inner;
	result = _tmp0_;
	return result;
}


void vala_unresolved_symbol_set_inner (ValaUnresolvedSymbol* self, ValaUnresolvedSymbol* value) {
	ValaUnresolvedSymbol* _tmp0_;
	ValaUnresolvedSymbol* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	_tmp1_ = _vala_code_node_ref0 (_tmp0_);
	_vala_code_node_unref0 (self->priv->_inner);
	self->priv->_inner = _tmp1_;
}


gboolean vala_unresolved_symbol_get_qualified (ValaUnresolvedSymbol* self) {
	gboolean result;
	gboolean _tmp0_;
	g_return_val_if_fail (self != NULL, FALSE);
	_tmp0_ = self->priv->_qualified;
	result = _tmp0_;
	return result;
}


void vala_unresolved_symbol_set_qualified (ValaUnresolvedSymbol* self, gboolean value) {
	gboolean _tmp0_;
	g_return_if_fail (self != NULL);
	_tmp0_ = value;
	self->priv->_qualified = _tmp0_;
}


static void vala_unresolved_symbol_class_init (ValaUnresolvedSymbolClass * klass) {
	vala_unresolved_symbol_parent_class = g_type_class_peek_parent (klass);
	((ValaCodeNodeClass *) klass)->finalize = vala_unresolved_symbol_finalize;
	g_type_class_add_private (klass, sizeof (ValaUnresolvedSymbolPrivate));
	((ValaCodeNodeClass *) klass)->to_string = (gchar* (*) (ValaCodeNode *)) vala_unresolved_symbol_real_to_string;
}


static void vala_unresolved_symbol_instance_init (ValaUnresolvedSymbol * self) {
	self->priv = VALA_UNRESOLVED_SYMBOL_GET_PRIVATE (self);
}


static void vala_unresolved_symbol_finalize (ValaCodeNode * obj) {
	ValaUnresolvedSymbol * self;
	self = G_TYPE_CHECK_INSTANCE_CAST (obj, VALA_TYPE_UNRESOLVED_SYMBOL, ValaUnresolvedSymbol);
	_vala_code_node_unref0 (self->priv->_inner);
	VALA_CODE_NODE_CLASS (vala_unresolved_symbol_parent_class)->finalize (obj);
}


/**
 * An unresolved reference to a symbol.
 */
GType vala_unresolved_symbol_get_type (void) {
	static volatile gsize vala_unresolved_symbol_type_id__volatile = 0;
	if (g_once_init_enter (&vala_unresolved_symbol_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (ValaUnresolvedSymbolClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) vala_unresolved_symbol_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ValaUnresolvedSymbol), 0, (GInstanceInitFunc) vala_unresolved_symbol_instance_init, NULL };
		GType vala_unresolved_symbol_type_id;
		vala_unresolved_symbol_type_id = g_type_register_static (VALA_TYPE_SYMBOL, "ValaUnresolvedSymbol", &g_define_type_info, 0);
		g_once_init_leave (&vala_unresolved_symbol_type_id__volatile, vala_unresolved_symbol_type_id);
	}
	return vala_unresolved_symbol_type_id__volatile;
}



