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

/* valanullliteral.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 <stdlib.h>
#include <string.h>

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


static gpointer vala_null_literal_parent_class = NULL;

static void vala_null_literal_real_accept (ValaCodeNode* base, ValaCodeVisitor* visitor);
static gchar* vala_null_literal_real_to_string (ValaCodeNode* base);
static gboolean vala_null_literal_real_is_pure (ValaExpression* base);
static gboolean vala_null_literal_real_check (ValaCodeNode* base, ValaCodeContext* context);
static void vala_null_literal_real_emit (ValaCodeNode* base, ValaCodeGenerator* codegen);


/**
 * Creates a new null literal.
 *
 * @param source reference to source code
 * @return       newly created null literal
 */
ValaNullLiteral* vala_null_literal_construct (GType object_type, ValaSourceReference* source) {
	ValaNullLiteral* self = NULL;
	ValaSourceReference* _tmp0_;
	self = (ValaNullLiteral*) vala_literal_construct (object_type);
	_tmp0_ = source;
	vala_code_node_set_source_reference ((ValaCodeNode*) self, _tmp0_);
	return self;
}


ValaNullLiteral* vala_null_literal_new (ValaSourceReference* source) {
	return vala_null_literal_construct (VALA_TYPE_NULL_LITERAL, source);
}


static void vala_null_literal_real_accept (ValaCodeNode* base, ValaCodeVisitor* visitor) {
	ValaNullLiteral * self;
	ValaCodeVisitor* _tmp0_;
	ValaCodeVisitor* _tmp1_;
	self = (ValaNullLiteral*) base;
	g_return_if_fail (visitor != NULL);
	_tmp0_ = visitor;
	vala_code_visitor_visit_null_literal (_tmp0_, self);
	_tmp1_ = visitor;
	vala_code_visitor_visit_expression (_tmp1_, (ValaExpression*) self);
}


static gchar* vala_null_literal_real_to_string (ValaCodeNode* base) {
	ValaNullLiteral * self;
	gchar* result = NULL;
	gchar* _tmp0_;
	self = (ValaNullLiteral*) base;
	_tmp0_ = g_strdup ("null");
	result = _tmp0_;
	return result;
}


static gboolean vala_null_literal_real_is_pure (ValaExpression* base) {
	ValaNullLiteral * self;
	gboolean result = FALSE;
	self = (ValaNullLiteral*) base;
	result = TRUE;
	return result;
}


static gboolean vala_null_literal_real_check (ValaCodeNode* base, ValaCodeContext* context) {
	ValaNullLiteral * self;
	gboolean result = FALSE;
	gboolean _tmp0_;
	gboolean _tmp1_;
	ValaSourceReference* _tmp4_;
	ValaSourceReference* _tmp5_;
	ValaNullType* _tmp6_;
	ValaNullType* _tmp7_;
	gboolean _tmp8_;
	gboolean _tmp9_;
	self = (ValaNullLiteral*) 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_node_get_source_reference ((ValaCodeNode*) self);
	_tmp5_ = _tmp4_;
	_tmp6_ = vala_null_type_new (_tmp5_);
	_tmp7_ = _tmp6_;
	vala_expression_set_value_type ((ValaExpression*) self, (ValaDataType*) _tmp7_);
	_vala_code_node_unref0 (_tmp7_);
	_tmp8_ = vala_code_node_get_error ((ValaCodeNode*) self);
	_tmp9_ = _tmp8_;
	result = !_tmp9_;
	return result;
}


static void vala_null_literal_real_emit (ValaCodeNode* base, ValaCodeGenerator* codegen) {
	ValaNullLiteral * self;
	ValaCodeGenerator* _tmp0_;
	ValaCodeGenerator* _tmp1_;
	self = (ValaNullLiteral*) base;
	g_return_if_fail (codegen != NULL);
	_tmp0_ = codegen;
	vala_code_visitor_visit_null_literal ((ValaCodeVisitor*) _tmp0_, self);
	_tmp1_ = codegen;
	vala_code_visitor_visit_expression ((ValaCodeVisitor*) _tmp1_, (ValaExpression*) self);
}


static void vala_null_literal_class_init (ValaNullLiteralClass * klass) {
	vala_null_literal_parent_class = g_type_class_peek_parent (klass);
	((ValaCodeNodeClass *) klass)->accept = (void (*) (ValaCodeNode *, ValaCodeVisitor*)) vala_null_literal_real_accept;
	((ValaCodeNodeClass *) klass)->to_string = (gchar* (*) (ValaCodeNode *)) vala_null_literal_real_to_string;
	((ValaExpressionClass *) klass)->is_pure = (gboolean (*) (ValaExpression *)) vala_null_literal_real_is_pure;
	((ValaCodeNodeClass *) klass)->check = (gboolean (*) (ValaCodeNode *, ValaCodeContext*)) vala_null_literal_real_check;
	((ValaCodeNodeClass *) klass)->emit = (void (*) (ValaCodeNode *, ValaCodeGenerator*)) vala_null_literal_real_emit;
}


static void vala_null_literal_instance_init (ValaNullLiteral * self) {
}


/**
 * Represents a literal `null` in the source code.
 */
GType vala_null_literal_get_type (void) {
	static volatile gsize vala_null_literal_type_id__volatile = 0;
	if (g_once_init_enter (&vala_null_literal_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (ValaNullLiteralClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) vala_null_literal_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (ValaNullLiteral), 0, (GInstanceInitFunc) vala_null_literal_instance_init, NULL };
		GType vala_null_literal_type_id;
		vala_null_literal_type_id = g_type_register_static (VALA_TYPE_LITERAL, "ValaNullLiteral", &g_define_type_info, 0);
		g_once_init_leave (&vala_null_literal_type_id__volatile, vala_null_literal_type_id);
	}
	return vala_null_literal_type_id__volatile;
}



