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

/* valanulltype.vala
 *
 * Copyright (C) 2007-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 <stdlib.h>
#include <string.h>

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


static gpointer vala_null_type_parent_class = NULL;

static gboolean vala_null_type_real_compatible (ValaDataType* base, ValaDataType* target_type);
static ValaDataType* vala_null_type_real_copy (ValaDataType* base);
static gboolean vala_null_type_real_is_disposable (ValaDataType* base);
static gchar* vala_null_type_real_to_qualified_string (ValaDataType* base, ValaScope* scope);


ValaNullType* vala_null_type_construct (GType object_type, ValaSourceReference* source_reference) {
	ValaNullType* self = NULL;
	ValaSourceReference* _tmp0_;
	self = (ValaNullType*) vala_reference_type_construct (object_type);
	vala_data_type_set_nullable ((ValaDataType*) self, TRUE);
	_tmp0_ = source_reference;
	vala_code_node_set_source_reference ((ValaCodeNode*) self, _tmp0_);
	return self;
}


ValaNullType* vala_null_type_new (ValaSourceReference* source_reference) {
	return vala_null_type_construct (VALA_TYPE_NULL_TYPE, source_reference);
}


static gboolean vala_null_type_real_compatible (ValaDataType* base, ValaDataType* target_type) {
	ValaNullType * self;
	gboolean result = FALSE;
	ValaCodeContext* _tmp0_;
	ValaCodeContext* _tmp1_;
	gboolean _tmp2_;
	gboolean _tmp3_;
	gboolean _tmp4_;
	gboolean _tmp8_ = FALSE;
	ValaDataType* _tmp9_;
	gboolean _tmp19_ = FALSE;
	gboolean _tmp20_ = FALSE;
	gboolean _tmp21_ = FALSE;
	ValaDataType* _tmp22_;
	ValaTypeParameter* _tmp23_;
	ValaTypeParameter* _tmp24_;
	gboolean _tmp34_ = FALSE;
	gboolean _tmp35_ = FALSE;
	ValaDataType* _tmp36_;
	ValaTypeSymbol* _tmp37_;
	ValaTypeSymbol* _tmp38_;
	gboolean _tmp39_;
	self = (ValaNullType*) base;
	g_return_val_if_fail (target_type != NULL, FALSE);
	_tmp0_ = vala_code_context_get ();
	_tmp1_ = _tmp0_;
	_tmp2_ = vala_code_context_get_experimental_non_null (_tmp1_);
	_tmp3_ = _tmp2_;
	_tmp4_ = _tmp3_;
	_vala_code_context_unref0 (_tmp1_);
	if (_tmp4_) {
		ValaDataType* _tmp5_;
		gboolean _tmp6_;
		gboolean _tmp7_;
		_tmp5_ = target_type;
		_tmp6_ = vala_data_type_get_nullable (_tmp5_);
		_tmp7_ = _tmp6_;
		result = _tmp7_;
		return result;
	}
	_tmp9_ = target_type;
	if (!G_TYPE_CHECK_INSTANCE_TYPE (_tmp9_, VALA_TYPE_POINTER_TYPE)) {
		gboolean _tmp10_ = FALSE;
		ValaDataType* _tmp11_;
		_tmp11_ = target_type;
		if (G_TYPE_CHECK_INSTANCE_TYPE (_tmp11_, VALA_TYPE_NULL_TYPE)) {
			_tmp10_ = TRUE;
		} else {
			gboolean _tmp12_ = FALSE;
			ValaDataType* _tmp13_;
			ValaTypeSymbol* _tmp14_;
			ValaTypeSymbol* _tmp15_;
			_tmp13_ = target_type;
			_tmp14_ = vala_data_type_get_data_type (_tmp13_);
			_tmp15_ = _tmp14_;
			if (_tmp15_ == NULL) {
				ValaDataType* _tmp16_;
				ValaTypeParameter* _tmp17_;
				ValaTypeParameter* _tmp18_;
				_tmp16_ = target_type;
				_tmp17_ = vala_data_type_get_type_parameter (_tmp16_);
				_tmp18_ = _tmp17_;
				_tmp12_ = _tmp18_ == NULL;
			} else {
				_tmp12_ = FALSE;
			}
			_tmp10_ = _tmp12_;
		}
		_tmp8_ = _tmp10_;
	} else {
		_tmp8_ = FALSE;
	}
	if (_tmp8_) {
		result = TRUE;
		return result;
	}
	_tmp22_ = target_type;
	_tmp23_ = vala_data_type_get_type_parameter (_tmp22_);
	_tmp24_ = _tmp23_;
	if (_tmp24_ != NULL) {
		_tmp21_ = TRUE;
	} else {
		ValaDataType* _tmp25_;
		_tmp25_ = target_type;
		_tmp21_ = G_TYPE_CHECK_INSTANCE_TYPE (_tmp25_, VALA_TYPE_POINTER_TYPE);
	}
	if (_tmp21_) {
		_tmp20_ = TRUE;
	} else {
		ValaDataType* _tmp26_;
		gboolean _tmp27_;
		gboolean _tmp28_;
		_tmp26_ = target_type;
		_tmp27_ = vala_data_type_get_nullable (_tmp26_);
		_tmp28_ = _tmp27_;
		_tmp20_ = _tmp28_;
	}
	if (_tmp20_) {
		_tmp19_ = TRUE;
	} else {
		ValaDataType* _tmp29_;
		ValaTypeSymbol* _tmp30_;
		ValaTypeSymbol* _tmp31_;
		ValaAttribute* _tmp32_;
		ValaAttribute* _tmp33_;
		_tmp29_ = target_type;
		_tmp30_ = vala_data_type_get_data_type (_tmp29_);
		_tmp31_ = _tmp30_;
		_tmp32_ = vala_code_node_get_attribute ((ValaCodeNode*) _tmp31_, "PointerType");
		_tmp33_ = _tmp32_;
		_tmp19_ = _tmp33_ != NULL;
		_vala_code_node_unref0 (_tmp33_);
	}
	if (_tmp19_) {
		result = TRUE;
		return result;
	}
	_tmp36_ = target_type;
	_tmp37_ = vala_data_type_get_data_type (_tmp36_);
	_tmp38_ = _tmp37_;
	_tmp39_ = vala_typesymbol_is_reference_type (_tmp38_);
	if (_tmp39_) {
		_tmp35_ = TRUE;
	} else {
		ValaDataType* _tmp40_;
		_tmp40_ = target_type;
		_tmp35_ = G_TYPE_CHECK_INSTANCE_TYPE (_tmp40_, VALA_TYPE_ARRAY_TYPE);
	}
	if (_tmp35_) {
		_tmp34_ = TRUE;
	} else {
		ValaDataType* _tmp41_;
		_tmp41_ = target_type;
		_tmp34_ = G_TYPE_CHECK_INSTANCE_TYPE (_tmp41_, VALA_TYPE_DELEGATE_TYPE);
	}
	if (_tmp34_) {
		result = TRUE;
		return result;
	}
	result = FALSE;
	return result;
}


static ValaDataType* vala_null_type_real_copy (ValaDataType* base) {
	ValaNullType * self;
	ValaDataType* result = NULL;
	ValaSourceReference* _tmp0_;
	ValaSourceReference* _tmp1_;
	ValaNullType* _tmp2_;
	self = (ValaNullType*) base;
	_tmp0_ = vala_code_node_get_source_reference ((ValaCodeNode*) self);
	_tmp1_ = _tmp0_;
	_tmp2_ = vala_null_type_new (_tmp1_);
	result = (ValaDataType*) _tmp2_;
	return result;
}


static gboolean vala_null_type_real_is_disposable (ValaDataType* base) {
	ValaNullType * self;
	gboolean result = FALSE;
	self = (ValaNullType*) base;
	result = FALSE;
	return result;
}


static gchar* vala_null_type_real_to_qualified_string (ValaDataType* base, ValaScope* scope) {
	ValaNullType * self;
	gchar* result = NULL;
	gchar* _tmp0_;
	self = (ValaNullType*) base;
	_tmp0_ = g_strdup ("null");
	result = _tmp0_;
	return result;
}


static void vala_null_type_class_init (ValaNullTypeClass * klass) {
	vala_null_type_parent_class = g_type_class_peek_parent (klass);
	((ValaDataTypeClass *) klass)->compatible = (gboolean (*) (ValaDataType *, ValaDataType*)) vala_null_type_real_compatible;
	((ValaDataTypeClass *) klass)->copy = (ValaDataType* (*) (ValaDataType *)) vala_null_type_real_copy;
	((ValaDataTypeClass *) klass)->is_disposable = (gboolean (*) (ValaDataType *)) vala_null_type_real_is_disposable;
	((ValaDataTypeClass *) klass)->to_qualified_string = (gchar* (*) (ValaDataType *, ValaScope*)) vala_null_type_real_to_qualified_string;
}


static void vala_null_type_instance_init (ValaNullType * self) {
}


/**
 * The type of the null literal.
 */
GType vala_null_type_get_type (void) {
	static volatile gsize vala_null_type_type_id__volatile = 0;
	if (g_once_init_enter (&vala_null_type_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (ValaNullTypeClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) vala_null_type_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ValaNullType), 0, (GInstanceInitFunc) vala_null_type_instance_init, NULL };
		GType vala_null_type_type_id;
		vala_null_type_type_id = g_type_register_static (VALA_TYPE_REFERENCE_TYPE, "ValaNullType", &g_define_type_info, 0);
		g_once_init_leave (&vala_null_type_type_id__volatile, vala_null_type_type_id);
	}
	return vala_null_type_type_id__volatile;
}



