%------------------------------------------------------------------------------%
% Copyright (C) 1999 INRIA/INSA.
% 
% Author : Erwan Jahier <jahier@irisa.fr>
%
% define a monitor which is used in control_flow.op

:- import_module list.

:- type my_proc ---> proc_name/arity.
:- type edge ---> edge(my_proc, my_proc).
:- type graph == list(edge).

:- type collected_type --->  
	collected_type(my_proc, graph).

initialize(collected_type("main"/2, [])).

filter(Event, AccIn, AccOut, continue) :-
	Port = port(Event),
	AccIn = collected_type(Proc, Graph),
	( 
		not (Port = call ; Port = exit ; Port = redo ; Port = fail)
	->
		AccOut = AccIn
	;
		Proc2 = proc_name(Event) / proc_arity(Event),
		Edge = edge(Proc, Proc2),
		( member(Edge, Graph) ->
			AccOut = AccIn
		;
			AccOut = collected_type(Proc2, [Edge|Graph])
		)
	).

