:- module (mdbcomp.trace_counts).
:- interface.
:- import_module bool.
:- import_module io.
:- import_module list.
:- import_module map.
:- import_module maybe.
:- import_module set.
:- import_module (mdbcomp.goal_path).
:- import_module (mdbcomp.prim_data).
:- type all_or_nonzero
	--->	user_all 
	;	user_nonzero .
:- type base_count_file_type
	--->	base_count_file_type(mdbcomp.trace_counts.all_or_nonzero, string).
:- type line_no_and_count
	--->	line_no_and_count(((mdbcomp.trace_counts).line_number) :: int, ((mdbcomp.trace_counts).exec_count) :: int, ((mdbcomp.trace_counts).num_tests) :: int).
:- type path_port
	--->	port_only(mdbcomp.prim_data.trace_port)
	;	path_only(mdbcomp.goal_path.reverse_goal_path)
	;	port_and_path(mdbcomp.prim_data.trace_port, mdbcomp.goal_path.reverse_goal_path).
:- type proc_label_in_context
	--->	proc_label_in_context(((mdbcomp.trace_counts).context_module_symname) :: mdbcomp.prim_data.sym_name, ((mdbcomp.trace_counts).context_filename) :: string, ((mdbcomp.trace_counts).proc_label) :: mdbcomp.prim_data.proc_label).
:- type proc_trace_counts == map.map(mdbcomp.trace_counts.path_port, mdbcomp.trace_counts.line_no_and_count).
:- type read_trace_counts_list_result
	--->	list_ok(mdbcomp.trace_counts.trace_count_file_type, mdbcomp.trace_counts.trace_counts)
	;	list_error_message(string).
:- type read_trace_counts_result
	--->	ok(mdbcomp.trace_counts.trace_count_file_type, mdbcomp.trace_counts.trace_counts)
	;	syntax_error(string)
	;	error_message(string)
	;	open_error(io.error)
	;	io_error(io.error).
:- type trace_count_file_type
	--->	single_file(mdbcomp.trace_counts.base_count_file_type)
	;	union_file(int, list.list(mdbcomp.trace_counts.trace_count_file_type))
	;	diff_file(mdbcomp.trace_counts.trace_count_file_type, mdbcomp.trace_counts.trace_count_file_type).
:- type trace_counts == map.map(mdbcomp.trace_counts.proc_label_in_context, mdbcomp.trace_counts.proc_trace_counts).
:- func calc_num_tests(list.list(mdbcomp.trace_counts.trace_count_file_type)) = int.
:- pred diff_trace_counts(mdbcomp.trace_counts.trace_counts, mdbcomp.trace_counts.trace_counts, mdbcomp.trace_counts.trace_counts).
:- mode diff_trace_counts((builtin.in), (builtin.in), (builtin.out)) is det.
:- func make_path_port(mdbcomp.goal_path.reverse_goal_path, mdbcomp.prim_data.trace_port) = mdbcomp.trace_counts.path_port.
:- func num_tests_for_file_type(mdbcomp.trace_counts.trace_count_file_type) = int.
:- pred read_and_union_trace_counts(bool.bool, list.list(string), int, set.set(mdbcomp.trace_counts.trace_count_file_type), mdbcomp.trace_counts.trace_counts, maybe.maybe(string), io.io, io.io).
:- mode read_and_union_trace_counts((builtin.in), (builtin.in), (builtin.out), (builtin.out), (builtin.out), (builtin.out), (builtin.di), (builtin.uo)) is det.
:- pred read_trace_counts(string, mdbcomp.trace_counts.read_trace_counts_result, io.io, io.io).
:- mode read_trace_counts((builtin.in), (builtin.out), (builtin.di), (builtin.uo)) is det.
:- pred read_trace_counts_list(bool.bool, string, mdbcomp.trace_counts.read_trace_counts_list_result, io.io, io.io).
:- mode read_trace_counts_list((builtin.in), (builtin.in), (builtin.out), (builtin.di), (builtin.uo)) is det.
:- pred read_trace_counts_source(string, mdbcomp.trace_counts.read_trace_counts_list_result, io.io, io.io).
:- mode read_trace_counts_source((builtin.in), (builtin.out), (builtin.di), (builtin.uo)) is det.
:- pred restrict_trace_counts_to_module(mdbcomp.prim_data.module_name, mdbcomp.trace_counts.trace_counts, mdbcomp.trace_counts.trace_counts).
:- mode restrict_trace_counts_to_module((builtin.in), (builtin.in), (builtin.out)) is det.
:- pred string_to_trace_port(string, mdbcomp.prim_data.trace_port).
:- mode string_to_trace_port((builtin.in), (builtin.out)) is semidet.
:- mode string_to_trace_port((builtin.out), (builtin.in)) is det.
:- func sum_trace_count_file_type(mdbcomp.trace_counts.trace_count_file_type, mdbcomp.trace_counts.trace_count_file_type) = mdbcomp.trace_counts.trace_count_file_type.
:- pred sum_trace_counts(mdbcomp.trace_counts.trace_counts, mdbcomp.trace_counts.trace_counts, mdbcomp.trace_counts.trace_counts).
:- mode sum_trace_counts((builtin.in), (builtin.in), (builtin.out)) is det.
:- pred summarize_trace_counts_list(list.list(mdbcomp.trace_counts.trace_counts), mdbcomp.trace_counts.trace_counts).
:- mode summarize_trace_counts_list((builtin.in), (builtin.out)) is det.
:- pred write_proc_label(mdbcomp.prim_data.proc_label, io.io, io.io).
:- mode write_proc_label((builtin.in), (builtin.di), (builtin.uo)) is det.
:- pred write_trace_counts_to_file(mdbcomp.trace_counts.trace_count_file_type, mdbcomp.trace_counts.trace_counts, string, io.res, io.io, io.io).
:- mode write_trace_counts_to_file((builtin.in), (builtin.in), (builtin.in), (builtin.out), (builtin.di), (builtin.uo)) is det.
