/* astdumper.c generated by valac 0.12.1.1-323029-dirty, the Vala compiler
 * generated from astdumper.vala, do not modify */

/* contextdump.vala
 *
 * Copyright (C) 2009  Andrea Del Signore
 *
 * 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, see <http://www.gnu.org/licenses/>.
 *
 * Author:
 * 	Andrea Del Signore <sejerpz@tin.it>
 */

#include <glib.h>
#include <glib-object.h>
#include <vala.h>
#include <stdlib.h>
#include <string.h>
#include <valagee.h>


#define AFRODITE_TYPE_AST_DUMPER (afrodite_ast_dumper_get_type ())
#define AFRODITE_AST_DUMPER(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), AFRODITE_TYPE_AST_DUMPER, AfroditeAstDumper))
#define AFRODITE_AST_DUMPER_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), AFRODITE_TYPE_AST_DUMPER, AfroditeAstDumperClass))
#define AFRODITE_IS_AST_DUMPER(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), AFRODITE_TYPE_AST_DUMPER))
#define AFRODITE_IS_AST_DUMPER_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), AFRODITE_TYPE_AST_DUMPER))
#define AFRODITE_AST_DUMPER_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), AFRODITE_TYPE_AST_DUMPER, AfroditeAstDumperClass))

typedef struct _AfroditeAstDumper AfroditeAstDumper;
typedef struct _AfroditeAstDumperClass AfroditeAstDumperClass;
typedef struct _AfroditeAstDumperPrivate AfroditeAstDumperPrivate;
#define _g_free0(var) (var = (g_free (var), NULL))

#define AFRODITE_TYPE_SYMBOL (afrodite_symbol_get_type ())
#define AFRODITE_SYMBOL(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), AFRODITE_TYPE_SYMBOL, AfroditeSymbol))
#define AFRODITE_SYMBOL_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), AFRODITE_TYPE_SYMBOL, AfroditeSymbolClass))
#define AFRODITE_IS_SYMBOL(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), AFRODITE_TYPE_SYMBOL))
#define AFRODITE_IS_SYMBOL_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), AFRODITE_TYPE_SYMBOL))
#define AFRODITE_SYMBOL_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), AFRODITE_TYPE_SYMBOL, AfroditeSymbolClass))

typedef struct _AfroditeSymbol AfroditeSymbol;
typedef struct _AfroditeSymbolClass AfroditeSymbolClass;

#define AFRODITE_TYPE_MEMBER_TYPE (afrodite_member_type_get_type ())

#define AFRODITE_TYPE_SOURCE_REFERENCE (afrodite_source_reference_get_type ())
#define AFRODITE_SOURCE_REFERENCE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), AFRODITE_TYPE_SOURCE_REFERENCE, AfroditeSourceReference))
#define AFRODITE_SOURCE_REFERENCE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), AFRODITE_TYPE_SOURCE_REFERENCE, AfroditeSourceReferenceClass))
#define AFRODITE_IS_SOURCE_REFERENCE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), AFRODITE_TYPE_SOURCE_REFERENCE))
#define AFRODITE_IS_SOURCE_REFERENCE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), AFRODITE_TYPE_SOURCE_REFERENCE))
#define AFRODITE_SOURCE_REFERENCE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), AFRODITE_TYPE_SOURCE_REFERENCE, AfroditeSourceReferenceClass))

typedef struct _AfroditeSourceReference AfroditeSourceReference;
typedef struct _AfroditeSourceReferenceClass AfroditeSourceReferenceClass;

#define AFRODITE_TYPE_SOURCE_FILE (afrodite_source_file_get_type ())
#define AFRODITE_SOURCE_FILE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), AFRODITE_TYPE_SOURCE_FILE, AfroditeSourceFile))
#define AFRODITE_SOURCE_FILE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), AFRODITE_TYPE_SOURCE_FILE, AfroditeSourceFileClass))
#define AFRODITE_IS_SOURCE_FILE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), AFRODITE_TYPE_SOURCE_FILE))
#define AFRODITE_IS_SOURCE_FILE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), AFRODITE_TYPE_SOURCE_FILE))
#define AFRODITE_SOURCE_FILE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), AFRODITE_TYPE_SOURCE_FILE, AfroditeSourceFileClass))

typedef struct _AfroditeSourceFile AfroditeSourceFile;
typedef struct _AfroditeSourceFileClass AfroditeSourceFileClass;
#define _afrodite_source_reference_unref0(var) ((var == NULL) ? NULL : (var = (afrodite_source_reference_unref (var), NULL)))
#define _vala_iterable_unref0(var) ((var == NULL) ? NULL : (var = (vala_iterable_unref (var), NULL)))
#define _g_string_free0(var) ((var == NULL) ? NULL : (var = (g_string_free (var, TRUE), NULL)))

#define AFRODITE_TYPE_CODE_DOM (afrodite_code_dom_get_type ())
#define AFRODITE_CODE_DOM(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), AFRODITE_TYPE_CODE_DOM, AfroditeCodeDom))
#define AFRODITE_CODE_DOM_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), AFRODITE_TYPE_CODE_DOM, AfroditeCodeDomClass))
#define AFRODITE_IS_CODE_DOM(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), AFRODITE_TYPE_CODE_DOM))
#define AFRODITE_IS_CODE_DOM_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), AFRODITE_TYPE_CODE_DOM))
#define AFRODITE_CODE_DOM_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), AFRODITE_TYPE_CODE_DOM, AfroditeCodeDomClass))

typedef struct _AfroditeCodeDom AfroditeCodeDom;
typedef struct _AfroditeCodeDomClass AfroditeCodeDomClass;

#define AFRODITE_TYPE_DATA_TYPE (afrodite_data_type_get_type ())
#define AFRODITE_DATA_TYPE(obj) (G_TYPE_CHECK_INSTANCE_CAST ((obj), AFRODITE_TYPE_DATA_TYPE, AfroditeDataType))
#define AFRODITE_DATA_TYPE_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST ((klass), AFRODITE_TYPE_DATA_TYPE, AfroditeDataTypeClass))
#define AFRODITE_IS_DATA_TYPE(obj) (G_TYPE_CHECK_INSTANCE_TYPE ((obj), AFRODITE_TYPE_DATA_TYPE))
#define AFRODITE_IS_DATA_TYPE_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE ((klass), AFRODITE_TYPE_DATA_TYPE))
#define AFRODITE_DATA_TYPE_GET_CLASS(obj) (G_TYPE_INSTANCE_GET_CLASS ((obj), AFRODITE_TYPE_DATA_TYPE, AfroditeDataTypeClass))

typedef struct _AfroditeDataType AfroditeDataType;
typedef struct _AfroditeDataTypeClass AfroditeDataTypeClass;
#define _afrodite_data_type_unref0(var) ((var == NULL) ? NULL : (var = (afrodite_data_type_unref (var), NULL)))
#define _afrodite_source_file_unref0(var) ((var == NULL) ? NULL : (var = (afrodite_source_file_unref (var), NULL)))
#define _g_timer_destroy0(var) ((var == NULL) ? NULL : (var = (g_timer_destroy (var), NULL)))
#define _g_object_unref0(var) ((var == NULL) ? NULL : (var = (g_object_unref (var), NULL)))

struct _AfroditeAstDumper {
	ValaCodeVisitor parent_instance;
	AfroditeAstDumperPrivate * priv;
};

struct _AfroditeAstDumperClass {
	ValaCodeVisitorClass parent_class;
};

struct _AfroditeAstDumperPrivate {
	gchar* pad;
	gint level;
	gint symbols;
	gint unresolved_types;
	gint types;
};

typedef enum  {
	AFRODITE_MEMBER_TYPE_NONE,
	AFRODITE_MEMBER_TYPE_VOID,
	AFRODITE_MEMBER_TYPE_CONSTANT,
	AFRODITE_MEMBER_TYPE_ENUM,
	AFRODITE_MEMBER_TYPE_ENUM_VALUE,
	AFRODITE_MEMBER_TYPE_FIELD,
	AFRODITE_MEMBER_TYPE_PROPERTY,
	AFRODITE_MEMBER_TYPE_LOCAL_VARIABLE,
	AFRODITE_MEMBER_TYPE_SIGNAL,
	AFRODITE_MEMBER_TYPE_CREATION_METHOD,
	AFRODITE_MEMBER_TYPE_CONSTRUCTOR,
	AFRODITE_MEMBER_TYPE_DESTRUCTOR,
	AFRODITE_MEMBER_TYPE_METHOD,
	AFRODITE_MEMBER_TYPE_DELEGATE,
	AFRODITE_MEMBER_TYPE_PARAMETER,
	AFRODITE_MEMBER_TYPE_TYPE_PARAMETER,
	AFRODITE_MEMBER_TYPE_ERROR_DOMAIN,
	AFRODITE_MEMBER_TYPE_ERROR_CODE,
	AFRODITE_MEMBER_TYPE_NAMESPACE,
	AFRODITE_MEMBER_TYPE_STRUCT,
	AFRODITE_MEMBER_TYPE_CLASS,
	AFRODITE_MEMBER_TYPE_INTERFACE,
	AFRODITE_MEMBER_TYPE_SCOPED_CODE_NODE
} AfroditeMemberType;


static gpointer afrodite_ast_dumper_parent_class = NULL;

GType afrodite_ast_dumper_get_type (void) G_GNUC_CONST;
#define AFRODITE_AST_DUMPER_GET_PRIVATE(o) (G_TYPE_INSTANCE_GET_PRIVATE ((o), AFRODITE_TYPE_AST_DUMPER, AfroditeAstDumperPrivate))
enum  {
	AFRODITE_AST_DUMPER_DUMMY_PROPERTY
};
static void afrodite_ast_dumper_inc_pad (AfroditeAstDumper* self);
static void afrodite_ast_dumper_dec_pad (AfroditeAstDumper* self);
GType afrodite_symbol_get_type (void) G_GNUC_CONST;
static void afrodite_ast_dumper_print_symbol (AfroditeAstDumper* self, AfroditeSymbol* s);
gchar* afrodite_ast_dumper_create_symbol_dump_info (AfroditeAstDumper* self, AfroditeSymbol* s, gboolean update_counters);
GType afrodite_member_type_get_type (void) G_GNUC_CONST;
AfroditeMemberType afrodite_symbol_get_member_type (AfroditeSymbol* self);
gchar* afrodite_utils_symbols_get_symbol_type_description (AfroditeMemberType type);
gchar* afrodite_utils_unescape_xml_string (const gchar* text);
gchar* afrodite_symbol_get_description (AfroditeSymbol* self);
gboolean afrodite_symbol_get_has_source_references (AfroditeSymbol* self);
gpointer afrodite_source_reference_ref (gpointer instance);
void afrodite_source_reference_unref (gpointer instance);
GParamSpec* afrodite_param_spec_source_reference (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
void afrodite_value_set_source_reference (GValue* value, gpointer v_object);
void afrodite_value_take_source_reference (GValue* value, gpointer v_object);
gpointer afrodite_value_get_source_reference (const GValue* value);
GType afrodite_source_reference_get_type (void) G_GNUC_CONST;
ValaList* afrodite_symbol_get_source_references (AfroditeSymbol* self);
gint afrodite_source_reference_get_first_line (AfroditeSourceReference* self);
gint afrodite_source_reference_get_last_line (AfroditeSourceReference* self);
gpointer afrodite_source_file_ref (gpointer instance);
void afrodite_source_file_unref (gpointer instance);
GParamSpec* afrodite_param_spec_source_file (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
void afrodite_value_set_source_file (GValue* value, gpointer v_object);
void afrodite_value_take_source_file (GValue* value, gpointer v_object);
gpointer afrodite_value_get_source_file (const GValue* value);
GType afrodite_source_file_get_type (void) G_GNUC_CONST;
AfroditeSourceFile* afrodite_source_reference_get_file (AfroditeSourceReference* self);
const gchar* afrodite_source_file_get_filename (AfroditeSourceFile* self);
gpointer afrodite_code_dom_ref (gpointer instance);
void afrodite_code_dom_unref (gpointer instance);
GParamSpec* afrodite_param_spec_code_dom (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
void afrodite_value_set_code_dom (GValue* value, gpointer v_object);
void afrodite_value_take_code_dom (GValue* value, gpointer v_object);
gpointer afrodite_value_get_code_dom (const GValue* value);
GType afrodite_code_dom_get_type (void) G_GNUC_CONST;
void afrodite_ast_dumper_dump (AfroditeAstDumper* self, AfroditeCodeDom* ast, const gchar* filter_symbol);
AfroditeSymbol* afrodite_code_dom_get_root (AfroditeCodeDom* self);
gboolean afrodite_symbol_get_has_children (AfroditeSymbol* self);
static void afrodite_ast_dumper_dump_symbols (AfroditeAstDumper* self, ValaList* symbols, const gchar* filter_symbol);
ValaList* afrodite_symbol_get_children (AfroditeSymbol* self);
gboolean afrodite_code_dom_get_has_source_files (AfroditeCodeDom* self);
ValaList* afrodite_code_dom_get_source_files (AfroditeCodeDom* self);
gboolean afrodite_source_file_get_has_using_directives (AfroditeSourceFile* self);
gpointer afrodite_data_type_ref (gpointer instance);
void afrodite_data_type_unref (gpointer instance);
GParamSpec* afrodite_param_spec_data_type (const gchar* name, const gchar* nick, const gchar* blurb, GType object_type, GParamFlags flags);
void afrodite_value_set_data_type (GValue* value, gpointer v_object);
void afrodite_value_take_data_type (GValue* value, gpointer v_object);
gpointer afrodite_value_get_data_type (const GValue* value);
GType afrodite_data_type_get_type (void) G_GNUC_CONST;
ValaList* afrodite_source_file_get_using_directives (AfroditeSourceFile* self);
const gchar* afrodite_data_type_get_type_name (AfroditeDataType* self);
gchar* afrodite_symbol_get_fully_qualified_name (AfroditeSymbol* self);
gboolean afrodite_symbol_get_has_local_variables (AfroditeSymbol* self);
ValaList* afrodite_symbol_get_local_variables (AfroditeSymbol* self);
AfroditeSourceReference* afrodite_data_type_get_source_reference (AfroditeDataType* self);
gchar* afrodite_data_type_get_description (AfroditeDataType* self);
AfroditeAstDumper* afrodite_ast_dumper_new (void);
AfroditeAstDumper* afrodite_ast_dumper_construct (GType object_type);
static void afrodite_ast_dumper_finalize (ValaCodeVisitor* obj);


static void afrodite_ast_dumper_inc_pad (AfroditeAstDumper* self) {
	g_return_if_fail (self != NULL);
	if (self->priv->pad == NULL) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup ("");
		_g_free0 (self->priv->pad);
		self->priv->pad = _tmp0_;
		self->priv->level = 0;
	} else {
		gchar* _tmp1_ = NULL;
		self->priv->level++;
		_tmp1_ = g_strnfill ((gsize) self->priv->level, '\t');
		_g_free0 (self->priv->pad);
		self->priv->pad = _tmp1_;
	}
}


static void afrodite_ast_dumper_dec_pad (AfroditeAstDumper* self) {
	g_return_if_fail (self != NULL);
	if (self->priv->pad == NULL) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup ("");
		_g_free0 (self->priv->pad);
		self->priv->pad = _tmp0_;
		self->priv->level = 0;
		g_error ("astdumper.vala:51: dec_pad call!!!");
	} else {
		if (self->priv->level == 0) {
			_g_free0 (self->priv->pad);
			self->priv->pad = NULL;
		} else {
			gchar* _tmp1_ = NULL;
			self->priv->level--;
			_tmp1_ = g_strnfill ((gsize) self->priv->level, '\t');
			_g_free0 (self->priv->pad);
			self->priv->pad = _tmp1_;
		}
	}
}


static void afrodite_ast_dumper_print_symbol (AfroditeAstDumper* self, AfroditeSymbol* s) {
	gchar* _tmp0_ = NULL;
	gchar* _tmp1_;
	g_return_if_fail (self != NULL);
	_tmp0_ = afrodite_ast_dumper_create_symbol_dump_info (self, s, TRUE);
	_tmp1_ = _tmp0_;
	g_print ("%s\n", _tmp1_);
	_g_free0 (_tmp1_);
}


static gpointer _vala_iterable_ref0 (gpointer self) {
	return self ? vala_iterable_ref (self) : NULL;
}


gchar* afrodite_ast_dumper_create_symbol_dump_info (AfroditeAstDumper* self, AfroditeSymbol* s, gboolean update_counters) {
	gchar* result = NULL;
	GString* _tmp1_ = NULL;
	GString* sb;
	gboolean _tmp2_ = FALSE;
	gboolean _tmp3_ = FALSE;
	gboolean _tmp4_ = FALSE;
	gboolean _tmp5_ = FALSE;
	gboolean _tmp6_ = FALSE;
	AfroditeMemberType _tmp7_;
	gchar* _tmp16_ = NULL;
	gchar* _tmp17_;
	gchar* _tmp18_ = NULL;
	gchar* _tmp19_;
	gboolean _tmp20_;
	gchar* _tmp29_;
	g_return_val_if_fail (self != NULL, NULL);
	if (s == NULL) {
		gchar* _tmp0_;
		_tmp0_ = g_strdup ("(empty)");
		result = _tmp0_;
		return result;
	}
	if (self->priv->pad == NULL) {
		afrodite_ast_dumper_inc_pad (self);
	}
	_tmp1_ = g_string_new ("");
	sb = _tmp1_;
	g_string_append (sb, self->priv->pad);
	_tmp7_ = afrodite_symbol_get_member_type (s);
	if (_tmp7_ == AFRODITE_MEMBER_TYPE_NAMESPACE) {
		_tmp6_ = TRUE;
	} else {
		AfroditeMemberType _tmp8_;
		_tmp8_ = afrodite_symbol_get_member_type (s);
		_tmp6_ = _tmp8_ == AFRODITE_MEMBER_TYPE_CLASS;
	}
	if (_tmp6_) {
		_tmp5_ = TRUE;
	} else {
		AfroditeMemberType _tmp9_;
		_tmp9_ = afrodite_symbol_get_member_type (s);
		_tmp5_ = _tmp9_ == AFRODITE_MEMBER_TYPE_STRUCT;
	}
	if (_tmp5_) {
		_tmp4_ = TRUE;
	} else {
		AfroditeMemberType _tmp10_;
		_tmp10_ = afrodite_symbol_get_member_type (s);
		_tmp4_ = _tmp10_ == AFRODITE_MEMBER_TYPE_INTERFACE;
	}
	if (_tmp4_) {
		_tmp3_ = TRUE;
	} else {
		AfroditeMemberType _tmp11_;
		_tmp11_ = afrodite_symbol_get_member_type (s);
		_tmp3_ = _tmp11_ == AFRODITE_MEMBER_TYPE_ENUM;
	}
	if (_tmp3_) {
		_tmp2_ = TRUE;
	} else {
		AfroditeMemberType _tmp12_;
		_tmp12_ = afrodite_symbol_get_member_type (s);
		_tmp2_ = _tmp12_ == AFRODITE_MEMBER_TYPE_ERROR_DOMAIN;
	}
	if (_tmp2_) {
		AfroditeMemberType _tmp13_;
		gchar* _tmp14_ = NULL;
		gchar* _tmp15_;
		_tmp13_ = afrodite_symbol_get_member_type (s);
		_tmp14_ = afrodite_utils_symbols_get_symbol_type_description (_tmp13_);
		_tmp15_ = _tmp14_;
		g_string_append_printf (sb, "%s ", _tmp15_);
		_g_free0 (_tmp15_);
	}
	_tmp16_ = afrodite_symbol_get_description (s);
	_tmp17_ = _tmp16_;
	_tmp18_ = afrodite_utils_unescape_xml_string (_tmp17_);
	_tmp19_ = _tmp18_;
	g_string_append_printf (sb, "%s ", _tmp19_);
	_g_free0 (_tmp19_);
	_g_free0 (_tmp17_);
	_tmp20_ = afrodite_symbol_get_has_source_references (s);
	if (_tmp20_) {
		g_string_append (sb, "   - [");
		{
			ValaList* _tmp21_ = NULL;
			ValaList* _tmp22_;
			ValaList* _sr_list;
			gint _tmp23_;
			gint _sr_size;
			gint _sr_index;
			_tmp21_ = afrodite_symbol_get_source_references (s);
			_tmp22_ = _vala_iterable_ref0 (_tmp21_);
			_sr_list = _tmp22_;
			_tmp23_ = vala_collection_get_size ((ValaCollection*) _sr_list);
			_sr_size = _tmp23_;
			_sr_index = -1;
			while (TRUE) {
				gpointer _tmp24_ = NULL;
				AfroditeSourceReference* sr;
				gint _tmp25_;
				gint _tmp26_;
				AfroditeSourceFile* _tmp27_ = NULL;
				const gchar* _tmp28_ = NULL;
				_sr_index = _sr_index + 1;
				if (!(_sr_index < _sr_size)) {
					break;
				}
				_tmp24_ = vala_list_get (_sr_list, _sr_index);
				sr = (AfroditeSourceReference*) _tmp24_;
				_tmp25_ = afrodite_source_reference_get_first_line (sr);
				_tmp26_ = afrodite_source_reference_get_last_line (sr);
				_tmp27_ = afrodite_source_reference_get_file (sr);
				_tmp28_ = afrodite_source_file_get_filename (_tmp27_);
				g_string_append_printf (sb, "(%d - %d) %s, ", _tmp25_, _tmp26_, _tmp28_);
				_afrodite_source_reference_unref0 (sr);
			}
			_vala_iterable_unref0 (_sr_list);
		}
		g_string_truncate (sb, (gsize) (sb->len - 2));
		g_string_append (sb, "]");
	}
	if (update_counters) {
		self->priv->symbols++;
	}
	_tmp29_ = g_strdup (sb->str);
	result = _tmp29_;
	_g_string_free0 (sb);
	return result;
}


void afrodite_ast_dumper_dump (AfroditeAstDumper* self, AfroditeCodeDom* ast, const gchar* filter_symbol) {
	GTimer* _tmp0_ = NULL;
	GTimer* timer;
	AfroditeSymbol* _tmp1_ = NULL;
	gboolean _tmp2_;
	gboolean _tmp5_;
	gdouble _tmp17_;
	g_return_if_fail (self != NULL);
	g_return_if_fail (ast != NULL);
	_g_free0 (self->priv->pad);
	self->priv->pad = NULL;
	self->priv->level = 0;
	self->priv->symbols = 0;
	self->priv->unresolved_types = 0;
	self->priv->types = 0;
	_tmp0_ = g_timer_new ();
	timer = _tmp0_;
	g_timer_start (timer);
	_tmp1_ = afrodite_code_dom_get_root (ast);
	_tmp2_ = afrodite_symbol_get_has_children (_tmp1_);
	if (_tmp2_) {
		AfroditeSymbol* _tmp3_ = NULL;
		ValaList* _tmp4_ = NULL;
		_tmp3_ = afrodite_code_dom_get_root (ast);
		_tmp4_ = afrodite_symbol_get_children (_tmp3_);
		afrodite_ast_dumper_dump_symbols (self, _tmp4_, filter_symbol);
		g_print ("Dump done. Symbols %d, Types examinated %d of which unresolved %d\n" \
"\n", self->priv->symbols, self->priv->types, self->priv->unresolved_types);
	} else {
		g_print ("context empty!\n");
	}
	_tmp5_ = afrodite_code_dom_get_has_source_files (ast);
	if (_tmp5_) {
		g_print ("Source files:\n");
		{
			ValaList* _tmp6_ = NULL;
			ValaList* _tmp7_;
			ValaList* _file_list;
			gint _tmp8_;
			gint _file_size;
			gint _file_index;
			_tmp6_ = afrodite_code_dom_get_source_files (ast);
			_tmp7_ = _vala_iterable_ref0 (_tmp6_);
			_file_list = _tmp7_;
			_tmp8_ = vala_collection_get_size ((ValaCollection*) _file_list);
			_file_size = _tmp8_;
			_file_index = -1;
			while (TRUE) {
				gpointer _tmp9_ = NULL;
				AfroditeSourceFile* file;
				const gchar* _tmp10_ = NULL;
				gboolean _tmp11_;
				_file_index = _file_index + 1;
				if (!(_file_index < _file_size)) {
					break;
				}
				_tmp9_ = vala_list_get (_file_list, _file_index);
				file = (AfroditeSourceFile*) _tmp9_;
				_tmp10_ = afrodite_source_file_get_filename (file);
				g_print ("\tsource: %s\n", _tmp10_);
				_tmp11_ = afrodite_source_file_get_has_using_directives (file);
				if (_tmp11_) {
					g_print ("\t\tusing directives:\n");
					{
						ValaList* _tmp12_ = NULL;
						ValaList* _tmp13_;
						ValaList* _d_list;
						gint _tmp14_;
						gint _d_size;
						gint _d_index;
						_tmp12_ = afrodite_source_file_get_using_directives (file);
						_tmp13_ = _vala_iterable_ref0 (_tmp12_);
						_d_list = _tmp13_;
						_tmp14_ = vala_collection_get_size ((ValaCollection*) _d_list);
						_d_size = _tmp14_;
						_d_index = -1;
						while (TRUE) {
							gpointer _tmp15_ = NULL;
							AfroditeDataType* d;
							const gchar* _tmp16_ = NULL;
							_d_index = _d_index + 1;
							if (!(_d_index < _d_size)) {
								break;
							}
							_tmp15_ = vala_list_get (_d_list, _d_index);
							d = (AfroditeDataType*) _tmp15_;
							_tmp16_ = afrodite_data_type_get_type_name (d);
							g_print ("\t\t\tusing: %s\n", _tmp16_);
							_afrodite_data_type_unref0 (d);
						}
						_vala_iterable_unref0 (_d_list);
					}
				}
				_afrodite_source_file_unref0 (file);
			}
			_vala_iterable_unref0 (_file_list);
		}
	}
	g_timer_stop (timer);
	_tmp17_ = g_timer_elapsed (timer, NULL);
	g_print ("Dump done in %g\n", _tmp17_);
	_g_timer_destroy0 (timer);
}


static void afrodite_ast_dumper_dump_symbols (AfroditeAstDumper* self, ValaList* symbols, const gchar* filter_symbol) {
	g_return_if_fail (self != NULL);
	g_return_if_fail (symbols != NULL);
	afrodite_ast_dumper_inc_pad (self);
	{
		ValaList* _tmp0_;
		ValaList* _symbol_list;
		gint _tmp1_;
		gint _symbol_size;
		gint _symbol_index;
		_tmp0_ = _vala_iterable_ref0 (symbols);
		_symbol_list = _tmp0_;
		_tmp1_ = vala_collection_get_size ((ValaCollection*) _symbol_list);
		_symbol_size = _tmp1_;
		_symbol_index = -1;
		while (TRUE) {
			gpointer _tmp2_ = NULL;
			AfroditeSymbol* symbol;
			gboolean _tmp3_ = FALSE;
			gboolean _tmp4_ = FALSE;
			_symbol_index = _symbol_index + 1;
			if (!(_symbol_index < _symbol_size)) {
				break;
			}
			_tmp2_ = vala_list_get (_symbol_list, _symbol_index);
			symbol = (AfroditeSymbol*) _tmp2_;
			if (g_strcmp0 (filter_symbol, "") == 0) {
				_tmp4_ = TRUE;
			} else {
				_tmp4_ = filter_symbol == NULL;
			}
			if (_tmp4_) {
				_tmp3_ = TRUE;
			} else {
				gchar* _tmp5_ = NULL;
				gchar* _tmp6_;
				_tmp5_ = afrodite_symbol_get_fully_qualified_name (symbol);
				_tmp6_ = _tmp5_;
				_tmp3_ = g_strcmp0 (filter_symbol, _tmp6_) == 0;
				_g_free0 (_tmp6_);
			}
			if (_tmp3_) {
				gboolean _tmp7_;
				gboolean _tmp21_;
				afrodite_ast_dumper_print_symbol (self, symbol);
				_tmp7_ = afrodite_symbol_get_has_local_variables (symbol);
				if (_tmp7_) {
					afrodite_ast_dumper_inc_pad (self);
					g_print ("%slocal variables\n", self->priv->pad);
					{
						ValaList* _tmp8_ = NULL;
						ValaList* _tmp9_;
						ValaList* _local_list;
						gint _tmp10_;
						gint _local_size;
						gint _local_index;
						_tmp8_ = afrodite_symbol_get_local_variables (symbol);
						_tmp9_ = _vala_iterable_ref0 (_tmp8_);
						_local_list = _tmp9_;
						_tmp10_ = vala_collection_get_size ((ValaCollection*) _local_list);
						_local_size = _tmp10_;
						_local_index = -1;
						while (TRUE) {
							gpointer _tmp11_ = NULL;
							AfroditeDataType* local;
							AfroditeSourceReference* _tmp12_ = NULL;
							AfroditeSourceReference* sr;
							gchar* _tmp13_ = NULL;
							gchar* _tmp14_;
							gchar* _tmp15_ = NULL;
							gchar* _tmp16_;
							gint _tmp17_;
							gint _tmp18_;
							AfroditeSourceFile* _tmp19_ = NULL;
							const gchar* _tmp20_ = NULL;
							_local_index = _local_index + 1;
							if (!(_local_index < _local_size)) {
								break;
							}
							_tmp11_ = vala_list_get (_local_list, _local_index);
							local = (AfroditeDataType*) _tmp11_;
							_tmp12_ = afrodite_data_type_get_source_reference (local);
							sr = _tmp12_;
							_tmp13_ = afrodite_data_type_get_description (local);
							_tmp14_ = _tmp13_;
							_tmp15_ = afrodite_utils_unescape_xml_string (_tmp14_);
							_tmp16_ = _tmp15_;
							_tmp17_ = afrodite_source_reference_get_first_line (sr);
							_tmp18_ = afrodite_source_reference_get_last_line (sr);
							_tmp19_ = afrodite_source_reference_get_file (sr);
							_tmp20_ = afrodite_source_file_get_filename (_tmp19_);
							g_print ("%s   %s     - [(%d - %d) %s]\n", self->priv->pad, _tmp16_, _tmp17_, _tmp18_, _tmp20_);
							_g_free0 (_tmp16_);
							_g_free0 (_tmp14_);
							_afrodite_data_type_unref0 (local);
						}
						_vala_iterable_unref0 (_local_list);
					}
					afrodite_ast_dumper_dec_pad (self);
				}
				_tmp21_ = afrodite_symbol_get_has_children (symbol);
				if (_tmp21_) {
					ValaList* _tmp22_ = NULL;
					_tmp22_ = afrodite_symbol_get_children (symbol);
					afrodite_ast_dumper_dump_symbols (self, _tmp22_, NULL);
				}
			}
			_g_object_unref0 (symbol);
		}
		_vala_iterable_unref0 (_symbol_list);
	}
	afrodite_ast_dumper_dec_pad (self);
}


AfroditeAstDumper* afrodite_ast_dumper_construct (GType object_type) {
	AfroditeAstDumper* self = NULL;
	self = (AfroditeAstDumper*) vala_code_visitor_construct (object_type);
	return self;
}


AfroditeAstDumper* afrodite_ast_dumper_new (void) {
	return afrodite_ast_dumper_construct (AFRODITE_TYPE_AST_DUMPER);
}


static void afrodite_ast_dumper_class_init (AfroditeAstDumperClass * klass) {
	afrodite_ast_dumper_parent_class = g_type_class_peek_parent (klass);
	VALA_CODE_VISITOR_CLASS (klass)->finalize = afrodite_ast_dumper_finalize;
	g_type_class_add_private (klass, sizeof (AfroditeAstDumperPrivate));
}


static void afrodite_ast_dumper_instance_init (AfroditeAstDumper * self) {
	self->priv = AFRODITE_AST_DUMPER_GET_PRIVATE (self);
	self->priv->pad = NULL;
	self->priv->level = 0;
	self->priv->symbols = 0;
	self->priv->unresolved_types = 0;
	self->priv->types = 0;
}


static void afrodite_ast_dumper_finalize (ValaCodeVisitor* obj) {
	AfroditeAstDumper * self;
	self = AFRODITE_AST_DUMPER (obj);
	_g_free0 (self->priv->pad);
	VALA_CODE_VISITOR_CLASS (afrodite_ast_dumper_parent_class)->finalize (obj);
}


GType afrodite_ast_dumper_get_type (void) {
	static volatile gsize afrodite_ast_dumper_type_id__volatile = 0;
	if (g_once_init_enter (&afrodite_ast_dumper_type_id__volatile)) {
		static const GTypeInfo g_define_type_info = { sizeof (AfroditeAstDumperClass), (GBaseInitFunc) NULL, (GBaseFinalizeFunc) NULL, (GClassInitFunc) afrodite_ast_dumper_class_init, (GClassFinalizeFunc) NULL, NULL, sizeof (AfroditeAstDumper), 0, (GInstanceInitFunc) afrodite_ast_dumper_instance_init, NULL };
		GType afrodite_ast_dumper_type_id;
		afrodite_ast_dumper_type_id = g_type_register_static (VALA_TYPE_CODE_VISITOR, "AfroditeAstDumper", &g_define_type_info, 0);
		g_once_init_leave (&afrodite_ast_dumper_type_id__volatile, afrodite_ast_dumper_type_id);
	}
	return afrodite_ast_dumper_type_id__volatile;
}



