From 51096652b2d63065b496f9733428177455fa70ba Mon Sep 17 00:00:00 2001 From: geno Date: Fri, 22 Dec 2023 18:25:55 +0100 Subject: [PATCH 01/11] refactor: 1. eval_codeline is now more concise 2. adding features is more easy and natural 3. wip_lv record added to help evaluation --- examples/hello/greet_local_view.dot | 4 +- .../anonfun_line15_local_view.dot | 9 + examples/high-order-fun/greet_local_view.dot | 18 +- examples/high-order-fun/hof.erl | 3 +- src/choreography/actor_emul.erl | 28 +- src/choreography/global_view.erl | 6 +- src/choreography/gv.erl | 610 ++++++++++++++++++ src/choreography/lv.erl | 567 ++++++++++++++++ src/choreography/md.erl | 43 ++ src/chorer.erl | 46 +- src/share/common_data.hrl | 71 +- src/share/common_fun.erl | 10 +- 12 files changed, 1319 insertions(+), 96 deletions(-) create mode 100644 examples/high-order-fun/anonfun_line15_local_view.dot create mode 100644 src/choreography/gv.erl create mode 100644 src/choreography/lv.erl create mode 100644 src/choreography/md.erl diff --git a/examples/hello/greet_local_view.dot b/examples/hello/greet_local_view.dot index e4c31a8..8da9cb7 100644 --- a/examples/hello/greet_local_view.dot +++ b/examples/hello/greet_local_view.dot @@ -6,7 +6,7 @@ digraph greet { n_2 [id="2", shape=doublecircle, label="3"]; n_3 [id="3", shape=circle, label="2"]; - n_3 -> n_1 [id="[$e|4]", label="send hello1 to greet"]; - n_3 -> n_2 [id="[$e|2]", label="receive hello1"]; n_1 -> n_3 [id="[$e|3]", label="send hello1 to greet"]; + n_3 -> n_2 [id="[$e|1]", label="receive hello1"]; + n_3 -> n_1 [id="[$e|4]", label="send hello1 to greet"]; } diff --git a/examples/high-order-fun/anonfun_line15_local_view.dot b/examples/high-order-fun/anonfun_line15_local_view.dot new file mode 100644 index 0000000..91fa46e --- /dev/null +++ b/examples/high-order-fun/anonfun_line15_local_view.dot @@ -0,0 +1,9 @@ +digraph anonfun_line15 { + rankdir="LR"; + n_0 [label="anonfun_line15", shape="plaintext"]; + n_1 [id="1", shape=circle, label="1"]; + n_0 -> n_1 [arrowhead=none]; + n_2 [id="2", shape=doublecircle, label="2"]; + + n_1 -> n_2 [id="[$e|0]", label="receive hello"]; +} diff --git a/examples/high-order-fun/greet_local_view.dot b/examples/high-order-fun/greet_local_view.dot index e010089..5863a6e 100644 --- a/examples/high-order-fun/greet_local_view.dot +++ b/examples/high-order-fun/greet_local_view.dot @@ -1,13 +1,15 @@ digraph greet { rankdir="LR"; n_0 [label="greet", shape="plaintext"]; - n_1 [id="1", shape=circle, label="1"]; - n_0 -> n_1 [arrowhead=none]; - n_2 [id="2", shape=circle, label="2"]; - n_3 [id="4", shape=circle, label="3"]; - n_4 [id="3", shape=doublecircle, label="4"]; + n_1 [id="5", shape=doublecircle, label="5"]; + n_2 [id="1", shape=circle, label="1"]; + n_0 -> n_2 [arrowhead=none]; + n_3 [id="2", shape=circle, label="2"]; + n_4 [id="4", shape=circle, label="4"]; + n_5 [id="3", shape=circle, label="3"]; - n_3 -> n_4 [id="[$e|1]", label="receive hello"]; - n_2 -> n_3 [id="[$e|0]", label="send hello to Fun_0"]; - n_1 -> n_2 [id="[$e|2]", label="spawn Fun_0"]; + n_4 -> n_1 [id="[$e|3]", label="receive hello"]; + n_2 -> n_3 [id="[$e|1]", label="spawn anonfun_line15_0"]; + n_3 -> n_5 [id="[$e|0]", label="send hello to anonfun_line15_0"]; + n_5 -> n_4 [id="[$e|2]", label="send hello to greet"]; } diff --git a/examples/high-order-fun/hof.erl b/examples/high-order-fun/hof.erl index c7367a8..50890d6 100644 --- a/examples/high-order-fun/hof.erl +++ b/examples/high-order-fun/hof.erl @@ -12,6 +12,7 @@ greet() -> hello -> done end end, - A = spawn(fun() -> recv() end), %% TODO: implementare questa feature + A = spawn(fun() -> recv() end), A ! hello, + self() ! hello, Fun(). diff --git a/src/choreography/actor_emul.erl b/src/choreography/actor_emul.erl index 42c5081..715ac94 100644 --- a/src/choreography/actor_emul.erl +++ b/src/choreography/actor_emul.erl @@ -39,16 +39,15 @@ send_recv(P, Data) -> {D} -> D end. -%%% Actor simulator main function proc_loop(Data) -> - ProcName = Data#proc_info.proc_id, + ProcName = Data#actor_info.proc_id, G = db_manager:get_fun_graph(ProcName), % timer:sleep(200), - VCurr = Data#proc_info.current_vertex, - FirstMarkedE = Data#proc_info.first_marked_edges, - SecondMarkedE = Data#proc_info.second_marked_edges, - MessageQueue = Data#proc_info.message_queue, - LocalVars = Data#proc_info.local_vars, + VCurr = Data#actor_info.current_state, + FirstMarkedE = Data#actor_info.first_marked_edges, + SecondMarkedE = Data#actor_info.second_marked_edges, + MessageQueue = Data#actor_info.message_queue, + LocalVars = Data#actor_info.local_vars, receive {use_transition, E} -> IsAlreadyMarkedOnce = lists:member(E, FirstMarkedE), @@ -64,8 +63,8 @@ proc_loop(Data) -> false -> LocalVars end, - proc_loop(Data#proc_info{ - current_vertex = VNew, + proc_loop(Data#actor_info{ + current_state = VNew, second_marked_edges = SecondMarkedE ++ [E], local_vars = NewL }); @@ -80,8 +79,8 @@ proc_loop(Data) -> false -> LocalVars end, - proc_loop(Data#proc_info{ - current_vertex = VNew, + proc_loop(Data#actor_info{ + current_state = VNew, first_marked_edges = FirstMarkedE ++ [E], local_vars = NewL }); @@ -109,17 +108,16 @@ proc_loop(Data) -> P ! {sets:to_list(LocalVars)}, proc_loop(Data); {add_local_var, V} -> - proc_loop(Data#proc_info{local_vars = sets:add_element(V, LocalVars)}); + proc_loop(Data#actor_info{local_vars = sets:add_element(V, LocalVars)}); {P, get_mess_queue} -> P ! {MessageQueue}, proc_loop(Data); {add_mess_queue, M} -> - proc_loop(Data#proc_info{message_queue = MessageQueue ++ [M]}); + proc_loop(Data#actor_info{message_queue = MessageQueue ++ [M]}); {del_mess_queue, M} -> - proc_loop(Data#proc_info{message_queue = lists:delete(M, MessageQueue)}); + proc_loop(Data#actor_info{message_queue = lists:delete(M, MessageQueue)}); stop -> ok end. -%%% Filter and edge list, given a list of edges filter_marked_edges(EdgeL, MarkedE) -> [E || E <- EdgeL, not lists:member(E, MarkedE)]. diff --git a/src/choreography/global_view.erl b/src/choreography/global_view.erl index 245558c..96f9628 100644 --- a/src/choreography/global_view.erl +++ b/src/choreography/global_view.erl @@ -34,7 +34,7 @@ generate(OutputDir, EntryPoint) -> create_globalview(Name) -> RetG = digraph:new(), VNew = common_fun:add_vertex(RetG), - MainProcPid = spawn(actor_emul, proc_loop, [#proc_info{proc_id = Name}]), + MainProcPid = spawn(actor_emul, proc_loop, [#actor_info{proc_id = Name}]), ProcPidMap = #{Name => MainProcPid}, % initialize first branch progress_procs(RetG, [new_branch(RetG, VNew, ProcPidMap)]). @@ -146,7 +146,7 @@ duplicate_proccess(ProcMap) -> maps:fold( fun(K, V, A) -> Name = remove_id_from_proc(K), - NewPid = spawn(actor_emul, proc_loop, [#proc_info{proc_id = Name}]), + NewPid = spawn(actor_emul, proc_loop, [#actor_info{proc_id = Name}]), actor_emul:set_proc_data(NewPid, actor_emul:get_proc_data(V)), maps:put(K, NewPid, A) end, @@ -264,7 +264,7 @@ is_substring(S, SubS) -> is_list(string:find(S, SubS)). add_spawn_to_global(SLabel, ProcName, Data) -> ProcId = string:prefix(SLabel, "spawn "), FuncName = remove_last(remove_last(ProcId)), - FuncPid = spawn(actor_emul, proc_loop, [#proc_info{proc_id = ltoa(FuncName)}]), + FuncPid = spawn(actor_emul, proc_loop, [#actor_info{proc_id = ltoa(FuncName)}]), NewMap = maps:put(ltoa(ProcId), FuncPid, Data#branch.proc_pid_m), VNew = common_fun:add_vertex(Data#branch.graph), %%% Δ means spawned diff --git a/src/choreography/gv.erl b/src/choreography/gv.erl new file mode 100644 index 0000000..f6c7371 --- /dev/null +++ b/src/choreography/gv.erl @@ -0,0 +1,610 @@ +-module(gv). +-include("../share/common_data.hrl"). + +%%% API +-export([generate/2]). + +%%%=================================================================== +%%% API +%%%=================================================================== + +%%% Generate the glabal view from an entrypoint and save it in a specified folder +generate(OutputDir, EntryPoint) -> + MainGraph = db_manager:get_fun_graph(EntryPoint), + case MainGraph of + no_graph_found -> + no_entry_point_found; + _ -> + G = create_globalview(EntryPoint), + {ok, [In]} = io:fread("Minimize global view? [y/n] ", "~a"), + CG = + case In of + n -> G; + _ -> fsa:minimize(G) + end, + common_fun:save_graph_to_file(CG, OutputDir, atol(EntryPoint), global), + finished + end. + +%%%=================================================================== +%%% Internal Functions +%%%=================================================================== + +%%% Create the glabal view from a function entrypoint name +create_globalview(Name) -> + RetG = digraph:new(), + VNew = common_fun:add_vertex(RetG), + MainProcPid = spawn(actor_emul, proc_loop, [#actor_info{proc_id = Name}]), + ProcPidMap = #{Name => MainProcPid}, + % initialize first branch + progress_procs(RetG, [new_branch(RetG, VNew, ProcPidMap)]). + +%%% Create a new branch object +new_branch(G, V, P) -> + #branch{ + graph = G, + last_vertex = V, + proc_pid_m = P + }. + +%%% Create a new message object +new_message(F, D, E) -> + #message{ + from = F, data = D, edge = E + }. + +%%% Explore every possible branch of executions +progress_procs(G, []) -> + G; +progress_procs(GlobalGraph, BranchList) when is_list(BranchList) -> + RealList = lists:flatten(BranchList), + %io:fwrite("Branch to eval ~p~n", [length(RealList)]), + NewBL = lists:foldl( + fun(Item, AccL) -> + %io:fwrite("Eval branch~n"), + NewBreanches = progress_single_branch(Item), + AccL ++ NewBreanches + end, + [], + RealList + ), + progress_procs(GlobalGraph, NewBL). + +%%% Explore the execution of a single branch +progress_single_branch(BData) -> + %%% First let's eval each actor until it reaches a recv edges + {TempBranchData, OpDone, NBL} = eval_branch_until_recv(BData), + %%% Then, let's eval recv edges for each actor, creating a new execution branch foreach message + TempProcPidMap = TempBranchData#branch.proc_pid_m, + NewBranchList = + NBL ++ + maps:fold( + fun(Name, Pid, AccList) -> + MessageQueue = actor_emul:get_proc_mess_queue(Pid), + %io:fwrite("[PROGSB] Name ~p MQ ~p~n", [Name, MessageQueue]), + gen_branch_foreach_mess(TempBranchData, MessageQueue, Name, AccList) + end, + [], + TempProcPidMap + ), + case NewBranchList =:= [] of + true -> + case OpDone of + true -> [TempBranchData]; + false -> [] + end; + false -> + NewBranchList + end. + +%%% Generate new branches for each message accepted from an actor +gen_branch_foreach_mess(BranchData, MessageQueue, ProcName, BaseList) -> + lists:foldl( + fun(Message, AccList) -> + %%% Check if there's an edge who accepts the message + DupData = dup_branch(BranchData), + NewMap = DupData#branch.proc_pid_m, + NewPid = maps:get(ProcName, NewMap), + case manage_recv(NewPid, Message) of + ?UNDEFINED -> + stop_processes(NewMap), + AccList; + %%% If an edge has been found, duplicate the branch and add the transition to the graph + EdgeFound -> + %io:fwrite("[RECV] Mess ~p Edge choose ~p~n", [Message, EdgeFound]), + ProcFrom = Message#message.from, + MessData = Message#message.data, + PidFrom = maps:get(ProcFrom, NewMap), + Label = format_send_label(ProcFrom, ProcName, MessData), + %io:fwrite("~n~n[RECV] LABEL ~ts~n~n", [Label]), + EFromInfo = actor_emul:get_proc_edge_info(PidFrom, Message#message.edge), + EToInfo = actor_emul:get_proc_edge_info(NewPid, EdgeFound), + %LastVertex = simple_add_vertex(DupData, Label), + {LastVertex, NewStateMap} = complex_add_vertex( + ProcFrom, EFromInfo, ProcName, EToInfo, DupData, Label + ), + actor_emul:del_proc_mess_queue(NewPid, Message), + %%% NOTE: the last operation MUST be the use_proc_transition, otherwise the final graph might be wrong + actor_emul:use_proc_transition(NewPid, EdgeFound), + AccList ++ [DupData#branch{last_vertex = LastVertex, states_m = NewStateMap}] + end + end, + BaseList, + MessageQueue + ). + +%%% Format the send label for the global view +format_send_label(ProcFrom, ProcTo, Data) -> + atol(ProcFrom) ++ "→" ++ atol(ProcTo) ++ ":" ++ atol(Data). + +%%% Create a duplicate for a branch object +dup_branch(Data) -> + Data#branch{proc_pid_m = duplicate_proccess(Data#branch.proc_pid_m)}. + +%%% Duplicate ideantical processes from a process' map +duplicate_proccess(ProcMap) -> + maps:fold( + fun(K, V, A) -> + Name = remove_id_from_proc(K), + NewPid = spawn(actor_emul, proc_loop, [#actor_info{proc_id = Name}]), + actor_emul:set_proc_data(NewPid, actor_emul:get_proc_data(V)), + maps:put(K, NewPid, A) + end, + #{}, + ProcMap + ). + +%%% Remove the number from an actor's identificator +remove_id_from_proc(ProcId) -> + SProcId = atol(ProcId), + {Name, N} = lists:split(length(SProcId) - 1, SProcId), + case catch list_to_integer(N) of + {'EXIT', _} -> ProcId; + _ -> ltoa(remove_last(Name)) + end. + +%%% Evaluate the edges of a local view until it reaches a receive edge foreach actor +eval_branch_until_recv(BranchData) -> + Map = BranchData#branch.proc_pid_m, + {NewData, OP, LL} = maps:fold( + fun(Name, Pid, {D, B, L}) -> + {ND, BB, LL} = eval_proc_branch(Name, Pid, D), + {ND, B or BB, L ++ [LL]} + end, + {BranchData, false, []}, + Map + ), + case OP of + true -> + {ND, _, L} = eval_branch_until_recv(NewData), + {ND, true, LL ++ L}; + false -> + {NewData, false, LL} + end. + +%%% Evaluate the edges of a local view until it reaches a receive edge +eval_proc_branch(ProcName, ProcPid, Data) -> + EL = actor_emul:get_proc_edges(ProcPid), + ELLength = length(EL), + if + ELLength =:= 0 -> + {Data, false, []}; + ELLength =:= 1 -> + E = common_fun:first(EL), + EI = actor_emul:get_proc_edge_info(ProcPid, E), + {D, B} = eval_edge(EI, ProcName, ProcPid, Data), + {D, B, []}; + true -> + Cond = is_lists_edgerecv(ProcPid, EL), + case Cond of + true -> + {Data, false, []}; + false -> + LL = lists:foldl( + fun(ItemE, L) -> + DD = dup_branch(Data), + PP = maps:get(ProcName, DD#branch.proc_pid_m), + EI = actor_emul:get_proc_edge_info(PP, ItemE), + {D, B} = eval_edge(EI, ProcName, PP, DD), + case B of + true -> L ++ [D]; + false -> L + end + end, + [], + EL + ), + case LL =:= [] of + true -> + {Data, false, []}; + false -> + [F | H] = LL, + {F, true, H} + end + end + end. + +%%% Given a list of edges, check if one is a receive edge +is_lists_edgerecv(ProcPid, EL) -> + lists:foldl( + fun(E, A) -> + {E, _, _, Label} = actor_emul:get_proc_edge_info(ProcPid, E), + A or is_substring(atol(Label), "receive") + end, + false, + EL + ). + +%%% Evaluate a transition from an actor +eval_edge(EdgeInfo, ProcName, ProcPid, BData) -> + {Edge, _, _, PLabel} = EdgeInfo, + %io:fwrite("Proc ~p eval label ~p~n", [ProcName, PLabel]), + SLabel = atol(PLabel), + IsArg = is_substring(SLabel, "arg"), + IsSpawn = is_substring(SLabel, "spawn"), + IsSend = is_substring(SLabel, "send"), + if + IsArg -> + actor_emul:use_proc_transition(ProcPid, Edge), + {BData, true}; + IsSpawn -> + {VNew, NewM} = add_spawn_to_global(SLabel, ProcName, BData), + NewBData = BData#branch{last_vertex = VNew, proc_pid_m = NewM}, + actor_emul:use_proc_transition(ProcPid, Edge), + {NewBData, true}; + IsSend -> + manage_send(SLabel, BData, ProcName, ProcPid, Edge); + true -> + {BData, false} + end. + +is_substring(S, SubS) -> is_list(string:find(S, SubS)). + +%%% Add a spanw transition to the global view +add_spawn_to_global(SLabel, ProcName, Data) -> + ProcId = string:prefix(SLabel, "spawn "), + FuncName = remove_last(remove_last(ProcId)), + FuncPid = spawn(actor_emul, proc_loop, [#actor_info{proc_id = ltoa(FuncName)}]), + NewMap = maps:put(ltoa(ProcId), FuncPid, Data#branch.proc_pid_m), + VNew = common_fun:add_vertex(Data#branch.graph), + %%% Δ means spawned + NewLabel = atol(ProcName) ++ "Δ" ++ ProcId, + digraph:add_edge(Data#branch.graph, Data#branch.last_vertex, VNew, NewLabel), + {VNew, NewMap}. + +%%% Remove the last element froom a list +remove_last(List) when is_list(List) -> + {Rest, _} = lists:split(length(List) - 1, List), + Rest. + +%%% Evaluate a send transition of an actor +manage_send(SLabel, Data, ProcName, ProcPid, Edge) -> + ProcPidMap = Data#branch.proc_pid_m, + DataSent = get_data_from_label(SLabel), + ProcSentTemp = ltoa(get_proc_from_label(SLabel)), + IsVar = common_fun:is_erlvar(ProcSentTemp), + ProcSentName = + case IsVar of + true -> check_vars(ProcName, ProcPid, ProcSentTemp); + false -> ProcSentTemp + end, + ProcSentPid = maps:get(ProcSentName, ProcPidMap, no_pid), + case ProcSentPid of + no_pid -> + %io:fwrite("[SEND-ERR] no pid found for: ~p~n", [ProcSentName]), + {Data, false}; + P -> + actor_emul:add_proc_mess_queue(P, new_message(ProcName, DataSent, Edge)), + %%% NOTE: the last operation MUST be the use_proc_transition, otherwise the final graph might be wrong + actor_emul:use_proc_transition(ProcPid, Edge), + {Data, true} + end. + +%%% Evaluate a receive transition of an actor +manage_recv(ProcPid, Message) -> + EL = actor_emul:get_proc_edges(ProcPid), + %%% TODO: trovare il modo di valutare in ordine i rami del receive (in quanto è molto rilevante nell'esecuzione) + IsRecv = is_lists_edgerecv(ProcPid, EL), + %io:fwrite("IsRECV ~p EL ~p~n", [IsRecv, EL]), + From = Message#message.from, + case IsRecv of + false -> + % TODO: gestire casistica, il seguente codice è vecchio e quindi da prendere con le pinze + % {NewL, NOp} = lists:foldl( + % fun(E, A) -> + % EInfo = get_proc_edge_info(ProcPid, E), + % {B, C} = A, + % {D, O} = eval_edge(EInfo, ProcName, ProcPid, Data), + % {B ++ [D], C or O} + % end, + % {[], false}, + % EL + % ), + % [H | T] = NewL, + % {H, T, NOp}; + ?UNDEFINED; + true -> + {_, EdgeChoosen} = lists:foldl( + fun(E, {B, Ret}) -> + case B of + true -> + {B, Ret}; + false -> + {E, _, _, ELabel} = actor_emul:get_proc_edge_info(ProcPid, E), + IsIt = is_pm_msg_compatible(ProcPid, From, ELabel, Message), + case IsIt of + true -> {true, E}; + false -> {B, Ret} + end + end + end, + {false, ?UNDEFINED}, + EL + ), + EdgeChoosen + end. + +%%% Find the actor id from a variable's list, given the variable name +check_vars(ProcName, ProcPid, VarName) -> + Name = remove_id_from_proc(ProcName), + GlobalViewLocalVars = actor_emul:get_proc_localvars(ProcPid), + LocalViewLocalVars = db_manager:get_fun_local_vars(Name), + SpInfoP = find_spawn_info(ProcName), + ArgsVars = + case SpInfoP =:= [] of + true -> + []; + false -> + convertL_in_variable( + SpInfoP#spawned_proc.args_called, SpInfoP#spawned_proc.args_local + ) + end, + SeachList = ArgsVars ++ LocalViewLocalVars ++ GlobalViewLocalVars, + %io:fwrite("Find var ~p in ~p from ~p~n", [VarName, SeachList, ProcName]), + VarValue = find_var(SeachList, VarName), + case VarValue of + nomatch -> + VarName; + V -> + case V#variable.type of + ?UNDEFINED -> VarName; + "self" -> SpInfoP#spawned_proc.called_where; + self -> SpInfoP#spawned_proc.called_where; + "pid_self" -> SpInfoP#spawned_proc.called_where; + pid_self -> SpInfoP#spawned_proc.called_where; + _ -> remove_pid_part(V#variable.type) + end + end. + +%%% Remove the "pid_" part from a variable's type +remove_pid_part(Data) -> + ltoa(lists:flatten(string:replace(atol(Data), "pid_", ""))). + +%%% Get the spawn info given an actor id +find_spawn_info(PId) -> + SpInfoAll = db_manager:get_spawn_info(), + common_fun:first(lists:filter(fun(S) -> S#spawned_proc.name =:= PId end, SpInfoAll)). + +%%% Convert a list AST in a variable's list +convertL_in_variable(A, B) -> + convertL_in_variable(A, B, []). +convertL_in_variable({nil, _}, [], L) -> + L; +convertL_in_variable({cons, _, HeadList, TailList}, [H | T], L) -> + {var, _, Name} = H, + Var = convert_in_variable(HeadList, Name), + AL = convertL_in_variable(TailList, T, L), + [Var] ++ AL; +convertL_in_variable(_, _, _) -> + []. + +%%% Evaluate an AST entry and converts it to a variable +convert_in_variable(Eval, Name) -> + TempV = #variable{name = Name}, + case Eval of + {cons, _, HeadList, TailList} -> + Var = convert_in_variable(HeadList, ?UNDEFINED), + VarT = convert_in_variable(TailList, ?UNDEFINED), + NewVal = [Var] ++ VarT#variable.value, + TempV#variable{value = NewVal}; + %%% Evaluate Types + {call, _, {atom, _, self}, _} -> + TempV#variable{type = ltoa("pid_self")}; + {integer, _, Val} -> + TempV#variable{type = integer, value = Val}; + {float, _, Val} -> + TempV#variable{type = float, value = Val}; + {string, _, Val} -> + TempV#variable{type = string, value = Val}; + {atom, _, Val} -> + TempV#variable{type = atom, value = Val}; + {tuple, _, TupleVal} -> + L = lists:foldl( + fun(I, A) -> + V = convert_in_variable(I, ?UNDEFINED), + A ++ [V] + end, + [], + TupleVal + ), + TempV#variable{type = tuple, value = L}; + {nil, _} -> + TempV#variable{type = list, value = []}; + _ -> + TempV + end. + +%%% Find a variable in a list, given the name +find_var([], _) -> + nomatch; +find_var([H | T], VarName) -> + Cond = H#variable.name =:= VarName, + case Cond of + true -> H; + false -> find_var(T, VarName) + end. + +%%% Check if a pattern metching match a message, then register the new variables +is_pm_msg_compatible(ProcPid, CallingProc, PatternMatching, Message) -> + {RetBool, RegList} = check_msg_comp( + ProcPid, CallingProc, PatternMatching, Message#message.data + ), + lists:foreach( + fun(Item) -> register_var(Item) end, + RegList + ), + RetBool. + +%%% Check if a pattern metching match a message +check_msg_comp(ProcPid, CallingProc, PatternMatching, Message) -> + MessageS = atol(Message), + PatternMS = lists:flatten(string:replace(atol(PatternMatching), "receive ", "")), + [FirstPChar | RestP] = PatternMS, + [FirstMChar | RestM] = MessageS, + IsFirstCharUpperCase = common_fun:is_erlvar(PatternMS), + if + %%% hierarchy + ([FirstPChar] =:= "{") and ([FirstMChar] =:= "{") -> + ContentP = remove_last(RestP), + ContentM = remove_last(RestM), + PL = string:split(ContentP, ",", all), + A = lists:enumerate(PL), + ML = string:split(ContentM, ",", all), + B = lists:enumerate(ML), + BoolList = [ + check_msg_comp(ProcPid, CallingProc, IA, IB) + || {BA, IA} <- A, {BB, IB} <- B, BA =:= BB + ], + and_rec(BoolList); + PatternMS =:= MessageS -> + {true, []}; + IsFirstCharUpperCase -> + {true, [{ProcPid, ltoa(PatternMS), check_pid_self(Message, CallingProc)}]}; + [FirstPChar] =:= "_" -> + {true, []}; + true -> + {false, []} + end. + +%%% Register a actor's variable +register_var(Data) -> + {ProcPid, Name, Type} = Data, + V = #variable{name = ltoa(Name), type = ltoa(Type)}, + %io:fwrite("Added Var ~p~n", [V]), + actor_emul:add_proc_localvars(ProcPid, V). + +%%% Substitute pif_self to pid_procId +check_pid_self(Data, ProcId) -> + % %io:fwrite("[C]Data ~p proc id ~p~n", [Data, ProcId]), + lists:flatten(string:replace(atol(Data), "pid_self", "pid_" ++ atol(ProcId))). + +%%% Custom recursive logic and +and_rec([]) -> + {true, []}; +and_rec([{B, L} | T]) -> + case B of + true -> + {A, LL} = and_rec(T), + {A, L ++ LL}; + false -> + {B, []} + end. + +%%% Add a send/recv vertex to the global view, with some checks for recusive edges +complex_add_vertex(Proc1, EdgeInfo1, Proc2, EdgeInfo2, Data, Label) -> + StateM = Data#branch.states_m, + VLast = Data#branch.last_vertex, + G = Data#branch.graph, + {_, V1, V2, _} = EdgeInfo1, + {_, PV1, PV2, _} = EdgeInfo2, + EL = digraph:out_edges(G, VLast), + %%% Check if these vertex correspond to a global view's vertex + Vfirst = maps:get({{Proc1, V2}, {Proc2, PV2}}, StateM, ?UNDEFINED), + %%% Recheck vertexs, but in another order + Vsecond = maps:get({{Proc2, PV2}, {Proc1, V2}}, StateM, ?UNDEFINED), + %%% Check if already exist the same transition + case check_same_label(G, EL, Label) of + nomatch -> + case Vfirst of + ?UNDEFINED -> + case Vsecond of + ?UNDEFINED -> + Cond = (V1 =:= V2) and (PV1 =:= PV2), + case Cond of + true -> + digraph:add_edge(G, VLast, VLast, Label), + NewM = maps:put({{Proc1, V1}, {Proc2, PV1}}, VLast, StateM), + {VLast, NewM}; + %%% Add a new vertex, because no match found in StateM + false -> + VAdded = common_fun:add_vertex(G), + digraph:add_edge(G, VLast, VAdded, Label), + NewM = maps:put({{Proc1, V1}, {Proc2, PV1}}, VLast, StateM), + {VAdded, NewM} + end; + _ -> + %%% Match second vertex + digraph:add_edge(G, VLast, Vsecond, Label), + NewM = maps:put({{Proc1, V1}, {Proc2, PV1}}, VLast, StateM), + {Vsecond, NewM} + end; + _ -> + %%% Match First vertex + %io:fwrite("[ADD]First defined!!~n"), + digraph:add_edge(G, VLast, Vfirst, Label), + {Vfirst, StateM} + end; + VRet -> + {VRet, StateM} + end. + +% simple_add_vertex(Data, Label) -> +% VLast = Data#branch.last_vertex, +% G = Data#branch.graph, +% VAdded = common_fun:add_vertex(G), +% digraph:add_edge(G, VLast, VAdded, Label), +% VAdded. + +%%% Returns the outgoing vertex given a label and a list of transition +check_same_label(G, EL, Label) -> + lists:foldl( + fun(E, A) -> + {E, _, VTo, VLabel} = digraph:edge(G, E), + case VLabel =:= Label of + true -> VTo; + false -> A + end + end, + nomatch, + EL + ). + +%%% Get the data from a send local view's label +get_data_from_label(S) -> + Ret = lists:nth(2, string:split(S, " ", all)), + FirstChar = common_fun:first(Ret), + if + [FirstChar] =:= "[" -> Ret ++ " " ++ lists:nth(3, string:split(S, " ", all)); + true -> Ret + end. + +%%% Get the process from a send local view's label +get_proc_from_label(S) -> + lists:reverse(lists:nth(1, string:split(lists:reverse(S), " ", all))). + +%%% Stop all the processes from the process map +stop_processes(DataL) when is_list(DataL) -> + lists:foreach( + fun(D) -> + M = D#branch.proc_pid_m, + stop_processes(M) + end, + DataL + ); +stop_processes(ProcMap) -> + maps:foreach(fun(_K, V) -> V ! stop end, ProcMap). + +atol(A) when is_list(A) -> A; +atol(A) when is_atom(A) -> atom_to_list(A). +ltoa(L) when is_atom(L) -> L; +ltoa(L) when is_list(L) -> list_to_atom(L). diff --git a/src/choreography/lv.erl b/src/choreography/lv.erl new file mode 100644 index 0000000..735401e --- /dev/null +++ b/src/choreography/lv.erl @@ -0,0 +1,567 @@ +-module(lv). +-include("../share/common_data.hrl"). + +%%% API +-export([generate/1]). + +%%%=================================================================== +%%% API +%%%=================================================================== + +generate(Settings) -> + [{_, ActorList}] = ets:lookup(?DBMANAGER, ?ACTORLIST), + lists:foreach( + fun(Actor) -> create_save_localview(Actor#actor.name, Settings) end, + ActorList + ). + +%%%=================================================================== +%%% Internal Functions +%%%=================================================================== + +create_save_localview(ActorName, Settings) -> + ActorAst = get_fun_ast(ActorName), + case ActorAst of + not_found -> + io:fwrite("Error: Actor ~p's AST not found~n", [ActorName]); + _ -> + LocalViewData = check_and_get_lv(ActorName, ActorAst, Settings), + G = LocalViewData#wip_lv.graph, + set_final(G), + MinGraph = fsa:minimize(G), + OutputDir = Settings#setting.output_dir, + common_fun:save_graph_to_file(MinGraph, OutputDir, atol(ActorName), local) + end. + +create_localview(FunName) -> + ActorAst = get_fun_ast(FunName), + case ActorAst of + not_found -> + io:fwrite("Error: Function ~p's AST not found~n", [FunName]); + _ -> + check_and_get_lv(FunName, ActorAst, #setting{}) + end. + +get_fun_ast(FunName) -> + Ast = ets:lookup(?FUNAST, FunName), + case Ast of + [] -> not_found; + [{_, A}] -> A + end. + +check_and_get_lv(ActorName, Ast, Settings) -> + TempG = ets:lookup(?LOCALVIEW, ActorName), + case TempG of + [] -> + BaseData = #wip_lv{fun_name = ActorName, fun_ast = Ast, settings = Settings}, + common_fun:add_vertex(BaseData#wip_lv.graph), + D = get_localview(BaseData), + ets:insert(?LOCALVIEW, {ActorName, D}), + D; + [{_, Data}] -> + Data + end. + +get_localview(Data) -> + eval_pm_clause(Data#wip_lv.fun_ast, Data). + +add_args_to_graph(Gr, Vars, Guard, VStart, SetPm) -> + case SetPm of + true -> + VN = common_fun:add_vertex(Gr), + EdLabel = format_label_pm_edge(SetPm, Vars, Guard, "arg "), + digraph:add_edge(Gr, VStart, VN, EdLabel), + VN; + false -> + VStart + end. + +eval_codeline(CodeLine, Data) -> + % io:fwrite("evaluating ~p~n", [CodeLine]), + case CodeLine of + {clause, _, _Vars, _Guard, Content} -> eval_pm_clause(Content, Data); + {match, _, RightContent, LeftContent} -> eval_match(RightContent, LeftContent, Data); + {call, _, Function, ArgList} -> eval_call(Function, ArgList, Data); + {'case', _, Content, PMList} -> eval_case(Content, PMList, Data); + {'if', _, PMList} -> eval_pm(PMList, get_base_label(false, "if "), Data); + {'receive', _, PMList} -> eval_pm(PMList, "receive ", Data); + {op, _, Op, LeftContent, RightContent} -> eval_op(Op, LeftContent, RightContent, Data); + {'fun', N, Ast} -> eval_anon_fun(Ast, N, Data); + {integer, _, Val} -> eval_simple_type(integer, Val, Data); + {float, _, Val} -> eval_simple_type(float, Val, Data); + {string, _, Val} -> eval_simple_type(string, Val, Data); + {nil, _} -> eval_simple_type(nil, [], Data); + {atom, _, Val} -> eval_atom(Val, Data); + {cons, _, HeadList, TailList} -> eval_list(HeadList, TailList, Data); + {map, _, Val} -> eval_map(Val, Data); + {tuple, _, Val} -> eval_tuple(Val, Data); + {var, _, VarName} -> eval_variable(VarName, Data); + _ -> warning("couldn't parse code line", CodeLine, Data) + end. + +warning(String, Content, Data) -> + io:fwrite("WARNING: " ++ String ++ " ~p~n", [Content]), + Data. + +eval_pm_clause(Code, Data) -> + % db_manager:add_fun_local_vars(FunName, LocalVars), + lists:foldl( + fun(Line, AccData) -> eval_codeline(Line, AccData) end, + Data, + Code + ). + +eval_match(RightContent, LeftContent, Data) -> + case RightContent of + {var, _, VarName} -> + NewData = eval_codeline(LeftContent, Data), + Var = NewData#wip_lv.ret_var, + L = NewData#wip_lv.local_vars, + NewVarEntry = Var#variable{name = VarName}, + NewData#wip_lv{ret_var = NewVarEntry, local_vars = L ++ [NewVarEntry]}; + %%% TODO: eval pattern matching + R -> + warning("couldn't understand line", R, Data) + end. + +eval_call(Function, ArgList, Data) -> + case Function of + {atom, _, Name} -> eval_call_by_atom(Name, ArgList, Data); + {var, _, VarName} -> eval_call_by_var(VarName, ArgList, Data); + {remote, _, Package, FunName} -> eval_call_by_package(Package, FunName, ArgList, Data); + F -> warning("couldn't call function pattern", F, Data) + end. + +eval_call_by_atom(Name, ArgList, Data) -> + FunName = Data#wip_lv.fun_name, + case Name of + FunName -> eval_recursive(ArgList, Data); + spawn -> eval_spawn(ArgList, Data); + self -> eval_self(Data); + register -> eval_register(ArgList, Data); + Name -> eval_generic_call(Name, Data) + end. + +%%% Dubbio: In questo caso bisogna ritornare i Data così come sono o bisogna impostare il last_vertex all'1? +%%% TODO: Cosa fare con la lista degli argument? +eval_recursive(_ArgList, Data) -> + digraph:add_edge(Data#wip_lv.graph, Data#wip_lv.last_vertex, 1, 'ɛ'), + Data. + +eval_spawn(ArgList, Data) -> + case ArgList of + [Content] -> eval_spawn_one(Content, Data); + %%% TODO: check and implement package + [_Package, {atom, _, Name}, SpArgList] -> eval_spawn_three(Name, SpArgList, Data); + %%% TODO: spawn with 2/4 argument + _ -> warning("couldn't call function pattern", ArgList, Data) + end. + +eval_spawn_one(Content, Data) -> + G = Data#wip_lv.graph, + NewData = eval_codeline(Content, Data), + VLast = NewData#wip_lv.last_vertex, + VarFound = NewData#wip_lv.ret_var, + Id = VarFound#variable.value, + create_save_localview(ltoa(Id), Data#wip_lv.settings), + C = inc_spawn_counter(Id), + S = Id ++ "_" ++ integer_to_list(C), + VNew = common_fun:add_vertex(G), + digraph:add_edge(G, VLast, VNew, "spawn " ++ S), + % {VarArgL, _, _} = eval_codeline(ArgList, FunName, G, AccData, SetPm), + % db_manager:add_fun_arg(S, VarArgL#variable.value), + RetVar = #variable{type = ltoa("pid_" ++ S)}, + Data#wip_lv{ret_var = RetVar, last_vertex = VNew}. + +eval_spawn_three(Name, _SpArgList, Data) -> + G = Data#wip_lv.graph, + VLast = Data#wip_lv.last_vertex, + C = inc_spawn_counter(Name), + S = atol(Name) ++ "_" ++ integer_to_list(C), + VNew = common_fun:add_vertex(G), + digraph:add_edge(G, VLast, VNew, "spawn " ++ S), + % {VarArgL, _, _} = eval_codeline(ArgList, FunName, G, AccData, SetPm), + % db_manager:add_fun_arg(S, VarArgL#variable.value), + RetVar = #variable{type = ltoa("pid_" ++ S)}, + Data#wip_lv{ret_var = RetVar, last_vertex = VNew}. + +inc_spawn_counter(Name) -> + case ets:lookup(?SPAWNC, ltoa(Name)) of + [] -> + ets:insert(?SPAWNC, {Name, 1}), + 0; + [{_, N}] -> + ets:insert(?SPAWNC, {Name, N + 1}), + N + end. + +eval_self(Data) -> + RetVar = #variable{type = ltoa("pid_" ++ atol(Data#wip_lv.fun_name))}, + Data#wip_lv{ret_var = RetVar}. + +eval_register(ArgList, Data) -> + [{atom, _, AtomName}, {var, _, VarName}] = ArgList, + VarFound = find_var(Data, VarName), + case VarFound of + not_found -> + ?UNDEFINED; + V -> + IsPid = is_type_pid(V#variable.type), + Pid = get_pid_from_type(V#variable.type), + case IsPid of + false -> ?UNDEFINED; + true -> ets:insert(?REGISTERDB, {AtomName, Pid}) + end + end, + %%% Approx: ignoring returing value + Data. + +eval_generic_call(Name, Data) -> + % {V, _, NewL} = eval_codeline(ArgList, FunName, G, AccData, SetPm), + % NewData = eval_codeline(ArgList, Data), + % io:fwrite("[LOCAL] V ~p NewL ~p Name ~p~n", [V, NewL, FunName]), + case eval_func(Name) of + no_graph -> + Data; + NewD -> + G = Data#wip_lv.graph, + LastV = Data#wip_lv.last_vertex, + NewG = NewD#wip_lv.graph, + NewRet = NewD#wip_lv.ret_var, + NewLastV = merge_graph(G, NewG, LastV), + Data#wip_lv{ret_var = NewRet, last_vertex = NewLastV} + end. + +%%% TODO: eval argument list +eval_call_by_var(VarName, _ArgList, Data) -> + G = Data#wip_lv.graph, + VLast = Data#wip_lv.last_vertex, + LocalVarL = Data#wip_lv.local_vars, + VarFound = find_var(LocalVarL, VarName), + case VarFound of + not_found -> + warning("variable not found in eval_call_by_var with name", VarName, Data); + _ -> + Id = VarFound#variable.value, + NewData = create_localview(ltoa(Id)), + NewG = NewData#wip_lv.graph, + NewRet = NewData#wip_lv.ret_var, + NewLastV = merge_graph(G, NewG, VLast), + Data#wip_lv{ret_var = NewRet, last_vertex = NewLastV} + end. + +eval_call_by_package(Package, FunName, _ArgList, Data) -> + case Package of + rand -> eval_rand_package(FunName, Data); + %%% TODO: find the package and the function, create the local view of it, attach it to the current lv + _ -> warning("package not yet implemented:", Package, Data) + end. + +eval_rand_package(FunName, Data) -> + case FunName of + uniform -> eval_simple_type(integer, ?ANYDATA, Data); + %%% TODO: expand + _ -> warning("rand's function not yet implemented:", FunName, Data) + end. + +eval_case(Content, PMList, Data) -> + BaseL = + case Content of + {var, _, VarName} -> get_base_label(false, atol(VarName) ++ " match "); + _ -> get_base_label(false, "match smt") + end, + eval_pm(PMList, BaseL, Data). + +eval_op(Op, LeftContent, RightContent, Data) -> + case Op of + '!' -> eval_send(LeftContent, RightContent, Data); + %%% TODO: implement other basic operation + _ -> warning("operation not yet implemented", Op, Data) + end. + +eval_send(Destination, MessageContent, Data) -> + G = Data#wip_lv.graph, + TempData = eval_codeline(Destination, Data), + ProcName = get_pid(TempData#wip_lv.ret_var), + NewData = eval_codeline(MessageContent, TempData), + LastV = NewData#wip_lv.last_vertex, + case ProcName of + ?UNDEFINED -> + NewData; + _ -> + DataSent = recordvar_to_string(NewData#wip_lv.ret_var), + VNew = common_fun:add_vertex(G), + SLabel = "send " ++ DataSent ++ " to " ++ ProcName, + digraph:add_edge(G, LastV, VNew, SLabel), + NewData#wip_lv{last_vertex = VNew} + end. + +get_pid(Var) -> + ST = atol(Var#variable.type), + Cond = is_list(string:find(ST, "pid")), + case Cond of + true -> string:prefix(ST, "pid_"); + false -> ?UNDEFINED + end. + +eval_anon_fun(Content, N, Data) -> + case Content of + {clauses, A} -> + Id = "anonfun_line" ++ integer_to_list(N), + ets:insert(?FUNAST, {ltoa(Id), A}), + eval_simple_type(function, Id, Data); + _ -> + warning("not recognized content in eval_anon_fun", Content, Data) + end. + +eval_simple_type(Type, Val, Data) -> + VarRet = #variable{type = Type, value = Val}, + Data#wip_lv{ret_var = VarRet}. + +eval_atom(Val, Data) -> + %%% check if is a registerd atom, return the pid + case ets:lookup(?REGISTERDB, Val) of + [] -> eval_simple_type(atom, Val, Data); + [{_, Pid}] -> eval_simple_type(Pid, ?ANYDATA, Data) + end. + +eval_list(HeadList, TailList, Data) -> + NDH = eval_codeline(HeadList, Data), + NDT = eval_codeline(TailList, NDH), + Var = NDH#wip_lv.ret_var, + VarList = NDT#wip_lv.ret_var, + NewVal = [Var] ++ VarList#variable.value, + eval_simple_type(list, NewVal, NDT). + +%%% TODO +eval_map(_Val, Data) -> + Data. + +eval_tuple(Val, Data) -> + {NewVal, NewData} = lists:foldl( + fun(I, {A, D}) -> + ND = eval_codeline(I, D), + A ++ [ND#wip_lv.ret_var] + end, + {[], Data}, + Val + ), + eval_simple_type(tuple, NewVal, NewData). + +eval_variable(VarName, Data) -> + Var = find_var(Data#wip_lv.local_vars, VarName), + RetV = + case Var of + not_found -> #variable{name = VarName}; + V -> V + end, + Data#wip_lv{ret_var = RetV}. + +recordvar_to_string(Var) -> + case Var#variable.type of + ?UNDEFINED -> + atol(Var#variable.name); + Type -> + SType = atol(Type), + case Var#variable.value of + ?UNDEFINED -> + SType; + Val -> + case SType of + "integer" -> integer_to_list(Val); + "float" -> io_lib:format("~.2f", [Val]); + "string" -> "[" ++ Val ++ "]"; + "atom" -> atol(Val); + "tuple" -> format_tuple(Val, fun recordvar_to_string/1); + "pid" -> "pid"; + _ -> SType + end + end + end. + +format_tuple(VarL, Fun) -> + L = lists:foldl(fun(I, A) -> A ++ "," ++ Fun(I) end, "", VarL), + [_ | Label] = L, + "{" ++ Label ++ "}". + +get_base_label(SetPm, Label) -> + case SetPm of + true -> Label; + false -> 'ɛ' + end. + +find_var([], _) -> + not_found; +find_var([Var | Tail], Name) -> + Cond = Var#variable.name =:= Name, + case Cond of + true -> Var; + false -> find_var(Tail, Name) + end; +find_var(Data, Name) -> + LL = Data#wip_lv.local_vars, + find_var(LL, Name). + +%%% If the input is a string with "pid" in it returns true, otherwise false. +is_type_pid(Type) -> + SL = atol(Type), + IsPid = string:find(SL, "pid"), + is_list(IsPid). + +get_pid_from_type(Type) -> + SL = atol(Type), + string:prefix(SL, "pid_"). + +%%% We have a main graph G1, a graph G2 and a G1's vertex. +%%% We need to append G2 to the G1's vertex. +%%% Firstly, we add to G1 as many vertex as G2's vertex number. +%%% With a map, we associate every vertex of G2 to one of the new G1'vertex +%%% Secondly, we collect each G2's edge info and then we rebuild it in G1 using the previous map +merge_graph(MainG, GToAdd, VLast) -> + VertexGToAdd = digraph:vertices(GToAdd), + % Add a number of vertex equal to VertexGToAdd + VEquiMap = lists:foldl( + %%% With this function we add a vertex and we associate it with G2's vertex + fun(Item, M) -> maps:put(Item, common_fun:add_vertex(MainG), M) end, + maps:new(), + VertexGToAdd + ), + % link the first new state created to the main graph + digraph:add_edge(MainG, VLast, maps:get(1, VEquiMap), 'ɛ'), + % Add all the edges + EdgesGToAdd = digraph:edges(GToAdd), + lists:foreach( + fun(Item) -> + {Item, V1, V2, Label} = digraph:edge(GToAdd, Item), + %%% We use the map to rebuild the exact same edge but in G1 + digraph:add_edge(MainG, maps:get(V1, VEquiMap), maps:get(V2, VEquiMap), Label) + end, + EdgesGToAdd + ), + % return last added vertex, which is the max number in the key list + maps:get(lists:max(maps:keys(VEquiMap)), VEquiMap). + +eval_func(FuncName) -> + FunAst = get_fun_ast(FuncName), + case FunAst of + not_found -> no_graph; + _ -> create_localview(FuncName) + end. + +%%% Evaluate Pattern Matching's list of clauses: evaluate every branch alone, then +%%% link every last vertex's branch to a shared vertex with epsilon transaction +eval_pm(PMList, Label, Data) -> + VLast = Data#wip_lv.last_vertex, + G = Data#wip_lv.graph, + VLastList = explore_pm(PMList, Label, Data), + VRet = common_fun:add_vertex(G), + add_edges_recursive(G, VLastList, VRet, 'ɛ', VLast), + Data#wip_lv{last_vertex = VRet}. + +%%% Explore every pm's branch and returns the list of last added vertex +explore_pm(PMList, Base, Data) -> + G = Data#wip_lv.graph, + VLast = Data#wip_lv.last_vertex, + lists:foldl( + fun(CodeLine, AddedVertexList) -> + case CodeLine of + {clause, _, Vars, Guard, Content} -> + V = common_fun:add_vertex(G), + digraph:add_edge(G, VLast, V, 'ɛ'), + IsReceive = is_list(string:find(atol(Base), "receive")), + %%% if it's a receive pm, then the label must be written + EdLabel = format_label_pm_edge(IsReceive, Vars, Guard, atol(Base)), + VL = + case IsReceive of + true -> + VNew = common_fun:add_vertex(G), + digraph:add_edge(G, V, VNew, EdLabel), + VNew; + false -> + V + end, + VRet = eval_pm_clause(Content, Data#wip_lv{last_vertex = VL}), + AddedVertexList ++ [VRet]; + _ -> + AddedVertexList + end + end, + [], + PMList + ). + +%%% Format the Variables with the guards in a label for the FSA +format_label_pm_edge(SetPm, VarList, GuardList, BaseLabel) when is_list(BaseLabel) -> + case SetPm of + true -> + VarsS = lists:foldl(fun(V, Acc) -> astvar_to_s(V, Acc) ++ ", " end, BaseLabel, VarList), + VarGuardS = lists:foldl(fun(G, Acc) -> guards_to_s(G, Acc) end, VarsS, GuardList), + remove_last(remove_last(VarGuardS)); + false -> + 'ɛ' + end. + +%%% Remove the last element froom a list +remove_last(List) when is_list(List) -> + {Rest, _} = lists:split(length(List) - 1, List), + Rest. + +%%% Convert a data type (ast format) to a string +astvar_to_s(VarToVal) -> + astvar_to_s(VarToVal, ""). +astvar_to_s(VarToVal, BaseL) -> + BaseL ++ + case VarToVal of + %% TODO: espandere o fare refactor di sta parte + {integer, _, Value} -> integer_to_list(Value); + {var, _, '_'} -> "_"; + {tuple, _, LVar} -> format_tuple(LVar, fun astvar_to_s/1); + {var, _, Var} -> atol(Var); + {atom, _, Atom} -> atol(Atom); + {cons, _, H, T} -> "[" ++ astvar_to_s(H) ++ ", " ++ astvar_to_s(T) ++ "]"; + {nil, _} -> "null"; + _ -> atol(?UNDEFINED) + end. + +%%% Convert the guard (ast format) to a string +guards_to_s(GlobalToVal, BaseL) -> + case GlobalToVal of + %%% Add guards if there's a guard + %%% TODO: add more infos + {op, _, _, _} -> BaseL ++ " (guards)"; + _ -> BaseL + end. + +%%% Link each vertex of a vertex's list to a given vertex, with a defined label +add_edges_recursive(G, VertexList, VertexToLink, Label, Except) -> + %%% Link every V in the VertexList to the VertexToLink, with a specified label + [ + digraph:add_edge(G, V, VertexToLink, Label) + || V <- VertexList, + %%% exclude the start vertex + V =/= 1, + V =/= Except + ]. + +%%% Set vertices as a final state if they do not have out edges +set_final(Graph) -> + VL = digraph:vertices(Graph), + lists:foreach( + fun(Vertex) -> + OD = digraph:out_degree(Graph, Vertex), + {_, Label} = digraph:vertex(Graph, Vertex), + case OD =:= 0 of + true -> + FormattedLabel = ?FINALTAG ++ integer_to_list(Label), + digraph:add_vertex(Graph, Vertex, FormattedLabel); + false -> + do_nothing + end + end, + VL + ). + +ltoa(L) when is_list(L) -> list_to_atom(L); +ltoa(L) when is_atom(L) -> L. +atol(A) when is_atom(A) -> atom_to_list(A); +atol(A) when is_list(A) -> A. diff --git a/src/choreography/md.erl b/src/choreography/md.erl new file mode 100644 index 0000000..d585c67 --- /dev/null +++ b/src/choreography/md.erl @@ -0,0 +1,43 @@ +-module(md). +-include("../share/common_data.hrl"). + +%%% API +-export([extract/1, parse_file/1]). + +%%%=================================================================== +%%% API +%%%=================================================================== + +extract(InputFile) -> + gen_ast(InputFile), + gen_fun_ast_and_exported(). + +parse_file(Path) -> element(2, epp_dodger:quick_parse_file(Path)). + +%%%=================================================================== +%%% Internal Functions +%%%=================================================================== + +gen_ast(InputFile) -> + Ast = parse_file(InputFile), + ets:insert(?DBMANAGER, {?INPUTAST, Ast}). + +gen_fun_ast_and_exported() -> + [{_, Ast}] = ets:lookup(?DBMANAGER, ?INPUTAST), + List = + lists:foldl( + fun(CodeLine, AccList) -> + case CodeLine of + {attribute, _, export, AtrList} -> + AccList ++ [#actor{name = N, arity = A} || {N, A} <- AtrList]; + {function, _, Name, _, FunAst} -> + ets:insert(?FUNAST, {Name, FunAst}), + AccList; + _ -> + AccList + end + end, + [], + Ast + ), + ets:insert(?DBMANAGER, {?ACTORLIST, List}). diff --git a/src/chorer.erl b/src/chorer.erl index 9278f50..eafcd2a 100644 --- a/src/chorer.erl +++ b/src/chorer.erl @@ -2,49 +2,37 @@ -include("share/common_data.hrl"). %%% API --export([main/1, generate/2, generate/3, generate/4]). +-export([main/1, generate/2, generate/3]). %%%=================================================================== %%% API %%%=================================================================== main([InputFile, EntryPoint, OutputDir] = _Args) -> - generate(InputFile, list_to_atom(EntryPoint), OutputDir). + generate(InputFile, list_to_atom(EntryPoint), #setting{output_dir = OutputDir}). -%%% Generate the local and global view of an Erlang File source. -generate(InputFile, EntryPoint) -> - OutputDir = "./", - generate(InputFile, EntryPoint, OutputDir). - -generate(InputFile, EntryPoint, OutputDir) -> - generate(InputFile, EntryPoint, OutputDir, {false}). +-spec generate(InputFile, EntryPoint) -> atom() when + InputFile :: string(), + EntryPoint :: atom(). +generate(InputFile, EntryPoint) -> generate(InputFile, EntryPoint, #setting{}). --spec generate(InputFile, EntryPoint, OutputDir, Options) -> atom() when +-spec generate(InputFile, EntryPoint, OutDir) -> atom() when InputFile :: string(), EntryPoint :: atom(), - OutputDir :: string(), - Options :: [boolean()]. -generate(InputFile, EntryPoint, OutputDir, Options) -> + OutDir :: string(). +generate(InputFile, _EntryPoint, OutDir) -> init_db(), - %%% Get all the metadata info such as exported functions, spawn done and actors - metadata:extract(InputFile, EntryPoint), - %%% Generate local and global view and save them int the output directory - local_view:generate(OutputDir, Options), - global_view:generate(OutputDir, EntryPoint). + md:extract(InputFile), + lv:generate(#setting{output_dir = OutDir}). + % gv:generate(OutputDir, EntryPoint). %%%=================================================================== %%% Internal Functions %%%=================================================================== -%%% Initialize code manager as a key based database init_db() -> - Ret = whereis(?DBMANAGER), - case Ret of - % if the pid of the dbmenager is not defined, initialize it - 'undefined' -> - DBManagerPid = spawn(db_manager, loop, []), - register(?DBMANAGER, DBManagerPid); - % otherwise do nothing, because is already defined - _Pid -> - already_exist - end. + ets:new(?DBMANAGER, [set, named_table]), + ets:new(?FUNAST, [set, named_table]), + ets:new(?LOCALVIEW, [set, named_table]), + ets:new(?REGISTERDB, [set, named_table]), + ets:new(?SPAWNC, [set, named_table]). diff --git a/src/share/common_data.hrl b/src/share/common_data.hrl index ab6f4ab..98e79f2 100644 --- a/src/share/common_data.hrl +++ b/src/share/common_data.hrl @@ -1,44 +1,58 @@ %%%----FILE common_data.hrl---- +%%% CONSTANTS + -define(FINALTAG, "final"). -define(DBMANAGER, dbmanager). -define(UNDEFINED, none). -define(ANYDATA, any). -%%% fsa_states, a structure to keep track of all the state of a Finite State Automata -%%% start_state: a singlular starting poin, final_states: list of states -% -record(fsa_data, {all_states, start_state, final_states, transitions, labels}). +-define(INPUTAST, input_ast). +-define(ACTORLIST, actor_list). +-define(FUNAST, fun_ast). +-define(LOCALVIEW, lv). +-define(REGISTERDB, reg). +-define(SPAWNC, spc). -%%% graph node data, a structure to help the creation of the fsa -% -record(node_data, { -% is_start = false, -% is_final = false, -% guard = [], -% current_operation = none, -% label = 'ɛ' -% }). +%%% RECORDS -% -record(local_view, { -% name, -% n_args, -% ast, -% graph, -% current_vartex, -% local_vars, -% returned_var, -% nodes, -% transitions, -% recv_queue -% }). +-record(setting, { + more_info_lv = false, + debug = false, + output_dir = "./" +}). +-type setting() :: #setting{ + more_info_lv :: boolean(), + debug :: boolean(), + output_dir :: string() +}. -%%% Variable data structure -%%% type could be integrer, float, etc... or pid_prodId -record(variable, { type = ?ANYDATA, name = ?UNDEFINED, value = ?ANYDATA }). +-record(wip_lv, { + fun_name, + fun_ast, + graph = digraph:new(), + last_vertex = 1, + local_vars = [], + ret_var = #variable{}, + node_map = #{}, + settings = #setting{} +}). + +-record(node, { + id, + label, + op, + out_trans +}). + +-record(actor, {name, arity}). + %%% Spanwed processes data stracture %%% name: process id %%% called_where: in which function the spawn() is been called @@ -52,7 +66,6 @@ args_local = ?UNDEFINED }). -%%% -record(branch, { graph = digraph:new(), last_vertex = 1, @@ -60,9 +73,9 @@ states_m = #{} }). --record(proc_info, { - proc_id, - current_vertex = 1, +-record(actor_info, { + proc_id = ?UNDEFINED, + current_state = 1, first_marked_edges = [], second_marked_edges = [], local_vars = sets:new(), diff --git a/src/share/common_fun.erl b/src/share/common_fun.erl index ca13226..ffb2b15 100644 --- a/src/share/common_fun.erl +++ b/src/share/common_fun.erl @@ -26,12 +26,6 @@ pick_random(X) -> lists:nth(rand:uniform(length(X)), X). first([]) -> []; first([H | _]) -> H. -%%% Save some content into the specified directory with a formatted filename --spec save_graph_to_file(Graph, Dir, FileName, Type) -> ok when - Graph :: digraph:graph(), - Dir :: string(), - FileName :: string(), - Type :: atom(). save_graph_to_file(Graph, Dir, FileName, Type) -> case Type of local -> @@ -45,13 +39,11 @@ save_graph_to_file(Graph, Dir, FileName, Type) -> file:make_dir(Dir), file:write_file(FilePath, ToWriteData). -%%% Add a vertex to a FSA -spec add_vertex(G) -> digraph:vertex() when G :: digraph:graph(). add_vertex(G) -> Label = new_label(G), digraph:add_vertex(G, Label, Label). -%%% Delete a vertex to a FSA del_vertex(G, V) -> % TODO questa funzione cambia solo le label, l'ideale sarebbe cambiare anche il contenuto del vertice ma è difficile da fare [digraph:add_vertex(G, Ver, Ver - 1) || Ver <- digraph:vertices(G), Ver > V], @@ -91,4 +83,4 @@ new_label(Graph) -> length(digraph:vertices(Graph)) + 1. ltoa(L) when is_list(L) -> list_to_atom(L); ltoa(L) when is_atom(L) -> L. atol(A) when is_atom(A) -> atom_to_list(A); -atol(A) when is_list(A) -> A. \ No newline at end of file +atol(A) when is_list(A) -> A. From ac9e4df798d975ed269dc76e03453a6f1840a6a5 Mon Sep 17 00:00:00 2001 From: geno Date: Thu, 18 Jan 2024 19:04:05 +0100 Subject: [PATCH 02/11] fix: bus in lv, gv refactoring started --- examples/ticktack/start_global_view.dot | 36 +++---- examples/ticktack/start_local_view.dot | 18 ++-- examples/ticktack/tac_loop_local_view.dot | 12 +-- examples/ticktack/tic_loop_local_view.dot | 4 +- src/choreography/actor_emul.erl | 6 +- src/choreography/gv.erl | 13 +-- src/choreography/lv.erl | 110 +++++++++------------- src/chorer.erl | 9 +- src/share/common_fun.erl | 16 ++++ 9 files changed, 105 insertions(+), 119 deletions(-) diff --git a/examples/ticktack/start_global_view.dot b/examples/ticktack/start_global_view.dot index 4ce02bb..44048cd 100644 --- a/examples/ticktack/start_global_view.dot +++ b/examples/ticktack/start_global_view.dot @@ -1,30 +1,16 @@ digraph global { rankdir="LR"; n_0 [label="global", shape="plaintext"]; - n_1 [id="5", shape=circle, label="6"]; - n_2 [id="12", shape=circle, label="5"]; - n_3 [id="11", shape=circle, label="11"]; - n_4 [id="14", shape=circle, label="4"]; - n_5 [id="10", shape=circle, label="9"]; - n_6 [id="1", shape=circle, label="1"]; - n_0 -> n_6 [arrowhead=none]; - n_7 [id="2", shape=circle, label="2"]; - n_8 [id="8", shape=circle, label="10"]; - n_9 [id="4", shape=circle, label="7"]; - n_10 [id="7", shape=circle, label="8"]; - n_11 [id="3", shape=circle, label="3"]; + n_1 [id="5", shape=circle, label="5"]; + n_2 [id="1", shape=circle, label="1"]; + n_0 -> n_2 [arrowhead=none]; + n_3 [id="2", shape=circle, label="2"]; + n_4 [id="4", shape=circle, label="4"]; + n_5 [id="3", shape=circle, label="3"]; - n_2 -> n_9 [id="[$e|16]", label="tic_loop_0→tac_loop_0:stop"]; - n_1 -> n_10 [id="[$e|8]", label="tic_loop_0→tac_loop_0:tic"]; - n_7 -> n_11 [id="[$e|6]", label="startΔtic_loop_0"]; - n_5 -> n_3 [id="[$e|7]", label="tic_loop_0→tac_loop_0:tic"]; - n_6 -> n_7 [id="[$e|2]", label="startΔtac_loop_0"]; - n_11 -> n_4 [id="[$e|3]", label="startΔrandom_0"]; - n_4 -> n_2 [id="[$e|12]", label="random_0→tic_loop_0:stop"]; - n_5 -> n_9 [id="[$e|14]", label="tic_loop_0→tac_loop_0:stop"]; - n_10 -> n_8 [id="[$e|10]", label="random_0→tic_loop_0:stop"]; - n_1 -> n_5 [id="[$e|4]", label="random_0→tic_loop_0:stop"]; - n_3 -> n_9 [id="[$e|5]", label="tic_loop_0→tac_loop_0:stop"]; - n_4 -> n_1 [id="[$e|11]", label="start→tic_loop_0:tac"]; - n_8 -> n_9 [id="[$e|15]", label="tic_loop_0→tac_loop_0:stop"]; + n_4 -> n_1 [id="[$e|3]", label="tic_loop_0→tac_loop_0:tic"]; + n_2 -> n_3 [id="[$e|0]", label="startΔtac_loop_0"]; + n_3 -> n_5 [id="[$e|1]", label="startΔtic_loop_0"]; + n_5 -> n_4 [id="[$e|2]", label="start→tic_loop_0:tac"]; + n_1 -> n_4 [id="[$e|4]", label="tac_loop_0→tic_loop_0:tac"]; } diff --git a/examples/ticktack/start_local_view.dot b/examples/ticktack/start_local_view.dot index 3bb1530..bc84e40 100644 --- a/examples/ticktack/start_local_view.dot +++ b/examples/ticktack/start_local_view.dot @@ -1,15 +1,13 @@ digraph start { rankdir="LR"; n_0 [label="start", shape="plaintext"]; - n_1 [id="5", shape=circle, label="4"]; - n_2 [id="1", shape=circle, label="1"]; - n_0 -> n_2 [arrowhead=none]; - n_3 [id="2", shape=circle, label="2"]; - n_4 [id="4", shape=doublecircle, label="5"]; - n_5 [id="3", shape=circle, label="3"]; + n_1 [id="1", shape=circle, label="1"]; + n_0 -> n_1 [arrowhead=none]; + n_2 [id="2", shape=circle, label="2"]; + n_3 [id="4", shape=circle, label="3"]; + n_4 [id="3", shape=doublecircle, label="4"]; - n_5 -> n_1 [id="[$e|1]", label="spawn random_0"]; - n_3 -> n_5 [id="[$e|2]", label="spawn tic_loop_0"]; - n_2 -> n_3 [id="[$e|3]", label="spawn tac_loop_0"]; - n_1 -> n_4 [id="[$e|0]", label="send tac to tic_loop_0"]; + n_3 -> n_4 [id="[$e|0]", label="send tac to tic_loop_0"]; + n_2 -> n_3 [id="[$e|1]", label="spawn tic_loop_0"]; + n_1 -> n_2 [id="[$e|2]", label="spawn tac_loop_0"]; } diff --git a/examples/ticktack/tac_loop_local_view.dot b/examples/ticktack/tac_loop_local_view.dot index 38d45dd..7884bfe 100644 --- a/examples/ticktack/tac_loop_local_view.dot +++ b/examples/ticktack/tac_loop_local_view.dot @@ -3,12 +3,12 @@ digraph tac_loop { n_0 [label="tac_loop", shape="plaintext"]; n_1 [id="1", shape=circle, label="1"]; n_0 -> n_1 [arrowhead=none]; - n_2 [id="4", shape=circle, label="3"]; - n_3 [id="3", shape=doublecircle, label="2"]; + n_2 [id="2", shape=circle, label="2"]; + n_3 [id="4", shape=circle, label="3"]; + n_4 [id="3", shape=doublecircle, label="4"]; - n_2 -> n_1 [id="[$e|7]", label="send tac to tic_loop_0"]; - n_2 -> n_2 [id="[$e|2]", label="receive tic"]; - n_2 -> n_3 [id="[$e|3]", label="receive stop"]; + n_1 -> n_2 [id="[$e|3]", label="receive tic"]; + n_2 -> n_1 [id="[$e|6]", label="send tac to tic_loop_0"]; + n_3 -> n_4 [id="[$e|5]", label="send stop to tic_loop_0"]; n_1 -> n_3 [id="[$e|4]", label="receive stop"]; - n_1 -> n_2 [id="[$e|5]", label="receive tic"]; } diff --git a/examples/ticktack/tic_loop_local_view.dot b/examples/ticktack/tic_loop_local_view.dot index 4b9031e..3a48062 100644 --- a/examples/ticktack/tic_loop_local_view.dot +++ b/examples/ticktack/tic_loop_local_view.dot @@ -7,8 +7,8 @@ digraph tic_loop { n_3 [id="4", shape=circle, label="3"]; n_4 [id="3", shape=doublecircle, label="4"]; - n_1 -> n_2 [id="[$e|1]", label="receive tac"]; - n_2 -> n_1 [id="[$e|6]", label="send tic to tac_loop_0"]; n_3 -> n_4 [id="[$e|3]", label="send stop to tac_loop_0"]; + n_2 -> n_1 [id="[$e|6]", label="send tic to tac_loop_0"]; + n_1 -> n_2 [id="[$e|1]", label="receive tac"]; n_1 -> n_3 [id="[$e|4]", label="receive stop"]; } diff --git a/src/choreography/actor_emul.erl b/src/choreography/actor_emul.erl index 715ac94..fe2df0f 100644 --- a/src/choreography/actor_emul.erl +++ b/src/choreography/actor_emul.erl @@ -41,7 +41,7 @@ send_recv(P, Data) -> proc_loop(Data) -> ProcName = Data#actor_info.proc_id, - G = db_manager:get_fun_graph(ProcName), + G = common_fun:get_localview(ProcName), % timer:sleep(200), VCurr = Data#actor_info.current_state, FirstMarkedE = Data#actor_info.first_marked_edges, @@ -58,7 +58,7 @@ proc_loop(Data) -> NewL = case ToLabel =< FromLabel of true -> - io:fwrite("[PROC LOOP] RESET LOCALV IN ~p~n", [ProcName]), + % io:fwrite("[PROC LOOP] RESET LOCALV IN ~p~n", [ProcName]), sets:new(); false -> LocalVars @@ -74,7 +74,7 @@ proc_loop(Data) -> NewL = case ToLabel =< FromLabel of true -> - io:fwrite("[PROC LOOP] RESET LOCALV IN ~p~n", [ProcName]), + % io:fwrite("[PROC LOOP] RESET LOCALV IN ~p~n", [ProcName]), sets:new(); false -> LocalVars diff --git a/src/choreography/gv.erl b/src/choreography/gv.erl index f6c7371..1677495 100644 --- a/src/choreography/gv.erl +++ b/src/choreography/gv.erl @@ -9,10 +9,11 @@ %%%=================================================================== %%% Generate the glabal view from an entrypoint and save it in a specified folder -generate(OutputDir, EntryPoint) -> - MainGraph = db_manager:get_fun_graph(EntryPoint), +generate(Settings, EntryPoint) -> + OutputDir = Settings#setting.output_dir, + MainGraph = common_fun:get_localview(EntryPoint), case MainGraph of - no_graph_found -> + not_found -> no_entry_point_found; _ -> G = create_globalview(EntryPoint), @@ -346,9 +347,9 @@ manage_recv(ProcPid, Message) -> %%% Find the actor id from a variable's list, given the variable name check_vars(ProcName, ProcPid, VarName) -> - Name = remove_id_from_proc(ProcName), + % Name = remove_id_from_proc(ProcName), GlobalViewLocalVars = actor_emul:get_proc_localvars(ProcPid), - LocalViewLocalVars = db_manager:get_fun_local_vars(Name), + % LocalViewLocalVars = db_manager:get_fun_local_vars(Name), SpInfoP = find_spawn_info(ProcName), ArgsVars = case SpInfoP =:= [] of @@ -359,7 +360,7 @@ check_vars(ProcName, ProcPid, VarName) -> SpInfoP#spawned_proc.args_called, SpInfoP#spawned_proc.args_local ) end, - SeachList = ArgsVars ++ LocalViewLocalVars ++ GlobalViewLocalVars, + SeachList = ArgsVars ++ GlobalViewLocalVars, %++ LocalViewLocalVars, %io:fwrite("Find var ~p in ~p from ~p~n", [VarName, SeachList, ProcName]), VarValue = find_var(SeachList, VarName), case VarValue of diff --git a/src/choreography/lv.erl b/src/choreography/lv.erl index 735401e..6b51a94 100644 --- a/src/choreography/lv.erl +++ b/src/choreography/lv.erl @@ -20,49 +20,40 @@ generate(Settings) -> %%%=================================================================== create_save_localview(ActorName, Settings) -> - ActorAst = get_fun_ast(ActorName), + ActorAst = common_fun:get_fun_ast(ActorName), case ActorAst of not_found -> io:fwrite("Error: Actor ~p's AST not found~n", [ActorName]); _ -> + % io:fwrite("[LV] ~p~n", [ActorName]), LocalViewData = check_and_get_lv(ActorName, ActorAst, Settings), G = LocalViewData#wip_lv.graph, set_final(G), MinGraph = fsa:minimize(G), + ets:insert(?LOCALVIEW, {ActorName, MinGraph}), OutputDir = Settings#setting.output_dir, common_fun:save_graph_to_file(MinGraph, OutputDir, atol(ActorName), local) end. create_localview(FunName) -> - ActorAst = get_fun_ast(FunName), + ActorAst = common_fun:get_fun_ast(FunName), case ActorAst of - not_found -> - io:fwrite("Error: Function ~p's AST not found~n", [FunName]); - _ -> - check_and_get_lv(FunName, ActorAst, #setting{}) - end. - -get_fun_ast(FunName) -> - Ast = ets:lookup(?FUNAST, FunName), - case Ast of - [] -> not_found; - [{_, A}] -> A + not_found -> io:fwrite("Error: Function ~p's AST not found~n", [FunName]); + _ -> check_and_get_lv(FunName, ActorAst, #setting{}) end. check_and_get_lv(ActorName, Ast, Settings) -> - TempG = ets:lookup(?LOCALVIEW, ActorName), - case TempG of - [] -> + LV = common_fun:get_localview(ActorName), + case LV of + not_found -> BaseData = #wip_lv{fun_name = ActorName, fun_ast = Ast, settings = Settings}, common_fun:add_vertex(BaseData#wip_lv.graph), - D = get_localview(BaseData), - ets:insert(?LOCALVIEW, {ActorName, D}), - D; - [{_, Data}] -> - Data + build_localview(BaseData); + L -> + L end. -get_localview(Data) -> +build_localview(Data) -> eval_pm_clause(Data#wip_lv.fun_ast, Data). add_args_to_graph(Gr, Vars, Guard, VStart, SetPm) -> @@ -77,7 +68,7 @@ add_args_to_graph(Gr, Vars, Guard, VStart, SetPm) -> end. eval_codeline(CodeLine, Data) -> - % io:fwrite("evaluating ~p~n", [CodeLine]), + % io:fwrite("evaluating ~p on line ~p~n", [element(1, CodeLine), element(2, CodeLine)]), case CodeLine of {clause, _, _Vars, _Guard, Content} -> eval_pm_clause(Content, Data); {match, _, RightContent, LeftContent} -> eval_match(RightContent, LeftContent, Data); @@ -126,10 +117,14 @@ eval_match(RightContent, LeftContent, Data) -> eval_call(Function, ArgList, Data) -> case Function of - {atom, _, Name} -> eval_call_by_atom(Name, ArgList, Data); - {var, _, VarName} -> eval_call_by_var(VarName, ArgList, Data); - {remote, _, Package, FunName} -> eval_call_by_package(Package, FunName, ArgList, Data); - F -> warning("couldn't call function pattern", F, Data) + {atom, _, Name} -> + eval_call_by_atom(Name, ArgList, Data); + {var, _, VarName} -> + eval_call_by_var(VarName, ArgList, Data); + {remote, _, {atom, _, Package}, {atom, _, FunName}} -> + eval_call_by_package(Package, FunName, ArgList, Data); + F -> + warning("couldn't call function pattern", F, Data) end. eval_call_by_atom(Name, ArgList, Data) -> @@ -145,8 +140,9 @@ eval_call_by_atom(Name, ArgList, Data) -> %%% Dubbio: In questo caso bisogna ritornare i Data così come sono o bisogna impostare il last_vertex all'1? %%% TODO: Cosa fare con la lista degli argument? eval_recursive(_ArgList, Data) -> + % io:fwrite("[RECURSIVE] from vertex ~p~n", [Data#wip_lv.last_vertex]), digraph:add_edge(Data#wip_lv.graph, Data#wip_lv.last_vertex, 1, 'ɛ'), - Data. + Data#wip_lv{last_vertex = ?UNDEFINED}. eval_spawn(ArgList, Data) -> case ArgList of @@ -170,7 +166,7 @@ eval_spawn_one(Content, Data) -> digraph:add_edge(G, VLast, VNew, "spawn " ++ S), % {VarArgL, _, _} = eval_codeline(ArgList, FunName, G, AccData, SetPm), % db_manager:add_fun_arg(S, VarArgL#variable.value), - RetVar = #variable{type = ltoa("pid_" ++ S)}, + RetVar = #variable{type = pid, value = S}, Data#wip_lv{ret_var = RetVar, last_vertex = VNew}. eval_spawn_three(Name, _SpArgList, Data) -> @@ -182,7 +178,7 @@ eval_spawn_three(Name, _SpArgList, Data) -> digraph:add_edge(G, VLast, VNew, "spawn " ++ S), % {VarArgL, _, _} = eval_codeline(ArgList, FunName, G, AccData, SetPm), % db_manager:add_fun_arg(S, VarArgL#variable.value), - RetVar = #variable{type = ltoa("pid_" ++ S)}, + RetVar = #variable{type = pid, value = S}, Data#wip_lv{ret_var = RetVar, last_vertex = VNew}. inc_spawn_counter(Name) -> @@ -196,7 +192,7 @@ inc_spawn_counter(Name) -> end. eval_self(Data) -> - RetVar = #variable{type = ltoa("pid_" ++ atol(Data#wip_lv.fun_name))}, + RetVar = #variable{type = pid, value = atol(Data#wip_lv.fun_name)}, Data#wip_lv{ret_var = RetVar}. eval_register(ArgList, Data) -> @@ -206,11 +202,9 @@ eval_register(ArgList, Data) -> not_found -> ?UNDEFINED; V -> - IsPid = is_type_pid(V#variable.type), - Pid = get_pid_from_type(V#variable.type), - case IsPid of + case V#variable.type == pid of false -> ?UNDEFINED; - true -> ets:insert(?REGISTERDB, {AtomName, Pid}) + true -> ets:insert(?REGISTERDB, {AtomName, V#variable.value}) end end, %%% Approx: ignoring returing value @@ -287,7 +281,7 @@ eval_send(Destination, MessageContent, Data) -> LastV = NewData#wip_lv.last_vertex, case ProcName of ?UNDEFINED -> - NewData; + warning("Process not found", ProcName, NewData); _ -> DataSent = recordvar_to_string(NewData#wip_lv.ret_var), VNew = common_fun:add_vertex(G), @@ -297,10 +291,8 @@ eval_send(Destination, MessageContent, Data) -> end. get_pid(Var) -> - ST = atol(Var#variable.type), - Cond = is_list(string:find(ST, "pid")), - case Cond of - true -> string:prefix(ST, "pid_"); + case Var#variable.type == pid of + true -> Var#variable.value; false -> ?UNDEFINED end. @@ -322,7 +314,7 @@ eval_atom(Val, Data) -> %%% check if is a registerd atom, return the pid case ets:lookup(?REGISTERDB, Val) of [] -> eval_simple_type(atom, Val, Data); - [{_, Pid}] -> eval_simple_type(Pid, ?ANYDATA, Data) + [{_, Pid}] -> eval_simple_type(pid, Pid, Data) end. eval_list(HeadList, TailList, Data) -> @@ -402,16 +394,6 @@ find_var(Data, Name) -> LL = Data#wip_lv.local_vars, find_var(LL, Name). -%%% If the input is a string with "pid" in it returns true, otherwise false. -is_type_pid(Type) -> - SL = atol(Type), - IsPid = string:find(SL, "pid"), - is_list(IsPid). - -get_pid_from_type(Type) -> - SL = atol(Type), - string:prefix(SL, "pid_"). - %%% We have a main graph G1, a graph G2 and a G1's vertex. %%% We need to append G2 to the G1's vertex. %%% Firstly, we add to G1 as many vertex as G2's vertex number. @@ -442,7 +424,7 @@ merge_graph(MainG, GToAdd, VLast) -> maps:get(lists:max(maps:keys(VEquiMap)), VEquiMap). eval_func(FuncName) -> - FunAst = get_fun_ast(FuncName), + FunAst = common_fun:get_fun_ast(FuncName), case FunAst of not_found -> no_graph; _ -> create_localview(FuncName) @@ -456,7 +438,7 @@ eval_pm(PMList, Label, Data) -> VLastList = explore_pm(PMList, Label, Data), VRet = common_fun:add_vertex(G), add_edges_recursive(G, VLastList, VRet, 'ɛ', VLast), - Data#wip_lv{last_vertex = VRet}. + Data#wip_lv{graph = G, last_vertex = VRet}. %%% Explore every pm's branch and returns the list of last added vertex explore_pm(PMList, Base, Data) -> @@ -480,8 +462,8 @@ explore_pm(PMList, Base, Data) -> false -> V end, - VRet = eval_pm_clause(Content, Data#wip_lv{last_vertex = VL}), - AddedVertexList ++ [VRet]; + VDataRet = eval_pm_clause(Content, Data#wip_lv{last_vertex = VL}), + AddedVertexList ++ [VDataRet#wip_lv.last_vertex]; _ -> AddedVertexList end @@ -534,14 +516,16 @@ guards_to_s(GlobalToVal, BaseL) -> %%% Link each vertex of a vertex's list to a given vertex, with a defined label add_edges_recursive(G, VertexList, VertexToLink, Label, Except) -> - %%% Link every V in the VertexList to the VertexToLink, with a specified label - [ - digraph:add_edge(G, V, VertexToLink, Label) - || V <- VertexList, - %%% exclude the start vertex - V =/= 1, - V =/= Except - ]. + lists:foreach( + fun(V) -> + Cond = (V =/= Except) and (V =/= 1), + case Cond of + true -> digraph:add_edge(G, V, VertexToLink, Label); + false -> done + end + end, + VertexList + ). %%% Set vertices as a final state if they do not have out edges set_final(Graph) -> diff --git a/src/chorer.erl b/src/chorer.erl index eafcd2a..e01ceb2 100644 --- a/src/chorer.erl +++ b/src/chorer.erl @@ -9,7 +9,7 @@ %%%=================================================================== main([InputFile, EntryPoint, OutputDir] = _Args) -> - generate(InputFile, list_to_atom(EntryPoint), #setting{output_dir = OutputDir}). + generate(InputFile, list_to_atom(EntryPoint), OutputDir). -spec generate(InputFile, EntryPoint) -> atom() when InputFile :: string(), @@ -20,11 +20,12 @@ generate(InputFile, EntryPoint) -> generate(InputFile, EntryPoint, #setting{}). InputFile :: string(), EntryPoint :: atom(), OutDir :: string(). -generate(InputFile, _EntryPoint, OutDir) -> +generate(InputFile, EntryPoint, OutDir) -> init_db(), + Settings = #setting{output_dir = OutDir}, md:extract(InputFile), - lv:generate(#setting{output_dir = OutDir}). - % gv:generate(OutputDir, EntryPoint). + lv:generate(Settings), + gv:generate(Settings, EntryPoint). %%%=================================================================== %%% Internal Functions diff --git a/src/share/common_fun.erl b/src/share/common_fun.erl index ffb2b15..5a1402f 100644 --- a/src/share/common_fun.erl +++ b/src/share/common_fun.erl @@ -11,6 +11,8 @@ is_erlvar/1, is_uppercase/1, is_lowercase/1, + get_fun_ast/1, + get_localview/1, atol/1, ltoa/1 ]). @@ -67,6 +69,20 @@ is_lowercase(Char) when -> (Char >= "a") and (Char =< "z"). +get_fun_ast(FunName) -> + Ast = ets:lookup(?FUNAST, FunName), + case Ast of + [] -> not_found; + [{_, A}] -> A + end. + +get_localview(FunName) -> + Ast = ets:lookup(?LOCALVIEW, FunName), + case Ast of + [] -> not_found; + [{_, A}] -> A + end. + %%%=================================================================== %%% Internal Functions %%%=================================================================== From d5fbc63f5a297be6e4e93f9efc6c6504e976eff4 Mon Sep 17 00:00:00 2001 From: geno Date: Wed, 7 Feb 2024 17:04:18 +0100 Subject: [PATCH 03/11] fix: eval_tuple added docs and line number in warning --- docs/codebeam.md | 32 ++ docs/index.html | 1 + thesis.pdf => docs/thesis.pdf | Bin .../thesis_presentation.pdf | Bin examples/airline/agent_local_view.dot | 2 +- examples/airline/main_global_view.dot | 28 +- examples/airline/main_local_view.dot | 4 +- examples/async/main_global_view.dot | 27 +- examples/customer/customer_local_view.dot | 6 +- examples/customer/main_global_view.dot | 28 +- examples/customer/main_local_view.dot | 2 +- examples/customer/store_local_view.dot | 4 +- examples/hello/greet_local_view.dot | 4 +- examples/serverclient/client_local_view.dot | 6 +- .../serverclient/handle_req_local_view.dot | 2 +- examples/serverclient/main_global_view.dot | 25 +- examples/serverclient/main_local_view.dot | 2 +- examples/serverclient/server_local_view.dot | 8 +- examples/ticktack/start_global_view.dot | 36 ++- examples/ticktack/start_local_view.dot | 18 +- examples/ticktack/tac_loop_local_view.dot | 12 +- examples/ticktack/tic_loop_local_view.dot | 2 +- examples/trick/main_global_view.dot | 31 +- examples/trick/main_local_view.dot | 2 +- examples/violation/incrementer_local_view.dot | 10 +- examples/violation/main_global_view.dot | 279 +----------------- examples/violation/main_local_view.dot | 4 +- examples/violation/meManager_local_view.dot | 2 +- examples/violation/varManager_local_view.dot | 2 +- src/choreography/gv.erl | 7 +- src/choreography/lv.erl | 26 +- src/chorer.erl | 2 + src/share/common_data.hrl | 1 + 33 files changed, 194 insertions(+), 421 deletions(-) create mode 100644 docs/codebeam.md create mode 100644 docs/index.html rename thesis.pdf => docs/thesis.pdf (100%) rename thesis_presentation.pdf => docs/thesis_presentation.pdf (100%) diff --git a/docs/codebeam.md b/docs/codebeam.md new file mode 100644 index 0000000..ac6046c --- /dev/null +++ b/docs/codebeam.md @@ -0,0 +1,32 @@ +# Title +Chorer: a static analyser to generate Choreography Automata + +## Abstract +One of the main features of Erlang is that it enables easy communication between processes. +Choreographies are a mathematical model to describe the message-passing communications among +two or more processes. Choreography Automata are a way to graphically present a Choreography +as a finite state automaton. This representation can be used both for program understanding +and to support automatic analysis of behavioral properties, such as deadlock freedom. This +talk will present Chorer, a static analysis prototype which takes as input an Erlang source +code and ganerates a Choreography Automaton which is an over-approximation of all its possible +interactions. The talk will focus on how Chorer works, how to interpret its output, and the +basic ideas underlying its construction. + +## Talk objective: What will the audience learn from your talk? +The audience will learn what are choreographies and how Chorer allows one to exploit them for +understanding and analysis of Erlang program. + +## Target audience: Who would this talk appeal to? +Erlang programmers + +### Which three words would best sum up your talk? +choreographies, static-analysis, concurrency + + +### Speaker tagline +Master student in Computer Science at University of Bologna + +### Speaker biography +I'm a Master student in Computer science at Alma Mater Studiorum - University of Bologna. +I gradueted with a thesis focused on choreographies for Erlang, supervised by Prof. Ivan Lanese. +Into languages and distributed systems. diff --git a/docs/index.html b/docs/index.html new file mode 100644 index 0000000..efe5048 --- /dev/null +++ b/docs/index.html @@ -0,0 +1 @@ +

Hello world!

\ No newline at end of file diff --git a/thesis.pdf b/docs/thesis.pdf similarity index 100% rename from thesis.pdf rename to docs/thesis.pdf diff --git a/thesis_presentation.pdf b/docs/thesis_presentation.pdf similarity index 100% rename from thesis_presentation.pdf rename to docs/thesis_presentation.pdf diff --git a/examples/airline/agent_local_view.dot b/examples/airline/agent_local_view.dot index 9c04fa2..dd13123 100644 --- a/examples/airline/agent_local_view.dot +++ b/examples/airline/agent_local_view.dot @@ -5,6 +5,6 @@ digraph agent { n_0 -> n_1 [arrowhead=none]; n_2 [id="3", shape=circle, label="2"]; - n_1 -> n_2 [id="[$e|1]", label="send {sell,pid_self} to Pid2"]; n_2 -> n_1 [id="[$e|3]", label="receive {booked,_}"]; + n_1 -> n_2 [id="[$e|1]", label="send {sell,pid} to Pid2"]; } diff --git a/examples/airline/main_global_view.dot b/examples/airline/main_global_view.dot index add9e5d..37dcd79 100644 --- a/examples/airline/main_global_view.dot +++ b/examples/airline/main_global_view.dot @@ -1,27 +1,11 @@ digraph global { rankdir="LR"; n_0 [label="global", shape="plaintext"]; - n_1 [id="5", shape=circle, label="5"]; - n_2 [id="6", shape=circle, label="6"]; - n_3 [id="1", shape=circle, label="1"]; - n_0 -> n_3 [arrowhead=none]; - n_4 [id="2", shape=circle, label="2"]; - n_5 [id="4", shape=circle, label="4"]; - n_6 [id="7", shape=circle, label="7"]; - n_7 [id="3", shape=circle, label="3"]; + n_1 [id="1", shape=circle, label="1"]; + n_0 -> n_1 [arrowhead=none]; + n_2 [id="2", shape=circle, label="2"]; + n_3 [id="3", shape=circle, label="3"]; - n_4 -> n_7 [id="[$e|1]", label="mainΔagent_1"]; - n_3 -> n_4 [id="[$e|0]", label="mainΔagent_0"]; - n_2 -> n_5 [id="[$e|9]", label="main→agent_1:{booked,any}"]; - n_5 -> n_2 [id="[$e|4]", label="agent_1→main:{sell,pid_self}"]; - n_7 -> n_5 [id="[$e|12]", label="main→agent_1:{booked,any}"]; - n_7 -> n_5 [id="[$e|2]", label="agent_0→main:{sell,pid_self}"]; - n_1 -> n_7 [id="[$e|7]", label="main→agent_1:{booked,any}"]; - n_1 -> n_6 [id="[$e|6]", label="agent_0→main:{sell,pid_self}"]; - n_6 -> n_1 [id="[$e|10]", label="main→agent_0:{booked,any}"]; - n_5 -> n_7 [id="[$e|5]", label="main→agent_0:{booked,any}"]; - n_6 -> n_7 [id="[$e|11]", label="main→agent_1:{booked,any}"]; - n_7 -> n_1 [id="[$e|3]", label="agent_1→main:{sell,pid_self}"]; - n_2 -> n_7 [id="[$e|8]", label="main→agent_0:{booked,any}"]; - n_7 -> n_1 [id="[$e|13]", label="main→agent_0:{booked,any}"]; + n_1 -> n_2 [id="[$e|1]", label="mainΔagent_0"]; + n_2 -> n_3 [id="[$e|0]", label="mainΔagent_1"]; } diff --git a/examples/airline/main_local_view.dot b/examples/airline/main_local_view.dot index 1f36e02..b68dd5e 100644 --- a/examples/airline/main_local_view.dot +++ b/examples/airline/main_local_view.dot @@ -7,8 +7,8 @@ digraph main { n_3 [id="4", shape=circle, label="4"]; n_4 [id="3", shape=circle, label="2"]; + n_2 -> n_3 [id="[$e|3]", label="receive {sell,Pid1}"]; n_1 -> n_4 [id="[$e|1]", label="spawn agent_0"]; - n_3 -> n_2 [id="[$e|4]", label="send {booked,any} to Pid1"]; n_4 -> n_2 [id="[$e|5]", label="spawn agent_1"]; - n_2 -> n_3 [id="[$e|3]", label="receive {sell,Pid1}"]; + n_3 -> n_2 [id="[$e|4]", label="send {booked,any} to Pid1"]; } diff --git a/examples/async/main_global_view.dot b/examples/async/main_global_view.dot index c78b770..2bd62aa 100644 --- a/examples/async/main_global_view.dot +++ b/examples/async/main_global_view.dot @@ -1,19 +1,18 @@ digraph global { rankdir="LR"; n_0 [label="global", shape="plaintext"]; - n_1 [id="5", shape=circle, label="5"]; - n_2 [id="6", shape=circle, label="6"]; - n_3 [id="1", shape=circle, label="1"]; - n_0 -> n_3 [arrowhead=none]; - n_4 [id="2", shape=circle, label="2"]; - n_5 [id="4", shape=circle, label="4"]; - n_6 [id="7", shape=circle, label="7"]; - n_7 [id="3", shape=circle, label="3"]; + n_1 [id="5", shape=circle, label="6"]; + n_2 [id="1", shape=circle, label="1"]; + n_0 -> n_2 [arrowhead=none]; + n_3 [id="2", shape=circle, label="2"]; + n_4 [id="4", shape=circle, label="4"]; + n_5 [id="7", shape=circle, label="5"]; + n_6 [id="3", shape=circle, label="3"]; - n_4 -> n_7 [id="[$e|1]", label="mainΔdummy2_0"]; - n_3 -> n_4 [id="[$e|0]", label="mainΔdummy1_0"]; - n_5 -> n_2 [id="[$e|4]", label="dummy1_0→dummy2_0:bello"]; - n_7 -> n_5 [id="[$e|2]", label="dummy2_0→dummy1_0:ciao"]; - n_1 -> n_6 [id="[$e|5]", label="dummy2_0→dummy1_0:ciao"]; - n_7 -> n_1 [id="[$e|3]", label="dummy1_0→dummy2_0:bello"]; + n_6 -> n_4 [id="[$e|3]", label="dummy1_0→dummy2_0:bello"]; + n_2 -> n_3 [id="[$e|1]", label="mainΔdummy1_0"]; + n_3 -> n_6 [id="[$e|2]", label="mainΔdummy2_0"]; + n_4 -> n_1 [id="[$e|0]", label="dummy2_0→dummy1_0:ciao"]; + n_5 -> n_1 [id="[$e|6]", label="dummy1_0→dummy2_0:bello"]; + n_6 -> n_5 [id="[$e|4]", label="dummy2_0→dummy1_0:ciao"]; } diff --git a/examples/customer/customer_local_view.dot b/examples/customer/customer_local_view.dot index 1b897b6..f92b1db 100644 --- a/examples/customer/customer_local_view.dot +++ b/examples/customer/customer_local_view.dot @@ -8,10 +8,10 @@ digraph customer { n_4 [id="4", shape=circle, label="4"]; n_5 [id="7", shape=circle, label="2"]; - n_3 -> n_4 [id="[$e|5]", label="send payment to store_0"]; + n_4 -> n_1 [id="[$e|2]", label="receive accepted"]; n_4 -> n_3 [id="[$e|9]", label="receive reject"]; - n_2 -> n_5 [id="[$e|3]", label="send item to store_0"]; + n_3 -> n_4 [id="[$e|5]", label="send payment to store_0"]; n_5 -> n_2 [id="[$e|8]", label="send more to store_0"]; + n_2 -> n_5 [id="[$e|3]", label="send item to store_0"]; n_5 -> n_3 [id="[$e|7]", label="send buy to store_0"]; - n_4 -> n_1 [id="[$e|2]", label="receive accepted"]; } diff --git a/examples/customer/main_global_view.dot b/examples/customer/main_global_view.dot index 9b69c6d..53c6af6 100644 --- a/examples/customer/main_global_view.dot +++ b/examples/customer/main_global_view.dot @@ -1,23 +1,21 @@ digraph global { rankdir="LR"; n_0 [label="global", shape="plaintext"]; - n_1 [id="5", shape=circle, label="5"]; - n_2 [id="6", shape=circle, label="6"]; + n_1 [id="5", shape=circle, label="6"]; + n_2 [id="6", shape=circle, label="7"]; n_3 [id="1", shape=circle, label="1"]; n_0 -> n_3 [arrowhead=none]; n_4 [id="2", shape=circle, label="2"]; - n_5 [id="8", shape=circle, label="8"]; - n_6 [id="4", shape=circle, label="4"]; - n_7 [id="7", shape=circle, label="7"]; - n_8 [id="3", shape=circle, label="3"]; + n_5 [id="8", shape=circle, label="4"]; + n_6 [id="4", shape=circle, label="5"]; + n_7 [id="3", shape=circle, label="3"]; - n_1 -> n_7 [id="[$e|5]", label="customer_0→store_0:payment"]; - n_4 -> n_8 [id="[$e|1]", label="mainΔstore_0"]; - n_3 -> n_4 [id="[$e|0]", label="mainΔcustomer_0"]; - n_6 -> n_1 [id="[$e|3]", label="customer_0→store_0:buy"]; - n_2 -> n_6 [id="[$e|6]", label="customer_0→store_0:item"]; - n_6 -> n_2 [id="[$e|4]", label="customer_0→store_0:more"]; - n_7 -> n_5 [id="[$e|8]", label="store_0→customer_0:accepted"]; - n_7 -> n_1 [id="[$e|7]", label="store_0→customer_0:reject"]; - n_8 -> n_6 [id="[$e|2]", label="customer_0→store_0:item"]; + n_4 -> n_7 [id="[$e|2]", label="mainΔstore_0"]; + n_5 -> n_7 [id="[$e|9]", label="customer_0→store_0:more"]; + n_1 -> n_2 [id="[$e|0]", label="store_0→customer_0:accepted"]; + n_6 -> n_1 [id="[$e|1]", label="customer_0→store_0:payment"]; + n_1 -> n_6 [id="[$e|5]", label="store_0→customer_0:reject"]; + n_5 -> n_6 [id="[$e|8]", label="customer_0→store_0:buy"]; + n_3 -> n_4 [id="[$e|4]", label="mainΔcustomer_0"]; + n_7 -> n_5 [id="[$e|7]", label="customer_0→store_0:item"]; } diff --git a/examples/customer/main_local_view.dot b/examples/customer/main_local_view.dot index 16d9271..3fe9570 100644 --- a/examples/customer/main_local_view.dot +++ b/examples/customer/main_local_view.dot @@ -6,6 +6,6 @@ digraph main { n_2 [id="2", shape=circle, label="2"]; n_3 [id="3", shape=doublecircle, label="3"]; - n_2 -> n_3 [id="[$e|1]", label="spawn store_0"]; n_1 -> n_2 [id="[$e|0]", label="spawn customer_0"]; + n_2 -> n_3 [id="[$e|1]", label="spawn store_0"]; } diff --git a/examples/customer/store_local_view.dot b/examples/customer/store_local_view.dot index f0d3c1a..cf1abb8 100644 --- a/examples/customer/store_local_view.dot +++ b/examples/customer/store_local_view.dot @@ -8,10 +8,10 @@ digraph store { n_4 [id="7", shape=doublecircle, label="5"]; n_5 [id="3", shape=circle, label="2"]; - n_1 -> n_4 [id="[$e|5]", label="send accepted to customer_0"]; n_5 -> n_3 [id="[$e|9]", label="receive buy"]; + n_1 -> n_4 [id="[$e|5]", label="send accepted to customer_0"]; + n_5 -> n_2 [id="[$e|8]", label="receive more"]; n_2 -> n_5 [id="[$e|3]", label="receive item"]; n_1 -> n_3 [id="[$e|4]", label="send reject to customer_0"]; - n_5 -> n_2 [id="[$e|8]", label="receive more"]; n_3 -> n_1 [id="[$e|7]", label="receive payment"]; } diff --git a/examples/hello/greet_local_view.dot b/examples/hello/greet_local_view.dot index 8da9cb7..d674802 100644 --- a/examples/hello/greet_local_view.dot +++ b/examples/hello/greet_local_view.dot @@ -6,7 +6,7 @@ digraph greet { n_2 [id="2", shape=doublecircle, label="3"]; n_3 [id="3", shape=circle, label="2"]; - n_1 -> n_3 [id="[$e|3]", label="send hello1 to greet"]; - n_3 -> n_2 [id="[$e|1]", label="receive hello1"]; n_3 -> n_1 [id="[$e|4]", label="send hello1 to greet"]; + n_1 -> n_3 [id="[$e|3]", label="send hello1 to greet"]; + n_3 -> n_2 [id="[$e|2]", label="receive hello1"]; } diff --git a/examples/serverclient/client_local_view.dot b/examples/serverclient/client_local_view.dot index 09c36fc..aa79aa5 100644 --- a/examples/serverclient/client_local_view.dot +++ b/examples/serverclient/client_local_view.dot @@ -7,8 +7,8 @@ digraph client { n_3 [id="4", shape=circle, label="2"]; n_4 [id="3", shape=circle, label="3"]; - n_4 -> n_2 [id="[$e|5]", label="send done to Handle"]; - n_1 -> n_3 [id="[$e|1]", label="send {req,pid_self} to server_0"]; + n_1 -> n_3 [id="[$e|5]", label="send {req,pid} to server_0"]; + n_3 -> n_4 [id="[$e|3]", label="receive {res,Handle}"]; + n_4 -> n_2 [id="[$e|4]", label="send done to Handle"]; n_4 -> n_4 [id="[$e|7]", label="send next to Handle"]; - n_3 -> n_4 [id="[$e|4]", label="receive {res,Handle}"]; } diff --git a/examples/serverclient/handle_req_local_view.dot b/examples/serverclient/handle_req_local_view.dot index 167736c..7049be7 100644 --- a/examples/serverclient/handle_req_local_view.dot +++ b/examples/serverclient/handle_req_local_view.dot @@ -5,6 +5,6 @@ digraph handle_req { n_0 -> n_1 [arrowhead=none]; n_2 [id="3", shape=doublecircle, label="2"]; - n_1 -> n_1 [id="[$e|4]", label="receive next"]; n_1 -> n_2 [id="[$e|0]", label="receive done"]; + n_1 -> n_1 [id="[$e|4]", label="receive next"]; } diff --git a/examples/serverclient/main_global_view.dot b/examples/serverclient/main_global_view.dot index 8c78657..9c18f60 100644 --- a/examples/serverclient/main_global_view.dot +++ b/examples/serverclient/main_global_view.dot @@ -1,20 +1,15 @@ digraph global { rankdir="LR"; n_0 [label="global", shape="plaintext"]; - n_1 [id="5", shape=circle, label="5"]; - n_2 [id="6", shape=circle, label="6"]; - n_3 [id="1", shape=circle, label="1"]; - n_0 -> n_3 [arrowhead=none]; - n_4 [id="2", shape=circle, label="2"]; - n_5 [id="4", shape=circle, label="4"]; - n_6 [id="7", shape=circle, label="7"]; - n_7 [id="3", shape=circle, label="3"]; + n_1 [id="5", shape=circle, label="4"]; + n_2 [id="1", shape=circle, label="1"]; + n_0 -> n_2 [arrowhead=none]; + n_3 [id="2", shape=circle, label="2"]; + n_4 [id="4", shape=circle, label="5"]; + n_5 [id="3", shape=circle, label="3"]; - n_2 -> n_6 [id="[$e|5]", label="client_0→handle_req_0:done"]; - n_4 -> n_7 [id="[$e|1]", label="mainΔclient_0"]; - n_7 -> n_5 [id="[$e|2]", label="client_0→server_0:{req,pid_self}"]; - n_2 -> n_2 [id="[$e|6]", label="client_0→handle_req_0:next"]; - n_5 -> n_1 [id="[$e|3]", label="server_0Δhandle_req_0"]; - n_1 -> n_2 [id="[$e|4]", label="server_0→client_0:{res,pid_handle_req_0}"]; - n_3 -> n_4 [id="[$e|0]", label="mainΔserver_0"]; + n_1 -> n_4 [id="[$e|2]", label="server_0Δhandle_req_0"]; + n_2 -> n_3 [id="[$e|0]", label="mainΔserver_0"]; + n_3 -> n_5 [id="[$e|1]", label="mainΔclient_0"]; + n_5 -> n_1 [id="[$e|3]", label="client_0→server_0:{req,pid}"]; } diff --git a/examples/serverclient/main_local_view.dot b/examples/serverclient/main_local_view.dot index 4d05ac7..38d1439 100644 --- a/examples/serverclient/main_local_view.dot +++ b/examples/serverclient/main_local_view.dot @@ -6,6 +6,6 @@ digraph main { n_2 [id="2", shape=circle, label="2"]; n_3 [id="3", shape=doublecircle, label="3"]; - n_2 -> n_3 [id="[$e|1]", label="spawn client_0"]; n_1 -> n_2 [id="[$e|0]", label="spawn server_0"]; + n_2 -> n_3 [id="[$e|1]", label="spawn client_0"]; } diff --git a/examples/serverclient/server_local_view.dot b/examples/serverclient/server_local_view.dot index d980ba7..91f14c4 100644 --- a/examples/serverclient/server_local_view.dot +++ b/examples/serverclient/server_local_view.dot @@ -8,9 +8,9 @@ digraph server { n_4 [id="2", shape=circle, label="3"]; n_5 [id="3", shape=circle, label="2"]; - n_3 -> n_5 [id="[$e|5]", label="receive ciao"]; - n_3 -> n_4 [id="[$e|2]", label="receive {req,P}"]; - n_1 -> n_3 [id="[$e|7]", label="send {res,pid_handle_req_0} to P"]; - n_5 -> n_2 [id="[$e|6]", label="spawn handle_req_1"]; n_4 -> n_1 [id="[$e|0]", label="spawn handle_req_0"]; + n_5 -> n_2 [id="[$e|6]", label="spawn handle_req_1"]; + n_3 -> n_5 [id="[$e|5]", label="receive ciao"]; + n_3 -> n_4 [id="[$e|3]", label="receive {req,P}"]; + n_1 -> n_3 [id="[$e|7]", label="send {res,pid} to P"]; } diff --git a/examples/ticktack/start_global_view.dot b/examples/ticktack/start_global_view.dot index 44048cd..bfa9797 100644 --- a/examples/ticktack/start_global_view.dot +++ b/examples/ticktack/start_global_view.dot @@ -1,16 +1,30 @@ digraph global { rankdir="LR"; n_0 [label="global", shape="plaintext"]; - n_1 [id="5", shape=circle, label="5"]; - n_2 [id="1", shape=circle, label="1"]; - n_0 -> n_2 [arrowhead=none]; - n_3 [id="2", shape=circle, label="2"]; - n_4 [id="4", shape=circle, label="4"]; - n_5 [id="3", shape=circle, label="3"]; + n_1 [id="5", shape=circle, label="6"]; + n_2 [id="12", shape=circle, label="5"]; + n_3 [id="11", shape=circle, label="11"]; + n_4 [id="14", shape=circle, label="4"]; + n_5 [id="10", shape=circle, label="9"]; + n_6 [id="1", shape=circle, label="1"]; + n_0 -> n_6 [arrowhead=none]; + n_7 [id="2", shape=circle, label="2"]; + n_8 [id="8", shape=circle, label="10"]; + n_9 [id="4", shape=circle, label="7"]; + n_10 [id="7", shape=circle, label="8"]; + n_11 [id="3", shape=circle, label="3"]; - n_4 -> n_1 [id="[$e|3]", label="tic_loop_0→tac_loop_0:tic"]; - n_2 -> n_3 [id="[$e|0]", label="startΔtac_loop_0"]; - n_3 -> n_5 [id="[$e|1]", label="startΔtic_loop_0"]; - n_5 -> n_4 [id="[$e|2]", label="start→tic_loop_0:tac"]; - n_1 -> n_4 [id="[$e|4]", label="tac_loop_0→tic_loop_0:tac"]; + n_11 -> n_4 [id="[$e|3]", label="startΔrandom_0"]; + n_6 -> n_7 [id="[$e|2]", label="startΔtac_loop_0"]; + n_2 -> n_9 [id="[$e|16]", label="tic_loop_0→tac_loop_0:stop"]; + n_5 -> n_3 [id="[$e|7]", label="tic_loop_0→tac_loop_0:tic"]; + n_4 -> n_2 [id="[$e|12]", label="random_0→tic_loop_0:stop"]; + n_5 -> n_9 [id="[$e|14]", label="tic_loop_0→tac_loop_0:stop"]; + n_3 -> n_9 [id="[$e|5]", label="tic_loop_0→tac_loop_0:stop"]; + n_4 -> n_1 [id="[$e|11]", label="start→tic_loop_0:tac"]; + n_7 -> n_11 [id="[$e|6]", label="startΔtic_loop_0"]; + n_10 -> n_8 [id="[$e|10]", label="random_0→tic_loop_0:stop"]; + n_8 -> n_9 [id="[$e|15]", label="tic_loop_0→tac_loop_0:stop"]; + n_1 -> n_10 [id="[$e|8]", label="tic_loop_0→tac_loop_0:tic"]; + n_1 -> n_5 [id="[$e|4]", label="random_0→tic_loop_0:stop"]; } diff --git a/examples/ticktack/start_local_view.dot b/examples/ticktack/start_local_view.dot index bc84e40..3b9cba9 100644 --- a/examples/ticktack/start_local_view.dot +++ b/examples/ticktack/start_local_view.dot @@ -1,13 +1,15 @@ digraph start { rankdir="LR"; n_0 [label="start", shape="plaintext"]; - n_1 [id="1", shape=circle, label="1"]; - n_0 -> n_1 [arrowhead=none]; - n_2 [id="2", shape=circle, label="2"]; - n_3 [id="4", shape=circle, label="3"]; - n_4 [id="3", shape=doublecircle, label="4"]; + n_1 [id="5", shape=circle, label="4"]; + n_2 [id="1", shape=circle, label="1"]; + n_0 -> n_2 [arrowhead=none]; + n_3 [id="2", shape=circle, label="2"]; + n_4 [id="4", shape=doublecircle, label="5"]; + n_5 [id="3", shape=circle, label="3"]; - n_3 -> n_4 [id="[$e|0]", label="send tac to tic_loop_0"]; - n_2 -> n_3 [id="[$e|1]", label="spawn tic_loop_0"]; - n_1 -> n_2 [id="[$e|2]", label="spawn tac_loop_0"]; + n_2 -> n_3 [id="[$e|3]", label="spawn tac_loop_0"]; + n_5 -> n_1 [id="[$e|1]", label="spawn random_0"]; + n_3 -> n_5 [id="[$e|2]", label="spawn tic_loop_0"]; + n_1 -> n_4 [id="[$e|0]", label="send tac to tic_loop_0"]; } diff --git a/examples/ticktack/tac_loop_local_view.dot b/examples/ticktack/tac_loop_local_view.dot index 7884bfe..f1490a6 100644 --- a/examples/ticktack/tac_loop_local_view.dot +++ b/examples/ticktack/tac_loop_local_view.dot @@ -3,12 +3,12 @@ digraph tac_loop { n_0 [label="tac_loop", shape="plaintext"]; n_1 [id="1", shape=circle, label="1"]; n_0 -> n_1 [arrowhead=none]; - n_2 [id="2", shape=circle, label="2"]; - n_3 [id="4", shape=circle, label="3"]; - n_4 [id="3", shape=doublecircle, label="4"]; + n_2 [id="4", shape=circle, label="3"]; + n_3 [id="3", shape=doublecircle, label="2"]; - n_1 -> n_2 [id="[$e|3]", label="receive tic"]; - n_2 -> n_1 [id="[$e|6]", label="send tac to tic_loop_0"]; - n_3 -> n_4 [id="[$e|5]", label="send stop to tic_loop_0"]; + n_2 -> n_3 [id="[$e|3]", label="receive stop"]; + n_2 -> n_2 [id="[$e|2]", label="receive tic"]; + n_2 -> n_1 [id="[$e|7]", label="send tac to tic_loop_0"]; + n_1 -> n_2 [id="[$e|5]", label="receive tic"]; n_1 -> n_3 [id="[$e|4]", label="receive stop"]; } diff --git a/examples/ticktack/tic_loop_local_view.dot b/examples/ticktack/tic_loop_local_view.dot index 3a48062..55543df 100644 --- a/examples/ticktack/tic_loop_local_view.dot +++ b/examples/ticktack/tic_loop_local_view.dot @@ -8,7 +8,7 @@ digraph tic_loop { n_4 [id="3", shape=doublecircle, label="4"]; n_3 -> n_4 [id="[$e|3]", label="send stop to tac_loop_0"]; - n_2 -> n_1 [id="[$e|6]", label="send tic to tac_loop_0"]; n_1 -> n_2 [id="[$e|1]", label="receive tac"]; + n_2 -> n_1 [id="[$e|6]", label="send tic to tac_loop_0"]; n_1 -> n_3 [id="[$e|4]", label="receive stop"]; } diff --git a/examples/trick/main_global_view.dot b/examples/trick/main_global_view.dot index 5cd37e2..14c1a3d 100644 --- a/examples/trick/main_global_view.dot +++ b/examples/trick/main_global_view.dot @@ -1,25 +1,24 @@ digraph global { rankdir="LR"; n_0 [label="global", shape="plaintext"]; - n_1 [id="5", shape=circle, label="5"]; - n_2 [id="6", shape=circle, label="6"]; - n_3 [id="10", shape=circle, label="10"]; + n_1 [id="5", shape=circle, label="7"]; + n_2 [id="6", shape=circle, label="9"]; + n_3 [id="10", shape=circle, label="4"]; n_4 [id="1", shape=circle, label="1"]; n_0 -> n_4 [arrowhead=none]; - n_5 [id="9", shape=circle, label="9"]; + n_5 [id="9", shape=circle, label="5"]; n_6 [id="2", shape=circle, label="2"]; n_7 [id="8", shape=circle, label="8"]; - n_8 [id="4", shape=circle, label="4"]; - n_9 [id="7", shape=circle, label="7"]; - n_10 [id="3", shape=circle, label="3"]; + n_8 [id="4", shape=circle, label="6"]; + n_9 [id="3", shape=circle, label="3"]; - n_6 -> n_10 [id="[$e|1]", label="mainΔb_0"]; - n_8 -> n_1 [id="[$e|3]", label="a_0→b_0:v2"]; - n_10 -> n_8 [id="[$e|2]", label="mainΔc_0"]; - n_1 -> n_9 [id="[$e|5]", label="a_0→c_0:v1"]; - n_2 -> n_7 [id="[$e|6]", label="a_0→b_0:v2"]; - n_9 -> n_5 [id="[$e|7]", label="b_0→c_0:v2"]; - n_7 -> n_3 [id="[$e|8]", label="b_0→c_0:v2"]; - n_8 -> n_2 [id="[$e|4]", label="a_0→c_0:v1"]; - n_4 -> n_6 [id="[$e|0]", label="mainΔa_0"]; + n_7 -> n_2 [id="[$e|1]", label="b_0→c_0:v2"]; + n_8 -> n_1 [id="[$e|4]", label="a_0→c_0:v1"]; + n_3 -> n_5 [id="[$e|7]", label="a_0→c_0:v1"]; + n_3 -> n_8 [id="[$e|8]", label="a_0→b_0:v2"]; + n_5 -> n_7 [id="[$e|0]", label="a_0→b_0:v2"]; + n_6 -> n_9 [id="[$e|3]", label="mainΔb_0"]; + n_4 -> n_6 [id="[$e|2]", label="mainΔa_0"]; + n_9 -> n_3 [id="[$e|6]", label="mainΔc_0"]; + n_1 -> n_2 [id="[$e|9]", label="b_0→c_0:v2"]; } diff --git a/examples/trick/main_local_view.dot b/examples/trick/main_local_view.dot index f0c5b9e..be634ad 100644 --- a/examples/trick/main_local_view.dot +++ b/examples/trick/main_local_view.dot @@ -8,6 +8,6 @@ digraph main { n_4 [id="3", shape=circle, label="3"]; n_1 -> n_2 [id="[$e|1]", label="spawn a_0"]; - n_2 -> n_4 [id="[$e|2]", label="spawn b_0"]; n_4 -> n_3 [id="[$e|0]", label="spawn c_0"]; + n_2 -> n_4 [id="[$e|2]", label="spawn b_0"]; } diff --git a/examples/violation/incrementer_local_view.dot b/examples/violation/incrementer_local_view.dot index f794e08..b441471 100644 --- a/examples/violation/incrementer_local_view.dot +++ b/examples/violation/incrementer_local_view.dot @@ -10,10 +10,10 @@ digraph incrementer { n_6 [id="7", shape=circle, label="3"]; n_7 [id="3", shape=circle, label="5"]; - n_2 -> n_6 [id="[$e|4]", label="receive answer"]; - n_7 -> n_1 [id="[$e|0]", label="send {write,any} to varManager_0"]; + n_6 -> n_4 [id="[$e|3]", label="send {read,pid} to varManager_0"]; + n_3 -> n_2 [id="[$e|1]", label="send {request,pid} to meManager_0"]; + n_7 -> n_1 [id="[$e|0]", label="send {write,write} to varManager_0"]; + n_2 -> n_6 [id="[$e|5]", label="receive answer"]; + n_4 -> n_7 [id="[$e|4]", label="receive X"]; n_1 -> n_5 [id="[$e|2]", label="send {release} to meManager_0"]; - n_3 -> n_2 [id="[$e|5]", label="send {request,pid_self} to meManager_0"]; - n_4 -> n_7 [id="[$e|3]", label="receive X"]; - n_6 -> n_4 [id="[$e|1]", label="send {read,pid_self} to varManager_0"]; } diff --git a/examples/violation/main_global_view.dot b/examples/violation/main_global_view.dot index 97c5044..0878158 100644 --- a/examples/violation/main_global_view.dot +++ b/examples/violation/main_global_view.dot @@ -1,271 +1,18 @@ digraph global { rankdir="LR"; n_0 [label="global", shape="plaintext"]; - n_1 [id="33", shape=circle, label="33"]; - n_2 [id="34", shape=circle, label="34"]; - n_3 [id="20", shape=circle, label="20"]; - n_4 [id="58", shape=circle, label="58"]; - n_5 [id="119", shape=circle, label="119"]; - n_6 [id="129", shape=circle, label="129"]; - n_7 [id="57", shape=circle, label="57"]; - n_8 [id="98", shape=circle, label="98"]; - n_9 [id="91", shape=circle, label="91"]; - n_10 [id="78", shape=circle, label="78"]; - n_11 [id="102", shape=circle, label="102"]; - n_12 [id="27", shape=circle, label="27"]; - n_13 [id="118", shape=circle, label="118"]; - n_14 [id="114", shape=circle, label="114"]; - n_15 [id="89", shape=circle, label="89"]; - n_16 [id="47", shape=circle, label="47"]; - n_17 [id="29", shape=circle, label="29"]; - n_18 [id="23", shape=circle, label="23"]; - n_19 [id="110", shape=circle, label="110"]; - n_20 [id="72", shape=circle, label="72"]; - n_21 [id="122", shape=circle, label="122"]; - n_22 [id="55", shape=circle, label="55"]; - n_23 [id="82", shape=circle, label="82"]; - n_24 [id="117", shape=circle, label="117"]; - n_25 [id="25", shape=circle, label="25"]; - n_26 [id="120", shape=circle, label="120"]; - n_27 [id="68", shape=circle, label="68"]; - n_28 [id="83", shape=circle, label="83"]; - n_29 [id="36", shape=circle, label="36"]; - n_30 [id="94", shape=circle, label="94"]; - n_31 [id="84", shape=circle, label="84"]; - n_32 [id="5", shape=circle, label="5"]; - n_33 [id="81", shape=circle, label="81"]; - n_34 [id="74", shape=circle, label="74"]; - n_35 [id="92", shape=circle, label="92"]; - n_36 [id="63", shape=circle, label="63"]; - n_37 [id="28", shape=circle, label="28"]; - n_38 [id="64", shape=circle, label="64"]; - n_39 [id="86", shape=circle, label="86"]; - n_40 [id="15", shape=circle, label="15"]; - n_41 [id="87", shape=circle, label="87"]; - n_42 [id="42", shape=circle, label="42"]; - n_43 [id="19", shape=circle, label="19"]; - n_44 [id="12", shape=circle, label="12"]; - n_45 [id="11", shape=circle, label="11"]; - n_46 [id="116", shape=circle, label="116"]; - n_47 [id="112", shape=circle, label="112"]; - n_48 [id="99", shape=circle, label="99"]; - n_49 [id="17", shape=circle, label="17"]; - n_50 [id="53", shape=circle, label="53"]; - n_51 [id="50", shape=circle, label="50"]; - n_52 [id="62", shape=circle, label="62"]; - n_53 [id="67", shape=circle, label="67"]; - n_54 [id="54", shape=circle, label="54"]; - n_55 [id="18", shape=circle, label="18"]; - n_56 [id="61", shape=circle, label="61"]; - n_57 [id="113", shape=circle, label="113"]; - n_58 [id="37", shape=circle, label="37"]; - n_59 [id="80", shape=circle, label="80"]; - n_60 [id="51", shape=circle, label="51"]; - n_61 [id="14", shape=circle, label="14"]; - n_62 [id="66", shape=circle, label="66"]; - n_63 [id="93", shape=circle, label="93"]; - n_64 [id="132", shape=circle, label="132"]; - n_65 [id="100", shape=circle, label="100"]; - n_66 [id="6", shape=circle, label="6"]; - n_67 [id="126", shape=circle, label="126"]; - n_68 [id="38", shape=circle, label="38"]; - n_69 [id="13", shape=circle, label="13"]; - n_70 [id="24", shape=circle, label="24"]; - n_71 [id="10", shape=circle, label="10"]; - n_72 [id="79", shape=circle, label="79"]; - n_73 [id="43", shape=circle, label="43"]; - n_74 [id="30", shape=circle, label="30"]; - n_75 [id="71", shape=circle, label="71"]; - n_76 [id="59", shape=circle, label="59"]; - n_77 [id="40", shape=circle, label="40"]; - n_78 [id="22", shape=circle, label="22"]; - n_79 [id="105", shape=circle, label="105"]; - n_80 [id="106", shape=circle, label="106"]; - n_81 [id="101", shape=circle, label="101"]; - n_82 [id="65", shape=circle, label="65"]; - n_83 [id="73", shape=circle, label="73"]; - n_84 [id="131", shape=circle, label="131"]; - n_85 [id="39", shape=circle, label="39"]; - n_86 [id="123", shape=circle, label="123"]; - n_87 [id="108", shape=circle, label="108"]; - n_88 [id="60", shape=circle, label="60"]; - n_89 [id="1", shape=circle, label="1"]; - n_0 -> n_89 [arrowhead=none]; - n_90 [id="115", shape=circle, label="115"]; - n_91 [id="45", shape=circle, label="45"]; - n_92 [id="26", shape=circle, label="26"]; - n_93 [id="133", shape=circle, label="133"]; - n_94 [id="76", shape=circle, label="76"]; - n_95 [id="9", shape=circle, label="9"]; - n_96 [id="2", shape=circle, label="2"]; - n_97 [id="104", shape=circle, label="104"]; - n_98 [id="97", shape=circle, label="97"]; - n_99 [id="21", shape=circle, label="21"]; - n_100 [id="127", shape=circle, label="127"]; - n_101 [id="107", shape=circle, label="107"]; - n_102 [id="44", shape=circle, label="44"]; - n_103 [id="69", shape=circle, label="69"]; - n_104 [id="46", shape=circle, label="46"]; - n_105 [id="95", shape=circle, label="95"]; - n_106 [id="77", shape=circle, label="77"]; - n_107 [id="8", shape=circle, label="8"]; - n_108 [id="96", shape=circle, label="96"]; - n_109 [id="124", shape=circle, label="124"]; - n_110 [id="48", shape=circle, label="48"]; - n_111 [id="88", shape=circle, label="88"]; - n_112 [id="109", shape=circle, label="109"]; - n_113 [id="130", shape=circle, label="130"]; - n_114 [id="103", shape=circle, label="103"]; - n_115 [id="128", shape=circle, label="128"]; - n_116 [id="4", shape=circle, label="4"]; - n_117 [id="70", shape=circle, label="70"]; - n_118 [id="35", shape=circle, label="35"]; - n_119 [id="121", shape=circle, label="121"]; - n_120 [id="31", shape=circle, label="31"]; - n_121 [id="32", shape=circle, label="32"]; - n_122 [id="85", shape=circle, label="85"]; - n_123 [id="41", shape=circle, label="41"]; - n_124 [id="7", shape=circle, label="7"]; - n_125 [id="90", shape=circle, label="90"]; - n_126 [id="75", shape=circle, label="75"]; - n_127 [id="3", shape=circle, label="3"]; - n_128 [id="52", shape=circle, label="52"]; - n_129 [id="56", shape=circle, label="56"]; - n_130 [id="125", shape=circle, label="125"]; - n_131 [id="49", shape=circle, label="49"]; - n_132 [id="111", shape=circle, label="111"]; - n_133 [id="16", shape=circle, label="16"]; + n_1 [id="5", shape=circle, label="6"]; + n_2 [id="1", shape=circle, label="1"]; + n_0 -> n_2 [arrowhead=none]; + n_3 [id="2", shape=circle, label="2"]; + n_4 [id="4", shape=circle, label="5"]; + n_5 [id="7", shape=circle, label="4"]; + n_6 [id="3", shape=circle, label="3"]; - n_62 -> n_105 [id="[$e|93]", label="incrementer_0→varManager_0:{write,any}"]; - n_99 -> n_17 [id="[$e|27]", label="meManager_0→incrementer_0:answer"]; - n_7 -> n_94 [id="[$e|74]", label="incrementer_0→varManager_0:{write,any}"]; - n_126 -> n_101 [id="[$e|105]", label="incrementer_1→meManager_0:{release}"]; - n_62 -> n_30 [id="[$e|92]", label="incrementer_0→meManager_0:{release}"]; - n_82 -> n_63 [id="[$e|91]", label="incrementer_0→varManager_0:{write,any}"]; - n_7 -> n_106 [id="[$e|75]", label="incrementer_1→varManager_0:{write,any}"]; - n_99 -> n_37 [id="[$e|26]", label="incrementer_1→varManager_0:{write,any}"]; - n_36 -> n_111 [id="[$e|86]", label="incrementer_0→meManager_0:{release}"]; - n_20 -> n_97 [id="[$e|102]", label="incrementer_1→varManager_0:{write,any}"]; - n_32 -> n_66 [id="[$e|4]", label="incrementer_0→meManager_0:{request,pid_self}"]; - n_76 -> n_33 [id="[$e|79]", label="incrementer_0→varManager_0:{write,any}"]; - n_30 -> n_67 [id="[$e|124]", label="incrementer_0→varManager_0:{write,any}"]; - n_35 -> n_109 [id="[$e|122]", label="incrementer_0→varManager_0:{write,any}"]; - n_56 -> n_31 [id="[$e|82]", label="incrementer_1→meManager_0:{release}"]; - n_89 -> n_96 [id="[$e|0]", label="mainΔmeManager_0"]; - n_40 -> n_3 [id="[$e|18]", label="incrementer_0→meManager_0:{release}"]; - n_2 -> n_102 [id="[$e|42]", label="incrementer_0→varManager_0:{write,any}"]; - n_41 -> n_5 [id="[$e|117]", label="incrementer_0→meManager_0:{release}"]; - n_37 -> n_58 [id="[$e|35]", label="meManager_0→incrementer_0:answer"]; - n_91 -> n_4 [id="[$e|56]", label="incrementer_0→varManager_0:{write,any}"]; - n_45 -> n_69 [id="[$e|11]", label="varManager_0→incrementer_1:any"]; - n_129 -> n_126 [id="[$e|73]", label="incrementer_1→varManager_0:{write,any}"]; - n_9 -> n_86 [id="[$e|121]", label="incrementer_0→meManager_0:{release}"]; - n_107 -> n_71 [id="[$e|8]", label="incrementer_0→varManager_0:{read,pid_self}"]; - n_82 -> n_35 [id="[$e|90]", label="incrementer_1→varManager_0:{write,any}"]; - n_29 -> n_16 [id="[$e|45]", label="incrementer_1→varManager_0:{read,pid_self}"]; - n_83 -> n_79 [id="[$e|103]", label="incrementer_1→meManager_0:{release}"]; - n_88 -> n_28 [id="[$e|81]", label="incrementer_1→varManager_0:{write,any}"]; - n_72 -> n_132 [id="[$e|109]", label="incrementer_1→meManager_0:{release}"]; - n_54 -> n_117 [id="[$e|68]", label="incrementer_1→meManager_0:{release}"]; - n_18 -> n_120 [id="[$e|29]", label="incrementer_0→meManager_0:{request,pid_self}"]; - n_95 -> n_45 [id="[$e|9]", label="incrementer_1→varManager_0:{read,pid_self}"]; - n_69 -> n_133 [id="[$e|14]", label="incrementer_1→meManager_0:{release}"]; - n_103 -> n_81 [id="[$e|99]", label="incrementer_0→varManager_0:{write,any}"]; - n_125 -> n_21 [id="[$e|120]", label="incrementer_0→varManager_0:{write,any}"]; - n_71 -> n_44 [id="[$e|10]", label="varManager_0→incrementer_0:any"]; - n_34 -> n_80 [id="[$e|104]", label="incrementer_1→varManager_0:{write,any}"]; - n_44 -> n_61 [id="[$e|12]", label="incrementer_0→meManager_0:{release}"]; - n_63 -> n_130 [id="[$e|123]", label="incrementer_1→varManager_0:{write,any}"]; - n_94 -> n_87 [id="[$e|106]", label="incrementer_1→varManager_0:{write,any}"]; - n_27 -> n_8 [id="[$e|96]", label="incrementer_0→meManager_0:{release}"]; - n_133 -> n_78 [id="[$e|20]", label="incrementer_1→varManager_0:{write,any}"]; - n_52 -> n_41 [id="[$e|85]", label="incrementer_0→varManager_0:{write,any}"]; - n_68 -> n_131 [id="[$e|47]", label="incrementer_0→varManager_0:{read,pid_self}"]; - n_91 -> n_76 [id="[$e|57]", label="incrementer_1→varManager_0:{write,any}"]; - n_59 -> n_47 [id="[$e|110]", label="incrementer_0→varManager_0:{write,any}"]; - n_120 -> n_123 [id="[$e|39]", label="meManager_0→incrementer_0:answer"]; - n_48 -> n_84 [id="[$e|129]", label="incrementer_0→meManager_0:{release}"]; - n_43 -> n_92 [id="[$e|24]", label="incrementer_1→meManager_0:{request,pid_self}"]; - n_103 -> n_65 [id="[$e|98]", label="incrementer_0→meManager_0:{release}"]; - n_127 -> n_116 [id="[$e|2]", label="mainΔincrementer_0"]; - n_73 -> n_22 [id="[$e|53]", label="varManager_0→incrementer_1:any"]; - n_66 -> n_107 [id="[$e|6]", label="meManager_0→incrementer_0:answer"]; - n_91 -> n_7 [id="[$e|55]", label="incrementer_1→meManager_0:{release}"]; - n_49 -> n_18 [id="[$e|21]", label="incrementer_1→meManager_0:{release}"]; - n_3 -> n_12 [id="[$e|25]", label="incrementer_1→meManager_0:{request,pid_self}"]; - n_22 -> n_83 [id="[$e|71]", label="incrementer_1→varManager_0:{write,any}"]; - n_15 -> n_119 [id="[$e|119]", label="incrementer_0→meManager_0:{release}"]; - n_38 -> n_125 [id="[$e|88]", label="incrementer_0→meManager_0:{release}"]; - n_22 -> n_20 [id="[$e|70]", label="incrementer_1→meManager_0:{release}"]; - n_17 -> n_85 [id="[$e|37]", label="incrementer_0→varManager_0:{read,pid_self}"]; - n_25 -> n_2 [id="[$e|32]", label="incrementer_1→varManager_0:{read,pid_self}"]; - n_32 -> n_124 [id="[$e|5]", label="incrementer_1→meManager_0:{request,pid_self}"]; - n_31 -> n_46 [id="[$e|114]", label="incrementer_1→varManager_0:{write,any}"]; - n_118 -> n_104 [id="[$e|44]", label="incrementer_1→varManager_0:{read,pid_self}"]; - n_12 -> n_29 [id="[$e|34]", label="meManager_0→incrementer_1:answer"]; - n_61 -> n_43 [id="[$e|17]", label="incrementer_0→varManager_0:{write,any}"]; - n_8 -> n_113 [id="[$e|128]", label="incrementer_0→varManager_0:{write,any}"]; - n_129 -> n_34 [id="[$e|72]", label="incrementer_1→meManager_0:{release}"]; - n_74 -> n_77 [id="[$e|38]", label="meManager_0→incrementer_0:answer"]; - n_104 -> n_88 [id="[$e|58]", label="varManager_0→incrementer_1:any"]; - n_106 -> n_112 [id="[$e|107]", label="incrementer_0→varManager_0:{write,any}"]; - n_2 -> n_91 [id="[$e|43]", label="varManager_0→incrementer_1:any"]; - n_70 -> n_121 [id="[$e|30]", label="meManager_0→incrementer_1:answer"]; - n_123 -> n_50 [id="[$e|51]", label="incrementer_0→varManager_0:{read,pid_self}"]; - n_122 -> n_24 [id="[$e|115]", label="incrementer_1→meManager_0:{release}"]; - n_60 -> n_62 [id="[$e|64]", label="incrementer_1→varManager_0:{write,any}"]; - n_133 -> n_99 [id="[$e|19]", label="incrementer_0→meManager_0:{request,pid_self}"]; - n_28 -> n_90 [id="[$e|113]", label="incrementer_1→meManager_0:{release}"]; - n_116 -> n_32 [id="[$e|3]", label="mainΔincrementer_1"]; - n_60 -> n_82 [id="[$e|63]", label="incrementer_0→meManager_0:{release}"]; - n_111 -> n_26 [id="[$e|118]", label="incrementer_0→varManager_0:{write,any}"]; - n_10 -> n_19 [id="[$e|108]", label="incrementer_1→varManager_0:{write,any}"]; - n_105 -> n_100 [id="[$e|125]", label="incrementer_0→meManager_0:{release}"]; - n_16 -> n_56 [id="[$e|59]", label="varManager_0→incrementer_1:any"]; - n_124 -> n_95 [id="[$e|7]", label="meManager_0→incrementer_1:answer"]; - n_108 -> n_115 [id="[$e|126]", label="incrementer_1→varManager_0:{write,any}"]; - n_55 -> n_70 [id="[$e|22]", label="incrementer_0→varManager_0:{write,any}"]; - n_25 -> n_1 [id="[$e|31]", label="incrementer_0→varManager_0:{write,any}"]; - n_85 -> n_51 [id="[$e|48]", label="incrementer_1→varManager_0:{write,any}"]; - n_56 -> n_122 [id="[$e|83]", label="incrementer_1→varManager_0:{write,any}"]; - n_23 -> n_14 [id="[$e|112]", label="incrementer_1→varManager_0:{write,any}"]; - n_121 -> n_42 [id="[$e|40]", label="incrementer_1→varManager_0:{read,pid_self}"]; - n_102 -> n_129 [id="[$e|54]", label="varManager_0→incrementer_1:any"]; - n_85 -> n_60 [id="[$e|49]", label="varManager_0→incrementer_0:any"]; - n_50 -> n_103 [id="[$e|67]", label="varManager_0→incrementer_0:any"]; - n_76 -> n_59 [id="[$e|78]", label="incrementer_1→meManager_0:{release}"]; - n_58 -> n_110 [id="[$e|46]", label="incrementer_0→varManager_0:{read,pid_self}"]; - n_54 -> n_75 [id="[$e|69]", label="incrementer_1→varManager_0:{write,any}"]; - n_44 -> n_40 [id="[$e|13]", label="incrementer_0→varManager_0:{write,any}"]; - n_27 -> n_48 [id="[$e|97]", label="incrementer_0→varManager_0:{write,any}"]; - n_98 -> n_6 [id="[$e|127]", label="incrementer_0→meManager_0:{release}"]; - n_53 -> n_98 [id="[$e|95]", label="incrementer_1→varManager_0:{write,any}"]; - n_52 -> n_39 [id="[$e|84]", label="incrementer_0→meManager_0:{release}"]; - n_4 -> n_72 [id="[$e|77]", label="incrementer_1→varManager_0:{write,any}"]; - n_51 -> n_38 [id="[$e|62]", label="varManager_0→incrementer_0:any"]; - n_131 -> n_36 [id="[$e|61]", label="varManager_0→incrementer_0:any"]; - n_17 -> n_68 [id="[$e|36]", label="incrementer_1→varManager_0:{write,any}"]; - n_1 -> n_73 [id="[$e|41]", label="incrementer_1→varManager_0:{read,pid_self}"]; - n_96 -> n_127 [id="[$e|1]", label="mainΔvarManager_0"]; - n_110 -> n_52 [id="[$e|60]", label="varManager_0→incrementer_0:any"]; - n_53 -> n_108 [id="[$e|94]", label="incrementer_0→meManager_0:{release}"]; - n_42 -> n_54 [id="[$e|52]", label="varManager_0→incrementer_1:any"]; - n_78 -> n_74 [id="[$e|28]", label="incrementer_0→meManager_0:{request,pid_self}"]; - n_55 -> n_25 [id="[$e|23]", label="meManager_0→incrementer_1:answer"]; - n_33 -> n_57 [id="[$e|111]", label="incrementer_1→meManager_0:{release}"]; - n_39 -> n_13 [id="[$e|116]", label="incrementer_0→varManager_0:{write,any}"]; - n_81 -> n_93 [id="[$e|131]", label="incrementer_0→meManager_0:{release}"]; - n_36 -> n_15 [id="[$e|87]", label="incrementer_0→varManager_0:{write,any}"]; - n_128 -> n_27 [id="[$e|66]", label="varManager_0→incrementer_0:any"]; - n_60 -> n_53 [id="[$e|65]", label="incrementer_0→varManager_0:{write,any}"]; - n_75 -> n_114 [id="[$e|101]", label="incrementer_1→meManager_0:{release}"]; - n_61 -> n_55 [id="[$e|16]", label="incrementer_1→meManager_0:{request,pid_self}"]; - n_69 -> n_49 [id="[$e|15]", label="incrementer_1→varManager_0:{write,any}"]; - n_38 -> n_9 [id="[$e|89]", label="incrementer_0→varManager_0:{write,any}"]; - n_77 -> n_128 [id="[$e|50]", label="incrementer_0→varManager_0:{read,pid_self}"]; - n_117 -> n_11 [id="[$e|100]", label="incrementer_1→varManager_0:{write,any}"]; - n_65 -> n_64 [id="[$e|130]", label="incrementer_0→varManager_0:{write,any}"]; - n_88 -> n_23 [id="[$e|80]", label="incrementer_1→meManager_0:{release}"]; - n_4 -> n_10 [id="[$e|76]", label="incrementer_1→meManager_0:{release}"]; - n_92 -> n_118 [id="[$e|33]", label="meManager_0→incrementer_1:answer"]; + n_6 -> n_5 [id="[$e|3]", label="mainΔincrementer_0"]; + n_4 -> n_1 [id="[$e|1]", label="incrementer_1→meManager_0:{request,pid}"]; + n_3 -> n_6 [id="[$e|0]", label="mainΔvarManager_0"]; + n_4 -> n_1 [id="[$e|6]", label="incrementer_0→meManager_0:{request,pid}"]; + n_5 -> n_4 [id="[$e|4]", label="mainΔincrementer_1"]; + n_2 -> n_3 [id="[$e|2]", label="mainΔmeManager_0"]; } diff --git a/examples/violation/main_local_view.dot b/examples/violation/main_local_view.dot index 1ab64b4..7e9d9d6 100644 --- a/examples/violation/main_local_view.dot +++ b/examples/violation/main_local_view.dot @@ -8,8 +8,8 @@ digraph main { n_4 [id="4", shape=doublecircle, label="5"]; n_5 [id="3", shape=circle, label="3"]; - n_1 -> n_4 [id="[$e|0]", label="spawn incrementer_1"]; - n_2 -> n_3 [id="[$e|2]", label="spawn meManager_0"]; n_5 -> n_1 [id="[$e|3]", label="spawn incrementer_0"]; n_3 -> n_5 [id="[$e|1]", label="spawn varManager_0"]; + n_1 -> n_4 [id="[$e|0]", label="spawn incrementer_1"]; + n_2 -> n_3 [id="[$e|2]", label="spawn meManager_0"]; } diff --git a/examples/violation/meManager_local_view.dot b/examples/violation/meManager_local_view.dot index 70ae78b..e3f56af 100644 --- a/examples/violation/meManager_local_view.dot +++ b/examples/violation/meManager_local_view.dot @@ -6,7 +6,7 @@ digraph meManager { n_2 [id="2", shape=circle, label="2"]; n_3 [id="3", shape=circle, label="3"]; + n_1 -> n_2 [id="[$e|1]", label="receive {request,Pid}"]; n_3 -> n_1 [id="[$e|4]", label="receive {release}"]; n_2 -> n_3 [id="[$e|2]", label="send answer to Pid"]; - n_1 -> n_2 [id="[$e|1]", label="receive {request,Pid}"]; } diff --git a/examples/violation/varManager_local_view.dot b/examples/violation/varManager_local_view.dot index d8846a7..b57e880 100644 --- a/examples/violation/varManager_local_view.dot +++ b/examples/violation/varManager_local_view.dot @@ -5,7 +5,7 @@ digraph varManager { n_0 -> n_1 [arrowhead=none]; n_2 [id="3", shape=circle, label="2"]; - n_1 -> n_1 [id="[$e|8]", label="receive {write,NewVal}"]; n_1 -> n_2 [id="[$e|5]", label="receive {read,Pid}"]; + n_1 -> n_1 [id="[$e|8]", label="receive {write,NewVal}"]; n_2 -> n_1 [id="[$e|7]", label="send any to Pid"]; } diff --git a/src/choreography/gv.erl b/src/choreography/gv.erl index 1677495..ed332bd 100644 --- a/src/choreography/gv.erl +++ b/src/choreography/gv.erl @@ -382,9 +382,10 @@ remove_pid_part(Data) -> ltoa(lists:flatten(string:replace(atol(Data), "pid_", ""))). %%% Get the spawn info given an actor id -find_spawn_info(PId) -> - SpInfoAll = db_manager:get_spawn_info(), - common_fun:first(lists:filter(fun(S) -> S#spawned_proc.name =:= PId end, SpInfoAll)). +find_spawn_info(_PId) -> + % SpInfoAll = db_manager:get_spawn_info(), + % common_fun:first(lists:filter(fun(S) -> S#spawned_proc.name =:= PId end, SpInfoAll)), + []. %%% Convert a list AST in a variable's list convertL_in_variable(A, B) -> diff --git a/src/choreography/lv.erl b/src/choreography/lv.erl index 6b51a94..87c9281 100644 --- a/src/choreography/lv.erl +++ b/src/choreography/lv.erl @@ -68,7 +68,9 @@ add_args_to_graph(Gr, Vars, Guard, VStart, SetPm) -> end. eval_codeline(CodeLine, Data) -> - % io:fwrite("evaluating ~p on line ~p~n", [element(1, CodeLine), element(2, CodeLine)]), + Line = element(2, CodeLine), + ets:insert(?CLINE, {line, Line}), + % io:fwrite("evaluating ~p on line ~p~n", [element(1, CodeLine), Line), case CodeLine of {clause, _, _Vars, _Guard, Content} -> eval_pm_clause(Content, Data); {match, _, RightContent, LeftContent} -> eval_match(RightContent, LeftContent, Data); @@ -91,7 +93,8 @@ eval_codeline(CodeLine, Data) -> end. warning(String, Content, Data) -> - io:fwrite("WARNING: " ++ String ++ " ~p~n", [Content]), + [{_, Line}] = ets:lookup(?CLINE, line), + io:fwrite("WARNING on line ~p: " ++ String ++ " ~p~n", [Line, Content]), Data. eval_pm_clause(Code, Data) -> @@ -279,21 +282,16 @@ eval_send(Destination, MessageContent, Data) -> ProcName = get_pid(TempData#wip_lv.ret_var), NewData = eval_codeline(MessageContent, TempData), LastV = NewData#wip_lv.last_vertex, - case ProcName of - ?UNDEFINED -> - warning("Process not found", ProcName, NewData); - _ -> - DataSent = recordvar_to_string(NewData#wip_lv.ret_var), - VNew = common_fun:add_vertex(G), - SLabel = "send " ++ DataSent ++ " to " ++ ProcName, - digraph:add_edge(G, LastV, VNew, SLabel), - NewData#wip_lv{last_vertex = VNew} - end. + DataSent = recordvar_to_string(NewData#wip_lv.ret_var), + VNew = common_fun:add_vertex(G), + SLabel = "send " ++ DataSent ++ " to " ++ ProcName, + digraph:add_edge(G, LastV, VNew, SLabel), + NewData#wip_lv{last_vertex = VNew}. get_pid(Var) -> case Var#variable.type == pid of true -> Var#variable.value; - false -> ?UNDEFINED + false -> atol(Var#variable.name) end. eval_anon_fun(Content, N, Data) -> @@ -333,7 +331,7 @@ eval_tuple(Val, Data) -> {NewVal, NewData} = lists:foldl( fun(I, {A, D}) -> ND = eval_codeline(I, D), - A ++ [ND#wip_lv.ret_var] + {A ++ [ND#wip_lv.ret_var], ND} end, {[], Data}, Val diff --git a/src/chorer.erl b/src/chorer.erl index e01ceb2..75ad289 100644 --- a/src/chorer.erl +++ b/src/chorer.erl @@ -21,6 +21,7 @@ generate(InputFile, EntryPoint) -> generate(InputFile, EntryPoint, #setting{}). EntryPoint :: atom(), OutDir :: string(). generate(InputFile, EntryPoint, OutDir) -> + io:fwrite("Analysing ~p, entrypoint: '~p'~n", [InputFile, EntryPoint]), init_db(), Settings = #setting{output_dir = OutDir}, md:extract(InputFile), @@ -32,6 +33,7 @@ generate(InputFile, EntryPoint, OutDir) -> %%%=================================================================== init_db() -> + ets:new(?CLINE, [set, named_table]), ets:new(?DBMANAGER, [set, named_table]), ets:new(?FUNAST, [set, named_table]), ets:new(?LOCALVIEW, [set, named_table]), diff --git a/src/share/common_data.hrl b/src/share/common_data.hrl index 98e79f2..44ca9e9 100644 --- a/src/share/common_data.hrl +++ b/src/share/common_data.hrl @@ -7,6 +7,7 @@ -define(UNDEFINED, none). -define(ANYDATA, any). +-define(CLINE, curr_line). -define(INPUTAST, input_ast). -define(ACTORLIST, actor_list). -define(FUNAST, fun_ast). From 1d9eacf3b46d16f262edb29268eb45a2be5ca552 Mon Sep 17 00:00:00 2001 From: geno Date: Tue, 13 Feb 2024 20:43:21 +0100 Subject: [PATCH 04/11] feat: lv argument evaluation implemented --- README.md | 6 +- examples/airline/agent_local_view.dot | 2 +- examples/airline/airline.erl | 7 +- examples/airline/main_global_view.dot | 4 +- examples/airline/main_local_view.dot | 20 +-- examples/async/main_global_view.dot | 27 ++-- examples/customer/customer_local_view.dot | 6 +- examples/customer/main_global_view.dot | 28 +++-- examples/customer/main_local_view.dot | 2 +- examples/customer/store_local_view.dot | 4 +- examples/hello/greet_local_view.dot | 2 +- examples/serverclient/client_local_view.dot | 2 +- examples/serverclient/main_global_view.dot | 10 +- examples/serverclient/main_local_view.dot | 2 +- examples/serverclient/server_local_view.dot | 2 +- examples/ticktack/start_global_view.dot | 51 ++++---- examples/ticktack/start_local_view.dot | 4 +- examples/ticktack/tac_loop_local_view.dot | 6 +- examples/ticktack/tic_loop_local_view.dot | 4 +- examples/trick/a_local_view.dot | 2 +- examples/trick/b_local_view.dot | 2 +- examples/trick/c_local_view.dot | 2 +- examples/trick/main_global_view.dot | 31 ++--- examples/trick/main_local_view.dot | 4 +- examples/violation/incrementer_local_view.dot | 4 +- examples/violation/main_global_view.dot | 27 ++-- examples/violation/main_local_view.dot | 2 +- examples/violation/meManager_local_view.dot | 4 +- examples/violation/varManager_local_view.dot | 4 +- src/choreography/actor_emul.erl | 10 +- src/choreography/gv.erl | 38 ++++-- src/choreography/lv.erl | 116 +++++++++++------- src/share/common_data.hrl | 3 + src/share/common_fun.erl | 16 +++ test.sh | 10 +- 35 files changed, 275 insertions(+), 189 deletions(-) diff --git a/README.md b/README.md index e8ce0c8..86e1156 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ Use `rebar3` to run the program from the command line or to compile it. # ./_build/default/bin/chorer ./path/to/your/program.erl main ``` -otherwise +or ```erlang # rebar3 shell @@ -25,9 +25,9 @@ finished ### Output -The tool will create a DOT file for each actor's local view and a DOT file for the global view in the specified folder. To visualize the Choreography Automatas, copy paste the content's files in a [DOT viewer](https://dreampuf.github.io/GraphvizOnline). +The tool will create a DOT file for each actor's local view and a DOT file for the global view in the specified folder. To visualize the Choreography Automatas copy and paste the `.dot` files' content in a [DOT viewer](https://dreampuf.github.io/GraphvizOnline). ## Credits This project was made for the Bachelor's degree Thesis of the Computer Science course at Alma Mater Studiorum - University of Bologna. -I am grateful to the professor [Ivan Lanese](https://github.com/lanese), who supervised the development of this project. +I am grateful to the professor [Ivan Lanese](http://www.cs.unibo.it/~lanese/), who supervised the development of this project. diff --git a/examples/airline/agent_local_view.dot b/examples/airline/agent_local_view.dot index dd13123..0ba5406 100644 --- a/examples/airline/agent_local_view.dot +++ b/examples/airline/agent_local_view.dot @@ -5,6 +5,6 @@ digraph agent { n_0 -> n_1 [arrowhead=none]; n_2 [id="3", shape=circle, label="2"]; - n_2 -> n_1 [id="[$e|3]", label="receive {booked,_}"]; n_1 -> n_2 [id="[$e|1]", label="send {sell,pid} to Pid2"]; + n_2 -> n_1 [id="[$e|3]", label="receive {booked,_}"]; } diff --git a/examples/airline/airline.erl b/examples/airline/airline.erl index 922ca05..719eb37 100644 --- a/examples/airline/airline.erl +++ b/examples/airline/airline.erl @@ -4,13 +4,14 @@ main() -> spawn(?MODULE, agent, [self()]), spawn(?MODULE, agent, [self()]), - seats(3). + seats(self(), 3). -seats(Num) -> +seats(Pid, Num) -> + Pid ! 2, receive {sell, Pid1} -> Pid1 ! {booked, Num}, - seats(Num - 1) + seats(Pid, Num - 1) end. agent(Pid2) -> diff --git a/examples/airline/main_global_view.dot b/examples/airline/main_global_view.dot index 37dcd79..6e3015f 100644 --- a/examples/airline/main_global_view.dot +++ b/examples/airline/main_global_view.dot @@ -6,6 +6,6 @@ digraph global { n_2 [id="2", shape=circle, label="2"]; n_3 [id="3", shape=circle, label="3"]; - n_1 -> n_2 [id="[$e|1]", label="mainΔagent_0"]; - n_2 -> n_3 [id="[$e|0]", label="mainΔagent_1"]; + n_1 -> n_2 [id="[$e|0]", label="mainΔagent_0"]; + n_2 -> n_3 [id="[$e|1]", label="mainΔagent_1"]; } diff --git a/examples/airline/main_local_view.dot b/examples/airline/main_local_view.dot index b68dd5e..940d827 100644 --- a/examples/airline/main_local_view.dot +++ b/examples/airline/main_local_view.dot @@ -1,14 +1,16 @@ digraph main { rankdir="LR"; n_0 [label="main", shape="plaintext"]; - n_1 [id="1", shape=circle, label="1"]; - n_0 -> n_1 [arrowhead=none]; - n_2 [id="2", shape=circle, label="3"]; - n_3 [id="4", shape=circle, label="4"]; - n_4 [id="3", shape=circle, label="2"]; + n_1 [id="5", shape=circle, label="4"]; + n_2 [id="1", shape=circle, label="1"]; + n_0 -> n_2 [arrowhead=none]; + n_3 [id="2", shape=circle, label="2"]; + n_4 [id="4", shape=circle, label="5"]; + n_5 [id="3", shape=circle, label="3"]; - n_2 -> n_3 [id="[$e|3]", label="receive {sell,Pid1}"]; - n_1 -> n_4 [id="[$e|1]", label="spawn agent_0"]; - n_4 -> n_2 [id="[$e|5]", label="spawn agent_1"]; - n_3 -> n_2 [id="[$e|4]", label="send {booked,any} to Pid1"]; + n_3 -> n_5 [id="[$e|0]", label="spawn agent_1"]; + n_1 -> n_4 [id="[$e|1]", label="receive {sell,Pid1}"]; + n_2 -> n_3 [id="[$e|3]", label="spawn agent_0"]; + n_4 -> n_5 [id="[$e|6]", label="send {booked,3} to Pid1"]; + n_5 -> n_1 [id="[$e|5]", label="send 2 to main"]; } diff --git a/examples/async/main_global_view.dot b/examples/async/main_global_view.dot index 2bd62aa..39cd2d1 100644 --- a/examples/async/main_global_view.dot +++ b/examples/async/main_global_view.dot @@ -1,18 +1,19 @@ digraph global { rankdir="LR"; n_0 [label="global", shape="plaintext"]; - n_1 [id="5", shape=circle, label="6"]; - n_2 [id="1", shape=circle, label="1"]; - n_0 -> n_2 [arrowhead=none]; - n_3 [id="2", shape=circle, label="2"]; - n_4 [id="4", shape=circle, label="4"]; - n_5 [id="7", shape=circle, label="5"]; - n_6 [id="3", shape=circle, label="3"]; + n_1 [id="5", shape=circle, label="5"]; + n_2 [id="6", shape=circle, label="6"]; + n_3 [id="1", shape=circle, label="1"]; + n_0 -> n_3 [arrowhead=none]; + n_4 [id="2", shape=circle, label="2"]; + n_5 [id="4", shape=circle, label="4"]; + n_6 [id="7", shape=circle, label="7"]; + n_7 [id="3", shape=circle, label="3"]; - n_6 -> n_4 [id="[$e|3]", label="dummy1_0→dummy2_0:bello"]; - n_2 -> n_3 [id="[$e|1]", label="mainΔdummy1_0"]; - n_3 -> n_6 [id="[$e|2]", label="mainΔdummy2_0"]; - n_4 -> n_1 [id="[$e|0]", label="dummy2_0→dummy1_0:ciao"]; - n_5 -> n_1 [id="[$e|6]", label="dummy1_0→dummy2_0:bello"]; - n_6 -> n_5 [id="[$e|4]", label="dummy2_0→dummy1_0:ciao"]; + n_4 -> n_7 [id="[$e|1]", label="mainΔdummy2_0"]; + n_3 -> n_4 [id="[$e|0]", label="mainΔdummy1_0"]; + n_5 -> n_2 [id="[$e|4]", label="dummy1_0→dummy2_0:bello"]; + n_7 -> n_1 [id="[$e|3]", label="dummy1_0→dummy2_0:bello"]; + n_1 -> n_6 [id="[$e|5]", label="dummy2_0→dummy1_0:ciao"]; + n_7 -> n_5 [id="[$e|2]", label="dummy2_0→dummy1_0:ciao"]; } diff --git a/examples/customer/customer_local_view.dot b/examples/customer/customer_local_view.dot index f92b1db..28bb4f1 100644 --- a/examples/customer/customer_local_view.dot +++ b/examples/customer/customer_local_view.dot @@ -8,10 +8,10 @@ digraph customer { n_4 [id="4", shape=circle, label="4"]; n_5 [id="7", shape=circle, label="2"]; - n_4 -> n_1 [id="[$e|2]", label="receive accepted"]; - n_4 -> n_3 [id="[$e|9]", label="receive reject"]; + n_2 -> n_5 [id="[$e|3]", label="send item to store_0"]; n_3 -> n_4 [id="[$e|5]", label="send payment to store_0"]; n_5 -> n_2 [id="[$e|8]", label="send more to store_0"]; - n_2 -> n_5 [id="[$e|3]", label="send item to store_0"]; + n_4 -> n_3 [id="[$e|9]", label="receive reject"]; n_5 -> n_3 [id="[$e|7]", label="send buy to store_0"]; + n_4 -> n_1 [id="[$e|2]", label="receive accepted"]; } diff --git a/examples/customer/main_global_view.dot b/examples/customer/main_global_view.dot index 53c6af6..0d85b79 100644 --- a/examples/customer/main_global_view.dot +++ b/examples/customer/main_global_view.dot @@ -1,21 +1,23 @@ digraph global { rankdir="LR"; n_0 [label="global", shape="plaintext"]; - n_1 [id="5", shape=circle, label="6"]; - n_2 [id="6", shape=circle, label="7"]; + n_1 [id="5", shape=circle, label="5"]; + n_2 [id="6", shape=circle, label="6"]; n_3 [id="1", shape=circle, label="1"]; n_0 -> n_3 [arrowhead=none]; n_4 [id="2", shape=circle, label="2"]; - n_5 [id="8", shape=circle, label="4"]; - n_6 [id="4", shape=circle, label="5"]; - n_7 [id="3", shape=circle, label="3"]; + n_5 [id="8", shape=circle, label="8"]; + n_6 [id="4", shape=circle, label="4"]; + n_7 [id="7", shape=circle, label="7"]; + n_8 [id="3", shape=circle, label="3"]; - n_4 -> n_7 [id="[$e|2]", label="mainΔstore_0"]; - n_5 -> n_7 [id="[$e|9]", label="customer_0→store_0:more"]; - n_1 -> n_2 [id="[$e|0]", label="store_0→customer_0:accepted"]; - n_6 -> n_1 [id="[$e|1]", label="customer_0→store_0:payment"]; - n_1 -> n_6 [id="[$e|5]", label="store_0→customer_0:reject"]; - n_5 -> n_6 [id="[$e|8]", label="customer_0→store_0:buy"]; - n_3 -> n_4 [id="[$e|4]", label="mainΔcustomer_0"]; - n_7 -> n_5 [id="[$e|7]", label="customer_0→store_0:item"]; + n_6 -> n_1 [id="[$e|3]", label="customer_0→store_0:buy"]; + n_4 -> n_8 [id="[$e|1]", label="mainΔstore_0"]; + n_3 -> n_4 [id="[$e|0]", label="mainΔcustomer_0"]; + n_2 -> n_6 [id="[$e|6]", label="customer_0→store_0:item"]; + n_1 -> n_7 [id="[$e|5]", label="customer_0→store_0:payment"]; + n_7 -> n_5 [id="[$e|8]", label="store_0→customer_0:accepted"]; + n_6 -> n_2 [id="[$e|4]", label="customer_0→store_0:more"]; + n_7 -> n_1 [id="[$e|7]", label="store_0→customer_0:reject"]; + n_8 -> n_6 [id="[$e|2]", label="customer_0→store_0:item"]; } diff --git a/examples/customer/main_local_view.dot b/examples/customer/main_local_view.dot index 3fe9570..16d9271 100644 --- a/examples/customer/main_local_view.dot +++ b/examples/customer/main_local_view.dot @@ -6,6 +6,6 @@ digraph main { n_2 [id="2", shape=circle, label="2"]; n_3 [id="3", shape=doublecircle, label="3"]; - n_1 -> n_2 [id="[$e|0]", label="spawn customer_0"]; n_2 -> n_3 [id="[$e|1]", label="spawn store_0"]; + n_1 -> n_2 [id="[$e|0]", label="spawn customer_0"]; } diff --git a/examples/customer/store_local_view.dot b/examples/customer/store_local_view.dot index cf1abb8..5a48012 100644 --- a/examples/customer/store_local_view.dot +++ b/examples/customer/store_local_view.dot @@ -8,10 +8,10 @@ digraph store { n_4 [id="7", shape=doublecircle, label="5"]; n_5 [id="3", shape=circle, label="2"]; - n_5 -> n_3 [id="[$e|9]", label="receive buy"]; + n_2 -> n_5 [id="[$e|3]", label="receive item"]; n_1 -> n_4 [id="[$e|5]", label="send accepted to customer_0"]; n_5 -> n_2 [id="[$e|8]", label="receive more"]; - n_2 -> n_5 [id="[$e|3]", label="receive item"]; + n_5 -> n_3 [id="[$e|9]", label="receive buy"]; n_1 -> n_3 [id="[$e|4]", label="send reject to customer_0"]; n_3 -> n_1 [id="[$e|7]", label="receive payment"]; } diff --git a/examples/hello/greet_local_view.dot b/examples/hello/greet_local_view.dot index d674802..71af9ca 100644 --- a/examples/hello/greet_local_view.dot +++ b/examples/hello/greet_local_view.dot @@ -6,7 +6,7 @@ digraph greet { n_2 [id="2", shape=doublecircle, label="3"]; n_3 [id="3", shape=circle, label="2"]; - n_3 -> n_1 [id="[$e|4]", label="send hello1 to greet"]; n_1 -> n_3 [id="[$e|3]", label="send hello1 to greet"]; n_3 -> n_2 [id="[$e|2]", label="receive hello1"]; + n_3 -> n_1 [id="[$e|4]", label="send hello1 to greet"]; } diff --git a/examples/serverclient/client_local_view.dot b/examples/serverclient/client_local_view.dot index aa79aa5..86e602b 100644 --- a/examples/serverclient/client_local_view.dot +++ b/examples/serverclient/client_local_view.dot @@ -7,8 +7,8 @@ digraph client { n_3 [id="4", shape=circle, label="2"]; n_4 [id="3", shape=circle, label="3"]; - n_1 -> n_3 [id="[$e|5]", label="send {req,pid} to server_0"]; n_3 -> n_4 [id="[$e|3]", label="receive {res,Handle}"]; + n_1 -> n_3 [id="[$e|5]", label="send {req,pid} to server_0"]; n_4 -> n_2 [id="[$e|4]", label="send done to Handle"]; n_4 -> n_4 [id="[$e|7]", label="send next to Handle"]; } diff --git a/examples/serverclient/main_global_view.dot b/examples/serverclient/main_global_view.dot index 9c18f60..b13644a 100644 --- a/examples/serverclient/main_global_view.dot +++ b/examples/serverclient/main_global_view.dot @@ -1,15 +1,15 @@ digraph global { rankdir="LR"; n_0 [label="global", shape="plaintext"]; - n_1 [id="5", shape=circle, label="4"]; + n_1 [id="5", shape=circle, label="5"]; n_2 [id="1", shape=circle, label="1"]; n_0 -> n_2 [arrowhead=none]; n_3 [id="2", shape=circle, label="2"]; - n_4 [id="4", shape=circle, label="5"]; + n_4 [id="4", shape=circle, label="4"]; n_5 [id="3", shape=circle, label="3"]; - n_1 -> n_4 [id="[$e|2]", label="server_0Δhandle_req_0"]; - n_2 -> n_3 [id="[$e|0]", label="mainΔserver_0"]; + n_4 -> n_1 [id="[$e|3]", label="server_0Δhandle_req_0"]; n_3 -> n_5 [id="[$e|1]", label="mainΔclient_0"]; - n_5 -> n_1 [id="[$e|3]", label="client_0→server_0:{req,pid}"]; + n_2 -> n_3 [id="[$e|0]", label="mainΔserver_0"]; + n_5 -> n_4 [id="[$e|2]", label="client_0→server_0:{req,pid}"]; } diff --git a/examples/serverclient/main_local_view.dot b/examples/serverclient/main_local_view.dot index 38d1439..4d05ac7 100644 --- a/examples/serverclient/main_local_view.dot +++ b/examples/serverclient/main_local_view.dot @@ -6,6 +6,6 @@ digraph main { n_2 [id="2", shape=circle, label="2"]; n_3 [id="3", shape=doublecircle, label="3"]; - n_1 -> n_2 [id="[$e|0]", label="spawn server_0"]; n_2 -> n_3 [id="[$e|1]", label="spawn client_0"]; + n_1 -> n_2 [id="[$e|0]", label="spawn server_0"]; } diff --git a/examples/serverclient/server_local_view.dot b/examples/serverclient/server_local_view.dot index 91f14c4..850cbfd 100644 --- a/examples/serverclient/server_local_view.dot +++ b/examples/serverclient/server_local_view.dot @@ -8,9 +8,9 @@ digraph server { n_4 [id="2", shape=circle, label="3"]; n_5 [id="3", shape=circle, label="2"]; + n_3 -> n_4 [id="[$e|3]", label="receive {req,P}"]; n_4 -> n_1 [id="[$e|0]", label="spawn handle_req_0"]; n_5 -> n_2 [id="[$e|6]", label="spawn handle_req_1"]; n_3 -> n_5 [id="[$e|5]", label="receive ciao"]; - n_3 -> n_4 [id="[$e|3]", label="receive {req,P}"]; n_1 -> n_3 [id="[$e|7]", label="send {res,pid} to P"]; } diff --git a/examples/ticktack/start_global_view.dot b/examples/ticktack/start_global_view.dot index bfa9797..007ad41 100644 --- a/examples/ticktack/start_global_view.dot +++ b/examples/ticktack/start_global_view.dot @@ -1,30 +1,33 @@ digraph global { rankdir="LR"; n_0 [label="global", shape="plaintext"]; - n_1 [id="5", shape=circle, label="6"]; - n_2 [id="12", shape=circle, label="5"]; + n_1 [id="5", shape=circle, label="5"]; + n_2 [id="12", shape=circle, label="12"]; n_3 [id="11", shape=circle, label="11"]; - n_4 [id="14", shape=circle, label="4"]; - n_5 [id="10", shape=circle, label="9"]; - n_6 [id="1", shape=circle, label="1"]; - n_0 -> n_6 [arrowhead=none]; - n_7 [id="2", shape=circle, label="2"]; - n_8 [id="8", shape=circle, label="10"]; - n_9 [id="4", shape=circle, label="7"]; - n_10 [id="7", shape=circle, label="8"]; - n_11 [id="3", shape=circle, label="3"]; + n_4 [id="14", shape=circle, label="14"]; + n_5 [id="6", shape=circle, label="6"]; + n_6 [id="13", shape=circle, label="13"]; + n_7 [id="10", shape=circle, label="10"]; + n_8 [id="1", shape=circle, label="1"]; + n_0 -> n_8 [arrowhead=none]; + n_9 [id="9", shape=circle, label="9"]; + n_10 [id="2", shape=circle, label="2"]; + n_11 [id="8", shape=circle, label="8"]; + n_12 [id="4", shape=circle, label="4"]; + n_13 [id="7", shape=circle, label="7"]; + n_14 [id="3", shape=circle, label="3"]; - n_11 -> n_4 [id="[$e|3]", label="startΔrandom_0"]; - n_6 -> n_7 [id="[$e|2]", label="startΔtac_loop_0"]; - n_2 -> n_9 [id="[$e|16]", label="tic_loop_0→tac_loop_0:stop"]; - n_5 -> n_3 [id="[$e|7]", label="tic_loop_0→tac_loop_0:tic"]; - n_4 -> n_2 [id="[$e|12]", label="random_0→tic_loop_0:stop"]; - n_5 -> n_9 [id="[$e|14]", label="tic_loop_0→tac_loop_0:stop"]; - n_3 -> n_9 [id="[$e|5]", label="tic_loop_0→tac_loop_0:stop"]; - n_4 -> n_1 [id="[$e|11]", label="start→tic_loop_0:tac"]; - n_7 -> n_11 [id="[$e|6]", label="startΔtic_loop_0"]; - n_10 -> n_8 [id="[$e|10]", label="random_0→tic_loop_0:stop"]; - n_8 -> n_9 [id="[$e|15]", label="tic_loop_0→tac_loop_0:stop"]; - n_1 -> n_10 [id="[$e|8]", label="tic_loop_0→tac_loop_0:tic"]; - n_1 -> n_5 [id="[$e|4]", label="random_0→tic_loop_0:stop"]; + n_1 -> n_11 [id="[$e|6]", label="random_0→tic_loop_0:stop"]; + n_3 -> n_4 [id="[$e|12]", label="tic_loop_0→tac_loop_0:stop"]; + n_5 -> n_9 [id="[$e|7]", label="tic_loop_0→tac_loop_0:stop"]; + n_7 -> n_6 [id="[$e|11]", label="tic_loop_0→tac_loop_0:stop"]; + n_10 -> n_14 [id="[$e|1]", label="startΔtic_loop_0"]; + n_8 -> n_10 [id="[$e|0]", label="startΔtac_loop_0"]; + n_11 -> n_2 [id="[$e|10]", label="tic_loop_0→tac_loop_0:stop"]; + n_12 -> n_5 [id="[$e|4]", label="random_0→tic_loop_0:stop"]; + n_13 -> n_7 [id="[$e|8]", label="random_0→tic_loop_0:stop"]; + n_12 -> n_1 [id="[$e|3]", label="start→tic_loop_0:tac"]; + n_1 -> n_13 [id="[$e|5]", label="tic_loop_0→tac_loop_0:tic"]; + n_14 -> n_12 [id="[$e|2]", label="startΔrandom_0"]; + n_11 -> n_3 [id="[$e|9]", label="tic_loop_0→tac_loop_0:tic"]; } diff --git a/examples/ticktack/start_local_view.dot b/examples/ticktack/start_local_view.dot index 3b9cba9..ac5c2d8 100644 --- a/examples/ticktack/start_local_view.dot +++ b/examples/ticktack/start_local_view.dot @@ -8,8 +8,8 @@ digraph start { n_4 [id="4", shape=doublecircle, label="5"]; n_5 [id="3", shape=circle, label="3"]; - n_2 -> n_3 [id="[$e|3]", label="spawn tac_loop_0"]; n_5 -> n_1 [id="[$e|1]", label="spawn random_0"]; - n_3 -> n_5 [id="[$e|2]", label="spawn tic_loop_0"]; n_1 -> n_4 [id="[$e|0]", label="send tac to tic_loop_0"]; + n_2 -> n_3 [id="[$e|3]", label="spawn tac_loop_0"]; + n_3 -> n_5 [id="[$e|2]", label="spawn tic_loop_0"]; } diff --git a/examples/ticktack/tac_loop_local_view.dot b/examples/ticktack/tac_loop_local_view.dot index f1490a6..8113438 100644 --- a/examples/ticktack/tac_loop_local_view.dot +++ b/examples/ticktack/tac_loop_local_view.dot @@ -6,9 +6,9 @@ digraph tac_loop { n_2 [id="4", shape=circle, label="3"]; n_3 [id="3", shape=doublecircle, label="2"]; - n_2 -> n_3 [id="[$e|3]", label="receive stop"]; - n_2 -> n_2 [id="[$e|2]", label="receive tic"]; n_2 -> n_1 [id="[$e|7]", label="send tac to tic_loop_0"]; - n_1 -> n_2 [id="[$e|5]", label="receive tic"]; n_1 -> n_3 [id="[$e|4]", label="receive stop"]; + n_2 -> n_3 [id="[$e|3]", label="receive stop"]; + n_1 -> n_2 [id="[$e|5]", label="receive tic"]; + n_2 -> n_2 [id="[$e|2]", label="receive tic"]; } diff --git a/examples/ticktack/tic_loop_local_view.dot b/examples/ticktack/tic_loop_local_view.dot index 55543df..a43e604 100644 --- a/examples/ticktack/tic_loop_local_view.dot +++ b/examples/ticktack/tic_loop_local_view.dot @@ -7,8 +7,8 @@ digraph tic_loop { n_3 [id="4", shape=circle, label="3"]; n_4 [id="3", shape=doublecircle, label="4"]; - n_3 -> n_4 [id="[$e|3]", label="send stop to tac_loop_0"]; - n_1 -> n_2 [id="[$e|1]", label="receive tac"]; n_2 -> n_1 [id="[$e|6]", label="send tic to tac_loop_0"]; + n_1 -> n_2 [id="[$e|1]", label="receive tac"]; n_1 -> n_3 [id="[$e|4]", label="receive stop"]; + n_3 -> n_4 [id="[$e|3]", label="send stop to tac_loop_0"]; } diff --git a/examples/trick/a_local_view.dot b/examples/trick/a_local_view.dot index a93155d..7137d2c 100644 --- a/examples/trick/a_local_view.dot +++ b/examples/trick/a_local_view.dot @@ -6,6 +6,6 @@ digraph a { n_2 [id="2", shape=circle, label="2"]; n_3 [id="3", shape=doublecircle, label="3"]; - n_2 -> n_3 [id="[$e|1]", label="send v2 to b_0"]; n_1 -> n_2 [id="[$e|0]", label="send v1 to c_0"]; + n_2 -> n_3 [id="[$e|1]", label="send v2 to b_0"]; } diff --git a/examples/trick/b_local_view.dot b/examples/trick/b_local_view.dot index 5bf7ada..e83cc13 100644 --- a/examples/trick/b_local_view.dot +++ b/examples/trick/b_local_view.dot @@ -6,6 +6,6 @@ digraph b { n_2 [id="2", shape=circle, label="2"]; n_3 [id="3", shape=doublecircle, label="3"]; - n_2 -> n_3 [id="[$e|1]", label="send v2 to c_0"]; n_1 -> n_2 [id="[$e|0]", label="receive v2"]; + n_2 -> n_3 [id="[$e|1]", label="send v2 to c_0"]; } diff --git a/examples/trick/c_local_view.dot b/examples/trick/c_local_view.dot index d63db2e..d6d64d8 100644 --- a/examples/trick/c_local_view.dot +++ b/examples/trick/c_local_view.dot @@ -6,6 +6,6 @@ digraph c { n_2 [id="2", shape=doublecircle, label="3"]; n_3 [id="3", shape=circle, label="2"]; - n_1 -> n_3 [id="[$e|1]", label="receive v1"]; n_3 -> n_2 [id="[$e|0]", label="receive v2"]; + n_1 -> n_3 [id="[$e|1]", label="receive v1"]; } diff --git a/examples/trick/main_global_view.dot b/examples/trick/main_global_view.dot index 14c1a3d..d379d4b 100644 --- a/examples/trick/main_global_view.dot +++ b/examples/trick/main_global_view.dot @@ -1,24 +1,25 @@ digraph global { rankdir="LR"; n_0 [label="global", shape="plaintext"]; - n_1 [id="5", shape=circle, label="7"]; - n_2 [id="6", shape=circle, label="9"]; - n_3 [id="10", shape=circle, label="4"]; + n_1 [id="5", shape=circle, label="5"]; + n_2 [id="6", shape=circle, label="6"]; + n_3 [id="10", shape=circle, label="10"]; n_4 [id="1", shape=circle, label="1"]; n_0 -> n_4 [arrowhead=none]; - n_5 [id="9", shape=circle, label="5"]; + n_5 [id="9", shape=circle, label="9"]; n_6 [id="2", shape=circle, label="2"]; n_7 [id="8", shape=circle, label="8"]; - n_8 [id="4", shape=circle, label="6"]; - n_9 [id="3", shape=circle, label="3"]; + n_8 [id="4", shape=circle, label="4"]; + n_9 [id="7", shape=circle, label="7"]; + n_10 [id="3", shape=circle, label="3"]; - n_7 -> n_2 [id="[$e|1]", label="b_0→c_0:v2"]; - n_8 -> n_1 [id="[$e|4]", label="a_0→c_0:v1"]; - n_3 -> n_5 [id="[$e|7]", label="a_0→c_0:v1"]; - n_3 -> n_8 [id="[$e|8]", label="a_0→b_0:v2"]; - n_5 -> n_7 [id="[$e|0]", label="a_0→b_0:v2"]; - n_6 -> n_9 [id="[$e|3]", label="mainΔb_0"]; - n_4 -> n_6 [id="[$e|2]", label="mainΔa_0"]; - n_9 -> n_3 [id="[$e|6]", label="mainΔc_0"]; - n_1 -> n_2 [id="[$e|9]", label="b_0→c_0:v2"]; + n_10 -> n_8 [id="[$e|2]", label="mainΔc_0"]; + n_4 -> n_6 [id="[$e|0]", label="mainΔa_0"]; + n_2 -> n_7 [id="[$e|6]", label="a_0→b_0:v2"]; + n_6 -> n_10 [id="[$e|1]", label="mainΔb_0"]; + n_1 -> n_9 [id="[$e|5]", label="a_0→c_0:v1"]; + n_7 -> n_3 [id="[$e|8]", label="b_0→c_0:v2"]; + n_8 -> n_1 [id="[$e|3]", label="a_0→b_0:v2"]; + n_8 -> n_2 [id="[$e|4]", label="a_0→c_0:v1"]; + n_9 -> n_5 [id="[$e|7]", label="b_0→c_0:v2"]; } diff --git a/examples/trick/main_local_view.dot b/examples/trick/main_local_view.dot index be634ad..d8fd95d 100644 --- a/examples/trick/main_local_view.dot +++ b/examples/trick/main_local_view.dot @@ -7,7 +7,7 @@ digraph main { n_3 [id="4", shape=doublecircle, label="4"]; n_4 [id="3", shape=circle, label="3"]; - n_1 -> n_2 [id="[$e|1]", label="spawn a_0"]; - n_4 -> n_3 [id="[$e|0]", label="spawn c_0"]; n_2 -> n_4 [id="[$e|2]", label="spawn b_0"]; + n_4 -> n_3 [id="[$e|0]", label="spawn c_0"]; + n_1 -> n_2 [id="[$e|1]", label="spawn a_0"]; } diff --git a/examples/violation/incrementer_local_view.dot b/examples/violation/incrementer_local_view.dot index b441471..048b64b 100644 --- a/examples/violation/incrementer_local_view.dot +++ b/examples/violation/incrementer_local_view.dot @@ -10,10 +10,10 @@ digraph incrementer { n_6 [id="7", shape=circle, label="3"]; n_7 [id="3", shape=circle, label="5"]; + n_1 -> n_5 [id="[$e|2]", label="send {release} to meManager_0"]; n_6 -> n_4 [id="[$e|3]", label="send {read,pid} to varManager_0"]; + n_4 -> n_7 [id="[$e|4]", label="receive X"]; n_3 -> n_2 [id="[$e|1]", label="send {request,pid} to meManager_0"]; n_7 -> n_1 [id="[$e|0]", label="send {write,write} to varManager_0"]; n_2 -> n_6 [id="[$e|5]", label="receive answer"]; - n_4 -> n_7 [id="[$e|4]", label="receive X"]; - n_1 -> n_5 [id="[$e|2]", label="send {release} to meManager_0"]; } diff --git a/examples/violation/main_global_view.dot b/examples/violation/main_global_view.dot index 0878158..a55a984 100644 --- a/examples/violation/main_global_view.dot +++ b/examples/violation/main_global_view.dot @@ -1,18 +1,19 @@ digraph global { rankdir="LR"; n_0 [label="global", shape="plaintext"]; - n_1 [id="5", shape=circle, label="6"]; - n_2 [id="1", shape=circle, label="1"]; - n_0 -> n_2 [arrowhead=none]; - n_3 [id="2", shape=circle, label="2"]; - n_4 [id="4", shape=circle, label="5"]; - n_5 [id="7", shape=circle, label="4"]; - n_6 [id="3", shape=circle, label="3"]; + n_1 [id="5", shape=circle, label="5"]; + n_2 [id="6", shape=circle, label="6"]; + n_3 [id="1", shape=circle, label="1"]; + n_0 -> n_3 [arrowhead=none]; + n_4 [id="2", shape=circle, label="2"]; + n_5 [id="4", shape=circle, label="4"]; + n_6 [id="7", shape=circle, label="7"]; + n_7 [id="3", shape=circle, label="3"]; - n_6 -> n_5 [id="[$e|3]", label="mainΔincrementer_0"]; - n_4 -> n_1 [id="[$e|1]", label="incrementer_1→meManager_0:{request,pid}"]; - n_3 -> n_6 [id="[$e|0]", label="mainΔvarManager_0"]; - n_4 -> n_1 [id="[$e|6]", label="incrementer_0→meManager_0:{request,pid}"]; - n_5 -> n_4 [id="[$e|4]", label="mainΔincrementer_1"]; - n_2 -> n_3 [id="[$e|2]", label="mainΔmeManager_0"]; + n_7 -> n_5 [id="[$e|2]", label="mainΔincrementer_0"]; + n_5 -> n_1 [id="[$e|3]", label="mainΔincrementer_1"]; + n_1 -> n_2 [id="[$e|4]", label="incrementer_0→meManager_0:{request,pid}"]; + n_4 -> n_7 [id="[$e|1]", label="mainΔvarManager_0"]; + n_3 -> n_4 [id="[$e|0]", label="mainΔmeManager_0"]; + n_1 -> n_6 [id="[$e|5]", label="incrementer_1→meManager_0:{request,pid}"]; } diff --git a/examples/violation/main_local_view.dot b/examples/violation/main_local_view.dot index 7e9d9d6..3fb5622 100644 --- a/examples/violation/main_local_view.dot +++ b/examples/violation/main_local_view.dot @@ -8,8 +8,8 @@ digraph main { n_4 [id="4", shape=doublecircle, label="5"]; n_5 [id="3", shape=circle, label="3"]; + n_2 -> n_3 [id="[$e|2]", label="spawn meManager_0"]; n_5 -> n_1 [id="[$e|3]", label="spawn incrementer_0"]; n_3 -> n_5 [id="[$e|1]", label="spawn varManager_0"]; n_1 -> n_4 [id="[$e|0]", label="spawn incrementer_1"]; - n_2 -> n_3 [id="[$e|2]", label="spawn meManager_0"]; } diff --git a/examples/violation/meManager_local_view.dot b/examples/violation/meManager_local_view.dot index e3f56af..7a0f2cc 100644 --- a/examples/violation/meManager_local_view.dot +++ b/examples/violation/meManager_local_view.dot @@ -6,7 +6,7 @@ digraph meManager { n_2 [id="2", shape=circle, label="2"]; n_3 [id="3", shape=circle, label="3"]; - n_1 -> n_2 [id="[$e|1]", label="receive {request,Pid}"]; - n_3 -> n_1 [id="[$e|4]", label="receive {release}"]; n_2 -> n_3 [id="[$e|2]", label="send answer to Pid"]; + n_3 -> n_1 [id="[$e|4]", label="receive {release}"]; + n_1 -> n_2 [id="[$e|1]", label="receive {request,Pid}"]; } diff --git a/examples/violation/varManager_local_view.dot b/examples/violation/varManager_local_view.dot index b57e880..fbae762 100644 --- a/examples/violation/varManager_local_view.dot +++ b/examples/violation/varManager_local_view.dot @@ -5,7 +5,7 @@ digraph varManager { n_0 -> n_1 [arrowhead=none]; n_2 [id="3", shape=circle, label="2"]; - n_1 -> n_2 [id="[$e|5]", label="receive {read,Pid}"]; - n_1 -> n_1 [id="[$e|8]", label="receive {write,NewVal}"]; n_2 -> n_1 [id="[$e|7]", label="send any to Pid"]; + n_1 -> n_1 [id="[$e|8]", label="receive {write,NewVal}"]; + n_1 -> n_2 [id="[$e|5]", label="receive {read,Pid}"]; } diff --git a/src/choreography/actor_emul.erl b/src/choreography/actor_emul.erl index fe2df0f..33f094f 100644 --- a/src/choreography/actor_emul.erl +++ b/src/choreography/actor_emul.erl @@ -9,6 +9,7 @@ get_proc_out_degree/1, get_proc_edge_info/2, get_proc_localvars/1, + add_proc_spawnvars/2, add_proc_localvars/2, get_proc_data/1, set_proc_data/2, @@ -26,6 +27,7 @@ get_proc_edges(P) -> send_recv(P, {self(), get_edges}). get_proc_out_degree(P) -> send_recv(P, {self(), get_out_degree}). get_proc_edge_info(P, E) -> send_recv(P, {self(), get_edge_info, E}). get_proc_localvars(P) -> send_recv(P, {self(), get_local_vars}). +add_proc_spawnvars(P, V) -> P ! {add_spawn_var, V}. add_proc_localvars(P, V) -> P ! {add_local_var, V}. get_proc_data(P) -> send_recv(P, {self(), get_data}). set_proc_data(P, Data) -> P ! {set_data, Data}. @@ -41,13 +43,15 @@ send_recv(P, Data) -> proc_loop(Data) -> ProcName = Data#actor_info.proc_id, - G = common_fun:get_localview(ProcName), + LV = common_fun:get_localview(ProcName), + G = LV#wip_lv.graph, % timer:sleep(200), VCurr = Data#actor_info.current_state, FirstMarkedE = Data#actor_info.first_marked_edges, SecondMarkedE = Data#actor_info.second_marked_edges, MessageQueue = Data#actor_info.message_queue, - LocalVars = Data#actor_info.local_vars, + SpawnVars = Data#actor_info.spawn_vars, + LocalVars = sets:union(Data#actor_info.local_vars, SpawnVars), receive {use_transition, E} -> IsAlreadyMarkedOnce = lists:member(E, FirstMarkedE), @@ -107,6 +111,8 @@ proc_loop(Data) -> {P, get_local_vars} -> P ! {sets:to_list(LocalVars)}, proc_loop(Data); + {add_spawn_var, V} -> + proc_loop(Data#actor_info{spawn_vars = sets:add_element(V, SpawnVars)}); {add_local_var, V} -> proc_loop(Data#actor_info{local_vars = sets:add_element(V, LocalVars)}); {P, get_mess_queue} -> diff --git a/src/choreography/gv.erl b/src/choreography/gv.erl index ed332bd..f12ad7a 100644 --- a/src/choreography/gv.erl +++ b/src/choreography/gv.erl @@ -11,7 +11,7 @@ %%% Generate the glabal view from an entrypoint and save it in a specified folder generate(Settings, EntryPoint) -> OutputDir = Settings#setting.output_dir, - MainGraph = common_fun:get_localview(EntryPoint), + MainGraph = common_fun:get_localview(EntryPoint), case MainGraph of not_found -> no_entry_point_found; @@ -40,7 +40,6 @@ create_globalview(Name) -> % initialize first branch progress_procs(RetG, [new_branch(RetG, VNew, ProcPidMap)]). -%%% Create a new branch object new_branch(G, V, P) -> #branch{ graph = G, @@ -48,7 +47,6 @@ new_branch(G, V, P) -> proc_pid_m = P }. -%%% Create a new message object new_message(F, D, E) -> #message{ from = F, data = D, edge = E @@ -239,7 +237,7 @@ is_lists_edgerecv(ProcPid, EL) -> %%% Evaluate a transition from an actor eval_edge(EdgeInfo, ProcName, ProcPid, BData) -> {Edge, _, _, PLabel} = EdgeInfo, - %io:fwrite("Proc ~p eval label ~p~n", [ProcName, PLabel]), + io:fwrite("Proc ~p eval label ~p~n", [ProcName, PLabel]), SLabel = atol(PLabel), IsArg = is_substring(SLabel, "arg"), IsSpawn = is_substring(SLabel, "spawn"), @@ -249,7 +247,7 @@ eval_edge(EdgeInfo, ProcName, ProcPid, BData) -> actor_emul:use_proc_transition(ProcPid, Edge), {BData, true}; IsSpawn -> - {VNew, NewM} = add_spawn_to_global(SLabel, ProcName, BData), + {VNew, NewM} = add_spawn_to_global(Edge, SLabel, ProcName, BData), NewBData = BData#branch{last_vertex = VNew, proc_pid_m = NewM}, actor_emul:use_proc_transition(ProcPid, Edge), {NewBData, true}; @@ -262,11 +260,32 @@ eval_edge(EdgeInfo, ProcName, ProcPid, BData) -> is_substring(S, SubS) -> is_list(string:find(S, SubS)). %%% Add a spanw transition to the global view -add_spawn_to_global(SLabel, ProcName, Data) -> +add_spawn_to_global(Edge, SLabel, ProcName, Data) -> + % get proc name ProcId = string:prefix(SLabel, "spawn "), FuncName = remove_last(remove_last(ProcId)), + % spawn the actor emulator FuncPid = spawn(actor_emul, proc_loop, [#actor_info{proc_id = ltoa(FuncName)}]), NewMap = maps:put(ltoa(ProcId), FuncPid, Data#branch.proc_pid_m), + LV = common_fun:get_localview(ProcName), + EM = common_fun:get_edgedata(ProcName), + % add input data to local vars + InputData = maps:get(Edge, EM), + Input = LV#wip_lv.input_vars, + io:fwrite("~p ~p~n", [Input, InputData]), + {LL, _} = lists:foldl( + fun({var, _, Name}, {A, In}) -> + case In of + [] -> {A ++ [#variable{name = Name}], []}; + [H | T] -> {A ++ [H#variable{name = Name}], T} + end + end, + {[], Input}, + InputData#variable.value + ), + + lists:foreach(fun(I) -> actor_emul:add_proc_spawnvars(FuncPid, I) end, LL), + % create the edge on the global graph VNew = common_fun:add_vertex(Data#branch.graph), %%% Δ means spawned NewLabel = atol(ProcName) ++ "Δ" ++ ProcId, @@ -360,7 +379,8 @@ check_vars(ProcName, ProcPid, VarName) -> SpInfoP#spawned_proc.args_called, SpInfoP#spawned_proc.args_local ) end, - SeachList = ArgsVars ++ GlobalViewLocalVars, %++ LocalViewLocalVars, + %++ LocalViewLocalVars, + SeachList = ArgsVars ++ GlobalViewLocalVars, %io:fwrite("Find var ~p in ~p from ~p~n", [VarName, SeachList, ProcName]), VarValue = find_var(SeachList, VarName), case VarValue of @@ -382,7 +402,9 @@ remove_pid_part(Data) -> ltoa(lists:flatten(string:replace(atol(Data), "pid_", ""))). %%% Get the spawn info given an actor id -find_spawn_info(_PId) -> +find_spawn_info(PId) -> + common_fun:get_edgedata(PId), + % SpInfoAll = db_manager:get_spawn_info(), % common_fun:first(lists:filter(fun(S) -> S#spawned_proc.name =:= PId end, SpInfoAll)), []. diff --git a/src/choreography/lv.erl b/src/choreography/lv.erl index 87c9281..0202e6f 100644 --- a/src/choreography/lv.erl +++ b/src/choreography/lv.erl @@ -26,27 +26,29 @@ create_save_localview(ActorName, Settings) -> io:fwrite("Error: Actor ~p's AST not found~n", [ActorName]); _ -> % io:fwrite("[LV] ~p~n", [ActorName]), - LocalViewData = check_and_get_lv(ActorName, ActorAst, Settings), + LocalViewData = check_and_get_lv(ActorName, ActorAst, [], Settings), G = LocalViewData#wip_lv.graph, set_final(G), MinGraph = fsa:minimize(G), - ets:insert(?LOCALVIEW, {ActorName, MinGraph}), + ets:insert(?LOCALVIEW, {ActorName, LocalViewData}), OutputDir = Settings#setting.output_dir, common_fun:save_graph_to_file(MinGraph, OutputDir, atol(ActorName), local) end. -create_localview(FunName) -> +create_localview(FunName, LocalVars) -> ActorAst = common_fun:get_fun_ast(FunName), case ActorAst of not_found -> io:fwrite("Error: Function ~p's AST not found~n", [FunName]); - _ -> check_and_get_lv(FunName, ActorAst, #setting{}) + _ -> check_and_get_lv(FunName, ActorAst, LocalVars, #setting{}) end. -check_and_get_lv(ActorName, Ast, Settings) -> - LV = common_fun:get_localview(ActorName), +check_and_get_lv(ActorName, Ast, LovalVars, Settings) -> + LV = common_fun:get_graph(ActorName), case LV of not_found -> - BaseData = #wip_lv{fun_name = ActorName, fun_ast = Ast, settings = Settings}, + BaseData = #wip_lv{ + fun_name = ActorName, fun_ast = Ast, settings = Settings, input_vars = LovalVars + }, common_fun:add_vertex(BaseData#wip_lv.graph), build_localview(BaseData); L -> @@ -54,25 +56,30 @@ check_and_get_lv(ActorName, Ast, Settings) -> end. build_localview(Data) -> - eval_pm_clause(Data#wip_lv.fun_ast, Data). - -add_args_to_graph(Gr, Vars, Guard, VStart, SetPm) -> - case SetPm of - true -> - VN = common_fun:add_vertex(Gr), - EdLabel = format_label_pm_edge(SetPm, Vars, Guard, "arg "), - digraph:add_edge(Gr, VStart, VN, EdLabel), - VN; - false -> - VStart - end. + eval_pm_clause(Data#wip_lv.fun_ast, [], Data). + +% add_args_to_graph(Gr, Vars, Guard, VStart, SetPm) -> +% case SetPm of +% true -> +% VN = common_fun:add_vertex(Gr), +% EdLabel = format_label_pm_edge(SetPm, Vars, Guard, "arg "), +% digraph:add_edge(Gr, VStart, VN, EdLabel), +% VN; +% false -> +% VStart +% end. eval_codeline(CodeLine, Data) -> - Line = element(2, CodeLine), - ets:insert(?CLINE, {line, Line}), - % io:fwrite("evaluating ~p on line ~p~n", [element(1, CodeLine), Line), + if + is_tuple(CodeLine) -> + Line = element(2, CodeLine), + % io:fwrite("evaluating ~p on line ~p~n", [element(1, CodeLine), Line]), + ets:insert(?CLINE, {line, Line}); + true -> + done + end, case CodeLine of - {clause, _, _Vars, _Guard, Content} -> eval_pm_clause(Content, Data); + {clause, _, Vars, _Guard, Content} -> eval_pm_clause(Content, Vars, Data); {match, _, RightContent, LeftContent} -> eval_match(RightContent, LeftContent, Data); {call, _, Function, ArgList} -> eval_call(Function, ArgList, Data); {'case', _, Content, PMList} -> eval_case(Content, PMList, Data); @@ -89,6 +96,8 @@ eval_codeline(CodeLine, Data) -> {map, _, Val} -> eval_map(Val, Data); {tuple, _, Val} -> eval_tuple(Val, Data); {var, _, VarName} -> eval_variable(VarName, Data); + [] -> eval_simple_type(list, [], Data); + [H | T] -> eval_list(H, T, Data); _ -> warning("couldn't parse code line", CodeLine, Data) end. @@ -97,11 +106,29 @@ warning(String, Content, Data) -> io:fwrite("WARNING on line ~p: " ++ String ++ " ~p~n", [Line, Content]), Data. -eval_pm_clause(Code, Data) -> - % db_manager:add_fun_local_vars(FunName, LocalVars), +eval_pm_clause(Code, Vars, Data) -> + LocalV = Data#wip_lv.local_vars, + ND = + case Vars =:= [] of + true -> + Data; + false -> + Input = Data#wip_lv.input_vars, + {LL, _} = lists:foldl( + fun({var, _, Name}, {A, In}) -> + case In of + [] -> {A ++ [#variable{name = Name}], []}; + [H | T] -> {A ++ [H#variable{name = Name}], T} + end + end, + {[], Input}, + Vars + ), + Data#wip_lv{local_vars = LocalV ++ LL} + end, lists:foldl( fun(Line, AccData) -> eval_codeline(Line, AccData) end, - Data, + ND, Code ). @@ -137,7 +164,7 @@ eval_call_by_atom(Name, ArgList, Data) -> spawn -> eval_spawn(ArgList, Data); self -> eval_self(Data); register -> eval_register(ArgList, Data); - Name -> eval_generic_call(Name, Data) + Name -> eval_generic_call(ArgList, Name, Data) end. %%% Dubbio: In questo caso bisogna ritornare i Data così come sono o bisogna impostare il last_vertex all'1? @@ -167,22 +194,22 @@ eval_spawn_one(Content, Data) -> S = Id ++ "_" ++ integer_to_list(C), VNew = common_fun:add_vertex(G), digraph:add_edge(G, VLast, VNew, "spawn " ++ S), - % {VarArgL, _, _} = eval_codeline(ArgList, FunName, G, AccData, SetPm), - % db_manager:add_fun_arg(S, VarArgL#variable.value), RetVar = #variable{type = pid, value = S}, Data#wip_lv{ret_var = RetVar, last_vertex = VNew}. -eval_spawn_three(Name, _SpArgList, Data) -> +eval_spawn_three(Name, ArgList, Data) -> G = Data#wip_lv.graph, VLast = Data#wip_lv.last_vertex, C = inc_spawn_counter(Name), S = atol(Name) ++ "_" ++ integer_to_list(C), VNew = common_fun:add_vertex(G), - digraph:add_edge(G, VLast, VNew, "spawn " ++ S), - % {VarArgL, _, _} = eval_codeline(ArgList, FunName, G, AccData, SetPm), - % db_manager:add_fun_arg(S, VarArgL#variable.value), + E = digraph:add_edge(G, VLast, VNew, "spawn " ++ S), + NewData = eval_codeline(ArgList, Data), + EM = NewData#wip_lv.edge_map, + io:fwrite("sucone ~p ~p~n", [E, NewData#wip_lv.ret_var]), + ND = NewData#wip_lv{edge_map = maps:put(E, NewData#wip_lv.ret_var, EM)}, RetVar = #variable{type = pid, value = S}, - Data#wip_lv{ret_var = RetVar, last_vertex = VNew}. + ND#wip_lv{ret_var = RetVar, last_vertex = VNew}. inc_spawn_counter(Name) -> case ets:lookup(?SPAWNC, ltoa(Name)) of @@ -213,11 +240,11 @@ eval_register(ArgList, Data) -> %%% Approx: ignoring returing value Data. -eval_generic_call(Name, Data) -> - % {V, _, NewL} = eval_codeline(ArgList, FunName, G, AccData, SetPm), - % NewData = eval_codeline(ArgList, Data), - % io:fwrite("[LOCAL] V ~p NewL ~p Name ~p~n", [V, NewL, FunName]), - case eval_func(Name) of +eval_generic_call(ArgList, Name, Data) -> + % io:fwrite("ARG LIST ~p~n", [ArgList]), + NewData = eval_codeline(ArgList, Data), + % io:fwrite("RET VAR ~p~n", [NewData#wip_lv.ret_var#variable.value]), + case eval_func(Name, NewData#wip_lv.ret_var#variable.value) of no_graph -> Data; NewD -> @@ -230,7 +257,7 @@ eval_generic_call(Name, Data) -> end. %%% TODO: eval argument list -eval_call_by_var(VarName, _ArgList, Data) -> +eval_call_by_var(VarName, ArgList, Data) -> G = Data#wip_lv.graph, VLast = Data#wip_lv.last_vertex, LocalVarL = Data#wip_lv.local_vars, @@ -240,7 +267,8 @@ eval_call_by_var(VarName, _ArgList, Data) -> warning("variable not found in eval_call_by_var with name", VarName, Data); _ -> Id = VarFound#variable.value, - NewData = create_localview(ltoa(Id)), + ND = eval_codeline(ArgList, Data), + NewData = create_localview(ltoa(Id), ND#wip_lv.ret_var#variable.value), NewG = NewData#wip_lv.graph, NewRet = NewData#wip_lv.ret_var, NewLastV = merge_graph(G, NewG, VLast), @@ -421,11 +449,11 @@ merge_graph(MainG, GToAdd, VLast) -> % return last added vertex, which is the max number in the key list maps:get(lists:max(maps:keys(VEquiMap)), VEquiMap). -eval_func(FuncName) -> +eval_func(FuncName, LV) -> FunAst = common_fun:get_fun_ast(FuncName), case FunAst of not_found -> no_graph; - _ -> create_localview(FuncName) + _ -> create_localview(FuncName, LV) end. %%% Evaluate Pattern Matching's list of clauses: evaluate every branch alone, then @@ -460,7 +488,7 @@ explore_pm(PMList, Base, Data) -> false -> V end, - VDataRet = eval_pm_clause(Content, Data#wip_lv{last_vertex = VL}), + VDataRet = eval_pm_clause(Content, [], Data#wip_lv{last_vertex = VL}), AddedVertexList ++ [VDataRet#wip_lv.last_vertex]; _ -> AddedVertexList diff --git a/src/share/common_data.hrl b/src/share/common_data.hrl index 44ca9e9..975906f 100644 --- a/src/share/common_data.hrl +++ b/src/share/common_data.hrl @@ -42,6 +42,8 @@ local_vars = [], ret_var = #variable{}, node_map = #{}, + edge_map = #{}, + input_vars = [], settings = #setting{} }). @@ -79,6 +81,7 @@ current_state = 1, first_marked_edges = [], second_marked_edges = [], + spawn_vars = sets:new(), local_vars = sets:new(), message_queue = [] }). diff --git a/src/share/common_fun.erl b/src/share/common_fun.erl index 5a1402f..5f26434 100644 --- a/src/share/common_fun.erl +++ b/src/share/common_fun.erl @@ -13,6 +13,8 @@ is_lowercase/1, get_fun_ast/1, get_localview/1, + get_graph/1, + get_edgedata/1, atol/1, ltoa/1 ]). @@ -83,6 +85,20 @@ get_localview(FunName) -> [{_, A}] -> A end. +get_graph(FunName) -> + Ast = ets:lookup(?LOCALVIEW, FunName), + case Ast of + [] -> not_found; + [{_, A}] -> A#wip_lv.graph + end. + +get_edgedata(FunName) -> + Ast = ets:lookup(?LOCALVIEW, FunName), + case Ast of + [] -> not_found; + [{_, A}] -> A#wip_lv.edge_map + end. + %%%=================================================================== %%% Internal Functions %%%=================================================================== diff --git a/test.sh b/test.sh index 986348b..5939711 100755 --- a/test.sh +++ b/test.sh @@ -1,9 +1,9 @@ rebar3 escriptize -./_build/default/bin/chorer ./examples/ticktack/tictacstop.erl start examples/ticktack ./_build/default/bin/chorer ./examples/hello/hello.erl greet examples/hello +./_build/default/bin/chorer ./examples/async/simple.erl main examples/async +./_build/default/bin/chorer ./examples/ticktack/tictacstop.erl start examples/ticktack +./_build/default/bin/chorer ./examples/customer/customer.erl main examples/customer ./_build/default/bin/chorer ./examples/serverclient/serverclient.erl main examples/serverclient -./_build/default/bin/chorer ./examples/airline/airline.erl main examples/airline ./_build/default/bin/chorer ./examples/trick/trick.erl main examples/trick -./_build/default/bin/chorer ./examples/violation/meViolation.erl main examples/violation -./_build/default/bin/chorer ./examples/customer/customer.erl main examples/customer -./_build/default/bin/chorer ./examples/async/simple.erl main examples/async \ No newline at end of file +./_build/default/bin/chorer ./examples/airline/airline.erl main examples/airline +./_build/default/bin/chorer ./examples/violation/meViolation.erl main examples/violation \ No newline at end of file From 6e531ba2e114bbf3b5ecf6c340177ae12505eaec Mon Sep 17 00:00:00 2001 From: geno Date: Wed, 14 Feb 2024 13:58:35 +0100 Subject: [PATCH 05/11] fix: spawn passing vars works --- examples/airline/agent_local_view.dot | 2 +- examples/airline/airline.erl | 7 +- examples/airline/main_global_view.dot | 28 +- examples/airline/main_local_view.dot | 20 +- examples/async/dummy1_local_view.dot | 2 +- examples/async/dummy2_local_view.dot | 2 +- examples/async/main_global_view.dot | 4 +- examples/async/main_local_view.dot | 2 +- examples/customer/customer_local_view.dot | 6 +- examples/customer/main_global_view.dot | 10 +- examples/customer/store_local_view.dot | 6 +- examples/hello/greet_global_view.dot | 2 - examples/hello/greet_local_view.dot | 6 +- examples/serverclient/client_local_view.dot | 6 +- .../serverclient/handle_req_local_view.dot | 2 +- examples/serverclient/main_global_view.dot | 23 +- examples/serverclient/server_local_view.dot | 6 +- examples/ticktack/start_global_view.dot | 14 +- examples/ticktack/start_local_view.dot | 4 +- examples/ticktack/tac_loop_local_view.dot | 2 +- examples/ticktack/tic_loop_local_view.dot | 2 +- examples/trick/a_local_view.dot | 2 +- examples/trick/b_local_view.dot | 2 +- examples/trick/c_local_view.dot | 2 +- examples/trick/main_global_view.dot | 6 +- examples/trick/main_local_view.dot | 4 +- examples/violation/incrementer_local_view.dot | 10 +- examples/violation/main_global_view.dot | 280 +++++++++++++++++- examples/violation/main_local_view.dot | 4 +- examples/violation/meManager_local_view.dot | 2 +- src/choreography/gv.erl | 147 +++------ src/choreography/lv.erl | 25 +- src/chorer.erl | 1 + src/share/common_data.hrl | 1 + src/share/common_fun.erl | 2 +- 35 files changed, 429 insertions(+), 215 deletions(-) diff --git a/examples/airline/agent_local_view.dot b/examples/airline/agent_local_view.dot index 0ba5406..9c04fa2 100644 --- a/examples/airline/agent_local_view.dot +++ b/examples/airline/agent_local_view.dot @@ -5,6 +5,6 @@ digraph agent { n_0 -> n_1 [arrowhead=none]; n_2 [id="3", shape=circle, label="2"]; - n_1 -> n_2 [id="[$e|1]", label="send {sell,pid} to Pid2"]; + n_1 -> n_2 [id="[$e|1]", label="send {sell,pid_self} to Pid2"]; n_2 -> n_1 [id="[$e|3]", label="receive {booked,_}"]; } diff --git a/examples/airline/airline.erl b/examples/airline/airline.erl index 719eb37..922ca05 100644 --- a/examples/airline/airline.erl +++ b/examples/airline/airline.erl @@ -4,14 +4,13 @@ main() -> spawn(?MODULE, agent, [self()]), spawn(?MODULE, agent, [self()]), - seats(self(), 3). + seats(3). -seats(Pid, Num) -> - Pid ! 2, +seats(Num) -> receive {sell, Pid1} -> Pid1 ! {booked, Num}, - seats(Pid, Num - 1) + seats(Num - 1) end. agent(Pid2) -> diff --git a/examples/airline/main_global_view.dot b/examples/airline/main_global_view.dot index 6e3015f..b896585 100644 --- a/examples/airline/main_global_view.dot +++ b/examples/airline/main_global_view.dot @@ -1,11 +1,27 @@ digraph global { rankdir="LR"; n_0 [label="global", shape="plaintext"]; - n_1 [id="1", shape=circle, label="1"]; - n_0 -> n_1 [arrowhead=none]; - n_2 [id="2", shape=circle, label="2"]; - n_3 [id="3", shape=circle, label="3"]; + n_1 [id="5", shape=circle, label="5"]; + n_2 [id="6", shape=circle, label="6"]; + n_3 [id="1", shape=circle, label="1"]; + n_0 -> n_3 [arrowhead=none]; + n_4 [id="2", shape=circle, label="2"]; + n_5 [id="4", shape=circle, label="4"]; + n_6 [id="7", shape=circle, label="7"]; + n_7 [id="3", shape=circle, label="3"]; - n_1 -> n_2 [id="[$e|0]", label="mainΔagent_0"]; - n_2 -> n_3 [id="[$e|1]", label="mainΔagent_1"]; + n_1 -> n_7 [id="[$e|7]", label="main→agent_1:{booked,3}"]; + n_7 -> n_1 [id="[$e|13]", label="main→agent_0:{booked,3}"]; + n_3 -> n_4 [id="[$e|0]", label="mainΔagent_0"]; + n_4 -> n_7 [id="[$e|1]", label="mainΔagent_1"]; + n_7 -> n_5 [id="[$e|12]", label="main→agent_1:{booked,3}"]; + n_5 -> n_2 [id="[$e|4]", label="agent_1→main:{sell,pid_self}"]; + n_7 -> n_5 [id="[$e|2]", label="agent_0→main:{sell,pid_self}"]; + n_2 -> n_5 [id="[$e|9]", label="main→agent_1:{booked,3}"]; + n_6 -> n_7 [id="[$e|11]", label="main→agent_1:{booked,3}"]; + n_2 -> n_7 [id="[$e|8]", label="main→agent_0:{booked,3}"]; + n_7 -> n_1 [id="[$e|3]", label="agent_1→main:{sell,pid_self}"]; + n_1 -> n_6 [id="[$e|6]", label="agent_0→main:{sell,pid_self}"]; + n_5 -> n_7 [id="[$e|5]", label="main→agent_0:{booked,3}"]; + n_6 -> n_1 [id="[$e|10]", label="main→agent_0:{booked,3}"]; } diff --git a/examples/airline/main_local_view.dot b/examples/airline/main_local_view.dot index 940d827..833b5fe 100644 --- a/examples/airline/main_local_view.dot +++ b/examples/airline/main_local_view.dot @@ -1,16 +1,14 @@ digraph main { rankdir="LR"; n_0 [label="main", shape="plaintext"]; - n_1 [id="5", shape=circle, label="4"]; - n_2 [id="1", shape=circle, label="1"]; - n_0 -> n_2 [arrowhead=none]; - n_3 [id="2", shape=circle, label="2"]; - n_4 [id="4", shape=circle, label="5"]; - n_5 [id="3", shape=circle, label="3"]; + n_1 [id="1", shape=circle, label="1"]; + n_0 -> n_1 [arrowhead=none]; + n_2 [id="2", shape=circle, label="3"]; + n_3 [id="4", shape=circle, label="4"]; + n_4 [id="3", shape=circle, label="2"]; - n_3 -> n_5 [id="[$e|0]", label="spawn agent_1"]; - n_1 -> n_4 [id="[$e|1]", label="receive {sell,Pid1}"]; - n_2 -> n_3 [id="[$e|3]", label="spawn agent_0"]; - n_4 -> n_5 [id="[$e|6]", label="send {booked,3} to Pid1"]; - n_5 -> n_1 [id="[$e|5]", label="send 2 to main"]; + n_3 -> n_2 [id="[$e|1]", label="send {booked,3} to Pid1"]; + n_2 -> n_3 [id="[$e|4]", label="receive {sell,Pid1}"]; + n_1 -> n_4 [id="[$e|2]", label="spawn agent_0"]; + n_4 -> n_2 [id="[$e|5]", label="spawn agent_1"]; } diff --git a/examples/async/dummy1_local_view.dot b/examples/async/dummy1_local_view.dot index 3e56cec..6e10ff8 100644 --- a/examples/async/dummy1_local_view.dot +++ b/examples/async/dummy1_local_view.dot @@ -6,6 +6,6 @@ digraph dummy1 { n_2 [id="2", shape=doublecircle, label="3"]; n_3 [id="3", shape=circle, label="2"]; - n_3 -> n_2 [id="[$e|1]", label="receive ciao"]; n_1 -> n_3 [id="[$e|0]", label="send bello to dummy2_0"]; + n_3 -> n_2 [id="[$e|1]", label="receive ciao"]; } diff --git a/examples/async/dummy2_local_view.dot b/examples/async/dummy2_local_view.dot index f3c5f58..660c639 100644 --- a/examples/async/dummy2_local_view.dot +++ b/examples/async/dummy2_local_view.dot @@ -6,6 +6,6 @@ digraph dummy2 { n_2 [id="2", shape=doublecircle, label="3"]; n_3 [id="3", shape=circle, label="2"]; - n_3 -> n_2 [id="[$e|1]", label="receive bello"]; n_1 -> n_3 [id="[$e|0]", label="send ciao to dummy1_0"]; + n_3 -> n_2 [id="[$e|1]", label="receive bello"]; } diff --git a/examples/async/main_global_view.dot b/examples/async/main_global_view.dot index 39cd2d1..f8db0ed 100644 --- a/examples/async/main_global_view.dot +++ b/examples/async/main_global_view.dot @@ -10,10 +10,10 @@ digraph global { n_6 [id="7", shape=circle, label="7"]; n_7 [id="3", shape=circle, label="3"]; - n_4 -> n_7 [id="[$e|1]", label="mainΔdummy2_0"]; n_3 -> n_4 [id="[$e|0]", label="mainΔdummy1_0"]; + n_4 -> n_7 [id="[$e|1]", label="mainΔdummy2_0"]; n_5 -> n_2 [id="[$e|4]", label="dummy1_0→dummy2_0:bello"]; + n_7 -> n_5 [id="[$e|2]", label="dummy2_0→dummy1_0:ciao"]; n_7 -> n_1 [id="[$e|3]", label="dummy1_0→dummy2_0:bello"]; n_1 -> n_6 [id="[$e|5]", label="dummy2_0→dummy1_0:ciao"]; - n_7 -> n_5 [id="[$e|2]", label="dummy2_0→dummy1_0:ciao"]; } diff --git a/examples/async/main_local_view.dot b/examples/async/main_local_view.dot index eb45845..4a7b843 100644 --- a/examples/async/main_local_view.dot +++ b/examples/async/main_local_view.dot @@ -6,6 +6,6 @@ digraph main { n_2 [id="2", shape=circle, label="2"]; n_3 [id="3", shape=doublecircle, label="3"]; - n_1 -> n_2 [id="[$e|1]", label="spawn dummy1_0"]; n_2 -> n_3 [id="[$e|0]", label="spawn dummy2_0"]; + n_1 -> n_2 [id="[$e|1]", label="spawn dummy1_0"]; } diff --git a/examples/customer/customer_local_view.dot b/examples/customer/customer_local_view.dot index 28bb4f1..44b4896 100644 --- a/examples/customer/customer_local_view.dot +++ b/examples/customer/customer_local_view.dot @@ -8,10 +8,10 @@ digraph customer { n_4 [id="4", shape=circle, label="4"]; n_5 [id="7", shape=circle, label="2"]; + n_5 -> n_3 [id="[$e|7]", label="send buy to store_0"]; + n_4 -> n_1 [id="[$e|2]", label="receive accepted"]; n_2 -> n_5 [id="[$e|3]", label="send item to store_0"]; - n_3 -> n_4 [id="[$e|5]", label="send payment to store_0"]; n_5 -> n_2 [id="[$e|8]", label="send more to store_0"]; n_4 -> n_3 [id="[$e|9]", label="receive reject"]; - n_5 -> n_3 [id="[$e|7]", label="send buy to store_0"]; - n_4 -> n_1 [id="[$e|2]", label="receive accepted"]; + n_3 -> n_4 [id="[$e|5]", label="send payment to store_0"]; } diff --git a/examples/customer/main_global_view.dot b/examples/customer/main_global_view.dot index 0d85b79..fdcb6fe 100644 --- a/examples/customer/main_global_view.dot +++ b/examples/customer/main_global_view.dot @@ -11,13 +11,13 @@ digraph global { n_7 [id="7", shape=circle, label="7"]; n_8 [id="3", shape=circle, label="3"]; + n_7 -> n_1 [id="[$e|7]", label="store_0→customer_0:reject"]; + n_8 -> n_6 [id="[$e|2]", label="customer_0→store_0:item"]; + n_2 -> n_6 [id="[$e|6]", label="customer_0→store_0:item"]; n_6 -> n_1 [id="[$e|3]", label="customer_0→store_0:buy"]; + n_7 -> n_5 [id="[$e|8]", label="store_0→customer_0:accepted"]; + n_6 -> n_2 [id="[$e|4]", label="customer_0→store_0:more"]; n_4 -> n_8 [id="[$e|1]", label="mainΔstore_0"]; n_3 -> n_4 [id="[$e|0]", label="mainΔcustomer_0"]; - n_2 -> n_6 [id="[$e|6]", label="customer_0→store_0:item"]; n_1 -> n_7 [id="[$e|5]", label="customer_0→store_0:payment"]; - n_7 -> n_5 [id="[$e|8]", label="store_0→customer_0:accepted"]; - n_6 -> n_2 [id="[$e|4]", label="customer_0→store_0:more"]; - n_7 -> n_1 [id="[$e|7]", label="store_0→customer_0:reject"]; - n_8 -> n_6 [id="[$e|2]", label="customer_0→store_0:item"]; } diff --git a/examples/customer/store_local_view.dot b/examples/customer/store_local_view.dot index 5a48012..2f89520 100644 --- a/examples/customer/store_local_view.dot +++ b/examples/customer/store_local_view.dot @@ -8,10 +8,10 @@ digraph store { n_4 [id="7", shape=doublecircle, label="5"]; n_5 [id="3", shape=circle, label="2"]; + n_3 -> n_1 [id="[$e|7]", label="receive payment"]; n_2 -> n_5 [id="[$e|3]", label="receive item"]; - n_1 -> n_4 [id="[$e|5]", label="send accepted to customer_0"]; n_5 -> n_2 [id="[$e|8]", label="receive more"]; - n_5 -> n_3 [id="[$e|9]", label="receive buy"]; n_1 -> n_3 [id="[$e|4]", label="send reject to customer_0"]; - n_3 -> n_1 [id="[$e|7]", label="receive payment"]; + n_5 -> n_3 [id="[$e|9]", label="receive buy"]; + n_1 -> n_4 [id="[$e|5]", label="send accepted to customer_0"]; } diff --git a/examples/hello/greet_global_view.dot b/examples/hello/greet_global_view.dot index 0681616..66efabb 100644 --- a/examples/hello/greet_global_view.dot +++ b/examples/hello/greet_global_view.dot @@ -3,7 +3,5 @@ digraph global { n_0 [label="global", shape="plaintext"]; n_1 [id="1", shape=circle, label="1"]; n_0 -> n_1 [arrowhead=none]; - n_2 [id="2", shape=circle, label="2"]; - n_1 -> n_2 [id="[$e|0]", label="greet→greet:hello1"]; } diff --git a/examples/hello/greet_local_view.dot b/examples/hello/greet_local_view.dot index 71af9ca..d7e698b 100644 --- a/examples/hello/greet_local_view.dot +++ b/examples/hello/greet_local_view.dot @@ -6,7 +6,7 @@ digraph greet { n_2 [id="2", shape=doublecircle, label="3"]; n_3 [id="3", shape=circle, label="2"]; - n_1 -> n_3 [id="[$e|3]", label="send hello1 to greet"]; - n_3 -> n_2 [id="[$e|2]", label="receive hello1"]; - n_3 -> n_1 [id="[$e|4]", label="send hello1 to greet"]; + n_3 -> n_2 [id="[$e|1]", label="receive hello1"]; + n_1 -> n_3 [id="[$e|2]", label="send hello1 to Me"]; + n_3 -> n_1 [id="[$e|4]", label="send hello1 to Me"]; } diff --git a/examples/serverclient/client_local_view.dot b/examples/serverclient/client_local_view.dot index 86e602b..acb2f1e 100644 --- a/examples/serverclient/client_local_view.dot +++ b/examples/serverclient/client_local_view.dot @@ -7,8 +7,8 @@ digraph client { n_3 [id="4", shape=circle, label="2"]; n_4 [id="3", shape=circle, label="3"]; - n_3 -> n_4 [id="[$e|3]", label="receive {res,Handle}"]; - n_1 -> n_3 [id="[$e|5]", label="send {req,pid} to server_0"]; - n_4 -> n_2 [id="[$e|4]", label="send done to Handle"]; n_4 -> n_4 [id="[$e|7]", label="send next to Handle"]; + n_3 -> n_4 [id="[$e|4]", label="receive {res,Handle}"]; + n_1 -> n_3 [id="[$e|1]", label="send {req,pid_self} to server_0"]; + n_4 -> n_2 [id="[$e|5]", label="send done to Handle"]; } diff --git a/examples/serverclient/handle_req_local_view.dot b/examples/serverclient/handle_req_local_view.dot index 7049be7..167736c 100644 --- a/examples/serverclient/handle_req_local_view.dot +++ b/examples/serverclient/handle_req_local_view.dot @@ -5,6 +5,6 @@ digraph handle_req { n_0 -> n_1 [arrowhead=none]; n_2 [id="3", shape=doublecircle, label="2"]; - n_1 -> n_2 [id="[$e|0]", label="receive done"]; n_1 -> n_1 [id="[$e|4]", label="receive next"]; + n_1 -> n_2 [id="[$e|0]", label="receive done"]; } diff --git a/examples/serverclient/main_global_view.dot b/examples/serverclient/main_global_view.dot index b13644a..a49dc7c 100644 --- a/examples/serverclient/main_global_view.dot +++ b/examples/serverclient/main_global_view.dot @@ -2,14 +2,19 @@ digraph global { rankdir="LR"; n_0 [label="global", shape="plaintext"]; n_1 [id="5", shape=circle, label="5"]; - n_2 [id="1", shape=circle, label="1"]; - n_0 -> n_2 [arrowhead=none]; - n_3 [id="2", shape=circle, label="2"]; - n_4 [id="4", shape=circle, label="4"]; - n_5 [id="3", shape=circle, label="3"]; + n_2 [id="6", shape=circle, label="6"]; + n_3 [id="1", shape=circle, label="1"]; + n_0 -> n_3 [arrowhead=none]; + n_4 [id="2", shape=circle, label="2"]; + n_5 [id="4", shape=circle, label="4"]; + n_6 [id="7", shape=circle, label="7"]; + n_7 [id="3", shape=circle, label="3"]; - n_4 -> n_1 [id="[$e|3]", label="server_0Δhandle_req_0"]; - n_3 -> n_5 [id="[$e|1]", label="mainΔclient_0"]; - n_2 -> n_3 [id="[$e|0]", label="mainΔserver_0"]; - n_5 -> n_4 [id="[$e|2]", label="client_0→server_0:{req,pid}"]; + n_7 -> n_5 [id="[$e|2]", label="client_0→server_0:{req,pid_self}"]; + n_2 -> n_2 [id="[$e|6]", label="client_0→handle_req_0:next"]; + n_5 -> n_1 [id="[$e|3]", label="server_0Δhandle_req_0"]; + n_1 -> n_2 [id="[$e|4]", label="server_0→client_0:{res,pid_handle_req_0}"]; + n_4 -> n_7 [id="[$e|1]", label="mainΔclient_0"]; + n_3 -> n_4 [id="[$e|0]", label="mainΔserver_0"]; + n_2 -> n_6 [id="[$e|5]", label="client_0→handle_req_0:done"]; } diff --git a/examples/serverclient/server_local_view.dot b/examples/serverclient/server_local_view.dot index 850cbfd..b6cdbc8 100644 --- a/examples/serverclient/server_local_view.dot +++ b/examples/serverclient/server_local_view.dot @@ -8,9 +8,9 @@ digraph server { n_4 [id="2", shape=circle, label="3"]; n_5 [id="3", shape=circle, label="2"]; - n_3 -> n_4 [id="[$e|3]", label="receive {req,P}"]; - n_4 -> n_1 [id="[$e|0]", label="spawn handle_req_0"]; + n_1 -> n_3 [id="[$e|7]", label="send {res,pid_handle_req_0} to P"]; + n_3 -> n_4 [id="[$e|2]", label="receive {req,P}"]; n_5 -> n_2 [id="[$e|6]", label="spawn handle_req_1"]; + n_4 -> n_1 [id="[$e|0]", label="spawn handle_req_0"]; n_3 -> n_5 [id="[$e|5]", label="receive ciao"]; - n_1 -> n_3 [id="[$e|7]", label="send {res,pid} to P"]; } diff --git a/examples/ticktack/start_global_view.dot b/examples/ticktack/start_global_view.dot index 007ad41..49a4946 100644 --- a/examples/ticktack/start_global_view.dot +++ b/examples/ticktack/start_global_view.dot @@ -17,17 +17,17 @@ digraph global { n_13 [id="7", shape=circle, label="7"]; n_14 [id="3", shape=circle, label="3"]; - n_1 -> n_11 [id="[$e|6]", label="random_0→tic_loop_0:stop"]; - n_3 -> n_4 [id="[$e|12]", label="tic_loop_0→tac_loop_0:stop"]; n_5 -> n_9 [id="[$e|7]", label="tic_loop_0→tac_loop_0:stop"]; - n_7 -> n_6 [id="[$e|11]", label="tic_loop_0→tac_loop_0:stop"]; - n_10 -> n_14 [id="[$e|1]", label="startΔtic_loop_0"]; n_8 -> n_10 [id="[$e|0]", label="startΔtac_loop_0"]; - n_11 -> n_2 [id="[$e|10]", label="tic_loop_0→tac_loop_0:stop"]; + n_10 -> n_14 [id="[$e|1]", label="startΔtic_loop_0"]; + n_3 -> n_4 [id="[$e|12]", label="tic_loop_0→tac_loop_0:stop"]; n_12 -> n_5 [id="[$e|4]", label="random_0→tic_loop_0:stop"]; + n_14 -> n_12 [id="[$e|2]", label="startΔrandom_0"]; + n_11 -> n_3 [id="[$e|9]", label="tic_loop_0→tac_loop_0:tic"]; + n_7 -> n_6 [id="[$e|11]", label="tic_loop_0→tac_loop_0:stop"]; n_13 -> n_7 [id="[$e|8]", label="random_0→tic_loop_0:stop"]; n_12 -> n_1 [id="[$e|3]", label="start→tic_loop_0:tac"]; + n_1 -> n_11 [id="[$e|6]", label="random_0→tic_loop_0:stop"]; n_1 -> n_13 [id="[$e|5]", label="tic_loop_0→tac_loop_0:tic"]; - n_14 -> n_12 [id="[$e|2]", label="startΔrandom_0"]; - n_11 -> n_3 [id="[$e|9]", label="tic_loop_0→tac_loop_0:tic"]; + n_11 -> n_2 [id="[$e|10]", label="tic_loop_0→tac_loop_0:stop"]; } diff --git a/examples/ticktack/start_local_view.dot b/examples/ticktack/start_local_view.dot index ac5c2d8..5ec9ceb 100644 --- a/examples/ticktack/start_local_view.dot +++ b/examples/ticktack/start_local_view.dot @@ -8,8 +8,8 @@ digraph start { n_4 [id="4", shape=doublecircle, label="5"]; n_5 [id="3", shape=circle, label="3"]; - n_5 -> n_1 [id="[$e|1]", label="spawn random_0"]; n_1 -> n_4 [id="[$e|0]", label="send tac to tic_loop_0"]; - n_2 -> n_3 [id="[$e|3]", label="spawn tac_loop_0"]; + n_5 -> n_1 [id="[$e|1]", label="spawn random_0"]; n_3 -> n_5 [id="[$e|2]", label="spawn tic_loop_0"]; + n_2 -> n_3 [id="[$e|3]", label="spawn tac_loop_0"]; } diff --git a/examples/ticktack/tac_loop_local_view.dot b/examples/ticktack/tac_loop_local_view.dot index 8113438..c13f774 100644 --- a/examples/ticktack/tac_loop_local_view.dot +++ b/examples/ticktack/tac_loop_local_view.dot @@ -8,7 +8,7 @@ digraph tac_loop { n_2 -> n_1 [id="[$e|7]", label="send tac to tic_loop_0"]; n_1 -> n_3 [id="[$e|4]", label="receive stop"]; + n_2 -> n_2 [id="[$e|2]", label="receive tic"]; n_2 -> n_3 [id="[$e|3]", label="receive stop"]; n_1 -> n_2 [id="[$e|5]", label="receive tic"]; - n_2 -> n_2 [id="[$e|2]", label="receive tic"]; } diff --git a/examples/ticktack/tic_loop_local_view.dot b/examples/ticktack/tic_loop_local_view.dot index a43e604..1bc7c57 100644 --- a/examples/ticktack/tic_loop_local_view.dot +++ b/examples/ticktack/tic_loop_local_view.dot @@ -7,8 +7,8 @@ digraph tic_loop { n_3 [id="4", shape=circle, label="3"]; n_4 [id="3", shape=doublecircle, label="4"]; - n_2 -> n_1 [id="[$e|6]", label="send tic to tac_loop_0"]; n_1 -> n_2 [id="[$e|1]", label="receive tac"]; n_1 -> n_3 [id="[$e|4]", label="receive stop"]; n_3 -> n_4 [id="[$e|3]", label="send stop to tac_loop_0"]; + n_2 -> n_1 [id="[$e|6]", label="send tic to tac_loop_0"]; } diff --git a/examples/trick/a_local_view.dot b/examples/trick/a_local_view.dot index 7137d2c..a93155d 100644 --- a/examples/trick/a_local_view.dot +++ b/examples/trick/a_local_view.dot @@ -6,6 +6,6 @@ digraph a { n_2 [id="2", shape=circle, label="2"]; n_3 [id="3", shape=doublecircle, label="3"]; - n_1 -> n_2 [id="[$e|0]", label="send v1 to c_0"]; n_2 -> n_3 [id="[$e|1]", label="send v2 to b_0"]; + n_1 -> n_2 [id="[$e|0]", label="send v1 to c_0"]; } diff --git a/examples/trick/b_local_view.dot b/examples/trick/b_local_view.dot index e83cc13..5bf7ada 100644 --- a/examples/trick/b_local_view.dot +++ b/examples/trick/b_local_view.dot @@ -6,6 +6,6 @@ digraph b { n_2 [id="2", shape=circle, label="2"]; n_3 [id="3", shape=doublecircle, label="3"]; - n_1 -> n_2 [id="[$e|0]", label="receive v2"]; n_2 -> n_3 [id="[$e|1]", label="send v2 to c_0"]; + n_1 -> n_2 [id="[$e|0]", label="receive v2"]; } diff --git a/examples/trick/c_local_view.dot b/examples/trick/c_local_view.dot index d6d64d8..d63db2e 100644 --- a/examples/trick/c_local_view.dot +++ b/examples/trick/c_local_view.dot @@ -6,6 +6,6 @@ digraph c { n_2 [id="2", shape=doublecircle, label="3"]; n_3 [id="3", shape=circle, label="2"]; - n_3 -> n_2 [id="[$e|0]", label="receive v2"]; n_1 -> n_3 [id="[$e|1]", label="receive v1"]; + n_3 -> n_2 [id="[$e|0]", label="receive v2"]; } diff --git a/examples/trick/main_global_view.dot b/examples/trick/main_global_view.dot index d379d4b..597e103 100644 --- a/examples/trick/main_global_view.dot +++ b/examples/trick/main_global_view.dot @@ -13,13 +13,13 @@ digraph global { n_9 [id="7", shape=circle, label="7"]; n_10 [id="3", shape=circle, label="3"]; - n_10 -> n_8 [id="[$e|2]", label="mainΔc_0"]; + n_8 -> n_1 [id="[$e|3]", label="a_0→b_0:v2"]; + n_6 -> n_10 [id="[$e|1]", label="mainΔb_0"]; n_4 -> n_6 [id="[$e|0]", label="mainΔa_0"]; n_2 -> n_7 [id="[$e|6]", label="a_0→b_0:v2"]; - n_6 -> n_10 [id="[$e|1]", label="mainΔb_0"]; n_1 -> n_9 [id="[$e|5]", label="a_0→c_0:v1"]; n_7 -> n_3 [id="[$e|8]", label="b_0→c_0:v2"]; - n_8 -> n_1 [id="[$e|3]", label="a_0→b_0:v2"]; n_8 -> n_2 [id="[$e|4]", label="a_0→c_0:v1"]; n_9 -> n_5 [id="[$e|7]", label="b_0→c_0:v2"]; + n_10 -> n_8 [id="[$e|2]", label="mainΔc_0"]; } diff --git a/examples/trick/main_local_view.dot b/examples/trick/main_local_view.dot index d8fd95d..be634ad 100644 --- a/examples/trick/main_local_view.dot +++ b/examples/trick/main_local_view.dot @@ -7,7 +7,7 @@ digraph main { n_3 [id="4", shape=doublecircle, label="4"]; n_4 [id="3", shape=circle, label="3"]; - n_2 -> n_4 [id="[$e|2]", label="spawn b_0"]; - n_4 -> n_3 [id="[$e|0]", label="spawn c_0"]; n_1 -> n_2 [id="[$e|1]", label="spawn a_0"]; + n_4 -> n_3 [id="[$e|0]", label="spawn c_0"]; + n_2 -> n_4 [id="[$e|2]", label="spawn b_0"]; } diff --git a/examples/violation/incrementer_local_view.dot b/examples/violation/incrementer_local_view.dot index 048b64b..59f0f67 100644 --- a/examples/violation/incrementer_local_view.dot +++ b/examples/violation/incrementer_local_view.dot @@ -10,10 +10,10 @@ digraph incrementer { n_6 [id="7", shape=circle, label="3"]; n_7 [id="3", shape=circle, label="5"]; - n_1 -> n_5 [id="[$e|2]", label="send {release} to meManager_0"]; - n_6 -> n_4 [id="[$e|3]", label="send {read,pid} to varManager_0"]; - n_4 -> n_7 [id="[$e|4]", label="receive X"]; - n_3 -> n_2 [id="[$e|1]", label="send {request,pid} to meManager_0"]; n_7 -> n_1 [id="[$e|0]", label="send {write,write} to varManager_0"]; - n_2 -> n_6 [id="[$e|5]", label="receive answer"]; + n_2 -> n_6 [id="[$e|4]", label="receive answer"]; + n_1 -> n_5 [id="[$e|2]", label="send {release} to meManager_0"]; + n_6 -> n_4 [id="[$e|1]", label="send {read,pid_self} to varManager_0"]; + n_4 -> n_7 [id="[$e|3]", label="receive X"]; + n_3 -> n_2 [id="[$e|5]", label="send {request,pid_self} to meManager_0"]; } diff --git a/examples/violation/main_global_view.dot b/examples/violation/main_global_view.dot index a55a984..afeb962 100644 --- a/examples/violation/main_global_view.dot +++ b/examples/violation/main_global_view.dot @@ -1,19 +1,271 @@ digraph global { rankdir="LR"; n_0 [label="global", shape="plaintext"]; - n_1 [id="5", shape=circle, label="5"]; - n_2 [id="6", shape=circle, label="6"]; - n_3 [id="1", shape=circle, label="1"]; - n_0 -> n_3 [arrowhead=none]; - n_4 [id="2", shape=circle, label="2"]; - n_5 [id="4", shape=circle, label="4"]; - n_6 [id="7", shape=circle, label="7"]; - n_7 [id="3", shape=circle, label="3"]; + n_1 [id="33", shape=circle, label="33"]; + n_2 [id="34", shape=circle, label="34"]; + n_3 [id="20", shape=circle, label="20"]; + n_4 [id="58", shape=circle, label="58"]; + n_5 [id="119", shape=circle, label="119"]; + n_6 [id="129", shape=circle, label="129"]; + n_7 [id="57", shape=circle, label="57"]; + n_8 [id="98", shape=circle, label="98"]; + n_9 [id="91", shape=circle, label="91"]; + n_10 [id="78", shape=circle, label="78"]; + n_11 [id="102", shape=circle, label="102"]; + n_12 [id="27", shape=circle, label="27"]; + n_13 [id="118", shape=circle, label="118"]; + n_14 [id="114", shape=circle, label="114"]; + n_15 [id="89", shape=circle, label="89"]; + n_16 [id="47", shape=circle, label="47"]; + n_17 [id="29", shape=circle, label="29"]; + n_18 [id="23", shape=circle, label="23"]; + n_19 [id="110", shape=circle, label="110"]; + n_20 [id="72", shape=circle, label="72"]; + n_21 [id="122", shape=circle, label="122"]; + n_22 [id="55", shape=circle, label="55"]; + n_23 [id="82", shape=circle, label="82"]; + n_24 [id="117", shape=circle, label="117"]; + n_25 [id="25", shape=circle, label="25"]; + n_26 [id="120", shape=circle, label="120"]; + n_27 [id="68", shape=circle, label="68"]; + n_28 [id="83", shape=circle, label="83"]; + n_29 [id="36", shape=circle, label="36"]; + n_30 [id="94", shape=circle, label="94"]; + n_31 [id="84", shape=circle, label="84"]; + n_32 [id="5", shape=circle, label="5"]; + n_33 [id="81", shape=circle, label="81"]; + n_34 [id="74", shape=circle, label="74"]; + n_35 [id="92", shape=circle, label="92"]; + n_36 [id="63", shape=circle, label="63"]; + n_37 [id="28", shape=circle, label="28"]; + n_38 [id="64", shape=circle, label="64"]; + n_39 [id="86", shape=circle, label="86"]; + n_40 [id="15", shape=circle, label="15"]; + n_41 [id="87", shape=circle, label="87"]; + n_42 [id="42", shape=circle, label="42"]; + n_43 [id="19", shape=circle, label="19"]; + n_44 [id="12", shape=circle, label="12"]; + n_45 [id="11", shape=circle, label="11"]; + n_46 [id="116", shape=circle, label="116"]; + n_47 [id="112", shape=circle, label="112"]; + n_48 [id="99", shape=circle, label="99"]; + n_49 [id="17", shape=circle, label="17"]; + n_50 [id="53", shape=circle, label="53"]; + n_51 [id="50", shape=circle, label="50"]; + n_52 [id="62", shape=circle, label="62"]; + n_53 [id="67", shape=circle, label="67"]; + n_54 [id="54", shape=circle, label="54"]; + n_55 [id="18", shape=circle, label="18"]; + n_56 [id="61", shape=circle, label="61"]; + n_57 [id="113", shape=circle, label="113"]; + n_58 [id="37", shape=circle, label="37"]; + n_59 [id="80", shape=circle, label="80"]; + n_60 [id="51", shape=circle, label="51"]; + n_61 [id="14", shape=circle, label="14"]; + n_62 [id="66", shape=circle, label="66"]; + n_63 [id="93", shape=circle, label="93"]; + n_64 [id="132", shape=circle, label="132"]; + n_65 [id="100", shape=circle, label="100"]; + n_66 [id="6", shape=circle, label="6"]; + n_67 [id="126", shape=circle, label="126"]; + n_68 [id="38", shape=circle, label="38"]; + n_69 [id="13", shape=circle, label="13"]; + n_70 [id="24", shape=circle, label="24"]; + n_71 [id="10", shape=circle, label="10"]; + n_72 [id="79", shape=circle, label="79"]; + n_73 [id="43", shape=circle, label="43"]; + n_74 [id="30", shape=circle, label="30"]; + n_75 [id="71", shape=circle, label="71"]; + n_76 [id="59", shape=circle, label="59"]; + n_77 [id="40", shape=circle, label="40"]; + n_78 [id="22", shape=circle, label="22"]; + n_79 [id="105", shape=circle, label="105"]; + n_80 [id="106", shape=circle, label="106"]; + n_81 [id="101", shape=circle, label="101"]; + n_82 [id="65", shape=circle, label="65"]; + n_83 [id="73", shape=circle, label="73"]; + n_84 [id="131", shape=circle, label="131"]; + n_85 [id="39", shape=circle, label="39"]; + n_86 [id="123", shape=circle, label="123"]; + n_87 [id="108", shape=circle, label="108"]; + n_88 [id="60", shape=circle, label="60"]; + n_89 [id="1", shape=circle, label="1"]; + n_0 -> n_89 [arrowhead=none]; + n_90 [id="115", shape=circle, label="115"]; + n_91 [id="45", shape=circle, label="45"]; + n_92 [id="26", shape=circle, label="26"]; + n_93 [id="133", shape=circle, label="133"]; + n_94 [id="76", shape=circle, label="76"]; + n_95 [id="9", shape=circle, label="9"]; + n_96 [id="2", shape=circle, label="2"]; + n_97 [id="104", shape=circle, label="104"]; + n_98 [id="97", shape=circle, label="97"]; + n_99 [id="21", shape=circle, label="21"]; + n_100 [id="127", shape=circle, label="127"]; + n_101 [id="107", shape=circle, label="107"]; + n_102 [id="44", shape=circle, label="44"]; + n_103 [id="69", shape=circle, label="69"]; + n_104 [id="46", shape=circle, label="46"]; + n_105 [id="95", shape=circle, label="95"]; + n_106 [id="77", shape=circle, label="77"]; + n_107 [id="8", shape=circle, label="8"]; + n_108 [id="96", shape=circle, label="96"]; + n_109 [id="124", shape=circle, label="124"]; + n_110 [id="48", shape=circle, label="48"]; + n_111 [id="88", shape=circle, label="88"]; + n_112 [id="109", shape=circle, label="109"]; + n_113 [id="130", shape=circle, label="130"]; + n_114 [id="103", shape=circle, label="103"]; + n_115 [id="128", shape=circle, label="128"]; + n_116 [id="4", shape=circle, label="4"]; + n_117 [id="70", shape=circle, label="70"]; + n_118 [id="35", shape=circle, label="35"]; + n_119 [id="121", shape=circle, label="121"]; + n_120 [id="31", shape=circle, label="31"]; + n_121 [id="32", shape=circle, label="32"]; + n_122 [id="85", shape=circle, label="85"]; + n_123 [id="41", shape=circle, label="41"]; + n_124 [id="7", shape=circle, label="7"]; + n_125 [id="90", shape=circle, label="90"]; + n_126 [id="75", shape=circle, label="75"]; + n_127 [id="3", shape=circle, label="3"]; + n_128 [id="52", shape=circle, label="52"]; + n_129 [id="56", shape=circle, label="56"]; + n_130 [id="125", shape=circle, label="125"]; + n_131 [id="49", shape=circle, label="49"]; + n_132 [id="111", shape=circle, label="111"]; + n_133 [id="16", shape=circle, label="16"]; - n_7 -> n_5 [id="[$e|2]", label="mainΔincrementer_0"]; - n_5 -> n_1 [id="[$e|3]", label="mainΔincrementer_1"]; - n_1 -> n_2 [id="[$e|4]", label="incrementer_0→meManager_0:{request,pid}"]; - n_4 -> n_7 [id="[$e|1]", label="mainΔvarManager_0"]; - n_3 -> n_4 [id="[$e|0]", label="mainΔmeManager_0"]; - n_1 -> n_6 [id="[$e|5]", label="incrementer_1→meManager_0:{request,pid}"]; + n_68 -> n_131 [id="[$e|47]", label="incrementer_0→varManager_0:{read,pid_self}"]; + n_70 -> n_121 [id="[$e|30]", label="meManager_0→incrementer_1:answer"]; + n_44 -> n_61 [id="[$e|12]", label="incrementer_0→meManager_0:{release}"]; + n_54 -> n_75 [id="[$e|69]", label="incrementer_1→varManager_0:{write,write}"]; + n_131 -> n_36 [id="[$e|61]", label="varManager_0→incrementer_0:any"]; + n_73 -> n_22 [id="[$e|53]", label="varManager_0→incrementer_1:any"]; + n_2 -> n_91 [id="[$e|43]", label="varManager_0→incrementer_1:any"]; + n_118 -> n_104 [id="[$e|44]", label="incrementer_1→varManager_0:{read,pid_self}"]; + n_37 -> n_58 [id="[$e|35]", label="meManager_0→incrementer_0:answer"]; + n_120 -> n_123 [id="[$e|39]", label="meManager_0→incrementer_0:answer"]; + n_12 -> n_29 [id="[$e|34]", label="meManager_0→incrementer_1:answer"]; + n_61 -> n_43 [id="[$e|17]", label="incrementer_0→varManager_0:{write,write}"]; + n_41 -> n_5 [id="[$e|117]", label="incrementer_0→meManager_0:{release}"]; + n_89 -> n_96 [id="[$e|0]", label="mainΔmeManager_0"]; + n_20 -> n_97 [id="[$e|102]", label="incrementer_1→varManager_0:{write,write}"]; + n_36 -> n_15 [id="[$e|87]", label="incrementer_0→varManager_0:{write,write}"]; + n_18 -> n_120 [id="[$e|29]", label="incrementer_0→meManager_0:{request,pid_self}"]; + n_32 -> n_66 [id="[$e|4]", label="incrementer_0→meManager_0:{request,pid_self}"]; + n_51 -> n_38 [id="[$e|62]", label="varManager_0→incrementer_0:any"]; + n_65 -> n_64 [id="[$e|130]", label="incrementer_0→varManager_0:{write,write}"]; + n_92 -> n_118 [id="[$e|33]", label="meManager_0→incrementer_1:answer"]; + n_75 -> n_114 [id="[$e|101]", label="incrementer_1→meManager_0:{release}"]; + n_127 -> n_116 [id="[$e|2]", label="mainΔincrementer_0"]; + n_49 -> n_18 [id="[$e|21]", label="incrementer_1→meManager_0:{release}"]; + n_105 -> n_100 [id="[$e|125]", label="incrementer_0→meManager_0:{release}"]; + n_85 -> n_51 [id="[$e|48]", label="incrementer_1→varManager_0:{write,write}"]; + n_85 -> n_60 [id="[$e|49]", label="varManager_0→incrementer_0:any"]; + n_3 -> n_12 [id="[$e|25]", label="incrementer_1→meManager_0:{request,pid_self}"]; + n_125 -> n_21 [id="[$e|120]", label="incrementer_0→varManager_0:{write,write}"]; + n_48 -> n_84 [id="[$e|129]", label="incrementer_0→meManager_0:{release}"]; + n_53 -> n_108 [id="[$e|94]", label="incrementer_0→meManager_0:{release}"]; + n_42 -> n_54 [id="[$e|52]", label="varManager_0→incrementer_1:any"]; + n_74 -> n_77 [id="[$e|38]", label="meManager_0→incrementer_0:answer"]; + n_52 -> n_39 [id="[$e|84]", label="incrementer_0→meManager_0:{release}"]; + n_72 -> n_132 [id="[$e|109]", label="incrementer_1→meManager_0:{release}"]; + n_88 -> n_23 [id="[$e|80]", label="incrementer_1→meManager_0:{release}"]; + n_66 -> n_107 [id="[$e|6]", label="meManager_0→incrementer_0:answer"]; + n_7 -> n_106 [id="[$e|75]", label="incrementer_1→varManager_0:{write,write}"]; + n_94 -> n_87 [id="[$e|106]", label="incrementer_1→varManager_0:{write,write}"]; + n_38 -> n_9 [id="[$e|89]", label="incrementer_0→varManager_0:{write,write}"]; + n_60 -> n_53 [id="[$e|65]", label="incrementer_0→varManager_0:{write,write}"]; + n_78 -> n_74 [id="[$e|28]", label="incrementer_0→meManager_0:{request,pid_self}"]; + n_99 -> n_17 [id="[$e|27]", label="meManager_0→incrementer_0:answer"]; + n_124 -> n_95 [id="[$e|7]", label="meManager_0→incrementer_1:answer"]; + n_133 -> n_99 [id="[$e|19]", label="incrementer_0→meManager_0:{request,pid_self}"]; + n_38 -> n_125 [id="[$e|88]", label="incrementer_0→meManager_0:{release}"]; + n_54 -> n_117 [id="[$e|68]", label="incrementer_1→meManager_0:{release}"]; + n_16 -> n_56 [id="[$e|59]", label="varManager_0→incrementer_1:any"]; + n_96 -> n_127 [id="[$e|1]", label="mainΔvarManager_0"]; + n_17 -> n_85 [id="[$e|37]", label="incrementer_0→varManager_0:{read,pid_self}"]; + n_77 -> n_128 [id="[$e|50]", label="incrementer_0→varManager_0:{read,pid_self}"]; + n_1 -> n_73 [id="[$e|41]", label="incrementer_1→varManager_0:{read,pid_self}"]; + n_62 -> n_105 [id="[$e|93]", label="incrementer_0→varManager_0:{write,write}"]; + n_29 -> n_16 [id="[$e|45]", label="incrementer_1→varManager_0:{read,pid_self}"]; + n_111 -> n_26 [id="[$e|118]", label="incrementer_0→varManager_0:{write,write}"]; + n_129 -> n_126 [id="[$e|73]", label="incrementer_1→varManager_0:{write,write}"]; + n_116 -> n_32 [id="[$e|3]", label="mainΔincrementer_1"]; + n_122 -> n_24 [id="[$e|115]", label="incrementer_1→meManager_0:{release}"]; + n_117 -> n_11 [id="[$e|100]", label="incrementer_1→varManager_0:{write,write}"]; + n_102 -> n_129 [id="[$e|54]", label="varManager_0→incrementer_1:any"]; + n_35 -> n_109 [id="[$e|122]", label="incrementer_0→varManager_0:{write,write}"]; + n_82 -> n_35 [id="[$e|90]", label="incrementer_1→varManager_0:{write,write}"]; + n_27 -> n_48 [id="[$e|97]", label="incrementer_0→varManager_0:{write,write}"]; + n_95 -> n_45 [id="[$e|9]", label="incrementer_1→varManager_0:{read,pid_self}"]; + n_103 -> n_81 [id="[$e|99]", label="incrementer_0→varManager_0:{write,write}"]; + n_59 -> n_47 [id="[$e|110]", label="incrementer_0→varManager_0:{write,write}"]; + n_31 -> n_46 [id="[$e|114]", label="incrementer_1→varManager_0:{write,write}"]; + n_110 -> n_52 [id="[$e|60]", label="varManager_0→incrementer_0:any"]; + n_15 -> n_119 [id="[$e|119]", label="incrementer_0→meManager_0:{release}"]; + n_62 -> n_30 [id="[$e|92]", label="incrementer_0→meManager_0:{release}"]; + n_36 -> n_111 [id="[$e|86]", label="incrementer_0→meManager_0:{release}"]; + n_63 -> n_130 [id="[$e|123]", label="incrementer_1→varManager_0:{write,write}"]; + n_107 -> n_71 [id="[$e|8]", label="incrementer_0→varManager_0:{read,pid_self}"]; + n_23 -> n_14 [id="[$e|112]", label="incrementer_1→varManager_0:{write,write}"]; + n_10 -> n_19 [id="[$e|108]", label="incrementer_1→varManager_0:{write,write}"]; + n_8 -> n_113 [id="[$e|128]", label="incrementer_0→varManager_0:{write,write}"]; + n_53 -> n_98 [id="[$e|95]", label="incrementer_1→varManager_0:{write,write}"]; + n_7 -> n_94 [id="[$e|74]", label="incrementer_0→varManager_0:{write,write}"]; + n_22 -> n_20 [id="[$e|70]", label="incrementer_1→meManager_0:{release}"]; + n_126 -> n_101 [id="[$e|105]", label="incrementer_1→meManager_0:{release}"]; + n_76 -> n_33 [id="[$e|79]", label="incrementer_0→varManager_0:{write,write}"]; + n_4 -> n_10 [id="[$e|76]", label="incrementer_1→meManager_0:{release}"]; + n_121 -> n_42 [id="[$e|40]", label="incrementer_1→varManager_0:{read,pid_self}"]; + n_17 -> n_68 [id="[$e|36]", label="incrementer_1→varManager_0:{write,write}"]; + n_55 -> n_70 [id="[$e|22]", label="incrementer_0→varManager_0:{write,write}"]; + n_25 -> n_1 [id="[$e|31]", label="incrementer_0→varManager_0:{write,write}"]; + n_56 -> n_31 [id="[$e|82]", label="incrementer_1→meManager_0:{release}"]; + n_69 -> n_49 [id="[$e|15]", label="incrementer_1→varManager_0:{write,write}"]; + n_83 -> n_79 [id="[$e|103]", label="incrementer_1→meManager_0:{release}"]; + n_58 -> n_110 [id="[$e|46]", label="incrementer_0→varManager_0:{read,pid_self}"]; + n_103 -> n_65 [id="[$e|98]", label="incrementer_0→meManager_0:{release}"]; + n_91 -> n_4 [id="[$e|56]", label="incrementer_0→varManager_0:{write,write}"]; + n_2 -> n_102 [id="[$e|42]", label="incrementer_0→varManager_0:{write,write}"]; + n_28 -> n_90 [id="[$e|113]", label="incrementer_1→meManager_0:{release}"]; + n_44 -> n_40 [id="[$e|13]", label="incrementer_0→varManager_0:{write,write}"]; + n_56 -> n_122 [id="[$e|83]", label="incrementer_1→varManager_0:{write,write}"]; + n_32 -> n_124 [id="[$e|5]", label="incrementer_1→meManager_0:{request,pid_self}"]; + n_52 -> n_41 [id="[$e|85]", label="incrementer_0→varManager_0:{write,write}"]; + n_22 -> n_83 [id="[$e|71]", label="incrementer_1→varManager_0:{write,write}"]; + n_91 -> n_7 [id="[$e|55]", label="incrementer_1→meManager_0:{release}"]; + n_34 -> n_80 [id="[$e|104]", label="incrementer_1→varManager_0:{write,write}"]; + n_39 -> n_13 [id="[$e|116]", label="incrementer_0→varManager_0:{write,write}"]; + n_60 -> n_62 [id="[$e|64]", label="incrementer_1→varManager_0:{write,write}"]; + n_123 -> n_50 [id="[$e|51]", label="incrementer_0→varManager_0:{read,pid_self}"]; + n_45 -> n_69 [id="[$e|11]", label="varManager_0→incrementer_1:any"]; + n_76 -> n_59 [id="[$e|78]", label="incrementer_1→meManager_0:{release}"]; + n_50 -> n_103 [id="[$e|67]", label="varManager_0→incrementer_0:any"]; + n_82 -> n_63 [id="[$e|91]", label="incrementer_0→varManager_0:{write,write}"]; + n_71 -> n_44 [id="[$e|10]", label="varManager_0→incrementer_0:any"]; + n_25 -> n_2 [id="[$e|32]", label="incrementer_1→varManager_0:{read,pid_self}"]; + n_99 -> n_37 [id="[$e|26]", label="incrementer_1→varManager_0:{write,write}"]; + n_129 -> n_34 [id="[$e|72]", label="incrementer_1→meManager_0:{release}"]; + n_30 -> n_67 [id="[$e|124]", label="incrementer_0→varManager_0:{write,write}"]; + n_4 -> n_72 [id="[$e|77]", label="incrementer_1→varManager_0:{write,write}"]; + n_108 -> n_115 [id="[$e|126]", label="incrementer_1→varManager_0:{write,write}"]; + n_40 -> n_3 [id="[$e|18]", label="incrementer_0→meManager_0:{release}"]; + n_61 -> n_55 [id="[$e|16]", label="incrementer_1→meManager_0:{request,pid_self}"]; + n_133 -> n_78 [id="[$e|20]", label="incrementer_1→varManager_0:{write,write}"]; + n_27 -> n_8 [id="[$e|96]", label="incrementer_0→meManager_0:{release}"]; + n_106 -> n_112 [id="[$e|107]", label="incrementer_0→varManager_0:{write,write}"]; + n_88 -> n_28 [id="[$e|81]", label="incrementer_1→varManager_0:{write,write}"]; + n_55 -> n_25 [id="[$e|23]", label="meManager_0→incrementer_1:answer"]; + n_91 -> n_76 [id="[$e|57]", label="incrementer_1→varManager_0:{write,write}"]; + n_9 -> n_86 [id="[$e|121]", label="incrementer_0→meManager_0:{release}"]; + n_43 -> n_92 [id="[$e|24]", label="incrementer_1→meManager_0:{request,pid_self}"]; + n_81 -> n_93 [id="[$e|131]", label="incrementer_0→meManager_0:{release}"]; + n_128 -> n_27 [id="[$e|66]", label="varManager_0→incrementer_0:any"]; + n_33 -> n_57 [id="[$e|111]", label="incrementer_1→meManager_0:{release}"]; + n_104 -> n_88 [id="[$e|58]", label="varManager_0→incrementer_1:any"]; + n_69 -> n_133 [id="[$e|14]", label="incrementer_1→meManager_0:{release}"]; + n_60 -> n_82 [id="[$e|63]", label="incrementer_0→meManager_0:{release}"]; + n_98 -> n_6 [id="[$e|127]", label="incrementer_0→meManager_0:{release}"]; } diff --git a/examples/violation/main_local_view.dot b/examples/violation/main_local_view.dot index 3fb5622..45c8a86 100644 --- a/examples/violation/main_local_view.dot +++ b/examples/violation/main_local_view.dot @@ -8,8 +8,8 @@ digraph main { n_4 [id="4", shape=doublecircle, label="5"]; n_5 [id="3", shape=circle, label="3"]; + n_1 -> n_4 [id="[$e|0]", label="spawn incrementer_1"]; n_2 -> n_3 [id="[$e|2]", label="spawn meManager_0"]; - n_5 -> n_1 [id="[$e|3]", label="spawn incrementer_0"]; n_3 -> n_5 [id="[$e|1]", label="spawn varManager_0"]; - n_1 -> n_4 [id="[$e|0]", label="spawn incrementer_1"]; + n_5 -> n_1 [id="[$e|3]", label="spawn incrementer_0"]; } diff --git a/examples/violation/meManager_local_view.dot b/examples/violation/meManager_local_view.dot index 7a0f2cc..70ae78b 100644 --- a/examples/violation/meManager_local_view.dot +++ b/examples/violation/meManager_local_view.dot @@ -6,7 +6,7 @@ digraph meManager { n_2 [id="2", shape=circle, label="2"]; n_3 [id="3", shape=circle, label="3"]; - n_2 -> n_3 [id="[$e|2]", label="send answer to Pid"]; n_3 -> n_1 [id="[$e|4]", label="receive {release}"]; + n_2 -> n_3 [id="[$e|2]", label="send answer to Pid"]; n_1 -> n_2 [id="[$e|1]", label="receive {request,Pid}"]; } diff --git a/src/choreography/gv.erl b/src/choreography/gv.erl index f12ad7a..db30707 100644 --- a/src/choreography/gv.erl +++ b/src/choreography/gv.erl @@ -237,7 +237,7 @@ is_lists_edgerecv(ProcPid, EL) -> %%% Evaluate a transition from an actor eval_edge(EdgeInfo, ProcName, ProcPid, BData) -> {Edge, _, _, PLabel} = EdgeInfo, - io:fwrite("Proc ~p eval label ~p~n", [ProcName, PLabel]), + %io:fwrite("Proc ~p eval label ~p~n", [ProcName, PLabel]), SLabel = atol(PLabel), IsArg = is_substring(SLabel, "arg"), IsSpawn = is_substring(SLabel, "spawn"), @@ -247,7 +247,7 @@ eval_edge(EdgeInfo, ProcName, ProcPid, BData) -> actor_emul:use_proc_transition(ProcPid, Edge), {BData, true}; IsSpawn -> - {VNew, NewM} = add_spawn_to_global(Edge, SLabel, ProcName, BData), + {VNew, NewM} = add_spawn_to_global(SLabel, ProcName, BData), NewBData = BData#branch{last_vertex = VNew, proc_pid_m = NewM}, actor_emul:use_proc_transition(ProcPid, Edge), {NewBData, true}; @@ -260,38 +260,46 @@ eval_edge(EdgeInfo, ProcName, ProcPid, BData) -> is_substring(S, SubS) -> is_list(string:find(S, SubS)). %%% Add a spanw transition to the global view -add_spawn_to_global(Edge, SLabel, ProcName, Data) -> +add_spawn_to_global(SLabel, ProcName, Data) -> % get proc name - ProcId = string:prefix(SLabel, "spawn "), - FuncName = remove_last(remove_last(ProcId)), + ProcIdS = string:prefix(SLabel, "spawn "), + FuncNameS = remove_last(remove_last(ProcIdS)), % spawn the actor emulator - FuncPid = spawn(actor_emul, proc_loop, [#actor_info{proc_id = ltoa(FuncName)}]), - NewMap = maps:put(ltoa(ProcId), FuncPid, Data#branch.proc_pid_m), - LV = common_fun:get_localview(ProcName), - EM = common_fun:get_edgedata(ProcName), - % add input data to local vars - InputData = maps:get(Edge, EM), - Input = LV#wip_lv.input_vars, - io:fwrite("~p ~p~n", [Input, InputData]), - {LL, _} = lists:foldl( - fun({var, _, Name}, {A, In}) -> - case In of - [] -> {A ++ [#variable{name = Name}], []}; - [H | T] -> {A ++ [H#variable{name = Name}], T} - end - end, - {[], Input}, - InputData#variable.value - ), - - lists:foreach(fun(I) -> actor_emul:add_proc_spawnvars(FuncPid, I) end, LL), + FuncPid = spawn(actor_emul, proc_loop, [#actor_info{proc_id = ltoa(FuncNameS)}]), + NewMap = maps:put(ltoa(ProcIdS), FuncPid, Data#branch.proc_pid_m), + % get spawn arguemnt and add them to the local variables of the actor + LocalList = get_local_vars(ProcName, SLabel, FuncNameS), + lists:foreach(fun(Var) -> actor_emul:add_proc_spawnvars(FuncPid, Var) end, LocalList), % create the edge on the global graph VNew = common_fun:add_vertex(Data#branch.graph), %%% Δ means spawned - NewLabel = atol(ProcName) ++ "Δ" ++ ProcId, + NewLabel = atol(ProcName) ++ "Δ" ++ ProcIdS, digraph:add_edge(Data#branch.graph, Data#branch.last_vertex, VNew, NewLabel), {VNew, NewMap}. +get_local_vars(ProcName, Label, FuncName) -> + EM = common_fun:get_edgedata(ProcName), + % add input data to local vars + InputData = maps:get(Label, EM, []), + % io:fwrite("ProcName ~p Label ~p Input ~p~n", [ProcName, Label, InputData]), + case InputData of + [] -> + []; + _ -> + [{_, Input}] = ets:lookup(?ARGUMENTS, ltoa(FuncName)), + {LL, _} = lists:foldl( + fun({var, _, Name}, {A, In}) -> + case In of + [] -> {A ++ [#variable{name = Name}], []}; + [H | T] -> {A ++ [H#variable{name = Name}], T} + end + end, + {[], InputData#variable.value}, + Input + ), + LL + end. + %%% Remove the last element froom a list remove_last(List) when is_list(List) -> {Rest, _} = lists:split(length(List) - 1, List), @@ -305,7 +313,7 @@ manage_send(SLabel, Data, ProcName, ProcPid, Edge) -> IsVar = common_fun:is_erlvar(ProcSentTemp), ProcSentName = case IsVar of - true -> check_vars(ProcName, ProcPid, ProcSentTemp); + true -> check_vars(ProcPid, ProcSentTemp); false -> ProcSentTemp end, ProcSentPid = maps:get(ProcSentName, ProcPidMap, no_pid), @@ -365,34 +373,18 @@ manage_recv(ProcPid, Message) -> end. %%% Find the actor id from a variable's list, given the variable name -check_vars(ProcName, ProcPid, VarName) -> - % Name = remove_id_from_proc(ProcName), - GlobalViewLocalVars = actor_emul:get_proc_localvars(ProcPid), - % LocalViewLocalVars = db_manager:get_fun_local_vars(Name), - SpInfoP = find_spawn_info(ProcName), - ArgsVars = - case SpInfoP =:= [] of - true -> - []; - false -> - convertL_in_variable( - SpInfoP#spawned_proc.args_called, SpInfoP#spawned_proc.args_local - ) - end, - %++ LocalViewLocalVars, - SeachList = ArgsVars ++ GlobalViewLocalVars, - %io:fwrite("Find var ~p in ~p from ~p~n", [VarName, SeachList, ProcName]), - VarValue = find_var(SeachList, VarName), +check_vars(ProcPid, VarName) -> + ProcLocalVars = actor_emul:get_proc_localvars(ProcPid), + % io:fwrite("Find var ~p in ~p from ~p~n", [VarName, ProcLocalVars, ProcName]), + VarValue = find_var(ProcLocalVars, VarName), case VarValue of nomatch -> VarName; V -> case V#variable.type of ?UNDEFINED -> VarName; - "self" -> SpInfoP#spawned_proc.called_where; - self -> SpInfoP#spawned_proc.called_where; - "pid_self" -> SpInfoP#spawned_proc.called_where; - pid_self -> SpInfoP#spawned_proc.called_where; + "pid_self" -> ltoa(V#variable.value); + pid_self -> ltoa(V#variable.value); _ -> remove_pid_part(V#variable.type) end end. @@ -401,63 +393,6 @@ check_vars(ProcName, ProcPid, VarName) -> remove_pid_part(Data) -> ltoa(lists:flatten(string:replace(atol(Data), "pid_", ""))). -%%% Get the spawn info given an actor id -find_spawn_info(PId) -> - common_fun:get_edgedata(PId), - - % SpInfoAll = db_manager:get_spawn_info(), - % common_fun:first(lists:filter(fun(S) -> S#spawned_proc.name =:= PId end, SpInfoAll)), - []. - -%%% Convert a list AST in a variable's list -convertL_in_variable(A, B) -> - convertL_in_variable(A, B, []). -convertL_in_variable({nil, _}, [], L) -> - L; -convertL_in_variable({cons, _, HeadList, TailList}, [H | T], L) -> - {var, _, Name} = H, - Var = convert_in_variable(HeadList, Name), - AL = convertL_in_variable(TailList, T, L), - [Var] ++ AL; -convertL_in_variable(_, _, _) -> - []. - -%%% Evaluate an AST entry and converts it to a variable -convert_in_variable(Eval, Name) -> - TempV = #variable{name = Name}, - case Eval of - {cons, _, HeadList, TailList} -> - Var = convert_in_variable(HeadList, ?UNDEFINED), - VarT = convert_in_variable(TailList, ?UNDEFINED), - NewVal = [Var] ++ VarT#variable.value, - TempV#variable{value = NewVal}; - %%% Evaluate Types - {call, _, {atom, _, self}, _} -> - TempV#variable{type = ltoa("pid_self")}; - {integer, _, Val} -> - TempV#variable{type = integer, value = Val}; - {float, _, Val} -> - TempV#variable{type = float, value = Val}; - {string, _, Val} -> - TempV#variable{type = string, value = Val}; - {atom, _, Val} -> - TempV#variable{type = atom, value = Val}; - {tuple, _, TupleVal} -> - L = lists:foldl( - fun(I, A) -> - V = convert_in_variable(I, ?UNDEFINED), - A ++ [V] - end, - [], - TupleVal - ), - TempV#variable{type = tuple, value = L}; - {nil, _} -> - TempV#variable{type = list, value = []}; - _ -> - TempV - end. - %%% Find a variable in a list, given the name find_var([], _) -> nomatch; diff --git a/src/choreography/lv.erl b/src/choreography/lv.erl index 0202e6f..0f58836 100644 --- a/src/choreography/lv.erl +++ b/src/choreography/lv.erl @@ -30,7 +30,7 @@ create_save_localview(ActorName, Settings) -> G = LocalViewData#wip_lv.graph, set_final(G), MinGraph = fsa:minimize(G), - ets:insert(?LOCALVIEW, {ActorName, LocalViewData}), + ets:insert(?LOCALVIEW, {ActorName, LocalViewData#wip_lv{graph = MinGraph}}), OutputDir = Settings#setting.output_dir, common_fun:save_graph_to_file(MinGraph, OutputDir, atol(ActorName), local) end. @@ -103,11 +103,20 @@ eval_codeline(CodeLine, Data) -> warning(String, Content, Data) -> [{_, Line}] = ets:lookup(?CLINE, line), - io:fwrite("WARNING on line ~p: " ++ String ++ " ~p~n", [Line, Content]), + io:fwrite("[LV] WARNING on line ~p: " ++ String ++ " ~p~n", [Line, Content]), Data. eval_pm_clause(Code, Vars, Data) -> LocalV = Data#wip_lv.local_vars, + FunName = ltoa(Data#wip_lv.fun_name), + Exist = ets:lookup(?ARGUMENTS, FunName), + % io:fwrite("Per ~p salvo ~p esiste ~p~n", [FunName, Vars, Exist]), + case Exist of + [] -> ets:insert(?ARGUMENTS, {FunName, Vars}); + [{_, []}] -> ets:insert(?ARGUMENTS, {FunName, Vars}); + %io:fwrite("Esiste già~n") + [{_, [_]}] -> done + end, ND = case Vars =:= [] of true -> @@ -203,11 +212,11 @@ eval_spawn_three(Name, ArgList, Data) -> C = inc_spawn_counter(Name), S = atol(Name) ++ "_" ++ integer_to_list(C), VNew = common_fun:add_vertex(G), - E = digraph:add_edge(G, VLast, VNew, "spawn " ++ S), + Label = "spawn " ++ S, + digraph:add_edge(G, VLast, VNew, Label), NewData = eval_codeline(ArgList, Data), EM = NewData#wip_lv.edge_map, - io:fwrite("sucone ~p ~p~n", [E, NewData#wip_lv.ret_var]), - ND = NewData#wip_lv{edge_map = maps:put(E, NewData#wip_lv.ret_var, EM)}, + ND = NewData#wip_lv{edge_map = maps:put(Label, NewData#wip_lv.ret_var, EM)}, RetVar = #variable{type = pid, value = S}, ND#wip_lv{ret_var = RetVar, last_vertex = VNew}. @@ -222,7 +231,7 @@ inc_spawn_counter(Name) -> end. eval_self(Data) -> - RetVar = #variable{type = pid, value = atol(Data#wip_lv.fun_name)}, + RetVar = #variable{type = pid_self, value = atol(Data#wip_lv.fun_name)}, Data#wip_lv{ret_var = RetVar}. eval_register(ArgList, Data) -> @@ -391,8 +400,8 @@ recordvar_to_string(Var) -> "string" -> "[" ++ Val ++ "]"; "atom" -> atol(Val); "tuple" -> format_tuple(Val, fun recordvar_to_string/1); - "pid" -> "pid"; - _ -> SType + "pid" -> "pid" ++ "_" ++ atol(Var#variable.value); + S -> S end end end. diff --git a/src/chorer.erl b/src/chorer.erl index 75ad289..f804354 100644 --- a/src/chorer.erl +++ b/src/chorer.erl @@ -38,4 +38,5 @@ init_db() -> ets:new(?FUNAST, [set, named_table]), ets:new(?LOCALVIEW, [set, named_table]), ets:new(?REGISTERDB, [set, named_table]), + ets:new(?ARGUMENTS, [set, named_table]), ets:new(?SPAWNC, [set, named_table]). diff --git a/src/share/common_data.hrl b/src/share/common_data.hrl index 975906f..c68b3d4 100644 --- a/src/share/common_data.hrl +++ b/src/share/common_data.hrl @@ -11,6 +11,7 @@ -define(INPUTAST, input_ast). -define(ACTORLIST, actor_list). -define(FUNAST, fun_ast). +-define(ARGUMENTS, args). -define(LOCALVIEW, lv). -define(REGISTERDB, reg). -define(SPAWNC, spc). diff --git a/src/share/common_fun.erl b/src/share/common_fun.erl index 5f26434..ab7af5d 100644 --- a/src/share/common_fun.erl +++ b/src/share/common_fun.erl @@ -95,7 +95,7 @@ get_graph(FunName) -> get_edgedata(FunName) -> Ast = ets:lookup(?LOCALVIEW, FunName), case Ast of - [] -> not_found; + [] -> #{}; [{_, A}] -> A#wip_lv.edge_map end. From 0e4abb9511a277f18919850efe72016685c53d26 Mon Sep 17 00:00:00 2001 From: geno Date: Wed, 14 Feb 2024 17:03:37 +0100 Subject: [PATCH 06/11] removed useless files, better eval match with tuples (to test) --- .../src/anonfun_line28_local_view.dot | 11 + .../corner_tests/src/scenarios_local_view.dot | 7 + .../corner_tests/src/test_global_view.dot | 9 + .../corner_tests/src/test_local_view.dot | 15 + src/choreography/db_manager.erl | 246 ------- src/choreography/global_view.erl | 610 ------------------ src/choreography/local_view.erl | 511 --------------- src/choreography/lv.erl | 87 ++- src/choreography/metadata.erl | 147 ----- 9 files changed, 102 insertions(+), 1541 deletions(-) create mode 100644 examples/concuerror_suites/corner_tests/src/anonfun_line28_local_view.dot create mode 100644 examples/concuerror_suites/corner_tests/src/scenarios_local_view.dot create mode 100644 examples/concuerror_suites/corner_tests/src/test_global_view.dot create mode 100644 examples/concuerror_suites/corner_tests/src/test_local_view.dot delete mode 100644 src/choreography/db_manager.erl delete mode 100644 src/choreography/global_view.erl delete mode 100644 src/choreography/local_view.erl delete mode 100644 src/choreography/metadata.erl diff --git a/examples/concuerror_suites/corner_tests/src/anonfun_line28_local_view.dot b/examples/concuerror_suites/corner_tests/src/anonfun_line28_local_view.dot new file mode 100644 index 0000000..bd7ccec --- /dev/null +++ b/examples/concuerror_suites/corner_tests/src/anonfun_line28_local_view.dot @@ -0,0 +1,11 @@ +digraph anonfun_line28 { + rankdir="LR"; + n_0 [label="anonfun_line28", shape="plaintext"]; + n_1 [id="1", shape=circle, label="1"]; + n_0 -> n_1 [arrowhead=none]; + n_2 [id="2", shape=doublecircle, label="3"]; + n_3 [id="3", shape=circle, label="2"]; + + n_3 -> n_2 [id="[$e|1]", label="send any to P1"]; + n_1 -> n_3 [id="[$e|0]", label="receive M"]; +} diff --git a/examples/concuerror_suites/corner_tests/src/scenarios_local_view.dot b/examples/concuerror_suites/corner_tests/src/scenarios_local_view.dot new file mode 100644 index 0000000..475e25e --- /dev/null +++ b/examples/concuerror_suites/corner_tests/src/scenarios_local_view.dot @@ -0,0 +1,7 @@ +digraph scenarios { + rankdir="LR"; + n_0 [label="scenarios", shape="plaintext"]; + n_1 [id="1", shape=circle, label="1"]; + n_0 -> n_1 [arrowhead=none]; + +} diff --git a/examples/concuerror_suites/corner_tests/src/test_global_view.dot b/examples/concuerror_suites/corner_tests/src/test_global_view.dot new file mode 100644 index 0000000..99d5915 --- /dev/null +++ b/examples/concuerror_suites/corner_tests/src/test_global_view.dot @@ -0,0 +1,9 @@ +digraph global { + rankdir="LR"; + n_0 [label="global", shape="plaintext"]; + n_1 [id="1", shape=circle, label="1"]; + n_0 -> n_1 [arrowhead=none]; + n_2 [id="2", shape=circle, label="2"]; + + n_1 -> n_2 [id="[$e|0]", label="testΔanonfun_line28_0"]; +} diff --git a/examples/concuerror_suites/corner_tests/src/test_local_view.dot b/examples/concuerror_suites/corner_tests/src/test_local_view.dot new file mode 100644 index 0000000..9177dda --- /dev/null +++ b/examples/concuerror_suites/corner_tests/src/test_local_view.dot @@ -0,0 +1,15 @@ +digraph test { + rankdir="LR"; + n_0 [label="test", shape="plaintext"]; + n_1 [id="5", shape=doublecircle, label="5"]; + n_2 [id="1", shape=circle, label="1"]; + n_0 -> n_2 [arrowhead=none]; + n_3 [id="2", shape=circle, label="2"]; + n_4 [id="4", shape=circle, label="4"]; + n_5 [id="3", shape=circle, label="3"]; + + n_2 -> n_3 [id="[$e|2]", label="spawn anonfun_line28_0"]; + n_5 -> n_4 [id="[$e|3]", label="send second to anonfun_line28_0"]; + n_3 -> n_5 [id="[$e|1]", label="send first to P1"]; + n_4 -> n_1 [id="[$e|0]", label="receive {DOWN,M,process,P1,Tag}"]; +} diff --git a/src/choreography/db_manager.erl b/src/choreography/db_manager.erl deleted file mode 100644 index 92f77b5..0000000 --- a/src/choreography/db_manager.erl +++ /dev/null @@ -1,246 +0,0 @@ --module(db_manager). --include("../share/common_data.hrl"). - -%%% Api --export([ - loop/0, - get_entrypoint/0, - get_exported_fun/0, - get_ast/0, - get_actors/0, - get_fun_ast/1, - get_fun_graph/1, - get_reg_entry/0, - get_fun_args/1, - get_func_arg_map/0, - get_spawn_info/0, - get_fun_local_vars/1, - add_reg_entry/1, - inc_spawn_counter/1, - reset_spawn_counter/0, - send_fun_graph/2, - send_actor_list/1, - send_ast/1, - send_fun_ast/2, - add_fun_arg/2, - send_spawn_info/1, - add_fun_local_vars/2 -]). - -%%% Database Manager Info Record --record(db_info, { - common_m = #{register_list => []}, func_data_m = #{}, func_arg_m = #{} -}). - -%%% Function Data Structure --record(func_data, { - is_actor = false, - ast = no_ast_found, - graph = no_graph_found, - spawned_counter = 0, - local_vars = [] -}). - -%%%=================================================================== -%%% API -%%%=================================================================== - -%%% init db data -loop() -> loop(#db_info{}). - -%%%=================================================================== -%%% API to interract with the dbmanager -%%%=================================================================== - -%%% Getters -get_entrypoint() -> get_from_db({self(), get_entrypoint}). -get_ast() -> get_from_db({self(), get_ast}). -get_exported_fun() -> get_from_db({self(), get_exported_fun}). -get_actors() -> get_from_db({self(), get_actor_list}). -get_fun_ast(Key) -> get_from_db({self(), get_fun_ast, Key}). -get_fun_graph(Key) -> get_from_db({self(), get_fun_graph, Key}). -get_reg_entry() -> get_from_db({self(), get_register_list}). -get_fun_args(Key) -> get_from_db({self(), get_fun_arg, Key}). -get_spawn_info() -> get_from_db({self(), get_spawn_info}). -get_func_arg_map() -> get_from_db({self(), get_func_args_map}). -get_fun_local_vars(Key) -> get_from_db({self(), get_local_vars, Key}). - -%%% Both getter and setter -inc_spawn_counter(Key) -> get_from_db({self(), inc_spawned_counter, Key}). -reset_spawn_counter() -> send_to_db({reset_spawned_counter}). - -%%% Setters -send_spawn_info(Data) -> send_to_db({set_spawn_info, Data}). -send_fun_graph(Key, Graph) -> send_to_db({set_fun_graph, Key, Graph}). -send_fun_ast(Key, Ast) -> send_to_db({set_fun_ast, Key, Ast}). -send_actor_list(L) -> send_to_db({set_actor_list, L}). -send_ast(Ast) -> send_to_db({set_ast, Ast}). -add_reg_entry(L) -> send_to_db({add_to_register_list, L}). -add_fun_arg(Key, Args) -> send_to_db({add_fun_args, Key, Args}). -add_fun_local_vars(Key, Data) -> send_to_db({add_local_vars, Key, Data}). - -%%%=================================================================== -%%% Internal Functions -%%%=================================================================== - -%%% Sent and receive data from the db menager -get_from_db(Data) -> - send_to_db(Data), - recv(). - -send_to_db(Data) -> ?DBMANAGER ! Data. - -recv() -> - receive - {Data} -> Data - end. - -loop(Data) -> - CommonMap = Data#db_info.common_m, - FuncDataM = Data#db_info.func_data_m, - FuncArgM = Data#db_info.func_arg_m, - receive - %%%%%%%%%%%%%%%%%%%%%%%%%%%%% - %%% Common Map Operations %%% - %%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - %%%========================== - {set_entrypoint, Ep} -> - NewCommon = maps:put(entrypoint, Ep, CommonMap), - loop(Data#db_info{common_m = NewCommon}); - {P, get_entrypoint} -> - P ! {maps:get(entrypoint, CommonMap)}, - loop(Data); - %%%========================== - {set_exported_fun, L} -> - NewCommon = maps:put(exported_fun, L, CommonMap), - loop(Data#db_info{common_m = NewCommon}); - {P, get_exported_fun} -> - P ! {maps:get(exported_fun, CommonMap)}, - loop(Data); - %%%========================== - {set_ast, Ast} -> - NewCommon = maps:put(ast, Ast, CommonMap), - loop(Data#db_info{common_m = NewCommon}); - {P, get_ast} -> - P ! {maps:get(ast, CommonMap)}, - loop(Data); - %%%========================== - {set_actor_list, ActorL} -> - NewCommon = maps:put(actor_list, ActorL, CommonMap), - NewFD = lists:foldl( - fun(Actor, AccM) -> - D = maps:get(Actor, AccM), - maps:put(Actor, D#func_data{is_actor = true}, AccM) - end, - FuncDataM, - ActorL - ), - loop(Data#db_info{common_m = NewCommon, func_data_m = NewFD}); - {P, get_actor_list} -> - P ! {maps:get(actor_list, CommonMap)}, - loop(Data); - %%%========================== - {add_to_register_list, Item} -> - RegList = maps:get(register_list, CommonMap), - NewCommon = maps:put(register_list, RegList ++ [Item], CommonMap), - loop(Data#db_info{common_m = NewCommon}); - {P, get_register_list} -> - P ! {maps:get(register_list, CommonMap)}, - loop(Data); - %%%========================== - {set_spawn_info, List} -> - NewCommonM = maps:put(spawn_info, List, CommonMap), - loop(Data#db_info{common_m = NewCommonM}); - {P, get_spawn_info} -> - P ! {maps:get(spawn_info, CommonMap)}, - loop(Data); - %%%========================== - - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - %%% Function Map Operations %%% - %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - - %%% function data map getter - {P, get_func_data_m} -> - P ! {FuncDataM}, - loop(Data); - %%% function asts element map setter and getter - {set_fun_ast, Key, Ast} -> - FuncD = maps:get(Key, FuncDataM, #func_data{}), - NewFD = maps:put(Key, FuncD#func_data{ast = Ast}, FuncDataM), - loop(Data#db_info{func_data_m = NewFD}); - {P, get_fun_ast, Key} -> - FuncD = maps:get(Key, FuncDataM, no_key_found), - case FuncD of - no_key_found -> P ! {no_func_found}; - D -> P ! {D#func_data.ast} - end, - loop(Data); - %%%========================== - - %%%%%%%%%%%%%%%%%%%%%%%%%%%% - %%% Graph Map Operations %%% - %%%%%%%%%%%%%%%%%%%%%%%%%%%% - - %%% getter and setter for function graphs elements - {set_fun_graph, Key, G} -> - FuncD = maps:get(Key, FuncDataM), - NewFD = maps:put(Key, FuncD#func_data{graph = G}, FuncDataM), - loop(Data#db_info{func_data_m = NewFD}); - {P, get_fun_graph, Key} -> - FuncD = maps:get(Key, FuncDataM, #func_data{}), - P ! {FuncD#func_data.graph}, - loop(Data); - %%% increments amd send the spawned counter - {reset_spawned_counter} -> - NewM = maps:fold( - fun(K, V, A) -> maps:put(K, V#func_data{spawned_counter = 0}, A) end, - #{}, - FuncDataM - ), - loop(Data#db_info{func_data_m = NewM}); - {P, inc_spawned_counter, Key} -> - FuncD = maps:get(Key, FuncDataM), - C = FuncD#func_data.spawned_counter, - P ! {C}, - NewFD = maps:put(Key, FuncD#func_data{spawned_counter = C + 1}, FuncDataM), - loop(Data#db_info{func_data_m = NewFD}); - %%%========================== - {add_local_vars, Key, AddL} -> - FuncD = maps:get(Key, FuncDataM), - List = FuncD#func_data.local_vars, - NewFD = maps:put(Key, FuncD#func_data{local_vars = List ++ AddL}, FuncDataM), - loop(Data#db_info{func_data_m = NewFD}); - {P, get_local_vars, Key} -> - FuncD = maps:get(Key, FuncDataM), - P ! {FuncD#func_data.local_vars}, - loop(Data); - %%%========================== - - %%%%%%%%%%%%%%%%%%%%%%%%%%%% - %%% Func Args Operations %%% - %%%%%%%%%%%%%%%%%%%%%%%%%%%% - - {P, get_func_args_map} -> - P ! {FuncArgM}, - loop(Data); - %%% getter and setter for function graphs elements - {add_fun_args, Key, Args} -> - L = maps:get(Key, FuncArgM, []), - NewFA = maps:put(Key, L ++ Args, FuncArgM), - loop(Data#db_info{func_arg_m = NewFA}); - {P, get_fun_arg, Key} -> - P ! {maps:get(Key, FuncArgM, no_fun_args_found)}, - loop(Data); - %%%========================== - {P, _} -> - io:fwrite("No pattern matching found for process ~p~n", [P]), - P ! no_pattern_matching_found, - loop(Data); - stop -> - done; - _ -> - io:fwrite("No pattern matching found in db manager loop~n"), - loop(Data) - end. diff --git a/src/choreography/global_view.erl b/src/choreography/global_view.erl deleted file mode 100644 index 96f9628..0000000 --- a/src/choreography/global_view.erl +++ /dev/null @@ -1,610 +0,0 @@ --module(global_view). --include("../share/common_data.hrl"). - -%%% API --export([generate/2]). - -%%%=================================================================== -%%% API -%%%=================================================================== - -%%% Generate the glabal view from an entrypoint and save it in a specified folder -generate(OutputDir, EntryPoint) -> - MainGraph = db_manager:get_fun_graph(EntryPoint), - case MainGraph of - no_graph_found -> - no_entry_point_found; - _ -> - G = create_globalview(EntryPoint), - {ok, [In]} = io:fread("Minimize global view? [y/n] ", "~a"), - CG = - case In of - n -> G; - _ -> fsa:minimize(G) - end, - common_fun:save_graph_to_file(CG, OutputDir, atol(EntryPoint), global), - finished - end. - -%%%=================================================================== -%%% Internal Functions -%%%=================================================================== - -%%% Create the glabal view from a function entrypoint name -create_globalview(Name) -> - RetG = digraph:new(), - VNew = common_fun:add_vertex(RetG), - MainProcPid = spawn(actor_emul, proc_loop, [#actor_info{proc_id = Name}]), - ProcPidMap = #{Name => MainProcPid}, - % initialize first branch - progress_procs(RetG, [new_branch(RetG, VNew, ProcPidMap)]). - -%%% Create a new branch object -new_branch(G, V, P) -> - #branch{ - graph = G, - last_vertex = V, - proc_pid_m = P - }. - -%%% Create a new message object -new_message(F, D, E) -> - #message{ - from = F, data = D, edge = E - }. - -%%% Explore every possible branch of executions -progress_procs(G, []) -> - G; -progress_procs(GlobalGraph, BranchList) when is_list(BranchList) -> - RealList = lists:flatten(BranchList), - %io:fwrite("Branch to eval ~p~n", [length(RealList)]), - NewBL = lists:foldl( - fun(Item, AccL) -> - %io:fwrite("Eval branch~n"), - NewBreanches = progress_single_branch(Item), - AccL ++ NewBreanches - end, - [], - RealList - ), - progress_procs(GlobalGraph, NewBL). - -%%% Explore the execution of a single branch -progress_single_branch(BData) -> - %%% First let's eval each actor until it reaches a recv edges - {TempBranchData, OpDone, NBL} = eval_branch_until_recv(BData), - %%% Then, let's eval recv edges for each actor, creating a new execution branch foreach message - TempProcPidMap = TempBranchData#branch.proc_pid_m, - NewBranchList = - NBL ++ - maps:fold( - fun(Name, Pid, AccList) -> - MessageQueue = actor_emul:get_proc_mess_queue(Pid), - %io:fwrite("[PROGSB] Name ~p MQ ~p~n", [Name, MessageQueue]), - gen_branch_foreach_mess(TempBranchData, MessageQueue, Name, AccList) - end, - [], - TempProcPidMap - ), - case NewBranchList =:= [] of - true -> - case OpDone of - true -> [TempBranchData]; - false -> [] - end; - false -> - NewBranchList - end. - -%%% Generate new branches for each message accepted from an actor -gen_branch_foreach_mess(BranchData, MessageQueue, ProcName, BaseList) -> - lists:foldl( - fun(Message, AccList) -> - %%% Check if there's an edge who accepts the message - DupData = dup_branch(BranchData), - NewMap = DupData#branch.proc_pid_m, - NewPid = maps:get(ProcName, NewMap), - case manage_recv(NewPid, Message) of - ?UNDEFINED -> - stop_processes(NewMap), - AccList; - %%% If an edge has been found, duplicate the branch and add the transition to the graph - EdgeFound -> - %io:fwrite("[RECV] Mess ~p Edge choose ~p~n", [Message, EdgeFound]), - ProcFrom = Message#message.from, - MessData = Message#message.data, - PidFrom = maps:get(ProcFrom, NewMap), - Label = format_send_label(ProcFrom, ProcName, MessData), - %io:fwrite("~n~n[RECV] LABEL ~ts~n~n", [Label]), - EFromInfo = actor_emul:get_proc_edge_info(PidFrom, Message#message.edge), - EToInfo = actor_emul:get_proc_edge_info(NewPid, EdgeFound), - %LastVertex = simple_add_vertex(DupData, Label), - {LastVertex, NewStateMap} = complex_add_vertex( - ProcFrom, EFromInfo, ProcName, EToInfo, DupData, Label - ), - actor_emul:del_proc_mess_queue(NewPid, Message), - %%% NOTE: the last operation MUST be the use_proc_transition, otherwise the final graph might be wrong - actor_emul:use_proc_transition(NewPid, EdgeFound), - AccList ++ [DupData#branch{last_vertex = LastVertex, states_m = NewStateMap}] - end - end, - BaseList, - MessageQueue - ). - -%%% Format the send label for the global view -format_send_label(ProcFrom, ProcTo, Data) -> - atol(ProcFrom) ++ "→" ++ atol(ProcTo) ++ ":" ++ atol(Data). - -%%% Create a duplicate for a branch object -dup_branch(Data) -> - Data#branch{proc_pid_m = duplicate_proccess(Data#branch.proc_pid_m)}. - -%%% Duplicate ideantical processes from a process' map -duplicate_proccess(ProcMap) -> - maps:fold( - fun(K, V, A) -> - Name = remove_id_from_proc(K), - NewPid = spawn(actor_emul, proc_loop, [#actor_info{proc_id = Name}]), - actor_emul:set_proc_data(NewPid, actor_emul:get_proc_data(V)), - maps:put(K, NewPid, A) - end, - #{}, - ProcMap - ). - -%%% Remove the number from an actor's identificator -remove_id_from_proc(ProcId) -> - SProcId = atol(ProcId), - {Name, N} = lists:split(length(SProcId) - 1, SProcId), - case catch list_to_integer(N) of - {'EXIT', _} -> ProcId; - _ -> ltoa(remove_last(Name)) - end. - -%%% Evaluate the edges of a local view until it reaches a receive edge foreach actor -eval_branch_until_recv(BranchData) -> - Map = BranchData#branch.proc_pid_m, - {NewData, OP, LL} = maps:fold( - fun(Name, Pid, {D, B, L}) -> - {ND, BB, LL} = eval_proc_branch(Name, Pid, D), - {ND, B or BB, L ++ [LL]} - end, - {BranchData, false, []}, - Map - ), - case OP of - true -> - {ND, _, L} = eval_branch_until_recv(NewData), - {ND, true, LL ++ L}; - false -> - {NewData, false, LL} - end. - -%%% Evaluate the edges of a local view until it reaches a receive edge -eval_proc_branch(ProcName, ProcPid, Data) -> - EL = actor_emul:get_proc_edges(ProcPid), - ELLength = length(EL), - if - ELLength =:= 0 -> - {Data, false, []}; - ELLength =:= 1 -> - E = common_fun:first(EL), - EI = actor_emul:get_proc_edge_info(ProcPid, E), - {D, B} = eval_edge(EI, ProcName, ProcPid, Data), - {D, B, []}; - true -> - Cond = is_lists_edgerecv(ProcPid, EL), - case Cond of - true -> - {Data, false, []}; - false -> - LL = lists:foldl( - fun(ItemE, L) -> - DD = dup_branch(Data), - PP = maps:get(ProcName, DD#branch.proc_pid_m), - EI = actor_emul:get_proc_edge_info(PP, ItemE), - {D, B} = eval_edge(EI, ProcName, PP, DD), - case B of - true -> L ++ [D]; - false -> L - end - end, - [], - EL - ), - case LL =:= [] of - true -> - {Data, false, []}; - false -> - [F | H] = LL, - {F, true, H} - end - end - end. - -%%% Given a list of edges, check if one is a receive edge -is_lists_edgerecv(ProcPid, EL) -> - lists:foldl( - fun(E, A) -> - {E, _, _, Label} = actor_emul:get_proc_edge_info(ProcPid, E), - A or is_substring(atol(Label), "receive") - end, - false, - EL - ). - -%%% Evaluate a transition from an actor -eval_edge(EdgeInfo, ProcName, ProcPid, BData) -> - {Edge, _, _, PLabel} = EdgeInfo, - %io:fwrite("Proc ~p eval label ~p~n", [ProcName, PLabel]), - SLabel = atol(PLabel), - IsArg = is_substring(SLabel, "arg"), - IsSpawn = is_substring(SLabel, "spawn"), - IsSend = is_substring(SLabel, "send"), - if - IsArg -> - actor_emul:use_proc_transition(ProcPid, Edge), - {BData, true}; - IsSpawn -> - {VNew, NewM} = add_spawn_to_global(SLabel, ProcName, BData), - NewBData = BData#branch{last_vertex = VNew, proc_pid_m = NewM}, - actor_emul:use_proc_transition(ProcPid, Edge), - {NewBData, true}; - IsSend -> - manage_send(SLabel, BData, ProcName, ProcPid, Edge); - true -> - {BData, false} - end. - -is_substring(S, SubS) -> is_list(string:find(S, SubS)). - -%%% Add a spanw transition to the global view -add_spawn_to_global(SLabel, ProcName, Data) -> - ProcId = string:prefix(SLabel, "spawn "), - FuncName = remove_last(remove_last(ProcId)), - FuncPid = spawn(actor_emul, proc_loop, [#actor_info{proc_id = ltoa(FuncName)}]), - NewMap = maps:put(ltoa(ProcId), FuncPid, Data#branch.proc_pid_m), - VNew = common_fun:add_vertex(Data#branch.graph), - %%% Δ means spawned - NewLabel = atol(ProcName) ++ "Δ" ++ ProcId, - digraph:add_edge(Data#branch.graph, Data#branch.last_vertex, VNew, NewLabel), - {VNew, NewMap}. - -%%% Remove the last element froom a list -remove_last(List) when is_list(List) -> - {Rest, _} = lists:split(length(List) - 1, List), - Rest. - -%%% Evaluate a send transition of an actor -manage_send(SLabel, Data, ProcName, ProcPid, Edge) -> - ProcPidMap = Data#branch.proc_pid_m, - DataSent = get_data_from_label(SLabel), - ProcSentTemp = ltoa(get_proc_from_label(SLabel)), - IsVar = common_fun:is_erlvar(ProcSentTemp), - ProcSentName = - case IsVar of - true -> check_vars(ProcName, ProcPid, ProcSentTemp); - false -> ProcSentTemp - end, - ProcSentPid = maps:get(ProcSentName, ProcPidMap, no_pid), - case ProcSentPid of - no_pid -> - %io:fwrite("[SEND-ERR] no pid found for: ~p~n", [ProcSentName]), - {Data, false}; - P -> - actor_emul:add_proc_mess_queue(P, new_message(ProcName, DataSent, Edge)), - %%% NOTE: the last operation MUST be the use_proc_transition, otherwise the final graph might be wrong - actor_emul:use_proc_transition(ProcPid, Edge), - {Data, true} - end. - -%%% Evaluate a receive transition of an actor -manage_recv(ProcPid, Message) -> - EL = actor_emul:get_proc_edges(ProcPid), - %%% TODO: trovare il modo di valutare in ordine i rami del receive (in quanto è molto rilevante nell'esecuzione) - IsRecv = is_lists_edgerecv(ProcPid, EL), - %io:fwrite("IsRECV ~p EL ~p~n", [IsRecv, EL]), - From = Message#message.from, - case IsRecv of - false -> - % TODO: gestire casistica, il seguente codice è vecchio e quindi da prendere con le pinze - % {NewL, NOp} = lists:foldl( - % fun(E, A) -> - % EInfo = get_proc_edge_info(ProcPid, E), - % {B, C} = A, - % {D, O} = eval_edge(EInfo, ProcName, ProcPid, Data), - % {B ++ [D], C or O} - % end, - % {[], false}, - % EL - % ), - % [H | T] = NewL, - % {H, T, NOp}; - ?UNDEFINED; - true -> - {_, EdgeChoosen} = lists:foldl( - fun(E, {B, Ret}) -> - case B of - true -> - {B, Ret}; - false -> - {E, _, _, ELabel} = actor_emul:get_proc_edge_info(ProcPid, E), - IsIt = is_pm_msg_compatible(ProcPid, From, ELabel, Message), - case IsIt of - true -> {true, E}; - false -> {B, Ret} - end - end - end, - {false, ?UNDEFINED}, - EL - ), - EdgeChoosen - end. - -%%% Find the actor id from a variable's list, given the variable name -check_vars(ProcName, ProcPid, VarName) -> - Name = remove_id_from_proc(ProcName), - GlobalViewLocalVars = actor_emul:get_proc_localvars(ProcPid), - LocalViewLocalVars = db_manager:get_fun_local_vars(Name), - SpInfoP = find_spawn_info(ProcName), - ArgsVars = - case SpInfoP =:= [] of - true -> - []; - false -> - convertL_in_variable( - SpInfoP#spawned_proc.args_called, SpInfoP#spawned_proc.args_local - ) - end, - SeachList = ArgsVars ++ LocalViewLocalVars ++ GlobalViewLocalVars, - %io:fwrite("Find var ~p in ~p from ~p~n", [VarName, SeachList, ProcName]), - VarValue = find_var(SeachList, VarName), - case VarValue of - nomatch -> - VarName; - V -> - case V#variable.type of - ?UNDEFINED -> VarName; - "self" -> SpInfoP#spawned_proc.called_where; - self -> SpInfoP#spawned_proc.called_where; - "pid_self" -> SpInfoP#spawned_proc.called_where; - pid_self -> SpInfoP#spawned_proc.called_where; - _ -> remove_pid_part(V#variable.type) - end - end. - -%%% Remove the "pid_" part from a variable's type -remove_pid_part(Data) -> - ltoa(lists:flatten(string:replace(atol(Data), "pid_", ""))). - -%%% Get the spawn info given an actor id -find_spawn_info(PId) -> - SpInfoAll = db_manager:get_spawn_info(), - common_fun:first(lists:filter(fun(S) -> S#spawned_proc.name =:= PId end, SpInfoAll)). - -%%% Convert a list AST in a variable's list -convertL_in_variable(A, B) -> - convertL_in_variable(A, B, []). -convertL_in_variable({nil, _}, [], L) -> - L; -convertL_in_variable({cons, _, HeadList, TailList}, [H | T], L) -> - {var, _, Name} = H, - Var = convert_in_variable(HeadList, Name), - AL = convertL_in_variable(TailList, T, L), - [Var] ++ AL; -convertL_in_variable(_, _, _) -> - []. - -%%% Evaluate an AST entry and converts it to a variable -convert_in_variable(Eval, Name) -> - TempV = #variable{name = Name}, - case Eval of - {cons, _, HeadList, TailList} -> - Var = convert_in_variable(HeadList, ?UNDEFINED), - VarT = convert_in_variable(TailList, ?UNDEFINED), - NewVal = [Var] ++ VarT#variable.value, - TempV#variable{value = NewVal}; - %%% Evaluate Types - {call, _, {atom, _, self}, _} -> - TempV#variable{type = ltoa("pid_self")}; - {integer, _, Val} -> - TempV#variable{type = integer, value = Val}; - {float, _, Val} -> - TempV#variable{type = float, value = Val}; - {string, _, Val} -> - TempV#variable{type = string, value = Val}; - {atom, _, Val} -> - TempV#variable{type = atom, value = Val}; - {tuple, _, TupleVal} -> - L = lists:foldl( - fun(I, A) -> - V = convert_in_variable(I, ?UNDEFINED), - A ++ [V] - end, - [], - TupleVal - ), - TempV#variable{type = tuple, value = L}; - {nil, _} -> - TempV#variable{type = list, value = []}; - _ -> - TempV - end. - -%%% Find a variable in a list, given the name -find_var([], _) -> - nomatch; -find_var([H | T], VarName) -> - Cond = H#variable.name =:= VarName, - case Cond of - true -> H; - false -> find_var(T, VarName) - end. - -%%% Check if a pattern metching match a message, then register the new variables -is_pm_msg_compatible(ProcPid, CallingProc, PatternMatching, Message) -> - {RetBool, RegList} = check_msg_comp( - ProcPid, CallingProc, PatternMatching, Message#message.data - ), - lists:foreach( - fun(Item) -> register_var(Item) end, - RegList - ), - RetBool. - -%%% Check if a pattern metching match a message -check_msg_comp(ProcPid, CallingProc, PatternMatching, Message) -> - MessageS = atol(Message), - PatternMS = lists:flatten(string:replace(atol(PatternMatching), "receive ", "")), - [FirstPChar | RestP] = PatternMS, - [FirstMChar | RestM] = MessageS, - IsFirstCharUpperCase = common_fun:is_erlvar(PatternMS), - if - %%% hierarchy - ([FirstPChar] =:= "{") and ([FirstMChar] =:= "{") -> - ContentP = remove_last(RestP), - ContentM = remove_last(RestM), - PL = string:split(ContentP, ",", all), - A = lists:enumerate(PL), - ML = string:split(ContentM, ",", all), - B = lists:enumerate(ML), - BoolList = [ - check_msg_comp(ProcPid, CallingProc, IA, IB) - || {BA, IA} <- A, {BB, IB} <- B, BA =:= BB - ], - and_rec(BoolList); - PatternMS =:= MessageS -> - {true, []}; - IsFirstCharUpperCase -> - {true, [{ProcPid, ltoa(PatternMS), check_pid_self(Message, CallingProc)}]}; - [FirstPChar] =:= "_" -> - {true, []}; - true -> - {false, []} - end. - -%%% Register a actor's variable -register_var(Data) -> - {ProcPid, Name, Type} = Data, - V = #variable{name = ltoa(Name), type = ltoa(Type)}, - %io:fwrite("Added Var ~p~n", [V]), - actor_emul:add_proc_localvars(ProcPid, V). - -%%% Substitute pif_self to pid_procId -check_pid_self(Data, ProcId) -> - % %io:fwrite("[C]Data ~p proc id ~p~n", [Data, ProcId]), - lists:flatten(string:replace(atol(Data), "pid_self", "pid_" ++ atol(ProcId))). - -%%% Custom recursive logic and -and_rec([]) -> - {true, []}; -and_rec([{B, L} | T]) -> - case B of - true -> - {A, LL} = and_rec(T), - {A, L ++ LL}; - false -> - {B, []} - end. - -%%% Add a send/recv vertex to the global view, with some checks for recusive edges -complex_add_vertex(Proc1, EdgeInfo1, Proc2, EdgeInfo2, Data, Label) -> - StateM = Data#branch.states_m, - VLast = Data#branch.last_vertex, - G = Data#branch.graph, - {_, V1, V2, _} = EdgeInfo1, - {_, PV1, PV2, _} = EdgeInfo2, - EL = digraph:out_edges(G, VLast), - %%% Check if these vertex correspond to a global view's vertex - Vfirst = maps:get({{Proc1, V2}, {Proc2, PV2}}, StateM, ?UNDEFINED), - %%% Recheck vertexs, but in another order - Vsecond = maps:get({{Proc2, PV2}, {Proc1, V2}}, StateM, ?UNDEFINED), - %%% Check if already exist the same transition - case check_same_label(G, EL, Label) of - nomatch -> - case Vfirst of - ?UNDEFINED -> - case Vsecond of - ?UNDEFINED -> - Cond = (V1 =:= V2) and (PV1 =:= PV2), - case Cond of - true -> - digraph:add_edge(G, VLast, VLast, Label), - NewM = maps:put({{Proc1, V1}, {Proc2, PV1}}, VLast, StateM), - {VLast, NewM}; - %%% Add a new vertex, because no match found in StateM - false -> - VAdded = common_fun:add_vertex(G), - digraph:add_edge(G, VLast, VAdded, Label), - NewM = maps:put({{Proc1, V1}, {Proc2, PV1}}, VLast, StateM), - {VAdded, NewM} - end; - _ -> - %%% Match second vertex - digraph:add_edge(G, VLast, Vsecond, Label), - NewM = maps:put({{Proc1, V1}, {Proc2, PV1}}, VLast, StateM), - {Vsecond, NewM} - end; - _ -> - %%% Match First vertex - %io:fwrite("[ADD]First defined!!~n"), - digraph:add_edge(G, VLast, Vfirst, Label), - {Vfirst, StateM} - end; - VRet -> - {VRet, StateM} - end. - -% simple_add_vertex(Data, Label) -> -% VLast = Data#branch.last_vertex, -% G = Data#branch.graph, -% VAdded = common_fun:add_vertex(G), -% digraph:add_edge(G, VLast, VAdded, Label), -% VAdded. - -%%% Returns the outgoing vertex given a label and a list of transition -check_same_label(G, EL, Label) -> - lists:foldl( - fun(E, A) -> - {E, _, VTo, VLabel} = digraph:edge(G, E), - case VLabel =:= Label of - true -> VTo; - false -> A - end - end, - nomatch, - EL - ). - -%%% Get the data from a send local view's label -get_data_from_label(S) -> - Ret = lists:nth(2, string:split(S, " ", all)), - FirstChar = common_fun:first(Ret), - if - [FirstChar] =:= "[" -> Ret ++ " " ++ lists:nth(3, string:split(S, " ", all)); - true -> Ret - end. - -%%% Get the process from a send local view's label -get_proc_from_label(S) -> - lists:reverse(lists:nth(1, string:split(lists:reverse(S), " ", all))). - -%%% Stop all the processes from the process map -stop_processes(DataL) when is_list(DataL) -> - lists:foreach( - fun(D) -> - M = D#branch.proc_pid_m, - stop_processes(M) - end, - DataL - ); -stop_processes(ProcMap) -> - maps:foreach(fun(_K, V) -> V ! stop end, ProcMap). - -atol(A) when is_list(A) -> A; -atol(A) when is_atom(A) -> atom_to_list(A). -ltoa(L) when is_atom(L) -> L; -ltoa(L) when is_list(L) -> list_to_atom(L). diff --git a/src/choreography/local_view.erl b/src/choreography/local_view.erl deleted file mode 100644 index eac4837..0000000 --- a/src/choreography/local_view.erl +++ /dev/null @@ -1,511 +0,0 @@ --module(local_view). --include("../share/common_data.hrl"). - -%%% API --export([generate/2]). - -%%%=================================================================== -%%% API -%%%=================================================================== - -%%% Generate a local view for each actor -generate(OutputDir, Options) -> - ActorList = db_manager:get_actors(), - %%% For each actor, create and save the local view - lists:foreach( - fun(Actor) -> create_localview(Actor, OutputDir, Options) end, - ActorList - ). - -%%%=================================================================== -%%% Internal Functions -%%%=================================================================== - -%%% Create a local view for an actor -create_localview(ActorName, OutputDir, Options) -> - {SetMoreInfo} = Options, - ActorAst = db_manager:get_fun_ast(ActorName), - case ActorAst of - no_ast_found -> - io:fwrite("Error: Actor ~p's AST not found~n", [ActorName]); - _ -> - TempG = db_manager:get_fun_graph(ActorName), - ToMinG = - case TempG of - no_graph_found -> get_localview(ActorName, ActorAst, [], SetMoreInfo); - G -> G - end, - set_final(ToMinG), - MinGraph = fsa:minimize(ToMinG), - db_manager:send_fun_graph(ActorName, MinGraph), - %%% Send the graph to the dbmanager - common_fun:save_graph_to_file(MinGraph, OutputDir, atol(ActorName), local) - end. - -%%% Get the local view of a function -get_localview(FunName, Code, LocalVars, SetPm) when is_list(Code) -> - Gr = digraph:new(), - VStart = common_fun:add_vertex(Gr), - lists:foreach( - fun(Line) -> - case Line of - {clause, _, Vars, Guard, Content} -> - %%% Show the pattern matching options to view the complete local view - VN = add_args_to_graph(Gr, Vars, Guard, VStart, SetPm), - _VFinal = eval_pm_clause(Content, FunName, Gr, VN, LocalVars, false); - _ -> - ?UNDEFINED - end - end, - Code - ), - Gr. - -%%% Add "Argument" Edges to the local view. -add_args_to_graph(Gr, Vars, Guard, VStart, SetPm) -> - case SetPm of - true -> - VN = common_fun:add_vertex(Gr), - EdLabel = format_label_pm_edge(SetPm, Vars, Guard, "arg "), - digraph:add_edge(Gr, VStart, VN, EdLabel), - VN; - false -> - VStart - end. - -%%% Evaluate each codeline of a function and returns the last vertex added to the graph -eval_pm_clause(Code, FunName, Gr, VStart, LocalVarS, SetPm) -> - {_, LastVertexAdded, LocalVars} = lists:foldl( - fun(Line, AccData) -> eval_codeline(Line, FunName, Gr, AccData, SetPm) end, - {#variable{}, VStart, LocalVarS}, - Code - ), - db_manager:add_fun_local_vars(FunName, LocalVars), - LastVertexAdded. - -%%% Evaluate a single line of code and returns the last vertex added to the graph and the list of local variables -eval_codeline(CodeLine, FunName, G, AccData, SetPm) -> - {LastRetVar, VLast, LocalVarL} = AccData, - case CodeLine of - %%% In a match code line (Var = ...), evaluate the left - %%% content because it could be a receive, case, if, etc... - {match, _, {var, _, VarName}, LeftContent} -> - {Var, V, NewL} = eval_codeline(LeftContent, FunName, G, AccData, SetPm), - NewVarEntry = Var#variable{name = VarName}, - case Var#variable.type of - function -> done; - _ -> ?UNDEFINED - end, - {Var, V, NewL ++ [NewVarEntry]}; - %%% If there's a recursive call, just add an epsilon edge to the first state - {call, _, {atom, _, FunName}, _ArgList} -> - digraph:add_edge(G, VLast, 1, 'ɛ'), - {#variable{}, 1, LocalVarL}; - %%% Evaluate the spawn() function - {call, _, {atom, _, spawn}, [{var, _, Name}]} -> - % VarFound = find_var(LocalVarL, Name), - C = db_manager:inc_spawn_counter(Name), - S = atol(Name) ++ "_" ++ integer_to_list(C), - VNew = common_fun:add_vertex(G), - digraph:add_edge(G, VLast, VNew, "spawn " ++ S), - % {VarArgL, _, _} = eval_codeline(ArgList, FunName, G, AccData, SetPm), - % db_manager:add_fun_arg(S, VarArgL#variable.value), - {#variable{type = ltoa("pid_" ++ S)}, VNew, LocalVarL}; - {call, _, {atom, _, spawn}, [_, {atom, _, Name}, ArgList]} -> - C = db_manager:inc_spawn_counter(Name), - S = atol(Name) ++ "_" ++ integer_to_list(C), - VNew = common_fun:add_vertex(G), - digraph:add_edge(G, VLast, VNew, "spawn " ++ S), - {VarArgL, _, _} = eval_codeline(ArgList, FunName, G, AccData, SetPm), - db_manager:add_fun_arg(S, VarArgL#variable.value), - {#variable{type = ltoa("pid_" ++ S)}, VNew, LocalVarL}; - %%% Evaluate the self() function - {call, _, {atom, _, self}, _} -> - {#variable{type = ltoa("pid_self")}, VLast, LocalVarL}; - %%% Evaluate the register() function - {call, _, {atom, _, register}, [{atom, _, AtomV}, {var, _, VarV}]} -> - manage_register(LocalVarL, AtomV, VarV), - % io:fwrite("[LOCAL] AtomV ~p VarV ~p~n", [AtomV, VarV]), - AccData; - %%% Evaluate a generic function - %%% Attention: don't change the position of this pattern matching branch - %%% TODO: implement argument list evaluation feature - {call, _, {atom, _, Name}, ArgList} -> - {V, _, NewL} = eval_codeline(ArgList, FunName, G, AccData, SetPm), - io:fwrite("[LOCAL] V ~p NewL ~p Name ~p~n", [V, NewL, FunName]), - NewG = - case db_manager:get_fun_graph(Name) of - no_graph_found -> eval_func(Name, [], SetPm); - G -> G - end, - db_manager:send_fun_graph(Name, NewG), - case NewG of - %%% If the function called is a built-in or a module function, - %%% then we don't have the Ast. Just return the last added vertex - no_graph -> AccData; - %%% If there's no error, then we have a graph, then we need to - %%% add the graph to the main graph - _ -> {LastRetVar, merge_graph(G, NewG, VLast), LocalVarL} - end; - %%% Evaluate a rand:uniform() function - {call, _, {remote, _, {atom, _, rand}, {atom, _, uniform}}, _ArgList} -> - {#variable{type = integer}, VLast, LocalVarL}; - %%% Evaluate an extern function - {call, _, {remote, _, {atom, _, _Package}, {atom, _, _Name}}, _ArgList} -> - %%% TODO: find the package and the function, create the local view of it - AccData; - %%% TODO: implementare passaggio di variabili - {call, _, {var, _, Name}, _ArgList} -> - VarFound = find_var(LocalVarL, Name), - {clauses, Ast} = VarFound#variable.value, - %% TODO: get returned var - NewG = get_localview(Name, Ast, LocalVarL, SetPm), - case NewG of - %%% If the function called is a built-in or a module function, - %%% then we don't have the Ast. Just return the last added vertex - no_graph -> AccData; - %%% If there's no error, then we have a graph, then we need to - %%% add the graph to the main graph - _ -> {LastRetVar, merge_graph(G, NewG, VLast), LocalVarL} - end; - %%% Evaluate Case and If - {'case', _, {var, _, Var}, PMList} -> - BaseLabel = get_base_label(SetPm, atol(Var) ++ " match "), - { - #variable{}, - eval_pm(PMList, G, VLast, LocalVarL, FunName, BaseLabel, SetPm), - LocalVarL - }; - {'case', _, _, PMList} -> - BaseLabel = get_base_label(SetPm, "match smt"), - { - #variable{}, - eval_pm(PMList, G, VLast, LocalVarL, FunName, BaseLabel, SetPm), - LocalVarL - }; - {'if', _, PMList} -> - BaseLabel = get_base_label(SetPm, "if "), - { - #variable{}, - eval_pm(PMList, G, VLast, LocalVarL, FunName, BaseLabel, SetPm), - LocalVarL - }; - %%% Evaluate Receive - {'receive', _, PMList} -> - { - #variable{}, - eval_pm(PMList, G, VLast, LocalVarL, FunName, "receive ", SetPm), - LocalVarL - }; - %%% Evaluate Send - {op, _, '!', {_, _, VarName}, DataSentAst} -> - {Var, _, NewL} = eval_codeline(DataSentAst, FunName, G, AccData, SetPm), - DataSent = recordvar_to_string(Var), - VNew = common_fun:add_vertex(G), - IsVar = common_fun:is_erlvar(VarName), - ProcSentTo = - case IsVar of - true -> - ArgL = - case db_manager:get_fun_args(FunName) of - no_fun_args_found -> []; - L -> L - end, - find_proc_in_varl(VarName, LocalVarL ++ ArgL); - false -> - RegList = db_manager:get_reg_entry(), - find_in_register(RegList, ltoa(VarName)) - end, - SLabel = - "send " ++ DataSent ++ " to " ++ - case ProcSentTo of - nomatch -> atol(VarName); - self -> atol(FunName); - "self" -> atol(FunName); - P -> atol(P) - end, - digraph:add_edge(G, VLast, VNew, SLabel), - {#variable{type = atom, value = DataSent}, VNew, NewL}; - %%% Evaluate Types - {'fun', _, Ast} -> - {#variable{type = function, value = Ast}, VLast, LocalVarL}; - {cons, _, HeadList, TailList} -> - {Var, _, _} = eval_codeline(HeadList, FunName, G, AccData, SetPm), - {VarList, _, _} = eval_codeline(TailList, FunName, G, AccData, SetPm), - NewVal = [Var] ++ VarList#variable.value, - {VarList#variable{value = NewVal}, VLast, LocalVarL}; - {integer, _, Val} -> - {#variable{type = integer, value = Val}, VLast, LocalVarL}; - {float, _, Val} -> - {#variable{type = float, value = Val}, VLast, LocalVarL}; - {string, _, Val} -> - {#variable{type = string, value = Val}, VLast, LocalVarL}; - {atom, _, Val} -> - {#variable{type = atom, value = Val}, VLast, LocalVarL}; - {tuple, _, TupleVal} -> - L = lists:foldl( - fun(I, A) -> - {V, _, _} = eval_codeline(I, FunName, G, AccData, SetPm), - A ++ [V] - end, - [], - TupleVal - ), - {#variable{type = tuple, value = L}, VLast, LocalVarL}; - {nil, _} -> - {#variable{type = list, value = []}, VLast, LocalVarL}; - {var, _, VarName} -> - %%% TODO:find var in argument vars - % ArgL = db_manager:get_fun_args(FunName), - VarF = find_var(LocalVarL, VarName), - case VarF of - not_found -> {#variable{name = VarName}, VLast, LocalVarL}; - _ -> {VarF, VLast, LocalVarL} - end; - _ -> - io:fwrite("WARNING: couldn't parse code line ~p~n", [CodeLine]), - AccData - end. - -%%% Find a process in a list of variables -find_proc_in_varl(_, []) -> - nomatch; -find_proc_in_varl(Name, [H | T]) -> - VarN = H#variable.name, - S = atol(H#variable.type), - case Name =:= VarN of - true -> string:prefix(S, "pid_"); - false -> find_proc_in_varl(Name, T) - end. - -%%% Convert a variable (record) to a string -recordvar_to_string(Var) -> - case Var#variable.type of - ?UNDEFINED -> - atol(Var#variable.name); - Type -> - SType = atol(Type), - case Var#variable.value of - ?UNDEFINED -> - SType; - Val -> - case SType of - "integer" -> integer_to_list(Val); - "float" -> io_lib:format("~.2f", [Val]); - "string" -> "[" ++ Val ++ "]"; - "atom" -> atol(Val); - "tuple" -> format_tuple(Val, fun recordvar_to_string/1); - "pid" -> "pid"; - _ -> SType - end - end - end. - -%%% Convert a tuple to a string -format_tuple(VarL, Fun) -> - L = lists:foldl(fun(I, A) -> A ++ "," ++ Fun(I) end, "", VarL), - [_ | Label] = L, - "{" ++ Label ++ "}". - -get_base_label(SetPm, Label) -> - case SetPm of - true -> Label; - false -> 'ɛ' - end. - -%%% Send the info for the register() function to the db manager -manage_register(LocalVarL, AtomName, VarName) -> - VarFound = find_var(LocalVarL, VarName), - case VarFound of - not_found -> - ?UNDEFINED; - V -> - IsPid = is_type_pid(V#variable.type), - Pid = get_pid_from_type(V#variable.type), - case IsPid of - false -> ?UNDEFINED; - true -> db_manager:add_reg_entry({AtomName, Pid}) - end - end. - -%%% Find variable by Name in a list -find_var([], _) -> - not_found; -find_var([Var | Tail], Name) -> - Cond = Var#variable.name =:= Name, - case Cond of - true -> Var; - false -> find_var(Tail, Name) - end. - -%%% If the input is a string with "pid" in it returns true, otherwise false. -is_type_pid(Type) -> - SL = atol(Type), - IsPid = string:find(SL, "pid"), - is_list(IsPid). - -%%% Remove "pid_" from a string -get_pid_from_type(Type) -> - SL = atol(Type), - string:prefix(SL, "pid_"). - -%%% Find a registered atom in a list -find_in_register([], _) -> - nomatch; -find_in_register([{RegAtom, RegPid} | T], Name) -> - case RegAtom =:= Name of - true -> RegPid; - false -> find_in_register(T, Name) - end. - -%%% We have a main graph G1, a graph G2 and a G1's vertex. -%%% We need to append G2 to the G1's vertex. -%%% Firstly, we add to G1 as many vertex as G2's vertex number. -%%% With a map, we associate every vertex of G2 to one of the new G1'vertex -%%% Secondly, we collect each G2's edge info and then we rebuild it in G1 using the previous map -merge_graph(MainG, GToAdd, VLast) -> - VertexGToAdd = digraph:vertices(GToAdd), - % Add a number of vertex equal to VertexGToAdd - VEquiMap = lists:foldl( - %%% With this function we add a vertex and we associate it with G2's vertex - fun(Item, M) -> maps:put(Item, common_fun:add_vertex(MainG), M) end, - maps:new(), - VertexGToAdd - ), - % link the first new state created to the main graph - digraph:add_edge(MainG, VLast, maps:get(1, VEquiMap), 'ɛ'), - % Add all the edges - EdgesGToAdd = digraph:edges(GToAdd), - lists:foreach( - fun(Item) -> - {Item, V1, V2, Label} = digraph:edge(GToAdd, Item), - %%% We use the map to rebuild the exact same edge but in G1 - digraph:add_edge(MainG, maps:get(V1, VEquiMap), maps:get(V2, VEquiMap), Label) - end, - EdgesGToAdd - ), - % return last added vertex, which is the max number in the key list - maps:get(lists:max(maps:keys(VEquiMap)), VEquiMap). - -%%% Returns an FSA graph of the function if the ast exist, otherwise return error. -eval_func(FuncName, LocalVar, SetPm) -> - FunAst = db_manager:get_fun_ast(FuncName), - case FunAst of - no_ast_found -> no_graph; - %%% get the graph but don't set the final state - _ -> get_localview(FuncName, FunAst, LocalVar, SetPm) - end. - -%%% Evaluate Pattern Matching's list of clauses: evaluate every branch alone, then -%%% link every last vertex's branch to a shared vertex with epsilon transaction -eval_pm(PMList, G, VLast, LocalVarL, FunName, Label, SetPm) -> - VLastList = explore_pm(PMList, G, VLast, LocalVarL, FunName, Label, SetPm), - VRet = common_fun:add_vertex(G), - add_edges_recursive(G, VLastList, VRet, 'ɛ', VLast), - VRet. - -%%% Explore every pm's branch and returns the list of last added vertex -explore_pm(PMList, G, VLast, LocalVarL, FunName, Base, SetPm) -> - lists:foldl( - fun(CodeLine, AddedVertexList) -> - case CodeLine of - {clause, _, Vars, Guard, Content} -> - V = common_fun:add_vertex(G), - digraph:add_edge(G, VLast, V, 'ɛ'), - IsReceive = is_list(string:find(atol(Base), "receive")), - %%% if it's a receive pm, then the label must be written - EdLabel = format_label_pm_edge(IsReceive or SetPm, Vars, Guard, atol(Base)), - VL = - case IsReceive or SetPm of - true -> - VNew = common_fun:add_vertex(G), - digraph:add_edge(G, V, VNew, EdLabel), - VNew; - false -> - V - end, - VRet = eval_pm_clause(Content, FunName, G, VL, LocalVarL, SetPm), - AddedVertexList ++ [VRet]; - _ -> - AddedVertexList - end - end, - [], - PMList - ). - -%%% Format the Variables with the guards in a label for the FSA -format_label_pm_edge(SetPm, VarList, GuardList, BaseLabel) when is_list(BaseLabel) -> - case SetPm of - true -> - VarsS = lists:foldl(fun(V, Acc) -> astvar_to_s(V, Acc) ++ ", " end, BaseLabel, VarList), - VarGuardS = lists:foldl(fun(G, Acc) -> guards_to_s(G, Acc) end, VarsS, GuardList), - remove_last(remove_last(VarGuardS)); - false -> - 'ɛ' - end. - -%%% Remove the last element froom a list -remove_last(List) when is_list(List) -> - {Rest, _} = lists:split(length(List) - 1, List), - Rest. - -%%% Convert a data type (ast format) to a string -astvar_to_s(VarToVal) -> - astvar_to_s(VarToVal, ""). -astvar_to_s(VarToVal, BaseL) -> - BaseL ++ - case VarToVal of - %% TODO: espandere o fare refactor di sta parte - {integer, _, Value} -> integer_to_list(Value); - {var, _, '_'} -> "_"; - {tuple, _, LVar} -> format_tuple(LVar, fun astvar_to_s/1); - {var, _, Var} -> atol(Var); - {atom, _, Atom} -> atol(Atom); - {cons, _, H, T} -> "[" ++ astvar_to_s(H) ++ ", " ++ astvar_to_s(T) ++ "]"; - {nil, _} -> "null"; - _ -> atol(?UNDEFINED) - end. - -%%% Convert the guard (ast format) to a string -guards_to_s(GlobalToVal, BaseL) -> - case GlobalToVal of - %%% Add guards if there's a guard - %%% TODO: add more infos - {op, _, _, _} -> BaseL ++ " (guards)"; - _ -> BaseL - end. - -%%% Link each vertex of a vertex's list to a given vertex, with a defined label -add_edges_recursive(G, VertexList, VertexToLink, Label, Except) -> - %%% Link every V in the VertexList to the VertexToLink, with a specified label - [ - digraph:add_edge(G, V, VertexToLink, Label) - || V <- VertexList, - %%% exclude the start vertex - V =/= 1, - V =/= Except - ]. - -%%% Set vertices as a final state if they do not have out edges -set_final(Graph) -> - VL = digraph:vertices(Graph), - lists:foreach( - fun(Vertex) -> - OD = digraph:out_degree(Graph, Vertex), - {_, Label} = digraph:vertex(Graph, Vertex), - case OD =:= 0 of - true -> - FormattedLabel = ?FINALTAG ++ integer_to_list(Label), - digraph:add_vertex(Graph, Vertex, FormattedLabel); - false -> - do_nothing - end - end, - VL - ). - -ltoa(L) when is_list(L) -> list_to_atom(L); -ltoa(L) when is_atom(L) -> L. -atol(A) when is_atom(A) -> atom_to_list(A); -atol(A) when is_list(A) -> A. diff --git a/src/choreography/lv.erl b/src/choreography/lv.erl index 0f58836..6b9544c 100644 --- a/src/choreography/lv.erl +++ b/src/choreography/lv.erl @@ -25,7 +25,7 @@ create_save_localview(ActorName, Settings) -> not_found -> io:fwrite("Error: Actor ~p's AST not found~n", [ActorName]); _ -> - % io:fwrite("[LV] ~p~n", [ActorName]), + % io:fwrite("[LV] Creating a localview for ~p~n", [ActorName]), LocalViewData = check_and_get_lv(ActorName, ActorAst, [], Settings), G = LocalViewData#wip_lv.graph, set_final(G), @@ -73,7 +73,7 @@ eval_codeline(CodeLine, Data) -> if is_tuple(CodeLine) -> Line = element(2, CodeLine), - % io:fwrite("evaluating ~p on line ~p~n", [element(1, CodeLine), Line]), + % io:fwrite("Evaluating ~p on line ~p~n", [element(1, CodeLine), Line]), ets:insert(?CLINE, {line, Line}); true -> done @@ -110,11 +110,10 @@ eval_pm_clause(Code, Vars, Data) -> LocalV = Data#wip_lv.local_vars, FunName = ltoa(Data#wip_lv.fun_name), Exist = ets:lookup(?ARGUMENTS, FunName), - % io:fwrite("Per ~p salvo ~p esiste ~p~n", [FunName, Vars, Exist]), + % io:fwrite("Per ~ps salvo ~p esiste ~p~n", [FunName, Vars, Exist]), case Exist of [] -> ets:insert(?ARGUMENTS, {FunName, Vars}); [{_, []}] -> ets:insert(?ARGUMENTS, {FunName, Vars}); - %io:fwrite("Esiste già~n") [{_, [_]}] -> done end, ND = @@ -143,27 +142,56 @@ eval_pm_clause(Code, Vars, Data) -> eval_match(RightContent, LeftContent, Data) -> case RightContent of - {var, _, VarName} -> - NewData = eval_codeline(LeftContent, Data), - Var = NewData#wip_lv.ret_var, - L = NewData#wip_lv.local_vars, - NewVarEntry = Var#variable{name = VarName}, - NewData#wip_lv{ret_var = NewVarEntry, local_vars = L ++ [NewVarEntry]}; - %%% TODO: eval pattern matching - R -> - warning("couldn't understand line", R, Data) + {var, _, VarName} -> eval_match_with_var(VarName, LeftContent, Data); + {tuple, _, VarList} -> eval_match_with_tuple(VarList, LeftContent, Data); + {cons, _, List} -> eval_match_with_list(List, Data); + R -> warning("[MATCH] couldn't understand line", R, Data) end. +eval_match_with_var(VarName, LeftContent, Data) -> + NewData = eval_codeline(LeftContent, Data), + Var = NewData#wip_lv.ret_var, + L = NewData#wip_lv.local_vars, + NewVarEntry = Var#variable{name = VarName}, + NewData#wip_lv{ret_var = NewVarEntry, local_vars = L ++ [NewVarEntry]}. + +eval_match_with_tuple(VarList, LeftContent, Data) -> + NewData = eval_codeline(LeftContent, Data), + Var = NewData#wip_lv.ret_var, + % not sure to use newdata + L = NewData#wip_lv.local_vars, + case Var#variable.type of + tuple -> + {TupleListWithNames, _} = + lists:foldl( + fun(Item, {AccL, [H | T]}) -> + {var, _, VarName} = H, + {AccL ++ [Item#variable{name = VarName}], T} + end, + {L, VarList}, + Var#variable.value + ), + NewData#wip_lv{ + ret_var = #variable{type = tuple, value = TupleListWithNames}, + local_vars = L ++ TupleListWithNames + }; + _ -> + RetVar = lists:foldl(fun(I, A) -> A ++ [#variable{name = I}] end, [], VarList), + ND = NewData#wip_lv{ + ret_var = #variable{type = tuple, value = RetVar}, + local_vars = L ++ RetVar + }, + warning("right content is a tuple but left content is", Var, ND) + end. + +eval_match_with_list(List, Data) -> warning("[MATCH] working in progress", List, Data). + eval_call(Function, ArgList, Data) -> case Function of - {atom, _, Name} -> - eval_call_by_atom(Name, ArgList, Data); - {var, _, VarName} -> - eval_call_by_var(VarName, ArgList, Data); - {remote, _, {atom, _, Package}, {atom, _, FunName}} -> - eval_call_by_package(Package, FunName, ArgList, Data); - F -> - warning("couldn't call function pattern", F, Data) + {atom, _, Name} -> eval_call_by_atom(Name, ArgList, Data); + {var, _, VarName} -> eval_call_by_var(VarName, ArgList, Data); + {remote, _, Package, FunName} -> eval_call_by_package(Package, FunName, ArgList, Data); + F -> warning("couldn't call function pattern", F, Data) end. eval_call_by_atom(Name, ArgList, Data) -> @@ -171,9 +199,10 @@ eval_call_by_atom(Name, ArgList, Data) -> case Name of FunName -> eval_recursive(ArgList, Data); spawn -> eval_spawn(ArgList, Data); + spawn_monitor -> eval_spawn_monitor(ArgList, Data); self -> eval_self(Data); register -> eval_register(ArgList, Data); - Name -> eval_generic_call(ArgList, Name, Data) + _ -> eval_generic_call(Name, ArgList, Data) end. %%% Dubbio: In questo caso bisogna ritornare i Data così come sono o bisogna impostare il last_vertex all'1? @@ -220,6 +249,8 @@ eval_spawn_three(Name, ArgList, Data) -> RetVar = #variable{type = pid, value = S}, ND#wip_lv{ret_var = RetVar, last_vertex = VNew}. +eval_spawn_monitor(ArgList, Data) -> warning("spawn_monitor not yet implemted. Arguments =", ArgList, Data). + inc_spawn_counter(Name) -> case ets:lookup(?SPAWNC, ltoa(Name)) of [] -> @@ -249,13 +280,13 @@ eval_register(ArgList, Data) -> %%% Approx: ignoring returing value Data. -eval_generic_call(ArgList, Name, Data) -> +eval_generic_call(Name, ArgList, Data) -> % io:fwrite("ARG LIST ~p~n", [ArgList]), NewData = eval_codeline(ArgList, Data), % io:fwrite("RET VAR ~p~n", [NewData#wip_lv.ret_var#variable.value]), case eval_func(Name, NewData#wip_lv.ret_var#variable.value) of no_graph -> - Data; + warning("couldn't parse function", Name, Data#wip_lv{ret_var = #variable{}}); NewD -> G = Data#wip_lv.graph, LastV = Data#wip_lv.last_vertex, @@ -285,10 +316,12 @@ eval_call_by_var(VarName, ArgList, Data) -> end. eval_call_by_package(Package, FunName, _ArgList, Data) -> - case Package of - rand -> eval_rand_package(FunName, Data); + {atom, _, Pack} = Package, + {atom, _, Name} = FunName, + case Pack of + rand -> eval_rand_package(Name, Data); %%% TODO: find the package and the function, create the local view of it, attach it to the current lv - _ -> warning("package not yet implemented:", Package, Data) + _ -> warning("package not yet implemented:", Pack, Data) end. eval_rand_package(FunName, Data) -> diff --git a/src/choreography/metadata.erl b/src/choreography/metadata.erl deleted file mode 100644 index 34fa4f0..0000000 --- a/src/choreography/metadata.erl +++ /dev/null @@ -1,147 +0,0 @@ --module(metadata). --include("../share/common_data.hrl"). - -%%% API --export([extract/2]). - -%%%=================================================================== -%%% API -%%%=================================================================== - -%%% Extract the metada, that is the Abstract Syntax Tree's file (AST), the -%%% Actor List and the AST of every functions. Send them to the DBMANAGER. -extract(InputFile, EntryPoint) -> - gen_ast(InputFile), - ActorList = gen_fun_ast_and_exported(), - %%% Send the actor list to the dbmanager - db_manager:send_actor_list(ActorList), - gen_spawned_names_and_args(EntryPoint), - db_manager:reset_spawn_counter(). - -%%%=================================================================== -%%% Internal Functions -%%%=================================================================== - -%%% Use of epp_dodger:quick_parse_file to generete the Abstract Syntax Tree -%%% of the InputFile and send it to the dbmanager --spec gen_ast(InputFile) -> atom() when - InputFile :: string(). -gen_ast(InputFile) -> - {ok, AST} = epp_dodger:quick_parse_file(InputFile), - db_manager:send_ast(AST), - done. - -%%% Generate the list of exported function and send it to the dbmanager. -%%% It also send the ast of every function. --spec gen_fun_ast_and_exported() -> [string()]. -gen_fun_ast_and_exported() -> - Ast = db_manager:get_ast(), - lists:foldl( - fun(CodeLine, AccList) -> - case CodeLine of - {attribute, _, export, AtrList} -> - AccList ++ [Name || {Name, _NArgs} <- AtrList]; - {function, _, Name, _NArgs, FunAst} -> - db_manager:send_fun_ast(Name, FunAst), - AccList; - _ -> - AccList - end - end, - [], - Ast - ). - -new_spawned_proc(Name, FunName, ArgC, ArgL) -> - #spawned_proc{ - name = Name, - called_where = FunName, - args_called = ArgC, - args_local = ArgL - }. - -gen_spawned_names_and_args(EntryPoint) when is_atom(EntryPoint) -> - L = gen_spawned_names_and_args(EntryPoint, ?UNDEFINED, true), - db_manager:send_spawn_info(L). - -%%% Get all the spawned function and the arguments passed to it. -gen_spawned_names_and_args(EntryPoint, CalledArgs, CreateEntry) when is_atom(EntryPoint) -> - Ast = db_manager:get_fun_ast(EntryPoint), - case Ast of - no_func_found -> - []; - _ -> - ListOfSpawn = get_spawned_loop(Ast, EntryPoint), - Vars = get_clause_vars(EntryPoint), - NewVal = #spawned_proc{name = EntryPoint, args_called = CalledArgs, args_local = Vars}, - case CreateEntry of - true -> [NewVal] ++ ListOfSpawn; - false -> ListOfSpawn - end - end. - -%%% Extract the variables from a clause statement (ast format) -get_clause_vars(FunName) -> - Ast = db_manager:get_fun_ast(FunName), - [{clause, _, Vars, _, _} | _] = Ast, - Vars. - -%%% Find every spawn -get_spawned_loop(Code, FunName) when is_list(Code) -> - lists:foldl( - fun(Line, A) -> - A ++ - case Line of - %%% Evaluate recursively statement with possible spawn in it - {clause, _, _, _, Content} -> - get_spawned_loop(Content, FunName); - {match, _, {var, _, VarName}, {'fun', _, {clauses, FunAst}}} -> - db_manager:send_fun_ast(VarName, FunAst), - case is_list(FunAst) of - true -> get_spawned_loop(FunAst, FunName); - false -> get_spawned_loop([FunAst], FunName) - end; - {match, _, _, LeftContent} -> - case is_list(LeftContent) of - true -> get_spawned_loop(LeftContent, FunName); - false -> get_spawned_loop([LeftContent], FunName) - end; - {'case', _, _, PMList} -> - get_spawned_loop(PMList, FunName); - {'if', _, PMList} -> - get_spawned_loop(PMList, FunName); - {'receive', _, PMList} -> - get_spawned_loop(PMList, FunName); - {op, _, '!', DataSentAst} -> - get_spawned_loop([DataSentAst], FunName); - %%% When a spawn is found, send the data to the db manager - {call, _, {atom, _, spawn}, [{var, _, Name}]} -> - ActorList = db_manager:get_actors(), - db_manager:send_actor_list(ActorList ++ [Name]), - C = db_manager:inc_spawn_counter(Name), - FName = list_to_atom(atom_to_list(Name) ++ "_" ++ integer_to_list(C)), - % TODO: come evitare loop infiniti? - FAst = db_manager:get_fun_ast(Name), - L = get_spawned_loop(FAst, Name), - [new_spawned_proc(FName, FunName, {}, {})] ++ L; - {call, _, {atom, _, spawn}, [_, {atom, _, Name}, ArgList]} -> - ArgVars = get_clause_vars(Name), - C = db_manager:inc_spawn_counter(Name), - FName = list_to_atom(atom_to_list(Name) ++ "_" ++ integer_to_list(C)), - % TODO: come evitare loop infiniti? - FAst = db_manager:get_fun_ast(Name), - L = get_spawned_loop(FAst, Name), - [new_spawned_proc(FName, FunName, ArgList, ArgVars)] ++ L; - %%% Attention: do not change position of this case branch - {call, _, {atom, _, FunName}, _} -> - []; - %%% Generic function call - {call, _, {atom, _, Name}, ArgL} -> - gen_spawned_names_and_args(Name, ArgL, false); - _ -> - [] - end - end, - [], - Code - ). From 1bd0ea46cd9608112f2da3807d7af9ece7e69e12 Mon Sep 17 00:00:00 2001 From: geno Date: Thu, 15 Feb 2024 12:21:55 +0100 Subject: [PATCH 07/11] fix: bug in recordvar_to_string --- examples/airline/main_global_view.dot | 18 ++--- examples/airline/main_local_view.dot | 2 +- examples/async/dummy1_local_view.dot | 2 +- examples/async/dummy2_local_view.dot | 2 +- examples/async/main_global_view.dot | 6 +- examples/async/main_local_view.dot | 2 +- .../conditional-case/dummy_local_view.dot | 8 +- .../conditional-case/main_global_view.dot | 55 ++++++++++---- examples/conditional-case/main_local_view.dot | 31 ++++---- examples/customer/customer_local_view.dot | 6 +- examples/customer/main_global_view.dot | 10 +-- examples/customer/store_local_view.dot | 6 +- .../for-loop-recursion/main_global_view.dot | 25 +++--- .../for-loop-recursion/main_local_view.dot | 10 +-- examples/function-call/dummy_local_view.dot | 4 +- examples/function-call/main_global_view.dot | 6 +- examples/function-call/main_local_view.dot | 4 +- examples/hello/greet_local_view.dot | 2 +- examples/high-order-fun/greet_global_view.dot | 4 +- examples/high-order-fun/greet_local_view.dot | 2 +- examples/if-cases/a_local_view.dot | 6 +- examples/if-cases/b_local_view.dot | 8 +- examples/if-cases/c_local_view.dot | 6 +- examples/if-cases/main_global_view.dot | 76 +++++++++++++++++-- examples/if-cases/main_local_view.dot | 28 +++---- examples/serverclient/client_local_view.dot | 4 +- .../serverclient/handle_req_local_view.dot | 2 +- examples/serverclient/main_global_view.dot | 8 +- examples/serverclient/server_local_view.dot | 6 +- examples/test/barber/test_local_view.dot | 19 +++++ examples/test/foo1/b_local_view.dot | 8 +- examples/test/foo1/c_local_view.dot | 10 +-- examples/test/foo1/test_global_view.dot | 24 +++--- examples/test/foo1/test_local_view.dot | 20 ++--- examples/test/foo2/b_local_view.dot | 2 +- examples/test/foo2/c_local_view.dot | 2 +- examples/test/foo2/test_global_view.dot | 2 +- examples/test/foo2/test_local_view.dot | 2 +- examples/test/foo3/a_local_view.dot | 10 +-- examples/test/foo3/b_local_view.dot | 8 +- examples/test/foo3/test_global_view.dot | 42 ++++++++-- examples/test/foo3/test_local_view.dot | 24 +++--- examples/test/foo4/r_local_view.dot | 16 ++-- examples/test/foo4/test_global_view.dot | 72 +++++++++--------- examples/test/foo4/test_local_view.dot | 24 +++--- examples/test/foo4/w1_local_view.dot | 10 +-- examples/test/foo4/w2_local_view.dot | 10 +-- examples/test/foo5/proxy_local_view.dot | 10 +-- examples/test/foo5/target_local_view.dot | 20 ++--- examples/test/foo5/test_global_view.dot | 24 +++--- examples/test/foo5/test_local_view.dot | 32 ++++---- examples/test/ping/ping_local_view.dot | 8 +- examples/test/ping/pong_local_view.dot | 10 +-- examples/test/ping/start_local_view.dot | 22 +++--- examples/ticktackloop/start_global_view.dot | 16 ++++ examples/ticktackloop/start_local_view.dot | 13 ++++ examples/ticktackloop/tac_loop_local_view.dot | 14 ++++ examples/ticktackloop/tic_loop_local_view.dot | 14 ++++ .../{ticktack => ticktackloop}/tictacloop.erl | 0 .../random_local_view.dot | 0 .../start_global_view.dot | 16 ++-- .../start_local_view.dot | 4 +- .../tac_loop_local_view.dot | 4 +- .../tic_loop_local_view.dot | 0 .../{ticktack => ticktackstop}/tictacstop.erl | 0 examples/trick/a_local_view.dot | 2 +- examples/trick/b_local_view.dot | 2 +- examples/trick/c_local_view.dot | 2 +- examples/trick/main_global_view.dot | 8 +- examples/trick/main_local_view.dot | 2 +- src/choreography/lv.erl | 6 +- test.sh | 17 ++++- 72 files changed, 555 insertions(+), 345 deletions(-) create mode 100644 examples/test/barber/test_local_view.dot create mode 100644 examples/ticktackloop/start_global_view.dot create mode 100644 examples/ticktackloop/start_local_view.dot create mode 100644 examples/ticktackloop/tac_loop_local_view.dot create mode 100644 examples/ticktackloop/tic_loop_local_view.dot rename examples/{ticktack => ticktackloop}/tictacloop.erl (100%) rename examples/{ticktack => ticktackstop}/random_local_view.dot (100%) rename examples/{ticktack => ticktackstop}/start_global_view.dot (100%) rename examples/{ticktack => ticktackstop}/start_local_view.dot (100%) rename examples/{ticktack => ticktackstop}/tac_loop_local_view.dot (100%) rename examples/{ticktack => ticktackstop}/tic_loop_local_view.dot (100%) rename examples/{ticktack => ticktackstop}/tictacstop.erl (100%) diff --git a/examples/airline/main_global_view.dot b/examples/airline/main_global_view.dot index b896585..a678dd4 100644 --- a/examples/airline/main_global_view.dot +++ b/examples/airline/main_global_view.dot @@ -10,18 +10,18 @@ digraph global { n_6 [id="7", shape=circle, label="7"]; n_7 [id="3", shape=circle, label="3"]; - n_1 -> n_7 [id="[$e|7]", label="main→agent_1:{booked,3}"]; - n_7 -> n_1 [id="[$e|13]", label="main→agent_0:{booked,3}"]; - n_3 -> n_4 [id="[$e|0]", label="mainΔagent_0"]; + n_7 -> n_5 [id="[$e|2]", label="agent_0→main:{sell,pid_self}"]; n_4 -> n_7 [id="[$e|1]", label="mainΔagent_1"]; - n_7 -> n_5 [id="[$e|12]", label="main→agent_1:{booked,3}"]; + n_2 -> n_7 [id="[$e|8]", label="main→agent_0:{booked,3}"]; + n_1 -> n_7 [id="[$e|7]", label="main→agent_1:{booked,3}"]; n_5 -> n_2 [id="[$e|4]", label="agent_1→main:{sell,pid_self}"]; - n_7 -> n_5 [id="[$e|2]", label="agent_0→main:{sell,pid_self}"]; - n_2 -> n_5 [id="[$e|9]", label="main→agent_1:{booked,3}"]; n_6 -> n_7 [id="[$e|11]", label="main→agent_1:{booked,3}"]; - n_2 -> n_7 [id="[$e|8]", label="main→agent_0:{booked,3}"]; - n_7 -> n_1 [id="[$e|3]", label="agent_1→main:{sell,pid_self}"]; - n_1 -> n_6 [id="[$e|6]", label="agent_0→main:{sell,pid_self}"]; n_5 -> n_7 [id="[$e|5]", label="main→agent_0:{booked,3}"]; + n_7 -> n_1 [id="[$e|13]", label="main→agent_0:{booked,3}"]; n_6 -> n_1 [id="[$e|10]", label="main→agent_0:{booked,3}"]; + n_2 -> n_5 [id="[$e|9]", label="main→agent_1:{booked,3}"]; + n_7 -> n_5 [id="[$e|12]", label="main→agent_1:{booked,3}"]; + n_7 -> n_1 [id="[$e|3]", label="agent_1→main:{sell,pid_self}"]; + n_3 -> n_4 [id="[$e|0]", label="mainΔagent_0"]; + n_1 -> n_6 [id="[$e|6]", label="agent_0→main:{sell,pid_self}"]; } diff --git a/examples/airline/main_local_view.dot b/examples/airline/main_local_view.dot index 833b5fe..98070fc 100644 --- a/examples/airline/main_local_view.dot +++ b/examples/airline/main_local_view.dot @@ -7,8 +7,8 @@ digraph main { n_3 [id="4", shape=circle, label="4"]; n_4 [id="3", shape=circle, label="2"]; + n_1 -> n_4 [id="[$e|2]", label="spawn agent_0"]; n_3 -> n_2 [id="[$e|1]", label="send {booked,3} to Pid1"]; n_2 -> n_3 [id="[$e|4]", label="receive {sell,Pid1}"]; - n_1 -> n_4 [id="[$e|2]", label="spawn agent_0"]; n_4 -> n_2 [id="[$e|5]", label="spawn agent_1"]; } diff --git a/examples/async/dummy1_local_view.dot b/examples/async/dummy1_local_view.dot index 6e10ff8..3e56cec 100644 --- a/examples/async/dummy1_local_view.dot +++ b/examples/async/dummy1_local_view.dot @@ -6,6 +6,6 @@ digraph dummy1 { n_2 [id="2", shape=doublecircle, label="3"]; n_3 [id="3", shape=circle, label="2"]; - n_1 -> n_3 [id="[$e|0]", label="send bello to dummy2_0"]; n_3 -> n_2 [id="[$e|1]", label="receive ciao"]; + n_1 -> n_3 [id="[$e|0]", label="send bello to dummy2_0"]; } diff --git a/examples/async/dummy2_local_view.dot b/examples/async/dummy2_local_view.dot index 660c639..f3c5f58 100644 --- a/examples/async/dummy2_local_view.dot +++ b/examples/async/dummy2_local_view.dot @@ -6,6 +6,6 @@ digraph dummy2 { n_2 [id="2", shape=doublecircle, label="3"]; n_3 [id="3", shape=circle, label="2"]; - n_1 -> n_3 [id="[$e|0]", label="send ciao to dummy1_0"]; n_3 -> n_2 [id="[$e|1]", label="receive bello"]; + n_1 -> n_3 [id="[$e|0]", label="send ciao to dummy1_0"]; } diff --git a/examples/async/main_global_view.dot b/examples/async/main_global_view.dot index f8db0ed..6d011f2 100644 --- a/examples/async/main_global_view.dot +++ b/examples/async/main_global_view.dot @@ -10,10 +10,10 @@ digraph global { n_6 [id="7", shape=circle, label="7"]; n_7 [id="3", shape=circle, label="3"]; - n_3 -> n_4 [id="[$e|0]", label="mainΔdummy1_0"]; + n_7 -> n_5 [id="[$e|2]", label="dummy2_0→dummy1_0:ciao"]; n_4 -> n_7 [id="[$e|1]", label="mainΔdummy2_0"]; n_5 -> n_2 [id="[$e|4]", label="dummy1_0→dummy2_0:bello"]; - n_7 -> n_5 [id="[$e|2]", label="dummy2_0→dummy1_0:ciao"]; - n_7 -> n_1 [id="[$e|3]", label="dummy1_0→dummy2_0:bello"]; n_1 -> n_6 [id="[$e|5]", label="dummy2_0→dummy1_0:ciao"]; + n_7 -> n_1 [id="[$e|3]", label="dummy1_0→dummy2_0:bello"]; + n_3 -> n_4 [id="[$e|0]", label="mainΔdummy1_0"]; } diff --git a/examples/async/main_local_view.dot b/examples/async/main_local_view.dot index 4a7b843..eb45845 100644 --- a/examples/async/main_local_view.dot +++ b/examples/async/main_local_view.dot @@ -6,6 +6,6 @@ digraph main { n_2 [id="2", shape=circle, label="2"]; n_3 [id="3", shape=doublecircle, label="3"]; - n_2 -> n_3 [id="[$e|0]", label="spawn dummy2_0"]; n_1 -> n_2 [id="[$e|1]", label="spawn dummy1_0"]; + n_2 -> n_3 [id="[$e|0]", label="spawn dummy2_0"]; } diff --git a/examples/conditional-case/dummy_local_view.dot b/examples/conditional-case/dummy_local_view.dot index 75e85bf..5db7e33 100644 --- a/examples/conditional-case/dummy_local_view.dot +++ b/examples/conditional-case/dummy_local_view.dot @@ -3,9 +3,9 @@ digraph dummy { n_0 [label="dummy", shape="plaintext"]; n_1 [id="1", shape=circle, label="1"]; n_0 -> n_1 [arrowhead=none]; - n_2 [id="2", shape=circle, label="2"]; - n_3 [id="3", shape=doublecircle, label="3"]; + n_2 [id="2", shape=doublecircle, label="3"]; + n_3 [id="3", shape=circle, label="2"]; - n_1 -> n_2 [id="[$e|0]", label="send {pid_self,integer} to Pid"]; - n_2 -> n_3 [id="[$e|1]", label="receive Str"]; + n_3 -> n_2 [id="[$e|0]", label="receive Str"]; + n_1 -> n_3 [id="[$e|1]", label="send {pid_self,integer} to Pid"]; } diff --git a/examples/conditional-case/main_global_view.dot b/examples/conditional-case/main_global_view.dot index f78199e..68076ec 100644 --- a/examples/conditional-case/main_global_view.dot +++ b/examples/conditional-case/main_global_view.dot @@ -1,18 +1,47 @@ digraph global { rankdir="LR"; n_0 [label="global", shape="plaintext"]; - n_1 [id="5", shape=circle, label="5"]; - n_2 [id="1", shape=circle, label="1"]; - n_0 -> n_2 [arrowhead=none]; - n_3 [id="9", shape=circle, label="9"]; - n_4 [id="2", shape=circle, label="2"]; - n_5 [id="4", shape=circle, label="4"]; - n_6 [id="3", shape=circle, label="3"]; + n_1 [id="20", shape=circle, label="20"]; + n_2 [id="5", shape=circle, label="5"]; + n_3 [id="15", shape=circle, label="15"]; + n_4 [id="19", shape=circle, label="19"]; + n_5 [id="12", shape=circle, label="12"]; + n_6 [id="11", shape=circle, label="11"]; + n_7 [id="17", shape=circle, label="17"]; + n_8 [id="18", shape=circle, label="18"]; + n_9 [id="14", shape=circle, label="14"]; + n_10 [id="6", shape=circle, label="6"]; + n_11 [id="13", shape=circle, label="13"]; + n_12 [id="10", shape=circle, label="10"]; + n_13 [id="1", shape=circle, label="1"]; + n_0 -> n_13 [arrowhead=none]; + n_14 [id="9", shape=circle, label="9"]; + n_15 [id="2", shape=circle, label="2"]; + n_16 [id="21", shape=circle, label="21"]; + n_17 [id="8", shape=circle, label="8"]; + n_18 [id="4", shape=circle, label="4"]; + n_19 [id="7", shape=circle, label="7"]; + n_20 [id="3", shape=circle, label="3"]; + n_21 [id="16", shape=circle, label="16"]; - n_4 -> n_6 [id="[$e|2]", label="mainΔdummy_1"]; - n_2 -> n_4 [id="[$e|1]", label="mainΔdummy_0"]; - n_3 -> n_5 [id="[$e|7]", label="mainΔdummy_3"]; - n_6 -> n_3 [id="[$e|6]", label="mainΔdummy_2"]; - n_5 -> n_1 [id="[$e|4]", label="dummy_1→main:{pid_self,integer}"]; - n_5 -> n_1 [id="[$e|8]", label="dummy_3→main:{pid_self,integer}"]; + n_2 -> n_19 [id="[$e|5]", label="dummy_1→main:{pid_self,integer}"]; + n_14 -> n_1 [id="[$e|18]", label="dummy_1→main:{pid_self,integer}"]; + n_13 -> n_15 [id="[$e|0]", label="mainΔdummy_0"]; + n_18 -> n_2 [id="[$e|3]", label="mainΔdummy_3"]; + n_2 -> n_17 [id="[$e|6]", label="dummy_2→main:{pid_self,integer}"]; + n_10 -> n_5 [id="[$e|10]", label="dummy_3→main:{pid_self,integer}"]; + n_19 -> n_9 [id="[$e|12]", label="dummy_2→main:{pid_self,integer}"]; + n_10 -> n_12 [id="[$e|8]", label="dummy_1→main:{pid_self,integer}"]; + n_10 -> n_6 [id="[$e|9]", label="dummy_2→main:{pid_self,integer}"]; + n_15 -> n_20 [id="[$e|1]", label="mainΔdummy_1"]; + n_2 -> n_10 [id="[$e|4]", label="dummy_0→main:{pid_self,integer}"]; + n_17 -> n_8 [id="[$e|16]", label="dummy_3→main:{pid_self,integer}"]; + n_20 -> n_18 [id="[$e|2]", label="mainΔdummy_2"]; + n_17 -> n_7 [id="[$e|15]", label="dummy_1→main:{pid_self,integer}"]; + n_14 -> n_4 [id="[$e|17]", label="dummy_0→main:{pid_self,integer}"]; + n_19 -> n_11 [id="[$e|11]", label="dummy_0→main:{pid_self,integer}"]; + n_19 -> n_3 [id="[$e|13]", label="dummy_3→main:{pid_self,integer}"]; + n_2 -> n_14 [id="[$e|7]", label="dummy_3→main:{pid_self,integer}"]; + n_17 -> n_21 [id="[$e|14]", label="dummy_0→main:{pid_self,integer}"]; + n_14 -> n_16 [id="[$e|19]", label="dummy_2→main:{pid_self,integer}"]; } diff --git a/examples/conditional-case/main_local_view.dot b/examples/conditional-case/main_local_view.dot index e210073..b0950dc 100644 --- a/examples/conditional-case/main_local_view.dot +++ b/examples/conditional-case/main_local_view.dot @@ -1,23 +1,24 @@ digraph main { rankdir="LR"; n_0 [label="main", shape="plaintext"]; - n_1 [id="5", shape=circle, label="5"]; - n_2 [id="6", shape=circle, label="6"]; - n_3 [id="10", shape=circle, label="10"]; + n_1 [id="5", shape=doublecircle, label="8"]; + n_2 [id="6", shape=circle, label="5"]; + n_3 [id="10", shape=circle, label="4"]; n_4 [id="1", shape=circle, label="1"]; n_0 -> n_4 [arrowhead=none]; n_5 [id="2", shape=circle, label="2"]; - n_6 [id="8", shape=circle, label="8"]; - n_7 [id="7", shape=doublecircle, label="7"]; - n_8 [id="3", shape=circle, label="3"]; + n_6 [id="4", shape=circle, label="3"]; + n_7 [id="7", shape=circle, label="6"]; + n_8 [id="3", shape=circle, label="7"]; - n_2 -> n_6 [id="[$e|10]", label="receive {Process,_}"]; - n_6 -> n_8 [id="[$e|15]", label="send [Ciao C] to dummy_2"]; - n_6 -> n_8 [id="[$e|0]", label="send [Ciao A] to dummy_0"]; - n_8 -> n_7 [id="[$e|12]", label="receive Obj"]; - n_3 -> n_2 [id="[$e|1]", label="spawn dummy_3"]; - n_6 -> n_8 [id="[$e|14]", label="send [Ciao D] to dummy_3"]; - n_1 -> n_3 [id="[$e|9]", label="spawn dummy_2"]; - n_4 -> n_5 [id="[$e|4]", label="spawn dummy_0"]; - n_5 -> n_1 [id="[$e|8]", label="spawn dummy_1"]; + n_4 -> n_5 [id="[$e|3]", label="spawn dummy_0"]; + n_6 -> n_3 [id="[$e|10]", label="spawn dummy_2"]; + n_2 -> n_7 [id="[$e|12]", label="receive {Process,_}"]; + n_5 -> n_6 [id="[$e|9]", label="spawn dummy_1"]; + n_7 -> n_1 [id="[$e|1]", label="receive Obj"]; + n_7 -> n_8 [id="[$e|4]", label="send [Ciao D] to dummy_3"]; + n_7 -> n_8 [id="[$e|16]", label="send [Ciao A] to dummy_0"]; + n_7 -> n_8 [id="[$e|15]", label="send [Ciao C] to dummy_2"]; + n_3 -> n_2 [id="[$e|11]", label="spawn dummy_3"]; + n_8 -> n_1 [id="[$e|13]", label="receive Obj"]; } diff --git a/examples/customer/customer_local_view.dot b/examples/customer/customer_local_view.dot index 44b4896..b0c3dff 100644 --- a/examples/customer/customer_local_view.dot +++ b/examples/customer/customer_local_view.dot @@ -8,10 +8,10 @@ digraph customer { n_4 [id="4", shape=circle, label="4"]; n_5 [id="7", shape=circle, label="2"]; - n_5 -> n_3 [id="[$e|7]", label="send buy to store_0"]; - n_4 -> n_1 [id="[$e|2]", label="receive accepted"]; + n_4 -> n_3 [id="[$e|9]", label="receive reject"]; n_2 -> n_5 [id="[$e|3]", label="send item to store_0"]; + n_5 -> n_3 [id="[$e|7]", label="send buy to store_0"]; n_5 -> n_2 [id="[$e|8]", label="send more to store_0"]; - n_4 -> n_3 [id="[$e|9]", label="receive reject"]; n_3 -> n_4 [id="[$e|5]", label="send payment to store_0"]; + n_4 -> n_1 [id="[$e|2]", label="receive accepted"]; } diff --git a/examples/customer/main_global_view.dot b/examples/customer/main_global_view.dot index fdcb6fe..a2983bc 100644 --- a/examples/customer/main_global_view.dot +++ b/examples/customer/main_global_view.dot @@ -11,13 +11,13 @@ digraph global { n_7 [id="7", shape=circle, label="7"]; n_8 [id="3", shape=circle, label="3"]; - n_7 -> n_1 [id="[$e|7]", label="store_0→customer_0:reject"]; - n_8 -> n_6 [id="[$e|2]", label="customer_0→store_0:item"]; + n_4 -> n_8 [id="[$e|1]", label="mainΔstore_0"]; + n_3 -> n_4 [id="[$e|0]", label="mainΔcustomer_0"]; n_2 -> n_6 [id="[$e|6]", label="customer_0→store_0:item"]; + n_6 -> n_2 [id="[$e|4]", label="customer_0→store_0:more"]; n_6 -> n_1 [id="[$e|3]", label="customer_0→store_0:buy"]; + n_7 -> n_1 [id="[$e|7]", label="store_0→customer_0:reject"]; n_7 -> n_5 [id="[$e|8]", label="store_0→customer_0:accepted"]; - n_6 -> n_2 [id="[$e|4]", label="customer_0→store_0:more"]; - n_4 -> n_8 [id="[$e|1]", label="mainΔstore_0"]; - n_3 -> n_4 [id="[$e|0]", label="mainΔcustomer_0"]; n_1 -> n_7 [id="[$e|5]", label="customer_0→store_0:payment"]; + n_8 -> n_6 [id="[$e|2]", label="customer_0→store_0:item"]; } diff --git a/examples/customer/store_local_view.dot b/examples/customer/store_local_view.dot index 2f89520..b8bd26c 100644 --- a/examples/customer/store_local_view.dot +++ b/examples/customer/store_local_view.dot @@ -8,10 +8,10 @@ digraph store { n_4 [id="7", shape=doublecircle, label="5"]; n_5 [id="3", shape=circle, label="2"]; - n_3 -> n_1 [id="[$e|7]", label="receive payment"]; + n_5 -> n_3 [id="[$e|9]", label="receive buy"]; + n_1 -> n_3 [id="[$e|4]", label="send reject to customer_0"]; n_2 -> n_5 [id="[$e|3]", label="receive item"]; + n_3 -> n_1 [id="[$e|7]", label="receive payment"]; n_5 -> n_2 [id="[$e|8]", label="receive more"]; - n_1 -> n_3 [id="[$e|4]", label="send reject to customer_0"]; - n_5 -> n_3 [id="[$e|9]", label="receive buy"]; n_1 -> n_4 [id="[$e|5]", label="send accepted to customer_0"]; } diff --git a/examples/for-loop-recursion/main_global_view.dot b/examples/for-loop-recursion/main_global_view.dot index 35b57a0..1abc751 100644 --- a/examples/for-loop-recursion/main_global_view.dot +++ b/examples/for-loop-recursion/main_global_view.dot @@ -2,17 +2,18 @@ digraph global { rankdir="LR"; n_0 [label="global", shape="plaintext"]; n_1 [id="5", shape=circle, label="5"]; - n_2 [id="1", shape=circle, label="1"]; - n_0 -> n_2 [arrowhead=none]; - n_3 [id="2", shape=circle, label="2"]; - n_4 [id="4", shape=circle, label="4"]; - n_5 [id="7", shape=circle, label="7"]; - n_6 [id="3", shape=circle, label="3"]; + n_2 [id="6", shape=circle, label="6"]; + n_3 [id="1", shape=circle, label="1"]; + n_0 -> n_3 [arrowhead=none]; + n_4 [id="2", shape=circle, label="2"]; + n_5 [id="4", shape=circle, label="4"]; + n_6 [id="7", shape=circle, label="7"]; + n_7 [id="3", shape=circle, label="3"]; - n_3 -> n_6 [id="[$e|2]", label="mainΔdummy_1"]; - n_2 -> n_3 [id="[$e|0]", label="mainΔdummy_0"]; - n_6 -> n_5 [id="[$e|1]", label="dummy_0→main:integer"]; - n_6 -> n_4 [id="[$e|5]", label="dummy_1→main:integer"]; - n_5 -> n_1 [id="[$e|6]", label="dummy_1→main:integer"]; - n_4 -> n_1 [id="[$e|4]", label="dummy_0→main:integer"]; + n_7 -> n_5 [id="[$e|2]", label="dummy_0→main:integer"]; + n_3 -> n_4 [id="[$e|0]", label="mainΔdummy_0"]; + n_7 -> n_1 [id="[$e|3]", label="dummy_1→main:integer"]; + n_5 -> n_2 [id="[$e|4]", label="dummy_1→main:integer"]; + n_1 -> n_6 [id="[$e|5]", label="dummy_0→main:integer"]; + n_4 -> n_7 [id="[$e|1]", label="mainΔdummy_1"]; } diff --git a/examples/for-loop-recursion/main_local_view.dot b/examples/for-loop-recursion/main_local_view.dot index 56dbeb0..fa886fc 100644 --- a/examples/for-loop-recursion/main_local_view.dot +++ b/examples/for-loop-recursion/main_local_view.dot @@ -4,11 +4,9 @@ digraph main { n_1 [id="1", shape=circle, label="1"]; n_0 -> n_1 [arrowhead=none]; n_2 [id="2", shape=circle, label="2"]; - n_3 [id="4", shape=circle, label="4"]; - n_4 [id="3", shape=doublecircle, label="3"]; + n_3 [id="3", shape=circle, label="3"]; - n_2 -> n_3 [id="[$e|2]", label="spawn dummy_1"]; - n_3 -> n_4 [id="[$e|0]", label="receive Num"]; - n_1 -> n_2 [id="[$e|1]", label="spawn dummy_0"]; - n_4 -> n_4 [id="[$e|3]", label="receive Num"]; + n_1 -> n_2 [id="[$e|2]", label="spawn dummy_0"]; + n_2 -> n_3 [id="[$e|4]", label="spawn dummy_1"]; + n_3 -> n_3 [id="[$e|1]", label="receive Num"]; } diff --git a/examples/function-call/dummy_local_view.dot b/examples/function-call/dummy_local_view.dot index c6f775c..22e8ccb 100644 --- a/examples/function-call/dummy_local_view.dot +++ b/examples/function-call/dummy_local_view.dot @@ -6,6 +6,6 @@ digraph dummy { n_2 [id="2", shape=circle, label="2"]; n_3 [id="3", shape=doublecircle, label="3"]; - n_1 -> n_2 [id="[$e|0]", label="send {pid_self,[Hello from dummy (1)]} to Pid"]; - n_2 -> n_3 [id="[$e|1]", label="send {pid_self,[Hello from dummy (2)]} to Pid"]; + n_1 -> n_2 [id="[$e|0]", label="send {pid_self,hello1} to Pid"]; + n_2 -> n_3 [id="[$e|1]", label="send {pid_self,hello2} to Pid"]; } diff --git a/examples/function-call/main_global_view.dot b/examples/function-call/main_global_view.dot index 18a0470..93bb02a 100644 --- a/examples/function-call/main_global_view.dot +++ b/examples/function-call/main_global_view.dot @@ -4,8 +4,10 @@ digraph global { n_1 [id="1", shape=circle, label="1"]; n_0 -> n_1 [arrowhead=none]; n_2 [id="2", shape=circle, label="2"]; - n_3 [id="3", shape=circle, label="3"]; + n_3 [id="4", shape=circle, label="4"]; + n_4 [id="3", shape=circle, label="3"]; n_1 -> n_2 [id="[$e|0]", label="mainΔdummy_0"]; - n_2 -> n_3 [id="[$e|1]", label="dummy_0→main:{pid_self,[Hello"]; + n_2 -> n_4 [id="[$e|1]", label="dummy_0→main:{pid_self,hello1}"]; + n_2 -> n_3 [id="[$e|2]", label="dummy_0→main:{pid_self,hello2}"]; } diff --git a/examples/function-call/main_local_view.dot b/examples/function-call/main_local_view.dot index fb5a6cb..6d4cb45 100644 --- a/examples/function-call/main_local_view.dot +++ b/examples/function-call/main_local_view.dot @@ -4,8 +4,8 @@ digraph main { n_1 [id="1", shape=circle, label="1"]; n_0 -> n_1 [arrowhead=none]; n_2 [id="2", shape=circle, label="2"]; - n_3 [id="3", shape=doublecircle, label="3"]; + n_3 [id="4", shape=doublecircle, label="3"]; - n_2 -> n_3 [id="[$e|1]", label="receive {_,Msg}"]; n_1 -> n_2 [id="[$e|3]", label="spawn dummy_0"]; + n_2 -> n_3 [id="[$e|1]", label="receive {_,Msg}"]; } diff --git a/examples/hello/greet_local_view.dot b/examples/hello/greet_local_view.dot index d7e698b..ff42fc5 100644 --- a/examples/hello/greet_local_view.dot +++ b/examples/hello/greet_local_view.dot @@ -7,6 +7,6 @@ digraph greet { n_3 [id="3", shape=circle, label="2"]; n_3 -> n_2 [id="[$e|1]", label="receive hello1"]; - n_1 -> n_3 [id="[$e|2]", label="send hello1 to Me"]; n_3 -> n_1 [id="[$e|4]", label="send hello1 to Me"]; + n_1 -> n_3 [id="[$e|2]", label="send hello1 to Me"]; } diff --git a/examples/high-order-fun/greet_global_view.dot b/examples/high-order-fun/greet_global_view.dot index ed6e578..2384629 100644 --- a/examples/high-order-fun/greet_global_view.dot +++ b/examples/high-order-fun/greet_global_view.dot @@ -6,6 +6,6 @@ digraph global { n_2 [id="2", shape=circle, label="2"]; n_3 [id="3", shape=circle, label="3"]; - n_2 -> n_3 [id="[$e|1]", label="greet→Fun_0:hello"]; - n_1 -> n_2 [id="[$e|0]", label="greetΔFun_0"]; + n_2 -> n_3 [id="[$e|1]", label="greet→anonfun_line15_0:hello"]; + n_1 -> n_2 [id="[$e|0]", label="greetΔanonfun_line15_0"]; } diff --git a/examples/high-order-fun/greet_local_view.dot b/examples/high-order-fun/greet_local_view.dot index 5863a6e..a1c3379 100644 --- a/examples/high-order-fun/greet_local_view.dot +++ b/examples/high-order-fun/greet_local_view.dot @@ -11,5 +11,5 @@ digraph greet { n_4 -> n_1 [id="[$e|3]", label="receive hello"]; n_2 -> n_3 [id="[$e|1]", label="spawn anonfun_line15_0"]; n_3 -> n_5 [id="[$e|0]", label="send hello to anonfun_line15_0"]; - n_5 -> n_4 [id="[$e|2]", label="send hello to greet"]; + n_5 -> n_4 [id="[$e|2]", label="send hello to none"]; } diff --git a/examples/if-cases/a_local_view.dot b/examples/if-cases/a_local_view.dot index 5c3186e..d0d5047 100644 --- a/examples/if-cases/a_local_view.dot +++ b/examples/if-cases/a_local_view.dot @@ -3,10 +3,10 @@ digraph a { n_0 [label="a", shape="plaintext"]; n_1 [id="1", shape=circle, label="1"]; n_0 -> n_1 [arrowhead=none]; - n_2 [id="2", shape=doublecircle, label="2"]; - n_3 [id="3", shape=circle, label="3"]; + n_2 [id="2", shape=doublecircle, label="3"]; + n_3 [id="3", shape=circle, label="2"]; - n_3 -> n_2 [id="[$e|2]", label="send [Hi, i'm A] to Pid"]; n_3 -> n_3 [id="[$e|0]", label="receive Pid"]; n_1 -> n_3 [id="[$e|1]", label="receive Pid"]; + n_3 -> n_2 [id="[$e|2]", label="send [Hi, i'm A] to Pid"]; } diff --git a/examples/if-cases/b_local_view.dot b/examples/if-cases/b_local_view.dot index 57b933a..bff0409 100644 --- a/examples/if-cases/b_local_view.dot +++ b/examples/if-cases/b_local_view.dot @@ -3,10 +3,10 @@ digraph b { n_0 [label="b", shape="plaintext"]; n_1 [id="1", shape=circle, label="1"]; n_0 -> n_1 [arrowhead=none]; - n_2 [id="2", shape=doublecircle, label="2"]; - n_3 [id="3", shape=circle, label="3"]; + n_2 [id="2", shape=doublecircle, label="3"]; + n_3 [id="3", shape=circle, label="2"]; + n_3 -> n_2 [id="[$e|0]", label="send [Hi, i'm B] to Pid"]; + n_3 -> n_3 [id="[$e|1]", label="receive Pid"]; n_1 -> n_3 [id="[$e|2]", label="receive Pid"]; - n_3 -> n_3 [id="[$e|0]", label="receive Pid"]; - n_3 -> n_2 [id="[$e|1]", label="send [Hi, i'm B] to Pid"]; } diff --git a/examples/if-cases/c_local_view.dot b/examples/if-cases/c_local_view.dot index c9c7cf0..08919a8 100644 --- a/examples/if-cases/c_local_view.dot +++ b/examples/if-cases/c_local_view.dot @@ -3,10 +3,10 @@ digraph c { n_0 [label="c", shape="plaintext"]; n_1 [id="1", shape=circle, label="1"]; n_0 -> n_1 [arrowhead=none]; - n_2 [id="2", shape=doublecircle, label="2"]; - n_3 [id="3", shape=circle, label="3"]; + n_2 [id="2", shape=doublecircle, label="3"]; + n_3 [id="3", shape=circle, label="2"]; - n_3 -> n_2 [id="[$e|2]", label="send [Hi, i'm C] to Pid"]; n_3 -> n_3 [id="[$e|0]", label="receive Pid"]; n_1 -> n_3 [id="[$e|1]", label="receive Pid"]; + n_3 -> n_2 [id="[$e|2]", label="send [Hi, i'm C] to Pid"]; } diff --git a/examples/if-cases/main_global_view.dot b/examples/if-cases/main_global_view.dot index a7c3669..171fff4 100644 --- a/examples/if-cases/main_global_view.dot +++ b/examples/if-cases/main_global_view.dot @@ -1,13 +1,73 @@ digraph global { rankdir="LR"; n_0 [label="global", shape="plaintext"]; - n_1 [id="1", shape=circle, label="1"]; - n_0 -> n_1 [arrowhead=none]; - n_2 [id="2", shape=circle, label="2"]; - n_3 [id="4", shape=circle, label="4"]; - n_4 [id="3", shape=circle, label="3"]; + n_1 [id="33", shape=circle, label="33"]; + n_2 [id="34", shape=circle, label="34"]; + n_3 [id="20", shape=circle, label="20"]; + n_4 [id="27", shape=circle, label="27"]; + n_5 [id="29", shape=circle, label="29"]; + n_6 [id="23", shape=circle, label="23"]; + n_7 [id="25", shape=circle, label="25"]; + n_8 [id="5", shape=circle, label="5"]; + n_9 [id="28", shape=circle, label="28"]; + n_10 [id="15", shape=circle, label="15"]; + n_11 [id="19", shape=circle, label="19"]; + n_12 [id="12", shape=circle, label="12"]; + n_13 [id="11", shape=circle, label="11"]; + n_14 [id="17", shape=circle, label="17"]; + n_15 [id="18", shape=circle, label="18"]; + n_16 [id="14", shape=circle, label="14"]; + n_17 [id="6", shape=circle, label="6"]; + n_18 [id="13", shape=circle, label="13"]; + n_19 [id="24", shape=circle, label="24"]; + n_20 [id="10", shape=circle, label="10"]; + n_21 [id="30", shape=circle, label="30"]; + n_22 [id="22", shape=circle, label="22"]; + n_23 [id="1", shape=circle, label="1"]; + n_0 -> n_23 [arrowhead=none]; + n_24 [id="26", shape=circle, label="26"]; + n_25 [id="9", shape=circle, label="9"]; + n_26 [id="2", shape=circle, label="2"]; + n_27 [id="21", shape=circle, label="21"]; + n_28 [id="8", shape=circle, label="8"]; + n_29 [id="4", shape=circle, label="4"]; + n_30 [id="31", shape=circle, label="31"]; + n_31 [id="32", shape=circle, label="32"]; + n_32 [id="7", shape=circle, label="7"]; + n_33 [id="3", shape=circle, label="3"]; + n_34 [id="16", shape=circle, label="16"]; - n_4 -> n_3 [id="[$e|2]", label="mainΔc_0"]; - n_1 -> n_2 [id="[$e|0]", label="mainΔa_0"]; - n_2 -> n_4 [id="[$e|1]", label="mainΔb_0"]; + n_22 -> n_2 [id="[$e|32]", label="main→a_0:pid_b_0"]; + n_11 -> n_30 [id="[$e|29]", label="main→c_0:pid_a_0"]; + n_17 -> n_18 [id="[$e|11]", label="main→a_0:pid_c_0"]; + n_29 -> n_8 [id="[$e|3]", label="main→a_0:pid_c_0"]; + n_15 -> n_21 [id="[$e|28]", label="main→b_0:pid_c_0"]; + n_23 -> n_26 [id="[$e|0]", label="mainΔa_0"]; + n_29 -> n_25 [id="[$e|7]", label="main→b_0:pid_c_0"]; + n_3 -> n_31 [id="[$e|30]", label="main→a_0:pid_b_0"]; + n_13 -> n_6 [id="[$e|21]", label="main→c_0:pid_b_0"]; + n_28 -> n_14 [id="[$e|15]", label="main→b_0:pid_c_0"]; + n_28 -> n_15 [id="[$e|16]", label="main→c_0:pid_a_0"]; + n_29 -> n_17 [id="[$e|4]", label="main→b_0:pid_a_0"]; + n_29 -> n_32 [id="[$e|5]", label="main→c_0:pid_b_0"]; + n_32 -> n_10 [id="[$e|13]", label="main→a_0:pid_c_0"]; + n_8 -> n_13 [id="[$e|9]", label="main→b_0:pid_a_0"]; + n_25 -> n_3 [id="[$e|18]", label="main→c_0:pid_a_0"]; + n_14 -> n_5 [id="[$e|27]", label="main→c_0:pid_a_0"]; + n_27 -> n_1 [id="[$e|31]", label="main→b_0:pid_c_0"]; + n_8 -> n_12 [id="[$e|10]", label="main→c_0:pid_b_0"]; + n_20 -> n_22 [id="[$e|20]", label="main→b_0:pid_c_0"]; + n_32 -> n_34 [id="[$e|14]", label="main→b_0:pid_a_0"]; + n_20 -> n_27 [id="[$e|19]", label="main→a_0:pid_b_0"]; + n_26 -> n_33 [id="[$e|1]", label="mainΔb_0"]; + n_12 -> n_19 [id="[$e|22]", label="main→b_0:pid_a_0"]; + n_10 -> n_4 [id="[$e|25]", label="main→b_0:pid_a_0"]; + n_29 -> n_20 [id="[$e|8]", label="main→c_0:pid_a_0"]; + n_16 -> n_24 [id="[$e|24]", label="main→a_0:pid_c_0"]; + n_34 -> n_9 [id="[$e|26]", label="main→a_0:pid_c_0"]; + n_17 -> n_16 [id="[$e|12]", label="main→c_0:pid_b_0"]; + n_25 -> n_11 [id="[$e|17]", label="main→a_0:pid_b_0"]; + n_33 -> n_29 [id="[$e|2]", label="mainΔc_0"]; + n_29 -> n_28 [id="[$e|6]", label="main→a_0:pid_b_0"]; + n_18 -> n_7 [id="[$e|23]", label="main→c_0:pid_b_0"]; } diff --git a/examples/if-cases/main_local_view.dot b/examples/if-cases/main_local_view.dot index b1e00da..fc705d2 100644 --- a/examples/if-cases/main_local_view.dot +++ b/examples/if-cases/main_local_view.dot @@ -1,24 +1,24 @@ digraph main { rankdir="LR"; n_0 [label="main", shape="plaintext"]; - n_1 [id="5", shape=doublecircle, label="5"]; - n_2 [id="6", shape=circle, label="6"]; - n_3 [id="10", shape=circle, label="10"]; + n_1 [id="5", shape=circle, label="7"]; + n_2 [id="6", shape=circle, label="5"]; + n_3 [id="10", shape=circle, label="6"]; n_4 [id="1", shape=circle, label="1"]; n_0 -> n_4 [arrowhead=none]; - n_5 [id="9", shape=circle, label="9"]; + n_5 [id="9", shape=doublecircle, label="4"]; n_6 [id="2", shape=circle, label="2"]; n_7 [id="8", shape=circle, label="8"]; - n_8 [id="4", shape=circle, label="4"]; + n_8 [id="4", shape=doublecircle, label="9"]; n_9 [id="3", shape=circle, label="3"]; - n_3 -> n_8 [id="[$e|2]", label="send pid_b_0 to a_0"]; - n_9 -> n_3 [id="[$e|0]", label="spawn c_0"]; - n_7 -> n_2 [id="[$e|1]", label="send pid_b_0 to c_0"]; - n_5 -> n_1 [id="[$e|7]", label="send pid_a_0 to c_0"]; - n_4 -> n_6 [id="[$e|5]", label="spawn a_0"]; - n_3 -> n_7 [id="[$e|6]", label="send pid_c_0 to a_0"]; - n_2 -> n_1 [id="[$e|9]", label="send pid_a_0 to b_0"]; - n_8 -> n_5 [id="[$e|4]", label="send pid_c_0 to b_0"]; - n_6 -> n_9 [id="[$e|8]", label="spawn b_0"]; + n_5 -> n_2 [id="[$e|3]", label="send pid_c_0 to a_0"]; + n_3 -> n_1 [id="[$e|0]", label="send pid_c_0 to b_0"]; + n_6 -> n_9 [id="[$e|7]", label="spawn b_0"]; + n_9 -> n_5 [id="[$e|4]", label="spawn c_0"]; + n_2 -> n_7 [id="[$e|5]", label="send pid_b_0 to c_0"]; + n_7 -> n_8 [id="[$e|9]", label="send pid_a_0 to b_0"]; + n_1 -> n_8 [id="[$e|1]", label="send pid_a_0 to c_0"]; + n_5 -> n_3 [id="[$e|8]", label="send pid_b_0 to a_0"]; + n_4 -> n_6 [id="[$e|2]", label="spawn a_0"]; } diff --git a/examples/serverclient/client_local_view.dot b/examples/serverclient/client_local_view.dot index acb2f1e..ce3e9e7 100644 --- a/examples/serverclient/client_local_view.dot +++ b/examples/serverclient/client_local_view.dot @@ -7,8 +7,8 @@ digraph client { n_3 [id="4", shape=circle, label="2"]; n_4 [id="3", shape=circle, label="3"]; - n_4 -> n_4 [id="[$e|7]", label="send next to Handle"]; - n_3 -> n_4 [id="[$e|4]", label="receive {res,Handle}"]; n_1 -> n_3 [id="[$e|1]", label="send {req,pid_self} to server_0"]; + n_3 -> n_4 [id="[$e|4]", label="receive {res,Handle}"]; + n_4 -> n_4 [id="[$e|7]", label="send next to Handle"]; n_4 -> n_2 [id="[$e|5]", label="send done to Handle"]; } diff --git a/examples/serverclient/handle_req_local_view.dot b/examples/serverclient/handle_req_local_view.dot index 167736c..7049be7 100644 --- a/examples/serverclient/handle_req_local_view.dot +++ b/examples/serverclient/handle_req_local_view.dot @@ -5,6 +5,6 @@ digraph handle_req { n_0 -> n_1 [arrowhead=none]; n_2 [id="3", shape=doublecircle, label="2"]; - n_1 -> n_1 [id="[$e|4]", label="receive next"]; n_1 -> n_2 [id="[$e|0]", label="receive done"]; + n_1 -> n_1 [id="[$e|4]", label="receive next"]; } diff --git a/examples/serverclient/main_global_view.dot b/examples/serverclient/main_global_view.dot index a49dc7c..ba34496 100644 --- a/examples/serverclient/main_global_view.dot +++ b/examples/serverclient/main_global_view.dot @@ -10,11 +10,11 @@ digraph global { n_6 [id="7", shape=circle, label="7"]; n_7 [id="3", shape=circle, label="3"]; - n_7 -> n_5 [id="[$e|2]", label="client_0→server_0:{req,pid_self}"]; - n_2 -> n_2 [id="[$e|6]", label="client_0→handle_req_0:next"]; - n_5 -> n_1 [id="[$e|3]", label="server_0Δhandle_req_0"]; - n_1 -> n_2 [id="[$e|4]", label="server_0→client_0:{res,pid_handle_req_0}"]; n_4 -> n_7 [id="[$e|1]", label="mainΔclient_0"]; n_3 -> n_4 [id="[$e|0]", label="mainΔserver_0"]; + n_2 -> n_2 [id="[$e|6]", label="client_0→handle_req_0:next"]; + n_1 -> n_2 [id="[$e|4]", label="server_0→client_0:{res,pid_handle_req_0}"]; + n_5 -> n_1 [id="[$e|3]", label="server_0Δhandle_req_0"]; n_2 -> n_6 [id="[$e|5]", label="client_0→handle_req_0:done"]; + n_7 -> n_5 [id="[$e|2]", label="client_0→server_0:{req,pid_self}"]; } diff --git a/examples/serverclient/server_local_view.dot b/examples/serverclient/server_local_view.dot index b6cdbc8..6eba092 100644 --- a/examples/serverclient/server_local_view.dot +++ b/examples/serverclient/server_local_view.dot @@ -8,9 +8,9 @@ digraph server { n_4 [id="2", shape=circle, label="3"]; n_5 [id="3", shape=circle, label="2"]; - n_1 -> n_3 [id="[$e|7]", label="send {res,pid_handle_req_0} to P"]; - n_3 -> n_4 [id="[$e|2]", label="receive {req,P}"]; - n_5 -> n_2 [id="[$e|6]", label="spawn handle_req_1"]; n_4 -> n_1 [id="[$e|0]", label="spawn handle_req_0"]; + n_5 -> n_2 [id="[$e|6]", label="spawn handle_req_1"]; + n_1 -> n_3 [id="[$e|7]", label="send {res,pid_handle_req_0} to P"]; n_3 -> n_5 [id="[$e|5]", label="receive ciao"]; + n_3 -> n_4 [id="[$e|2]", label="receive {req,P}"]; } diff --git a/examples/test/barber/test_local_view.dot b/examples/test/barber/test_local_view.dot new file mode 100644 index 0000000..c8a3f3f --- /dev/null +++ b/examples/test/barber/test_local_view.dot @@ -0,0 +1,19 @@ +digraph test { + rankdir="LR"; + n_0 [label="test", shape="plaintext"]; + n_1 [id="5", shape=doublecircle, label="7"]; + n_2 [id="6", shape=circle, label="5"]; + n_3 [id="1", shape=circle, label="1"]; + n_0 -> n_3 [arrowhead=none]; + n_4 [id="2", shape=circle, label="2"]; + n_5 [id="4", shape=circle, label="4"]; + n_6 [id="7", shape=circle, label="6"]; + n_7 [id="3", shape=circle, label="3"]; + + n_2 -> n_6 [id="[$e|1]", label="receive {Name2,State2}"]; + n_4 -> n_7 [id="[$e|5]", label="spawn customer_0"]; + n_7 -> n_5 [id="[$e|0]", label="spawn customer_1"]; + n_5 -> n_2 [id="[$e|4]", label="receive {Name1,State1}"]; + n_6 -> n_1 [id="[$e|3]", label="send stop to open_barber_shop_0"]; + n_3 -> n_4 [id="[$e|2]", label="spawn open_barber_shop_0"]; +} diff --git a/examples/test/foo1/b_local_view.dot b/examples/test/foo1/b_local_view.dot index 6e98b62..4dfd564 100644 --- a/examples/test/foo1/b_local_view.dot +++ b/examples/test/foo1/b_local_view.dot @@ -1,9 +1,9 @@ digraph b { rankdir="LR"; n_0 [label="b", shape="plaintext"]; - n_1 [id="2", shape=circle, label="2"]; - n_2 [id="1", shape=circle, label="1"]; - n_0 -> n_2 [arrowhead=none]; + n_1 [id="1", shape=circle, label="1"]; + n_0 -> n_1 [arrowhead=none]; + n_2 [id="2", shape=doublecircle, label="2"]; - n_2 -> n_1 [id="[$e|0]", label="receive X"]; + n_1 -> n_2 [id="[$e|0]", label="receive X"]; } diff --git a/examples/test/foo1/c_local_view.dot b/examples/test/foo1/c_local_view.dot index 5a42b6c..ae75bc2 100644 --- a/examples/test/foo1/c_local_view.dot +++ b/examples/test/foo1/c_local_view.dot @@ -1,11 +1,11 @@ digraph c { rankdir="LR"; n_0 [label="c", shape="plaintext"]; - n_1 [id="3", shape=circle, label="3"]; + n_1 [id="1", shape=circle, label="1"]; + n_0 -> n_1 [arrowhead=none]; n_2 [id="2", shape=circle, label="2"]; - n_3 [id="1", shape=circle, label="1"]; - n_0 -> n_3 [arrowhead=none]; + n_3 [id="3", shape=doublecircle, label="3"]; - n_2 -> n_1 [id="[$e|1]", label="send X to B"]; - n_3 -> n_2 [id="[$e|0]", label="receive X"]; + n_1 -> n_2 [id="[$e|0]", label="receive X"]; + n_2 -> n_3 [id="[$e|1]", label="send X to B"]; } diff --git a/examples/test/foo1/test_global_view.dot b/examples/test/foo1/test_global_view.dot index 229c2f6..acd7717 100644 --- a/examples/test/foo1/test_global_view.dot +++ b/examples/test/foo1/test_global_view.dot @@ -1,19 +1,19 @@ digraph global { rankdir="LR"; n_0 [label="global", shape="plaintext"]; - n_1 [id="3", shape=circle, label="3"]; + n_1 [id="5", shape=circle, label="5"]; n_2 [id="6", shape=circle, label="6"]; - n_3 [id="4", shape=circle, label="4"]; - n_4 [id="5", shape=circle, label="5"]; - n_5 [id="2", shape=circle, label="2"]; + n_3 [id="1", shape=circle, label="1"]; + n_0 -> n_3 [arrowhead=none]; + n_4 [id="2", shape=circle, label="2"]; + n_5 [id="4", shape=circle, label="4"]; n_6 [id="7", shape=circle, label="7"]; - n_7 [id="1", shape=circle, label="1"]; - n_0 -> n_7 [arrowhead=none]; + n_7 [id="3", shape=circle, label="3"]; - n_5 -> n_1 [id="[$e|1]", label="testΔc_0"]; - n_3 -> n_2 [id="[$e|4]", label="test→c_0:dos"]; - n_1 -> n_4 [id="[$e|3]", label="test→c_0:dos"]; - n_4 -> n_6 [id="[$e|5]", label="test→b_0:uno"]; - n_7 -> n_5 [id="[$e|0]", label="testΔb_0"]; - n_1 -> n_3 [id="[$e|2]", label="test→b_0:uno"]; + n_1 -> n_6 [id="[$e|5]", label="test→b_0:uno"]; + n_5 -> n_2 [id="[$e|4]", label="test→c_0:dos"]; + n_3 -> n_4 [id="[$e|0]", label="testΔb_0"]; + n_7 -> n_1 [id="[$e|3]", label="test→c_0:dos"]; + n_4 -> n_7 [id="[$e|1]", label="testΔc_0"]; + n_7 -> n_5 [id="[$e|2]", label="test→b_0:uno"]; } diff --git a/examples/test/foo1/test_local_view.dot b/examples/test/foo1/test_local_view.dot index 0a170ab..2da57db 100644 --- a/examples/test/foo1/test_local_view.dot +++ b/examples/test/foo1/test_local_view.dot @@ -1,15 +1,15 @@ digraph test { rankdir="LR"; n_0 [label="test", shape="plaintext"]; - n_1 [id="3", shape=circle, label="3"]; - n_2 [id="4", shape=circle, label="5"]; - n_3 [id="5", shape=circle, label="4"]; - n_4 [id="2", shape=circle, label="2"]; - n_5 [id="1", shape=circle, label="1"]; - n_0 -> n_5 [arrowhead=none]; + n_1 [id="5", shape=circle, label="4"]; + n_2 [id="1", shape=circle, label="1"]; + n_0 -> n_2 [arrowhead=none]; + n_3 [id="2", shape=circle, label="2"]; + n_4 [id="4", shape=doublecircle, label="5"]; + n_5 [id="3", shape=circle, label="3"]; - n_1 -> n_3 [id="[$e|1]", label="send uno to b_0"]; - n_3 -> n_2 [id="[$e|3]", label="send dos to c_0"]; - n_5 -> n_4 [id="[$e|0]", label="spawn b_0"]; - n_4 -> n_1 [id="[$e|2]", label="spawn c_0"]; + n_2 -> n_3 [id="[$e|0]", label="spawn b_0"]; + n_1 -> n_4 [id="[$e|3]", label="send dos to c_0"]; + n_5 -> n_1 [id="[$e|1]", label="send uno to b_0"]; + n_3 -> n_5 [id="[$e|2]", label="spawn c_0"]; } diff --git a/examples/test/foo2/b_local_view.dot b/examples/test/foo2/b_local_view.dot index b1f3eee..249bd65 100644 --- a/examples/test/foo2/b_local_view.dot +++ b/examples/test/foo2/b_local_view.dot @@ -6,6 +6,6 @@ digraph b { n_2 [id="2", shape=doublecircle, label="3"]; n_3 [id="3", shape=circle, label="2"]; - n_1 -> n_3 [id="[$e|0]", label="receive X"]; n_3 -> n_2 [id="[$e|1]", label="receive Z"]; + n_1 -> n_3 [id="[$e|0]", label="receive X"]; } diff --git a/examples/test/foo2/c_local_view.dot b/examples/test/foo2/c_local_view.dot index 00a57d2..6b9b3f5 100644 --- a/examples/test/foo2/c_local_view.dot +++ b/examples/test/foo2/c_local_view.dot @@ -6,6 +6,6 @@ digraph c { n_2 [id="2", shape=circle, label="2"]; n_3 [id="3", shape=doublecircle, label="3"]; - n_2 -> n_3 [id="[$e|0]", label="send 4 to b"]; n_1 -> n_2 [id="[$e|1]", label="receive _"]; + n_2 -> n_3 [id="[$e|0]", label="send 4 to none"]; } diff --git a/examples/test/foo2/test_global_view.dot b/examples/test/foo2/test_global_view.dot index 90b4cd1..1623da6 100644 --- a/examples/test/foo2/test_global_view.dot +++ b/examples/test/foo2/test_global_view.dot @@ -6,6 +6,6 @@ digraph global { n_2 [id="2", shape=circle, label="2"]; n_3 [id="3", shape=circle, label="3"]; - n_1 -> n_2 [id="[$e|0]", label="testΔc_0"]; n_2 -> n_3 [id="[$e|1]", label="testΔa_0"]; + n_1 -> n_2 [id="[$e|0]", label="testΔc_0"]; } diff --git a/examples/test/foo2/test_local_view.dot b/examples/test/foo2/test_local_view.dot index 726a39c..fc60150 100644 --- a/examples/test/foo2/test_local_view.dot +++ b/examples/test/foo2/test_local_view.dot @@ -6,6 +6,6 @@ digraph test { n_2 [id="2", shape=circle, label="2"]; n_3 [id="3", shape=doublecircle, label="3"]; - n_1 -> n_2 [id="[$e|0]", label="spawn c_0"]; n_2 -> n_3 [id="[$e|1]", label="spawn a_0"]; + n_1 -> n_2 [id="[$e|0]", label="spawn c_0"]; } diff --git a/examples/test/foo3/a_local_view.dot b/examples/test/foo3/a_local_view.dot index ea10316..99048a2 100644 --- a/examples/test/foo3/a_local_view.dot +++ b/examples/test/foo3/a_local_view.dot @@ -1,11 +1,11 @@ digraph a { rankdir="LR"; n_0 [label="a", shape="plaintext"]; - n_1 [id="3", shape=circle, label="3"]; + n_1 [id="1", shape=circle, label="1"]; + n_0 -> n_1 [arrowhead=none]; n_2 [id="2", shape=circle, label="2"]; - n_3 [id="1", shape=circle, label="1"]; - n_0 -> n_3 [arrowhead=none]; + n_3 [id="3", shape=doublecircle, label="3"]; - n_2 -> n_1 [id="[$e|1]", label="send 3 to S"]; - n_3 -> n_2 [id="[$e|0]", label="send 1 to S"]; + n_2 -> n_3 [id="[$e|1]", label="send 3 to S"]; + n_1 -> n_2 [id="[$e|0]", label="send 1 to S"]; } diff --git a/examples/test/foo3/b_local_view.dot b/examples/test/foo3/b_local_view.dot index d42d80f..15b2183 100644 --- a/examples/test/foo3/b_local_view.dot +++ b/examples/test/foo3/b_local_view.dot @@ -1,9 +1,9 @@ digraph b { rankdir="LR"; n_0 [label="b", shape="plaintext"]; - n_1 [id="2", shape=circle, label="2"]; - n_2 [id="1", shape=circle, label="1"]; - n_0 -> n_2 [arrowhead=none]; + n_1 [id="1", shape=circle, label="1"]; + n_0 -> n_1 [arrowhead=none]; + n_2 [id="2", shape=doublecircle, label="2"]; - n_2 -> n_1 [id="[$e|0]", label="send 2 to S"]; + n_1 -> n_2 [id="[$e|0]", label="send 2 to S"]; } diff --git a/examples/test/foo3/test_global_view.dot b/examples/test/foo3/test_global_view.dot index fcbf0ad..a80a077 100644 --- a/examples/test/foo3/test_global_view.dot +++ b/examples/test/foo3/test_global_view.dot @@ -1,11 +1,41 @@ digraph global { rankdir="LR"; n_0 [label="global", shape="plaintext"]; - n_1 [id="3", shape=circle, label="3"]; - n_2 [id="2", shape=circle, label="2"]; - n_3 [id="1", shape=circle, label="1"]; - n_0 -> n_3 [arrowhead=none]; + n_1 [id="5", shape=circle, label="5"]; + n_2 [id="15", shape=circle, label="15"]; + n_3 [id="12", shape=circle, label="12"]; + n_4 [id="11", shape=circle, label="11"]; + n_5 [id="17", shape=circle, label="17"]; + n_6 [id="18", shape=circle, label="18"]; + n_7 [id="14", shape=circle, label="14"]; + n_8 [id="6", shape=circle, label="6"]; + n_9 [id="13", shape=circle, label="13"]; + n_10 [id="10", shape=circle, label="10"]; + n_11 [id="1", shape=circle, label="1"]; + n_0 -> n_11 [arrowhead=none]; + n_12 [id="9", shape=circle, label="9"]; + n_13 [id="2", shape=circle, label="2"]; + n_14 [id="8", shape=circle, label="8"]; + n_15 [id="4", shape=circle, label="4"]; + n_16 [id="7", shape=circle, label="7"]; + n_17 [id="3", shape=circle, label="3"]; + n_18 [id="16", shape=circle, label="16"]; - n_2 -> n_1 [id="[$e|1]", label="testΔb_0"]; - n_3 -> n_2 [id="[$e|0]", label="testΔa_0"]; + n_1 -> n_12 [id="[$e|7]", label="a_0→test:1"]; + n_17 -> n_15 [id="[$e|2]", label="a_0→test:1"]; + n_3 -> n_6 [id="[$e|16]", label="a_0→test:1"]; + n_15 -> n_14 [id="[$e|6]", label="b_0→test:2"]; + n_17 -> n_1 [id="[$e|3]", label="a_0→test:3"]; + n_8 -> n_3 [id="[$e|10]", label="a_0→test:3"]; + n_16 -> n_9 [id="[$e|11]", label="b_0→test:2"]; + n_1 -> n_10 [id="[$e|8]", label="b_0→test:2"]; + n_17 -> n_8 [id="[$e|4]", label="b_0→test:2"]; + n_8 -> n_4 [id="[$e|9]", label="a_0→test:1"]; + n_12 -> n_2 [id="[$e|13]", label="b_0→test:2"]; + n_13 -> n_17 [id="[$e|1]", label="testΔb_0"]; + n_11 -> n_13 [id="[$e|0]", label="testΔa_0"]; + n_4 -> n_5 [id="[$e|15]", label="a_0→test:3"]; + n_15 -> n_16 [id="[$e|5]", label="a_0→test:3"]; + n_10 -> n_18 [id="[$e|14]", label="a_0→test:1"]; + n_14 -> n_7 [id="[$e|12]", label="a_0→test:3"]; } diff --git a/examples/test/foo3/test_local_view.dot b/examples/test/foo3/test_local_view.dot index ae362b4..5f88cb3 100644 --- a/examples/test/foo3/test_local_view.dot +++ b/examples/test/foo3/test_local_view.dot @@ -1,17 +1,17 @@ digraph test { rankdir="LR"; n_0 [label="test", shape="plaintext"]; - n_1 [id="3", shape=circle, label="3"]; - n_2 [id="6", shape=circle, label="6"]; - n_3 [id="4", shape=circle, label="4"]; - n_4 [id="5", shape=circle, label="5"]; - n_5 [id="2", shape=circle, label="2"]; - n_6 [id="1", shape=circle, label="1"]; - n_0 -> n_6 [arrowhead=none]; + n_1 [id="5", shape=circle, label="3"]; + n_2 [id="6", shape=circle, label="5"]; + n_3 [id="1", shape=circle, label="1"]; + n_0 -> n_3 [arrowhead=none]; + n_4 [id="2", shape=circle, label="4"]; + n_5 [id="4", shape=doublecircle, label="6"]; + n_6 [id="3", shape=circle, label="2"]; - n_6 -> n_5 [id="[$e|1]", label="spawn a_0"]; - n_5 -> n_1 [id="[$e|4]", label="spawn b_0"]; - n_4 -> n_2 [id="[$e|3]", label="receive Z"]; - n_1 -> n_3 [id="[$e|0]", label="receive X"]; - n_3 -> n_4 [id="[$e|2]", label="receive Y"]; + n_6 -> n_1 [id="[$e|2]", label="spawn b_0"]; + n_1 -> n_4 [id="[$e|3]", label="receive X"]; + n_2 -> n_5 [id="[$e|4]", label="receive Z"]; + n_3 -> n_6 [id="[$e|1]", label="spawn a_0"]; + n_4 -> n_2 [id="[$e|0]", label="receive Y"]; } diff --git a/examples/test/foo4/r_local_view.dot b/examples/test/foo4/r_local_view.dot index 337124e..20561fc 100644 --- a/examples/test/foo4/r_local_view.dot +++ b/examples/test/foo4/r_local_view.dot @@ -1,13 +1,13 @@ digraph r { rankdir="LR"; n_0 [label="r", shape="plaintext"]; - n_1 [id="3", shape=circle, label="4"]; - n_2 [id="4", shape=circle, label="2"]; - n_3 [id="2", shape=circle, label="3"]; - n_4 [id="1", shape=circle, label="1"]; - n_0 -> n_4 [arrowhead=none]; + n_1 [id="1", shape=circle, label="1"]; + n_0 -> n_1 [arrowhead=none]; + n_2 [id="2", shape=circle, label="3"]; + n_3 [id="4", shape=circle, label="2"]; + n_4 [id="3", shape=doublecircle, label="4"]; - n_2 -> n_3 [id="[$e|1]", label="receive Y"]; - n_3 -> n_1 [id="[$e|0]", label="receive Z"]; - n_4 -> n_2 [id="[$e|2]", label="receive X"]; + n_1 -> n_3 [id="[$e|0]", label="receive X"]; + n_3 -> n_2 [id="[$e|1]", label="receive Y"]; + n_2 -> n_4 [id="[$e|2]", label="receive Z"]; } diff --git a/examples/test/foo4/test_global_view.dot b/examples/test/foo4/test_global_view.dot index d674fd6..b881840 100644 --- a/examples/test/foo4/test_global_view.dot +++ b/examples/test/foo4/test_global_view.dot @@ -1,43 +1,43 @@ digraph global { rankdir="LR"; n_0 [label="global", shape="plaintext"]; - n_1 [id="11", shape=circle, label="11"]; - n_2 [id="10", shape=circle, label="10"]; - n_3 [id="18", shape=circle, label="18"]; - n_4 [id="3", shape=circle, label="3"]; - n_5 [id="19", shape=circle, label="19"]; - n_6 [id="13", shape=circle, label="13"]; - n_7 [id="9", shape=circle, label="9"]; - n_8 [id="17", shape=circle, label="17"]; + n_1 [id="5", shape=circle, label="5"]; + n_2 [id="15", shape=circle, label="15"]; + n_3 [id="19", shape=circle, label="19"]; + n_4 [id="12", shape=circle, label="12"]; + n_5 [id="11", shape=circle, label="11"]; + n_6 [id="17", shape=circle, label="17"]; + n_7 [id="18", shape=circle, label="18"]; + n_8 [id="14", shape=circle, label="14"]; n_9 [id="6", shape=circle, label="6"]; - n_10 [id="15", shape=circle, label="15"]; - n_11 [id="16", shape=circle, label="16"]; - n_12 [id="4", shape=circle, label="4"]; - n_13 [id="5", shape=circle, label="5"]; + n_10 [id="13", shape=circle, label="13"]; + n_11 [id="10", shape=circle, label="10"]; + n_12 [id="1", shape=circle, label="1"]; + n_0 -> n_12 [arrowhead=none]; + n_13 [id="9", shape=circle, label="9"]; n_14 [id="2", shape=circle, label="2"]; - n_15 [id="14", shape=circle, label="14"]; - n_16 [id="7", shape=circle, label="7"]; - n_17 [id="1", shape=circle, label="1"]; - n_0 -> n_17 [arrowhead=none]; - n_18 [id="12", shape=circle, label="12"]; - n_19 [id="8", shape=circle, label="8"]; + n_15 [id="8", shape=circle, label="8"]; + n_16 [id="4", shape=circle, label="4"]; + n_17 [id="7", shape=circle, label="7"]; + n_18 [id="3", shape=circle, label="3"]; + n_19 [id="16", shape=circle, label="16"]; - n_2 -> n_11 [id="[$e|14]", label="test→w2_0:w2"]; - n_1 -> n_8 [id="[$e|15]", label="test→r_0:r0"]; - n_14 -> n_4 [id="[$e|1]", label="testΔw1_0"]; - n_13 -> n_7 [id="[$e|7]", label="test→w2_0:w2"]; - n_12 -> n_9 [id="[$e|4]", label="test→w1_0:w1"]; - n_19 -> n_15 [id="[$e|12]", label="test→w2_0:w2"]; - n_16 -> n_6 [id="[$e|11]", label="test→w1_0:w1"]; - n_12 -> n_13 [id="[$e|3]", label="test→r_0:r0"]; - n_6 -> n_5 [id="[$e|17]", label="test→r_0:r0"]; - n_12 -> n_16 [id="[$e|5]", label="test→w2_0:w2"]; - n_9 -> n_2 [id="[$e|8]", label="test→r_0:r0"]; - n_18 -> n_3 [id="[$e|16]", label="test→w1_0:w1"]; - n_17 -> n_14 [id="[$e|0]", label="testΔr_0"]; - n_13 -> n_19 [id="[$e|6]", label="test→w1_0:w1"]; - n_4 -> n_12 [id="[$e|2]", label="testΔw2_0"]; - n_9 -> n_1 [id="[$e|9]", label="test→w2_0:w2"]; - n_16 -> n_18 [id="[$e|10]", label="test→r_0:r0"]; - n_7 -> n_10 [id="[$e|13]", label="test→w1_0:w1"]; + n_9 -> n_11 [id="[$e|8]", label="test→r_0:r0"]; + n_13 -> n_2 [id="[$e|13]", label="test→w1_0:w1"]; + n_11 -> n_19 [id="[$e|14]", label="test→w2_0:w2"]; + n_16 -> n_9 [id="[$e|4]", label="test→w1_0:w1"]; + n_17 -> n_4 [id="[$e|10]", label="test→r_0:r0"]; + n_10 -> n_3 [id="[$e|17]", label="test→r_0:r0"]; + n_16 -> n_1 [id="[$e|3]", label="test→r_0:r0"]; + n_5 -> n_6 [id="[$e|15]", label="test→r_0:r0"]; + n_1 -> n_13 [id="[$e|7]", label="test→w2_0:w2"]; + n_9 -> n_5 [id="[$e|9]", label="test→w2_0:w2"]; + n_4 -> n_7 [id="[$e|16]", label="test→w1_0:w1"]; + n_16 -> n_17 [id="[$e|5]", label="test→w2_0:w2"]; + n_12 -> n_14 [id="[$e|0]", label="testΔr_0"]; + n_1 -> n_15 [id="[$e|6]", label="test→w1_0:w1"]; + n_14 -> n_18 [id="[$e|1]", label="testΔw1_0"]; + n_17 -> n_10 [id="[$e|11]", label="test→w1_0:w1"]; + n_18 -> n_16 [id="[$e|2]", label="testΔw2_0"]; + n_15 -> n_8 [id="[$e|12]", label="test→w2_0:w2"]; } diff --git a/examples/test/foo4/test_local_view.dot b/examples/test/foo4/test_local_view.dot index fe4f861..21b9196 100644 --- a/examples/test/foo4/test_local_view.dot +++ b/examples/test/foo4/test_local_view.dot @@ -1,19 +1,19 @@ digraph test { rankdir="LR"; n_0 [label="test", shape="plaintext"]; - n_1 [id="3", shape=circle, label="3"]; + n_1 [id="5", shape=doublecircle, label="7"]; n_2 [id="6", shape=circle, label="6"]; - n_3 [id="4", shape=circle, label="5"]; - n_4 [id="5", shape=circle, label="7"]; - n_5 [id="2", shape=circle, label="2"]; + n_3 [id="1", shape=circle, label="1"]; + n_0 -> n_3 [arrowhead=none]; + n_4 [id="2", shape=circle, label="2"]; + n_5 [id="4", shape=circle, label="5"]; n_6 [id="7", shape=circle, label="4"]; - n_7 [id="1", shape=circle, label="1"]; - n_0 -> n_7 [arrowhead=none]; + n_7 [id="3", shape=circle, label="3"]; - n_7 -> n_5 [id="[$e|1]", label="spawn r_0"]; - n_3 -> n_2 [id="[$e|4]", label="send w1 to w1_0"]; - n_2 -> n_4 [id="[$e|3]", label="send w2 to w2_0"]; - n_1 -> n_6 [id="[$e|5]", label="spawn w1_0"]; - n_6 -> n_3 [id="[$e|0]", label="spawn w2_0"]; - n_5 -> n_1 [id="[$e|2]", label="send r0 to r_0"]; + n_5 -> n_2 [id="[$e|4]", label="send w1 to w1_0"]; + n_2 -> n_1 [id="[$e|3]", label="send w2 to w2_0"]; + n_7 -> n_6 [id="[$e|5]", label="spawn w1_0"]; + n_6 -> n_5 [id="[$e|0]", label="spawn w2_0"]; + n_3 -> n_4 [id="[$e|1]", label="spawn r_0"]; + n_4 -> n_7 [id="[$e|2]", label="send r0 to r_0"]; } diff --git a/examples/test/foo4/w1_local_view.dot b/examples/test/foo4/w1_local_view.dot index 3d83460..5d925b0 100644 --- a/examples/test/foo4/w1_local_view.dot +++ b/examples/test/foo4/w1_local_view.dot @@ -1,11 +1,11 @@ digraph w1 { rankdir="LR"; n_0 [label="w1", shape="plaintext"]; - n_1 [id="3", shape=circle, label="3"]; + n_1 [id="1", shape=circle, label="1"]; + n_0 -> n_1 [arrowhead=none]; n_2 [id="2", shape=circle, label="2"]; - n_3 [id="1", shape=circle, label="1"]; - n_0 -> n_3 [arrowhead=none]; + n_3 [id="3", shape=doublecircle, label="3"]; - n_2 -> n_1 [id="[$e|1]", label="send r1 to Reg"]; - n_3 -> n_2 [id="[$e|0]", label="receive _X"]; + n_2 -> n_3 [id="[$e|0]", label="send r1 to Reg"]; + n_1 -> n_2 [id="[$e|1]", label="receive _X"]; } diff --git a/examples/test/foo4/w2_local_view.dot b/examples/test/foo4/w2_local_view.dot index 5c5ccf3..ac37aca 100644 --- a/examples/test/foo4/w2_local_view.dot +++ b/examples/test/foo4/w2_local_view.dot @@ -1,11 +1,11 @@ digraph w2 { rankdir="LR"; n_0 [label="w2", shape="plaintext"]; - n_1 [id="3", shape=circle, label="3"]; + n_1 [id="1", shape=circle, label="1"]; + n_0 -> n_1 [arrowhead=none]; n_2 [id="2", shape=circle, label="2"]; - n_3 [id="1", shape=circle, label="1"]; - n_0 -> n_3 [arrowhead=none]; + n_3 [id="3", shape=doublecircle, label="3"]; - n_2 -> n_1 [id="[$e|1]", label="send r2 to Reg"]; - n_3 -> n_2 [id="[$e|0]", label="receive _X"]; + n_2 -> n_3 [id="[$e|0]", label="send r2 to Reg"]; + n_1 -> n_2 [id="[$e|1]", label="receive _X"]; } diff --git a/examples/test/foo5/proxy_local_view.dot b/examples/test/foo5/proxy_local_view.dot index 8a48013..00b4e0e 100644 --- a/examples/test/foo5/proxy_local_view.dot +++ b/examples/test/foo5/proxy_local_view.dot @@ -1,11 +1,11 @@ digraph proxy { rankdir="LR"; n_0 [label="proxy", shape="plaintext"]; - n_1 [id="3", shape=circle, label="3"]; + n_1 [id="1", shape=circle, label="1"]; + n_0 -> n_1 [arrowhead=none]; n_2 [id="2", shape=circle, label="2"]; - n_3 [id="1", shape=circle, label="1"]; - n_0 -> n_3 [arrowhead=none]; + n_3 [id="3", shape=doublecircle, label="3"]; - n_3 -> n_2 [id="[$e|1]", label="receive M"]; - n_2 -> n_1 [id="[$e|0]", label="send M to Target"]; + n_1 -> n_2 [id="[$e|1]", label="receive M"]; + n_2 -> n_3 [id="[$e|0]", label="send M to Target"]; } diff --git a/examples/test/foo5/target_local_view.dot b/examples/test/foo5/target_local_view.dot index fb2b378..80fdb5d 100644 --- a/examples/test/foo5/target_local_view.dot +++ b/examples/test/foo5/target_local_view.dot @@ -1,15 +1,15 @@ digraph target { rankdir="LR"; n_0 [label="target", shape="plaintext"]; - n_1 [id="3", shape=circle, label="4"]; - n_2 [id="4", shape=circle, label="2"]; - n_3 [id="5", shape=circle, label="5"]; - n_4 [id="2", shape=circle, label="3"]; - n_5 [id="1", shape=circle, label="1"]; - n_0 -> n_5 [arrowhead=none]; + n_1 [id="5", shape=circle, label="2"]; + n_2 [id="1", shape=circle, label="1"]; + n_0 -> n_2 [arrowhead=none]; + n_3 [id="2", shape=doublecircle, label="5"]; + n_4 [id="4", shape=circle, label="3"]; + n_5 [id="3", shape=circle, label="4"]; - n_2 -> n_4 [id="[$e|1]", label="receive B"]; - n_5 -> n_2 [id="[$e|3]", label="receive A"]; - n_4 -> n_1 [id="[$e|0]", label="receive C"]; - n_1 -> n_3 [id="[$e|2]", label="receive D"]; + n_1 -> n_4 [id="[$e|2]", label="receive B"]; + n_4 -> n_5 [id="[$e|3]", label="receive C"]; + n_5 -> n_3 [id="[$e|1]", label="receive D"]; + n_2 -> n_1 [id="[$e|0]", label="receive A"]; } diff --git a/examples/test/foo5/test_global_view.dot b/examples/test/foo5/test_global_view.dot index 2f5b2fe..ec9f4b6 100644 --- a/examples/test/foo5/test_global_view.dot +++ b/examples/test/foo5/test_global_view.dot @@ -1,19 +1,19 @@ digraph global { rankdir="LR"; n_0 [label="global", shape="plaintext"]; - n_1 [id="3", shape=circle, label="3"]; + n_1 [id="5", shape=circle, label="5"]; n_2 [id="6", shape=circle, label="6"]; - n_3 [id="4", shape=circle, label="4"]; - n_4 [id="5", shape=circle, label="5"]; - n_5 [id="2", shape=circle, label="2"]; + n_3 [id="1", shape=circle, label="1"]; + n_0 -> n_3 [arrowhead=none]; + n_4 [id="2", shape=circle, label="2"]; + n_5 [id="4", shape=circle, label="4"]; n_6 [id="7", shape=circle, label="7"]; - n_7 [id="1", shape=circle, label="1"]; - n_0 -> n_7 [arrowhead=none]; + n_7 [id="3", shape=circle, label="3"]; - n_5 -> n_1 [id="[$e|1]", label="testΔproxy_1"]; - n_3 -> n_2 [id="[$e|4]", label="test→proxy_1:m3"]; - n_1 -> n_4 [id="[$e|3]", label="test→proxy_1:m3"]; - n_4 -> n_6 [id="[$e|5]", label="test→proxy_0:m2"]; - n_7 -> n_5 [id="[$e|0]", label="testΔproxy_0"]; - n_1 -> n_3 [id="[$e|2]", label="test→proxy_0:m2"]; + n_5 -> n_2 [id="[$e|4]", label="test→proxy_1:m3"]; + n_7 -> n_5 [id="[$e|2]", label="test→proxy_0:m2"]; + n_7 -> n_1 [id="[$e|3]", label="test→proxy_1:m3"]; + n_4 -> n_7 [id="[$e|1]", label="testΔproxy_1"]; + n_1 -> n_6 [id="[$e|5]", label="test→proxy_0:m2"]; + n_3 -> n_4 [id="[$e|0]", label="testΔproxy_0"]; } diff --git a/examples/test/foo5/test_local_view.dot b/examples/test/foo5/test_local_view.dot index bc98d1c..70a411b 100644 --- a/examples/test/foo5/test_local_view.dot +++ b/examples/test/foo5/test_local_view.dot @@ -1,21 +1,21 @@ digraph test { rankdir="LR"; n_0 [label="test", shape="plaintext"]; - n_1 [id="3", shape=circle, label="3"]; - n_2 [id="6", shape=circle, label="8"]; - n_3 [id="4", shape=circle, label="5"]; - n_4 [id="5", shape=circle, label="7"]; - n_5 [id="2", shape=circle, label="2"]; - n_6 [id="7", shape=circle, label="6"]; - n_7 [id="1", shape=circle, label="1"]; - n_0 -> n_7 [arrowhead=none]; - n_8 [id="8", shape=circle, label="4"]; + n_1 [id="5", shape=circle, label="7"]; + n_2 [id="6", shape=doublecircle, label="8"]; + n_3 [id="1", shape=circle, label="1"]; + n_0 -> n_3 [arrowhead=none]; + n_4 [id="2", shape=circle, label="2"]; + n_5 [id="8", shape=circle, label="4"]; + n_6 [id="4", shape=circle, label="5"]; + n_7 [id="7", shape=circle, label="6"]; + n_8 [id="3", shape=circle, label="3"]; - n_8 -> n_3 [id="[$e|1]", label="send m1 to target_0"]; - n_7 -> n_5 [id="[$e|4]", label="spawn target_0"]; - n_4 -> n_2 [id="[$e|3]", label="send m4 to target_0"]; - n_3 -> n_6 [id="[$e|5]", label="send m2 to proxy_0"]; - n_1 -> n_8 [id="[$e|0]", label="spawn proxy_1"]; - n_5 -> n_1 [id="[$e|6]", label="spawn proxy_0"]; - n_6 -> n_4 [id="[$e|2]", label="send m3 to proxy_1"]; + n_3 -> n_4 [id="[$e|4]", label="spawn target_0"]; + n_7 -> n_1 [id="[$e|2]", label="send m3 to proxy_1"]; + n_1 -> n_2 [id="[$e|3]", label="send m4 to target_0"]; + n_5 -> n_6 [id="[$e|1]", label="send m1 to target_0"]; + n_6 -> n_7 [id="[$e|5]", label="send m2 to proxy_0"]; + n_4 -> n_8 [id="[$e|6]", label="spawn proxy_0"]; + n_8 -> n_5 [id="[$e|0]", label="spawn proxy_1"]; } diff --git a/examples/test/ping/ping_local_view.dot b/examples/test/ping/ping_local_view.dot index aa2dce4..e341d42 100644 --- a/examples/test/ping/ping_local_view.dot +++ b/examples/test/ping/ping_local_view.dot @@ -3,10 +3,10 @@ digraph ping { n_0 [label="ping", shape="plaintext"]; n_1 [id="1", shape=circle, label="1"]; n_0 -> n_1 [arrowhead=none]; - n_2 [id="2", shape=circle, label="3"]; + n_2 [id="2", shape=doublecircle, label="3"]; n_3 [id="3", shape=circle, label="2"]; - n_1 -> n_3 [id="[$e|1]", label="receive N"]; - n_3 -> n_1 [id="[$e|5]", label="send {pid_self,any} to Pong"]; - n_1 -> n_2 [id="[$e|3]", label="receive kill"]; + n_1 -> n_2 [id="[$e|1]", label="receive kill"]; + n_3 -> n_1 [id="[$e|5]", label="send {pid_self,pid_self} to Pong"]; + n_1 -> n_3 [id="[$e|2]", label="receive N"]; } diff --git a/examples/test/ping/pong_local_view.dot b/examples/test/ping/pong_local_view.dot index f01cfc0..8f7be1c 100644 --- a/examples/test/ping/pong_local_view.dot +++ b/examples/test/ping/pong_local_view.dot @@ -4,11 +4,11 @@ digraph pong { n_1 [id="5", shape=circle, label="3"]; n_2 [id="1", shape=circle, label="1"]; n_0 -> n_2 [arrowhead=none]; - n_3 [id="2", shape=circle, label="2"]; - n_4 [id="3", shape=circle, label="4"]; + n_3 [id="2", shape=doublecircle, label="4"]; + n_4 [id="3", shape=circle, label="2"]; - n_1 -> n_2 [id="[$e|6]", label="send any to S"]; - n_2 -> n_3 [id="[$e|3]", label="receive {S,0}"]; + n_1 -> n_2 [id="[$e|6]", label="send N to S"]; + n_2 -> n_4 [id="[$e|5]", label="receive {S,0}"]; n_2 -> n_1 [id="[$e|4]", label="receive {S,N}"]; - n_3 -> n_4 [id="[$e|2]", label="send kill to S"]; + n_4 -> n_3 [id="[$e|2]", label="send kill to S"]; } diff --git a/examples/test/ping/start_local_view.dot b/examples/test/ping/start_local_view.dot index 7142cd4..00acece 100644 --- a/examples/test/ping/start_local_view.dot +++ b/examples/test/ping/start_local_view.dot @@ -1,16 +1,16 @@ digraph start { rankdir="LR"; n_0 [label="start", shape="plaintext"]; - n_1 [id="5", shape=circle, label="5"]; - n_2 [id="1", shape=circle, label="1"]; - n_0 -> n_2 [arrowhead=none]; - n_3 [id="2", shape=circle, label="2"]; - n_4 [id="4", shape=circle, label="3"]; - n_5 [id="3", shape=circle, label="4"]; + n_1 [id="5", shape=doublecircle, label="5"]; + n_2 [id="6", shape=circle, label="4"]; + n_3 [id="1", shape=circle, label="1"]; + n_0 -> n_3 [arrowhead=none]; + n_4 [id="2", shape=circle, label="2"]; + n_5 [id="3", shape=circle, label="3"]; - n_4 -> n_5 [id="[$e|1]", label="receive N"]; - n_2 -> n_3 [id="[$e|6]", label="spawn pong_0"]; - n_5 -> n_4 [id="[$e|5]", label="send {pid_self,any} to Pong"]; - n_4 -> n_1 [id="[$e|3]", label="receive kill"]; - n_3 -> n_4 [id="[$e|7]", label="send 3 to start"]; + n_5 -> n_2 [id="[$e|1]", label="receive N"]; + n_3 -> n_4 [id="[$e|6]", label="spawn pong_0"]; + n_2 -> n_5 [id="[$e|5]", label="send {pid_self,pid_self} to pong_0"]; + n_5 -> n_1 [id="[$e|4]", label="receive kill"]; + n_4 -> n_5 [id="[$e|7]", label="send 3 to S"]; } diff --git a/examples/ticktackloop/start_global_view.dot b/examples/ticktackloop/start_global_view.dot new file mode 100644 index 0000000..6c1b0fb --- /dev/null +++ b/examples/ticktackloop/start_global_view.dot @@ -0,0 +1,16 @@ +digraph global { + rankdir="LR"; + n_0 [label="global", shape="plaintext"]; + n_1 [id="5", shape=circle, label="5"]; + n_2 [id="1", shape=circle, label="1"]; + n_0 -> n_2 [arrowhead=none]; + n_3 [id="2", shape=circle, label="2"]; + n_4 [id="4", shape=circle, label="4"]; + n_5 [id="3", shape=circle, label="3"]; + + n_4 -> n_1 [id="[$e|3]", label="tic_loop_0→tac_loop_0:tic"]; + n_2 -> n_3 [id="[$e|0]", label="startΔtac_loop_0"]; + n_1 -> n_4 [id="[$e|4]", label="tac_loop_0→tic_loop_0:tac"]; + n_3 -> n_5 [id="[$e|1]", label="startΔtic_loop_0"]; + n_5 -> n_4 [id="[$e|2]", label="start→tic_loop_0:tac"]; +} diff --git a/examples/ticktackloop/start_local_view.dot b/examples/ticktackloop/start_local_view.dot new file mode 100644 index 0000000..bc84e40 --- /dev/null +++ b/examples/ticktackloop/start_local_view.dot @@ -0,0 +1,13 @@ +digraph start { + rankdir="LR"; + n_0 [label="start", shape="plaintext"]; + n_1 [id="1", shape=circle, label="1"]; + n_0 -> n_1 [arrowhead=none]; + n_2 [id="2", shape=circle, label="2"]; + n_3 [id="4", shape=circle, label="3"]; + n_4 [id="3", shape=doublecircle, label="4"]; + + n_3 -> n_4 [id="[$e|0]", label="send tac to tic_loop_0"]; + n_2 -> n_3 [id="[$e|1]", label="spawn tic_loop_0"]; + n_1 -> n_2 [id="[$e|2]", label="spawn tac_loop_0"]; +} diff --git a/examples/ticktackloop/tac_loop_local_view.dot b/examples/ticktackloop/tac_loop_local_view.dot new file mode 100644 index 0000000..1b9c166 --- /dev/null +++ b/examples/ticktackloop/tac_loop_local_view.dot @@ -0,0 +1,14 @@ +digraph tac_loop { + rankdir="LR"; + n_0 [label="tac_loop", shape="plaintext"]; + n_1 [id="1", shape=circle, label="1"]; + n_0 -> n_1 [arrowhead=none]; + n_2 [id="2", shape=circle, label="2"]; + n_3 [id="4", shape=circle, label="3"]; + n_4 [id="3", shape=doublecircle, label="4"]; + + n_1 -> n_2 [id="[$e|3]", label="receive tic"]; + n_1 -> n_3 [id="[$e|4]", label="receive stop"]; + n_3 -> n_4 [id="[$e|5]", label="send stop to tic_loop_0"]; + n_2 -> n_1 [id="[$e|6]", label="send tac to tic_loop_0"]; +} diff --git a/examples/ticktackloop/tic_loop_local_view.dot b/examples/ticktackloop/tic_loop_local_view.dot new file mode 100644 index 0000000..9026d6a --- /dev/null +++ b/examples/ticktackloop/tic_loop_local_view.dot @@ -0,0 +1,14 @@ +digraph tic_loop { + rankdir="LR"; + n_0 [label="tic_loop", shape="plaintext"]; + n_1 [id="1", shape=circle, label="1"]; + n_0 -> n_1 [arrowhead=none]; + n_2 [id="2", shape=circle, label="2"]; + n_3 [id="4", shape=circle, label="3"]; + n_4 [id="3", shape=doublecircle, label="4"]; + + n_3 -> n_4 [id="[$e|3]", label="send stop to tac_loop_0"]; + n_1 -> n_3 [id="[$e|4]", label="receive stop"]; + n_1 -> n_2 [id="[$e|1]", label="receive tac"]; + n_2 -> n_1 [id="[$e|6]", label="send tic to tac_loop_0"]; +} diff --git a/examples/ticktack/tictacloop.erl b/examples/ticktackloop/tictacloop.erl similarity index 100% rename from examples/ticktack/tictacloop.erl rename to examples/ticktackloop/tictacloop.erl diff --git a/examples/ticktack/random_local_view.dot b/examples/ticktackstop/random_local_view.dot similarity index 100% rename from examples/ticktack/random_local_view.dot rename to examples/ticktackstop/random_local_view.dot diff --git a/examples/ticktack/start_global_view.dot b/examples/ticktackstop/start_global_view.dot similarity index 100% rename from examples/ticktack/start_global_view.dot rename to examples/ticktackstop/start_global_view.dot index 49a4946..fd3f5e9 100644 --- a/examples/ticktack/start_global_view.dot +++ b/examples/ticktackstop/start_global_view.dot @@ -17,17 +17,17 @@ digraph global { n_13 [id="7", shape=circle, label="7"]; n_14 [id="3", shape=circle, label="3"]; - n_5 -> n_9 [id="[$e|7]", label="tic_loop_0→tac_loop_0:stop"]; - n_8 -> n_10 [id="[$e|0]", label="startΔtac_loop_0"]; + n_14 -> n_12 [id="[$e|2]", label="startΔrandom_0"]; n_10 -> n_14 [id="[$e|1]", label="startΔtic_loop_0"]; - n_3 -> n_4 [id="[$e|12]", label="tic_loop_0→tac_loop_0:stop"]; + n_13 -> n_7 [id="[$e|8]", label="random_0→tic_loop_0:stop"]; + n_5 -> n_9 [id="[$e|7]", label="tic_loop_0→tac_loop_0:stop"]; n_12 -> n_5 [id="[$e|4]", label="random_0→tic_loop_0:stop"]; - n_14 -> n_12 [id="[$e|2]", label="startΔrandom_0"]; - n_11 -> n_3 [id="[$e|9]", label="tic_loop_0→tac_loop_0:tic"]; n_7 -> n_6 [id="[$e|11]", label="tic_loop_0→tac_loop_0:stop"]; - n_13 -> n_7 [id="[$e|8]", label="random_0→tic_loop_0:stop"]; - n_12 -> n_1 [id="[$e|3]", label="start→tic_loop_0:tac"]; - n_1 -> n_11 [id="[$e|6]", label="random_0→tic_loop_0:stop"]; n_1 -> n_13 [id="[$e|5]", label="tic_loop_0→tac_loop_0:tic"]; n_11 -> n_2 [id="[$e|10]", label="tic_loop_0→tac_loop_0:stop"]; + n_11 -> n_3 [id="[$e|9]", label="tic_loop_0→tac_loop_0:tic"]; + n_3 -> n_4 [id="[$e|12]", label="tic_loop_0→tac_loop_0:stop"]; + n_12 -> n_1 [id="[$e|3]", label="start→tic_loop_0:tac"]; + n_8 -> n_10 [id="[$e|0]", label="startΔtac_loop_0"]; + n_1 -> n_11 [id="[$e|6]", label="random_0→tic_loop_0:stop"]; } diff --git a/examples/ticktack/start_local_view.dot b/examples/ticktackstop/start_local_view.dot similarity index 100% rename from examples/ticktack/start_local_view.dot rename to examples/ticktackstop/start_local_view.dot index 5ec9ceb..75290d4 100644 --- a/examples/ticktack/start_local_view.dot +++ b/examples/ticktackstop/start_local_view.dot @@ -8,8 +8,8 @@ digraph start { n_4 [id="4", shape=doublecircle, label="5"]; n_5 [id="3", shape=circle, label="3"]; - n_1 -> n_4 [id="[$e|0]", label="send tac to tic_loop_0"]; - n_5 -> n_1 [id="[$e|1]", label="spawn random_0"]; n_3 -> n_5 [id="[$e|2]", label="spawn tic_loop_0"]; + n_5 -> n_1 [id="[$e|1]", label="spawn random_0"]; n_2 -> n_3 [id="[$e|3]", label="spawn tac_loop_0"]; + n_1 -> n_4 [id="[$e|0]", label="send tac to tic_loop_0"]; } diff --git a/examples/ticktack/tac_loop_local_view.dot b/examples/ticktackstop/tac_loop_local_view.dot similarity index 100% rename from examples/ticktack/tac_loop_local_view.dot rename to examples/ticktackstop/tac_loop_local_view.dot index c13f774..7fb8451 100644 --- a/examples/ticktack/tac_loop_local_view.dot +++ b/examples/ticktackstop/tac_loop_local_view.dot @@ -6,9 +6,9 @@ digraph tac_loop { n_2 [id="4", shape=circle, label="3"]; n_3 [id="3", shape=doublecircle, label="2"]; + n_2 -> n_2 [id="[$e|2]", label="receive tic"]; n_2 -> n_1 [id="[$e|7]", label="send tac to tic_loop_0"]; n_1 -> n_3 [id="[$e|4]", label="receive stop"]; - n_2 -> n_2 [id="[$e|2]", label="receive tic"]; - n_2 -> n_3 [id="[$e|3]", label="receive stop"]; n_1 -> n_2 [id="[$e|5]", label="receive tic"]; + n_2 -> n_3 [id="[$e|3]", label="receive stop"]; } diff --git a/examples/ticktack/tic_loop_local_view.dot b/examples/ticktackstop/tic_loop_local_view.dot similarity index 100% rename from examples/ticktack/tic_loop_local_view.dot rename to examples/ticktackstop/tic_loop_local_view.dot diff --git a/examples/ticktack/tictacstop.erl b/examples/ticktackstop/tictacstop.erl similarity index 100% rename from examples/ticktack/tictacstop.erl rename to examples/ticktackstop/tictacstop.erl diff --git a/examples/trick/a_local_view.dot b/examples/trick/a_local_view.dot index a93155d..7137d2c 100644 --- a/examples/trick/a_local_view.dot +++ b/examples/trick/a_local_view.dot @@ -6,6 +6,6 @@ digraph a { n_2 [id="2", shape=circle, label="2"]; n_3 [id="3", shape=doublecircle, label="3"]; - n_2 -> n_3 [id="[$e|1]", label="send v2 to b_0"]; n_1 -> n_2 [id="[$e|0]", label="send v1 to c_0"]; + n_2 -> n_3 [id="[$e|1]", label="send v2 to b_0"]; } diff --git a/examples/trick/b_local_view.dot b/examples/trick/b_local_view.dot index 5bf7ada..e83cc13 100644 --- a/examples/trick/b_local_view.dot +++ b/examples/trick/b_local_view.dot @@ -6,6 +6,6 @@ digraph b { n_2 [id="2", shape=circle, label="2"]; n_3 [id="3", shape=doublecircle, label="3"]; - n_2 -> n_3 [id="[$e|1]", label="send v2 to c_0"]; n_1 -> n_2 [id="[$e|0]", label="receive v2"]; + n_2 -> n_3 [id="[$e|1]", label="send v2 to c_0"]; } diff --git a/examples/trick/c_local_view.dot b/examples/trick/c_local_view.dot index d63db2e..d6d64d8 100644 --- a/examples/trick/c_local_view.dot +++ b/examples/trick/c_local_view.dot @@ -6,6 +6,6 @@ digraph c { n_2 [id="2", shape=doublecircle, label="3"]; n_3 [id="3", shape=circle, label="2"]; - n_1 -> n_3 [id="[$e|1]", label="receive v1"]; n_3 -> n_2 [id="[$e|0]", label="receive v2"]; + n_1 -> n_3 [id="[$e|1]", label="receive v1"]; } diff --git a/examples/trick/main_global_view.dot b/examples/trick/main_global_view.dot index 597e103..1671522 100644 --- a/examples/trick/main_global_view.dot +++ b/examples/trick/main_global_view.dot @@ -14,12 +14,12 @@ digraph global { n_10 [id="3", shape=circle, label="3"]; n_8 -> n_1 [id="[$e|3]", label="a_0→b_0:v2"]; - n_6 -> n_10 [id="[$e|1]", label="mainΔb_0"]; n_4 -> n_6 [id="[$e|0]", label="mainΔa_0"]; - n_2 -> n_7 [id="[$e|6]", label="a_0→b_0:v2"]; + n_9 -> n_5 [id="[$e|7]", label="b_0→c_0:v2"]; + n_8 -> n_2 [id="[$e|4]", label="a_0→c_0:v1"]; n_1 -> n_9 [id="[$e|5]", label="a_0→c_0:v1"]; + n_6 -> n_10 [id="[$e|1]", label="mainΔb_0"]; n_7 -> n_3 [id="[$e|8]", label="b_0→c_0:v2"]; - n_8 -> n_2 [id="[$e|4]", label="a_0→c_0:v1"]; - n_9 -> n_5 [id="[$e|7]", label="b_0→c_0:v2"]; n_10 -> n_8 [id="[$e|2]", label="mainΔc_0"]; + n_2 -> n_7 [id="[$e|6]", label="a_0→b_0:v2"]; } diff --git a/examples/trick/main_local_view.dot b/examples/trick/main_local_view.dot index be634ad..f022386 100644 --- a/examples/trick/main_local_view.dot +++ b/examples/trick/main_local_view.dot @@ -7,7 +7,7 @@ digraph main { n_3 [id="4", shape=doublecircle, label="4"]; n_4 [id="3", shape=circle, label="3"]; - n_1 -> n_2 [id="[$e|1]", label="spawn a_0"]; n_4 -> n_3 [id="[$e|0]", label="spawn c_0"]; + n_1 -> n_2 [id="[$e|1]", label="spawn a_0"]; n_2 -> n_4 [id="[$e|2]", label="spawn b_0"]; } diff --git a/src/choreography/lv.erl b/src/choreography/lv.erl index 6b9544c..2bf6d3a 100644 --- a/src/choreography/lv.erl +++ b/src/choreography/lv.erl @@ -114,7 +114,7 @@ eval_pm_clause(Code, Vars, Data) -> case Exist of [] -> ets:insert(?ARGUMENTS, {FunName, Vars}); [{_, []}] -> ets:insert(?ARGUMENTS, {FunName, Vars}); - [{_, [_]}] -> done + _ -> done end, ND = case Vars =:= [] of @@ -419,12 +419,12 @@ eval_variable(VarName, Data) -> recordvar_to_string(Var) -> case Var#variable.type of - ?UNDEFINED -> + ?ANYDATA -> atol(Var#variable.name); Type -> SType = atol(Type), case Var#variable.value of - ?UNDEFINED -> + ?ANYDATA -> SType; Val -> case SType of diff --git a/test.sh b/test.sh index 5939711..8632c81 100755 --- a/test.sh +++ b/test.sh @@ -1,9 +1,22 @@ rebar3 escriptize ./_build/default/bin/chorer ./examples/hello/hello.erl greet examples/hello ./_build/default/bin/chorer ./examples/async/simple.erl main examples/async -./_build/default/bin/chorer ./examples/ticktack/tictacstop.erl start examples/ticktack +./_build/default/bin/chorer ./examples/ticktackstop/tictacstop.erl start examples/ticktackstop +./_build/default/bin/chorer ./examples/ticktackloop/tictacloop.erl start examples/ticktackloop ./_build/default/bin/chorer ./examples/customer/customer.erl main examples/customer ./_build/default/bin/chorer ./examples/serverclient/serverclient.erl main examples/serverclient ./_build/default/bin/chorer ./examples/trick/trick.erl main examples/trick ./_build/default/bin/chorer ./examples/airline/airline.erl main examples/airline -./_build/default/bin/chorer ./examples/violation/meViolation.erl main examples/violation \ No newline at end of file +./_build/default/bin/chorer ./examples/conditional-case/conditional_case.erl main examples/conditional-case +./_build/default/bin/chorer ./examples/for-loop-recursion/forloop.erl main examples/for-loop-recursion +./_build/default/bin/chorer ./examples/function-call/funny.erl main examples/function-call +./_build/default/bin/chorer ./examples/high-order-fun/hof.erl greet examples/high-order-fun +./_build/default/bin/chorer ./examples/if-cases/ifcases.erl main examples/if-cases +./_build/default/bin/chorer ./examples/test/barber/barber.erl test examples/test/barber +./_build/default/bin/chorer ./examples/test/foo1/foo1.erl test examples/test/foo1 +./_build/default/bin/chorer ./examples/test/foo2/foo2.erl test examples/test/foo2 +./_build/default/bin/chorer ./examples/test/foo3/foo3.erl test examples/test/foo3 +./_build/default/bin/chorer ./examples/test/foo4/foo4.erl test examples/test/foo4 +./_build/default/bin/chorer ./examples/test/foo5/foo5.erl test examples/test/foo5 +./_build/default/bin/chorer ./examples/test/foo6/foo6.erl test examples/test/foo6 +./_build/default/bin/chorer ./examples/test/ping/ping.erl test examples/test/ping \ No newline at end of file From edf83ff77c3bf25b4815a1b5b59a4c0839a29dbe Mon Sep 17 00:00:00 2001 From: geno Date: Fri, 16 Feb 2024 21:44:27 +0100 Subject: [PATCH 08/11] fix: function arguments works --- examples/airline/agent1_local_view.dot | 10 + examples/airline/agent_local_view.dot | 10 - examples/airline/airline.erl | 2 + ...l_view.dot => correct_main_local_view.dot} | 8 +- examples/airline/main0_global_view.dot | 11 + examples/airline/main0_local_view.dot | 14 + examples/airline/main_global_view.dot | 27 - examples/test/foo6/client_gen_local_view.dot | 5 +- examples/test/foo6/client_local_view.dot | 2 +- .../test/foo6/client_server_local_view.dot | 11 +- examples/test/foo6/foo6.erl | 5 +- examples/test/foo6/test_global_view.dot | 22 +- examples/test/foo6/test_local_view.dot | 11 +- src/choreography/actor_emul.erl | 9 +- src/choreography/eval.erl | 485 ++++++++++++++ src/choreography/gv.erl | 97 +-- src/choreography/lv.erl | 619 ++---------------- src/choreography/md.erl | 7 +- src/chorer.erl | 2 +- src/share/common_data.hrl | 16 +- src/share/fsa.erl | 6 +- src/share/{common_fun.erl => share.erl} | 120 +++- 22 files changed, 755 insertions(+), 744 deletions(-) create mode 100644 examples/airline/agent1_local_view.dot delete mode 100644 examples/airline/agent_local_view.dot rename examples/airline/{main_local_view.dot => correct_main_local_view.dot} (55%) create mode 100644 examples/airline/main0_global_view.dot create mode 100644 examples/airline/main0_local_view.dot delete mode 100644 examples/airline/main_global_view.dot create mode 100644 src/choreography/eval.erl rename src/share/{common_fun.erl => share.erl} (51%) diff --git a/examples/airline/agent1_local_view.dot b/examples/airline/agent1_local_view.dot new file mode 100644 index 0000000..c7e1f9f --- /dev/null +++ b/examples/airline/agent1_local_view.dot @@ -0,0 +1,10 @@ +digraph agent1 { + rankdir="LR"; + n_0 [label="agent1", shape="plaintext"]; + n_1 [id="1", shape=circle, label="1"]; + n_0 -> n_1 [arrowhead=none]; + n_2 [id="2", shape=circle, label="2"]; + + n_1 -> n_2 [id="[$e|0]", label="send {sell,pid_self} to Pid2"]; + n_2 -> n_1 [id="[$e|3]", label="receive {booked,_}"]; +} diff --git a/examples/airline/agent_local_view.dot b/examples/airline/agent_local_view.dot deleted file mode 100644 index 9c04fa2..0000000 --- a/examples/airline/agent_local_view.dot +++ /dev/null @@ -1,10 +0,0 @@ -digraph agent { - rankdir="LR"; - n_0 [label="agent", shape="plaintext"]; - n_1 [id="1", shape=circle, label="1"]; - n_0 -> n_1 [arrowhead=none]; - n_2 [id="3", shape=circle, label="2"]; - - n_1 -> n_2 [id="[$e|1]", label="send {sell,pid_self} to Pid2"]; - n_2 -> n_1 [id="[$e|3]", label="receive {booked,_}"]; -} diff --git a/examples/airline/airline.erl b/examples/airline/airline.erl index 922ca05..b8be069 100644 --- a/examples/airline/airline.erl +++ b/examples/airline/airline.erl @@ -6,6 +6,8 @@ main() -> spawn(?MODULE, agent, [self()]), seats(3). +seats(0) -> + stop; seats(Num) -> receive {sell, Pid1} -> diff --git a/examples/airline/main_local_view.dot b/examples/airline/correct_main_local_view.dot similarity index 55% rename from examples/airline/main_local_view.dot rename to examples/airline/correct_main_local_view.dot index 98070fc..775507d 100644 --- a/examples/airline/main_local_view.dot +++ b/examples/airline/correct_main_local_view.dot @@ -6,9 +6,15 @@ digraph main { n_2 [id="2", shape=circle, label="3"]; n_3 [id="4", shape=circle, label="4"]; n_4 [id="3", shape=circle, label="2"]; + n_5 [id="3", shape=circle, label="5"]; + n_6 [id="3", shape=circle, label="6"]; + n_7 [id="3", shape=circle, label="7"]; n_1 -> n_4 [id="[$e|2]", label="spawn agent_0"]; - n_3 -> n_2 [id="[$e|1]", label="send {booked,3} to Pid1"]; + n_3 -> n_5 [id="[$e|1]", label="send {booked,2} to Pid1"]; + n_6 -> n_5 [id="[$e|1]", label="send {booked,?} to Pid1"]; n_2 -> n_3 [id="[$e|4]", label="receive {sell,Pid1}"]; + n_5 -> n_6 [id="[$e|4]", label="receive {sell,Pid1}"]; n_4 -> n_2 [id="[$e|5]", label="spawn agent_1"]; + n_5 -> n_7 [id="[$e|5]", label="epsilon"]; } diff --git a/examples/airline/main0_global_view.dot b/examples/airline/main0_global_view.dot new file mode 100644 index 0000000..03055e6 --- /dev/null +++ b/examples/airline/main0_global_view.dot @@ -0,0 +1,11 @@ +digraph global { + rankdir="LR"; + n_0 [label="global", shape="plaintext"]; + n_1 [id="1", shape=circle, label="1"]; + n_0 -> n_1 [arrowhead=none]; + n_2 [id="2", shape=circle, label="2"]; + n_3 [id="3", shape=circle, label="3"]; + + n_1 -> n_2 [id="[$e|0]", label="main0Δagent1_0"]; + n_2 -> n_3 [id="[$e|1]", label="main0Δagent1_1"]; +} diff --git a/examples/airline/main0_local_view.dot b/examples/airline/main0_local_view.dot new file mode 100644 index 0000000..147e1a6 --- /dev/null +++ b/examples/airline/main0_local_view.dot @@ -0,0 +1,14 @@ +digraph main0 { + rankdir="LR"; + n_0 [label="main0", shape="plaintext"]; + n_1 [id="5", shape=circle, label="4"]; + n_2 [id="1", shape=circle, label="1"]; + n_0 -> n_2 [arrowhead=none]; + n_3 [id="2", shape=doublecircle, label="3"]; + n_4 [id="4", shape=circle, label="2"]; + + n_1 -> n_3 [id="[$e|5]", label="send {booked,Num} to Pid1"]; + n_4 -> n_3 [id="[$e|3]", label="spawn agent1_1"]; + n_3 -> n_1 [id="[$e|2]", label="receive {sell,Pid1}"]; + n_2 -> n_4 [id="[$e|1]", label="spawn agent1_0"]; +} diff --git a/examples/airline/main_global_view.dot b/examples/airline/main_global_view.dot deleted file mode 100644 index a678dd4..0000000 --- a/examples/airline/main_global_view.dot +++ /dev/null @@ -1,27 +0,0 @@ -digraph global { - rankdir="LR"; - n_0 [label="global", shape="plaintext"]; - n_1 [id="5", shape=circle, label="5"]; - n_2 [id="6", shape=circle, label="6"]; - n_3 [id="1", shape=circle, label="1"]; - n_0 -> n_3 [arrowhead=none]; - n_4 [id="2", shape=circle, label="2"]; - n_5 [id="4", shape=circle, label="4"]; - n_6 [id="7", shape=circle, label="7"]; - n_7 [id="3", shape=circle, label="3"]; - - n_7 -> n_5 [id="[$e|2]", label="agent_0→main:{sell,pid_self}"]; - n_4 -> n_7 [id="[$e|1]", label="mainΔagent_1"]; - n_2 -> n_7 [id="[$e|8]", label="main→agent_0:{booked,3}"]; - n_1 -> n_7 [id="[$e|7]", label="main→agent_1:{booked,3}"]; - n_5 -> n_2 [id="[$e|4]", label="agent_1→main:{sell,pid_self}"]; - n_6 -> n_7 [id="[$e|11]", label="main→agent_1:{booked,3}"]; - n_5 -> n_7 [id="[$e|5]", label="main→agent_0:{booked,3}"]; - n_7 -> n_1 [id="[$e|13]", label="main→agent_0:{booked,3}"]; - n_6 -> n_1 [id="[$e|10]", label="main→agent_0:{booked,3}"]; - n_2 -> n_5 [id="[$e|9]", label="main→agent_1:{booked,3}"]; - n_7 -> n_5 [id="[$e|12]", label="main→agent_1:{booked,3}"]; - n_7 -> n_1 [id="[$e|3]", label="agent_1→main:{sell,pid_self}"]; - n_3 -> n_4 [id="[$e|0]", label="mainΔagent_0"]; - n_1 -> n_6 [id="[$e|6]", label="agent_0→main:{sell,pid_self}"]; -} diff --git a/examples/test/foo6/client_gen_local_view.dot b/examples/test/foo6/client_gen_local_view.dot index b26488a..c090476 100644 --- a/examples/test/foo6/client_gen_local_view.dot +++ b/examples/test/foo6/client_gen_local_view.dot @@ -4,7 +4,8 @@ digraph client_gen { n_1 [id="1", shape=circle, label="1"]; n_0 -> n_1 [arrowhead=none]; n_2 [id="2", shape=circle, label="2"]; + n_3 [id="3", shape=doublecircle, label="3"]; - n_1 -> n_1 [id="[$e|5]", label="spawn client_1"]; - n_1 -> n_2 [id="[$e|2]", label="spawn client_0"]; + n_1 -> n_2 [id="[$e|0]", label="spawn client_4"]; + n_2 -> n_3 [id="[$e|1]", label="spawn client_5"]; } diff --git a/examples/test/foo6/client_local_view.dot b/examples/test/foo6/client_local_view.dot index 50ae152..526e27e 100644 --- a/examples/test/foo6/client_local_view.dot +++ b/examples/test/foo6/client_local_view.dot @@ -3,7 +3,7 @@ digraph client { n_0 [label="client", shape="plaintext"]; n_1 [id="1", shape=circle, label="1"]; n_0 -> n_1 [arrowhead=none]; - n_2 [id="2", shape=circle, label="2"]; + n_2 [id="2", shape=doublecircle, label="2"]; n_1 -> n_2 [id="[$e|0]", label="send hello to S"]; } diff --git a/examples/test/foo6/client_server_local_view.dot b/examples/test/foo6/client_server_local_view.dot index 8ca755c..754261f 100644 --- a/examples/test/foo6/client_server_local_view.dot +++ b/examples/test/foo6/client_server_local_view.dot @@ -3,10 +3,11 @@ digraph client_server { n_0 [label="client_server", shape="plaintext"]; n_1 [id="1", shape=circle, label="1"]; n_0 -> n_1 [arrowhead=none]; - n_2 [id="2", shape=circle, label="2"]; - n_3 [id="3", shape=circle, label="3"]; + n_2 [id="2", shape=doublecircle, label="4"]; + n_3 [id="4", shape=circle, label="3"]; + n_4 [id="3", shape=circle, label="2"]; - n_2 -> n_2 [id="[$e|6]", label="spawn client_1"]; - n_1 -> n_2 [id="[$e|3]", label="spawn server_0"]; - n_2 -> n_3 [id="[$e|4]", label="spawn client_0"]; + n_1 -> n_4 [id="[$e|0]", label="spawn server_1"]; + n_4 -> n_3 [id="[$e|2]", label="spawn client_2"]; + n_3 -> n_2 [id="[$e|1]", label="spawn client_3"]; } diff --git a/examples/test/foo6/foo6.erl b/examples/test/foo6/foo6.erl index d03d148..1db24bc 100644 --- a/examples/test/foo6/foo6.erl +++ b/examples/test/foo6/foo6.erl @@ -16,9 +16,8 @@ server() -> client_gen(S,1) -> spawn(foo6,client,[S]); -client_gen(S,N) when N>1 -> - spawn(foo6,client,[S]), - client_gen(S,N-1). +client_gen(S,N) -> + spawn(foo6,client,[S]). client(S) -> S ! hello. \ No newline at end of file diff --git a/examples/test/foo6/test_global_view.dot b/examples/test/foo6/test_global_view.dot index ee6fc86..dac7721 100644 --- a/examples/test/foo6/test_global_view.dot +++ b/examples/test/foo6/test_global_view.dot @@ -1,19 +1,13 @@ digraph global { rankdir="LR"; n_0 [label="global", shape="plaintext"]; - n_1 [id="5", shape=circle, label="5"]; - n_2 [id="6", shape=circle, label="6"]; - n_3 [id="1", shape=circle, label="1"]; - n_0 -> n_3 [arrowhead=none]; - n_4 [id="2", shape=circle, label="2"]; - n_5 [id="4", shape=circle, label="4"]; - n_6 [id="7", shape=circle, label="7"]; - n_7 [id="3", shape=circle, label="3"]; + n_1 [id="1", shape=circle, label="1"]; + n_0 -> n_1 [arrowhead=none]; + n_2 [id="2", shape=circle, label="2"]; + n_3 [id="4", shape=circle, label="4"]; + n_4 [id="3", shape=circle, label="3"]; - n_4 -> n_7 [id="[$e|1]", label="testΔclient_1"]; - n_1 -> n_6 [id="[$e|5]", label="testΔclient_0"]; - n_7 -> n_1 [id="[$e|3]", label="testΔclient_1"]; - n_7 -> n_2 [id="[$e|4]", label="testΔclient_0"]; - n_3 -> n_4 [id="[$e|0]", label="testΔserver_0"]; - n_4 -> n_5 [id="[$e|2]", label="testΔclient_0"]; + n_1 -> n_2 [id="[$e|0]", label="testΔserver_0"]; + n_4 -> n_3 [id="[$e|2]", label="testΔclient_1"]; + n_2 -> n_4 [id="[$e|1]", label="testΔclient_0"]; } diff --git a/examples/test/foo6/test_local_view.dot b/examples/test/foo6/test_local_view.dot index e52e21a..8a633ed 100644 --- a/examples/test/foo6/test_local_view.dot +++ b/examples/test/foo6/test_local_view.dot @@ -3,10 +3,11 @@ digraph test { n_0 [label="test", shape="plaintext"]; n_1 [id="1", shape=circle, label="1"]; n_0 -> n_1 [arrowhead=none]; - n_2 [id="2", shape=circle, label="2"]; - n_3 [id="3", shape=circle, label="3"]; + n_2 [id="2", shape=doublecircle, label="4"]; + n_3 [id="4", shape=circle, label="2"]; + n_4 [id="3", shape=circle, label="3"]; - n_1 -> n_2 [id="[$e|5]", label="spawn server_0"]; - n_2 -> n_3 [id="[$e|3]", label="spawn client_0"]; - n_2 -> n_2 [id="[$e|2]", label="spawn client_1"]; + n_1 -> n_3 [id="[$e|0]", label="spawn server_0"]; + n_3 -> n_4 [id="[$e|2]", label="spawn client_0"]; + n_4 -> n_2 [id="[$e|1]", label="spawn client_1"]; } diff --git a/src/choreography/actor_emul.erl b/src/choreography/actor_emul.erl index 33f094f..ec3dd7a 100644 --- a/src/choreography/actor_emul.erl +++ b/src/choreography/actor_emul.erl @@ -43,7 +43,8 @@ send_recv(P, Data) -> proc_loop(Data) -> ProcName = Data#actor_info.proc_id, - LV = common_fun:get_localview(ProcName), + % io:fwrite("[EMUL] ID ~p~n", [ProcName]), + LV = share:get_localview(share:atol(ProcName)), G = LV#wip_lv.graph, % timer:sleep(200), VCurr = Data#actor_info.current_state, @@ -62,7 +63,7 @@ proc_loop(Data) -> NewL = case ToLabel =< FromLabel of true -> - % io:fwrite("[PROC LOOP] RESET LOCALV IN ~p~n", [ProcName]), + % io:fwrite("[EMUL] RESET LOCALV IN ~p~n", [ProcName]), sets:new(); false -> LocalVars @@ -78,7 +79,7 @@ proc_loop(Data) -> NewL = case ToLabel =< FromLabel of true -> - % io:fwrite("[PROC LOOP] RESET LOCALV IN ~p~n", [ProcName]), + % io:fwrite("[EMUL] RESET LOCALV IN ~p~n", [ProcName]), sets:new(); false -> LocalVars @@ -89,7 +90,7 @@ proc_loop(Data) -> local_vars = NewL }); _ -> - io:fwrite("[PROC LOOP] V ~p Edge ~p non trovato in ~p~n", [VCurr, E, ProcName]), + io:fwrite("[EMUL] V ~p Edge ~p non trovato in ~p~n", [VCurr, E, ProcName]), proc_loop(Data) end; {P, get_edges} -> diff --git a/src/choreography/eval.erl b/src/choreography/eval.erl new file mode 100644 index 0000000..eff2a67 --- /dev/null +++ b/src/choreography/eval.erl @@ -0,0 +1,485 @@ +-module(eval). +-include("../share/common_data.hrl"). + +%%% API +-export([ + function_list/2, + clause/5, + match/3, + case_pm/3, + if_pm/2, + receive_pm/2, + operation/4, + function_call/3, + anon_fun/3, + simple_type/3, + atom/2, + list/3, + map/2, + tuple/2, + variable/2 +]). + +%%%=================================================================== +%%% API +%%%=================================================================== + +function_list(ContList, Data) -> + lists:foreach( + fun(FunctionBody) -> + case FunctionBody of + {clause, _, Vars, Guard, Content} -> clause(Content, Vars, Guard, Data, "arg"); + C -> share:warning("should be a clause but it's", C, ?UNDEFINED) + end + end, + ContList + ), + Data. + +clause(Code, Vars, Guards, Data, BaseLabel) -> + % io:fwrite("[CLAUSE] Code ~p~n Vars ~p~n Guards ~p~n", [Code, Vars, Guards]), + LocalV = Data#wip_lv.local_vars, + TempData = lv:eval_codeline(Vars, Data), + % should always be a list + EvalVarList = TempData#wip_lv.ret_var, + TempLabel = BaseLabel ++ " " ++ var_to_string(EvalVarList) ++ guards_to_string(Guards), + FinalLabel = decide_label(BaseLabel, TempLabel, Data), + NewData = share:add_vertex_edge(FinalLabel, Data), + lists:foldl( + fun(Line, AccData) -> lv:eval_codeline(Line, AccData) end, + NewData#wip_lv{local_vars = LocalV ++ EvalVarList#variable.value}, + Code + ). + +match(RightContent, LeftContent, Data) -> + case RightContent of + {var, _, VarName} -> match_with_var(VarName, LeftContent, Data); + {tuple, _, VarList} -> match_with_tuple(VarList, LeftContent, Data); + {cons, _, List} -> match_with_list(List, Data); + R -> share:warning("[MATCH] couldn't understand line", R, Data) + end. + +case_pm(Content, PMList, Data) -> + NewData = lv:eval_codeline(Content, Data), + %% TODO: save the returning variable? + pattern_matching(PMList, "match", NewData). + +if_pm(PMList, Data) -> + pattern_matching(PMList, "if", Data). + +receive_pm(PMList, Data) -> + pattern_matching(PMList, "receive", Data). + +operation(Symbol, LeftContent, RightContent, Data) -> + case Symbol of + '!' -> send(LeftContent, RightContent, Data); + %%% TODO: implement other basic operation + _ -> share:warning("operation not yet implemented", Symbol, Data) + end. + +function_call(Function, ArgList, Data) -> + case Function of + {atom, _, Name} -> call_by_atom(Name, ArgList, Data); + {var, _, VarName} -> call_by_var(VarName, ArgList, Data); + {remote, _, Package, FunName} -> call_by_package(Package, FunName, ArgList, Data); + F -> share:warning("couldn't call function pattern", F, Data) + end. + +anon_fun(Content, Line, Data) -> + case Content of + {clauses, A} -> + Id = "anonfun_" ++ integer_to_list(Line), + ets:insert(?FUNAST, {share:ltoa(Id), A}), + simple_type(function, Id, Data); + _ -> + share:warning("not recognized content in anon_fun", Content, Data) + end. + +simple_type(Type, Val, Data) -> + VarRet = #variable{type = Type, value = Val}, + Data#wip_lv{ret_var = VarRet}. + +atom(Val, Data) -> + %%% check if is a registerd atom, return the pid + case ets:lookup(?REGISTERDB, Val) of + [] -> simple_type(atom, Val, Data); + [{_, Pid}] -> simple_type(pid, Pid, Data) + end. + +list(HeadList, TailList, Data) -> + NDH = lv:eval_codeline(HeadList, Data), + NDT = lv:eval_codeline(TailList, NDH), + Var = NDH#wip_lv.ret_var, + VarList = NDT#wip_lv.ret_var, + NewVal = [Var] ++ VarList#variable.value, + simple_type(list, NewVal, NDT). + +map(Val, Data) -> + share:warning("TODO map evaluation", Val, Data). + +tuple(Val, Data) -> + {NewVal, NewData} = lists:foldl( + fun(I, {A, D}) -> + ND = lv:eval_codeline(I, D), + {A ++ [ND#wip_lv.ret_var], ND} + end, + {[], Data}, + Val + ), + simple_type(tuple, NewVal, NewData). + +variable(VarName, Data) -> + Var = share:find_var(Data#wip_lv.local_vars, VarName), + RetV = + case Var of + not_found -> #variable{name = VarName}; + V -> V + end, + Data#wip_lv{ret_var = RetV}. + +%%%=================================================================== +%%% Internal Functions +%%%=================================================================== + +decide_label(Base, Label, Data) -> + Settings = Data#wip_lv.settings, + MoreInfo = Settings#setting.more_info_lv, + ToWriteL = + if + Base =:= "receive" -> + {H, T} = remove_square_parenthesis(Label), + H ++ T; + Base =:= "arg" -> + {H, T} = remove_square_parenthesis(Label), + H ++ "(" ++ T ++ ")"; + MoreInfo -> + %% to decide + Label; + true -> + Label + end, + % for testing purposes add: or (Base =:= "arg"), + Cond = (Base =:= "receive") or MoreInfo, + share:get_base_label(Cond, ToWriteL). + +remove_square_parenthesis(Label) -> + [L | _] = string:split(Label, "]"), + [H | [T]] = string:split(L, "["), + {H, T}. + +match_with_var(VarName, LeftContent, Data) -> + NewData = lv:eval_codeline(LeftContent, Data), + Var = NewData#wip_lv.ret_var, + L = NewData#wip_lv.local_vars, + NewVarEntry = Var#variable{name = VarName}, + NewData#wip_lv{ret_var = NewVarEntry, local_vars = L ++ [NewVarEntry]}. + +match_with_tuple(VarList, LeftContent, Data) -> + NewData = lv:eval_codeline(LeftContent, Data), + Var = NewData#wip_lv.ret_var, + % not sure to use newdata + L = NewData#wip_lv.local_vars, + case Var#variable.type of + tuple -> + {TupleListWithNames, _} = + lists:foldl( + fun(Item, {AccL, [H | T]}) -> + {var, _, VarName} = H, + {AccL ++ [Item#variable{name = VarName}], T} + end, + {L, VarList}, + Var#variable.value + ), + NewData#wip_lv{ + ret_var = #variable{type = tuple, value = TupleListWithNames}, + local_vars = L ++ TupleListWithNames + }; + _ -> + RetVar = lists:foldl(fun(I, A) -> A ++ [#variable{name = I}] end, [], VarList), + ND = NewData#wip_lv{ + ret_var = #variable{type = tuple, value = RetVar}, + local_vars = L ++ RetVar + }, + share:warning("right content is a tuple but left content is", Var, ND) + end. + +match_with_list(List, Data) -> + share:warning("[MATCH] TODO match with list", List, Data). + +call_by_atom(Name, ArgList, Data) -> + FunName = Data#wip_lv.fun_name, + RealName = share:ltoa(share:remove_last(FunName)), + case Name of + RealName -> recursive(ArgList, Data); + spawn -> spawn_call(ArgList, Data); + spawn_monitor -> spawn_monitor_call(ArgList, Data); + self -> self_call(Data); + register -> register_call(ArgList, Data); + _ -> generic_call(Name, ArgList, Data) + end. + +%%% TODO: What to do with argument lists? Put them in the #wip_lv.edge_map? +recursive(_ArgList, Data) -> + % io:fwrite("[RECURSIVE] from vertex ~p~n", [Data#wip_lv.last_vertex]), + digraph:add_edge(Data#wip_lv.graph, Data#wip_lv.last_vertex, 1, 'ɛ'), + Data#wip_lv{last_vertex = ?UNDEFINED}. + +spawn_call(ArgList, Data) -> + case ArgList of + [Content] -> spawn_one(Content, Data); + %%% TODO: check and implement package + [_Package, {atom, _, Name}, SpArgList] -> spawn_three(Name, SpArgList, Data); + %%% TODO: spawn with 2/4 argument + _ -> share:warning("couldn't call function pattern", ArgList, Data) + end. + +spawn_one(Content, Data) -> + NewData = lv:eval_codeline(Content, Data), + VarFound = NewData#wip_lv.ret_var, + Id = VarFound#variable.value, + lv:create_save_localview(share:ltoa(Id), Data#wip_lv.settings), + C = inc_spawn_counter(Id), + S = Id ++ "_" ++ integer_to_list(C), + RetData = share:add_vertex_edge("spawn " ++ S, NewData), + RetVar = #variable{type = pid, value = S}, + RetData#wip_lv{ret_var = RetVar}. + +spawn_three(Name, ArgList, Data) -> + NewData = lv:eval_codeline(ArgList, Data), + EM = NewData#wip_lv.edge_map, + NewDataRetVar = NewData#wip_lv.ret_var, + {Label, ProcId} = format_spawn_label(Name, NewDataRetVar), + ND = NewData#wip_lv{edge_map = maps:put(Label, NewDataRetVar, EM)}, + RetData = share:add_vertex_edge(Label, ND), + RetData#wip_lv{ret_var = #variable{type = pid, value = ProcId}}. + +format_spawn_label(Name, NewDataRetVar) -> + C = inc_spawn_counter(Name), + Arity = integer_to_list(length(NewDataRetVar#variable.value)), + ProcId = share:atol(Name) ++ Arity ++ "_" ++ integer_to_list(C), + {"spawn " ++ ProcId, ProcId}. + +spawn_monitor_call(ArgList, Data) -> + share:warning("spawn_monitor not yet implemted. Arguments =", ArgList, Data). + +inc_spawn_counter(Name) -> + case ets:lookup(?SPAWNC, share:ltoa(Name)) of + [] -> + ets:insert(?SPAWNC, {Name, 1}), + 0; + [{_, N}] -> + ets:insert(?SPAWNC, {Name, N + 1}), + N + end. + +self_call(Data) -> + RetVar = #variable{type = pid_self, value = share:atol(Data#wip_lv.fun_name)}, + Data#wip_lv{ret_var = RetVar}. + +register_call(ArgList, Data) -> + [{atom, _, AtomName}, {var, _, VarName}] = ArgList, + VarFound = share:find_var(Data, VarName), + case VarFound of + not_found -> + ?UNDEFINED; + V -> + case V#variable.type == pid of + false -> ?UNDEFINED; + true -> ets:insert(?REGISTERDB, {AtomName, V#variable.value}) + end + end, + %%% Approx: ignoring returing value + Data. + +generic_call(Name, ArgList, Data) -> + NewData = lv:eval_codeline(ArgList, Data), + % io:fwrite("ARG LIST ~p~n", [ArgList]), + % io:fwrite("RET VAR ~p~n", [NewData#wip_lv.ret_var#variable.value]), + NameString = share:merge_fun_ar(Name, length(ArgList)), + case get_function_graph(NameString, Data#wip_lv.settings) of + no_graph -> + share:warning("couldn't parse function", Name, Data#wip_lv{ret_var = #variable{}}); + NewD -> + G = Data#wip_lv.graph, + LastV = Data#wip_lv.last_vertex, + NewG = NewD#wip_lv.graph, + NewRet = NewD#wip_lv.ret_var, + NewLastV = merge_graph(G, NewG, LastV), + Data#wip_lv{ret_var = NewRet, last_vertex = NewLastV} + end. + +%%% TODO: eval argument list +call_by_var(VarName, ArgList, Data) -> + G = Data#wip_lv.graph, + VLast = Data#wip_lv.last_vertex, + LocalVarL = Data#wip_lv.local_vars, + VarFound = share:find_var(LocalVarL, VarName), + case VarFound of + not_found -> + share:warning("variable not found in call_by_var with name", VarName, Data); + _ -> + Id = VarFound#variable.value, + ND = lv:eval_codeline(ArgList, Data), + NewData = lv:create_localview(share:ltoa(Id), ND#wip_lv.settings, false), + NewG = NewData#wip_lv.graph, + NewRet = NewData#wip_lv.ret_var, + NewLastV = merge_graph(G, NewG, VLast), + Data#wip_lv{ret_var = NewRet, last_vertex = NewLastV} + end. + +call_by_package(Package, FunName, _ArgList, Data) -> + {atom, _, Pack} = Package, + {atom, _, Name} = FunName, + case Pack of + rand -> rand_package(Name, Data); + %%% TODO: find the package and the function, create the local view of it, attach it to the current lv + _ -> share:warning("package not yet implemented:", Pack, Data) + end. + +rand_package(FunName, Data) -> + case FunName of + uniform -> simple_type(integer, ?ANYDATA, Data); + %%% TODO: expand + _ -> share:warning("rand's function not yet implemented:", FunName, Data) + end. + +send(Destination, MessageContent, Data) -> + TempData = lv:eval_codeline(Destination, Data), + ProcName = get_pid(TempData#wip_lv.ret_var), + NewData = lv:eval_codeline(MessageContent, TempData), + DataSent = var_to_string(NewData#wip_lv.ret_var), + SLabel = "send " ++ DataSent ++ " to " ++ ProcName, + share:add_vertex_edge(SLabel, NewData). + +get_pid(Var) -> + case Var#variable.type == pid of + true -> Var#variable.value; + false -> share:atol(Var#variable.name) + end. + +var_to_string(Var) -> + case Var of + [] -> + ""; + V -> + case V#variable.type of + ?ANYDATA -> + share:atol(V#variable.name); + Type -> + SType = share:atol(Type), + case V#variable.value of + ?ANYDATA -> + SType; + Val -> + case SType of + "integer" -> integer_to_list(Val); + "float" -> io_lib:format("~.2f", [Val]); + "string" -> "\"" ++ Val ++ "\""; + "atom" -> share:atol(Val); + "list" -> format_list(Val, fun var_to_string/1); + "tuple" -> format_tuple(Val, fun var_to_string/1); + "pid" -> "pid" ++ "_" ++ share:atol(V#variable.value); + S -> S + end + end + end + end. + +format_tuple(VarL, Fun) -> + Label = join_list(VarL, Fun), + "{" ++ Label ++ "}". + +format_list(VarL, Fun) -> + Label = join_list(VarL, Fun), + "[" ++ Label ++ "]". + +join_list(VarL, Fun) -> + L = lists:foldl(fun(I, A) -> A ++ "," ++ Fun(I) end, "", VarL), + case L of + [] -> ""; + [_ | T] -> T + end. + +%%% We have a main graph G1, a graph G2 and a G1's vertex. +%%% We need to append G2 to the G1's vertex. +%%% Firstly, we add to G1 as many vertex as G2's vertex number. +%%% With a map, we associate every vertex of G2 to one of the new G1'vertex +%%% Secondly, we collect each G2's edge info and then we rebuild it in G1 using the previous map +merge_graph(MainG, GToAdd, VLast) -> + VertexGToAdd = digraph:vertices(GToAdd), + % Add a number of vertex equal to VertexGToAdd + VEquiMap = lists:foldl( + %%% With this function we add a vertex and we associate it with G2's vertex + fun(Item, M) -> maps:put(Item, share:add_vertex(MainG), M) end, + maps:new(), + VertexGToAdd + ), + % link the first new state created to the main graph + digraph:add_edge(MainG, VLast, maps:get(1, VEquiMap), 'ɛ'), + % Add all the edges + EdgesGToAdd = digraph:edges(GToAdd), + lists:foreach( + fun(Item) -> + {Item, V1, V2, Label} = digraph:edge(GToAdd, Item), + %%% We use the map to rebuild the exact same edge but in G1 + digraph:add_edge(MainG, maps:get(V1, VEquiMap), maps:get(V2, VEquiMap), Label) + end, + EdgesGToAdd + ), + % return last added vertex, which is the max number in the key list + maps:get(lists:max(maps:keys(VEquiMap)), VEquiMap). + +get_function_graph(FuncName, Settings) -> + FunAst = share:get_fun_ast(FuncName), + case FunAst of + not_found -> no_graph; + _ -> lv:create_localview(FuncName, Settings, false) + end. + +%%% Evaluate Pattern Matching's list of clauses: evaluate every branch alone, then +%%% link every last vertex's branch to a shared vertex with epsilon transaction +pattern_matching(PMList, Label, Data) -> + VLast = Data#wip_lv.last_vertex, + G = Data#wip_lv.graph, + VLastList = explore_pm(PMList, Label, Data), + VRet = share:add_vertex(G), + add_edges_recursive(G, VLastList, VRet, 'ɛ', VLast), + Data#wip_lv{graph = G, last_vertex = VRet}. + +%%% Explore every pm's branch and returns the list of last added vertex +explore_pm(PMList, Base, Data) -> + lists:foldl( + fun(CodeLine, AddedVertexList) -> + case CodeLine of + {clause, _, Vars, Guard, Content} -> + VDataRet = clause(Content, Vars, Guard, Data, Base), + AddedVertexList ++ [VDataRet#wip_lv.last_vertex]; + C -> + share:warning("Should be clause but it's", C, AddedVertexList) + end + end, + [], + PMList + ). + +%%% Convert the guard (ast format) to a string +guards_to_string(GlobalToVal) -> + case GlobalToVal of + %%% Add guards if there's a guard + %%% TODO: add more infos + {op, _, _, _} -> " (guards)"; + _ -> "" + end. + +%%% Link each vertex of a vertex's list to a given vertex, with a defined label +add_edges_recursive(G, VertexList, VertexToLink, Label, Except) -> + lists:foreach( + fun(V) -> + Cond = (V =/= Except) and (V =/= 1), + case Cond of + true -> digraph:add_edge(G, V, VertexToLink, Label); + false -> done + end + end, + VertexList + ). diff --git a/src/choreography/gv.erl b/src/choreography/gv.erl index db30707..b90a7b6 100644 --- a/src/choreography/gv.erl +++ b/src/choreography/gv.erl @@ -10,20 +10,14 @@ %%% Generate the glabal view from an entrypoint and save it in a specified folder generate(Settings, EntryPoint) -> - OutputDir = Settings#setting.output_dir, - MainGraph = common_fun:get_localview(EntryPoint), + MainGraph = share:get_localview(share:atol(EntryPoint)), case MainGraph of not_found -> - no_entry_point_found; + io:fwrite("Error: entrypoint for global view not found ~p~n", [EntryPoint]), + error; _ -> G = create_globalview(EntryPoint), - {ok, [In]} = io:fread("Minimize global view? [y/n] ", "~a"), - CG = - case In of - n -> G; - _ -> fsa:minimize(G) - end, - common_fun:save_graph_to_file(CG, OutputDir, atol(EntryPoint), global), + share:save_graph(G, Settings, EntryPoint, global), finished end. @@ -34,7 +28,7 @@ generate(Settings, EntryPoint) -> %%% Create the glabal view from a function entrypoint name create_globalview(Name) -> RetG = digraph:new(), - VNew = common_fun:add_vertex(RetG), + VNew = share:add_vertex(RetG), MainProcPid = spawn(actor_emul, proc_loop, [#actor_info{proc_id = Name}]), ProcPidMap = #{Name => MainProcPid}, % initialize first branch @@ -57,10 +51,10 @@ progress_procs(G, []) -> G; progress_procs(GlobalGraph, BranchList) when is_list(BranchList) -> RealList = lists:flatten(BranchList), - %io:fwrite("Branch to eval ~p~n", [length(RealList)]), + io:fwrite("Branch to eval ~p~n", [length(RealList)]), NewBL = lists:foldl( fun(Item, AccL) -> - %io:fwrite("Eval branch~n"), + io:fwrite("Eval branch~n"), NewBreanches = progress_single_branch(Item), AccL ++ NewBreanches end, @@ -80,7 +74,7 @@ progress_single_branch(BData) -> maps:fold( fun(Name, Pid, AccList) -> MessageQueue = actor_emul:get_proc_mess_queue(Pid), - %io:fwrite("[PROGSB] Name ~p MQ ~p~n", [Name, MessageQueue]), + io:fwrite("[PROGSB] Name ~p MQ ~p~n", [Name, MessageQueue]), gen_branch_foreach_mess(TempBranchData, MessageQueue, Name, AccList) end, [], @@ -110,15 +104,14 @@ gen_branch_foreach_mess(BranchData, MessageQueue, ProcName, BaseList) -> AccList; %%% If an edge has been found, duplicate the branch and add the transition to the graph EdgeFound -> - %io:fwrite("[RECV] Mess ~p Edge choose ~p~n", [Message, EdgeFound]), + io:fwrite("[RECV] Mess ~p Edge choose ~p~n", [Message, EdgeFound]), ProcFrom = Message#message.from, MessData = Message#message.data, PidFrom = maps:get(ProcFrom, NewMap), Label = format_send_label(ProcFrom, ProcName, MessData), - %io:fwrite("~n~n[RECV] LABEL ~ts~n~n", [Label]), + io:fwrite("~n~n[RECV] LABEL ~ts~n~n", [Label]), EFromInfo = actor_emul:get_proc_edge_info(PidFrom, Message#message.edge), EToInfo = actor_emul:get_proc_edge_info(NewPid, EdgeFound), - %LastVertex = simple_add_vertex(DupData, Label), {LastVertex, NewStateMap} = complex_add_vertex( ProcFrom, EFromInfo, ProcName, EToInfo, DupData, Label ), @@ -155,11 +148,11 @@ duplicate_proccess(ProcMap) -> %%% Remove the number from an actor's identificator remove_id_from_proc(ProcId) -> - SProcId = atol(ProcId), - {Name, N} = lists:split(length(SProcId) - 1, SProcId), - case catch list_to_integer(N) of - {'EXIT', _} -> ProcId; - _ -> ltoa(remove_last(Name)) + Split = string:split(ProcId, "_"), + % io:fwrite("split ~p~n", [Split]), + case Split of + [Name | _N] -> ltoa(Name); + _ -> ProcId end. %%% Evaluate the edges of a local view until it reaches a receive edge foreach actor @@ -189,7 +182,7 @@ eval_proc_branch(ProcName, ProcPid, Data) -> ELLength =:= 0 -> {Data, false, []}; ELLength =:= 1 -> - E = common_fun:first(EL), + E = share:first(EL), EI = actor_emul:get_proc_edge_info(ProcPid, E), {D, B} = eval_edge(EI, ProcName, ProcPid, Data), {D, B, []}; @@ -237,7 +230,7 @@ is_lists_edgerecv(ProcPid, EL) -> %%% Evaluate a transition from an actor eval_edge(EdgeInfo, ProcName, ProcPid, BData) -> {Edge, _, _, PLabel} = EdgeInfo, - %io:fwrite("Proc ~p eval label ~p~n", [ProcName, PLabel]), + io:fwrite("Proc ~p eval label ~p~n", [ProcName, PLabel]), SLabel = atol(PLabel), IsArg = is_substring(SLabel, "arg"), IsSpawn = is_substring(SLabel, "spawn"), @@ -257,13 +250,14 @@ eval_edge(EdgeInfo, ProcName, ProcPid, BData) -> {BData, false} end. -is_substring(S, SubS) -> is_list(string:find(S, SubS)). +is_substring(S, SubS) -> + is_list(string:find(S, SubS)). %%% Add a spanw transition to the global view add_spawn_to_global(SLabel, ProcName, Data) -> % get proc name ProcIdS = string:prefix(SLabel, "spawn "), - FuncNameS = remove_last(remove_last(ProcIdS)), + FuncNameS = share:remove_last(share:remove_last(ProcIdS)), % spawn the actor emulator FuncPid = spawn(actor_emul, proc_loop, [#actor_info{proc_id = ltoa(FuncNameS)}]), NewMap = maps:put(ltoa(ProcIdS), FuncPid, Data#branch.proc_pid_m), @@ -271,17 +265,17 @@ add_spawn_to_global(SLabel, ProcName, Data) -> LocalList = get_local_vars(ProcName, SLabel, FuncNameS), lists:foreach(fun(Var) -> actor_emul:add_proc_spawnvars(FuncPid, Var) end, LocalList), % create the edge on the global graph - VNew = common_fun:add_vertex(Data#branch.graph), + VNew = share:add_vertex(Data#branch.graph), %%% Δ means spawned NewLabel = atol(ProcName) ++ "Δ" ++ ProcIdS, digraph:add_edge(Data#branch.graph, Data#branch.last_vertex, VNew, NewLabel), {VNew, NewMap}. get_local_vars(ProcName, Label, FuncName) -> - EM = common_fun:get_edgedata(ProcName), + EM = share:get_edgedata(atol(ProcName)), % add input data to local vars InputData = maps:get(Label, EM, []), - % io:fwrite("ProcName ~p Label ~p Input ~p~n", [ProcName, Label, InputData]), + io:fwrite("ProcName ~p Label ~p Input ~p~n", [ProcName, Label, EM]), case InputData of [] -> []; @@ -300,17 +294,12 @@ get_local_vars(ProcName, Label, FuncName) -> LL end. -%%% Remove the last element froom a list -remove_last(List) when is_list(List) -> - {Rest, _} = lists:split(length(List) - 1, List), - Rest. - %%% Evaluate a send transition of an actor manage_send(SLabel, Data, ProcName, ProcPid, Edge) -> ProcPidMap = Data#branch.proc_pid_m, DataSent = get_data_from_label(SLabel), ProcSentTemp = ltoa(get_proc_from_label(SLabel)), - IsVar = common_fun:is_erlvar(ProcSentTemp), + IsVar = share:is_erlvar(ProcSentTemp), ProcSentName = case IsVar of true -> check_vars(ProcPid, ProcSentTemp); @@ -319,7 +308,7 @@ manage_send(SLabel, Data, ProcName, ProcPid, Edge) -> ProcSentPid = maps:get(ProcSentName, ProcPidMap, no_pid), case ProcSentPid of no_pid -> - %io:fwrite("[SEND-ERR] no pid found for: ~p~n", [ProcSentName]), + io:fwrite("[SEND-ERR] no pid found for: ~p~n", [ProcSentName]), {Data, false}; P -> actor_emul:add_proc_mess_queue(P, new_message(ProcName, DataSent, Edge)), @@ -331,13 +320,14 @@ manage_send(SLabel, Data, ProcName, ProcPid, Edge) -> %%% Evaluate a receive transition of an actor manage_recv(ProcPid, Message) -> EL = actor_emul:get_proc_edges(ProcPid), - %%% TODO: trovare il modo di valutare in ordine i rami del receive (in quanto è molto rilevante nell'esecuzione) + %%% IMPORTANT TODO: evaluation of the edge's order not implemented!! IsRecv = is_lists_edgerecv(ProcPid, EL), %io:fwrite("IsRECV ~p EL ~p~n", [IsRecv, EL]), From = Message#message.from, case IsRecv of false -> - % TODO: gestire casistica, il seguente codice è vecchio e quindi da prendere con le pinze + % TODO: manage when is not ONLY a receive edge + % the following piece of code is old, check before uncommenting % {NewL, NOp} = lists:foldl( % fun(E, A) -> % EInfo = get_proc_edge_info(ProcPid, E), @@ -376,9 +366,9 @@ manage_recv(ProcPid, Message) -> check_vars(ProcPid, VarName) -> ProcLocalVars = actor_emul:get_proc_localvars(ProcPid), % io:fwrite("Find var ~p in ~p from ~p~n", [VarName, ProcLocalVars, ProcName]), - VarValue = find_var(ProcLocalVars, VarName), + VarValue = share:find_var(ProcLocalVars, VarName), case VarValue of - nomatch -> + not_found -> VarName; V -> case V#variable.type of @@ -393,16 +383,6 @@ check_vars(ProcPid, VarName) -> remove_pid_part(Data) -> ltoa(lists:flatten(string:replace(atol(Data), "pid_", ""))). -%%% Find a variable in a list, given the name -find_var([], _) -> - nomatch; -find_var([H | T], VarName) -> - Cond = H#variable.name =:= VarName, - case Cond of - true -> H; - false -> find_var(T, VarName) - end. - %%% Check if a pattern metching match a message, then register the new variables is_pm_msg_compatible(ProcPid, CallingProc, PatternMatching, Message) -> {RetBool, RegList} = check_msg_comp( @@ -420,12 +400,12 @@ check_msg_comp(ProcPid, CallingProc, PatternMatching, Message) -> PatternMS = lists:flatten(string:replace(atol(PatternMatching), "receive ", "")), [FirstPChar | RestP] = PatternMS, [FirstMChar | RestM] = MessageS, - IsFirstCharUpperCase = common_fun:is_erlvar(PatternMS), + IsFirstCharUpperCase = share:is_erlvar(PatternMS), if %%% hierarchy ([FirstPChar] =:= "{") and ([FirstMChar] =:= "{") -> - ContentP = remove_last(RestP), - ContentM = remove_last(RestM), + ContentP = share:remove_last(RestP), + ContentM = share:remove_last(RestM), PL = string:split(ContentP, ",", all), A = lists:enumerate(PL), ML = string:split(ContentM, ",", all), @@ -496,7 +476,7 @@ complex_add_vertex(Proc1, EdgeInfo1, Proc2, EdgeInfo2, Data, Label) -> {VLast, NewM}; %%% Add a new vertex, because no match found in StateM false -> - VAdded = common_fun:add_vertex(G), + VAdded = share:add_vertex(G), digraph:add_edge(G, VLast, VAdded, Label), NewM = maps:put({{Proc1, V1}, {Proc2, PV1}}, VLast, StateM), {VAdded, NewM} @@ -517,13 +497,6 @@ complex_add_vertex(Proc1, EdgeInfo1, Proc2, EdgeInfo2, Data, Label) -> {VRet, StateM} end. -% simple_add_vertex(Data, Label) -> -% VLast = Data#branch.last_vertex, -% G = Data#branch.graph, -% VAdded = common_fun:add_vertex(G), -% digraph:add_edge(G, VLast, VAdded, Label), -% VAdded. - %%% Returns the outgoing vertex given a label and a list of transition check_same_label(G, EL, Label) -> lists:foldl( @@ -541,7 +514,7 @@ check_same_label(G, EL, Label) -> %%% Get the data from a send local view's label get_data_from_label(S) -> Ret = lists:nth(2, string:split(S, " ", all)), - FirstChar = common_fun:first(Ret), + FirstChar = share:first(Ret), if [FirstChar] =:= "[" -> Ret ++ " " ++ lists:nth(3, string:split(S, " ", all)); true -> Ret diff --git a/src/choreography/lv.erl b/src/choreography/lv.erl index 2bf6d3a..98ed03e 100644 --- a/src/choreography/lv.erl +++ b/src/choreography/lv.erl @@ -2,7 +2,7 @@ -include("../share/common_data.hrl"). %%% API --export([generate/1]). +-export([generate/1, create_localview/3, eval_codeline/2]). %%%=================================================================== %%% API @@ -11,7 +11,7 @@ generate(Settings) -> [{_, ActorList}] = ets:lookup(?DBMANAGER, ?ACTORLIST), lists:foreach( - fun(Actor) -> create_save_localview(Actor#actor.name, Settings) end, + fun(Actor) -> create_localview(Actor, Settings, true) end, ActorList ). @@ -19,57 +19,73 @@ generate(Settings) -> %%% Internal Functions %%%=================================================================== -create_save_localview(ActorName, Settings) -> - ActorAst = common_fun:get_fun_ast(ActorName), - case ActorAst of - not_found -> - io:fwrite("Error: Actor ~p's AST not found~n", [ActorName]); - _ -> - % io:fwrite("[LV] Creating a localview for ~p~n", [ActorName]), - LocalViewData = check_and_get_lv(ActorName, ActorAst, [], Settings), +create_localview(ActorName, Settings, Save) -> + case does_actor_exist(ActorName) of + false -> + io:fwrite("Error: Actor ~p's AST not found~n", [ActorName]), + no_graph; + ActorAst -> + io:fwrite("[LV] Creating a localview for ~p~n", [ActorName]), + LocalViewData = build_localview(ActorName, ActorAst, Settings), G = LocalViewData#wip_lv.graph, - set_final(G), - MinGraph = fsa:minimize(G), - ets:insert(?LOCALVIEW, {ActorName, LocalViewData#wip_lv{graph = MinGraph}}), - OutputDir = Settings#setting.output_dir, - common_fun:save_graph_to_file(MinGraph, OutputDir, atol(ActorName), local) + set_final_state(G), + MinG = fsa:minimize(G), + LV = LocalViewData#wip_lv{graph = MinG}, + ets:insert(?LOCALVIEW, {ActorName, LV}), + case Save or Settings#setting.save_all of + true -> share:save_graph(G, Settings, ActorName, local); + false -> done + end, + %% Which should I return? LV (contains the MinGraph) or LocalViewData (not minimized) + LocalViewData end. -create_localview(FunName, LocalVars) -> - ActorAst = common_fun:get_fun_ast(FunName), +does_actor_exist(ActorName) -> + ActorAst = share:get_fun_ast(share:atol(ActorName)), case ActorAst of - not_found -> io:fwrite("Error: Function ~p's AST not found~n", [FunName]); - _ -> check_and_get_lv(FunName, ActorAst, LocalVars, #setting{}) + not_found -> false; + A -> A end. -check_and_get_lv(ActorName, Ast, LovalVars, Settings) -> - LV = common_fun:get_graph(ActorName), +build_localview(ActorName, Ast, Settings) -> + LV = share:get_localview(ActorName), case LV of not_found -> - BaseData = #wip_lv{ - fun_name = ActorName, fun_ast = Ast, settings = Settings, input_vars = LovalVars - }, - common_fun:add_vertex(BaseData#wip_lv.graph), - build_localview(BaseData); + BaseData = #wip_lv{fun_name = ActorName, fun_ast = Ast, settings = Settings}, + share:add_vertex(BaseData#wip_lv.graph), + eval_codeline(BaseData#wip_lv.fun_ast, BaseData); L -> L end. -build_localview(Data) -> - eval_pm_clause(Data#wip_lv.fun_ast, [], Data). - -% add_args_to_graph(Gr, Vars, Guard, VStart, SetPm) -> -% case SetPm of -% true -> -% VN = common_fun:add_vertex(Gr), -% EdLabel = format_label_pm_edge(SetPm, Vars, Guard, "arg "), -% digraph:add_edge(Gr, VStart, VN, EdLabel), -% VN; -% false -> -% VStart -% end. - eval_codeline(CodeLine, Data) -> + debug_print(CodeLine), + case CodeLine of + {function, _, DefinitionList} -> eval:function_list(DefinitionList, Data); + % {clause, _, Vars, Guard, Content} -> eval:clause(Content, Vars, Guard, Data, ""); this should never match + {match, _, RightContent, LeftContent} -> eval:match(RightContent, LeftContent, Data); + {call, _, Function, ArgList} -> eval:function_call(Function, ArgList, Data); + {'case', _, Content, PMList} -> eval:case_pm(Content, PMList, Data); + {'if', _, PMList} -> eval:if_pm(PMList, Data); + {'receive', _, PMList} -> eval:receive_pm(PMList, Data); + {op, _, Op, LeftC, RightC} -> eval:operation(Op, LeftC, RightC, Data); + {'fun', N, Ast} -> eval:anon_fun(Ast, N, Data); + {integer, _, Val} -> eval:simple_type(integer, Val, Data); + {float, _, Val} -> eval:simple_type(float, Val, Data); + {string, _, Val} -> eval:simple_type(string, Val, Data); + {nil, _} -> eval:simple_type(nil, [], Data); + {atom, _, Val} -> eval:atom(Val, Data); + {cons, _, HeadList, TailList} -> eval:list(HeadList, TailList, Data); + {map, _, Val} -> eval:map(Val, Data); + {tuple, _, Val} -> eval:tuple(Val, Data); + {var, _, VarName} -> eval:variable(VarName, Data); + % attention: don't set this to eval:list([], [], Data) otherwise infinite loop + [] -> eval:simple_type(list, [], Data); + [H | T] -> eval:list(H, T, Data); + _ -> share:warning("couldn't parse code line", CodeLine, Data) + end. + +debug_print(CodeLine) -> if is_tuple(CodeLine) -> Line = element(2, CodeLine), @@ -77,526 +93,10 @@ eval_codeline(CodeLine, Data) -> ets:insert(?CLINE, {line, Line}); true -> done - end, - case CodeLine of - {clause, _, Vars, _Guard, Content} -> eval_pm_clause(Content, Vars, Data); - {match, _, RightContent, LeftContent} -> eval_match(RightContent, LeftContent, Data); - {call, _, Function, ArgList} -> eval_call(Function, ArgList, Data); - {'case', _, Content, PMList} -> eval_case(Content, PMList, Data); - {'if', _, PMList} -> eval_pm(PMList, get_base_label(false, "if "), Data); - {'receive', _, PMList} -> eval_pm(PMList, "receive ", Data); - {op, _, Op, LeftContent, RightContent} -> eval_op(Op, LeftContent, RightContent, Data); - {'fun', N, Ast} -> eval_anon_fun(Ast, N, Data); - {integer, _, Val} -> eval_simple_type(integer, Val, Data); - {float, _, Val} -> eval_simple_type(float, Val, Data); - {string, _, Val} -> eval_simple_type(string, Val, Data); - {nil, _} -> eval_simple_type(nil, [], Data); - {atom, _, Val} -> eval_atom(Val, Data); - {cons, _, HeadList, TailList} -> eval_list(HeadList, TailList, Data); - {map, _, Val} -> eval_map(Val, Data); - {tuple, _, Val} -> eval_tuple(Val, Data); - {var, _, VarName} -> eval_variable(VarName, Data); - [] -> eval_simple_type(list, [], Data); - [H | T] -> eval_list(H, T, Data); - _ -> warning("couldn't parse code line", CodeLine, Data) - end. - -warning(String, Content, Data) -> - [{_, Line}] = ets:lookup(?CLINE, line), - io:fwrite("[LV] WARNING on line ~p: " ++ String ++ " ~p~n", [Line, Content]), - Data. - -eval_pm_clause(Code, Vars, Data) -> - LocalV = Data#wip_lv.local_vars, - FunName = ltoa(Data#wip_lv.fun_name), - Exist = ets:lookup(?ARGUMENTS, FunName), - % io:fwrite("Per ~ps salvo ~p esiste ~p~n", [FunName, Vars, Exist]), - case Exist of - [] -> ets:insert(?ARGUMENTS, {FunName, Vars}); - [{_, []}] -> ets:insert(?ARGUMENTS, {FunName, Vars}); - _ -> done - end, - ND = - case Vars =:= [] of - true -> - Data; - false -> - Input = Data#wip_lv.input_vars, - {LL, _} = lists:foldl( - fun({var, _, Name}, {A, In}) -> - case In of - [] -> {A ++ [#variable{name = Name}], []}; - [H | T] -> {A ++ [H#variable{name = Name}], T} - end - end, - {[], Input}, - Vars - ), - Data#wip_lv{local_vars = LocalV ++ LL} - end, - lists:foldl( - fun(Line, AccData) -> eval_codeline(Line, AccData) end, - ND, - Code - ). - -eval_match(RightContent, LeftContent, Data) -> - case RightContent of - {var, _, VarName} -> eval_match_with_var(VarName, LeftContent, Data); - {tuple, _, VarList} -> eval_match_with_tuple(VarList, LeftContent, Data); - {cons, _, List} -> eval_match_with_list(List, Data); - R -> warning("[MATCH] couldn't understand line", R, Data) - end. - -eval_match_with_var(VarName, LeftContent, Data) -> - NewData = eval_codeline(LeftContent, Data), - Var = NewData#wip_lv.ret_var, - L = NewData#wip_lv.local_vars, - NewVarEntry = Var#variable{name = VarName}, - NewData#wip_lv{ret_var = NewVarEntry, local_vars = L ++ [NewVarEntry]}. - -eval_match_with_tuple(VarList, LeftContent, Data) -> - NewData = eval_codeline(LeftContent, Data), - Var = NewData#wip_lv.ret_var, - % not sure to use newdata - L = NewData#wip_lv.local_vars, - case Var#variable.type of - tuple -> - {TupleListWithNames, _} = - lists:foldl( - fun(Item, {AccL, [H | T]}) -> - {var, _, VarName} = H, - {AccL ++ [Item#variable{name = VarName}], T} - end, - {L, VarList}, - Var#variable.value - ), - NewData#wip_lv{ - ret_var = #variable{type = tuple, value = TupleListWithNames}, - local_vars = L ++ TupleListWithNames - }; - _ -> - RetVar = lists:foldl(fun(I, A) -> A ++ [#variable{name = I}] end, [], VarList), - ND = NewData#wip_lv{ - ret_var = #variable{type = tuple, value = RetVar}, - local_vars = L ++ RetVar - }, - warning("right content is a tuple but left content is", Var, ND) - end. - -eval_match_with_list(List, Data) -> warning("[MATCH] working in progress", List, Data). - -eval_call(Function, ArgList, Data) -> - case Function of - {atom, _, Name} -> eval_call_by_atom(Name, ArgList, Data); - {var, _, VarName} -> eval_call_by_var(VarName, ArgList, Data); - {remote, _, Package, FunName} -> eval_call_by_package(Package, FunName, ArgList, Data); - F -> warning("couldn't call function pattern", F, Data) - end. - -eval_call_by_atom(Name, ArgList, Data) -> - FunName = Data#wip_lv.fun_name, - case Name of - FunName -> eval_recursive(ArgList, Data); - spawn -> eval_spawn(ArgList, Data); - spawn_monitor -> eval_spawn_monitor(ArgList, Data); - self -> eval_self(Data); - register -> eval_register(ArgList, Data); - _ -> eval_generic_call(Name, ArgList, Data) - end. - -%%% Dubbio: In questo caso bisogna ritornare i Data così come sono o bisogna impostare il last_vertex all'1? -%%% TODO: Cosa fare con la lista degli argument? -eval_recursive(_ArgList, Data) -> - % io:fwrite("[RECURSIVE] from vertex ~p~n", [Data#wip_lv.last_vertex]), - digraph:add_edge(Data#wip_lv.graph, Data#wip_lv.last_vertex, 1, 'ɛ'), - Data#wip_lv{last_vertex = ?UNDEFINED}. - -eval_spawn(ArgList, Data) -> - case ArgList of - [Content] -> eval_spawn_one(Content, Data); - %%% TODO: check and implement package - [_Package, {atom, _, Name}, SpArgList] -> eval_spawn_three(Name, SpArgList, Data); - %%% TODO: spawn with 2/4 argument - _ -> warning("couldn't call function pattern", ArgList, Data) - end. - -eval_spawn_one(Content, Data) -> - G = Data#wip_lv.graph, - NewData = eval_codeline(Content, Data), - VLast = NewData#wip_lv.last_vertex, - VarFound = NewData#wip_lv.ret_var, - Id = VarFound#variable.value, - create_save_localview(ltoa(Id), Data#wip_lv.settings), - C = inc_spawn_counter(Id), - S = Id ++ "_" ++ integer_to_list(C), - VNew = common_fun:add_vertex(G), - digraph:add_edge(G, VLast, VNew, "spawn " ++ S), - RetVar = #variable{type = pid, value = S}, - Data#wip_lv{ret_var = RetVar, last_vertex = VNew}. - -eval_spawn_three(Name, ArgList, Data) -> - G = Data#wip_lv.graph, - VLast = Data#wip_lv.last_vertex, - C = inc_spawn_counter(Name), - S = atol(Name) ++ "_" ++ integer_to_list(C), - VNew = common_fun:add_vertex(G), - Label = "spawn " ++ S, - digraph:add_edge(G, VLast, VNew, Label), - NewData = eval_codeline(ArgList, Data), - EM = NewData#wip_lv.edge_map, - ND = NewData#wip_lv{edge_map = maps:put(Label, NewData#wip_lv.ret_var, EM)}, - RetVar = #variable{type = pid, value = S}, - ND#wip_lv{ret_var = RetVar, last_vertex = VNew}. - -eval_spawn_monitor(ArgList, Data) -> warning("spawn_monitor not yet implemted. Arguments =", ArgList, Data). - -inc_spawn_counter(Name) -> - case ets:lookup(?SPAWNC, ltoa(Name)) of - [] -> - ets:insert(?SPAWNC, {Name, 1}), - 0; - [{_, N}] -> - ets:insert(?SPAWNC, {Name, N + 1}), - N - end. - -eval_self(Data) -> - RetVar = #variable{type = pid_self, value = atol(Data#wip_lv.fun_name)}, - Data#wip_lv{ret_var = RetVar}. - -eval_register(ArgList, Data) -> - [{atom, _, AtomName}, {var, _, VarName}] = ArgList, - VarFound = find_var(Data, VarName), - case VarFound of - not_found -> - ?UNDEFINED; - V -> - case V#variable.type == pid of - false -> ?UNDEFINED; - true -> ets:insert(?REGISTERDB, {AtomName, V#variable.value}) - end - end, - %%% Approx: ignoring returing value - Data. - -eval_generic_call(Name, ArgList, Data) -> - % io:fwrite("ARG LIST ~p~n", [ArgList]), - NewData = eval_codeline(ArgList, Data), - % io:fwrite("RET VAR ~p~n", [NewData#wip_lv.ret_var#variable.value]), - case eval_func(Name, NewData#wip_lv.ret_var#variable.value) of - no_graph -> - warning("couldn't parse function", Name, Data#wip_lv{ret_var = #variable{}}); - NewD -> - G = Data#wip_lv.graph, - LastV = Data#wip_lv.last_vertex, - NewG = NewD#wip_lv.graph, - NewRet = NewD#wip_lv.ret_var, - NewLastV = merge_graph(G, NewG, LastV), - Data#wip_lv{ret_var = NewRet, last_vertex = NewLastV} - end. - -%%% TODO: eval argument list -eval_call_by_var(VarName, ArgList, Data) -> - G = Data#wip_lv.graph, - VLast = Data#wip_lv.last_vertex, - LocalVarL = Data#wip_lv.local_vars, - VarFound = find_var(LocalVarL, VarName), - case VarFound of - not_found -> - warning("variable not found in eval_call_by_var with name", VarName, Data); - _ -> - Id = VarFound#variable.value, - ND = eval_codeline(ArgList, Data), - NewData = create_localview(ltoa(Id), ND#wip_lv.ret_var#variable.value), - NewG = NewData#wip_lv.graph, - NewRet = NewData#wip_lv.ret_var, - NewLastV = merge_graph(G, NewG, VLast), - Data#wip_lv{ret_var = NewRet, last_vertex = NewLastV} - end. - -eval_call_by_package(Package, FunName, _ArgList, Data) -> - {atom, _, Pack} = Package, - {atom, _, Name} = FunName, - case Pack of - rand -> eval_rand_package(Name, Data); - %%% TODO: find the package and the function, create the local view of it, attach it to the current lv - _ -> warning("package not yet implemented:", Pack, Data) - end. - -eval_rand_package(FunName, Data) -> - case FunName of - uniform -> eval_simple_type(integer, ?ANYDATA, Data); - %%% TODO: expand - _ -> warning("rand's function not yet implemented:", FunName, Data) - end. - -eval_case(Content, PMList, Data) -> - BaseL = - case Content of - {var, _, VarName} -> get_base_label(false, atol(VarName) ++ " match "); - _ -> get_base_label(false, "match smt") - end, - eval_pm(PMList, BaseL, Data). - -eval_op(Op, LeftContent, RightContent, Data) -> - case Op of - '!' -> eval_send(LeftContent, RightContent, Data); - %%% TODO: implement other basic operation - _ -> warning("operation not yet implemented", Op, Data) end. -eval_send(Destination, MessageContent, Data) -> - G = Data#wip_lv.graph, - TempData = eval_codeline(Destination, Data), - ProcName = get_pid(TempData#wip_lv.ret_var), - NewData = eval_codeline(MessageContent, TempData), - LastV = NewData#wip_lv.last_vertex, - DataSent = recordvar_to_string(NewData#wip_lv.ret_var), - VNew = common_fun:add_vertex(G), - SLabel = "send " ++ DataSent ++ " to " ++ ProcName, - digraph:add_edge(G, LastV, VNew, SLabel), - NewData#wip_lv{last_vertex = VNew}. - -get_pid(Var) -> - case Var#variable.type == pid of - true -> Var#variable.value; - false -> atol(Var#variable.name) - end. - -eval_anon_fun(Content, N, Data) -> - case Content of - {clauses, A} -> - Id = "anonfun_line" ++ integer_to_list(N), - ets:insert(?FUNAST, {ltoa(Id), A}), - eval_simple_type(function, Id, Data); - _ -> - warning("not recognized content in eval_anon_fun", Content, Data) - end. - -eval_simple_type(Type, Val, Data) -> - VarRet = #variable{type = Type, value = Val}, - Data#wip_lv{ret_var = VarRet}. - -eval_atom(Val, Data) -> - %%% check if is a registerd atom, return the pid - case ets:lookup(?REGISTERDB, Val) of - [] -> eval_simple_type(atom, Val, Data); - [{_, Pid}] -> eval_simple_type(pid, Pid, Data) - end. - -eval_list(HeadList, TailList, Data) -> - NDH = eval_codeline(HeadList, Data), - NDT = eval_codeline(TailList, NDH), - Var = NDH#wip_lv.ret_var, - VarList = NDT#wip_lv.ret_var, - NewVal = [Var] ++ VarList#variable.value, - eval_simple_type(list, NewVal, NDT). - -%%% TODO -eval_map(_Val, Data) -> - Data. - -eval_tuple(Val, Data) -> - {NewVal, NewData} = lists:foldl( - fun(I, {A, D}) -> - ND = eval_codeline(I, D), - {A ++ [ND#wip_lv.ret_var], ND} - end, - {[], Data}, - Val - ), - eval_simple_type(tuple, NewVal, NewData). - -eval_variable(VarName, Data) -> - Var = find_var(Data#wip_lv.local_vars, VarName), - RetV = - case Var of - not_found -> #variable{name = VarName}; - V -> V - end, - Data#wip_lv{ret_var = RetV}. - -recordvar_to_string(Var) -> - case Var#variable.type of - ?ANYDATA -> - atol(Var#variable.name); - Type -> - SType = atol(Type), - case Var#variable.value of - ?ANYDATA -> - SType; - Val -> - case SType of - "integer" -> integer_to_list(Val); - "float" -> io_lib:format("~.2f", [Val]); - "string" -> "[" ++ Val ++ "]"; - "atom" -> atol(Val); - "tuple" -> format_tuple(Val, fun recordvar_to_string/1); - "pid" -> "pid" ++ "_" ++ atol(Var#variable.value); - S -> S - end - end - end. - -format_tuple(VarL, Fun) -> - L = lists:foldl(fun(I, A) -> A ++ "," ++ Fun(I) end, "", VarL), - [_ | Label] = L, - "{" ++ Label ++ "}". - -get_base_label(SetPm, Label) -> - case SetPm of - true -> Label; - false -> 'ɛ' - end. - -find_var([], _) -> - not_found; -find_var([Var | Tail], Name) -> - Cond = Var#variable.name =:= Name, - case Cond of - true -> Var; - false -> find_var(Tail, Name) - end; -find_var(Data, Name) -> - LL = Data#wip_lv.local_vars, - find_var(LL, Name). - -%%% We have a main graph G1, a graph G2 and a G1's vertex. -%%% We need to append G2 to the G1's vertex. -%%% Firstly, we add to G1 as many vertex as G2's vertex number. -%%% With a map, we associate every vertex of G2 to one of the new G1'vertex -%%% Secondly, we collect each G2's edge info and then we rebuild it in G1 using the previous map -merge_graph(MainG, GToAdd, VLast) -> - VertexGToAdd = digraph:vertices(GToAdd), - % Add a number of vertex equal to VertexGToAdd - VEquiMap = lists:foldl( - %%% With this function we add a vertex and we associate it with G2's vertex - fun(Item, M) -> maps:put(Item, common_fun:add_vertex(MainG), M) end, - maps:new(), - VertexGToAdd - ), - % link the first new state created to the main graph - digraph:add_edge(MainG, VLast, maps:get(1, VEquiMap), 'ɛ'), - % Add all the edges - EdgesGToAdd = digraph:edges(GToAdd), - lists:foreach( - fun(Item) -> - {Item, V1, V2, Label} = digraph:edge(GToAdd, Item), - %%% We use the map to rebuild the exact same edge but in G1 - digraph:add_edge(MainG, maps:get(V1, VEquiMap), maps:get(V2, VEquiMap), Label) - end, - EdgesGToAdd - ), - % return last added vertex, which is the max number in the key list - maps:get(lists:max(maps:keys(VEquiMap)), VEquiMap). - -eval_func(FuncName, LV) -> - FunAst = common_fun:get_fun_ast(FuncName), - case FunAst of - not_found -> no_graph; - _ -> create_localview(FuncName, LV) - end. - -%%% Evaluate Pattern Matching's list of clauses: evaluate every branch alone, then -%%% link every last vertex's branch to a shared vertex with epsilon transaction -eval_pm(PMList, Label, Data) -> - VLast = Data#wip_lv.last_vertex, - G = Data#wip_lv.graph, - VLastList = explore_pm(PMList, Label, Data), - VRet = common_fun:add_vertex(G), - add_edges_recursive(G, VLastList, VRet, 'ɛ', VLast), - Data#wip_lv{graph = G, last_vertex = VRet}. - -%%% Explore every pm's branch and returns the list of last added vertex -explore_pm(PMList, Base, Data) -> - G = Data#wip_lv.graph, - VLast = Data#wip_lv.last_vertex, - lists:foldl( - fun(CodeLine, AddedVertexList) -> - case CodeLine of - {clause, _, Vars, Guard, Content} -> - V = common_fun:add_vertex(G), - digraph:add_edge(G, VLast, V, 'ɛ'), - IsReceive = is_list(string:find(atol(Base), "receive")), - %%% if it's a receive pm, then the label must be written - EdLabel = format_label_pm_edge(IsReceive, Vars, Guard, atol(Base)), - VL = - case IsReceive of - true -> - VNew = common_fun:add_vertex(G), - digraph:add_edge(G, V, VNew, EdLabel), - VNew; - false -> - V - end, - VDataRet = eval_pm_clause(Content, [], Data#wip_lv{last_vertex = VL}), - AddedVertexList ++ [VDataRet#wip_lv.last_vertex]; - _ -> - AddedVertexList - end - end, - [], - PMList - ). - -%%% Format the Variables with the guards in a label for the FSA -format_label_pm_edge(SetPm, VarList, GuardList, BaseLabel) when is_list(BaseLabel) -> - case SetPm of - true -> - VarsS = lists:foldl(fun(V, Acc) -> astvar_to_s(V, Acc) ++ ", " end, BaseLabel, VarList), - VarGuardS = lists:foldl(fun(G, Acc) -> guards_to_s(G, Acc) end, VarsS, GuardList), - remove_last(remove_last(VarGuardS)); - false -> - 'ɛ' - end. - -%%% Remove the last element froom a list -remove_last(List) when is_list(List) -> - {Rest, _} = lists:split(length(List) - 1, List), - Rest. - -%%% Convert a data type (ast format) to a string -astvar_to_s(VarToVal) -> - astvar_to_s(VarToVal, ""). -astvar_to_s(VarToVal, BaseL) -> - BaseL ++ - case VarToVal of - %% TODO: espandere o fare refactor di sta parte - {integer, _, Value} -> integer_to_list(Value); - {var, _, '_'} -> "_"; - {tuple, _, LVar} -> format_tuple(LVar, fun astvar_to_s/1); - {var, _, Var} -> atol(Var); - {atom, _, Atom} -> atol(Atom); - {cons, _, H, T} -> "[" ++ astvar_to_s(H) ++ ", " ++ astvar_to_s(T) ++ "]"; - {nil, _} -> "null"; - _ -> atol(?UNDEFINED) - end. - -%%% Convert the guard (ast format) to a string -guards_to_s(GlobalToVal, BaseL) -> - case GlobalToVal of - %%% Add guards if there's a guard - %%% TODO: add more infos - {op, _, _, _} -> BaseL ++ " (guards)"; - _ -> BaseL - end. - -%%% Link each vertex of a vertex's list to a given vertex, with a defined label -add_edges_recursive(G, VertexList, VertexToLink, Label, Except) -> - lists:foreach( - fun(V) -> - Cond = (V =/= Except) and (V =/= 1), - case Cond of - true -> digraph:add_edge(G, V, VertexToLink, Label); - false -> done - end - end, - VertexList - ). - %%% Set vertices as a final state if they do not have out edges -set_final(Graph) -> +set_final_state(Graph) -> VL = digraph:vertices(Graph), lists:foreach( fun(Vertex) -> @@ -612,8 +112,3 @@ set_final(Graph) -> end, VL ). - -ltoa(L) when is_list(L) -> list_to_atom(L); -ltoa(L) when is_atom(L) -> L. -atol(A) when is_atom(A) -> atom_to_list(A); -atol(A) when is_list(A) -> A. diff --git a/src/choreography/md.erl b/src/choreography/md.erl index d585c67..ec5a6de 100644 --- a/src/choreography/md.erl +++ b/src/choreography/md.erl @@ -29,9 +29,10 @@ gen_fun_ast_and_exported() -> fun(CodeLine, AccList) -> case CodeLine of {attribute, _, export, AtrList} -> - AccList ++ [#actor{name = N, arity = A} || {N, A} <- AtrList]; - {function, _, Name, _, FunAst} -> - ets:insert(?FUNAST, {Name, FunAst}), + AccList ++ [share:merge_fun_ar(N, A) || {N, A} <- AtrList]; + {function, Line, Name, Arity, FunAst} -> + % io:fwrite("[MD] Found ~p~n", [share:merge_fun_ar(Name, Arity)]), + ets:insert(?FUNAST, {share:merge_fun_ar(Name, Arity), {function, Line, FunAst}}), AccList; _ -> AccList diff --git a/src/chorer.erl b/src/chorer.erl index f804354..d7d1683 100644 --- a/src/chorer.erl +++ b/src/chorer.erl @@ -21,7 +21,7 @@ generate(InputFile, EntryPoint) -> generate(InputFile, EntryPoint, #setting{}). EntryPoint :: atom(), OutDir :: string(). generate(InputFile, EntryPoint, OutDir) -> - io:fwrite("Analysing ~p, entrypoint: '~p'~n", [InputFile, EntryPoint]), + io:fwrite("Analysing ~p, entrypoint: ~p~n", [InputFile, EntryPoint]), init_db(), Settings = #setting{output_dir = OutDir}, md:extract(InputFile), diff --git a/src/share/common_data.hrl b/src/share/common_data.hrl index c68b3d4..839f1aa 100644 --- a/src/share/common_data.hrl +++ b/src/share/common_data.hrl @@ -21,7 +21,8 @@ -record(setting, { more_info_lv = false, debug = false, - output_dir = "./" + output_dir = "./", + save_all = false }). -type setting() :: #setting{ more_info_lv :: boolean(), @@ -57,19 +58,6 @@ -record(actor, {name, arity}). -%%% Spanwed processes data stracture -%%% name: process id -%%% called_where: in which function the spawn() is been called -%%% args_called: spawn's arguments -%%% args_local: cluase match of function -%%% local_vars: local variables --record(spawned_proc, { - name = ?UNDEFINED, - called_where = ?UNDEFINED, - args_called = ?UNDEFINED, - args_local = ?UNDEFINED -}). - -record(branch, { graph = digraph:new(), last_vertex = 1, diff --git a/src/share/fsa.erl b/src/share/fsa.erl index adb8f2f..6447ed5 100644 --- a/src/share/fsa.erl +++ b/src/share/fsa.erl @@ -109,13 +109,13 @@ subset_construction(NFA, StateS, TransS, MarkedS) -> %%% Convert a list of DFA state in a given DFA graph: %%% a set of NFA states equals to a graph vertex convert_statel_to_graph(NFA, DFA, FirstDFAState, DFAStateL) -> - RetM = #{FirstDFAState => common_fun:add_vertex(DFA)}, + RetM = #{FirstDFAState => share:add_vertex(DFA)}, FoldFun = fun(DFAState, AccM) -> case DFAState =:= FirstDFAState of true -> AccM; false -> - DFAVertex = common_fun:add_vertex(DFA), + DFAVertex = share:add_vertex(DFA), case is_final_state(NFA, sets:to_list(DFAState)) of true -> set_as_final(DFA, DFAVertex); false -> ?UNDEFINED @@ -138,7 +138,7 @@ convert_transl_to_graph(DFA, DFAVertexEquivM, DFATransitionsL) -> %%% Returns an unmarked state if present, otherwise returns an empty list get_not_marked(AllStateS, MarkedStateS) -> DiffS = sets:subtract(AllStateS, MarkedStateS), - common_fun:first(stol(DiffS)). + share:first(stol(DiffS)). %%% Given a graph G, this function will delete every unreachable vertex, that is %%% if the number of incident edges on a vertex is 0, then delete it diff --git a/src/share/common_fun.erl b/src/share/share.erl similarity index 51% rename from src/share/common_fun.erl rename to src/share/share.erl index ab7af5d..06f464b 100644 --- a/src/share/common_fun.erl +++ b/src/share/share.erl @@ -1,20 +1,28 @@ --module(common_fun). +-module(share). -include("common_data.hrl"). %%% API -export([ first/1, - pick_random/1, save_graph_to_file/4, add_vertex/1, del_vertex/2, is_erlvar/1, is_uppercase/1, - is_lowercase/1, get_fun_ast/1, get_localview/1, get_graph/1, get_edgedata/1, + warning/3, + error/3, + get_base_label/2, + merge_fun_ar/2, + parse_actor_string/1, + should_minimize/1, + save_graph/4, + add_vertex_edge/2, + remove_last/1, + find_var/2, atol/1, ltoa/1 ]). @@ -23,21 +31,19 @@ %%% API %%%=================================================================== -%%% Pick a random element from a list -pick_random(X) -> lists:nth(rand:uniform(length(X)), X). - %%% Pick first element from a list first([]) -> []; first([H | _]) -> H. save_graph_to_file(Graph, Dir, FileName, Type) -> + StrinName = atol(FileName), case Type of local -> - GraphDotStr = digraph_to_dot:convert(Graph, FileName), - FilePath = filename:join([Dir, format_local_name(FileName)]); + GraphDotStr = digraph_to_dot:convert(Graph, StrinName), + FilePath = filename:join([Dir, format_local_name(StrinName)]); global -> GraphDotStr = digraph_to_dot:convert(Graph, "global"), - FilePath = filename:join([Dir, format_global_name(FileName)]) + FilePath = filename:join([Dir, format_global_name(StrinName)]) end, ToWriteData = unicode:characters_to_binary(GraphDotStr), file:make_dir(Dir), @@ -60,19 +66,11 @@ is_erlvar(Name) -> is_uppercase([FirstChar]). %%% If the input character is uppercase return true, otherwise false. -is_uppercase(Char) when - (is_list(Char)) and (length(Char) =:= 1) --> +is_uppercase(Char) when (is_list(Char)) and (length(Char) =:= 1) -> (Char >= "A") and (Char =< "Z"). -%%% If the input character is lowercase return true, otherwise false. -is_lowercase(Char) when - (is_list(Char)) and (length(Char) =:= 1) --> - (Char >= "a") and (Char =< "z"). - get_fun_ast(FunName) -> - Ast = ets:lookup(?FUNAST, FunName), + Ast = ets:lookup(?FUNAST, atol(FunName)), case Ast of [] -> not_found; [{_, A}] -> A @@ -95,24 +93,92 @@ get_graph(FunName) -> get_edgedata(FunName) -> Ast = ets:lookup(?LOCALVIEW, FunName), case Ast of - [] -> #{}; + [] -> not_found; [{_, A}] -> A#wip_lv.edge_map end. +warning(String, Content, RetData) -> + [{_, Line}] = ets:lookup(?CLINE, line), + io:fwrite("[LV] WARNING on line ~p: " ++ String ++ " ~p~n", [Line, Content]), + RetData. + +error(String, Content, RetData) -> + io:fwrite("ERROR: ~p ~p~n", [String, Content]), + RetData. + +get_base_label(SetPm, Label) -> + case SetPm of + true -> Label; + false -> epsilon() + end. + +ltoa(L) when is_list(L) -> list_to_atom(L); +ltoa(L) when is_atom(L) -> L. +atol(A) when is_atom(A) -> atom_to_list(A); +atol(A) when is_list(A) -> A. + +merge_fun_ar(Name, Arity) -> + atol(Name) ++ integer_to_list(Arity). + +parse_actor_string(String) -> + {N, A} = divide(String, length(String) - 1), + #actor{name = N, arity = A}. + +should_minimize(S) -> + io:fwrite("Minimize ~s view? [y/n] ", [S]), + {ok, [In]} = io:fread("", "~a"), + case In of + n -> false; + _ -> true + end. + +save_graph(G, Settings, FunName, Mode) -> + OutputDir = Settings#setting.output_dir, + Minimize = should_minimize(atol(FunName) ++ " " ++ atol(Mode)), + ToSaveG = + case Minimize of + true -> fsa:minimize(G); + false -> G + end, + save_graph_to_file(ToSaveG, OutputDir, FunName, Mode). + +add_vertex_edge(Label, Data) -> + G = Data#wip_lv.graph, + LastV = Data#wip_lv.last_vertex, + V = share:add_vertex(G), + digraph:add_edge(G, LastV, V, Label), + Data#wip_lv{last_vertex = V}. + +%%% Remove the last element from a list +remove_last(Item) -> + ItemList = atol(Item), + {Rest, _} = lists:split(length(ItemList) - 1, ItemList), + Rest. + +find_var([], _) -> + not_found; +find_var([Var | Tail], Name) -> + Cond = Var#variable.name =:= Name, + case Cond of + true -> Var; + false -> find_var(Tail, Name) + end; +find_var(Data, Name) -> + LL = Data#wip_lv.local_vars, + find_var(LL, Name). + %%%=================================================================== %%% Internal Functions %%%=================================================================== --spec format_local_name(Name) -> string() when Name :: string(). format_local_name(Name) -> Name ++ "_local_view.dot". - --spec format_global_name(Name) -> string() when Name :: string(). format_global_name(Name) -> Name ++ "_global_view.dot". %%% Get a new label for a given graph new_label(Graph) -> length(digraph:vertices(Graph)) + 1. -ltoa(L) when is_list(L) -> list_to_atom(L); -ltoa(L) when is_atom(L) -> L. -atol(A) when is_atom(A) -> atom_to_list(A); -atol(A) when is_list(A) -> A. +divide(S, N) -> divide(S, N, []). +divide(T, 0, H) -> {H, T}; +divide([H | T], N, L) -> divide(T, N - 1, L ++ H). + +epsilon() -> 'ɛ'. From b42e2e2138d8b4bff4038f936697fa6679006f96 Mon Sep 17 00:00:00 2001 From: geno Date: Thu, 22 Feb 2024 00:49:35 +0100 Subject: [PATCH 09/11] test.sh modified, lots of changes in eval send, self and spawn to manage processes --- examples/airline/agent1_local_view.dot | 2 +- examples/airline/main0_global_view.dot | 4 +- examples/airline/main0_local_view.dot | 18 +- examples/async/dummy10_local_view.dot | 11 + examples/async/dummy1_local_view.dot | 11 - examples/async/dummy20_local_view.dot | 11 + examples/async/dummy2_local_view.dot | 11 - examples/async/main0_global_view.dot | 18 ++ .../main0_local_view.dot} | 8 +- examples/async/main_global_view.dot | 19 -- .../conditional-case/dummy1_local_view.dot | 11 + .../conditional-case/dummy_local_view.dot | 11 - .../conditional-case/main0_global_view.dot | 15 + .../conditional-case/main0_local_view.dot | 25 ++ .../conditional-case/main_global_view.dot | 47 --- examples/conditional-case/main_local_view.dot | 24 -- examples/customer/customer0_local_view.dot | 17 ++ examples/customer/customer_local_view.dot | 17 -- examples/customer/main0_global_view.dot | 21 ++ .../main0_local_view.dot} | 8 +- examples/customer/main_global_view.dot | 23 -- examples/customer/store0_local_view.dot | 17 ++ examples/customer/store_local_view.dot | 17 -- ...y_local_view.dot => dummy1_local_view.dot} | 4 +- .../main0_global_view.dot} | 4 +- .../for-loop-recursion/main0_local_view.dot | 12 + .../for-loop-recursion/main_global_view.dot | 19 -- .../for-loop-recursion/main_local_view.dot | 12 - examples/function-call/dummy1_local_view.dot | 11 + examples/function-call/dummy_local_view.dot | 11 - .../main0_global_view.dot} | 2 + .../main0_local_view.dot} | 8 +- examples/function-call/main_global_view.dot | 13 - examples/function-call/main_local_view.dot | 11 - examples/hello/greet0_global_view.dot | 9 + examples/hello/greet0_local_view.dot | 12 + examples/hello/greet_local_view.dot | 12 - examples/hello/hello.erl | 4 +- ...cal_view.dot => anonfun_10_local_view.dot} | 4 +- ...cal_view.dot => anonfun_15_local_view.dot} | 4 +- .../high-order-fun/greet0_global_view.dot | 36 +++ examples/high-order-fun/greet0_local_view.dot | 19 ++ examples/high-order-fun/greet_local_view.dot | 15 - examples/high-order-fun/hof.erl | 3 + .../{c_local_view.dot => a0_local_view.dot} | 8 +- .../{b_local_view.dot => b0_local_view.dot} | 8 +- .../{a_local_view.dot => c0_local_view.dot} | 8 +- examples/if-cases/main0_global_view.dot | 57 ++++ examples/if-cases/main0_local_view.dot | 24 ++ examples/if-cases/main_global_view.dot | 73 ----- examples/if-cases/main_local_view.dot | 24 -- examples/serverclient/client0_local_view.dot | 14 + examples/serverclient/client_local_view.dot | 14 - .../serverclient/handle_req1_local_view.dot | 10 + .../serverclient/handle_req_local_view.dot | 10 - examples/serverclient/main0_global_view.dot | 163 +++++++++++ examples/serverclient/main0_local_view.dot | 13 + examples/serverclient/main_global_view.dot | 20 -- examples/serverclient/server0_local_view.dot | 16 ++ examples/serverclient/server_local_view.dot | 16 -- examples/serverclient/serverclient.erl | 1 + examples/test/barber/test0_local_view.dot | 19 ++ examples/test/barber/test_local_view.dot | 19 -- .../{b_local_view.dot => b0_local_view.dot} | 4 +- .../{c_local_view.dot => c1_local_view.dot} | 6 +- examples/test/foo1/test0_global_view.dot | 18 ++ examples/test/foo1/test0_local_view.dot | 15 + examples/test/foo1/test_global_view.dot | 19 -- examples/test/foo1/test_local_view.dot | 15 - .../{a_local_view.dot => a1_local_view.dot} | 4 +- .../foo2/b0_local_view.dot} | 8 +- .../{c_local_view.dot => c0_local_view.dot} | 6 +- ..._global_view.dot => test0_global_view.dot} | 4 +- examples/test/foo2/test0_local_view.dot | 11 + .../{a_local_view.dot => a1_local_view.dot} | 6 +- .../{b_local_view.dot => b1_local_view.dot} | 4 +- examples/test/foo3/c_local_view.dot | 11 - examples/test/foo3/test0_global_view.dot | 11 + examples/test/foo3/test0_local_view.dot | 17 ++ examples/test/foo3/test_global_view.dot | 41 --- examples/test/foo3/test_local_view.dot | 17 -- examples/test/foo4/a_local_view.dot | 11 - examples/test/foo4/b_local_view.dot | 9 - examples/test/foo4/c_local_view.dot | 11 - examples/test/foo4/r0_local_view.dot | 13 + examples/test/foo4/r_local_view.dot | 13 - examples/test/foo4/test0_global_view.dot | 36 +++ examples/test/foo4/test0_local_view.dot | 19 ++ examples/test/foo4/test_global_view.dot | 43 --- examples/test/foo4/test_local_view.dot | 19 -- .../{w1_local_view.dot => w11_local_view.dot} | 6 +- .../{w2_local_view.dot => w21_local_view.dot} | 6 +- examples/test/foo5/a_local_view.dot | 11 - examples/test/foo5/b_local_view.dot | 9 - examples/test/foo5/c_local_view.dot | 11 - ...y_local_view.dot => proxy1_local_view.dot} | 6 +- examples/test/foo5/r_local_view.dot | 13 - examples/test/foo5/target0_local_view.dot | 15 + examples/test/foo5/target_local_view.dot | 15 - examples/test/foo5/test0_global_view.dot | 18 ++ examples/test/foo5/test0_local_view.dot | 21 ++ examples/test/foo5/test_global_view.dot | 19 -- examples/test/foo5/test_local_view.dot | 21 -- examples/test/foo5/w1_local_view.dot | 11 - examples/test/foo5/w2_local_view.dot | 11 - ..._local_view.dot => client1_local_view.dot} | 4 +- examples/test/foo6/client_gen_local_view.dot | 11 - .../test/foo6/client_server_local_view.dot | 13 - ..._local_view.dot => server0_local_view.dot} | 4 +- examples/test/foo6/test0_global_view.dot | 12 + examples/test/foo6/test0_local_view.dot | 12 + examples/test/foo6/test_global_view.dot | 13 - examples/test/foo6/test_local_view.dot | 13 - examples/test/ping/ping_local_view.dot | 12 - examples/test/ping/pong0_local_view.dot | 14 + examples/test/ping/pong_local_view.dot | 14 - examples/test/ping/start0_global_view.dot | 11 + examples/test/ping/start0_local_view.dot | 16 ++ examples/test/ping/start_global_view.dot | 14 - examples/test/ping/start_local_view.dot | 16 -- examples/ticktackloop/start0_global_view.dot | 16 ++ examples/ticktackloop/start0_local_view.dot | 13 + examples/ticktackloop/start_global_view.dot | 16 -- examples/ticktackloop/start_local_view.dot | 13 - .../ticktackloop/tac_loop0_local_view.dot | 14 + examples/ticktackloop/tac_loop_local_view.dot | 14 - .../ticktackloop/tic_loop0_local_view.dot | 14 + examples/ticktackloop/tic_loop_local_view.dot | 14 - examples/ticktackstop/random0_local_view.dot | 9 + examples/ticktackstop/random_local_view.dot | 9 - examples/ticktackstop/start0_global_view.dot | 20 ++ examples/ticktackstop/start0_local_view.dot | 14 + examples/ticktackstop/start_global_view.dot | 33 --- examples/ticktackstop/start_local_view.dot | 15 - .../ticktackstop/tac_loop0_local_view.dot | 14 + examples/ticktackstop/tac_loop_local_view.dot | 14 - .../ticktackstop/tic_loop0_local_view.dot | 14 + examples/ticktackstop/tic_loop_local_view.dot | 14 - examples/trick/a0_local_view.dot | 11 + examples/trick/a_local_view.dot | 11 - .../b0_local_view.dot} | 8 +- examples/trick/b_local_view.dot | 11 - .../c0_local_view.dot} | 8 +- examples/trick/main0_global_view.dot | 24 ++ examples/trick/main0_local_view.dot | 13 + examples/trick/main_global_view.dot | 25 -- examples/trick/main_local_view.dot | 13 - examples/violation/incrementer_local_view.dot | 19 -- examples/violation/main_global_view.dot | 271 ------------------ examples/violation/main_local_view.dot | 15 - examples/violation/meManager_local_view.dot | 12 - examples/violation/varManager_local_view.dot | 11 - src/choreography/actor_emul.erl | 20 +- src/choreography/eval.erl | 101 ++++--- src/choreography/gv.erl | 105 ++++--- src/choreography/lv.erl | 44 ++- src/share/common_data.hrl | 12 +- src/share/share.erl | 59 ++-- test.py | 35 +++ test.sh | 22 -- 160 files changed, 1327 insertions(+), 1664 deletions(-) create mode 100644 examples/async/dummy10_local_view.dot delete mode 100644 examples/async/dummy1_local_view.dot create mode 100644 examples/async/dummy20_local_view.dot delete mode 100644 examples/async/dummy2_local_view.dot create mode 100644 examples/async/main0_global_view.dot rename examples/{customer/main_local_view.dot => async/main0_local_view.dot} (51%) delete mode 100644 examples/async/main_global_view.dot create mode 100644 examples/conditional-case/dummy1_local_view.dot delete mode 100644 examples/conditional-case/dummy_local_view.dot create mode 100644 examples/conditional-case/main0_global_view.dot create mode 100644 examples/conditional-case/main0_local_view.dot delete mode 100644 examples/conditional-case/main_global_view.dot delete mode 100644 examples/conditional-case/main_local_view.dot create mode 100644 examples/customer/customer0_local_view.dot delete mode 100644 examples/customer/customer_local_view.dot create mode 100644 examples/customer/main0_global_view.dot rename examples/{async/main_local_view.dot => customer/main0_local_view.dot} (51%) delete mode 100644 examples/customer/main_global_view.dot create mode 100644 examples/customer/store0_local_view.dot delete mode 100644 examples/customer/store_local_view.dot rename examples/for-loop-recursion/{dummy_local_view.dot => dummy1_local_view.dot} (76%) rename examples/{high-order-fun/greet_global_view.dot => for-loop-recursion/main0_global_view.dot} (64%) create mode 100644 examples/for-loop-recursion/main0_local_view.dot delete mode 100644 examples/for-loop-recursion/main_global_view.dot delete mode 100644 examples/for-loop-recursion/main_local_view.dot create mode 100644 examples/function-call/dummy1_local_view.dot delete mode 100644 examples/function-call/dummy_local_view.dot rename examples/{hello/greet_global_view.dot => function-call/main0_global_view.dot} (60%) rename examples/{serverclient/main_local_view.dot => function-call/main0_local_view.dot} (52%) delete mode 100644 examples/function-call/main_global_view.dot delete mode 100644 examples/function-call/main_local_view.dot create mode 100644 examples/hello/greet0_global_view.dot create mode 100644 examples/hello/greet0_local_view.dot delete mode 100644 examples/hello/greet_local_view.dot rename examples/high-order-fun/{Fun_local_view.dot => anonfun_10_local_view.dot} (73%) rename examples/high-order-fun/{anonfun_line15_local_view.dot => anonfun_15_local_view.dot} (71%) create mode 100644 examples/high-order-fun/greet0_global_view.dot create mode 100644 examples/high-order-fun/greet0_local_view.dot delete mode 100644 examples/high-order-fun/greet_local_view.dot rename examples/if-cases/{c_local_view.dot => a0_local_view.dot} (70%) rename examples/if-cases/{b_local_view.dot => b0_local_view.dot} (70%) rename examples/if-cases/{a_local_view.dot => c0_local_view.dot} (70%) create mode 100644 examples/if-cases/main0_global_view.dot create mode 100644 examples/if-cases/main0_local_view.dot delete mode 100644 examples/if-cases/main_global_view.dot delete mode 100644 examples/if-cases/main_local_view.dot create mode 100644 examples/serverclient/client0_local_view.dot delete mode 100644 examples/serverclient/client_local_view.dot create mode 100644 examples/serverclient/handle_req1_local_view.dot delete mode 100644 examples/serverclient/handle_req_local_view.dot create mode 100644 examples/serverclient/main0_global_view.dot create mode 100644 examples/serverclient/main0_local_view.dot delete mode 100644 examples/serverclient/main_global_view.dot create mode 100644 examples/serverclient/server0_local_view.dot delete mode 100644 examples/serverclient/server_local_view.dot create mode 100644 examples/test/barber/test0_local_view.dot delete mode 100644 examples/test/barber/test_local_view.dot rename examples/test/foo1/{b_local_view.dot => b0_local_view.dot} (77%) rename examples/test/foo1/{c_local_view.dot => c1_local_view.dot} (84%) create mode 100644 examples/test/foo1/test0_global_view.dot create mode 100644 examples/test/foo1/test0_local_view.dot delete mode 100644 examples/test/foo1/test_global_view.dot delete mode 100644 examples/test/foo1/test_local_view.dot rename examples/test/foo2/{a_local_view.dot => a1_local_view.dot} (78%) rename examples/{trick/c_local_view.dot => test/foo2/b0_local_view.dot} (54%) rename examples/test/foo2/{c_local_view.dot => c0_local_view.dot} (68%) rename examples/test/foo2/{test_global_view.dot => test0_global_view.dot} (69%) create mode 100644 examples/test/foo2/test0_local_view.dot rename examples/test/foo3/{a_local_view.dot => a1_local_view.dot} (84%) rename examples/test/foo3/{b_local_view.dot => b1_local_view.dot} (78%) delete mode 100644 examples/test/foo3/c_local_view.dot create mode 100644 examples/test/foo3/test0_global_view.dot create mode 100644 examples/test/foo3/test0_local_view.dot delete mode 100644 examples/test/foo3/test_global_view.dot delete mode 100644 examples/test/foo3/test_local_view.dot delete mode 100644 examples/test/foo4/a_local_view.dot delete mode 100644 examples/test/foo4/b_local_view.dot delete mode 100644 examples/test/foo4/c_local_view.dot create mode 100644 examples/test/foo4/r0_local_view.dot delete mode 100644 examples/test/foo4/r_local_view.dot create mode 100644 examples/test/foo4/test0_global_view.dot create mode 100644 examples/test/foo4/test0_local_view.dot delete mode 100644 examples/test/foo4/test_global_view.dot delete mode 100644 examples/test/foo4/test_local_view.dot rename examples/test/foo4/{w1_local_view.dot => w11_local_view.dot} (83%) rename examples/test/foo4/{w2_local_view.dot => w21_local_view.dot} (83%) delete mode 100644 examples/test/foo5/a_local_view.dot delete mode 100644 examples/test/foo5/b_local_view.dot delete mode 100644 examples/test/foo5/c_local_view.dot rename examples/test/foo5/{proxy_local_view.dot => proxy1_local_view.dot} (82%) delete mode 100644 examples/test/foo5/r_local_view.dot create mode 100644 examples/test/foo5/target0_local_view.dot delete mode 100644 examples/test/foo5/target_local_view.dot create mode 100644 examples/test/foo5/test0_global_view.dot create mode 100644 examples/test/foo5/test0_local_view.dot delete mode 100644 examples/test/foo5/test_global_view.dot delete mode 100644 examples/test/foo5/test_local_view.dot delete mode 100644 examples/test/foo5/w1_local_view.dot delete mode 100644 examples/test/foo5/w2_local_view.dot rename examples/test/foo6/{client_local_view.dot => client1_local_view.dot} (75%) delete mode 100644 examples/test/foo6/client_gen_local_view.dot delete mode 100644 examples/test/foo6/client_server_local_view.dot rename examples/test/foo6/{server_local_view.dot => server0_local_view.dot} (68%) create mode 100644 examples/test/foo6/test0_global_view.dot create mode 100644 examples/test/foo6/test0_local_view.dot delete mode 100644 examples/test/foo6/test_global_view.dot delete mode 100644 examples/test/foo6/test_local_view.dot delete mode 100644 examples/test/ping/ping_local_view.dot create mode 100644 examples/test/ping/pong0_local_view.dot delete mode 100644 examples/test/ping/pong_local_view.dot create mode 100644 examples/test/ping/start0_global_view.dot create mode 100644 examples/test/ping/start0_local_view.dot delete mode 100644 examples/test/ping/start_global_view.dot delete mode 100644 examples/test/ping/start_local_view.dot create mode 100644 examples/ticktackloop/start0_global_view.dot create mode 100644 examples/ticktackloop/start0_local_view.dot delete mode 100644 examples/ticktackloop/start_global_view.dot delete mode 100644 examples/ticktackloop/start_local_view.dot create mode 100644 examples/ticktackloop/tac_loop0_local_view.dot delete mode 100644 examples/ticktackloop/tac_loop_local_view.dot create mode 100644 examples/ticktackloop/tic_loop0_local_view.dot delete mode 100644 examples/ticktackloop/tic_loop_local_view.dot create mode 100644 examples/ticktackstop/random0_local_view.dot delete mode 100644 examples/ticktackstop/random_local_view.dot create mode 100644 examples/ticktackstop/start0_global_view.dot create mode 100644 examples/ticktackstop/start0_local_view.dot delete mode 100644 examples/ticktackstop/start_global_view.dot delete mode 100644 examples/ticktackstop/start_local_view.dot create mode 100644 examples/ticktackstop/tac_loop0_local_view.dot delete mode 100644 examples/ticktackstop/tac_loop_local_view.dot create mode 100644 examples/ticktackstop/tic_loop0_local_view.dot delete mode 100644 examples/ticktackstop/tic_loop_local_view.dot create mode 100644 examples/trick/a0_local_view.dot delete mode 100644 examples/trick/a_local_view.dot rename examples/{test/foo2/test_local_view.dot => trick/b0_local_view.dot} (53%) delete mode 100644 examples/trick/b_local_view.dot rename examples/{test/foo2/b_local_view.dot => trick/c0_local_view.dot} (54%) create mode 100644 examples/trick/main0_global_view.dot create mode 100644 examples/trick/main0_local_view.dot delete mode 100644 examples/trick/main_global_view.dot delete mode 100644 examples/trick/main_local_view.dot delete mode 100644 examples/violation/incrementer_local_view.dot delete mode 100644 examples/violation/main_global_view.dot delete mode 100644 examples/violation/main_local_view.dot delete mode 100644 examples/violation/meManager_local_view.dot delete mode 100644 examples/violation/varManager_local_view.dot create mode 100755 test.py delete mode 100755 test.sh diff --git a/examples/airline/agent1_local_view.dot b/examples/airline/agent1_local_view.dot index c7e1f9f..de697fd 100644 --- a/examples/airline/agent1_local_view.dot +++ b/examples/airline/agent1_local_view.dot @@ -5,6 +5,6 @@ digraph agent1 { n_0 -> n_1 [arrowhead=none]; n_2 [id="2", shape=circle, label="2"]; - n_1 -> n_2 [id="[$e|0]", label="send {sell,pid_self} to Pid2"]; n_2 -> n_1 [id="[$e|3]", label="receive {booked,_}"]; + n_1 -> n_2 [id="[$e|0]", label="send {sell,pid_self} to Pid2"]; } diff --git a/examples/airline/main0_global_view.dot b/examples/airline/main0_global_view.dot index 03055e6..986c711 100644 --- a/examples/airline/main0_global_view.dot +++ b/examples/airline/main0_global_view.dot @@ -6,6 +6,6 @@ digraph global { n_2 [id="2", shape=circle, label="2"]; n_3 [id="3", shape=circle, label="3"]; - n_1 -> n_2 [id="[$e|0]", label="main0Δagent1_0"]; - n_2 -> n_3 [id="[$e|1]", label="main0Δagent1_1"]; + n_2 -> n_3 [id="[$e|1]", label="main0/0Δagent1/1"]; + n_1 -> n_2 [id="[$e|0]", label="main0/0Δagent1/0"]; } diff --git a/examples/airline/main0_local_view.dot b/examples/airline/main0_local_view.dot index 147e1a6..96e1bde 100644 --- a/examples/airline/main0_local_view.dot +++ b/examples/airline/main0_local_view.dot @@ -1,14 +1,14 @@ digraph main0 { rankdir="LR"; n_0 [label="main0", shape="plaintext"]; - n_1 [id="5", shape=circle, label="4"]; - n_2 [id="1", shape=circle, label="1"]; - n_0 -> n_2 [arrowhead=none]; - n_3 [id="2", shape=doublecircle, label="3"]; - n_4 [id="4", shape=circle, label="2"]; + n_1 [id="1", shape=circle, label="1"]; + n_0 -> n_1 [arrowhead=none]; + n_2 [id="2", shape=circle, label="2"]; + n_3 [id="4", shape=circle, label="4"]; + n_4 [id="3", shape=circle, label="3"]; - n_1 -> n_3 [id="[$e|5]", label="send {booked,Num} to Pid1"]; - n_4 -> n_3 [id="[$e|3]", label="spawn agent1_1"]; - n_3 -> n_1 [id="[$e|2]", label="receive {sell,Pid1}"]; - n_2 -> n_4 [id="[$e|1]", label="spawn agent1_0"]; + n_1 -> n_2 [id="[$e|3]", label="spawn agent1/0"]; + n_4 -> n_3 [id="[$e|2]", label="receive {sell,Pid1}"]; + n_3 -> n_4 [id="[$e|5]", label="send {booked,Num} to Pid1"]; + n_2 -> n_4 [id="[$e|0]", label="spawn agent1/1"]; } diff --git a/examples/async/dummy10_local_view.dot b/examples/async/dummy10_local_view.dot new file mode 100644 index 0000000..469fa95 --- /dev/null +++ b/examples/async/dummy10_local_view.dot @@ -0,0 +1,11 @@ +digraph dummy10 { + rankdir="LR"; + n_0 [label="dummy10", shape="plaintext"]; + n_1 [id="1", shape=circle, label="1"]; + n_0 -> n_1 [arrowhead=none]; + n_2 [id="2", shape=circle, label="2"]; + n_3 [id="3", shape=doublecircle, label="3"]; + + n_1 -> n_2 [id="[$e|1]", label="send bello to dummy20/0"]; + n_2 -> n_3 [id="[$e|0]", label="receive ciao"]; +} diff --git a/examples/async/dummy1_local_view.dot b/examples/async/dummy1_local_view.dot deleted file mode 100644 index 3e56cec..0000000 --- a/examples/async/dummy1_local_view.dot +++ /dev/null @@ -1,11 +0,0 @@ -digraph dummy1 { - rankdir="LR"; - n_0 [label="dummy1", shape="plaintext"]; - n_1 [id="1", shape=circle, label="1"]; - n_0 -> n_1 [arrowhead=none]; - n_2 [id="2", shape=doublecircle, label="3"]; - n_3 [id="3", shape=circle, label="2"]; - - n_3 -> n_2 [id="[$e|1]", label="receive ciao"]; - n_1 -> n_3 [id="[$e|0]", label="send bello to dummy2_0"]; -} diff --git a/examples/async/dummy20_local_view.dot b/examples/async/dummy20_local_view.dot new file mode 100644 index 0000000..0354f03 --- /dev/null +++ b/examples/async/dummy20_local_view.dot @@ -0,0 +1,11 @@ +digraph dummy20 { + rankdir="LR"; + n_0 [label="dummy20", shape="plaintext"]; + n_1 [id="1", shape=circle, label="1"]; + n_0 -> n_1 [arrowhead=none]; + n_2 [id="2", shape=circle, label="2"]; + n_3 [id="3", shape=doublecircle, label="3"]; + + n_2 -> n_3 [id="[$e|1]", label="receive bello"]; + n_1 -> n_2 [id="[$e|0]", label="send ciao to dummy10/0"]; +} diff --git a/examples/async/dummy2_local_view.dot b/examples/async/dummy2_local_view.dot deleted file mode 100644 index f3c5f58..0000000 --- a/examples/async/dummy2_local_view.dot +++ /dev/null @@ -1,11 +0,0 @@ -digraph dummy2 { - rankdir="LR"; - n_0 [label="dummy2", shape="plaintext"]; - n_1 [id="1", shape=circle, label="1"]; - n_0 -> n_1 [arrowhead=none]; - n_2 [id="2", shape=doublecircle, label="3"]; - n_3 [id="3", shape=circle, label="2"]; - - n_3 -> n_2 [id="[$e|1]", label="receive bello"]; - n_1 -> n_3 [id="[$e|0]", label="send ciao to dummy1_0"]; -} diff --git a/examples/async/main0_global_view.dot b/examples/async/main0_global_view.dot new file mode 100644 index 0000000..0212b52 --- /dev/null +++ b/examples/async/main0_global_view.dot @@ -0,0 +1,18 @@ +digraph global { + rankdir="LR"; + n_0 [label="global", shape="plaintext"]; + n_1 [id="5", shape=circle, label="6"]; + n_2 [id="1", shape=circle, label="1"]; + n_0 -> n_2 [arrowhead=none]; + n_3 [id="2", shape=circle, label="2"]; + n_4 [id="4", shape=circle, label="4"]; + n_5 [id="7", shape=circle, label="5"]; + n_6 [id="3", shape=circle, label="3"]; + + n_2 -> n_3 [id="[$e|3]", label="main0/0Δdummy10/0"]; + n_3 -> n_6 [id="[$e|1]", label="main0/0Δdummy20/0"]; + n_5 -> n_1 [id="[$e|6]", label="dummy10/0→dummy20/0:bello"]; + n_4 -> n_1 [id="[$e|2]", label="dummy20/0→dummy10/0:ciao"]; + n_6 -> n_5 [id="[$e|5]", label="dummy20/0→dummy10/0:ciao"]; + n_6 -> n_4 [id="[$e|0]", label="dummy10/0→dummy20/0:bello"]; +} diff --git a/examples/customer/main_local_view.dot b/examples/async/main0_local_view.dot similarity index 51% rename from examples/customer/main_local_view.dot rename to examples/async/main0_local_view.dot index 16d9271..5c7e5bd 100644 --- a/examples/customer/main_local_view.dot +++ b/examples/async/main0_local_view.dot @@ -1,11 +1,11 @@ -digraph main { +digraph main0 { rankdir="LR"; - n_0 [label="main", shape="plaintext"]; + n_0 [label="main0", shape="plaintext"]; n_1 [id="1", shape=circle, label="1"]; n_0 -> n_1 [arrowhead=none]; n_2 [id="2", shape=circle, label="2"]; n_3 [id="3", shape=doublecircle, label="3"]; - n_2 -> n_3 [id="[$e|1]", label="spawn store_0"]; - n_1 -> n_2 [id="[$e|0]", label="spawn customer_0"]; + n_2 -> n_3 [id="[$e|1]", label="spawn dummy20/0"]; + n_1 -> n_2 [id="[$e|0]", label="spawn dummy10/0"]; } diff --git a/examples/async/main_global_view.dot b/examples/async/main_global_view.dot deleted file mode 100644 index 6d011f2..0000000 --- a/examples/async/main_global_view.dot +++ /dev/null @@ -1,19 +0,0 @@ -digraph global { - rankdir="LR"; - n_0 [label="global", shape="plaintext"]; - n_1 [id="5", shape=circle, label="5"]; - n_2 [id="6", shape=circle, label="6"]; - n_3 [id="1", shape=circle, label="1"]; - n_0 -> n_3 [arrowhead=none]; - n_4 [id="2", shape=circle, label="2"]; - n_5 [id="4", shape=circle, label="4"]; - n_6 [id="7", shape=circle, label="7"]; - n_7 [id="3", shape=circle, label="3"]; - - n_7 -> n_5 [id="[$e|2]", label="dummy2_0→dummy1_0:ciao"]; - n_4 -> n_7 [id="[$e|1]", label="mainΔdummy2_0"]; - n_5 -> n_2 [id="[$e|4]", label="dummy1_0→dummy2_0:bello"]; - n_1 -> n_6 [id="[$e|5]", label="dummy2_0→dummy1_0:ciao"]; - n_7 -> n_1 [id="[$e|3]", label="dummy1_0→dummy2_0:bello"]; - n_3 -> n_4 [id="[$e|0]", label="mainΔdummy1_0"]; -} diff --git a/examples/conditional-case/dummy1_local_view.dot b/examples/conditional-case/dummy1_local_view.dot new file mode 100644 index 0000000..2ada5ea --- /dev/null +++ b/examples/conditional-case/dummy1_local_view.dot @@ -0,0 +1,11 @@ +digraph dummy1 { + rankdir="LR"; + n_0 [label="dummy1", shape="plaintext"]; + n_1 [id="1", shape=circle, label="1"]; + n_0 -> n_1 [arrowhead=none]; + n_2 [id="2", shape=circle, label="2"]; + n_3 [id="3", shape=doublecircle, label="3"]; + + n_1 -> n_2 [id="[$e|0]", label="send {pid_self,integer} to Pid"]; + n_2 -> n_3 [id="[$e|1]", label="receive Str"]; +} diff --git a/examples/conditional-case/dummy_local_view.dot b/examples/conditional-case/dummy_local_view.dot deleted file mode 100644 index 5db7e33..0000000 --- a/examples/conditional-case/dummy_local_view.dot +++ /dev/null @@ -1,11 +0,0 @@ -digraph dummy { - rankdir="LR"; - n_0 [label="dummy", shape="plaintext"]; - n_1 [id="1", shape=circle, label="1"]; - n_0 -> n_1 [arrowhead=none]; - n_2 [id="2", shape=doublecircle, label="3"]; - n_3 [id="3", shape=circle, label="2"]; - - n_3 -> n_2 [id="[$e|0]", label="receive Str"]; - n_1 -> n_3 [id="[$e|1]", label="send {pid_self,integer} to Pid"]; -} diff --git a/examples/conditional-case/main0_global_view.dot b/examples/conditional-case/main0_global_view.dot new file mode 100644 index 0000000..56a109b --- /dev/null +++ b/examples/conditional-case/main0_global_view.dot @@ -0,0 +1,15 @@ +digraph global { + rankdir="LR"; + n_0 [label="global", shape="plaintext"]; + n_1 [id="5", shape=circle, label="4"]; + n_2 [id="1", shape=circle, label="1"]; + n_0 -> n_2 [arrowhead=none]; + n_3 [id="2", shape=circle, label="2"]; + n_4 [id="4", shape=circle, label="5"]; + n_5 [id="3", shape=circle, label="3"]; + + n_2 -> n_3 [id="[$e|0]", label="main0/0Δdummy1/0"]; + n_1 -> n_4 [id="[$e|3]", label="main0/0Δdummy1/3"]; + n_5 -> n_1 [id="[$e|2]", label="main0/0Δdummy1/2"]; + n_3 -> n_5 [id="[$e|1]", label="main0/0Δdummy1/1"]; +} diff --git a/examples/conditional-case/main0_local_view.dot b/examples/conditional-case/main0_local_view.dot new file mode 100644 index 0000000..14a22ae --- /dev/null +++ b/examples/conditional-case/main0_local_view.dot @@ -0,0 +1,25 @@ +digraph main0 { + rankdir="LR"; + n_0 [label="main0", shape="plaintext"]; + n_1 [id="11", shape=circle, label="3"]; + n_2 [id="6", shape=circle, label="4"]; + n_3 [id="10", shape=circle, label="5"]; + n_4 [id="1", shape=circle, label="1"]; + n_0 -> n_4 [arrowhead=none]; + n_5 [id="2", shape=circle, label="7"]; + n_6 [id="8", shape=doublecircle, label="8"]; + n_7 [id="4", shape=circle, label="2"]; + n_8 [id="3", shape=circle, label="6"]; + + n_8 -> n_5 [id="[$e|16]", label="send "Ciao A" to dummy1/0"]; + n_8 -> n_5 [id="[$e|0]", label="send "Ciao C" to dummy1/2"]; + n_8 -> n_6 [id="[$e|9]", label="receive Obj"]; + n_8 -> n_5 [id="[$e|14]", label="send "Ciao D" to dummy1/3"]; + n_1 -> n_2 [id="[$e|5]", label="spawn dummy1/2"]; + n_5 -> n_6 [id="[$e|3]", label="receive Obj"]; + n_3 -> n_8 [id="[$e|8]", label="receive {Process,_}"]; + n_2 -> n_3 [id="[$e|6]", label="spawn dummy1/3"]; + n_7 -> n_1 [id="[$e|11]", label="spawn dummy1/1"]; + n_8 -> n_5 [id="[$e|15]", label="send "Ciao B" to dummy1/1"]; + n_4 -> n_7 [id="[$e|4]", label="spawn dummy1/0"]; +} diff --git a/examples/conditional-case/main_global_view.dot b/examples/conditional-case/main_global_view.dot deleted file mode 100644 index 68076ec..0000000 --- a/examples/conditional-case/main_global_view.dot +++ /dev/null @@ -1,47 +0,0 @@ -digraph global { - rankdir="LR"; - n_0 [label="global", shape="plaintext"]; - n_1 [id="20", shape=circle, label="20"]; - n_2 [id="5", shape=circle, label="5"]; - n_3 [id="15", shape=circle, label="15"]; - n_4 [id="19", shape=circle, label="19"]; - n_5 [id="12", shape=circle, label="12"]; - n_6 [id="11", shape=circle, label="11"]; - n_7 [id="17", shape=circle, label="17"]; - n_8 [id="18", shape=circle, label="18"]; - n_9 [id="14", shape=circle, label="14"]; - n_10 [id="6", shape=circle, label="6"]; - n_11 [id="13", shape=circle, label="13"]; - n_12 [id="10", shape=circle, label="10"]; - n_13 [id="1", shape=circle, label="1"]; - n_0 -> n_13 [arrowhead=none]; - n_14 [id="9", shape=circle, label="9"]; - n_15 [id="2", shape=circle, label="2"]; - n_16 [id="21", shape=circle, label="21"]; - n_17 [id="8", shape=circle, label="8"]; - n_18 [id="4", shape=circle, label="4"]; - n_19 [id="7", shape=circle, label="7"]; - n_20 [id="3", shape=circle, label="3"]; - n_21 [id="16", shape=circle, label="16"]; - - n_2 -> n_19 [id="[$e|5]", label="dummy_1→main:{pid_self,integer}"]; - n_14 -> n_1 [id="[$e|18]", label="dummy_1→main:{pid_self,integer}"]; - n_13 -> n_15 [id="[$e|0]", label="mainΔdummy_0"]; - n_18 -> n_2 [id="[$e|3]", label="mainΔdummy_3"]; - n_2 -> n_17 [id="[$e|6]", label="dummy_2→main:{pid_self,integer}"]; - n_10 -> n_5 [id="[$e|10]", label="dummy_3→main:{pid_self,integer}"]; - n_19 -> n_9 [id="[$e|12]", label="dummy_2→main:{pid_self,integer}"]; - n_10 -> n_12 [id="[$e|8]", label="dummy_1→main:{pid_self,integer}"]; - n_10 -> n_6 [id="[$e|9]", label="dummy_2→main:{pid_self,integer}"]; - n_15 -> n_20 [id="[$e|1]", label="mainΔdummy_1"]; - n_2 -> n_10 [id="[$e|4]", label="dummy_0→main:{pid_self,integer}"]; - n_17 -> n_8 [id="[$e|16]", label="dummy_3→main:{pid_self,integer}"]; - n_20 -> n_18 [id="[$e|2]", label="mainΔdummy_2"]; - n_17 -> n_7 [id="[$e|15]", label="dummy_1→main:{pid_self,integer}"]; - n_14 -> n_4 [id="[$e|17]", label="dummy_0→main:{pid_self,integer}"]; - n_19 -> n_11 [id="[$e|11]", label="dummy_0→main:{pid_self,integer}"]; - n_19 -> n_3 [id="[$e|13]", label="dummy_3→main:{pid_self,integer}"]; - n_2 -> n_14 [id="[$e|7]", label="dummy_3→main:{pid_self,integer}"]; - n_17 -> n_21 [id="[$e|14]", label="dummy_0→main:{pid_self,integer}"]; - n_14 -> n_16 [id="[$e|19]", label="dummy_2→main:{pid_self,integer}"]; -} diff --git a/examples/conditional-case/main_local_view.dot b/examples/conditional-case/main_local_view.dot deleted file mode 100644 index b0950dc..0000000 --- a/examples/conditional-case/main_local_view.dot +++ /dev/null @@ -1,24 +0,0 @@ -digraph main { - rankdir="LR"; - n_0 [label="main", shape="plaintext"]; - n_1 [id="5", shape=doublecircle, label="8"]; - n_2 [id="6", shape=circle, label="5"]; - n_3 [id="10", shape=circle, label="4"]; - n_4 [id="1", shape=circle, label="1"]; - n_0 -> n_4 [arrowhead=none]; - n_5 [id="2", shape=circle, label="2"]; - n_6 [id="4", shape=circle, label="3"]; - n_7 [id="7", shape=circle, label="6"]; - n_8 [id="3", shape=circle, label="7"]; - - n_4 -> n_5 [id="[$e|3]", label="spawn dummy_0"]; - n_6 -> n_3 [id="[$e|10]", label="spawn dummy_2"]; - n_2 -> n_7 [id="[$e|12]", label="receive {Process,_}"]; - n_5 -> n_6 [id="[$e|9]", label="spawn dummy_1"]; - n_7 -> n_1 [id="[$e|1]", label="receive Obj"]; - n_7 -> n_8 [id="[$e|4]", label="send [Ciao D] to dummy_3"]; - n_7 -> n_8 [id="[$e|16]", label="send [Ciao A] to dummy_0"]; - n_7 -> n_8 [id="[$e|15]", label="send [Ciao C] to dummy_2"]; - n_3 -> n_2 [id="[$e|11]", label="spawn dummy_3"]; - n_8 -> n_1 [id="[$e|13]", label="receive Obj"]; -} diff --git a/examples/customer/customer0_local_view.dot b/examples/customer/customer0_local_view.dot new file mode 100644 index 0000000..e9e2c74 --- /dev/null +++ b/examples/customer/customer0_local_view.dot @@ -0,0 +1,17 @@ +digraph customer0 { + rankdir="LR"; + n_0 [label="customer0", shape="plaintext"]; + n_1 [id="5", shape=circle, label="2"]; + n_2 [id="1", shape=circle, label="1"]; + n_0 -> n_2 [arrowhead=none]; + n_3 [id="2", shape=circle, label="3"]; + n_4 [id="7", shape=doublecircle, label="5"]; + n_5 [id="3", shape=circle, label="4"]; + + n_1 -> n_3 [id="[$e|4]", label="send buy to store0/0"]; + n_5 -> n_4 [id="[$e|1]", label="receive accepted"]; + n_1 -> n_2 [id="[$e|8]", label="send more to store0/0"]; + n_5 -> n_3 [id="[$e|9]", label="receive reject"]; + n_2 -> n_1 [id="[$e|7]", label="send item to store0/0"]; + n_3 -> n_5 [id="[$e|2]", label="send payment to store0/0"]; +} diff --git a/examples/customer/customer_local_view.dot b/examples/customer/customer_local_view.dot deleted file mode 100644 index b0c3dff..0000000 --- a/examples/customer/customer_local_view.dot +++ /dev/null @@ -1,17 +0,0 @@ -digraph customer { - rankdir="LR"; - n_0 [label="customer", shape="plaintext"]; - n_1 [id="6", shape=doublecircle, label="5"]; - n_2 [id="1", shape=circle, label="1"]; - n_0 -> n_2 [arrowhead=none]; - n_3 [id="2", shape=circle, label="3"]; - n_4 [id="4", shape=circle, label="4"]; - n_5 [id="7", shape=circle, label="2"]; - - n_4 -> n_3 [id="[$e|9]", label="receive reject"]; - n_2 -> n_5 [id="[$e|3]", label="send item to store_0"]; - n_5 -> n_3 [id="[$e|7]", label="send buy to store_0"]; - n_5 -> n_2 [id="[$e|8]", label="send more to store_0"]; - n_3 -> n_4 [id="[$e|5]", label="send payment to store_0"]; - n_4 -> n_1 [id="[$e|2]", label="receive accepted"]; -} diff --git a/examples/customer/main0_global_view.dot b/examples/customer/main0_global_view.dot new file mode 100644 index 0000000..fb214e0 --- /dev/null +++ b/examples/customer/main0_global_view.dot @@ -0,0 +1,21 @@ +digraph global { + rankdir="LR"; + n_0 [label="global", shape="plaintext"]; + n_1 [id="5", shape=circle, label="6"]; + n_2 [id="6", shape=circle, label="7"]; + n_3 [id="1", shape=circle, label="1"]; + n_0 -> n_3 [arrowhead=none]; + n_4 [id="2", shape=circle, label="2"]; + n_5 [id="8", shape=circle, label="4"]; + n_6 [id="4", shape=circle, label="5"]; + n_7 [id="3", shape=circle, label="3"]; + + n_4 -> n_7 [id="[$e|4]", label="main0/0Δstore0/0"]; + n_1 -> n_2 [id="[$e|1]", label="store0/0→customer0/0:accepted"]; + n_1 -> n_6 [id="[$e|3]", label="store0/0→customer0/0:reject"]; + n_5 -> n_7 [id="[$e|9]", label="customer0/0→store0/0:more"]; + n_6 -> n_1 [id="[$e|6]", label="customer0/0→store0/0:payment"]; + n_7 -> n_5 [id="[$e|0]", label="customer0/0→store0/0:item"]; + n_5 -> n_6 [id="[$e|2]", label="customer0/0→store0/0:buy"]; + n_3 -> n_4 [id="[$e|5]", label="main0/0Δcustomer0/0"]; +} diff --git a/examples/async/main_local_view.dot b/examples/customer/main0_local_view.dot similarity index 51% rename from examples/async/main_local_view.dot rename to examples/customer/main0_local_view.dot index eb45845..114b1d5 100644 --- a/examples/async/main_local_view.dot +++ b/examples/customer/main0_local_view.dot @@ -1,11 +1,11 @@ -digraph main { +digraph main0 { rankdir="LR"; - n_0 [label="main", shape="plaintext"]; + n_0 [label="main0", shape="plaintext"]; n_1 [id="1", shape=circle, label="1"]; n_0 -> n_1 [arrowhead=none]; n_2 [id="2", shape=circle, label="2"]; n_3 [id="3", shape=doublecircle, label="3"]; - n_1 -> n_2 [id="[$e|1]", label="spawn dummy1_0"]; - n_2 -> n_3 [id="[$e|0]", label="spawn dummy2_0"]; + n_2 -> n_3 [id="[$e|1]", label="spawn store0/0"]; + n_1 -> n_2 [id="[$e|0]", label="spawn customer0/0"]; } diff --git a/examples/customer/main_global_view.dot b/examples/customer/main_global_view.dot deleted file mode 100644 index a2983bc..0000000 --- a/examples/customer/main_global_view.dot +++ /dev/null @@ -1,23 +0,0 @@ -digraph global { - rankdir="LR"; - n_0 [label="global", shape="plaintext"]; - n_1 [id="5", shape=circle, label="5"]; - n_2 [id="6", shape=circle, label="6"]; - n_3 [id="1", shape=circle, label="1"]; - n_0 -> n_3 [arrowhead=none]; - n_4 [id="2", shape=circle, label="2"]; - n_5 [id="8", shape=circle, label="8"]; - n_6 [id="4", shape=circle, label="4"]; - n_7 [id="7", shape=circle, label="7"]; - n_8 [id="3", shape=circle, label="3"]; - - n_4 -> n_8 [id="[$e|1]", label="mainΔstore_0"]; - n_3 -> n_4 [id="[$e|0]", label="mainΔcustomer_0"]; - n_2 -> n_6 [id="[$e|6]", label="customer_0→store_0:item"]; - n_6 -> n_2 [id="[$e|4]", label="customer_0→store_0:more"]; - n_6 -> n_1 [id="[$e|3]", label="customer_0→store_0:buy"]; - n_7 -> n_1 [id="[$e|7]", label="store_0→customer_0:reject"]; - n_7 -> n_5 [id="[$e|8]", label="store_0→customer_0:accepted"]; - n_1 -> n_7 [id="[$e|5]", label="customer_0→store_0:payment"]; - n_8 -> n_6 [id="[$e|2]", label="customer_0→store_0:item"]; -} diff --git a/examples/customer/store0_local_view.dot b/examples/customer/store0_local_view.dot new file mode 100644 index 0000000..ee95a60 --- /dev/null +++ b/examples/customer/store0_local_view.dot @@ -0,0 +1,17 @@ +digraph store0 { + rankdir="LR"; + n_0 [label="store0", shape="plaintext"]; + n_1 [id="6", shape=doublecircle, label="5"]; + n_2 [id="1", shape=circle, label="1"]; + n_0 -> n_2 [arrowhead=none]; + n_3 [id="2", shape=circle, label="2"]; + n_4 [id="7", shape=doublecircle, label="4"]; + n_5 [id="3", shape=circle, label="3"]; + + n_5 -> n_4 [id="[$e|1]", label="receive payment"]; + n_3 -> n_2 [id="[$e|8]", label="receive more"]; + n_3 -> n_5 [id="[$e|9]", label="receive buy"]; + n_2 -> n_3 [id="[$e|6]", label="receive item"]; + n_4 -> n_1 [id="[$e|7]", label="send accepted to customer0/0"]; + n_4 -> n_5 [id="[$e|5]", label="send reject to customer0/0"]; +} diff --git a/examples/customer/store_local_view.dot b/examples/customer/store_local_view.dot deleted file mode 100644 index b8bd26c..0000000 --- a/examples/customer/store_local_view.dot +++ /dev/null @@ -1,17 +0,0 @@ -digraph store { - rankdir="LR"; - n_0 [label="store", shape="plaintext"]; - n_1 [id="6", shape=circle, label="4"]; - n_2 [id="1", shape=circle, label="1"]; - n_0 -> n_2 [arrowhead=none]; - n_3 [id="2", shape=circle, label="3"]; - n_4 [id="7", shape=doublecircle, label="5"]; - n_5 [id="3", shape=circle, label="2"]; - - n_5 -> n_3 [id="[$e|9]", label="receive buy"]; - n_1 -> n_3 [id="[$e|4]", label="send reject to customer_0"]; - n_2 -> n_5 [id="[$e|3]", label="receive item"]; - n_3 -> n_1 [id="[$e|7]", label="receive payment"]; - n_5 -> n_2 [id="[$e|8]", label="receive more"]; - n_1 -> n_4 [id="[$e|5]", label="send accepted to customer_0"]; -} diff --git a/examples/for-loop-recursion/dummy_local_view.dot b/examples/for-loop-recursion/dummy1_local_view.dot similarity index 76% rename from examples/for-loop-recursion/dummy_local_view.dot rename to examples/for-loop-recursion/dummy1_local_view.dot index 9fbe0ea..797d99e 100644 --- a/examples/for-loop-recursion/dummy_local_view.dot +++ b/examples/for-loop-recursion/dummy1_local_view.dot @@ -1,6 +1,6 @@ -digraph dummy { +digraph dummy1 { rankdir="LR"; - n_0 [label="dummy", shape="plaintext"]; + n_0 [label="dummy1", shape="plaintext"]; n_1 [id="1", shape=circle, label="1"]; n_0 -> n_1 [arrowhead=none]; n_2 [id="2", shape=doublecircle, label="2"]; diff --git a/examples/high-order-fun/greet_global_view.dot b/examples/for-loop-recursion/main0_global_view.dot similarity index 64% rename from examples/high-order-fun/greet_global_view.dot rename to examples/for-loop-recursion/main0_global_view.dot index 2384629..9845deb 100644 --- a/examples/high-order-fun/greet_global_view.dot +++ b/examples/for-loop-recursion/main0_global_view.dot @@ -6,6 +6,6 @@ digraph global { n_2 [id="2", shape=circle, label="2"]; n_3 [id="3", shape=circle, label="3"]; - n_2 -> n_3 [id="[$e|1]", label="greet→anonfun_line15_0:hello"]; - n_1 -> n_2 [id="[$e|0]", label="greetΔanonfun_line15_0"]; + n_1 -> n_2 [id="[$e|0]", label="main0/0Δdummy1/0"]; + n_2 -> n_3 [id="[$e|1]", label="main0/0Δdummy1/1"]; } diff --git a/examples/for-loop-recursion/main0_local_view.dot b/examples/for-loop-recursion/main0_local_view.dot new file mode 100644 index 0000000..7d6a7a5 --- /dev/null +++ b/examples/for-loop-recursion/main0_local_view.dot @@ -0,0 +1,12 @@ +digraph main0 { + rankdir="LR"; + n_0 [label="main0", shape="plaintext"]; + n_1 [id="1", shape=circle, label="1"]; + n_0 -> n_1 [arrowhead=none]; + n_2 [id="2", shape=circle, label="2"]; + n_3 [id="3", shape=circle, label="3"]; + + n_3 -> n_3 [id="[$e|5]", label="receive Num"]; + n_1 -> n_2 [id="[$e|0]", label="spawn dummy1/0"]; + n_2 -> n_3 [id="[$e|2]", label="spawn dummy1/1"]; +} diff --git a/examples/for-loop-recursion/main_global_view.dot b/examples/for-loop-recursion/main_global_view.dot deleted file mode 100644 index 1abc751..0000000 --- a/examples/for-loop-recursion/main_global_view.dot +++ /dev/null @@ -1,19 +0,0 @@ -digraph global { - rankdir="LR"; - n_0 [label="global", shape="plaintext"]; - n_1 [id="5", shape=circle, label="5"]; - n_2 [id="6", shape=circle, label="6"]; - n_3 [id="1", shape=circle, label="1"]; - n_0 -> n_3 [arrowhead=none]; - n_4 [id="2", shape=circle, label="2"]; - n_5 [id="4", shape=circle, label="4"]; - n_6 [id="7", shape=circle, label="7"]; - n_7 [id="3", shape=circle, label="3"]; - - n_7 -> n_5 [id="[$e|2]", label="dummy_0→main:integer"]; - n_3 -> n_4 [id="[$e|0]", label="mainΔdummy_0"]; - n_7 -> n_1 [id="[$e|3]", label="dummy_1→main:integer"]; - n_5 -> n_2 [id="[$e|4]", label="dummy_1→main:integer"]; - n_1 -> n_6 [id="[$e|5]", label="dummy_0→main:integer"]; - n_4 -> n_7 [id="[$e|1]", label="mainΔdummy_1"]; -} diff --git a/examples/for-loop-recursion/main_local_view.dot b/examples/for-loop-recursion/main_local_view.dot deleted file mode 100644 index fa886fc..0000000 --- a/examples/for-loop-recursion/main_local_view.dot +++ /dev/null @@ -1,12 +0,0 @@ -digraph main { - rankdir="LR"; - n_0 [label="main", shape="plaintext"]; - n_1 [id="1", shape=circle, label="1"]; - n_0 -> n_1 [arrowhead=none]; - n_2 [id="2", shape=circle, label="2"]; - n_3 [id="3", shape=circle, label="3"]; - - n_1 -> n_2 [id="[$e|2]", label="spawn dummy_0"]; - n_2 -> n_3 [id="[$e|4]", label="spawn dummy_1"]; - n_3 -> n_3 [id="[$e|1]", label="receive Num"]; -} diff --git a/examples/function-call/dummy1_local_view.dot b/examples/function-call/dummy1_local_view.dot new file mode 100644 index 0000000..293ca13 --- /dev/null +++ b/examples/function-call/dummy1_local_view.dot @@ -0,0 +1,11 @@ +digraph dummy1 { + rankdir="LR"; + n_0 [label="dummy1", shape="plaintext"]; + n_1 [id="1", shape=circle, label="1"]; + n_0 -> n_1 [arrowhead=none]; + n_2 [id="2", shape=circle, label="2"]; + n_3 [id="3", shape=doublecircle, label="3"]; + + n_1 -> n_2 [id="[$e|1]", label="send {pid_self,hello1} to Pid"]; + n_2 -> n_3 [id="[$e|0]", label="send {pid_self,hello2} to Pid"]; +} diff --git a/examples/function-call/dummy_local_view.dot b/examples/function-call/dummy_local_view.dot deleted file mode 100644 index 22e8ccb..0000000 --- a/examples/function-call/dummy_local_view.dot +++ /dev/null @@ -1,11 +0,0 @@ -digraph dummy { - rankdir="LR"; - n_0 [label="dummy", shape="plaintext"]; - n_1 [id="1", shape=circle, label="1"]; - n_0 -> n_1 [arrowhead=none]; - n_2 [id="2", shape=circle, label="2"]; - n_3 [id="3", shape=doublecircle, label="3"]; - - n_1 -> n_2 [id="[$e|0]", label="send {pid_self,hello1} to Pid"]; - n_2 -> n_3 [id="[$e|1]", label="send {pid_self,hello2} to Pid"]; -} diff --git a/examples/hello/greet_global_view.dot b/examples/function-call/main0_global_view.dot similarity index 60% rename from examples/hello/greet_global_view.dot rename to examples/function-call/main0_global_view.dot index 66efabb..072df90 100644 --- a/examples/hello/greet_global_view.dot +++ b/examples/function-call/main0_global_view.dot @@ -3,5 +3,7 @@ digraph global { n_0 [label="global", shape="plaintext"]; n_1 [id="1", shape=circle, label="1"]; n_0 -> n_1 [arrowhead=none]; + n_2 [id="2", shape=circle, label="2"]; + n_1 -> n_2 [id="[$e|0]", label="main0/0Δdummy1/0"]; } diff --git a/examples/serverclient/main_local_view.dot b/examples/function-call/main0_local_view.dot similarity index 52% rename from examples/serverclient/main_local_view.dot rename to examples/function-call/main0_local_view.dot index 4d05ac7..0b74324 100644 --- a/examples/serverclient/main_local_view.dot +++ b/examples/function-call/main0_local_view.dot @@ -1,11 +1,11 @@ -digraph main { +digraph main0 { rankdir="LR"; - n_0 [label="main", shape="plaintext"]; + n_0 [label="main0", shape="plaintext"]; n_1 [id="1", shape=circle, label="1"]; n_0 -> n_1 [arrowhead=none]; n_2 [id="2", shape=circle, label="2"]; n_3 [id="3", shape=doublecircle, label="3"]; - n_2 -> n_3 [id="[$e|1]", label="spawn client_0"]; - n_1 -> n_2 [id="[$e|0]", label="spawn server_0"]; + n_2 -> n_3 [id="[$e|2]", label="receive {_,Msg}"]; + n_1 -> n_2 [id="[$e|3]", label="spawn dummy1/0"]; } diff --git a/examples/function-call/main_global_view.dot b/examples/function-call/main_global_view.dot deleted file mode 100644 index 93bb02a..0000000 --- a/examples/function-call/main_global_view.dot +++ /dev/null @@ -1,13 +0,0 @@ -digraph global { - rankdir="LR"; - n_0 [label="global", shape="plaintext"]; - n_1 [id="1", shape=circle, label="1"]; - n_0 -> n_1 [arrowhead=none]; - n_2 [id="2", shape=circle, label="2"]; - n_3 [id="4", shape=circle, label="4"]; - n_4 [id="3", shape=circle, label="3"]; - - n_1 -> n_2 [id="[$e|0]", label="mainΔdummy_0"]; - n_2 -> n_4 [id="[$e|1]", label="dummy_0→main:{pid_self,hello1}"]; - n_2 -> n_3 [id="[$e|2]", label="dummy_0→main:{pid_self,hello2}"]; -} diff --git a/examples/function-call/main_local_view.dot b/examples/function-call/main_local_view.dot deleted file mode 100644 index 6d4cb45..0000000 --- a/examples/function-call/main_local_view.dot +++ /dev/null @@ -1,11 +0,0 @@ -digraph main { - rankdir="LR"; - n_0 [label="main", shape="plaintext"]; - n_1 [id="1", shape=circle, label="1"]; - n_0 -> n_1 [arrowhead=none]; - n_2 [id="2", shape=circle, label="2"]; - n_3 [id="4", shape=doublecircle, label="3"]; - - n_1 -> n_2 [id="[$e|3]", label="spawn dummy_0"]; - n_2 -> n_3 [id="[$e|1]", label="receive {_,Msg}"]; -} diff --git a/examples/hello/greet0_global_view.dot b/examples/hello/greet0_global_view.dot new file mode 100644 index 0000000..189e139 --- /dev/null +++ b/examples/hello/greet0_global_view.dot @@ -0,0 +1,9 @@ +digraph global { + rankdir="LR"; + n_0 [label="global", shape="plaintext"]; + n_1 [id="1", shape=circle, label="1"]; + n_0 -> n_1 [arrowhead=none]; + n_2 [id="2", shape=circle, label="2"]; + + n_1 -> n_2 [id="[$e|0]", label="greet0/0→greet0/0:hello1"]; +} diff --git a/examples/hello/greet0_local_view.dot b/examples/hello/greet0_local_view.dot new file mode 100644 index 0000000..9390f2d --- /dev/null +++ b/examples/hello/greet0_local_view.dot @@ -0,0 +1,12 @@ +digraph greet0 { + rankdir="LR"; + n_0 [label="greet0", shape="plaintext"]; + n_1 [id="1", shape=circle, label="1"]; + n_0 -> n_1 [arrowhead=none]; + n_2 [id="2", shape=circle, label="2"]; + n_3 [id="3", shape=doublecircle, label="3"]; + + n_2 -> n_3 [id="[$e|3]", label="receive _"]; + n_2 -> n_1 [id="[$e|4]", label="send hello2 to pid_self"]; + n_1 -> n_2 [id="[$e|1]", label="send hello1 to pid_self"]; +} diff --git a/examples/hello/greet_local_view.dot b/examples/hello/greet_local_view.dot deleted file mode 100644 index ff42fc5..0000000 --- a/examples/hello/greet_local_view.dot +++ /dev/null @@ -1,12 +0,0 @@ -digraph greet { - rankdir="LR"; - n_0 [label="greet", shape="plaintext"]; - n_1 [id="1", shape=circle, label="1"]; - n_0 -> n_1 [arrowhead=none]; - n_2 [id="2", shape=doublecircle, label="3"]; - n_3 [id="3", shape=circle, label="2"]; - - n_3 -> n_2 [id="[$e|1]", label="receive hello1"]; - n_3 -> n_1 [id="[$e|4]", label="send hello1 to Me"]; - n_1 -> n_3 [id="[$e|2]", label="send hello1 to Me"]; -} diff --git a/examples/hello/hello.erl b/examples/hello/hello.erl index 81ded98..170bfdc 100644 --- a/examples/hello/hello.erl +++ b/examples/hello/hello.erl @@ -6,10 +6,10 @@ greet() -> Me ! hello1, if true -> - Me ! hello1, + Me ! hello2, greet(); false -> receive - hello1 -> done + _ -> done end end. diff --git a/examples/high-order-fun/Fun_local_view.dot b/examples/high-order-fun/anonfun_10_local_view.dot similarity index 73% rename from examples/high-order-fun/Fun_local_view.dot rename to examples/high-order-fun/anonfun_10_local_view.dot index 1272891..3b2b5a0 100644 --- a/examples/high-order-fun/Fun_local_view.dot +++ b/examples/high-order-fun/anonfun_10_local_view.dot @@ -1,6 +1,6 @@ -digraph Fun { +digraph anonfun_10 { rankdir="LR"; - n_0 [label="Fun", shape="plaintext"]; + n_0 [label="anonfun_10", shape="plaintext"]; n_1 [id="1", shape=circle, label="1"]; n_0 -> n_1 [arrowhead=none]; n_2 [id="2", shape=doublecircle, label="2"]; diff --git a/examples/high-order-fun/anonfun_line15_local_view.dot b/examples/high-order-fun/anonfun_15_local_view.dot similarity index 71% rename from examples/high-order-fun/anonfun_line15_local_view.dot rename to examples/high-order-fun/anonfun_15_local_view.dot index 91fa46e..7544476 100644 --- a/examples/high-order-fun/anonfun_line15_local_view.dot +++ b/examples/high-order-fun/anonfun_15_local_view.dot @@ -1,6 +1,6 @@ -digraph anonfun_line15 { +digraph anonfun_15 { rankdir="LR"; - n_0 [label="anonfun_line15", shape="plaintext"]; + n_0 [label="anonfun_15", shape="plaintext"]; n_1 [id="1", shape=circle, label="1"]; n_0 -> n_1 [arrowhead=none]; n_2 [id="2", shape=doublecircle, label="2"]; diff --git a/examples/high-order-fun/greet0_global_view.dot b/examples/high-order-fun/greet0_global_view.dot new file mode 100644 index 0000000..a63b10e --- /dev/null +++ b/examples/high-order-fun/greet0_global_view.dot @@ -0,0 +1,36 @@ +digraph global { + rankdir="LR"; + n_0 [label="global", shape="plaintext"]; + n_1 [id="15", shape=circle, label="4"]; + n_2 [id="12", shape=circle, label="8"]; + n_3 [id="11", shape=circle, label="9"]; + n_4 [id="17", shape=circle, label="6"]; + n_5 [id="14", shape=circle, label="10"]; + n_6 [id="6", shape=circle, label="3"]; + n_7 [id="13", shape=circle, label="12"]; + n_8 [id="10", shape=circle, label="11"]; + n_9 [id="1", shape=circle, label="1"]; + n_0 -> n_9 [arrowhead=none]; + n_10 [id="9", shape=circle, label="7"]; + n_11 [id="2", shape=circle, label="13"]; + n_12 [id="8", shape=circle, label="5"]; + n_13 [id="3", shape=circle, label="2"]; + + n_4 -> n_8 [id="[$e|16]", label="greet0/0→anonfun_15/0:hello"]; + n_5 -> n_11 [id="[$e|19]", label="greet0/0→anonfun_15/0:hello"]; + n_12 -> n_3 [id="[$e|10]", label="greet0/0→anonfun_10/0:hello"]; + n_6 -> n_12 [id="[$e|12]", label="greet0/0→anonfun_15/0:hello"]; + n_8 -> n_11 [id="[$e|21]", label="greet0/0→anonfun_10/0:hello"]; + n_4 -> n_7 [id="[$e|13]", label="greet0/0→anonfun_10/0:hello"]; + n_12 -> n_2 [id="[$e|11]", label="greet0/0→greet0/0:hello"]; + n_1 -> n_5 [id="[$e|0]", label="greet0/0→greet0/0:hello"]; + n_2 -> n_11 [id="[$e|20]", label="greet0/0→anonfun_10/0:hello"]; + n_7 -> n_11 [id="[$e|22]", label="greet0/0→anonfun_15/0:hello"]; + n_6 -> n_1 [id="[$e|6]", label="greet0/0→anonfun_10/0:hello"]; + n_1 -> n_10 [id="[$e|7]", label="greet0/0→anonfun_15/0:hello"]; + n_6 -> n_4 [id="[$e|4]", label="greet0/0→greet0/0:hello"]; + n_13 -> n_6 [id="[$e|8]", label="greet0/0Δanonfun_10/0"]; + n_10 -> n_11 [id="[$e|15]", label="greet0/0→greet0/0:hello"]; + n_9 -> n_13 [id="[$e|1]", label="greet0/0Δanonfun_15/0"]; + n_3 -> n_11 [id="[$e|23]", label="greet0/0→greet0/0:hello"]; +} diff --git a/examples/high-order-fun/greet0_local_view.dot b/examples/high-order-fun/greet0_local_view.dot new file mode 100644 index 0000000..a1c41f3 --- /dev/null +++ b/examples/high-order-fun/greet0_local_view.dot @@ -0,0 +1,19 @@ +digraph greet0 { + rankdir="LR"; + n_0 [label="greet0", shape="plaintext"]; + n_1 [id="5", shape=doublecircle, label="5"]; + n_2 [id="1", shape=circle, label="1"]; + n_0 -> n_2 [arrowhead=none]; + n_3 [id="2", shape=circle, label="2"]; + n_4 [id="8", shape=circle, label="3"]; + n_5 [id="4", shape=circle, label="6"]; + n_6 [id="7", shape=circle, label="5"]; + n_7 [id="3", shape=circle, label="4"]; + + n_7 -> n_6 [id="[$e|5]", label="spawn anonfun_10/0"]; + n_2 -> n_3 [id="[$e|0]", label="spawn anonfun_15/0"]; + n_3 -> n_4 [id="[$e|3]", label="send hello to anonfun_15/0"]; + n_5 -> n_5 [id="[$e|7]", label="receive hello"]; + n_4 -> n_7 [id="[$e|4]", label="send hello to pid_self"]; + n_6 -> n_5 [id="[$e|1]", label="send hello to anonfun_10/0"]; +} diff --git a/examples/high-order-fun/greet_local_view.dot b/examples/high-order-fun/greet_local_view.dot deleted file mode 100644 index a1c3379..0000000 --- a/examples/high-order-fun/greet_local_view.dot +++ /dev/null @@ -1,15 +0,0 @@ -digraph greet { - rankdir="LR"; - n_0 [label="greet", shape="plaintext"]; - n_1 [id="5", shape=doublecircle, label="5"]; - n_2 [id="1", shape=circle, label="1"]; - n_0 -> n_2 [arrowhead=none]; - n_3 [id="2", shape=circle, label="2"]; - n_4 [id="4", shape=circle, label="4"]; - n_5 [id="3", shape=circle, label="3"]; - - n_4 -> n_1 [id="[$e|3]", label="receive hello"]; - n_2 -> n_3 [id="[$e|1]", label="spawn anonfun_line15_0"]; - n_3 -> n_5 [id="[$e|0]", label="send hello to anonfun_line15_0"]; - n_5 -> n_4 [id="[$e|2]", label="send hello to none"]; -} diff --git a/examples/high-order-fun/hof.erl b/examples/high-order-fun/hof.erl index 50890d6..057571c 100644 --- a/examples/high-order-fun/hof.erl +++ b/examples/high-order-fun/hof.erl @@ -15,4 +15,7 @@ greet() -> A = spawn(fun() -> recv() end), A ! hello, self() ! hello, + B = spawn(Fun), + B ! hello, + recv(), Fun(). diff --git a/examples/if-cases/c_local_view.dot b/examples/if-cases/a0_local_view.dot similarity index 70% rename from examples/if-cases/c_local_view.dot rename to examples/if-cases/a0_local_view.dot index 08919a8..54a70dd 100644 --- a/examples/if-cases/c_local_view.dot +++ b/examples/if-cases/a0_local_view.dot @@ -1,12 +1,12 @@ -digraph c { +digraph a0 { rankdir="LR"; - n_0 [label="c", shape="plaintext"]; + n_0 [label="a0", shape="plaintext"]; n_1 [id="1", shape=circle, label="1"]; n_0 -> n_1 [arrowhead=none]; n_2 [id="2", shape=doublecircle, label="3"]; n_3 [id="3", shape=circle, label="2"]; - n_3 -> n_3 [id="[$e|0]", label="receive Pid"]; + n_3 -> n_2 [id="[$e|2]", label="send "Hi, i'm A" to Pid"]; n_1 -> n_3 [id="[$e|1]", label="receive Pid"]; - n_3 -> n_2 [id="[$e|2]", label="send [Hi, i'm C] to Pid"]; + n_3 -> n_3 [id="[$e|0]", label="receive Pid"]; } diff --git a/examples/if-cases/b_local_view.dot b/examples/if-cases/b0_local_view.dot similarity index 70% rename from examples/if-cases/b_local_view.dot rename to examples/if-cases/b0_local_view.dot index bff0409..123dd08 100644 --- a/examples/if-cases/b_local_view.dot +++ b/examples/if-cases/b0_local_view.dot @@ -1,12 +1,12 @@ -digraph b { +digraph b0 { rankdir="LR"; - n_0 [label="b", shape="plaintext"]; + n_0 [label="b0", shape="plaintext"]; n_1 [id="1", shape=circle, label="1"]; n_0 -> n_1 [arrowhead=none]; n_2 [id="2", shape=doublecircle, label="3"]; n_3 [id="3", shape=circle, label="2"]; - n_3 -> n_2 [id="[$e|0]", label="send [Hi, i'm B] to Pid"]; - n_3 -> n_3 [id="[$e|1]", label="receive Pid"]; n_1 -> n_3 [id="[$e|2]", label="receive Pid"]; + n_3 -> n_3 [id="[$e|1]", label="receive Pid"]; + n_3 -> n_2 [id="[$e|0]", label="send "Hi, i'm B" to Pid"]; } diff --git a/examples/if-cases/a_local_view.dot b/examples/if-cases/c0_local_view.dot similarity index 70% rename from examples/if-cases/a_local_view.dot rename to examples/if-cases/c0_local_view.dot index d0d5047..bcab1de 100644 --- a/examples/if-cases/a_local_view.dot +++ b/examples/if-cases/c0_local_view.dot @@ -1,12 +1,12 @@ -digraph a { +digraph c0 { rankdir="LR"; - n_0 [label="a", shape="plaintext"]; + n_0 [label="c0", shape="plaintext"]; n_1 [id="1", shape=circle, label="1"]; n_0 -> n_1 [arrowhead=none]; n_2 [id="2", shape=doublecircle, label="3"]; n_3 [id="3", shape=circle, label="2"]; - n_3 -> n_3 [id="[$e|0]", label="receive Pid"]; + n_3 -> n_2 [id="[$e|2]", label="send "Hi, i'm C" to Pid"]; n_1 -> n_3 [id="[$e|1]", label="receive Pid"]; - n_3 -> n_2 [id="[$e|2]", label="send [Hi, i'm A] to Pid"]; + n_3 -> n_3 [id="[$e|0]", label="receive Pid"]; } diff --git a/examples/if-cases/main0_global_view.dot b/examples/if-cases/main0_global_view.dot new file mode 100644 index 0000000..2f9f54b --- /dev/null +++ b/examples/if-cases/main0_global_view.dot @@ -0,0 +1,57 @@ +digraph global { + rankdir="LR"; + n_0 [label="global", shape="plaintext"]; + n_1 [id="34", shape=circle, label="18"]; + n_2 [id="20", shape=circle, label="10"]; + n_3 [id="27", shape=circle, label="19"]; + n_4 [id="25", shape=circle, label="14"]; + n_5 [id="28", shape=circle, label="6"]; + n_6 [id="12", shape=circle, label="16"]; + n_7 [id="18", shape=circle, label="7"]; + n_8 [id="14", shape=circle, label="9"]; + n_9 [id="6", shape=circle, label="13"]; + n_10 [id="13", shape=circle, label="22"]; + n_11 [id="24", shape=circle, label="8"]; + n_12 [id="10", shape=circle, label="3"]; + n_13 [id="30", shape=circle, label="20"]; + n_14 [id="22", shape=circle, label="5"]; + n_15 [id="1", shape=circle, label="1"]; + n_0 -> n_15 [arrowhead=none]; + n_16 [id="9", shape=circle, label="15"]; + n_17 [id="2", shape=circle, label="23"]; + n_18 [id="4", shape=circle, label="2"]; + n_19 [id="31", shape=circle, label="17"]; + n_20 [id="32", shape=circle, label="4"]; + n_21 [id="7", shape=circle, label="21"]; + n_22 [id="3", shape=circle, label="12"]; + n_23 [id="16", shape=circle, label="11"]; + + n_11 -> n_9 [id="[$e|26]", label="main0/0→b0/0:a0/0"]; + n_13 -> n_17 [id="[$e|51]", label="main0/0→c0/0:a0/0"]; + n_14 -> n_19 [id="[$e|20]", label="main0/0→c0/0:b0/0"]; + n_18 -> n_12 [id="[$e|3]", label="main0/0Δb0/0"]; + n_8 -> n_4 [id="[$e|8]", label="main0/0→b0/0:c0/0"]; + n_23 -> n_17 [id="[$e|41]", label="main0/0→b0/0:c0/0"]; + n_12 -> n_20 [id="[$e|28]", label="main0/0Δc0/0"]; + n_14 -> n_16 [id="[$e|6]", label="main0/0→a0/0:c0/0"]; + n_1 -> n_17 [id="[$e|52]", label="main0/0→b0/0:c0/0"]; + n_2 -> n_3 [id="[$e|12]", label="main0/0→b0/0:a0/0"]; + n_5 -> n_6 [id="[$e|5]", label="main0/0→c0/0:a0/0"]; + n_11 -> n_22 [id="[$e|11]", label="main0/0→c0/0:b0/0"]; + n_9 -> n_17 [id="[$e|42]", label="main0/0→c0/0:b0/0"]; + n_5 -> n_13 [id="[$e|9]", label="main0/0→a0/0:b0/0"]; + n_20 -> n_8 [id="[$e|25]", label="main0/0→a0/0:b0/0"]; + n_2 -> n_10 [id="[$e|1]", label="main0/0→a0/0:c0/0"]; + n_20 -> n_11 [id="[$e|4]", label="main0/0→a0/0:c0/0"]; + n_7 -> n_1 [id="[$e|18]", label="main0/0→a0/0:b0/0"]; + n_8 -> n_23 [id="[$e|13]", label="main0/0→c0/0:a0/0"]; + n_7 -> n_21 [id="[$e|32]", label="main0/0→b0/0:c0/0"]; + n_15 -> n_18 [id="[$e|17]", label="main0/0Δa0/0"]; + n_20 -> n_2 [id="[$e|22]", label="main0/0→c0/0:b0/0"]; + n_20 -> n_7 [id="[$e|0]", label="main0/0→c0/0:a0/0"]; + n_10 -> n_17 [id="[$e|50]", label="main0/0→b0/0:a0/0"]; + n_19 -> n_17 [id="[$e|40]", label="main0/0→a0/0:c0/0"]; + n_20 -> n_5 [id="[$e|29]", label="main0/0→b0/0:c0/0"]; + n_20 -> n_14 [id="[$e|30]", label="main0/0→b0/0:a0/0"]; + n_3 -> n_17 [id="[$e|10]", label="main0/0→a0/0:c0/0"]; +} diff --git a/examples/if-cases/main0_local_view.dot b/examples/if-cases/main0_local_view.dot new file mode 100644 index 0000000..0630926 --- /dev/null +++ b/examples/if-cases/main0_local_view.dot @@ -0,0 +1,24 @@ +digraph main0 { + rankdir="LR"; + n_0 [label="main0", shape="plaintext"]; + n_1 [id="5", shape=circle, label="6"]; + n_2 [id="6", shape=circle, label="7"]; + n_3 [id="10", shape=circle, label="3"]; + n_4 [id="1", shape=circle, label="1"]; + n_0 -> n_4 [arrowhead=none]; + n_5 [id="9", shape=circle, label="5"]; + n_6 [id="2", shape=doublecircle, label="9"]; + n_7 [id="4", shape=circle, label="8"]; + n_8 [id="7", shape=doublecircle, label="4"]; + n_9 [id="3", shape=circle, label="2"]; + + n_2 -> n_6 [id="[$e|3]", label="send a0/0 to c0/0"]; + n_8 -> n_5 [id="[$e|8]", label="send c0/0 to a0/0"]; + n_4 -> n_9 [id="[$e|2]", label="spawn a0/0"]; + n_5 -> n_7 [id="[$e|6]", label="send b0/0 to c0/0"]; + n_8 -> n_1 [id="[$e|5]", label="send b0/0 to a0/0"]; + n_7 -> n_6 [id="[$e|9]", label="send a0/0 to b0/0"]; + n_9 -> n_3 [id="[$e|4]", label="spawn b0/0"]; + n_3 -> n_8 [id="[$e|0]", label="spawn c0/0"]; + n_1 -> n_2 [id="[$e|7]", label="send c0/0 to b0/0"]; +} diff --git a/examples/if-cases/main_global_view.dot b/examples/if-cases/main_global_view.dot deleted file mode 100644 index 171fff4..0000000 --- a/examples/if-cases/main_global_view.dot +++ /dev/null @@ -1,73 +0,0 @@ -digraph global { - rankdir="LR"; - n_0 [label="global", shape="plaintext"]; - n_1 [id="33", shape=circle, label="33"]; - n_2 [id="34", shape=circle, label="34"]; - n_3 [id="20", shape=circle, label="20"]; - n_4 [id="27", shape=circle, label="27"]; - n_5 [id="29", shape=circle, label="29"]; - n_6 [id="23", shape=circle, label="23"]; - n_7 [id="25", shape=circle, label="25"]; - n_8 [id="5", shape=circle, label="5"]; - n_9 [id="28", shape=circle, label="28"]; - n_10 [id="15", shape=circle, label="15"]; - n_11 [id="19", shape=circle, label="19"]; - n_12 [id="12", shape=circle, label="12"]; - n_13 [id="11", shape=circle, label="11"]; - n_14 [id="17", shape=circle, label="17"]; - n_15 [id="18", shape=circle, label="18"]; - n_16 [id="14", shape=circle, label="14"]; - n_17 [id="6", shape=circle, label="6"]; - n_18 [id="13", shape=circle, label="13"]; - n_19 [id="24", shape=circle, label="24"]; - n_20 [id="10", shape=circle, label="10"]; - n_21 [id="30", shape=circle, label="30"]; - n_22 [id="22", shape=circle, label="22"]; - n_23 [id="1", shape=circle, label="1"]; - n_0 -> n_23 [arrowhead=none]; - n_24 [id="26", shape=circle, label="26"]; - n_25 [id="9", shape=circle, label="9"]; - n_26 [id="2", shape=circle, label="2"]; - n_27 [id="21", shape=circle, label="21"]; - n_28 [id="8", shape=circle, label="8"]; - n_29 [id="4", shape=circle, label="4"]; - n_30 [id="31", shape=circle, label="31"]; - n_31 [id="32", shape=circle, label="32"]; - n_32 [id="7", shape=circle, label="7"]; - n_33 [id="3", shape=circle, label="3"]; - n_34 [id="16", shape=circle, label="16"]; - - n_22 -> n_2 [id="[$e|32]", label="main→a_0:pid_b_0"]; - n_11 -> n_30 [id="[$e|29]", label="main→c_0:pid_a_0"]; - n_17 -> n_18 [id="[$e|11]", label="main→a_0:pid_c_0"]; - n_29 -> n_8 [id="[$e|3]", label="main→a_0:pid_c_0"]; - n_15 -> n_21 [id="[$e|28]", label="main→b_0:pid_c_0"]; - n_23 -> n_26 [id="[$e|0]", label="mainΔa_0"]; - n_29 -> n_25 [id="[$e|7]", label="main→b_0:pid_c_0"]; - n_3 -> n_31 [id="[$e|30]", label="main→a_0:pid_b_0"]; - n_13 -> n_6 [id="[$e|21]", label="main→c_0:pid_b_0"]; - n_28 -> n_14 [id="[$e|15]", label="main→b_0:pid_c_0"]; - n_28 -> n_15 [id="[$e|16]", label="main→c_0:pid_a_0"]; - n_29 -> n_17 [id="[$e|4]", label="main→b_0:pid_a_0"]; - n_29 -> n_32 [id="[$e|5]", label="main→c_0:pid_b_0"]; - n_32 -> n_10 [id="[$e|13]", label="main→a_0:pid_c_0"]; - n_8 -> n_13 [id="[$e|9]", label="main→b_0:pid_a_0"]; - n_25 -> n_3 [id="[$e|18]", label="main→c_0:pid_a_0"]; - n_14 -> n_5 [id="[$e|27]", label="main→c_0:pid_a_0"]; - n_27 -> n_1 [id="[$e|31]", label="main→b_0:pid_c_0"]; - n_8 -> n_12 [id="[$e|10]", label="main→c_0:pid_b_0"]; - n_20 -> n_22 [id="[$e|20]", label="main→b_0:pid_c_0"]; - n_32 -> n_34 [id="[$e|14]", label="main→b_0:pid_a_0"]; - n_20 -> n_27 [id="[$e|19]", label="main→a_0:pid_b_0"]; - n_26 -> n_33 [id="[$e|1]", label="mainΔb_0"]; - n_12 -> n_19 [id="[$e|22]", label="main→b_0:pid_a_0"]; - n_10 -> n_4 [id="[$e|25]", label="main→b_0:pid_a_0"]; - n_29 -> n_20 [id="[$e|8]", label="main→c_0:pid_a_0"]; - n_16 -> n_24 [id="[$e|24]", label="main→a_0:pid_c_0"]; - n_34 -> n_9 [id="[$e|26]", label="main→a_0:pid_c_0"]; - n_17 -> n_16 [id="[$e|12]", label="main→c_0:pid_b_0"]; - n_25 -> n_11 [id="[$e|17]", label="main→a_0:pid_b_0"]; - n_33 -> n_29 [id="[$e|2]", label="mainΔc_0"]; - n_29 -> n_28 [id="[$e|6]", label="main→a_0:pid_b_0"]; - n_18 -> n_7 [id="[$e|23]", label="main→c_0:pid_b_0"]; -} diff --git a/examples/if-cases/main_local_view.dot b/examples/if-cases/main_local_view.dot deleted file mode 100644 index fc705d2..0000000 --- a/examples/if-cases/main_local_view.dot +++ /dev/null @@ -1,24 +0,0 @@ -digraph main { - rankdir="LR"; - n_0 [label="main", shape="plaintext"]; - n_1 [id="5", shape=circle, label="7"]; - n_2 [id="6", shape=circle, label="5"]; - n_3 [id="10", shape=circle, label="6"]; - n_4 [id="1", shape=circle, label="1"]; - n_0 -> n_4 [arrowhead=none]; - n_5 [id="9", shape=doublecircle, label="4"]; - n_6 [id="2", shape=circle, label="2"]; - n_7 [id="8", shape=circle, label="8"]; - n_8 [id="4", shape=doublecircle, label="9"]; - n_9 [id="3", shape=circle, label="3"]; - - n_5 -> n_2 [id="[$e|3]", label="send pid_c_0 to a_0"]; - n_3 -> n_1 [id="[$e|0]", label="send pid_c_0 to b_0"]; - n_6 -> n_9 [id="[$e|7]", label="spawn b_0"]; - n_9 -> n_5 [id="[$e|4]", label="spawn c_0"]; - n_2 -> n_7 [id="[$e|5]", label="send pid_b_0 to c_0"]; - n_7 -> n_8 [id="[$e|9]", label="send pid_a_0 to b_0"]; - n_1 -> n_8 [id="[$e|1]", label="send pid_a_0 to c_0"]; - n_5 -> n_3 [id="[$e|8]", label="send pid_b_0 to a_0"]; - n_4 -> n_6 [id="[$e|2]", label="spawn a_0"]; -} diff --git a/examples/serverclient/client0_local_view.dot b/examples/serverclient/client0_local_view.dot new file mode 100644 index 0000000..04b0258 --- /dev/null +++ b/examples/serverclient/client0_local_view.dot @@ -0,0 +1,14 @@ +digraph client0 { + rankdir="LR"; + n_0 [label="client0", shape="plaintext"]; + n_1 [id="5", shape=doublecircle, label="4"]; + n_2 [id="1", shape=circle, label="1"]; + n_0 -> n_2 [arrowhead=none]; + n_3 [id="2", shape=circle, label="2"]; + n_4 [id="3", shape=circle, label="3"]; + + n_4 -> n_1 [id="[$e|1]", label="send done to Handle"]; + n_4 -> n_4 [id="[$e|3]", label="send next to Handle"]; + n_3 -> n_4 [id="[$e|6]", label="receive {res,Handle}"]; + n_2 -> n_3 [id="[$e|2]", label="send {req,pid_self} to server0/0"]; +} diff --git a/examples/serverclient/client_local_view.dot b/examples/serverclient/client_local_view.dot deleted file mode 100644 index ce3e9e7..0000000 --- a/examples/serverclient/client_local_view.dot +++ /dev/null @@ -1,14 +0,0 @@ -digraph client { - rankdir="LR"; - n_0 [label="client", shape="plaintext"]; - n_1 [id="1", shape=circle, label="1"]; - n_0 -> n_1 [arrowhead=none]; - n_2 [id="2", shape=doublecircle, label="4"]; - n_3 [id="4", shape=circle, label="2"]; - n_4 [id="3", shape=circle, label="3"]; - - n_1 -> n_3 [id="[$e|1]", label="send {req,pid_self} to server_0"]; - n_3 -> n_4 [id="[$e|4]", label="receive {res,Handle}"]; - n_4 -> n_4 [id="[$e|7]", label="send next to Handle"]; - n_4 -> n_2 [id="[$e|5]", label="send done to Handle"]; -} diff --git a/examples/serverclient/handle_req1_local_view.dot b/examples/serverclient/handle_req1_local_view.dot new file mode 100644 index 0000000..2d9aefa --- /dev/null +++ b/examples/serverclient/handle_req1_local_view.dot @@ -0,0 +1,10 @@ +digraph handle_req1 { + rankdir="LR"; + n_0 [label="handle_req1", shape="plaintext"]; + n_1 [id="1", shape=circle, label="1"]; + n_0 -> n_1 [arrowhead=none]; + n_2 [id="2", shape=doublecircle, label="2"]; + + n_1 -> n_2 [id="[$e|1]", label="receive done"]; + n_1 -> n_1 [id="[$e|5]", label="receive next"]; +} diff --git a/examples/serverclient/handle_req_local_view.dot b/examples/serverclient/handle_req_local_view.dot deleted file mode 100644 index 7049be7..0000000 --- a/examples/serverclient/handle_req_local_view.dot +++ /dev/null @@ -1,10 +0,0 @@ -digraph handle_req { - rankdir="LR"; - n_0 [label="handle_req", shape="plaintext"]; - n_1 [id="1", shape=circle, label="1"]; - n_0 -> n_1 [arrowhead=none]; - n_2 [id="3", shape=doublecircle, label="2"]; - - n_1 -> n_2 [id="[$e|0]", label="receive done"]; - n_1 -> n_1 [id="[$e|4]", label="receive next"]; -} diff --git a/examples/serverclient/main0_global_view.dot b/examples/serverclient/main0_global_view.dot new file mode 100644 index 0000000..0e0ee56 --- /dev/null +++ b/examples/serverclient/main0_global_view.dot @@ -0,0 +1,163 @@ +digraph global { + rankdir="LR"; + n_0 [label="global", shape="plaintext"]; + n_1 [id="33", shape=circle, label="33"]; + n_2 [id="34", shape=circle, label="34"]; + n_3 [id="20", shape=circle, label="20"]; + n_4 [id="58", shape=circle, label="58"]; + n_5 [id="57", shape=circle, label="57"]; + n_6 [id="27", shape=circle, label="27"]; + n_7 [id="47", shape=circle, label="47"]; + n_8 [id="29", shape=circle, label="29"]; + n_9 [id="23", shape=circle, label="23"]; + n_10 [id="55", shape=circle, label="55"]; + n_11 [id="25", shape=circle, label="25"]; + n_12 [id="68", shape=circle, label="68"]; + n_13 [id="36", shape=circle, label="36"]; + n_14 [id="5", shape=circle, label="5"]; + n_15 [id="63", shape=circle, label="63"]; + n_16 [id="28", shape=circle, label="28"]; + n_17 [id="64", shape=circle, label="64"]; + n_18 [id="15", shape=circle, label="15"]; + n_19 [id="42", shape=circle, label="42"]; + n_20 [id="19", shape=circle, label="19"]; + n_21 [id="12", shape=circle, label="12"]; + n_22 [id="11", shape=circle, label="11"]; + n_23 [id="17", shape=circle, label="17"]; + n_24 [id="53", shape=circle, label="53"]; + n_25 [id="50", shape=circle, label="50"]; + n_26 [id="62", shape=circle, label="62"]; + n_27 [id="67", shape=circle, label="67"]; + n_28 [id="54", shape=circle, label="54"]; + n_29 [id="18", shape=circle, label="18"]; + n_30 [id="61", shape=circle, label="61"]; + n_31 [id="37", shape=circle, label="37"]; + n_32 [id="51", shape=circle, label="51"]; + n_33 [id="14", shape=circle, label="14"]; + n_34 [id="66", shape=circle, label="66"]; + n_35 [id="6", shape=circle, label="6"]; + n_36 [id="38", shape=circle, label="38"]; + n_37 [id="13", shape=circle, label="13"]; + n_38 [id="24", shape=circle, label="24"]; + n_39 [id="10", shape=circle, label="10"]; + n_40 [id="43", shape=circle, label="43"]; + n_41 [id="30", shape=circle, label="30"]; + n_42 [id="59", shape=circle, label="59"]; + n_43 [id="40", shape=circle, label="40"]; + n_44 [id="22", shape=circle, label="22"]; + n_45 [id="65", shape=circle, label="65"]; + n_46 [id="39", shape=circle, label="39"]; + n_47 [id="60", shape=circle, label="60"]; + n_48 [id="1", shape=circle, label="1"]; + n_0 -> n_48 [arrowhead=none]; + n_49 [id="45", shape=circle, label="45"]; + n_50 [id="26", shape=circle, label="26"]; + n_51 [id="9", shape=circle, label="9"]; + n_52 [id="2", shape=circle, label="2"]; + n_53 [id="21", shape=circle, label="21"]; + n_54 [id="44", shape=circle, label="44"]; + n_55 [id="46", shape=circle, label="46"]; + n_56 [id="8", shape=circle, label="8"]; + n_57 [id="48", shape=circle, label="48"]; + n_58 [id="4", shape=circle, label="4"]; + n_59 [id="35", shape=circle, label="35"]; + n_60 [id="31", shape=circle, label="31"]; + n_61 [id="32", shape=circle, label="32"]; + n_62 [id="41", shape=circle, label="41"]; + n_63 [id="7", shape=circle, label="7"]; + n_64 [id="3", shape=circle, label="3"]; + n_65 [id="52", shape=circle, label="52"]; + n_66 [id="56", shape=circle, label="56"]; + n_67 [id="49", shape=circle, label="49"]; + n_68 [id="16", shape=circle, label="16"]; + + n_9 -> n_36 [id="[$e|39]", label="client0/1→handle_req1/0:done"]; + n_56 -> n_37 [id="[$e|11]", label="server0/0Δhandle_req1/0"]; + n_45 -> n_12 [id="[$e|85]", label="client0/0→handle_req1/0:done"]; + n_53 -> n_17 [id="[$e|77]", label="server0/0Δhandle_req1/0"]; + n_61 -> n_32 [id="[$e|55]", label="client0/1→handle_req1/0:done"]; + n_10 -> n_10 [id="[$e|84]", label="client0/0→handle_req1/0:next"]; + n_33 -> n_38 [id="[$e|22]", label="client0/0→handle_req1/0:done"]; + n_61 -> n_61 [id="[$e|75]", label="client0/0→handle_req1/0:next"]; + n_58 -> n_35 [id="[$e|4]", label="client0/1→server0/0:{req,pid_self}"]; + n_30 -> n_30 [id="[$e|87]", label="client0/1→handle_req1/0:next"]; + n_38 -> n_46 [id="[$e|40]", label="server0/0→client0/1:{res,handle_req1/0}"]; + n_9 -> n_9 [id="[$e|64]", label="client0/1→handle_req1/0:next"]; + n_11 -> n_11 [id="[$e|66]", label="client0/0→handle_req1/0:next"]; + n_1 -> n_24 [id="[$e|57]", label="server0/0→client0/0:{res,handle_req1/0}"]; + n_3 -> n_3 [id="[$e|54]", label="client0/1→handle_req1/0:next"]; + n_41 -> n_67 [id="[$e|52]", label="client0/1→handle_req1/0:done"]; + n_52 -> n_64 [id="[$e|1]", label="main0/0Δclient0/0"]; + n_50 -> n_19 [id="[$e|44]", label="server0/0→client0/0:{res,handle_req1/0}"]; + n_28 -> n_10 [id="[$e|59]", label="server0/0→client0/0:{res,handle_req1/0}"]; + n_58 -> n_14 [id="[$e|3]", label="client0/0→server0/0:{req,pid_self}"]; + n_29 -> n_20 [id="[$e|17]", label="server0/0→client0/0:{res,handle_req1/0}"]; + n_41 -> n_41 [id="[$e|72]", label="client0/0→handle_req1/0:next"]; + n_45 -> n_45 [id="[$e|88]", label="client0/0→handle_req1/0:next"]; + n_59 -> n_66 [id="[$e|60]", label="client0/0→handle_req1/0:done"]; + n_68 -> n_6 [id="[$e|26]", label="server0/0Δhandle_req1/0"]; + n_3 -> n_61 [id="[$e|31]", label="server0/0→client0/0:{res,handle_req1/0}"]; + n_29 -> n_3 [id="[$e|18]", label="server0/0→client0/1:{res,handle_req1/0}"]; + n_40 -> n_54 [id="[$e|46]", label="server0/0→client0/1:{res,handle_req1/0}"]; + n_11 -> n_11 [id="[$e|65]", label="client0/1→handle_req1/0:next"]; + n_35 -> n_39 [id="[$e|8]", label="server0/0Δhandle_req1/0"]; + n_10 -> n_15 [id="[$e|76]", label="client0/0→handle_req1/0:done"]; + n_9 -> n_9 [id="[$e|63]", label="client0/0→handle_req1/0:next"]; + n_41 -> n_57 [id="[$e|51]", label="client0/0→handle_req1/0:done"]; + n_39 -> n_22 [id="[$e|9]", label="client0/0→server0/0:{req,pid_self}"]; + n_18 -> n_18 [id="[$e|41]", label="client0/1→handle_req1/0:next"]; + n_23 -> n_8 [id="[$e|28]", label="client0/1→server0/0:{req,pid_self}"]; + n_37 -> n_33 [id="[$e|12]", label="server0/0→client0/0:{res,handle_req1/0}"]; + n_47 -> n_30 [id="[$e|69]", label="server0/0→client0/1:{res,handle_req1/0}"]; + n_61 -> n_61 [id="[$e|74]", label="client0/1→handle_req1/0:next"]; + n_37 -> n_18 [id="[$e|13]", label="server0/0→client0/1:{res,handle_req1/0}"]; + n_63 -> n_56 [id="[$e|6]", label="client0/1→server0/0:{req,pid_self}"]; + n_60 -> n_25 [id="[$e|53]", label="server0/0→client0/1:{res,handle_req1/0}"]; + n_63 -> n_51 [id="[$e|7]", label="server0/0→client0/0:{res,handle_req1/0}"]; + n_51 -> n_68 [id="[$e|14]", label="client0/1→server0/0:{req,pid_self}"]; + n_5 -> n_4 [id="[$e|62]", label="server0/0→client0/0:{res,handle_req1/0}"]; + n_8 -> n_55 [id="[$e|48]", label="server0/0Δhandle_req1/0"]; + n_16 -> n_49 [id="[$e|47]", label="client0/1→handle_req1/0:done"]; + n_11 -> n_62 [id="[$e|43]", label="client0/0→handle_req1/0:done"]; + n_68 -> n_40 [id="[$e|45]", label="server0/0Δhandle_req1/0"]; + n_21 -> n_44 [id="[$e|20]", label="client0/1→handle_req1/0:done"]; + n_20 -> n_60 [id="[$e|30]", label="client0/0→handle_req1/0:done"]; + n_33 -> n_9 [id="[$e|21]", label="server0/0→client0/1:{res,handle_req1/0}"]; + n_59 -> n_59 [id="[$e|79]", label="client0/0→handle_req1/0:next"]; + n_20 -> n_20 [id="[$e|50]", label="client0/0→handle_req1/0:next"]; + n_6 -> n_16 [id="[$e|27]", label="server0/0→client0/1:{res,handle_req1/0}"]; + n_48 -> n_52 [id="[$e|0]", label="main0/0Δserver0/0"]; + n_61 -> n_65 [id="[$e|56]", label="client0/0→handle_req1/0:done"]; + n_4 -> n_4 [id="[$e|86]", label="client0/0→handle_req1/0:next"]; + n_21 -> n_53 [id="[$e|19]", label="client0/0→server0/0:{req,pid_self}"]; + n_18 -> n_50 [id="[$e|24]", label="client0/1→handle_req1/0:done"]; + n_22 -> n_29 [id="[$e|16]", label="server0/0Δhandle_req1/0"]; + n_51 -> n_23 [id="[$e|15]", label="client0/0→handle_req1/0:done"]; + n_7 -> n_7 [id="[$e|83]", label="client0/1→handle_req1/0:next"]; + n_51 -> n_51 [id="[$e|25]", label="client0/0→handle_req1/0:next"]; + n_53 -> n_28 [id="[$e|58]", label="server0/0Δhandle_req1/0"]; + n_3 -> n_1 [id="[$e|32]", label="client0/1→handle_req1/0:done"]; + n_64 -> n_58 [id="[$e|2]", label="main0/0Δclient0/1"]; + n_9 -> n_31 [id="[$e|38]", label="client0/0→handle_req1/0:done"]; + n_20 -> n_41 [id="[$e|29]", label="server0/0→client0/1:{res,handle_req1/0}"]; + n_4 -> n_34 [id="[$e|80]", label="client0/0→handle_req1/0:done"]; + n_68 -> n_47 [id="[$e|68]", label="server0/0Δhandle_req1/0"]; + n_13 -> n_5 [id="[$e|61]", label="server0/0Δhandle_req1/0"]; + n_11 -> n_43 [id="[$e|42]", label="client0/1→handle_req1/0:done"]; + n_14 -> n_63 [id="[$e|5]", label="server0/0Δhandle_req1/0"]; + n_16 -> n_16 [id="[$e|70]", label="client0/1→handle_req1/0:next"]; + n_54 -> n_42 [id="[$e|67]", label="client0/1→handle_req1/0:done"]; + n_39 -> n_21 [id="[$e|10]", label="server0/0→client0/1:{res,handle_req1/0}"]; + n_33 -> n_33 [id="[$e|37]", label="client0/0→handle_req1/0:next"]; + n_44 -> n_13 [id="[$e|36]", label="client0/0→server0/0:{req,pid_self}"]; + n_41 -> n_41 [id="[$e|73]", label="client0/1→handle_req1/0:next"]; + n_30 -> n_27 [id="[$e|82]", label="client0/1→handle_req1/0:done"]; + n_18 -> n_11 [id="[$e|23]", label="server0/0→client0/0:{res,handle_req1/0}"]; + n_55 -> n_7 [id="[$e|49]", label="server0/0→client0/1:{res,handle_req1/0}"]; + n_53 -> n_2 [id="[$e|34]", label="server0/0Δhandle_req1/0"]; + n_54 -> n_54 [id="[$e|81]", label="client0/1→handle_req1/0:next"]; + n_2 -> n_59 [id="[$e|35]", label="server0/0→client0/0:{res,handle_req1/0}"]; + n_7 -> n_26 [id="[$e|71]", label="client0/1→handle_req1/0:done"]; + n_21 -> n_21 [id="[$e|33]", label="client0/1→handle_req1/0:next"]; + n_17 -> n_45 [id="[$e|78]", label="server0/0→client0/0:{res,handle_req1/0}"]; +} diff --git a/examples/serverclient/main0_local_view.dot b/examples/serverclient/main0_local_view.dot new file mode 100644 index 0000000..efaf4c1 --- /dev/null +++ b/examples/serverclient/main0_local_view.dot @@ -0,0 +1,13 @@ +digraph main0 { + rankdir="LR"; + n_0 [label="main0", shape="plaintext"]; + n_1 [id="1", shape=circle, label="1"]; + n_0 -> n_1 [arrowhead=none]; + n_2 [id="2", shape=circle, label="2"]; + n_3 [id="4", shape=circle, label="3"]; + n_4 [id="3", shape=doublecircle, label="4"]; + + n_3 -> n_4 [id="[$e|1]", label="spawn client0/1"]; + n_1 -> n_2 [id="[$e|0]", label="spawn server0/0"]; + n_2 -> n_3 [id="[$e|2]", label="spawn client0/0"]; +} diff --git a/examples/serverclient/main_global_view.dot b/examples/serverclient/main_global_view.dot deleted file mode 100644 index ba34496..0000000 --- a/examples/serverclient/main_global_view.dot +++ /dev/null @@ -1,20 +0,0 @@ -digraph global { - rankdir="LR"; - n_0 [label="global", shape="plaintext"]; - n_1 [id="5", shape=circle, label="5"]; - n_2 [id="6", shape=circle, label="6"]; - n_3 [id="1", shape=circle, label="1"]; - n_0 -> n_3 [arrowhead=none]; - n_4 [id="2", shape=circle, label="2"]; - n_5 [id="4", shape=circle, label="4"]; - n_6 [id="7", shape=circle, label="7"]; - n_7 [id="3", shape=circle, label="3"]; - - n_4 -> n_7 [id="[$e|1]", label="mainΔclient_0"]; - n_3 -> n_4 [id="[$e|0]", label="mainΔserver_0"]; - n_2 -> n_2 [id="[$e|6]", label="client_0→handle_req_0:next"]; - n_1 -> n_2 [id="[$e|4]", label="server_0→client_0:{res,pid_handle_req_0}"]; - n_5 -> n_1 [id="[$e|3]", label="server_0Δhandle_req_0"]; - n_2 -> n_6 [id="[$e|5]", label="client_0→handle_req_0:done"]; - n_7 -> n_5 [id="[$e|2]", label="client_0→server_0:{req,pid_self}"]; -} diff --git a/examples/serverclient/server0_local_view.dot b/examples/serverclient/server0_local_view.dot new file mode 100644 index 0000000..4c98e78 --- /dev/null +++ b/examples/serverclient/server0_local_view.dot @@ -0,0 +1,16 @@ +digraph server0 { + rankdir="LR"; + n_0 [label="server0", shape="plaintext"]; + n_1 [id="6", shape=circle, label="5"]; + n_2 [id="1", shape=circle, label="1"]; + n_0 -> n_2 [arrowhead=none]; + n_3 [id="2", shape=circle, label="2"]; + n_4 [id="4", shape=circle, label="3"]; + n_5 [id="3", shape=doublecircle, label="4"]; + + n_3 -> n_1 [id="[$e|6]", label="spawn handle_req1/0"]; + n_1 -> n_2 [id="[$e|7]", label="send {res,handle_req1/0} to P"]; + n_2 -> n_3 [id="[$e|0]", label="receive {req,P}"]; + n_2 -> n_4 [id="[$e|2]", label="receive ciao"]; + n_4 -> n_5 [id="[$e|5]", label="spawn handle_req1/1"]; +} diff --git a/examples/serverclient/server_local_view.dot b/examples/serverclient/server_local_view.dot deleted file mode 100644 index 6eba092..0000000 --- a/examples/serverclient/server_local_view.dot +++ /dev/null @@ -1,16 +0,0 @@ -digraph server { - rankdir="LR"; - n_0 [label="server", shape="plaintext"]; - n_1 [id="5", shape=circle, label="5"]; - n_2 [id="6", shape=doublecircle, label="4"]; - n_3 [id="1", shape=circle, label="1"]; - n_0 -> n_3 [arrowhead=none]; - n_4 [id="2", shape=circle, label="3"]; - n_5 [id="3", shape=circle, label="2"]; - - n_4 -> n_1 [id="[$e|0]", label="spawn handle_req_0"]; - n_5 -> n_2 [id="[$e|6]", label="spawn handle_req_1"]; - n_1 -> n_3 [id="[$e|7]", label="send {res,pid_handle_req_0} to P"]; - n_3 -> n_5 [id="[$e|5]", label="receive ciao"]; - n_3 -> n_4 [id="[$e|2]", label="receive {req,P}"]; -} diff --git a/examples/serverclient/serverclient.erl b/examples/serverclient/serverclient.erl index 21c2408..97933ad 100644 --- a/examples/serverclient/serverclient.erl +++ b/examples/serverclient/serverclient.erl @@ -38,4 +38,5 @@ main() -> S = spawn(?MODULE, server, []), register(server, S), spawn(?MODULE, client, []), + spawn(?MODULE, client, []), done. diff --git a/examples/test/barber/test0_local_view.dot b/examples/test/barber/test0_local_view.dot new file mode 100644 index 0000000..9d85705 --- /dev/null +++ b/examples/test/barber/test0_local_view.dot @@ -0,0 +1,19 @@ +digraph test0 { + rankdir="LR"; + n_0 [label="test0", shape="plaintext"]; + n_1 [id="5", shape=circle, label="5"]; + n_2 [id="6", shape=circle, label="6"]; + n_3 [id="1", shape=circle, label="1"]; + n_0 -> n_3 [arrowhead=none]; + n_4 [id="2", shape=circle, label="2"]; + n_5 [id="4", shape=doublecircle, label="7"]; + n_6 [id="7", shape=circle, label="3"]; + n_7 [id="3", shape=circle, label="4"]; + + n_4 -> n_6 [id="[$e|4]", label="spawn customer3/0"]; + n_6 -> n_7 [id="[$e|0]", label="spawn customer3/1"]; + n_3 -> n_4 [id="[$e|5]", label="spawn open_barber_shop0/0"]; + n_1 -> n_2 [id="[$e|3]", label="receive {Name2,State2}"]; + n_7 -> n_1 [id="[$e|1]", label="receive {Name1,State1}"]; + n_2 -> n_5 [id="[$e|2]", label="send stop to open_barber_shop0/0"]; +} diff --git a/examples/test/barber/test_local_view.dot b/examples/test/barber/test_local_view.dot deleted file mode 100644 index c8a3f3f..0000000 --- a/examples/test/barber/test_local_view.dot +++ /dev/null @@ -1,19 +0,0 @@ -digraph test { - rankdir="LR"; - n_0 [label="test", shape="plaintext"]; - n_1 [id="5", shape=doublecircle, label="7"]; - n_2 [id="6", shape=circle, label="5"]; - n_3 [id="1", shape=circle, label="1"]; - n_0 -> n_3 [arrowhead=none]; - n_4 [id="2", shape=circle, label="2"]; - n_5 [id="4", shape=circle, label="4"]; - n_6 [id="7", shape=circle, label="6"]; - n_7 [id="3", shape=circle, label="3"]; - - n_2 -> n_6 [id="[$e|1]", label="receive {Name2,State2}"]; - n_4 -> n_7 [id="[$e|5]", label="spawn customer_0"]; - n_7 -> n_5 [id="[$e|0]", label="spawn customer_1"]; - n_5 -> n_2 [id="[$e|4]", label="receive {Name1,State1}"]; - n_6 -> n_1 [id="[$e|3]", label="send stop to open_barber_shop_0"]; - n_3 -> n_4 [id="[$e|2]", label="spawn open_barber_shop_0"]; -} diff --git a/examples/test/foo1/b_local_view.dot b/examples/test/foo1/b0_local_view.dot similarity index 77% rename from examples/test/foo1/b_local_view.dot rename to examples/test/foo1/b0_local_view.dot index 4dfd564..05ef4b7 100644 --- a/examples/test/foo1/b_local_view.dot +++ b/examples/test/foo1/b0_local_view.dot @@ -1,6 +1,6 @@ -digraph b { +digraph b0 { rankdir="LR"; - n_0 [label="b", shape="plaintext"]; + n_0 [label="b0", shape="plaintext"]; n_1 [id="1", shape=circle, label="1"]; n_0 -> n_1 [arrowhead=none]; n_2 [id="2", shape=doublecircle, label="2"]; diff --git a/examples/test/foo1/c_local_view.dot b/examples/test/foo1/c1_local_view.dot similarity index 84% rename from examples/test/foo1/c_local_view.dot rename to examples/test/foo1/c1_local_view.dot index ae75bc2..1d0a219 100644 --- a/examples/test/foo1/c_local_view.dot +++ b/examples/test/foo1/c1_local_view.dot @@ -1,11 +1,11 @@ -digraph c { +digraph c1 { rankdir="LR"; - n_0 [label="c", shape="plaintext"]; + n_0 [label="c1", shape="plaintext"]; n_1 [id="1", shape=circle, label="1"]; n_0 -> n_1 [arrowhead=none]; n_2 [id="2", shape=circle, label="2"]; n_3 [id="3", shape=doublecircle, label="3"]; - n_1 -> n_2 [id="[$e|0]", label="receive X"]; n_2 -> n_3 [id="[$e|1]", label="send X to B"]; + n_1 -> n_2 [id="[$e|0]", label="receive X"]; } diff --git a/examples/test/foo1/test0_global_view.dot b/examples/test/foo1/test0_global_view.dot new file mode 100644 index 0000000..9e5cc59 --- /dev/null +++ b/examples/test/foo1/test0_global_view.dot @@ -0,0 +1,18 @@ +digraph global { + rankdir="LR"; + n_0 [label="global", shape="plaintext"]; + n_1 [id="5", shape=circle, label="6"]; + n_2 [id="1", shape=circle, label="1"]; + n_0 -> n_2 [arrowhead=none]; + n_3 [id="2", shape=circle, label="2"]; + n_4 [id="4", shape=circle, label="4"]; + n_5 [id="7", shape=circle, label="5"]; + n_6 [id="3", shape=circle, label="3"]; + + n_2 -> n_3 [id="[$e|2]", label="test0/0Δb0/0"]; + n_3 -> n_6 [id="[$e|3]", label="test0/0Δc1/0"]; + n_4 -> n_1 [id="[$e|5]", label="test0/0→b0/0:uno"]; + n_5 -> n_1 [id="[$e|6]", label="test0/0→c1/0:dos"]; + n_6 -> n_5 [id="[$e|1]", label="test0/0→b0/0:uno"]; + n_6 -> n_4 [id="[$e|0]", label="test0/0→c1/0:dos"]; +} diff --git a/examples/test/foo1/test0_local_view.dot b/examples/test/foo1/test0_local_view.dot new file mode 100644 index 0000000..da4c3fa --- /dev/null +++ b/examples/test/foo1/test0_local_view.dot @@ -0,0 +1,15 @@ +digraph test0 { + rankdir="LR"; + n_0 [label="test0", shape="plaintext"]; + n_1 [id="5", shape=circle, label="3"]; + n_2 [id="1", shape=circle, label="1"]; + n_0 -> n_2 [arrowhead=none]; + n_3 [id="2", shape=circle, label="2"]; + n_4 [id="4", shape=doublecircle, label="5"]; + n_5 [id="3", shape=circle, label="4"]; + + n_5 -> n_4 [id="[$e|2]", label="send dos to c1/0"]; + n_3 -> n_1 [id="[$e|3]", label="spawn c1/0"]; + n_2 -> n_3 [id="[$e|1]", label="spawn b0/0"]; + n_1 -> n_5 [id="[$e|0]", label="send uno to b0/0"]; +} diff --git a/examples/test/foo1/test_global_view.dot b/examples/test/foo1/test_global_view.dot deleted file mode 100644 index acd7717..0000000 --- a/examples/test/foo1/test_global_view.dot +++ /dev/null @@ -1,19 +0,0 @@ -digraph global { - rankdir="LR"; - n_0 [label="global", shape="plaintext"]; - n_1 [id="5", shape=circle, label="5"]; - n_2 [id="6", shape=circle, label="6"]; - n_3 [id="1", shape=circle, label="1"]; - n_0 -> n_3 [arrowhead=none]; - n_4 [id="2", shape=circle, label="2"]; - n_5 [id="4", shape=circle, label="4"]; - n_6 [id="7", shape=circle, label="7"]; - n_7 [id="3", shape=circle, label="3"]; - - n_1 -> n_6 [id="[$e|5]", label="test→b_0:uno"]; - n_5 -> n_2 [id="[$e|4]", label="test→c_0:dos"]; - n_3 -> n_4 [id="[$e|0]", label="testΔb_0"]; - n_7 -> n_1 [id="[$e|3]", label="test→c_0:dos"]; - n_4 -> n_7 [id="[$e|1]", label="testΔc_0"]; - n_7 -> n_5 [id="[$e|2]", label="test→b_0:uno"]; -} diff --git a/examples/test/foo1/test_local_view.dot b/examples/test/foo1/test_local_view.dot deleted file mode 100644 index 2da57db..0000000 --- a/examples/test/foo1/test_local_view.dot +++ /dev/null @@ -1,15 +0,0 @@ -digraph test { - rankdir="LR"; - n_0 [label="test", shape="plaintext"]; - n_1 [id="5", shape=circle, label="4"]; - n_2 [id="1", shape=circle, label="1"]; - n_0 -> n_2 [arrowhead=none]; - n_3 [id="2", shape=circle, label="2"]; - n_4 [id="4", shape=doublecircle, label="5"]; - n_5 [id="3", shape=circle, label="3"]; - - n_2 -> n_3 [id="[$e|0]", label="spawn b_0"]; - n_1 -> n_4 [id="[$e|3]", label="send dos to c_0"]; - n_5 -> n_1 [id="[$e|1]", label="send uno to b_0"]; - n_3 -> n_5 [id="[$e|2]", label="spawn c_0"]; -} diff --git a/examples/test/foo2/a_local_view.dot b/examples/test/foo2/a1_local_view.dot similarity index 78% rename from examples/test/foo2/a_local_view.dot rename to examples/test/foo2/a1_local_view.dot index 00d3c97..d324b91 100644 --- a/examples/test/foo2/a_local_view.dot +++ b/examples/test/foo2/a1_local_view.dot @@ -1,6 +1,6 @@ -digraph a { +digraph a1 { rankdir="LR"; - n_0 [label="a", shape="plaintext"]; + n_0 [label="a1", shape="plaintext"]; n_1 [id="1", shape=circle, label="1"]; n_0 -> n_1 [arrowhead=none]; n_2 [id="2", shape=doublecircle, label="2"]; diff --git a/examples/trick/c_local_view.dot b/examples/test/foo2/b0_local_view.dot similarity index 54% rename from examples/trick/c_local_view.dot rename to examples/test/foo2/b0_local_view.dot index d6d64d8..136d27b 100644 --- a/examples/trick/c_local_view.dot +++ b/examples/test/foo2/b0_local_view.dot @@ -1,11 +1,11 @@ -digraph c { +digraph b0 { rankdir="LR"; - n_0 [label="c", shape="plaintext"]; + n_0 [label="b0", shape="plaintext"]; n_1 [id="1", shape=circle, label="1"]; n_0 -> n_1 [arrowhead=none]; n_2 [id="2", shape=doublecircle, label="3"]; n_3 [id="3", shape=circle, label="2"]; - n_3 -> n_2 [id="[$e|0]", label="receive v2"]; - n_1 -> n_3 [id="[$e|1]", label="receive v1"]; + n_3 -> n_2 [id="[$e|0]", label="receive Z"]; + n_1 -> n_3 [id="[$e|1]", label="receive X"]; } diff --git a/examples/test/foo2/c_local_view.dot b/examples/test/foo2/c0_local_view.dot similarity index 68% rename from examples/test/foo2/c_local_view.dot rename to examples/test/foo2/c0_local_view.dot index 6b9b3f5..295fd12 100644 --- a/examples/test/foo2/c_local_view.dot +++ b/examples/test/foo2/c0_local_view.dot @@ -1,11 +1,11 @@ -digraph c { +digraph c0 { rankdir="LR"; - n_0 [label="c", shape="plaintext"]; + n_0 [label="c0", shape="plaintext"]; n_1 [id="1", shape=circle, label="1"]; n_0 -> n_1 [arrowhead=none]; n_2 [id="2", shape=circle, label="2"]; n_3 [id="3", shape=doublecircle, label="3"]; + n_2 -> n_3 [id="[$e|0]", label="send 4 to atom"]; n_1 -> n_2 [id="[$e|1]", label="receive _"]; - n_2 -> n_3 [id="[$e|0]", label="send 4 to none"]; } diff --git a/examples/test/foo2/test_global_view.dot b/examples/test/foo2/test0_global_view.dot similarity index 69% rename from examples/test/foo2/test_global_view.dot rename to examples/test/foo2/test0_global_view.dot index 1623da6..294cc9b 100644 --- a/examples/test/foo2/test_global_view.dot +++ b/examples/test/foo2/test0_global_view.dot @@ -6,6 +6,6 @@ digraph global { n_2 [id="2", shape=circle, label="2"]; n_3 [id="3", shape=circle, label="3"]; - n_2 -> n_3 [id="[$e|1]", label="testΔa_0"]; - n_1 -> n_2 [id="[$e|0]", label="testΔc_0"]; + n_2 -> n_3 [id="[$e|0]", label="test0/0Δa1/0"]; + n_1 -> n_2 [id="[$e|1]", label="test0/0Δc0/0"]; } diff --git a/examples/test/foo2/test0_local_view.dot b/examples/test/foo2/test0_local_view.dot new file mode 100644 index 0000000..22d5e28 --- /dev/null +++ b/examples/test/foo2/test0_local_view.dot @@ -0,0 +1,11 @@ +digraph test0 { + rankdir="LR"; + n_0 [label="test0", shape="plaintext"]; + n_1 [id="1", shape=circle, label="1"]; + n_0 -> n_1 [arrowhead=none]; + n_2 [id="2", shape=circle, label="2"]; + n_3 [id="3", shape=doublecircle, label="3"]; + + n_2 -> n_3 [id="[$e|0]", label="spawn a1/0"]; + n_1 -> n_2 [id="[$e|1]", label="spawn c0/0"]; +} diff --git a/examples/test/foo3/a_local_view.dot b/examples/test/foo3/a1_local_view.dot similarity index 84% rename from examples/test/foo3/a_local_view.dot rename to examples/test/foo3/a1_local_view.dot index 99048a2..764f4b9 100644 --- a/examples/test/foo3/a_local_view.dot +++ b/examples/test/foo3/a1_local_view.dot @@ -1,11 +1,11 @@ -digraph a { +digraph a1 { rankdir="LR"; - n_0 [label="a", shape="plaintext"]; + n_0 [label="a1", shape="plaintext"]; n_1 [id="1", shape=circle, label="1"]; n_0 -> n_1 [arrowhead=none]; n_2 [id="2", shape=circle, label="2"]; n_3 [id="3", shape=doublecircle, label="3"]; - n_2 -> n_3 [id="[$e|1]", label="send 3 to S"]; n_1 -> n_2 [id="[$e|0]", label="send 1 to S"]; + n_2 -> n_3 [id="[$e|1]", label="send 3 to S"]; } diff --git a/examples/test/foo3/b_local_view.dot b/examples/test/foo3/b1_local_view.dot similarity index 78% rename from examples/test/foo3/b_local_view.dot rename to examples/test/foo3/b1_local_view.dot index 15b2183..ef0fdf6 100644 --- a/examples/test/foo3/b_local_view.dot +++ b/examples/test/foo3/b1_local_view.dot @@ -1,6 +1,6 @@ -digraph b { +digraph b1 { rankdir="LR"; - n_0 [label="b", shape="plaintext"]; + n_0 [label="b1", shape="plaintext"]; n_1 [id="1", shape=circle, label="1"]; n_0 -> n_1 [arrowhead=none]; n_2 [id="2", shape=doublecircle, label="2"]; diff --git a/examples/test/foo3/c_local_view.dot b/examples/test/foo3/c_local_view.dot deleted file mode 100644 index adab514..0000000 --- a/examples/test/foo3/c_local_view.dot +++ /dev/null @@ -1,11 +0,0 @@ -digraph c { - rankdir="LR"; - n_0 [label="c", shape="plaintext"]; - n_1 [id="3", shape=circle, label="3"]; - n_2 [id="2", shape=circle, label="2"]; - n_3 [id="1", shape=circle, label="1"]; - n_0 -> n_3 [arrowhead=none]; - - n_3 -> n_2 [id="[$e|1]", label="receive _"]; - n_2 -> n_1 [id="[$e|0]", label="send 4 to B"]; -} diff --git a/examples/test/foo3/test0_global_view.dot b/examples/test/foo3/test0_global_view.dot new file mode 100644 index 0000000..8b23dbc --- /dev/null +++ b/examples/test/foo3/test0_global_view.dot @@ -0,0 +1,11 @@ +digraph global { + rankdir="LR"; + n_0 [label="global", shape="plaintext"]; + n_1 [id="1", shape=circle, label="1"]; + n_0 -> n_1 [arrowhead=none]; + n_2 [id="2", shape=circle, label="2"]; + n_3 [id="3", shape=circle, label="3"]; + + n_1 -> n_2 [id="[$e|0]", label="test0/0Δa1/0"]; + n_2 -> n_3 [id="[$e|1]", label="test0/0Δb1/0"]; +} diff --git a/examples/test/foo3/test0_local_view.dot b/examples/test/foo3/test0_local_view.dot new file mode 100644 index 0000000..7fd7be4 --- /dev/null +++ b/examples/test/foo3/test0_local_view.dot @@ -0,0 +1,17 @@ +digraph test0 { + rankdir="LR"; + n_0 [label="test0", shape="plaintext"]; + n_1 [id="5", shape=doublecircle, label="6"]; + n_2 [id="6", shape=circle, label="3"]; + n_3 [id="1", shape=circle, label="1"]; + n_0 -> n_3 [arrowhead=none]; + n_4 [id="2", shape=circle, label="2"]; + n_5 [id="4", shape=circle, label="5"]; + n_6 [id="3", shape=circle, label="4"]; + + n_4 -> n_2 [id="[$e|0]", label="spawn b1/0"]; + n_5 -> n_1 [id="[$e|1]", label="receive Z"]; + n_2 -> n_6 [id="[$e|2]", label="receive X"]; + n_6 -> n_5 [id="[$e|3]", label="receive Y"]; + n_3 -> n_4 [id="[$e|4]", label="spawn a1/0"]; +} diff --git a/examples/test/foo3/test_global_view.dot b/examples/test/foo3/test_global_view.dot deleted file mode 100644 index a80a077..0000000 --- a/examples/test/foo3/test_global_view.dot +++ /dev/null @@ -1,41 +0,0 @@ -digraph global { - rankdir="LR"; - n_0 [label="global", shape="plaintext"]; - n_1 [id="5", shape=circle, label="5"]; - n_2 [id="15", shape=circle, label="15"]; - n_3 [id="12", shape=circle, label="12"]; - n_4 [id="11", shape=circle, label="11"]; - n_5 [id="17", shape=circle, label="17"]; - n_6 [id="18", shape=circle, label="18"]; - n_7 [id="14", shape=circle, label="14"]; - n_8 [id="6", shape=circle, label="6"]; - n_9 [id="13", shape=circle, label="13"]; - n_10 [id="10", shape=circle, label="10"]; - n_11 [id="1", shape=circle, label="1"]; - n_0 -> n_11 [arrowhead=none]; - n_12 [id="9", shape=circle, label="9"]; - n_13 [id="2", shape=circle, label="2"]; - n_14 [id="8", shape=circle, label="8"]; - n_15 [id="4", shape=circle, label="4"]; - n_16 [id="7", shape=circle, label="7"]; - n_17 [id="3", shape=circle, label="3"]; - n_18 [id="16", shape=circle, label="16"]; - - n_1 -> n_12 [id="[$e|7]", label="a_0→test:1"]; - n_17 -> n_15 [id="[$e|2]", label="a_0→test:1"]; - n_3 -> n_6 [id="[$e|16]", label="a_0→test:1"]; - n_15 -> n_14 [id="[$e|6]", label="b_0→test:2"]; - n_17 -> n_1 [id="[$e|3]", label="a_0→test:3"]; - n_8 -> n_3 [id="[$e|10]", label="a_0→test:3"]; - n_16 -> n_9 [id="[$e|11]", label="b_0→test:2"]; - n_1 -> n_10 [id="[$e|8]", label="b_0→test:2"]; - n_17 -> n_8 [id="[$e|4]", label="b_0→test:2"]; - n_8 -> n_4 [id="[$e|9]", label="a_0→test:1"]; - n_12 -> n_2 [id="[$e|13]", label="b_0→test:2"]; - n_13 -> n_17 [id="[$e|1]", label="testΔb_0"]; - n_11 -> n_13 [id="[$e|0]", label="testΔa_0"]; - n_4 -> n_5 [id="[$e|15]", label="a_0→test:3"]; - n_15 -> n_16 [id="[$e|5]", label="a_0→test:3"]; - n_10 -> n_18 [id="[$e|14]", label="a_0→test:1"]; - n_14 -> n_7 [id="[$e|12]", label="a_0→test:3"]; -} diff --git a/examples/test/foo3/test_local_view.dot b/examples/test/foo3/test_local_view.dot deleted file mode 100644 index 5f88cb3..0000000 --- a/examples/test/foo3/test_local_view.dot +++ /dev/null @@ -1,17 +0,0 @@ -digraph test { - rankdir="LR"; - n_0 [label="test", shape="plaintext"]; - n_1 [id="5", shape=circle, label="3"]; - n_2 [id="6", shape=circle, label="5"]; - n_3 [id="1", shape=circle, label="1"]; - n_0 -> n_3 [arrowhead=none]; - n_4 [id="2", shape=circle, label="4"]; - n_5 [id="4", shape=doublecircle, label="6"]; - n_6 [id="3", shape=circle, label="2"]; - - n_6 -> n_1 [id="[$e|2]", label="spawn b_0"]; - n_1 -> n_4 [id="[$e|3]", label="receive X"]; - n_2 -> n_5 [id="[$e|4]", label="receive Z"]; - n_3 -> n_6 [id="[$e|1]", label="spawn a_0"]; - n_4 -> n_2 [id="[$e|0]", label="receive Y"]; -} diff --git a/examples/test/foo4/a_local_view.dot b/examples/test/foo4/a_local_view.dot deleted file mode 100644 index ea10316..0000000 --- a/examples/test/foo4/a_local_view.dot +++ /dev/null @@ -1,11 +0,0 @@ -digraph a { - rankdir="LR"; - n_0 [label="a", shape="plaintext"]; - n_1 [id="3", shape=circle, label="3"]; - n_2 [id="2", shape=circle, label="2"]; - n_3 [id="1", shape=circle, label="1"]; - n_0 -> n_3 [arrowhead=none]; - - n_2 -> n_1 [id="[$e|1]", label="send 3 to S"]; - n_3 -> n_2 [id="[$e|0]", label="send 1 to S"]; -} diff --git a/examples/test/foo4/b_local_view.dot b/examples/test/foo4/b_local_view.dot deleted file mode 100644 index d42d80f..0000000 --- a/examples/test/foo4/b_local_view.dot +++ /dev/null @@ -1,9 +0,0 @@ -digraph b { - rankdir="LR"; - n_0 [label="b", shape="plaintext"]; - n_1 [id="2", shape=circle, label="2"]; - n_2 [id="1", shape=circle, label="1"]; - n_0 -> n_2 [arrowhead=none]; - - n_2 -> n_1 [id="[$e|0]", label="send 2 to S"]; -} diff --git a/examples/test/foo4/c_local_view.dot b/examples/test/foo4/c_local_view.dot deleted file mode 100644 index adab514..0000000 --- a/examples/test/foo4/c_local_view.dot +++ /dev/null @@ -1,11 +0,0 @@ -digraph c { - rankdir="LR"; - n_0 [label="c", shape="plaintext"]; - n_1 [id="3", shape=circle, label="3"]; - n_2 [id="2", shape=circle, label="2"]; - n_3 [id="1", shape=circle, label="1"]; - n_0 -> n_3 [arrowhead=none]; - - n_3 -> n_2 [id="[$e|1]", label="receive _"]; - n_2 -> n_1 [id="[$e|0]", label="send 4 to B"]; -} diff --git a/examples/test/foo4/r0_local_view.dot b/examples/test/foo4/r0_local_view.dot new file mode 100644 index 0000000..850abf2 --- /dev/null +++ b/examples/test/foo4/r0_local_view.dot @@ -0,0 +1,13 @@ +digraph r0 { + rankdir="LR"; + n_0 [label="r0", shape="plaintext"]; + n_1 [id="1", shape=circle, label="1"]; + n_0 -> n_1 [arrowhead=none]; + n_2 [id="2", shape=circle, label="3"]; + n_3 [id="4", shape=doublecircle, label="4"]; + n_4 [id="3", shape=circle, label="2"]; + + n_1 -> n_4 [id="[$e|1]", label="receive X"]; + n_4 -> n_2 [id="[$e|2]", label="receive Y"]; + n_2 -> n_3 [id="[$e|0]", label="receive Z"]; +} diff --git a/examples/test/foo4/r_local_view.dot b/examples/test/foo4/r_local_view.dot deleted file mode 100644 index 20561fc..0000000 --- a/examples/test/foo4/r_local_view.dot +++ /dev/null @@ -1,13 +0,0 @@ -digraph r { - rankdir="LR"; - n_0 [label="r", shape="plaintext"]; - n_1 [id="1", shape=circle, label="1"]; - n_0 -> n_1 [arrowhead=none]; - n_2 [id="2", shape=circle, label="3"]; - n_3 [id="4", shape=circle, label="2"]; - n_4 [id="3", shape=doublecircle, label="4"]; - - n_1 -> n_3 [id="[$e|0]", label="receive X"]; - n_3 -> n_2 [id="[$e|1]", label="receive Y"]; - n_2 -> n_4 [id="[$e|2]", label="receive Z"]; -} diff --git a/examples/test/foo4/test0_global_view.dot b/examples/test/foo4/test0_global_view.dot new file mode 100644 index 0000000..b29ea1d --- /dev/null +++ b/examples/test/foo4/test0_global_view.dot @@ -0,0 +1,36 @@ +digraph global { + rankdir="LR"; + n_0 [label="global", shape="plaintext"]; + n_1 [id="15", shape=circle, label="9"]; + n_2 [id="12", shape=circle, label="8"]; + n_3 [id="11", shape=circle, label="7"]; + n_4 [id="17", shape=circle, label="11"]; + n_5 [id="18", shape=circle, label="4"]; + n_6 [id="14", shape=circle, label="10"]; + n_7 [id="13", shape=circle, label="13"]; + n_8 [id="10", shape=circle, label="12"]; + n_9 [id="1", shape=circle, label="1"]; + n_0 -> n_9 [arrowhead=none]; + n_10 [id="9", shape=circle, label="6"]; + n_11 [id="2", shape=circle, label="14"]; + n_12 [id="7", shape=circle, label="3"]; + n_13 [id="3", shape=circle, label="2"]; + n_14 [id="16", shape=circle, label="5"]; + + n_5 -> n_14 [id="[$e|1]", label="test0/0→w11/0:w1"]; + n_9 -> n_13 [id="[$e|13]", label="test0/0Δr0/0"]; + n_2 -> n_11 [id="[$e|23]", label="test0/0→w21/0:w2"]; + n_3 -> n_8 [id="[$e|9]", label="test0/0→r0/0:r0"]; + n_13 -> n_12 [id="[$e|8]", label="test0/0Δw11/0"]; + n_14 -> n_2 [id="[$e|2]", label="test0/0→r0/0:r0"]; + n_12 -> n_5 [id="[$e|6]", label="test0/0Δw21/0"]; + n_5 -> n_10 [id="[$e|0]", label="test0/0→r0/0:r0"]; + n_10 -> n_6 [id="[$e|4]", label="test0/0→w11/0:w1"]; + n_5 -> n_3 [id="[$e|16]", label="test0/0→w21/0:w2"]; + n_8 -> n_11 [id="[$e|5]", label="test0/0→w11/0:w1"]; + n_10 -> n_7 [id="[$e|14]", label="test0/0→w21/0:w2"]; + n_6 -> n_11 [id="[$e|22]", label="test0/0→w21/0:w2"]; + n_14 -> n_1 [id="[$e|12]", label="test0/0→w21/0:w2"]; + n_1 -> n_11 [id="[$e|19]", label="test0/0→r0/0:r0"]; + n_3 -> n_4 [id="[$e|10]", label="test0/0→w11/0:w1"]; +} diff --git a/examples/test/foo4/test0_local_view.dot b/examples/test/foo4/test0_local_view.dot new file mode 100644 index 0000000..50ae661 --- /dev/null +++ b/examples/test/foo4/test0_local_view.dot @@ -0,0 +1,19 @@ +digraph test0 { + rankdir="LR"; + n_0 [label="test0", shape="plaintext"]; + n_1 [id="5", shape=doublecircle, label="7"]; + n_2 [id="6", shape=circle, label="5"]; + n_3 [id="1", shape=circle, label="1"]; + n_0 -> n_3 [arrowhead=none]; + n_4 [id="2", shape=circle, label="2"]; + n_5 [id="4", shape=circle, label="6"]; + n_6 [id="7", shape=circle, label="3"]; + n_7 [id="3", shape=circle, label="4"]; + + n_5 -> n_1 [id="[$e|1]", label="send w2 to w21/0"]; + n_3 -> n_4 [id="[$e|2]", label="spawn r0/0"]; + n_7 -> n_2 [id="[$e|3]", label="spawn w21/0"]; + n_6 -> n_7 [id="[$e|0]", label="spawn w11/0"]; + n_4 -> n_6 [id="[$e|4]", label="send r0 to r0/0"]; + n_2 -> n_5 [id="[$e|5]", label="send w1 to w11/0"]; +} diff --git a/examples/test/foo4/test_global_view.dot b/examples/test/foo4/test_global_view.dot deleted file mode 100644 index b881840..0000000 --- a/examples/test/foo4/test_global_view.dot +++ /dev/null @@ -1,43 +0,0 @@ -digraph global { - rankdir="LR"; - n_0 [label="global", shape="plaintext"]; - n_1 [id="5", shape=circle, label="5"]; - n_2 [id="15", shape=circle, label="15"]; - n_3 [id="19", shape=circle, label="19"]; - n_4 [id="12", shape=circle, label="12"]; - n_5 [id="11", shape=circle, label="11"]; - n_6 [id="17", shape=circle, label="17"]; - n_7 [id="18", shape=circle, label="18"]; - n_8 [id="14", shape=circle, label="14"]; - n_9 [id="6", shape=circle, label="6"]; - n_10 [id="13", shape=circle, label="13"]; - n_11 [id="10", shape=circle, label="10"]; - n_12 [id="1", shape=circle, label="1"]; - n_0 -> n_12 [arrowhead=none]; - n_13 [id="9", shape=circle, label="9"]; - n_14 [id="2", shape=circle, label="2"]; - n_15 [id="8", shape=circle, label="8"]; - n_16 [id="4", shape=circle, label="4"]; - n_17 [id="7", shape=circle, label="7"]; - n_18 [id="3", shape=circle, label="3"]; - n_19 [id="16", shape=circle, label="16"]; - - n_9 -> n_11 [id="[$e|8]", label="test→r_0:r0"]; - n_13 -> n_2 [id="[$e|13]", label="test→w1_0:w1"]; - n_11 -> n_19 [id="[$e|14]", label="test→w2_0:w2"]; - n_16 -> n_9 [id="[$e|4]", label="test→w1_0:w1"]; - n_17 -> n_4 [id="[$e|10]", label="test→r_0:r0"]; - n_10 -> n_3 [id="[$e|17]", label="test→r_0:r0"]; - n_16 -> n_1 [id="[$e|3]", label="test→r_0:r0"]; - n_5 -> n_6 [id="[$e|15]", label="test→r_0:r0"]; - n_1 -> n_13 [id="[$e|7]", label="test→w2_0:w2"]; - n_9 -> n_5 [id="[$e|9]", label="test→w2_0:w2"]; - n_4 -> n_7 [id="[$e|16]", label="test→w1_0:w1"]; - n_16 -> n_17 [id="[$e|5]", label="test→w2_0:w2"]; - n_12 -> n_14 [id="[$e|0]", label="testΔr_0"]; - n_1 -> n_15 [id="[$e|6]", label="test→w1_0:w1"]; - n_14 -> n_18 [id="[$e|1]", label="testΔw1_0"]; - n_17 -> n_10 [id="[$e|11]", label="test→w1_0:w1"]; - n_18 -> n_16 [id="[$e|2]", label="testΔw2_0"]; - n_15 -> n_8 [id="[$e|12]", label="test→w2_0:w2"]; -} diff --git a/examples/test/foo4/test_local_view.dot b/examples/test/foo4/test_local_view.dot deleted file mode 100644 index 21b9196..0000000 --- a/examples/test/foo4/test_local_view.dot +++ /dev/null @@ -1,19 +0,0 @@ -digraph test { - rankdir="LR"; - n_0 [label="test", shape="plaintext"]; - n_1 [id="5", shape=doublecircle, label="7"]; - n_2 [id="6", shape=circle, label="6"]; - n_3 [id="1", shape=circle, label="1"]; - n_0 -> n_3 [arrowhead=none]; - n_4 [id="2", shape=circle, label="2"]; - n_5 [id="4", shape=circle, label="5"]; - n_6 [id="7", shape=circle, label="4"]; - n_7 [id="3", shape=circle, label="3"]; - - n_5 -> n_2 [id="[$e|4]", label="send w1 to w1_0"]; - n_2 -> n_1 [id="[$e|3]", label="send w2 to w2_0"]; - n_7 -> n_6 [id="[$e|5]", label="spawn w1_0"]; - n_6 -> n_5 [id="[$e|0]", label="spawn w2_0"]; - n_3 -> n_4 [id="[$e|1]", label="spawn r_0"]; - n_4 -> n_7 [id="[$e|2]", label="send r0 to r_0"]; -} diff --git a/examples/test/foo4/w1_local_view.dot b/examples/test/foo4/w11_local_view.dot similarity index 83% rename from examples/test/foo4/w1_local_view.dot rename to examples/test/foo4/w11_local_view.dot index 5d925b0..af67126 100644 --- a/examples/test/foo4/w1_local_view.dot +++ b/examples/test/foo4/w11_local_view.dot @@ -1,11 +1,11 @@ -digraph w1 { +digraph w11 { rankdir="LR"; - n_0 [label="w1", shape="plaintext"]; + n_0 [label="w11", shape="plaintext"]; n_1 [id="1", shape=circle, label="1"]; n_0 -> n_1 [arrowhead=none]; n_2 [id="2", shape=circle, label="2"]; n_3 [id="3", shape=doublecircle, label="3"]; - n_2 -> n_3 [id="[$e|0]", label="send r1 to Reg"]; n_1 -> n_2 [id="[$e|1]", label="receive _X"]; + n_2 -> n_3 [id="[$e|0]", label="send r1 to Reg"]; } diff --git a/examples/test/foo4/w2_local_view.dot b/examples/test/foo4/w21_local_view.dot similarity index 83% rename from examples/test/foo4/w2_local_view.dot rename to examples/test/foo4/w21_local_view.dot index ac37aca..27ccff2 100644 --- a/examples/test/foo4/w2_local_view.dot +++ b/examples/test/foo4/w21_local_view.dot @@ -1,11 +1,11 @@ -digraph w2 { +digraph w21 { rankdir="LR"; - n_0 [label="w2", shape="plaintext"]; + n_0 [label="w21", shape="plaintext"]; n_1 [id="1", shape=circle, label="1"]; n_0 -> n_1 [arrowhead=none]; n_2 [id="2", shape=circle, label="2"]; n_3 [id="3", shape=doublecircle, label="3"]; - n_2 -> n_3 [id="[$e|0]", label="send r2 to Reg"]; n_1 -> n_2 [id="[$e|1]", label="receive _X"]; + n_2 -> n_3 [id="[$e|0]", label="send r2 to Reg"]; } diff --git a/examples/test/foo5/a_local_view.dot b/examples/test/foo5/a_local_view.dot deleted file mode 100644 index ea10316..0000000 --- a/examples/test/foo5/a_local_view.dot +++ /dev/null @@ -1,11 +0,0 @@ -digraph a { - rankdir="LR"; - n_0 [label="a", shape="plaintext"]; - n_1 [id="3", shape=circle, label="3"]; - n_2 [id="2", shape=circle, label="2"]; - n_3 [id="1", shape=circle, label="1"]; - n_0 -> n_3 [arrowhead=none]; - - n_2 -> n_1 [id="[$e|1]", label="send 3 to S"]; - n_3 -> n_2 [id="[$e|0]", label="send 1 to S"]; -} diff --git a/examples/test/foo5/b_local_view.dot b/examples/test/foo5/b_local_view.dot deleted file mode 100644 index d42d80f..0000000 --- a/examples/test/foo5/b_local_view.dot +++ /dev/null @@ -1,9 +0,0 @@ -digraph b { - rankdir="LR"; - n_0 [label="b", shape="plaintext"]; - n_1 [id="2", shape=circle, label="2"]; - n_2 [id="1", shape=circle, label="1"]; - n_0 -> n_2 [arrowhead=none]; - - n_2 -> n_1 [id="[$e|0]", label="send 2 to S"]; -} diff --git a/examples/test/foo5/c_local_view.dot b/examples/test/foo5/c_local_view.dot deleted file mode 100644 index adab514..0000000 --- a/examples/test/foo5/c_local_view.dot +++ /dev/null @@ -1,11 +0,0 @@ -digraph c { - rankdir="LR"; - n_0 [label="c", shape="plaintext"]; - n_1 [id="3", shape=circle, label="3"]; - n_2 [id="2", shape=circle, label="2"]; - n_3 [id="1", shape=circle, label="1"]; - n_0 -> n_3 [arrowhead=none]; - - n_3 -> n_2 [id="[$e|1]", label="receive _"]; - n_2 -> n_1 [id="[$e|0]", label="send 4 to B"]; -} diff --git a/examples/test/foo5/proxy_local_view.dot b/examples/test/foo5/proxy1_local_view.dot similarity index 82% rename from examples/test/foo5/proxy_local_view.dot rename to examples/test/foo5/proxy1_local_view.dot index 00b4e0e..c58b6cd 100644 --- a/examples/test/foo5/proxy_local_view.dot +++ b/examples/test/foo5/proxy1_local_view.dot @@ -1,11 +1,11 @@ -digraph proxy { +digraph proxy1 { rankdir="LR"; - n_0 [label="proxy", shape="plaintext"]; + n_0 [label="proxy1", shape="plaintext"]; n_1 [id="1", shape=circle, label="1"]; n_0 -> n_1 [arrowhead=none]; n_2 [id="2", shape=circle, label="2"]; n_3 [id="3", shape=doublecircle, label="3"]; - n_1 -> n_2 [id="[$e|1]", label="receive M"]; n_2 -> n_3 [id="[$e|0]", label="send M to Target"]; + n_1 -> n_2 [id="[$e|1]", label="receive M"]; } diff --git a/examples/test/foo5/r_local_view.dot b/examples/test/foo5/r_local_view.dot deleted file mode 100644 index 337124e..0000000 --- a/examples/test/foo5/r_local_view.dot +++ /dev/null @@ -1,13 +0,0 @@ -digraph r { - rankdir="LR"; - n_0 [label="r", shape="plaintext"]; - n_1 [id="3", shape=circle, label="4"]; - n_2 [id="4", shape=circle, label="2"]; - n_3 [id="2", shape=circle, label="3"]; - n_4 [id="1", shape=circle, label="1"]; - n_0 -> n_4 [arrowhead=none]; - - n_2 -> n_3 [id="[$e|1]", label="receive Y"]; - n_3 -> n_1 [id="[$e|0]", label="receive Z"]; - n_4 -> n_2 [id="[$e|2]", label="receive X"]; -} diff --git a/examples/test/foo5/target0_local_view.dot b/examples/test/foo5/target0_local_view.dot new file mode 100644 index 0000000..5c4c796 --- /dev/null +++ b/examples/test/foo5/target0_local_view.dot @@ -0,0 +1,15 @@ +digraph target0 { + rankdir="LR"; + n_0 [label="target0", shape="plaintext"]; + n_1 [id="5", shape=doublecircle, label="5"]; + n_2 [id="1", shape=circle, label="1"]; + n_0 -> n_2 [arrowhead=none]; + n_3 [id="2", shape=circle, label="3"]; + n_4 [id="4", shape=circle, label="4"]; + n_5 [id="3", shape=circle, label="2"]; + + n_2 -> n_5 [id="[$e|2]", label="receive A"]; + n_5 -> n_3 [id="[$e|3]", label="receive B"]; + n_3 -> n_4 [id="[$e|0]", label="receive C"]; + n_4 -> n_1 [id="[$e|1]", label="receive D"]; +} diff --git a/examples/test/foo5/target_local_view.dot b/examples/test/foo5/target_local_view.dot deleted file mode 100644 index 80fdb5d..0000000 --- a/examples/test/foo5/target_local_view.dot +++ /dev/null @@ -1,15 +0,0 @@ -digraph target { - rankdir="LR"; - n_0 [label="target", shape="plaintext"]; - n_1 [id="5", shape=circle, label="2"]; - n_2 [id="1", shape=circle, label="1"]; - n_0 -> n_2 [arrowhead=none]; - n_3 [id="2", shape=doublecircle, label="5"]; - n_4 [id="4", shape=circle, label="3"]; - n_5 [id="3", shape=circle, label="4"]; - - n_1 -> n_4 [id="[$e|2]", label="receive B"]; - n_4 -> n_5 [id="[$e|3]", label="receive C"]; - n_5 -> n_3 [id="[$e|1]", label="receive D"]; - n_2 -> n_1 [id="[$e|0]", label="receive A"]; -} diff --git a/examples/test/foo5/test0_global_view.dot b/examples/test/foo5/test0_global_view.dot new file mode 100644 index 0000000..2421558 --- /dev/null +++ b/examples/test/foo5/test0_global_view.dot @@ -0,0 +1,18 @@ +digraph global { + rankdir="LR"; + n_0 [label="global", shape="plaintext"]; + n_1 [id="5", shape=circle, label="6"]; + n_2 [id="1", shape=circle, label="1"]; + n_0 -> n_2 [arrowhead=none]; + n_3 [id="2", shape=circle, label="2"]; + n_4 [id="4", shape=circle, label="4"]; + n_5 [id="7", shape=circle, label="5"]; + n_6 [id="3", shape=circle, label="3"]; + + n_3 -> n_6 [id="[$e|2]", label="test0/0Δproxy1/1"]; + n_6 -> n_5 [id="[$e|3]", label="test0/0→proxy1/0:m2"]; + n_4 -> n_1 [id="[$e|4]", label="test0/0→proxy1/0:m2"]; + n_2 -> n_3 [id="[$e|0]", label="test0/0Δproxy1/0"]; + n_5 -> n_1 [id="[$e|6]", label="test0/0→proxy1/1:m3"]; + n_6 -> n_4 [id="[$e|5]", label="test0/0→proxy1/1:m3"]; +} diff --git a/examples/test/foo5/test0_local_view.dot b/examples/test/foo5/test0_local_view.dot new file mode 100644 index 0000000..6df6b68 --- /dev/null +++ b/examples/test/foo5/test0_local_view.dot @@ -0,0 +1,21 @@ +digraph test0 { + rankdir="LR"; + n_0 [label="test0", shape="plaintext"]; + n_1 [id="5", shape=doublecircle, label="8"]; + n_2 [id="6", shape=circle, label="7"]; + n_3 [id="1", shape=circle, label="1"]; + n_0 -> n_3 [arrowhead=none]; + n_4 [id="2", shape=circle, label="2"]; + n_5 [id="8", shape=circle, label="3"]; + n_6 [id="4", shape=circle, label="6"]; + n_7 [id="7", shape=circle, label="5"]; + n_8 [id="3", shape=circle, label="4"]; + + n_6 -> n_2 [id="[$e|2]", label="send m3 to proxy1/1"]; + n_5 -> n_8 [id="[$e|3]", label="spawn proxy1/1"]; + n_2 -> n_1 [id="[$e|4]", label="send m4 to target0/0"]; + n_4 -> n_5 [id="[$e|0]", label="spawn proxy1/0"]; + n_7 -> n_6 [id="[$e|6]", label="send m2 to proxy1/0"]; + n_3 -> n_4 [id="[$e|5]", label="spawn target0/0"]; + n_8 -> n_7 [id="[$e|1]", label="send m1 to target0/0"]; +} diff --git a/examples/test/foo5/test_global_view.dot b/examples/test/foo5/test_global_view.dot deleted file mode 100644 index ec9f4b6..0000000 --- a/examples/test/foo5/test_global_view.dot +++ /dev/null @@ -1,19 +0,0 @@ -digraph global { - rankdir="LR"; - n_0 [label="global", shape="plaintext"]; - n_1 [id="5", shape=circle, label="5"]; - n_2 [id="6", shape=circle, label="6"]; - n_3 [id="1", shape=circle, label="1"]; - n_0 -> n_3 [arrowhead=none]; - n_4 [id="2", shape=circle, label="2"]; - n_5 [id="4", shape=circle, label="4"]; - n_6 [id="7", shape=circle, label="7"]; - n_7 [id="3", shape=circle, label="3"]; - - n_5 -> n_2 [id="[$e|4]", label="test→proxy_1:m3"]; - n_7 -> n_5 [id="[$e|2]", label="test→proxy_0:m2"]; - n_7 -> n_1 [id="[$e|3]", label="test→proxy_1:m3"]; - n_4 -> n_7 [id="[$e|1]", label="testΔproxy_1"]; - n_1 -> n_6 [id="[$e|5]", label="test→proxy_0:m2"]; - n_3 -> n_4 [id="[$e|0]", label="testΔproxy_0"]; -} diff --git a/examples/test/foo5/test_local_view.dot b/examples/test/foo5/test_local_view.dot deleted file mode 100644 index 70a411b..0000000 --- a/examples/test/foo5/test_local_view.dot +++ /dev/null @@ -1,21 +0,0 @@ -digraph test { - rankdir="LR"; - n_0 [label="test", shape="plaintext"]; - n_1 [id="5", shape=circle, label="7"]; - n_2 [id="6", shape=doublecircle, label="8"]; - n_3 [id="1", shape=circle, label="1"]; - n_0 -> n_3 [arrowhead=none]; - n_4 [id="2", shape=circle, label="2"]; - n_5 [id="8", shape=circle, label="4"]; - n_6 [id="4", shape=circle, label="5"]; - n_7 [id="7", shape=circle, label="6"]; - n_8 [id="3", shape=circle, label="3"]; - - n_3 -> n_4 [id="[$e|4]", label="spawn target_0"]; - n_7 -> n_1 [id="[$e|2]", label="send m3 to proxy_1"]; - n_1 -> n_2 [id="[$e|3]", label="send m4 to target_0"]; - n_5 -> n_6 [id="[$e|1]", label="send m1 to target_0"]; - n_6 -> n_7 [id="[$e|5]", label="send m2 to proxy_0"]; - n_4 -> n_8 [id="[$e|6]", label="spawn proxy_0"]; - n_8 -> n_5 [id="[$e|0]", label="spawn proxy_1"]; -} diff --git a/examples/test/foo5/w1_local_view.dot b/examples/test/foo5/w1_local_view.dot deleted file mode 100644 index 3d83460..0000000 --- a/examples/test/foo5/w1_local_view.dot +++ /dev/null @@ -1,11 +0,0 @@ -digraph w1 { - rankdir="LR"; - n_0 [label="w1", shape="plaintext"]; - n_1 [id="3", shape=circle, label="3"]; - n_2 [id="2", shape=circle, label="2"]; - n_3 [id="1", shape=circle, label="1"]; - n_0 -> n_3 [arrowhead=none]; - - n_2 -> n_1 [id="[$e|1]", label="send r1 to Reg"]; - n_3 -> n_2 [id="[$e|0]", label="receive _X"]; -} diff --git a/examples/test/foo5/w2_local_view.dot b/examples/test/foo5/w2_local_view.dot deleted file mode 100644 index 5c5ccf3..0000000 --- a/examples/test/foo5/w2_local_view.dot +++ /dev/null @@ -1,11 +0,0 @@ -digraph w2 { - rankdir="LR"; - n_0 [label="w2", shape="plaintext"]; - n_1 [id="3", shape=circle, label="3"]; - n_2 [id="2", shape=circle, label="2"]; - n_3 [id="1", shape=circle, label="1"]; - n_0 -> n_3 [arrowhead=none]; - - n_2 -> n_1 [id="[$e|1]", label="send r2 to Reg"]; - n_3 -> n_2 [id="[$e|0]", label="receive _X"]; -} diff --git a/examples/test/foo6/client_local_view.dot b/examples/test/foo6/client1_local_view.dot similarity index 75% rename from examples/test/foo6/client_local_view.dot rename to examples/test/foo6/client1_local_view.dot index 526e27e..96b9e94 100644 --- a/examples/test/foo6/client_local_view.dot +++ b/examples/test/foo6/client1_local_view.dot @@ -1,6 +1,6 @@ -digraph client { +digraph client1 { rankdir="LR"; - n_0 [label="client", shape="plaintext"]; + n_0 [label="client1", shape="plaintext"]; n_1 [id="1", shape=circle, label="1"]; n_0 -> n_1 [arrowhead=none]; n_2 [id="2", shape=doublecircle, label="2"]; diff --git a/examples/test/foo6/client_gen_local_view.dot b/examples/test/foo6/client_gen_local_view.dot deleted file mode 100644 index c090476..0000000 --- a/examples/test/foo6/client_gen_local_view.dot +++ /dev/null @@ -1,11 +0,0 @@ -digraph client_gen { - rankdir="LR"; - n_0 [label="client_gen", shape="plaintext"]; - n_1 [id="1", shape=circle, label="1"]; - n_0 -> n_1 [arrowhead=none]; - n_2 [id="2", shape=circle, label="2"]; - n_3 [id="3", shape=doublecircle, label="3"]; - - n_1 -> n_2 [id="[$e|0]", label="spawn client_4"]; - n_2 -> n_3 [id="[$e|1]", label="spawn client_5"]; -} diff --git a/examples/test/foo6/client_server_local_view.dot b/examples/test/foo6/client_server_local_view.dot deleted file mode 100644 index 754261f..0000000 --- a/examples/test/foo6/client_server_local_view.dot +++ /dev/null @@ -1,13 +0,0 @@ -digraph client_server { - rankdir="LR"; - n_0 [label="client_server", shape="plaintext"]; - n_1 [id="1", shape=circle, label="1"]; - n_0 -> n_1 [arrowhead=none]; - n_2 [id="2", shape=doublecircle, label="4"]; - n_3 [id="4", shape=circle, label="3"]; - n_4 [id="3", shape=circle, label="2"]; - - n_1 -> n_4 [id="[$e|0]", label="spawn server_1"]; - n_4 -> n_3 [id="[$e|2]", label="spawn client_2"]; - n_3 -> n_2 [id="[$e|1]", label="spawn client_3"]; -} diff --git a/examples/test/foo6/server_local_view.dot b/examples/test/foo6/server0_local_view.dot similarity index 68% rename from examples/test/foo6/server_local_view.dot rename to examples/test/foo6/server0_local_view.dot index 1b36b33..085eb3c 100644 --- a/examples/test/foo6/server_local_view.dot +++ b/examples/test/foo6/server0_local_view.dot @@ -1,6 +1,6 @@ -digraph server { +digraph server0 { rankdir="LR"; - n_0 [label="server", shape="plaintext"]; + n_0 [label="server0", shape="plaintext"]; n_1 [id="1", shape=circle, label="1"]; n_0 -> n_1 [arrowhead=none]; diff --git a/examples/test/foo6/test0_global_view.dot b/examples/test/foo6/test0_global_view.dot new file mode 100644 index 0000000..e3c0c96 --- /dev/null +++ b/examples/test/foo6/test0_global_view.dot @@ -0,0 +1,12 @@ +digraph global { + rankdir="LR"; + n_0 [label="global", shape="plaintext"]; + n_1 [id="1", shape=circle, label="1"]; + n_0 -> n_1 [arrowhead=none]; + n_2 [id="2", shape=circle, label="2"]; + n_3 [id="3", shape=circle, label="3"]; + + n_2 -> n_3 [id="[$e|3]", label="test0/0Δclient1/0"]; + n_2 -> n_3 [id="[$e|1]", label="test0/0Δclient1/1"]; + n_1 -> n_2 [id="[$e|0]", label="test0/0Δserver0/0"]; +} diff --git a/examples/test/foo6/test0_local_view.dot b/examples/test/foo6/test0_local_view.dot new file mode 100644 index 0000000..05b8ce2 --- /dev/null +++ b/examples/test/foo6/test0_local_view.dot @@ -0,0 +1,12 @@ +digraph test0 { + rankdir="LR"; + n_0 [label="test0", shape="plaintext"]; + n_1 [id="1", shape=circle, label="1"]; + n_0 -> n_1 [arrowhead=none]; + n_2 [id="2", shape=circle, label="2"]; + n_3 [id="3", shape=doublecircle, label="3"]; + + n_2 -> n_3 [id="[$e|2]", label="spawn client1/0"]; + n_1 -> n_2 [id="[$e|1]", label="spawn server0/0"]; + n_2 -> n_3 [id="[$e|0]", label="spawn client1/1"]; +} diff --git a/examples/test/foo6/test_global_view.dot b/examples/test/foo6/test_global_view.dot deleted file mode 100644 index dac7721..0000000 --- a/examples/test/foo6/test_global_view.dot +++ /dev/null @@ -1,13 +0,0 @@ -digraph global { - rankdir="LR"; - n_0 [label="global", shape="plaintext"]; - n_1 [id="1", shape=circle, label="1"]; - n_0 -> n_1 [arrowhead=none]; - n_2 [id="2", shape=circle, label="2"]; - n_3 [id="4", shape=circle, label="4"]; - n_4 [id="3", shape=circle, label="3"]; - - n_1 -> n_2 [id="[$e|0]", label="testΔserver_0"]; - n_4 -> n_3 [id="[$e|2]", label="testΔclient_1"]; - n_2 -> n_4 [id="[$e|1]", label="testΔclient_0"]; -} diff --git a/examples/test/foo6/test_local_view.dot b/examples/test/foo6/test_local_view.dot deleted file mode 100644 index 8a633ed..0000000 --- a/examples/test/foo6/test_local_view.dot +++ /dev/null @@ -1,13 +0,0 @@ -digraph test { - rankdir="LR"; - n_0 [label="test", shape="plaintext"]; - n_1 [id="1", shape=circle, label="1"]; - n_0 -> n_1 [arrowhead=none]; - n_2 [id="2", shape=doublecircle, label="4"]; - n_3 [id="4", shape=circle, label="2"]; - n_4 [id="3", shape=circle, label="3"]; - - n_1 -> n_3 [id="[$e|0]", label="spawn server_0"]; - n_3 -> n_4 [id="[$e|2]", label="spawn client_0"]; - n_4 -> n_2 [id="[$e|1]", label="spawn client_1"]; -} diff --git a/examples/test/ping/ping_local_view.dot b/examples/test/ping/ping_local_view.dot deleted file mode 100644 index e341d42..0000000 --- a/examples/test/ping/ping_local_view.dot +++ /dev/null @@ -1,12 +0,0 @@ -digraph ping { - rankdir="LR"; - n_0 [label="ping", shape="plaintext"]; - n_1 [id="1", shape=circle, label="1"]; - n_0 -> n_1 [arrowhead=none]; - n_2 [id="2", shape=doublecircle, label="3"]; - n_3 [id="3", shape=circle, label="2"]; - - n_1 -> n_2 [id="[$e|1]", label="receive kill"]; - n_3 -> n_1 [id="[$e|5]", label="send {pid_self,pid_self} to Pong"]; - n_1 -> n_3 [id="[$e|2]", label="receive N"]; -} diff --git a/examples/test/ping/pong0_local_view.dot b/examples/test/ping/pong0_local_view.dot new file mode 100644 index 0000000..c4fd085 --- /dev/null +++ b/examples/test/ping/pong0_local_view.dot @@ -0,0 +1,14 @@ +digraph pong0 { + rankdir="LR"; + n_0 [label="pong0", shape="plaintext"]; + n_1 [id="1", shape=circle, label="1"]; + n_0 -> n_1 [arrowhead=none]; + n_2 [id="2", shape=circle, label="3"]; + n_3 [id="4", shape=doublecircle, label="4"]; + n_4 [id="3", shape=circle, label="2"]; + + n_1 -> n_2 [id="[$e|4]", label="receive {S,0}"]; + n_1 -> n_4 [id="[$e|0]", label="receive {S,N}"]; + n_4 -> n_1 [id="[$e|6]", label="send N to S"]; + n_2 -> n_3 [id="[$e|5]", label="send kill to S"]; +} diff --git a/examples/test/ping/pong_local_view.dot b/examples/test/ping/pong_local_view.dot deleted file mode 100644 index 8f7be1c..0000000 --- a/examples/test/ping/pong_local_view.dot +++ /dev/null @@ -1,14 +0,0 @@ -digraph pong { - rankdir="LR"; - n_0 [label="pong", shape="plaintext"]; - n_1 [id="5", shape=circle, label="3"]; - n_2 [id="1", shape=circle, label="1"]; - n_0 -> n_2 [arrowhead=none]; - n_3 [id="2", shape=doublecircle, label="4"]; - n_4 [id="3", shape=circle, label="2"]; - - n_1 -> n_2 [id="[$e|6]", label="send N to S"]; - n_2 -> n_4 [id="[$e|5]", label="receive {S,0}"]; - n_2 -> n_1 [id="[$e|4]", label="receive {S,N}"]; - n_4 -> n_3 [id="[$e|2]", label="send kill to S"]; -} diff --git a/examples/test/ping/start0_global_view.dot b/examples/test/ping/start0_global_view.dot new file mode 100644 index 0000000..f571c10 --- /dev/null +++ b/examples/test/ping/start0_global_view.dot @@ -0,0 +1,11 @@ +digraph global { + rankdir="LR"; + n_0 [label="global", shape="plaintext"]; + n_1 [id="1", shape=circle, label="1"]; + n_0 -> n_1 [arrowhead=none]; + n_2 [id="2", shape=circle, label="2"]; + n_3 [id="3", shape=circle, label="3"]; + + n_2 -> n_3 [id="[$e|0]", label="start0/0→start0/0:3"]; + n_1 -> n_2 [id="[$e|1]", label="start0/0Δpong0/0"]; +} diff --git a/examples/test/ping/start0_local_view.dot b/examples/test/ping/start0_local_view.dot new file mode 100644 index 0000000..b7fb69d --- /dev/null +++ b/examples/test/ping/start0_local_view.dot @@ -0,0 +1,16 @@ +digraph start0 { + rankdir="LR"; + n_0 [label="start0", shape="plaintext"]; + n_1 [id="5", shape=circle, label="5"]; + n_2 [id="6", shape=doublecircle, label="4"]; + n_3 [id="1", shape=circle, label="1"]; + n_0 -> n_3 [arrowhead=none]; + n_4 [id="2", shape=circle, label="2"]; + n_5 [id="3", shape=circle, label="3"]; + + n_5 -> n_2 [id="[$e|4]", label="receive kill"]; + n_5 -> n_1 [id="[$e|6]", label="receive N"]; + n_1 -> n_5 [id="[$e|2]", label="send {pid_self,pid_self} to Pong"]; + n_3 -> n_4 [id="[$e|1]", label="spawn pong0/0"]; + n_4 -> n_5 [id="[$e|7]", label="send 3 to pid_self"]; +} diff --git a/examples/test/ping/start_global_view.dot b/examples/test/ping/start_global_view.dot deleted file mode 100644 index a07cb45..0000000 --- a/examples/test/ping/start_global_view.dot +++ /dev/null @@ -1,14 +0,0 @@ -digraph global { - rankdir="LR"; - n_0 [label="global", shape="plaintext"]; - n_1 [id="1", shape=circle, label="1"]; - n_0 -> n_1 [arrowhead=none]; - n_2 [id="2", shape=circle, label="2"]; - n_3 [id="4", shape=circle, label="4"]; - n_4 [id="3", shape=circle, label="3"]; - - n_1 -> n_2 [id="[$e|1]", label="startΔpong_0"]; - n_2 -> n_4 [id="[$e|3]", label="start→start:3"]; - n_3 -> n_4 [id="[$e|0]", label="pong_0→start:any"]; - n_4 -> n_3 [id="[$e|2]", label="start→pong_0:{pid_self,any}"]; -} diff --git a/examples/test/ping/start_local_view.dot b/examples/test/ping/start_local_view.dot deleted file mode 100644 index 00acece..0000000 --- a/examples/test/ping/start_local_view.dot +++ /dev/null @@ -1,16 +0,0 @@ -digraph start { - rankdir="LR"; - n_0 [label="start", shape="plaintext"]; - n_1 [id="5", shape=doublecircle, label="5"]; - n_2 [id="6", shape=circle, label="4"]; - n_3 [id="1", shape=circle, label="1"]; - n_0 -> n_3 [arrowhead=none]; - n_4 [id="2", shape=circle, label="2"]; - n_5 [id="3", shape=circle, label="3"]; - - n_5 -> n_2 [id="[$e|1]", label="receive N"]; - n_3 -> n_4 [id="[$e|6]", label="spawn pong_0"]; - n_2 -> n_5 [id="[$e|5]", label="send {pid_self,pid_self} to pong_0"]; - n_5 -> n_1 [id="[$e|4]", label="receive kill"]; - n_4 -> n_5 [id="[$e|7]", label="send 3 to S"]; -} diff --git a/examples/ticktackloop/start0_global_view.dot b/examples/ticktackloop/start0_global_view.dot new file mode 100644 index 0000000..f0ab167 --- /dev/null +++ b/examples/ticktackloop/start0_global_view.dot @@ -0,0 +1,16 @@ +digraph global { + rankdir="LR"; + n_0 [label="global", shape="plaintext"]; + n_1 [id="5", shape=circle, label="4"]; + n_2 [id="1", shape=circle, label="1"]; + n_0 -> n_2 [arrowhead=none]; + n_3 [id="2", shape=circle, label="2"]; + n_4 [id="4", shape=circle, label="5"]; + n_5 [id="3", shape=circle, label="3"]; + + n_3 -> n_5 [id="[$e|3]", label="start0/0Δtic_loop0/0"]; + n_2 -> n_3 [id="[$e|2]", label="start0/0Δtac_loop0/0"]; + n_1 -> n_4 [id="[$e|1]", label="tic_loop0/0→tac_loop0/0:tic"]; + n_5 -> n_1 [id="[$e|4]", label="start0/0→tic_loop0/0:tac"]; + n_4 -> n_1 [id="[$e|0]", label="tac_loop0/0→tic_loop0/0:tac"]; +} diff --git a/examples/ticktackloop/start0_local_view.dot b/examples/ticktackloop/start0_local_view.dot new file mode 100644 index 0000000..b3ae192 --- /dev/null +++ b/examples/ticktackloop/start0_local_view.dot @@ -0,0 +1,13 @@ +digraph start0 { + rankdir="LR"; + n_0 [label="start0", shape="plaintext"]; + n_1 [id="1", shape=circle, label="1"]; + n_0 -> n_1 [arrowhead=none]; + n_2 [id="2", shape=circle, label="3"]; + n_3 [id="4", shape=circle, label="2"]; + n_4 [id="3", shape=doublecircle, label="4"]; + + n_1 -> n_3 [id="[$e|2]", label="spawn tac_loop0/0"]; + n_2 -> n_4 [id="[$e|1]", label="send tac to tic_loop0/0"]; + n_3 -> n_2 [id="[$e|0]", label="spawn tic_loop0/0"]; +} diff --git a/examples/ticktackloop/start_global_view.dot b/examples/ticktackloop/start_global_view.dot deleted file mode 100644 index 6c1b0fb..0000000 --- a/examples/ticktackloop/start_global_view.dot +++ /dev/null @@ -1,16 +0,0 @@ -digraph global { - rankdir="LR"; - n_0 [label="global", shape="plaintext"]; - n_1 [id="5", shape=circle, label="5"]; - n_2 [id="1", shape=circle, label="1"]; - n_0 -> n_2 [arrowhead=none]; - n_3 [id="2", shape=circle, label="2"]; - n_4 [id="4", shape=circle, label="4"]; - n_5 [id="3", shape=circle, label="3"]; - - n_4 -> n_1 [id="[$e|3]", label="tic_loop_0→tac_loop_0:tic"]; - n_2 -> n_3 [id="[$e|0]", label="startΔtac_loop_0"]; - n_1 -> n_4 [id="[$e|4]", label="tac_loop_0→tic_loop_0:tac"]; - n_3 -> n_5 [id="[$e|1]", label="startΔtic_loop_0"]; - n_5 -> n_4 [id="[$e|2]", label="start→tic_loop_0:tac"]; -} diff --git a/examples/ticktackloop/start_local_view.dot b/examples/ticktackloop/start_local_view.dot deleted file mode 100644 index bc84e40..0000000 --- a/examples/ticktackloop/start_local_view.dot +++ /dev/null @@ -1,13 +0,0 @@ -digraph start { - rankdir="LR"; - n_0 [label="start", shape="plaintext"]; - n_1 [id="1", shape=circle, label="1"]; - n_0 -> n_1 [arrowhead=none]; - n_2 [id="2", shape=circle, label="2"]; - n_3 [id="4", shape=circle, label="3"]; - n_4 [id="3", shape=doublecircle, label="4"]; - - n_3 -> n_4 [id="[$e|0]", label="send tac to tic_loop_0"]; - n_2 -> n_3 [id="[$e|1]", label="spawn tic_loop_0"]; - n_1 -> n_2 [id="[$e|2]", label="spawn tac_loop_0"]; -} diff --git a/examples/ticktackloop/tac_loop0_local_view.dot b/examples/ticktackloop/tac_loop0_local_view.dot new file mode 100644 index 0000000..e028493 --- /dev/null +++ b/examples/ticktackloop/tac_loop0_local_view.dot @@ -0,0 +1,14 @@ +digraph tac_loop0 { + rankdir="LR"; + n_0 [label="tac_loop0", shape="plaintext"]; + n_1 [id="1", shape=circle, label="1"]; + n_0 -> n_1 [arrowhead=none]; + n_2 [id="2", shape=circle, label="3"]; + n_3 [id="4", shape=doublecircle, label="4"]; + n_4 [id="3", shape=circle, label="2"]; + + n_1 -> n_2 [id="[$e|3]", label="receive tic"]; + n_4 -> n_3 [id="[$e|2]", label="send stop to tic_loop0/0"]; + n_2 -> n_1 [id="[$e|6]", label="send tac to tic_loop0/0"]; + n_1 -> n_4 [id="[$e|0]", label="receive stop"]; +} diff --git a/examples/ticktackloop/tac_loop_local_view.dot b/examples/ticktackloop/tac_loop_local_view.dot deleted file mode 100644 index 1b9c166..0000000 --- a/examples/ticktackloop/tac_loop_local_view.dot +++ /dev/null @@ -1,14 +0,0 @@ -digraph tac_loop { - rankdir="LR"; - n_0 [label="tac_loop", shape="plaintext"]; - n_1 [id="1", shape=circle, label="1"]; - n_0 -> n_1 [arrowhead=none]; - n_2 [id="2", shape=circle, label="2"]; - n_3 [id="4", shape=circle, label="3"]; - n_4 [id="3", shape=doublecircle, label="4"]; - - n_1 -> n_2 [id="[$e|3]", label="receive tic"]; - n_1 -> n_3 [id="[$e|4]", label="receive stop"]; - n_3 -> n_4 [id="[$e|5]", label="send stop to tic_loop_0"]; - n_2 -> n_1 [id="[$e|6]", label="send tac to tic_loop_0"]; -} diff --git a/examples/ticktackloop/tic_loop0_local_view.dot b/examples/ticktackloop/tic_loop0_local_view.dot new file mode 100644 index 0000000..4c3526c --- /dev/null +++ b/examples/ticktackloop/tic_loop0_local_view.dot @@ -0,0 +1,14 @@ +digraph tic_loop0 { + rankdir="LR"; + n_0 [label="tic_loop0", shape="plaintext"]; + n_1 [id="1", shape=circle, label="1"]; + n_0 -> n_1 [arrowhead=none]; + n_2 [id="2", shape=circle, label="3"]; + n_3 [id="4", shape=doublecircle, label="4"]; + n_4 [id="3", shape=circle, label="2"]; + + n_1 -> n_2 [id="[$e|2]", label="receive tac"]; + n_2 -> n_1 [id="[$e|6]", label="send tic to tac_loop0/0"]; + n_4 -> n_3 [id="[$e|1]", label="send stop to tac_loop0/0"]; + n_1 -> n_4 [id="[$e|0]", label="receive stop"]; +} diff --git a/examples/ticktackloop/tic_loop_local_view.dot b/examples/ticktackloop/tic_loop_local_view.dot deleted file mode 100644 index 9026d6a..0000000 --- a/examples/ticktackloop/tic_loop_local_view.dot +++ /dev/null @@ -1,14 +0,0 @@ -digraph tic_loop { - rankdir="LR"; - n_0 [label="tic_loop", shape="plaintext"]; - n_1 [id="1", shape=circle, label="1"]; - n_0 -> n_1 [arrowhead=none]; - n_2 [id="2", shape=circle, label="2"]; - n_3 [id="4", shape=circle, label="3"]; - n_4 [id="3", shape=doublecircle, label="4"]; - - n_3 -> n_4 [id="[$e|3]", label="send stop to tac_loop_0"]; - n_1 -> n_3 [id="[$e|4]", label="receive stop"]; - n_1 -> n_2 [id="[$e|1]", label="receive tac"]; - n_2 -> n_1 [id="[$e|6]", label="send tic to tac_loop_0"]; -} diff --git a/examples/ticktackstop/random0_local_view.dot b/examples/ticktackstop/random0_local_view.dot new file mode 100644 index 0000000..2f91698 --- /dev/null +++ b/examples/ticktackstop/random0_local_view.dot @@ -0,0 +1,9 @@ +digraph random0 { + rankdir="LR"; + n_0 [label="random0", shape="plaintext"]; + n_1 [id="1", shape=circle, label="1"]; + n_0 -> n_1 [arrowhead=none]; + n_2 [id="2", shape=doublecircle, label="2"]; + + n_1 -> n_2 [id="[$e|0]", label="send stop to tic_loop0/0"]; +} diff --git a/examples/ticktackstop/random_local_view.dot b/examples/ticktackstop/random_local_view.dot deleted file mode 100644 index ae3050f..0000000 --- a/examples/ticktackstop/random_local_view.dot +++ /dev/null @@ -1,9 +0,0 @@ -digraph random { - rankdir="LR"; - n_0 [label="random", shape="plaintext"]; - n_1 [id="1", shape=circle, label="1"]; - n_0 -> n_1 [arrowhead=none]; - n_2 [id="2", shape=doublecircle, label="2"]; - - n_1 -> n_2 [id="[$e|0]", label="send stop to tic_loop_0"]; -} diff --git a/examples/ticktackstop/start0_global_view.dot b/examples/ticktackstop/start0_global_view.dot new file mode 100644 index 0000000..70b9fbd --- /dev/null +++ b/examples/ticktackstop/start0_global_view.dot @@ -0,0 +1,20 @@ +digraph global { + rankdir="LR"; + n_0 [label="global", shape="plaintext"]; + n_1 [id="5", shape=circle, label="6"]; + n_2 [id="1", shape=circle, label="1"]; + n_0 -> n_2 [arrowhead=none]; + n_3 [id="2", shape=circle, label="2"]; + n_4 [id="8", shape=circle, label="4"]; + n_5 [id="4", shape=circle, label="5"]; + n_6 [id="7", shape=circle, label="7"]; + n_7 [id="3", shape=circle, label="3"]; + + n_2 -> n_3 [id="[$e|3]", label="start0/0Δtac_loop0/0"]; + n_4 -> n_6 [id="[$e|1]", label="random0/0→tic_loop0/0:stop"]; + n_5 -> n_1 [id="[$e|6]", label="tic_loop0/0→tac_loop0/0:tic"]; + n_7 -> n_4 [id="[$e|4]", label="start0/0Δrandom0/0"]; + n_6 -> n_1 [id="[$e|7]", label="tic_loop0/0→tac_loop0/0:stop"]; + n_3 -> n_7 [id="[$e|5]", label="start0/0Δtic_loop0/0"]; + n_7 -> n_5 [id="[$e|0]", label="start0/0→tic_loop0/0:tac"]; +} diff --git a/examples/ticktackstop/start0_local_view.dot b/examples/ticktackstop/start0_local_view.dot new file mode 100644 index 0000000..16de98a --- /dev/null +++ b/examples/ticktackstop/start0_local_view.dot @@ -0,0 +1,14 @@ +digraph start0 { + rankdir="LR"; + n_0 [label="start0", shape="plaintext"]; + n_1 [id="5", shape=circle, label="2"]; + n_2 [id="1", shape=circle, label="1"]; + n_0 -> n_2 [arrowhead=none]; + n_3 [id="2", shape=circle, label="3"]; + n_4 [id="3", shape=doublecircle, label="4"]; + + n_3 -> n_4 [id="[$e|1]", label="send tac to tic_loop0/0"]; + n_3 -> n_4 [id="[$e|4]", label="spawn random0/0"]; + n_2 -> n_1 [id="[$e|2]", label="spawn tac_loop0/0"]; + n_1 -> n_3 [id="[$e|0]", label="spawn tic_loop0/0"]; +} diff --git a/examples/ticktackstop/start_global_view.dot b/examples/ticktackstop/start_global_view.dot deleted file mode 100644 index fd3f5e9..0000000 --- a/examples/ticktackstop/start_global_view.dot +++ /dev/null @@ -1,33 +0,0 @@ -digraph global { - rankdir="LR"; - n_0 [label="global", shape="plaintext"]; - n_1 [id="5", shape=circle, label="5"]; - n_2 [id="12", shape=circle, label="12"]; - n_3 [id="11", shape=circle, label="11"]; - n_4 [id="14", shape=circle, label="14"]; - n_5 [id="6", shape=circle, label="6"]; - n_6 [id="13", shape=circle, label="13"]; - n_7 [id="10", shape=circle, label="10"]; - n_8 [id="1", shape=circle, label="1"]; - n_0 -> n_8 [arrowhead=none]; - n_9 [id="9", shape=circle, label="9"]; - n_10 [id="2", shape=circle, label="2"]; - n_11 [id="8", shape=circle, label="8"]; - n_12 [id="4", shape=circle, label="4"]; - n_13 [id="7", shape=circle, label="7"]; - n_14 [id="3", shape=circle, label="3"]; - - n_14 -> n_12 [id="[$e|2]", label="startΔrandom_0"]; - n_10 -> n_14 [id="[$e|1]", label="startΔtic_loop_0"]; - n_13 -> n_7 [id="[$e|8]", label="random_0→tic_loop_0:stop"]; - n_5 -> n_9 [id="[$e|7]", label="tic_loop_0→tac_loop_0:stop"]; - n_12 -> n_5 [id="[$e|4]", label="random_0→tic_loop_0:stop"]; - n_7 -> n_6 [id="[$e|11]", label="tic_loop_0→tac_loop_0:stop"]; - n_1 -> n_13 [id="[$e|5]", label="tic_loop_0→tac_loop_0:tic"]; - n_11 -> n_2 [id="[$e|10]", label="tic_loop_0→tac_loop_0:stop"]; - n_11 -> n_3 [id="[$e|9]", label="tic_loop_0→tac_loop_0:tic"]; - n_3 -> n_4 [id="[$e|12]", label="tic_loop_0→tac_loop_0:stop"]; - n_12 -> n_1 [id="[$e|3]", label="start→tic_loop_0:tac"]; - n_8 -> n_10 [id="[$e|0]", label="startΔtac_loop_0"]; - n_1 -> n_11 [id="[$e|6]", label="random_0→tic_loop_0:stop"]; -} diff --git a/examples/ticktackstop/start_local_view.dot b/examples/ticktackstop/start_local_view.dot deleted file mode 100644 index 75290d4..0000000 --- a/examples/ticktackstop/start_local_view.dot +++ /dev/null @@ -1,15 +0,0 @@ -digraph start { - rankdir="LR"; - n_0 [label="start", shape="plaintext"]; - n_1 [id="5", shape=circle, label="4"]; - n_2 [id="1", shape=circle, label="1"]; - n_0 -> n_2 [arrowhead=none]; - n_3 [id="2", shape=circle, label="2"]; - n_4 [id="4", shape=doublecircle, label="5"]; - n_5 [id="3", shape=circle, label="3"]; - - n_3 -> n_5 [id="[$e|2]", label="spawn tic_loop_0"]; - n_5 -> n_1 [id="[$e|1]", label="spawn random_0"]; - n_2 -> n_3 [id="[$e|3]", label="spawn tac_loop_0"]; - n_1 -> n_4 [id="[$e|0]", label="send tac to tic_loop_0"]; -} diff --git a/examples/ticktackstop/tac_loop0_local_view.dot b/examples/ticktackstop/tac_loop0_local_view.dot new file mode 100644 index 0000000..b3eaee4 --- /dev/null +++ b/examples/ticktackstop/tac_loop0_local_view.dot @@ -0,0 +1,14 @@ +digraph tac_loop0 { + rankdir="LR"; + n_0 [label="tac_loop0", shape="plaintext"]; + n_1 [id="1", shape=circle, label="1"]; + n_0 -> n_1 [arrowhead=none]; + n_2 [id="4", shape=doublecircle, label="3"]; + n_3 [id="3", shape=circle, label="2"]; + + n_1 -> n_2 [id="[$e|3]", label="receive stop"]; + n_3 -> n_2 [id="[$e|1]", label="receive stop"]; + n_1 -> n_3 [id="[$e|6]", label="receive tic"]; + n_3 -> n_1 [id="[$e|7]", label="send tac to tic_loop0/0"]; + n_3 -> n_3 [id="[$e|5]", label="receive tic"]; +} diff --git a/examples/ticktackstop/tac_loop_local_view.dot b/examples/ticktackstop/tac_loop_local_view.dot deleted file mode 100644 index 7fb8451..0000000 --- a/examples/ticktackstop/tac_loop_local_view.dot +++ /dev/null @@ -1,14 +0,0 @@ -digraph tac_loop { - rankdir="LR"; - n_0 [label="tac_loop", shape="plaintext"]; - n_1 [id="1", shape=circle, label="1"]; - n_0 -> n_1 [arrowhead=none]; - n_2 [id="4", shape=circle, label="3"]; - n_3 [id="3", shape=doublecircle, label="2"]; - - n_2 -> n_2 [id="[$e|2]", label="receive tic"]; - n_2 -> n_1 [id="[$e|7]", label="send tac to tic_loop_0"]; - n_1 -> n_3 [id="[$e|4]", label="receive stop"]; - n_1 -> n_2 [id="[$e|5]", label="receive tic"]; - n_2 -> n_3 [id="[$e|3]", label="receive stop"]; -} diff --git a/examples/ticktackstop/tic_loop0_local_view.dot b/examples/ticktackstop/tic_loop0_local_view.dot new file mode 100644 index 0000000..2b42db8 --- /dev/null +++ b/examples/ticktackstop/tic_loop0_local_view.dot @@ -0,0 +1,14 @@ +digraph tic_loop0 { + rankdir="LR"; + n_0 [label="tic_loop0", shape="plaintext"]; + n_1 [id="1", shape=circle, label="1"]; + n_0 -> n_1 [arrowhead=none]; + n_2 [id="2", shape=circle, label="3"]; + n_3 [id="4", shape=doublecircle, label="4"]; + n_4 [id="3", shape=circle, label="2"]; + + n_4 -> n_3 [id="[$e|1]", label="send stop to tac_loop0/0"]; + n_2 -> n_1 [id="[$e|6]", label="send tic to tac_loop0/0"]; + n_1 -> n_2 [id="[$e|2]", label="receive tac"]; + n_1 -> n_4 [id="[$e|0]", label="receive stop"]; +} diff --git a/examples/ticktackstop/tic_loop_local_view.dot b/examples/ticktackstop/tic_loop_local_view.dot deleted file mode 100644 index 1bc7c57..0000000 --- a/examples/ticktackstop/tic_loop_local_view.dot +++ /dev/null @@ -1,14 +0,0 @@ -digraph tic_loop { - rankdir="LR"; - n_0 [label="tic_loop", shape="plaintext"]; - n_1 [id="1", shape=circle, label="1"]; - n_0 -> n_1 [arrowhead=none]; - n_2 [id="2", shape=circle, label="2"]; - n_3 [id="4", shape=circle, label="3"]; - n_4 [id="3", shape=doublecircle, label="4"]; - - n_1 -> n_2 [id="[$e|1]", label="receive tac"]; - n_1 -> n_3 [id="[$e|4]", label="receive stop"]; - n_3 -> n_4 [id="[$e|3]", label="send stop to tac_loop_0"]; - n_2 -> n_1 [id="[$e|6]", label="send tic to tac_loop_0"]; -} diff --git a/examples/trick/a0_local_view.dot b/examples/trick/a0_local_view.dot new file mode 100644 index 0000000..786b6aa --- /dev/null +++ b/examples/trick/a0_local_view.dot @@ -0,0 +1,11 @@ +digraph a0 { + rankdir="LR"; + n_0 [label="a0", shape="plaintext"]; + n_1 [id="1", shape=circle, label="1"]; + n_0 -> n_1 [arrowhead=none]; + n_2 [id="2", shape=circle, label="2"]; + n_3 [id="3", shape=doublecircle, label="3"]; + + n_1 -> n_2 [id="[$e|1]", label="send v1 to c0/0"]; + n_2 -> n_3 [id="[$e|0]", label="send v2 to b0/0"]; +} diff --git a/examples/trick/a_local_view.dot b/examples/trick/a_local_view.dot deleted file mode 100644 index 7137d2c..0000000 --- a/examples/trick/a_local_view.dot +++ /dev/null @@ -1,11 +0,0 @@ -digraph a { - rankdir="LR"; - n_0 [label="a", shape="plaintext"]; - n_1 [id="1", shape=circle, label="1"]; - n_0 -> n_1 [arrowhead=none]; - n_2 [id="2", shape=circle, label="2"]; - n_3 [id="3", shape=doublecircle, label="3"]; - - n_1 -> n_2 [id="[$e|0]", label="send v1 to c_0"]; - n_2 -> n_3 [id="[$e|1]", label="send v2 to b_0"]; -} diff --git a/examples/test/foo2/test_local_view.dot b/examples/trick/b0_local_view.dot similarity index 53% rename from examples/test/foo2/test_local_view.dot rename to examples/trick/b0_local_view.dot index fc60150..8e4f198 100644 --- a/examples/test/foo2/test_local_view.dot +++ b/examples/trick/b0_local_view.dot @@ -1,11 +1,11 @@ -digraph test { +digraph b0 { rankdir="LR"; - n_0 [label="test", shape="plaintext"]; + n_0 [label="b0", shape="plaintext"]; n_1 [id="1", shape=circle, label="1"]; n_0 -> n_1 [arrowhead=none]; n_2 [id="2", shape=circle, label="2"]; n_3 [id="3", shape=doublecircle, label="3"]; - n_2 -> n_3 [id="[$e|1]", label="spawn a_0"]; - n_1 -> n_2 [id="[$e|0]", label="spawn c_0"]; + n_1 -> n_2 [id="[$e|1]", label="receive v2"]; + n_2 -> n_3 [id="[$e|0]", label="send v2 to c0/0"]; } diff --git a/examples/trick/b_local_view.dot b/examples/trick/b_local_view.dot deleted file mode 100644 index e83cc13..0000000 --- a/examples/trick/b_local_view.dot +++ /dev/null @@ -1,11 +0,0 @@ -digraph b { - rankdir="LR"; - n_0 [label="b", shape="plaintext"]; - n_1 [id="1", shape=circle, label="1"]; - n_0 -> n_1 [arrowhead=none]; - n_2 [id="2", shape=circle, label="2"]; - n_3 [id="3", shape=doublecircle, label="3"]; - - n_1 -> n_2 [id="[$e|0]", label="receive v2"]; - n_2 -> n_3 [id="[$e|1]", label="send v2 to c_0"]; -} diff --git a/examples/test/foo2/b_local_view.dot b/examples/trick/c0_local_view.dot similarity index 54% rename from examples/test/foo2/b_local_view.dot rename to examples/trick/c0_local_view.dot index 249bd65..1264ae2 100644 --- a/examples/test/foo2/b_local_view.dot +++ b/examples/trick/c0_local_view.dot @@ -1,11 +1,11 @@ -digraph b { +digraph c0 { rankdir="LR"; - n_0 [label="b", shape="plaintext"]; + n_0 [label="c0", shape="plaintext"]; n_1 [id="1", shape=circle, label="1"]; n_0 -> n_1 [arrowhead=none]; n_2 [id="2", shape=doublecircle, label="3"]; n_3 [id="3", shape=circle, label="2"]; - n_3 -> n_2 [id="[$e|1]", label="receive Z"]; - n_1 -> n_3 [id="[$e|0]", label="receive X"]; + n_3 -> n_2 [id="[$e|1]", label="receive v2"]; + n_1 -> n_3 [id="[$e|0]", label="receive v1"]; } diff --git a/examples/trick/main0_global_view.dot b/examples/trick/main0_global_view.dot new file mode 100644 index 0000000..638d9da --- /dev/null +++ b/examples/trick/main0_global_view.dot @@ -0,0 +1,24 @@ +digraph global { + rankdir="LR"; + n_0 [label="global", shape="plaintext"]; + n_1 [id="5", shape=circle, label="7"]; + n_2 [id="6", shape=circle, label="9"]; + n_3 [id="10", shape=circle, label="4"]; + n_4 [id="1", shape=circle, label="1"]; + n_0 -> n_4 [arrowhead=none]; + n_5 [id="9", shape=circle, label="5"]; + n_6 [id="2", shape=circle, label="2"]; + n_7 [id="8", shape=circle, label="8"]; + n_8 [id="4", shape=circle, label="6"]; + n_9 [id="3", shape=circle, label="3"]; + + n_4 -> n_6 [id="[$e|3]", label="main0/0Δa0/0"]; + n_3 -> n_8 [id="[$e|8]", label="a0/0→b0/0:v2"]; + n_3 -> n_5 [id="[$e|2]", label="a0/0→c0/0:v1"]; + n_8 -> n_1 [id="[$e|6]", label="a0/0→c0/0:v1"]; + n_9 -> n_3 [id="[$e|5]", label="main0/0Δc0/0"]; + n_1 -> n_2 [id="[$e|9]", label="b0/0→c0/0:v2"]; + n_6 -> n_9 [id="[$e|1]", label="main0/0Δb0/0"]; + n_7 -> n_2 [id="[$e|4]", label="b0/0→c0/0:v2"]; + n_5 -> n_7 [id="[$e|0]", label="a0/0→b0/0:v2"]; +} diff --git a/examples/trick/main0_local_view.dot b/examples/trick/main0_local_view.dot new file mode 100644 index 0000000..99dc5b9 --- /dev/null +++ b/examples/trick/main0_local_view.dot @@ -0,0 +1,13 @@ +digraph main0 { + rankdir="LR"; + n_0 [label="main0", shape="plaintext"]; + n_1 [id="1", shape=circle, label="1"]; + n_0 -> n_1 [arrowhead=none]; + n_2 [id="2", shape=circle, label="2"]; + n_3 [id="4", shape=circle, label="3"]; + n_4 [id="3", shape=doublecircle, label="4"]; + + n_2 -> n_3 [id="[$e|2]", label="spawn b0/0"]; + n_3 -> n_4 [id="[$e|1]", label="spawn c0/0"]; + n_1 -> n_2 [id="[$e|0]", label="spawn a0/0"]; +} diff --git a/examples/trick/main_global_view.dot b/examples/trick/main_global_view.dot deleted file mode 100644 index 1671522..0000000 --- a/examples/trick/main_global_view.dot +++ /dev/null @@ -1,25 +0,0 @@ -digraph global { - rankdir="LR"; - n_0 [label="global", shape="plaintext"]; - n_1 [id="5", shape=circle, label="5"]; - n_2 [id="6", shape=circle, label="6"]; - n_3 [id="10", shape=circle, label="10"]; - n_4 [id="1", shape=circle, label="1"]; - n_0 -> n_4 [arrowhead=none]; - n_5 [id="9", shape=circle, label="9"]; - n_6 [id="2", shape=circle, label="2"]; - n_7 [id="8", shape=circle, label="8"]; - n_8 [id="4", shape=circle, label="4"]; - n_9 [id="7", shape=circle, label="7"]; - n_10 [id="3", shape=circle, label="3"]; - - n_8 -> n_1 [id="[$e|3]", label="a_0→b_0:v2"]; - n_4 -> n_6 [id="[$e|0]", label="mainΔa_0"]; - n_9 -> n_5 [id="[$e|7]", label="b_0→c_0:v2"]; - n_8 -> n_2 [id="[$e|4]", label="a_0→c_0:v1"]; - n_1 -> n_9 [id="[$e|5]", label="a_0→c_0:v1"]; - n_6 -> n_10 [id="[$e|1]", label="mainΔb_0"]; - n_7 -> n_3 [id="[$e|8]", label="b_0→c_0:v2"]; - n_10 -> n_8 [id="[$e|2]", label="mainΔc_0"]; - n_2 -> n_7 [id="[$e|6]", label="a_0→b_0:v2"]; -} diff --git a/examples/trick/main_local_view.dot b/examples/trick/main_local_view.dot deleted file mode 100644 index f022386..0000000 --- a/examples/trick/main_local_view.dot +++ /dev/null @@ -1,13 +0,0 @@ -digraph main { - rankdir="LR"; - n_0 [label="main", shape="plaintext"]; - n_1 [id="1", shape=circle, label="1"]; - n_0 -> n_1 [arrowhead=none]; - n_2 [id="2", shape=circle, label="2"]; - n_3 [id="4", shape=doublecircle, label="4"]; - n_4 [id="3", shape=circle, label="3"]; - - n_4 -> n_3 [id="[$e|0]", label="spawn c_0"]; - n_1 -> n_2 [id="[$e|1]", label="spawn a_0"]; - n_2 -> n_4 [id="[$e|2]", label="spawn b_0"]; -} diff --git a/examples/violation/incrementer_local_view.dot b/examples/violation/incrementer_local_view.dot deleted file mode 100644 index 59f0f67..0000000 --- a/examples/violation/incrementer_local_view.dot +++ /dev/null @@ -1,19 +0,0 @@ -digraph incrementer { - rankdir="LR"; - n_0 [label="incrementer", shape="plaintext"]; - n_1 [id="5", shape=circle, label="6"]; - n_2 [id="6", shape=circle, label="2"]; - n_3 [id="1", shape=circle, label="1"]; - n_0 -> n_3 [arrowhead=none]; - n_4 [id="2", shape=circle, label="4"]; - n_5 [id="4", shape=doublecircle, label="7"]; - n_6 [id="7", shape=circle, label="3"]; - n_7 [id="3", shape=circle, label="5"]; - - n_7 -> n_1 [id="[$e|0]", label="send {write,write} to varManager_0"]; - n_2 -> n_6 [id="[$e|4]", label="receive answer"]; - n_1 -> n_5 [id="[$e|2]", label="send {release} to meManager_0"]; - n_6 -> n_4 [id="[$e|1]", label="send {read,pid_self} to varManager_0"]; - n_4 -> n_7 [id="[$e|3]", label="receive X"]; - n_3 -> n_2 [id="[$e|5]", label="send {request,pid_self} to meManager_0"]; -} diff --git a/examples/violation/main_global_view.dot b/examples/violation/main_global_view.dot deleted file mode 100644 index afeb962..0000000 --- a/examples/violation/main_global_view.dot +++ /dev/null @@ -1,271 +0,0 @@ -digraph global { - rankdir="LR"; - n_0 [label="global", shape="plaintext"]; - n_1 [id="33", shape=circle, label="33"]; - n_2 [id="34", shape=circle, label="34"]; - n_3 [id="20", shape=circle, label="20"]; - n_4 [id="58", shape=circle, label="58"]; - n_5 [id="119", shape=circle, label="119"]; - n_6 [id="129", shape=circle, label="129"]; - n_7 [id="57", shape=circle, label="57"]; - n_8 [id="98", shape=circle, label="98"]; - n_9 [id="91", shape=circle, label="91"]; - n_10 [id="78", shape=circle, label="78"]; - n_11 [id="102", shape=circle, label="102"]; - n_12 [id="27", shape=circle, label="27"]; - n_13 [id="118", shape=circle, label="118"]; - n_14 [id="114", shape=circle, label="114"]; - n_15 [id="89", shape=circle, label="89"]; - n_16 [id="47", shape=circle, label="47"]; - n_17 [id="29", shape=circle, label="29"]; - n_18 [id="23", shape=circle, label="23"]; - n_19 [id="110", shape=circle, label="110"]; - n_20 [id="72", shape=circle, label="72"]; - n_21 [id="122", shape=circle, label="122"]; - n_22 [id="55", shape=circle, label="55"]; - n_23 [id="82", shape=circle, label="82"]; - n_24 [id="117", shape=circle, label="117"]; - n_25 [id="25", shape=circle, label="25"]; - n_26 [id="120", shape=circle, label="120"]; - n_27 [id="68", shape=circle, label="68"]; - n_28 [id="83", shape=circle, label="83"]; - n_29 [id="36", shape=circle, label="36"]; - n_30 [id="94", shape=circle, label="94"]; - n_31 [id="84", shape=circle, label="84"]; - n_32 [id="5", shape=circle, label="5"]; - n_33 [id="81", shape=circle, label="81"]; - n_34 [id="74", shape=circle, label="74"]; - n_35 [id="92", shape=circle, label="92"]; - n_36 [id="63", shape=circle, label="63"]; - n_37 [id="28", shape=circle, label="28"]; - n_38 [id="64", shape=circle, label="64"]; - n_39 [id="86", shape=circle, label="86"]; - n_40 [id="15", shape=circle, label="15"]; - n_41 [id="87", shape=circle, label="87"]; - n_42 [id="42", shape=circle, label="42"]; - n_43 [id="19", shape=circle, label="19"]; - n_44 [id="12", shape=circle, label="12"]; - n_45 [id="11", shape=circle, label="11"]; - n_46 [id="116", shape=circle, label="116"]; - n_47 [id="112", shape=circle, label="112"]; - n_48 [id="99", shape=circle, label="99"]; - n_49 [id="17", shape=circle, label="17"]; - n_50 [id="53", shape=circle, label="53"]; - n_51 [id="50", shape=circle, label="50"]; - n_52 [id="62", shape=circle, label="62"]; - n_53 [id="67", shape=circle, label="67"]; - n_54 [id="54", shape=circle, label="54"]; - n_55 [id="18", shape=circle, label="18"]; - n_56 [id="61", shape=circle, label="61"]; - n_57 [id="113", shape=circle, label="113"]; - n_58 [id="37", shape=circle, label="37"]; - n_59 [id="80", shape=circle, label="80"]; - n_60 [id="51", shape=circle, label="51"]; - n_61 [id="14", shape=circle, label="14"]; - n_62 [id="66", shape=circle, label="66"]; - n_63 [id="93", shape=circle, label="93"]; - n_64 [id="132", shape=circle, label="132"]; - n_65 [id="100", shape=circle, label="100"]; - n_66 [id="6", shape=circle, label="6"]; - n_67 [id="126", shape=circle, label="126"]; - n_68 [id="38", shape=circle, label="38"]; - n_69 [id="13", shape=circle, label="13"]; - n_70 [id="24", shape=circle, label="24"]; - n_71 [id="10", shape=circle, label="10"]; - n_72 [id="79", shape=circle, label="79"]; - n_73 [id="43", shape=circle, label="43"]; - n_74 [id="30", shape=circle, label="30"]; - n_75 [id="71", shape=circle, label="71"]; - n_76 [id="59", shape=circle, label="59"]; - n_77 [id="40", shape=circle, label="40"]; - n_78 [id="22", shape=circle, label="22"]; - n_79 [id="105", shape=circle, label="105"]; - n_80 [id="106", shape=circle, label="106"]; - n_81 [id="101", shape=circle, label="101"]; - n_82 [id="65", shape=circle, label="65"]; - n_83 [id="73", shape=circle, label="73"]; - n_84 [id="131", shape=circle, label="131"]; - n_85 [id="39", shape=circle, label="39"]; - n_86 [id="123", shape=circle, label="123"]; - n_87 [id="108", shape=circle, label="108"]; - n_88 [id="60", shape=circle, label="60"]; - n_89 [id="1", shape=circle, label="1"]; - n_0 -> n_89 [arrowhead=none]; - n_90 [id="115", shape=circle, label="115"]; - n_91 [id="45", shape=circle, label="45"]; - n_92 [id="26", shape=circle, label="26"]; - n_93 [id="133", shape=circle, label="133"]; - n_94 [id="76", shape=circle, label="76"]; - n_95 [id="9", shape=circle, label="9"]; - n_96 [id="2", shape=circle, label="2"]; - n_97 [id="104", shape=circle, label="104"]; - n_98 [id="97", shape=circle, label="97"]; - n_99 [id="21", shape=circle, label="21"]; - n_100 [id="127", shape=circle, label="127"]; - n_101 [id="107", shape=circle, label="107"]; - n_102 [id="44", shape=circle, label="44"]; - n_103 [id="69", shape=circle, label="69"]; - n_104 [id="46", shape=circle, label="46"]; - n_105 [id="95", shape=circle, label="95"]; - n_106 [id="77", shape=circle, label="77"]; - n_107 [id="8", shape=circle, label="8"]; - n_108 [id="96", shape=circle, label="96"]; - n_109 [id="124", shape=circle, label="124"]; - n_110 [id="48", shape=circle, label="48"]; - n_111 [id="88", shape=circle, label="88"]; - n_112 [id="109", shape=circle, label="109"]; - n_113 [id="130", shape=circle, label="130"]; - n_114 [id="103", shape=circle, label="103"]; - n_115 [id="128", shape=circle, label="128"]; - n_116 [id="4", shape=circle, label="4"]; - n_117 [id="70", shape=circle, label="70"]; - n_118 [id="35", shape=circle, label="35"]; - n_119 [id="121", shape=circle, label="121"]; - n_120 [id="31", shape=circle, label="31"]; - n_121 [id="32", shape=circle, label="32"]; - n_122 [id="85", shape=circle, label="85"]; - n_123 [id="41", shape=circle, label="41"]; - n_124 [id="7", shape=circle, label="7"]; - n_125 [id="90", shape=circle, label="90"]; - n_126 [id="75", shape=circle, label="75"]; - n_127 [id="3", shape=circle, label="3"]; - n_128 [id="52", shape=circle, label="52"]; - n_129 [id="56", shape=circle, label="56"]; - n_130 [id="125", shape=circle, label="125"]; - n_131 [id="49", shape=circle, label="49"]; - n_132 [id="111", shape=circle, label="111"]; - n_133 [id="16", shape=circle, label="16"]; - - n_68 -> n_131 [id="[$e|47]", label="incrementer_0→varManager_0:{read,pid_self}"]; - n_70 -> n_121 [id="[$e|30]", label="meManager_0→incrementer_1:answer"]; - n_44 -> n_61 [id="[$e|12]", label="incrementer_0→meManager_0:{release}"]; - n_54 -> n_75 [id="[$e|69]", label="incrementer_1→varManager_0:{write,write}"]; - n_131 -> n_36 [id="[$e|61]", label="varManager_0→incrementer_0:any"]; - n_73 -> n_22 [id="[$e|53]", label="varManager_0→incrementer_1:any"]; - n_2 -> n_91 [id="[$e|43]", label="varManager_0→incrementer_1:any"]; - n_118 -> n_104 [id="[$e|44]", label="incrementer_1→varManager_0:{read,pid_self}"]; - n_37 -> n_58 [id="[$e|35]", label="meManager_0→incrementer_0:answer"]; - n_120 -> n_123 [id="[$e|39]", label="meManager_0→incrementer_0:answer"]; - n_12 -> n_29 [id="[$e|34]", label="meManager_0→incrementer_1:answer"]; - n_61 -> n_43 [id="[$e|17]", label="incrementer_0→varManager_0:{write,write}"]; - n_41 -> n_5 [id="[$e|117]", label="incrementer_0→meManager_0:{release}"]; - n_89 -> n_96 [id="[$e|0]", label="mainΔmeManager_0"]; - n_20 -> n_97 [id="[$e|102]", label="incrementer_1→varManager_0:{write,write}"]; - n_36 -> n_15 [id="[$e|87]", label="incrementer_0→varManager_0:{write,write}"]; - n_18 -> n_120 [id="[$e|29]", label="incrementer_0→meManager_0:{request,pid_self}"]; - n_32 -> n_66 [id="[$e|4]", label="incrementer_0→meManager_0:{request,pid_self}"]; - n_51 -> n_38 [id="[$e|62]", label="varManager_0→incrementer_0:any"]; - n_65 -> n_64 [id="[$e|130]", label="incrementer_0→varManager_0:{write,write}"]; - n_92 -> n_118 [id="[$e|33]", label="meManager_0→incrementer_1:answer"]; - n_75 -> n_114 [id="[$e|101]", label="incrementer_1→meManager_0:{release}"]; - n_127 -> n_116 [id="[$e|2]", label="mainΔincrementer_0"]; - n_49 -> n_18 [id="[$e|21]", label="incrementer_1→meManager_0:{release}"]; - n_105 -> n_100 [id="[$e|125]", label="incrementer_0→meManager_0:{release}"]; - n_85 -> n_51 [id="[$e|48]", label="incrementer_1→varManager_0:{write,write}"]; - n_85 -> n_60 [id="[$e|49]", label="varManager_0→incrementer_0:any"]; - n_3 -> n_12 [id="[$e|25]", label="incrementer_1→meManager_0:{request,pid_self}"]; - n_125 -> n_21 [id="[$e|120]", label="incrementer_0→varManager_0:{write,write}"]; - n_48 -> n_84 [id="[$e|129]", label="incrementer_0→meManager_0:{release}"]; - n_53 -> n_108 [id="[$e|94]", label="incrementer_0→meManager_0:{release}"]; - n_42 -> n_54 [id="[$e|52]", label="varManager_0→incrementer_1:any"]; - n_74 -> n_77 [id="[$e|38]", label="meManager_0→incrementer_0:answer"]; - n_52 -> n_39 [id="[$e|84]", label="incrementer_0→meManager_0:{release}"]; - n_72 -> n_132 [id="[$e|109]", label="incrementer_1→meManager_0:{release}"]; - n_88 -> n_23 [id="[$e|80]", label="incrementer_1→meManager_0:{release}"]; - n_66 -> n_107 [id="[$e|6]", label="meManager_0→incrementer_0:answer"]; - n_7 -> n_106 [id="[$e|75]", label="incrementer_1→varManager_0:{write,write}"]; - n_94 -> n_87 [id="[$e|106]", label="incrementer_1→varManager_0:{write,write}"]; - n_38 -> n_9 [id="[$e|89]", label="incrementer_0→varManager_0:{write,write}"]; - n_60 -> n_53 [id="[$e|65]", label="incrementer_0→varManager_0:{write,write}"]; - n_78 -> n_74 [id="[$e|28]", label="incrementer_0→meManager_0:{request,pid_self}"]; - n_99 -> n_17 [id="[$e|27]", label="meManager_0→incrementer_0:answer"]; - n_124 -> n_95 [id="[$e|7]", label="meManager_0→incrementer_1:answer"]; - n_133 -> n_99 [id="[$e|19]", label="incrementer_0→meManager_0:{request,pid_self}"]; - n_38 -> n_125 [id="[$e|88]", label="incrementer_0→meManager_0:{release}"]; - n_54 -> n_117 [id="[$e|68]", label="incrementer_1→meManager_0:{release}"]; - n_16 -> n_56 [id="[$e|59]", label="varManager_0→incrementer_1:any"]; - n_96 -> n_127 [id="[$e|1]", label="mainΔvarManager_0"]; - n_17 -> n_85 [id="[$e|37]", label="incrementer_0→varManager_0:{read,pid_self}"]; - n_77 -> n_128 [id="[$e|50]", label="incrementer_0→varManager_0:{read,pid_self}"]; - n_1 -> n_73 [id="[$e|41]", label="incrementer_1→varManager_0:{read,pid_self}"]; - n_62 -> n_105 [id="[$e|93]", label="incrementer_0→varManager_0:{write,write}"]; - n_29 -> n_16 [id="[$e|45]", label="incrementer_1→varManager_0:{read,pid_self}"]; - n_111 -> n_26 [id="[$e|118]", label="incrementer_0→varManager_0:{write,write}"]; - n_129 -> n_126 [id="[$e|73]", label="incrementer_1→varManager_0:{write,write}"]; - n_116 -> n_32 [id="[$e|3]", label="mainΔincrementer_1"]; - n_122 -> n_24 [id="[$e|115]", label="incrementer_1→meManager_0:{release}"]; - n_117 -> n_11 [id="[$e|100]", label="incrementer_1→varManager_0:{write,write}"]; - n_102 -> n_129 [id="[$e|54]", label="varManager_0→incrementer_1:any"]; - n_35 -> n_109 [id="[$e|122]", label="incrementer_0→varManager_0:{write,write}"]; - n_82 -> n_35 [id="[$e|90]", label="incrementer_1→varManager_0:{write,write}"]; - n_27 -> n_48 [id="[$e|97]", label="incrementer_0→varManager_0:{write,write}"]; - n_95 -> n_45 [id="[$e|9]", label="incrementer_1→varManager_0:{read,pid_self}"]; - n_103 -> n_81 [id="[$e|99]", label="incrementer_0→varManager_0:{write,write}"]; - n_59 -> n_47 [id="[$e|110]", label="incrementer_0→varManager_0:{write,write}"]; - n_31 -> n_46 [id="[$e|114]", label="incrementer_1→varManager_0:{write,write}"]; - n_110 -> n_52 [id="[$e|60]", label="varManager_0→incrementer_0:any"]; - n_15 -> n_119 [id="[$e|119]", label="incrementer_0→meManager_0:{release}"]; - n_62 -> n_30 [id="[$e|92]", label="incrementer_0→meManager_0:{release}"]; - n_36 -> n_111 [id="[$e|86]", label="incrementer_0→meManager_0:{release}"]; - n_63 -> n_130 [id="[$e|123]", label="incrementer_1→varManager_0:{write,write}"]; - n_107 -> n_71 [id="[$e|8]", label="incrementer_0→varManager_0:{read,pid_self}"]; - n_23 -> n_14 [id="[$e|112]", label="incrementer_1→varManager_0:{write,write}"]; - n_10 -> n_19 [id="[$e|108]", label="incrementer_1→varManager_0:{write,write}"]; - n_8 -> n_113 [id="[$e|128]", label="incrementer_0→varManager_0:{write,write}"]; - n_53 -> n_98 [id="[$e|95]", label="incrementer_1→varManager_0:{write,write}"]; - n_7 -> n_94 [id="[$e|74]", label="incrementer_0→varManager_0:{write,write}"]; - n_22 -> n_20 [id="[$e|70]", label="incrementer_1→meManager_0:{release}"]; - n_126 -> n_101 [id="[$e|105]", label="incrementer_1→meManager_0:{release}"]; - n_76 -> n_33 [id="[$e|79]", label="incrementer_0→varManager_0:{write,write}"]; - n_4 -> n_10 [id="[$e|76]", label="incrementer_1→meManager_0:{release}"]; - n_121 -> n_42 [id="[$e|40]", label="incrementer_1→varManager_0:{read,pid_self}"]; - n_17 -> n_68 [id="[$e|36]", label="incrementer_1→varManager_0:{write,write}"]; - n_55 -> n_70 [id="[$e|22]", label="incrementer_0→varManager_0:{write,write}"]; - n_25 -> n_1 [id="[$e|31]", label="incrementer_0→varManager_0:{write,write}"]; - n_56 -> n_31 [id="[$e|82]", label="incrementer_1→meManager_0:{release}"]; - n_69 -> n_49 [id="[$e|15]", label="incrementer_1→varManager_0:{write,write}"]; - n_83 -> n_79 [id="[$e|103]", label="incrementer_1→meManager_0:{release}"]; - n_58 -> n_110 [id="[$e|46]", label="incrementer_0→varManager_0:{read,pid_self}"]; - n_103 -> n_65 [id="[$e|98]", label="incrementer_0→meManager_0:{release}"]; - n_91 -> n_4 [id="[$e|56]", label="incrementer_0→varManager_0:{write,write}"]; - n_2 -> n_102 [id="[$e|42]", label="incrementer_0→varManager_0:{write,write}"]; - n_28 -> n_90 [id="[$e|113]", label="incrementer_1→meManager_0:{release}"]; - n_44 -> n_40 [id="[$e|13]", label="incrementer_0→varManager_0:{write,write}"]; - n_56 -> n_122 [id="[$e|83]", label="incrementer_1→varManager_0:{write,write}"]; - n_32 -> n_124 [id="[$e|5]", label="incrementer_1→meManager_0:{request,pid_self}"]; - n_52 -> n_41 [id="[$e|85]", label="incrementer_0→varManager_0:{write,write}"]; - n_22 -> n_83 [id="[$e|71]", label="incrementer_1→varManager_0:{write,write}"]; - n_91 -> n_7 [id="[$e|55]", label="incrementer_1→meManager_0:{release}"]; - n_34 -> n_80 [id="[$e|104]", label="incrementer_1→varManager_0:{write,write}"]; - n_39 -> n_13 [id="[$e|116]", label="incrementer_0→varManager_0:{write,write}"]; - n_60 -> n_62 [id="[$e|64]", label="incrementer_1→varManager_0:{write,write}"]; - n_123 -> n_50 [id="[$e|51]", label="incrementer_0→varManager_0:{read,pid_self}"]; - n_45 -> n_69 [id="[$e|11]", label="varManager_0→incrementer_1:any"]; - n_76 -> n_59 [id="[$e|78]", label="incrementer_1→meManager_0:{release}"]; - n_50 -> n_103 [id="[$e|67]", label="varManager_0→incrementer_0:any"]; - n_82 -> n_63 [id="[$e|91]", label="incrementer_0→varManager_0:{write,write}"]; - n_71 -> n_44 [id="[$e|10]", label="varManager_0→incrementer_0:any"]; - n_25 -> n_2 [id="[$e|32]", label="incrementer_1→varManager_0:{read,pid_self}"]; - n_99 -> n_37 [id="[$e|26]", label="incrementer_1→varManager_0:{write,write}"]; - n_129 -> n_34 [id="[$e|72]", label="incrementer_1→meManager_0:{release}"]; - n_30 -> n_67 [id="[$e|124]", label="incrementer_0→varManager_0:{write,write}"]; - n_4 -> n_72 [id="[$e|77]", label="incrementer_1→varManager_0:{write,write}"]; - n_108 -> n_115 [id="[$e|126]", label="incrementer_1→varManager_0:{write,write}"]; - n_40 -> n_3 [id="[$e|18]", label="incrementer_0→meManager_0:{release}"]; - n_61 -> n_55 [id="[$e|16]", label="incrementer_1→meManager_0:{request,pid_self}"]; - n_133 -> n_78 [id="[$e|20]", label="incrementer_1→varManager_0:{write,write}"]; - n_27 -> n_8 [id="[$e|96]", label="incrementer_0→meManager_0:{release}"]; - n_106 -> n_112 [id="[$e|107]", label="incrementer_0→varManager_0:{write,write}"]; - n_88 -> n_28 [id="[$e|81]", label="incrementer_1→varManager_0:{write,write}"]; - n_55 -> n_25 [id="[$e|23]", label="meManager_0→incrementer_1:answer"]; - n_91 -> n_76 [id="[$e|57]", label="incrementer_1→varManager_0:{write,write}"]; - n_9 -> n_86 [id="[$e|121]", label="incrementer_0→meManager_0:{release}"]; - n_43 -> n_92 [id="[$e|24]", label="incrementer_1→meManager_0:{request,pid_self}"]; - n_81 -> n_93 [id="[$e|131]", label="incrementer_0→meManager_0:{release}"]; - n_128 -> n_27 [id="[$e|66]", label="varManager_0→incrementer_0:any"]; - n_33 -> n_57 [id="[$e|111]", label="incrementer_1→meManager_0:{release}"]; - n_104 -> n_88 [id="[$e|58]", label="varManager_0→incrementer_1:any"]; - n_69 -> n_133 [id="[$e|14]", label="incrementer_1→meManager_0:{release}"]; - n_60 -> n_82 [id="[$e|63]", label="incrementer_0→meManager_0:{release}"]; - n_98 -> n_6 [id="[$e|127]", label="incrementer_0→meManager_0:{release}"]; -} diff --git a/examples/violation/main_local_view.dot b/examples/violation/main_local_view.dot deleted file mode 100644 index 45c8a86..0000000 --- a/examples/violation/main_local_view.dot +++ /dev/null @@ -1,15 +0,0 @@ -digraph main { - rankdir="LR"; - n_0 [label="main", shape="plaintext"]; - n_1 [id="5", shape=circle, label="4"]; - n_2 [id="1", shape=circle, label="1"]; - n_0 -> n_2 [arrowhead=none]; - n_3 [id="2", shape=circle, label="2"]; - n_4 [id="4", shape=doublecircle, label="5"]; - n_5 [id="3", shape=circle, label="3"]; - - n_1 -> n_4 [id="[$e|0]", label="spawn incrementer_1"]; - n_2 -> n_3 [id="[$e|2]", label="spawn meManager_0"]; - n_3 -> n_5 [id="[$e|1]", label="spawn varManager_0"]; - n_5 -> n_1 [id="[$e|3]", label="spawn incrementer_0"]; -} diff --git a/examples/violation/meManager_local_view.dot b/examples/violation/meManager_local_view.dot deleted file mode 100644 index 70ae78b..0000000 --- a/examples/violation/meManager_local_view.dot +++ /dev/null @@ -1,12 +0,0 @@ -digraph meManager { - rankdir="LR"; - n_0 [label="meManager", shape="plaintext"]; - n_1 [id="1", shape=circle, label="1"]; - n_0 -> n_1 [arrowhead=none]; - n_2 [id="2", shape=circle, label="2"]; - n_3 [id="3", shape=circle, label="3"]; - - n_3 -> n_1 [id="[$e|4]", label="receive {release}"]; - n_2 -> n_3 [id="[$e|2]", label="send answer to Pid"]; - n_1 -> n_2 [id="[$e|1]", label="receive {request,Pid}"]; -} diff --git a/examples/violation/varManager_local_view.dot b/examples/violation/varManager_local_view.dot deleted file mode 100644 index fbae762..0000000 --- a/examples/violation/varManager_local_view.dot +++ /dev/null @@ -1,11 +0,0 @@ -digraph varManager { - rankdir="LR"; - n_0 [label="varManager", shape="plaintext"]; - n_1 [id="1", shape=circle, label="1"]; - n_0 -> n_1 [arrowhead=none]; - n_2 [id="3", shape=circle, label="2"]; - - n_2 -> n_1 [id="[$e|7]", label="send any to Pid"]; - n_1 -> n_1 [id="[$e|8]", label="receive {write,NewVal}"]; - n_1 -> n_2 [id="[$e|5]", label="receive {read,Pid}"]; -} diff --git a/src/choreography/actor_emul.erl b/src/choreography/actor_emul.erl index ec3dd7a..269f4bb 100644 --- a/src/choreography/actor_emul.erl +++ b/src/choreography/actor_emul.erl @@ -42,9 +42,9 @@ send_recv(P, Data) -> end. proc_loop(Data) -> - ProcName = Data#actor_info.proc_id, + ProcName = Data#actor_info.fun_name, % io:fwrite("[EMUL] ID ~p~n", [ProcName]), - LV = share:get_localview(share:atol(ProcName)), + LV = share:get_localview(ProcName), G = LV#wip_lv.graph, % timer:sleep(200), VCurr = Data#actor_info.current_state, @@ -60,10 +60,14 @@ proc_loop(Data) -> {E, VCurr, VNew, _} when IsAlreadyMarkedOnce -> {_, FromLabel} = digraph:vertex(G, VCurr), {_, ToLabel} = digraph:vertex(G, VNew), + To = share:if_final_get_n(ToLabel), + From = share:if_final_get_n(FromLabel), NewL = - case ToLabel =< FromLabel of + case To =< From of true -> - % io:fwrite("[EMUL] RESET LOCALV IN ~p~n", [ProcName]), + % io:fwrite("[EMUL] RESET LOCALV IN ~p from ~p to ~p~n", [ + % ProcName, FromLabel, ToLabel + % ]), sets:new(); false -> LocalVars @@ -76,10 +80,14 @@ proc_loop(Data) -> {E, VCurr, VNew, _} -> {_, FromLabel} = digraph:vertex(G, VCurr), {_, ToLabel} = digraph:vertex(G, VNew), + To = share:if_final_get_n(ToLabel), + From = share:if_final_get_n(FromLabel), NewL = - case ToLabel =< FromLabel of + case To =< From of true -> - % io:fwrite("[EMUL] RESET LOCALV IN ~p~n", [ProcName]), + % io:fwrite("[EMUL] RESET LOCALV IN ~p from ~p to ~p~n", [ + % ProcName, FromLabel, ToLabel + % ]), sets:new(); false -> LocalVars diff --git a/src/choreography/eval.erl b/src/choreography/eval.erl index eff2a67..fa30187 100644 --- a/src/choreography/eval.erl +++ b/src/choreography/eval.erl @@ -25,16 +25,19 @@ %%%=================================================================== function_list(ContList, Data) -> - lists:foreach( - fun(FunctionBody) -> + lists:foldl( + fun(FunctionBody, AccData) -> case FunctionBody of - {clause, _, Vars, Guard, Content} -> clause(Content, Vars, Guard, Data, "arg"); - C -> share:warning("should be a clause but it's", C, ?UNDEFINED) + {clause, _, Vars, Guard, Content} -> + ets:insert(?ARGUMENTS, {Data#wip_lv.fun_name, Vars}), + clause(Content, Vars, Guard, AccData#wip_lv{last_vertex = 1}, "arg"); + C -> + share:warning("should be a clause but it's", C, ?UNDEFINED) end end, + Data, ContList - ), - Data. + ). clause(Code, Vars, Guards, Data, BaseLabel) -> % io:fwrite("[CLAUSE] Code ~p~n Vars ~p~n Guards ~p~n", [Code, Vars, Guards]), @@ -44,7 +47,7 @@ clause(Code, Vars, Guards, Data, BaseLabel) -> EvalVarList = TempData#wip_lv.ret_var, TempLabel = BaseLabel ++ " " ++ var_to_string(EvalVarList) ++ guards_to_string(Guards), FinalLabel = decide_label(BaseLabel, TempLabel, Data), - NewData = share:add_vertex_edge(FinalLabel, Data), + NewData = add_vertex_edge(FinalLabel, Data), lists:foldl( fun(Line, AccData) -> lv:eval_codeline(Line, AccData) end, NewData#wip_lv{local_vars = LocalV ++ EvalVarList#variable.value}, @@ -89,7 +92,7 @@ anon_fun(Content, Line, Data) -> case Content of {clauses, A} -> Id = "anonfun_" ++ integer_to_list(Line), - ets:insert(?FUNAST, {share:ltoa(Id), A}), + ets:insert(?FUNAST, {Id, {function, Line, A}}), simple_type(function, Id, Data); _ -> share:warning("not recognized content in anon_fun", Content, Data) @@ -237,45 +240,38 @@ spawn_one(Content, Data) -> NewData = lv:eval_codeline(Content, Data), VarFound = NewData#wip_lv.ret_var, Id = VarFound#variable.value, - lv:create_save_localview(share:ltoa(Id), Data#wip_lv.settings), - C = inc_spawn_counter(Id), - S = Id ++ "_" ++ integer_to_list(C), - RetData = share:add_vertex_edge("spawn " ++ S, NewData), + lv:create_localview(Id, Data#wip_lv.settings, true), + C = share:inc_spawn_counter(Id), + S = Id ++ ?SEPARATOR ++ integer_to_list(C), + RetData = add_vertex_edge("spawn " ++ S, NewData), RetVar = #variable{type = pid, value = S}, RetData#wip_lv{ret_var = RetVar}. spawn_three(Name, ArgList, Data) -> NewData = lv:eval_codeline(ArgList, Data), - EM = NewData#wip_lv.edge_map, NewDataRetVar = NewData#wip_lv.ret_var, {Label, ProcId} = format_spawn_label(Name, NewDataRetVar), - ND = NewData#wip_lv{edge_map = maps:put(Label, NewDataRetVar, EM)}, - RetData = share:add_vertex_edge(Label, ND), + EM = maps:put(Label, NewDataRetVar, NewData#wip_lv.edge_map), + % io:fwrite("label ~p new edge map ~p map ~p~n", [Label, NewData#wip_lv.fun_name, EM]), + ND = NewData#wip_lv{edge_map = EM}, + RetData = add_vertex_edge(Label, ND), RetData#wip_lv{ret_var = #variable{type = pid, value = ProcId}}. format_spawn_label(Name, NewDataRetVar) -> - C = inc_spawn_counter(Name), + C = share:inc_spawn_counter(Name), Arity = integer_to_list(length(NewDataRetVar#variable.value)), - ProcId = share:atol(Name) ++ Arity ++ "_" ++ integer_to_list(C), + ProcId = share:atol(Name) ++ Arity ++ ?SEPARATOR ++ integer_to_list(C), {"spawn " ++ ProcId, ProcId}. spawn_monitor_call(ArgList, Data) -> share:warning("spawn_monitor not yet implemted. Arguments =", ArgList, Data). -inc_spawn_counter(Name) -> - case ets:lookup(?SPAWNC, share:ltoa(Name)) of - [] -> - ets:insert(?SPAWNC, {Name, 1}), - 0; - [{_, N}] -> - ets:insert(?SPAWNC, {Name, N + 1}), - N - end. - self_call(Data) -> - RetVar = #variable{type = pid_self, value = share:atol(Data#wip_lv.fun_name)}, + RetVar = #variable{type = pid, value = "pid_self"}, Data#wip_lv{ret_var = RetVar}. +%%% TODO: now the register function is implemented with a static behaviour, +%%% but should be dynamic. register_call(ArgList, Data) -> [{atom, _, AtomName}, {var, _, VarName}] = ArgList, VarFound = share:find_var(Data, VarName), @@ -283,16 +279,17 @@ register_call(ArgList, Data) -> not_found -> ?UNDEFINED; V -> - case V#variable.type == pid of - false -> ?UNDEFINED; - true -> ets:insert(?REGISTERDB, {AtomName, V#variable.value}) + case V#variable.type of + pid -> ets:insert(?REGISTERDB, {AtomName, V#variable.value}); + _ -> ?UNDEFINED end end, - %%% Approx: ignoring returing value + %%% ignoring returing value Data. generic_call(Name, ArgList, Data) -> - NewData = lv:eval_codeline(ArgList, Data), + % TODO: how to evaluate argument list? + _NewData = lv:eval_codeline(ArgList, Data), % io:fwrite("ARG LIST ~p~n", [ArgList]), % io:fwrite("RET VAR ~p~n", [NewData#wip_lv.ret_var#variable.value]), NameString = share:merge_fun_ar(Name, length(ArgList)), @@ -320,7 +317,7 @@ call_by_var(VarName, ArgList, Data) -> _ -> Id = VarFound#variable.value, ND = lv:eval_codeline(ArgList, Data), - NewData = lv:create_localview(share:ltoa(Id), ND#wip_lv.settings, false), + NewData = lv:create_localview(Id, ND#wip_lv.settings, false), NewG = NewData#wip_lv.graph, NewRet = NewData#wip_lv.ret_var, NewLastV = merge_graph(G, NewG, VLast), @@ -345,16 +342,27 @@ rand_package(FunName, Data) -> send(Destination, MessageContent, Data) -> TempData = lv:eval_codeline(Destination, Data), - ProcName = get_pid(TempData#wip_lv.ret_var), + VarProcName = TempData#wip_lv.ret_var, + ProcName = get_pid(VarProcName), + % io:fwrite("Ret Var ~p found ~p~n", [VarProcName, ProcName]), NewData = lv:eval_codeline(MessageContent, TempData), - DataSent = var_to_string(NewData#wip_lv.ret_var), - SLabel = "send " ++ DataSent ++ " to " ++ ProcName, - share:add_vertex_edge(SLabel, NewData). + VarDataSent = NewData#wip_lv.ret_var, + DataSent = var_to_string(VarDataSent), + SLabel = "send " ++ share:atol(DataSent) ++ " to " ++ share:atol(ProcName), + EM = NewData#wip_lv.edge_map, + add_vertex_edge(SLabel, NewData#wip_lv{ + edge_map = maps:put(SLabel, {VarProcName, VarDataSent}, EM) + }). get_pid(Var) -> - case Var#variable.type == pid of - true -> Var#variable.value; - false -> share:atol(Var#variable.name) + case Var#variable.type of + pid -> + Var#variable.value; + _ -> + case Var#variable.name of + ?UNDEFINED -> Var#variable.type; + _ -> share:atol(Var#variable.name) + end end. var_to_string(Var) -> @@ -378,8 +386,8 @@ var_to_string(Var) -> "atom" -> share:atol(Val); "list" -> format_list(Val, fun var_to_string/1); "tuple" -> format_tuple(Val, fun var_to_string/1); - "pid" -> "pid" ++ "_" ++ share:atol(V#variable.value); - S -> S + "pid" -> share:atol(V#variable.value); + S -> share:atol(S) end end end @@ -462,6 +470,13 @@ explore_pm(PMList, Base, Data) -> PMList ). +add_vertex_edge(Label, Data) -> + G = Data#wip_lv.graph, + LastV = Data#wip_lv.last_vertex, + V = share:add_vertex(G), + digraph:add_edge(G, LastV, V, Label), + Data#wip_lv{last_vertex = V}. + %%% Convert the guard (ast format) to a string guards_to_string(GlobalToVal) -> case GlobalToVal of diff --git a/src/choreography/gv.erl b/src/choreography/gv.erl index b90a7b6..42d1051 100644 --- a/src/choreography/gv.erl +++ b/src/choreography/gv.erl @@ -10,12 +10,13 @@ %%% Generate the glabal view from an entrypoint and save it in a specified folder generate(Settings, EntryPoint) -> - MainGraph = share:get_localview(share:atol(EntryPoint)), + MainGraph = share:get_localview(EntryPoint), case MainGraph of not_found -> io:fwrite("Error: entrypoint for global view not found ~p~n", [EntryPoint]), error; _ -> + % io:fwrite("Creating the globalview starting from ~p~n", [EntryPoint]), G = create_globalview(EntryPoint), share:save_graph(G, Settings, EntryPoint, global), finished @@ -29,8 +30,10 @@ generate(Settings, EntryPoint) -> create_globalview(Name) -> RetG = digraph:new(), VNew = share:add_vertex(RetG), - MainProcPid = spawn(actor_emul, proc_loop, [#actor_info{proc_id = Name}]), - ProcPidMap = #{Name => MainProcPid}, + N = share:inc_spawn_counter(Name), + MainProcPid = spawn(actor_emul, proc_loop, [#actor_info{fun_name = Name, id = N}]), + PidKey = share:atol(Name) ++ ?SEPARATOR ++ integer_to_list(N), + ProcPidMap = #{ltoa(PidKey) => MainProcPid}, % initialize first branch progress_procs(RetG, [new_branch(RetG, VNew, ProcPidMap)]). @@ -51,10 +54,10 @@ progress_procs(G, []) -> G; progress_procs(GlobalGraph, BranchList) when is_list(BranchList) -> RealList = lists:flatten(BranchList), - io:fwrite("Branch to eval ~p~n", [length(RealList)]), + % io:fwrite("Branch to eval ~p~n", [length(RealList)]), NewBL = lists:foldl( fun(Item, AccL) -> - io:fwrite("Eval branch~n"), + % io:fwrite("Eval branch~n"), NewBreanches = progress_single_branch(Item), AccL ++ NewBreanches end, @@ -74,7 +77,7 @@ progress_single_branch(BData) -> maps:fold( fun(Name, Pid, AccList) -> MessageQueue = actor_emul:get_proc_mess_queue(Pid), - io:fwrite("[PROGSB] Name ~p MQ ~p~n", [Name, MessageQueue]), + % io:fwrite("[PROGSB] Name ~p MQ ~p~n", [Name, MessageQueue]), gen_branch_foreach_mess(TempBranchData, MessageQueue, Name, AccList) end, [], @@ -104,12 +107,12 @@ gen_branch_foreach_mess(BranchData, MessageQueue, ProcName, BaseList) -> AccList; %%% If an edge has been found, duplicate the branch and add the transition to the graph EdgeFound -> - io:fwrite("[RECV] Mess ~p Edge choose ~p~n", [Message, EdgeFound]), + % io:fwrite("[RECV] Mess ~p Edge choose ~p~n", [Message, EdgeFound]), ProcFrom = Message#message.from, MessData = Message#message.data, PidFrom = maps:get(ProcFrom, NewMap), Label = format_send_label(ProcFrom, ProcName, MessData), - io:fwrite("~n~n[RECV] LABEL ~ts~n~n", [Label]), + % io:fwrite("~n~n[RECV] LABEL ~ts~n~n", [Label]), EFromInfo = actor_emul:get_proc_edge_info(PidFrom, Message#message.edge), EToInfo = actor_emul:get_proc_edge_info(NewPid, EdgeFound), {LastVertex, NewStateMap} = complex_add_vertex( @@ -137,8 +140,8 @@ dup_branch(Data) -> duplicate_proccess(ProcMap) -> maps:fold( fun(K, V, A) -> - Name = remove_id_from_proc(K), - NewPid = spawn(actor_emul, proc_loop, [#actor_info{proc_id = Name}]), + {Name, N} = remove_id_from_proc(K), + NewPid = spawn(actor_emul, proc_loop, [#actor_info{fun_name = Name, id = N}]), actor_emul:set_proc_data(NewPid, actor_emul:get_proc_data(V)), maps:put(K, NewPid, A) end, @@ -148,11 +151,13 @@ duplicate_proccess(ProcMap) -> %%% Remove the number from an actor's identificator remove_id_from_proc(ProcId) -> - Split = string:split(ProcId, "_"), - % io:fwrite("split ~p~n", [Split]), + Split = string:split(share:atol(ProcId), ?SEPARATOR), case Split of - [Name | _N] -> ltoa(Name); - _ -> ProcId + [Name | N] -> + {share:ltoa(Name), N}; + _ -> + io:fwrite("Error: should have an id ~p", [ProcId]), + {ProcId, 0} end. %%% Evaluate the edges of a local view until it reaches a receive edge foreach actor @@ -230,7 +235,7 @@ is_lists_edgerecv(ProcPid, EL) -> %%% Evaluate a transition from an actor eval_edge(EdgeInfo, ProcName, ProcPid, BData) -> {Edge, _, _, PLabel} = EdgeInfo, - io:fwrite("Proc ~p eval label ~p~n", [ProcName, PLabel]), + % io:fwrite("Proc ~p eval label ~p~n", [ProcName, PLabel]), SLabel = atol(PLabel), IsArg = is_substring(SLabel, "arg"), IsSpawn = is_substring(SLabel, "spawn"), @@ -254,43 +259,56 @@ is_substring(S, SubS) -> is_list(string:find(S, SubS)). %%% Add a spanw transition to the global view -add_spawn_to_global(SLabel, ProcName, Data) -> +add_spawn_to_global(SLabel, EmulProcName, Data) -> % get proc name - ProcIdS = string:prefix(SLabel, "spawn "), - FuncNameS = share:remove_last(share:remove_last(ProcIdS)), + FunSpawned = string:prefix(SLabel, "spawn "), + {FunSName, Counter} = remove_id_from_proc(FunSpawned), % spawn the actor emulator - FuncPid = spawn(actor_emul, proc_loop, [#actor_info{proc_id = ltoa(FuncNameS)}]), - NewMap = maps:put(ltoa(ProcIdS), FuncPid, Data#branch.proc_pid_m), + FuncPid = spawn(actor_emul, proc_loop, [#actor_info{fun_name = FunSName, id = Counter}]), + NewMap = maps:put(share:ltoa(FunSpawned), FuncPid, Data#branch.proc_pid_m), % get spawn arguemnt and add them to the local variables of the actor - LocalList = get_local_vars(ProcName, SLabel, FuncNameS), + LocalList = get_local_vars(EmulProcName, SLabel, FunSName), lists:foreach(fun(Var) -> actor_emul:add_proc_spawnvars(FuncPid, Var) end, LocalList), % create the edge on the global graph VNew = share:add_vertex(Data#branch.graph), %%% Δ means spawned - NewLabel = atol(ProcName) ++ "Δ" ++ ProcIdS, + NewLabel = share:atol(EmulProcName) ++ "Δ" ++ FunSpawned, digraph:add_edge(Data#branch.graph, Data#branch.last_vertex, VNew, NewLabel), {VNew, NewMap}. -get_local_vars(ProcName, Label, FuncName) -> - EM = share:get_edgedata(atol(ProcName)), - % add input data to local vars +get_local_vars(ProcId, Label, FunSName) -> + EM = share:get_edgedata(FunSName), InputData = maps:get(Label, EM, []), - io:fwrite("ProcName ~p Label ~p Input ~p~n", [ProcName, Label, EM]), + % io:fwrite("[GV] EmulProcName ~p Label ~p Input ~p~n", [ProcId, Label, EM]), + % add input data to local vars case InputData of [] -> []; _ -> - [{_, Input}] = ets:lookup(?ARGUMENTS, ltoa(FuncName)), - {LL, _} = lists:foldl( + [{_, Input}] = ets:lookup(?ARGUMENTS, FunSName), + % io:fwrite("[GV] for fun ~p found ~p~n", [atol(FuncName), Input]), + {LL, Remain} = lists:foldl( fun({var, _, Name}, {A, In}) -> case In of - [] -> {A ++ [#variable{name = Name}], []}; - [H | T] -> {A ++ [H#variable{name = Name}], T} + [] -> + io:fwrite("ERROR: list should NOT be empty but there is ~p~n", Name), + {A ++ [#variable{name = Name}], []}; + [H | T] -> + case H#variable.value of + "pid_self" -> + {A ++ [#variable{type = pid, name = Name, value = ProcId}], T}; + _ -> + {A ++ [H#variable{name = Name}], T} + end end end, {[], InputData#variable.value}, Input ), + case Remain =:= [] of + true -> done; + false -> io:fwrite("ERROR: list should be empty but there is ~p~n", Remain) + end, LL end. @@ -298,12 +316,12 @@ get_local_vars(ProcName, Label, FuncName) -> manage_send(SLabel, Data, ProcName, ProcPid, Edge) -> ProcPidMap = Data#branch.proc_pid_m, DataSent = get_data_from_label(SLabel), - ProcSentTemp = ltoa(get_proc_from_label(SLabel)), + ProcSentTemp = share:ltoa(get_proc_from_label(SLabel)), IsVar = share:is_erlvar(ProcSentTemp), ProcSentName = case IsVar of true -> check_vars(ProcPid, ProcSentTemp); - false -> ProcSentTemp + false -> share:ltoa(check_pid_self(ProcSentTemp, ProcName)) end, ProcSentPid = maps:get(ProcSentName, ProcPidMap, no_pid), case ProcSentPid of @@ -365,7 +383,7 @@ manage_recv(ProcPid, Message) -> %%% Find the actor id from a variable's list, given the variable name check_vars(ProcPid, VarName) -> ProcLocalVars = actor_emul:get_proc_localvars(ProcPid), - % io:fwrite("Find var ~p in ~p from ~p~n", [VarName, ProcLocalVars, ProcName]), + % io:fwrite("Find var ~p in ~p pid ~p~n", [VarName, ProcLocalVars, ProcPid]), VarValue = share:find_var(ProcLocalVars, VarName), case VarValue of not_found -> @@ -373,21 +391,21 @@ check_vars(ProcPid, VarName) -> V -> case V#variable.type of ?UNDEFINED -> VarName; - "pid_self" -> ltoa(V#variable.value); - pid_self -> ltoa(V#variable.value); - _ -> remove_pid_part(V#variable.type) + "pid" -> V#variable.value; + pid -> V#variable.value; + _ -> V#variable.type end end. %%% Remove the "pid_" part from a variable's type -remove_pid_part(Data) -> - ltoa(lists:flatten(string:replace(atol(Data), "pid_", ""))). +% remove_pid_part(Data) -> ltoa(lists:flatten(string:replace(atol(Data), "pid_", ""))). %%% Check if a pattern metching match a message, then register the new variables is_pm_msg_compatible(ProcPid, CallingProc, PatternMatching, Message) -> {RetBool, RegList} = check_msg_comp( ProcPid, CallingProc, PatternMatching, Message#message.data ), + % io:fwrite("Reg List ~p~n", [RegList]), lists:foreach( fun(Item) -> register_var(Item) end, RegList @@ -427,15 +445,16 @@ check_msg_comp(ProcPid, CallingProc, PatternMatching, Message) -> %%% Register a actor's variable register_var(Data) -> - {ProcPid, Name, Type} = Data, - V = #variable{name = ltoa(Name), type = ltoa(Type)}, - %io:fwrite("Added Var ~p~n", [V]), + {ProcPid, Name, Value} = Data, + %%% type = pid to change, for now it's ok like this because I only focus on pid exchange + V = #variable{name = ltoa(Name), type = pid, value = ltoa(Value)}, + % io:fwrite("Added Var ~p~n", [V]), actor_emul:add_proc_localvars(ProcPid, V). %%% Substitute pif_self to pid_procId check_pid_self(Data, ProcId) -> - % %io:fwrite("[C]Data ~p proc id ~p~n", [Data, ProcId]), - lists:flatten(string:replace(atol(Data), "pid_self", "pid_" ++ atol(ProcId))). + % io:fwrite("[C]Data ~p proc id ~p~n", [Data, ProcId]), + lists:flatten(string:replace(atol(Data), "pid_self", atol(ProcId))). %%% Custom recursive logic and and_rec([]) -> diff --git a/src/choreography/lv.erl b/src/choreography/lv.erl index 98ed03e..8330044 100644 --- a/src/choreography/lv.erl +++ b/src/choreography/lv.erl @@ -26,18 +26,27 @@ create_localview(ActorName, Settings, Save) -> no_graph; ActorAst -> io:fwrite("[LV] Creating a localview for ~p~n", [ActorName]), - LocalViewData = build_localview(ActorName, ActorAst, Settings), - G = LocalViewData#wip_lv.graph, - set_final_state(G), - MinG = fsa:minimize(G), - LV = LocalViewData#wip_lv{graph = MinG}, - ets:insert(?LOCALVIEW, {ActorName, LV}), - case Save or Settings#setting.save_all of - true -> share:save_graph(G, Settings, ActorName, local); - false -> done - end, - %% Which should I return? LV (contains the MinGraph) or LocalViewData (not minimized) - LocalViewData + LV = share:get_localview(ActorName), + case LV of + not_found -> + BaseData = #wip_lv{ + fun_name = ActorName, fun_ast = ActorAst, settings = Settings + }, + share:add_vertex(BaseData#wip_lv.graph), + LVData = eval_codeline(BaseData#wip_lv.fun_ast, BaseData), + G = LVData#wip_lv.graph, + set_final_state(G), + MinG = fsa:minimize(G), + NewLV = LVData#wip_lv{graph = MinG}, + ets:insert(?LOCALVIEW, {ActorName, NewLV}), + case Save or Settings#setting.save_all of + true -> share:save_graph(G, Settings, ActorName, local); + false -> done + end, + NewLV; + L -> + L + end end. does_actor_exist(ActorName) -> @@ -47,17 +56,6 @@ does_actor_exist(ActorName) -> A -> A end. -build_localview(ActorName, Ast, Settings) -> - LV = share:get_localview(ActorName), - case LV of - not_found -> - BaseData = #wip_lv{fun_name = ActorName, fun_ast = Ast, settings = Settings}, - share:add_vertex(BaseData#wip_lv.graph), - eval_codeline(BaseData#wip_lv.fun_ast, BaseData); - L -> - L - end. - eval_codeline(CodeLine, Data) -> debug_print(CodeLine), case CodeLine of diff --git a/src/share/common_data.hrl b/src/share/common_data.hrl index 839f1aa..b323b7a 100644 --- a/src/share/common_data.hrl +++ b/src/share/common_data.hrl @@ -15,6 +15,7 @@ -define(LOCALVIEW, lv). -define(REGISTERDB, reg). -define(SPAWNC, spc). +-define(SEPARATOR, "/"). %%% RECORDS @@ -37,15 +38,15 @@ }). -record(wip_lv, { - fun_name, - fun_ast, + fun_name = "", + fun_ast = {}, graph = digraph:new(), last_vertex = 1, local_vars = [], ret_var = #variable{}, - node_map = #{}, + % node_map = #{}, + % input_vars = [], edge_map = #{}, - input_vars = [], settings = #setting{} }). @@ -66,7 +67,8 @@ }). -record(actor_info, { - proc_id = ?UNDEFINED, + fun_name = "", + id = ?UNDEFINED, current_state = 1, first_marked_edges = [], second_marked_edges = [], diff --git a/src/share/share.erl b/src/share/share.erl index 06f464b..9be5136 100644 --- a/src/share/share.erl +++ b/src/share/share.erl @@ -20,9 +20,10 @@ parse_actor_string/1, should_minimize/1, save_graph/4, - add_vertex_edge/2, remove_last/1, find_var/2, + if_final_get_n/1, + inc_spawn_counter/1, atol/1, ltoa/1 ]). @@ -72,29 +73,41 @@ is_uppercase(Char) when (is_list(Char)) and (length(Char) =:= 1) -> get_fun_ast(FunName) -> Ast = ets:lookup(?FUNAST, atol(FunName)), case Ast of - [] -> not_found; - [{_, A}] -> A + [] -> + % io:fwrite("[S] Not Found in funast ~p~n", [FunName]), + not_found; + [{_, A}] -> + A end. get_localview(FunName) -> - Ast = ets:lookup(?LOCALVIEW, FunName), + Ast = ets:lookup(?LOCALVIEW, atol(FunName)), case Ast of - [] -> not_found; - [{_, A}] -> A + [] -> + % io:fwrite("[S] Not Found in localview ~p~n", [FunName]), + not_found; + [{_, A}] -> + A end. get_graph(FunName) -> - Ast = ets:lookup(?LOCALVIEW, FunName), + Ast = ets:lookup(?LOCALVIEW, atol(FunName)), case Ast of - [] -> not_found; - [{_, A}] -> A#wip_lv.graph + [] -> + io:fwrite("[S] Not Found in graph ~p~n", [FunName]), + not_found; + [{_, A}] -> + A#wip_lv.graph end. get_edgedata(FunName) -> - Ast = ets:lookup(?LOCALVIEW, FunName), + Ast = ets:lookup(?LOCALVIEW, atol(FunName)), case Ast of - [] -> not_found; - [{_, A}] -> A#wip_lv.edge_map + [] -> + io:fwrite("[S] Not Found in edgedata ~p~n", [FunName]), + not_found; + [{_, A}] -> + A#wip_lv.edge_map end. warning(String, Content, RetData) -> @@ -117,6 +130,12 @@ ltoa(L) when is_atom(L) -> L. atol(A) when is_atom(A) -> atom_to_list(A); atol(A) when is_list(A) -> A. +if_final_get_n(L) when not is_integer(L) -> + NewL = re:replace(L, ?FINALTAG, "", [{return, list}]), + list_to_integer(NewL); +if_final_get_n(L) when is_integer(L) -> + L. + merge_fun_ar(Name, Arity) -> atol(Name) ++ integer_to_list(Arity). @@ -142,13 +161,6 @@ save_graph(G, Settings, FunName, Mode) -> end, save_graph_to_file(ToSaveG, OutputDir, FunName, Mode). -add_vertex_edge(Label, Data) -> - G = Data#wip_lv.graph, - LastV = Data#wip_lv.last_vertex, - V = share:add_vertex(G), - digraph:add_edge(G, LastV, V, Label), - Data#wip_lv{last_vertex = V}. - %%% Remove the last element from a list remove_last(Item) -> ItemList = atol(Item), @@ -167,6 +179,15 @@ find_var(Data, Name) -> LL = Data#wip_lv.local_vars, find_var(LL, Name). +inc_spawn_counter(Name) -> + Ret = + case ets:lookup(?SPAWNC, share:ltoa(Name)) of + [] -> 0; + [{_, N}] -> N + end, + ets:insert(?SPAWNC, {Name, Ret + 1}), + Ret. + %%%=================================================================== %%% Internal Functions %%%=================================================================== diff --git a/test.py b/test.py new file mode 100755 index 0000000..1a2a53f --- /dev/null +++ b/test.py @@ -0,0 +1,35 @@ +#!/bin/python +import os + +test_list = [ + ("./examples/hello/hello.erl", "greet0", "examples/hello"), + ("./examples/async/simple.erl","main0","examples/async"), + ("./examples/ticktackstop/tictacstop.erl","start0","examples/ticktackstop"), + ("./examples/ticktackloop/tictacloop.erl","start0","examples/ticktackloop"), + ("./examples/customer/customer.erl","main0","examples/customer"), + ("./examples/serverclient/serverclient.erl","main0","examples/serverclient"), + ("./examples/trick/trick.erl","main0","examples/trick"), + ("./examples/airline/airline.erl","main0","examples/airline"), + ("./examples/conditional-case/conditional_case.erl","main0","examples/conditional-case"), + ("./examples/for-loop-recursion/forloop.erl","main0","examples/for-loop-recursion"), + ("./examples/function-call/funny.erl","main0","examples/function-call"), + ("./examples/high-order-fun/hof.erl","greet0","examples/high-order-fun"), + ("./examples/if-cases/ifcases.erl","main0","examples/if-cases"), + ("./examples/test/barber/barber.erl","test0","examples/test/barber"), + ("./examples/test/foo1/foo1.erl","test0","examples/test/foo1"), + ("./examples/test/foo2/foo2.erl","test0","examples/test/foo2"), + ("./examples/test/foo3/foo3.erl","test0","examples/test/foo3"), + ("./examples/test/foo4/foo4.erl","test0","examples/test/foo4"), + ("./examples/test/foo5/foo5.erl","test0","examples/test/foo5"), + ("./examples/test/foo6/foo6.erl","test0","examples/test/foo6"), + ("./examples/test/ping/ping.erl","start0","examples/test/ping"), +] + +os.system("rebar3 escriptize") + +for item in test_list: + path, entrypoint, dir = item + cmd = f"./_build/default/bin/chorer {path} {entrypoint} {dir}" + print(cmd) + os.system(cmd) + print("\n") diff --git a/test.sh b/test.sh deleted file mode 100755 index 8632c81..0000000 --- a/test.sh +++ /dev/null @@ -1,22 +0,0 @@ -rebar3 escriptize -./_build/default/bin/chorer ./examples/hello/hello.erl greet examples/hello -./_build/default/bin/chorer ./examples/async/simple.erl main examples/async -./_build/default/bin/chorer ./examples/ticktackstop/tictacstop.erl start examples/ticktackstop -./_build/default/bin/chorer ./examples/ticktackloop/tictacloop.erl start examples/ticktackloop -./_build/default/bin/chorer ./examples/customer/customer.erl main examples/customer -./_build/default/bin/chorer ./examples/serverclient/serverclient.erl main examples/serverclient -./_build/default/bin/chorer ./examples/trick/trick.erl main examples/trick -./_build/default/bin/chorer ./examples/airline/airline.erl main examples/airline -./_build/default/bin/chorer ./examples/conditional-case/conditional_case.erl main examples/conditional-case -./_build/default/bin/chorer ./examples/for-loop-recursion/forloop.erl main examples/for-loop-recursion -./_build/default/bin/chorer ./examples/function-call/funny.erl main examples/function-call -./_build/default/bin/chorer ./examples/high-order-fun/hof.erl greet examples/high-order-fun -./_build/default/bin/chorer ./examples/if-cases/ifcases.erl main examples/if-cases -./_build/default/bin/chorer ./examples/test/barber/barber.erl test examples/test/barber -./_build/default/bin/chorer ./examples/test/foo1/foo1.erl test examples/test/foo1 -./_build/default/bin/chorer ./examples/test/foo2/foo2.erl test examples/test/foo2 -./_build/default/bin/chorer ./examples/test/foo3/foo3.erl test examples/test/foo3 -./_build/default/bin/chorer ./examples/test/foo4/foo4.erl test examples/test/foo4 -./_build/default/bin/chorer ./examples/test/foo5/foo5.erl test examples/test/foo5 -./_build/default/bin/chorer ./examples/test/foo6/foo6.erl test examples/test/foo6 -./_build/default/bin/chorer ./examples/test/ping/ping.erl test examples/test/ping \ No newline at end of file From cfc7d5637da16b296b30f1e00ccfa927f08e87da Mon Sep 17 00:00:00 2001 From: geno Date: Thu, 22 Feb 2024 18:20:38 +0100 Subject: [PATCH 10/11] readme for all the examples --- examples/airline/README.md | 20 ++ examples/airline/main0_global_view.dot | 28 +- examples/airline/main0_local_view.dot | 18 +- examples/async/README.md | 17 ++ examples/conditional-case/README.md | 34 ++- .../conditional-case/conditional_case.erl | 7 +- .../conditional-case/dummy1_local_view.dot | 2 +- .../conditional-case/main0_global_view.dot | 52 +++- .../conditional-case/main0_local_view.dot | 36 ++- examples/customer/README.md | 20 ++ examples/customer/customer0_local_view.dot | 16 +- examples/customer/store0_local_view.dot | 20 +- examples/for-loop-recursion/README.md | 25 +- .../for-loop-recursion/main0_global_view.dot | 19 +- .../for-loop-recursion/main0_local_view.dot | 6 +- examples/function-call/README.md | 26 +- examples/function-call/main0_global_view.dot | 4 + examples/function-call/main0_local_view.dot | 2 +- examples/hello/README.md | 19 ++ examples/hello/greet0_local_view.dot | 7 +- examples/hello/hello.erl | 3 +- examples/high-order-fun/README.md | 18 ++ .../high-order-fun/greet0_global_view.dot | 67 +++-- examples/high-order-fun/greet0_local_view.dot | 18 +- examples/if-cases/README.md | 25 +- examples/if-cases/a0_local_view.dot | 6 +- examples/if-cases/b0_local_view.dot | 6 +- examples/if-cases/c0_local_view.dot | 6 +- examples/if-cases/main0_global_view.dot | 120 ++++---- examples/serverclient/README.md | 24 ++ examples/serverclient/client0_local_view.dot | 16 +- examples/serverclient/main0_global_view.dot | 173 +---------- examples/serverclient/main0_local_view.dot | 6 +- examples/serverclient/serverclient.erl | 1 - examples/test/foo3/test0_global_view.dot | 37 ++- examples/test/foo6/README.md | 18 ++ examples/test/foo6/foo6.erl | 21 +- examples/test/foo6/test0_global_view.dot | 21 +- examples/test/foo6/test0_local_view.dot | 6 +- examples/test/ping/README.md | 18 ++ examples/test/ping/start0_global_view.dot | 4 +- examples/test/ping/start0_local_view.dot | 10 +- examples/ticktackloop/README.md | 17 ++ examples/ticktackloop/start0_global_view.dot | 14 +- examples/ticktackloop/start0_local_view.dot | 6 +- examples/ticktackstop/README.md | 17 ++ examples/ticktackstop/start0_global_view.dot | 38 ++- examples/ticktackstop/start0_local_view.dot | 15 +- examples/trick/README.md | 23 ++ examples/trick/main0_global_view.dot | 31 +- examples/violation/README.md | 17 ++ .../violation/incrementer0_local_view.dot | 19 ++ examples/violation/main0_global_view.dot | 271 ++++++++++++++++++ examples/violation/main0_local_view.dot | 15 + examples/violation/meManager0_local_view.dot | 12 + examples/violation/varManager1_local_view.dot | 11 + src/choreography/actor_emul.erl | 2 +- src/choreography/eval.erl | 12 +- src/choreography/gv.erl | 12 +- src/choreography/lv.erl | 6 +- src/share/common_data.hrl | 1 + src/share/fsa.erl | 51 ++-- src/share/share.erl | 9 +- test.py | 3 +- 64 files changed, 1101 insertions(+), 503 deletions(-) create mode 100644 examples/airline/README.md create mode 100644 examples/async/README.md create mode 100644 examples/customer/README.md create mode 100644 examples/hello/README.md create mode 100644 examples/high-order-fun/README.md create mode 100644 examples/serverclient/README.md create mode 100644 examples/test/foo6/README.md create mode 100644 examples/test/ping/README.md create mode 100644 examples/ticktackloop/README.md create mode 100644 examples/ticktackstop/README.md create mode 100644 examples/trick/README.md create mode 100644 examples/violation/README.md create mode 100644 examples/violation/incrementer0_local_view.dot create mode 100644 examples/violation/main0_global_view.dot create mode 100644 examples/violation/main0_local_view.dot create mode 100644 examples/violation/meManager0_local_view.dot create mode 100644 examples/violation/varManager1_local_view.dot diff --git a/examples/airline/README.md b/examples/airline/README.md new file mode 100644 index 0000000..a7142b6 --- /dev/null +++ b/examples/airline/README.md @@ -0,0 +1,20 @@ +# Airline example + +## Use + +```bash +./_build/default/bin/chorer ./examples/airline/airline.erl main0 ./examples/airline +``` + +## Description + +Features: + +- `seat` è una funzione con due definizioni e grazie alla funzione `eval:function_list` viene gestito correttamente questo caso ricominciando la costruzione del grafo dal primo vertice +- nel main viene chiamata la funzione `seat` che viene correttamente attaccata al main grazie alla funzione merge_graph (non viene valutato il passaggio di variabili) +- durante la costruzione della gv, vengono correttamente valutati i passaggi di variabili delle spawn e delle send/recv + +## Results + +La GV non sembra corretta, il problema sembra essere che torni in stati precedenti quando non dovrebbe essere così. +La LV del main è molto generica, potrebbe essere più precisa se si esegue la valuzione della variabile 2 (viene allegata una LV corretta nella cartella). diff --git a/examples/airline/main0_global_view.dot b/examples/airline/main0_global_view.dot index 986c711..18cac89 100644 --- a/examples/airline/main0_global_view.dot +++ b/examples/airline/main0_global_view.dot @@ -1,11 +1,27 @@ digraph global { rankdir="LR"; n_0 [label="global", shape="plaintext"]; - n_1 [id="1", shape=circle, label="1"]; - n_0 -> n_1 [arrowhead=none]; - n_2 [id="2", shape=circle, label="2"]; - n_3 [id="3", shape=circle, label="3"]; + n_1 [id="5", shape=circle, label="7"]; + n_2 [id="6", shape=circle, label="6"]; + n_3 [id="1", shape=circle, label="1"]; + n_0 -> n_3 [arrowhead=none]; + n_4 [id="2", shape=circle, label="2"]; + n_5 [id="4", shape=circle, label="4"]; + n_6 [id="7", shape=circle, label="5"]; + n_7 [id="3", shape=circle, label="3"]; - n_2 -> n_3 [id="[$e|1]", label="main0/0Δagent1/1"]; - n_1 -> n_2 [id="[$e|0]", label="main0/0Δagent1/0"]; + n_7 -> n_6 [id="[$e|3]", label="agent1/0→main0/0:{sell,pid_self}"]; + n_5 -> n_1 [id="[$e|11]", label="agent1/0→main0/0:{sell,pid_self}"]; + n_1 -> n_5 [id="[$e|12]", label="main0/0→agent1/0:{booked,Num}"]; + n_3 -> n_4 [id="[$e|8]", label="main0/0Δagent1/0"]; + n_2 -> n_6 [id="[$e|1]", label="main0/0→agent1/1:{booked,Num}"]; + n_6 -> n_7 [id="[$e|6]", label="main0/0→agent1/0:{booked,Num}"]; + n_7 -> n_5 [id="[$e|4]", label="agent1/1→main0/0:{sell,pid_self}"]; + n_5 -> n_7 [id="[$e|7]", label="main0/0→agent1/1:{booked,Num}"]; + n_7 -> n_6 [id="[$e|2]", label="main0/0→agent1/1:{booked,Num}"]; + n_1 -> n_7 [id="[$e|5]", label="main0/0→agent1/1:{booked,Num}"]; + n_7 -> n_5 [id="[$e|0]", label="main0/0→agent1/0:{booked,Num}"]; + n_6 -> n_2 [id="[$e|13]", label="agent1/1→main0/0:{sell,pid_self}"]; + n_2 -> n_7 [id="[$e|9]", label="main0/0→agent1/0:{booked,Num}"]; + n_4 -> n_7 [id="[$e|10]", label="main0/0Δagent1/1"]; } diff --git a/examples/airline/main0_local_view.dot b/examples/airline/main0_local_view.dot index 96e1bde..65ae918 100644 --- a/examples/airline/main0_local_view.dot +++ b/examples/airline/main0_local_view.dot @@ -1,14 +1,14 @@ digraph main0 { rankdir="LR"; n_0 [label="main0", shape="plaintext"]; - n_1 [id="1", shape=circle, label="1"]; - n_0 -> n_1 [arrowhead=none]; - n_2 [id="2", shape=circle, label="2"]; - n_3 [id="4", shape=circle, label="4"]; - n_4 [id="3", shape=circle, label="3"]; + n_1 [id="5", shape=circle, label="4"]; + n_2 [id="1", shape=circle, label="1"]; + n_0 -> n_2 [arrowhead=none]; + n_3 [id="2", shape=doublecircle, label="3"]; + n_4 [id="3", shape=circle, label="2"]; - n_1 -> n_2 [id="[$e|3]", label="spawn agent1/0"]; - n_4 -> n_3 [id="[$e|2]", label="receive {sell,Pid1}"]; - n_3 -> n_4 [id="[$e|5]", label="send {booked,Num} to Pid1"]; - n_2 -> n_4 [id="[$e|0]", label="spawn agent1/1"]; + n_4 -> n_3 [id="[$e|1]", label="spawn agent1/1"]; + n_2 -> n_4 [id="[$e|2]", label="spawn agent1/0"]; + n_1 -> n_3 [id="[$e|5]", label="send {booked,Num} to Pid1"]; + n_3 -> n_1 [id="[$e|0]", label="receive {sell,Pid1}"]; } diff --git a/examples/async/README.md b/examples/async/README.md new file mode 100644 index 0000000..4c72469 --- /dev/null +++ b/examples/async/README.md @@ -0,0 +1,17 @@ +# Async example + +## Use + +```bash +./_build/default/bin/chorer ./examples/async/simple.erl main0 ./examples/async +``` + +## Description + +Features: + +- in questo semplice esempio avvengono due send in contemporanea e quindi nella global view viene correttamente rappresentato che ci sono due possibili esecuzioni + +## Results + +LV e GV sono corrette. diff --git a/examples/conditional-case/README.md b/examples/conditional-case/README.md index f20ed31..0bfe434 100644 --- a/examples/conditional-case/README.md +++ b/examples/conditional-case/README.md @@ -1,10 +1,30 @@ -# Usage +# Conditional case example + +## Use + +```bash +./_build/default/bin/chorer ./examples/conditional-case/conditional_case.erl main0 ./examples/conditional-case +``` + +## Description + +Features: + +- vengono spawnati diversi processi dalla stessa funzione a cui viene passato il pid del main +- in questo esempio vengono usate le variabili per eseguire del pattern matching a cui poi corrisponde una send precisa + +## Results + +La GV cambia molto a seconda delle recv perché non vengono gestite bene le stringhe e le variabili con il pm + +provare ad aggiungere alla fine del main ```erlang -# erl -1> c(conditional_case). -{ok,funny} -2> conditional_case:main(). -Ciao A -{<0.91.0>,0.40993420732819685} +D -> D ! "Ciao D"; + true -> io:fwrite("Boh~n") + end, + + receive + Obj -> Obj + end. ``` diff --git a/examples/conditional-case/conditional_case.erl b/examples/conditional-case/conditional_case.erl index 840f209..1474643 100644 --- a/examples/conditional-case/conditional_case.erl +++ b/examples/conditional-case/conditional_case.erl @@ -22,10 +22,5 @@ main() -> A -> A ! "Ciao A"; B -> B ! "Ciao B"; C -> C ! "Ciao C"; - D -> D ! "Ciao D"; - true -> io:fwrite("Boh~n") - end, - - receive - Obj -> Obj + D -> D ! "Ciao D" end. diff --git a/examples/conditional-case/dummy1_local_view.dot b/examples/conditional-case/dummy1_local_view.dot index 2ada5ea..2277b04 100644 --- a/examples/conditional-case/dummy1_local_view.dot +++ b/examples/conditional-case/dummy1_local_view.dot @@ -6,6 +6,6 @@ digraph dummy1 { n_2 [id="2", shape=circle, label="2"]; n_3 [id="3", shape=doublecircle, label="3"]; - n_1 -> n_2 [id="[$e|0]", label="send {pid_self,integer} to Pid"]; n_2 -> n_3 [id="[$e|1]", label="receive Str"]; + n_1 -> n_2 [id="[$e|0]", label="send {pid_self,integer} to Pid"]; } diff --git a/examples/conditional-case/main0_global_view.dot b/examples/conditional-case/main0_global_view.dot index 56a109b..9f02d19 100644 --- a/examples/conditional-case/main0_global_view.dot +++ b/examples/conditional-case/main0_global_view.dot @@ -1,15 +1,47 @@ digraph global { rankdir="LR"; n_0 [label="global", shape="plaintext"]; - n_1 [id="5", shape=circle, label="4"]; - n_2 [id="1", shape=circle, label="1"]; - n_0 -> n_2 [arrowhead=none]; - n_3 [id="2", shape=circle, label="2"]; - n_4 [id="4", shape=circle, label="5"]; - n_5 [id="3", shape=circle, label="3"]; + n_1 [id="20", shape=circle, label="20"]; + n_2 [id="5", shape=circle, label="5"]; + n_3 [id="15", shape=circle, label="15"]; + n_4 [id="19", shape=circle, label="19"]; + n_5 [id="12", shape=circle, label="12"]; + n_6 [id="11", shape=circle, label="11"]; + n_7 [id="17", shape=circle, label="17"]; + n_8 [id="18", shape=circle, label="18"]; + n_9 [id="14", shape=circle, label="14"]; + n_10 [id="6", shape=circle, label="6"]; + n_11 [id="13", shape=circle, label="13"]; + n_12 [id="10", shape=circle, label="10"]; + n_13 [id="1", shape=circle, label="1"]; + n_0 -> n_13 [arrowhead=none]; + n_14 [id="9", shape=circle, label="9"]; + n_15 [id="2", shape=circle, label="2"]; + n_16 [id="21", shape=circle, label="21"]; + n_17 [id="8", shape=circle, label="8"]; + n_18 [id="4", shape=circle, label="4"]; + n_19 [id="7", shape=circle, label="7"]; + n_20 [id="3", shape=circle, label="3"]; + n_21 [id="16", shape=circle, label="16"]; - n_2 -> n_3 [id="[$e|0]", label="main0/0Δdummy1/0"]; - n_1 -> n_4 [id="[$e|3]", label="main0/0Δdummy1/3"]; - n_5 -> n_1 [id="[$e|2]", label="main0/0Δdummy1/2"]; - n_3 -> n_5 [id="[$e|1]", label="main0/0Δdummy1/1"]; + n_17 -> n_8 [id="[$e|16]", label="main0/0→dummy1/1:'Ciao"]; + n_18 -> n_2 [id="[$e|3]", label="main0/0Δdummy1/3"]; + n_10 -> n_12 [id="[$e|8]", label="main0/0→dummy1/0:'Ciao"]; + n_20 -> n_18 [id="[$e|2]", label="main0/0Δdummy1/2"]; + n_19 -> n_21 [id="[$e|14]", label="main0/0→dummy1/1:'Ciao"]; + n_2 -> n_17 [id="[$e|6]", label="dummy1/2→main0/0:{pid_self,integer}"]; + n_10 -> n_9 [id="[$e|12]", label="main0/0→dummy1/1:'Ciao"]; + n_19 -> n_7 [id="[$e|15]", label="main0/0→dummy1/2:'Ciao"]; + n_2 -> n_19 [id="[$e|5]", label="dummy1/1→main0/0:{pid_self,integer}"]; + n_14 -> n_11 [id="[$e|11]", label="main0/0→dummy1/0:'Ciao"]; + n_19 -> n_6 [id="[$e|9]", label="main0/0→dummy1/0:'Ciao"]; + n_15 -> n_20 [id="[$e|1]", label="main0/0Δdummy1/1"]; + n_2 -> n_10 [id="[$e|4]", label="dummy1/0→main0/0:{pid_self,integer}"]; + n_14 -> n_1 [id="[$e|18]", label="main0/0→dummy1/1:'Ciao"]; + n_10 -> n_3 [id="[$e|13]", label="main0/0→dummy1/2:'Ciao"]; + n_17 -> n_4 [id="[$e|17]", label="main0/0→dummy1/2:'Ciao"]; + n_13 -> n_15 [id="[$e|0]", label="main0/0Δdummy1/0"]; + n_2 -> n_14 [id="[$e|7]", label="dummy1/3→main0/0:{pid_self,integer}"]; + n_14 -> n_16 [id="[$e|19]", label="main0/0→dummy1/2:'Ciao"]; + n_17 -> n_5 [id="[$e|10]", label="main0/0→dummy1/0:'Ciao"]; } diff --git a/examples/conditional-case/main0_local_view.dot b/examples/conditional-case/main0_local_view.dot index 14a22ae..a292768 100644 --- a/examples/conditional-case/main0_local_view.dot +++ b/examples/conditional-case/main0_local_view.dot @@ -1,25 +1,21 @@ digraph main0 { rankdir="LR"; n_0 [label="main0", shape="plaintext"]; - n_1 [id="11", shape=circle, label="3"]; - n_2 [id="6", shape=circle, label="4"]; - n_3 [id="10", shape=circle, label="5"]; - n_4 [id="1", shape=circle, label="1"]; - n_0 -> n_4 [arrowhead=none]; - n_5 [id="2", shape=circle, label="7"]; - n_6 [id="8", shape=doublecircle, label="8"]; - n_7 [id="4", shape=circle, label="2"]; - n_8 [id="3", shape=circle, label="6"]; + n_1 [id="5", shape=circle, label="6"]; + n_2 [id="10", shape=circle, label="3"]; + n_3 [id="1", shape=circle, label="1"]; + n_0 -> n_3 [arrowhead=none]; + n_4 [id="9", shape=circle, label="5"]; + n_5 [id="2", shape=circle, label="2"]; + n_6 [id="4", shape=circle, label="4"]; + n_7 [id="3", shape=doublecircle, label="7"]; - n_8 -> n_5 [id="[$e|16]", label="send "Ciao A" to dummy1/0"]; - n_8 -> n_5 [id="[$e|0]", label="send "Ciao C" to dummy1/2"]; - n_8 -> n_6 [id="[$e|9]", label="receive Obj"]; - n_8 -> n_5 [id="[$e|14]", label="send "Ciao D" to dummy1/3"]; - n_1 -> n_2 [id="[$e|5]", label="spawn dummy1/2"]; - n_5 -> n_6 [id="[$e|3]", label="receive Obj"]; - n_3 -> n_8 [id="[$e|8]", label="receive {Process,_}"]; - n_2 -> n_3 [id="[$e|6]", label="spawn dummy1/3"]; - n_7 -> n_1 [id="[$e|11]", label="spawn dummy1/1"]; - n_8 -> n_5 [id="[$e|15]", label="send "Ciao B" to dummy1/1"]; - n_4 -> n_7 [id="[$e|4]", label="spawn dummy1/0"]; + n_2 -> n_6 [id="[$e|3]", label="spawn dummy1/2"]; + n_5 -> n_2 [id="[$e|8]", label="spawn dummy1/1"]; + n_3 -> n_5 [id="[$e|2]", label="spawn dummy1/0"]; + n_1 -> n_7 [id="[$e|5]", label="send 'Ciao A' to dummy1/0"]; + n_1 -> n_7 [id="[$e|9]", label="send 'Ciao B' to dummy1/1"]; + n_6 -> n_4 [id="[$e|4]", label="spawn dummy1/3"]; + n_4 -> n_1 [id="[$e|7]", label="receive {Process,_}"]; + n_1 -> n_7 [id="[$e|10]", label="send 'Ciao C' to dummy1/2"]; } diff --git a/examples/customer/README.md b/examples/customer/README.md new file mode 100644 index 0000000..20b0d7a --- /dev/null +++ b/examples/customer/README.md @@ -0,0 +1,20 @@ +# Customer example + +## Use + +```bash +./_build/default/bin/chorer ./examples/customer/customer.erl main0 ./examples/customer +``` + +## Description + +Features: + +- uso di register +- solo scambio di atom +- ricorsione +- la GV ha dei loop + +## Results + +LV e GV sono corrette. diff --git a/examples/customer/customer0_local_view.dot b/examples/customer/customer0_local_view.dot index e9e2c74..68ba790 100644 --- a/examples/customer/customer0_local_view.dot +++ b/examples/customer/customer0_local_view.dot @@ -5,13 +5,13 @@ digraph customer0 { n_2 [id="1", shape=circle, label="1"]; n_0 -> n_2 [arrowhead=none]; n_3 [id="2", shape=circle, label="3"]; - n_4 [id="7", shape=doublecircle, label="5"]; - n_5 [id="3", shape=circle, label="4"]; + n_4 [id="4", shape=circle, label="4"]; + n_5 [id="3", shape=doublecircle, label="5"]; - n_1 -> n_3 [id="[$e|4]", label="send buy to store0/0"]; - n_5 -> n_4 [id="[$e|1]", label="receive accepted"]; - n_1 -> n_2 [id="[$e|8]", label="send more to store0/0"]; - n_5 -> n_3 [id="[$e|9]", label="receive reject"]; - n_2 -> n_1 [id="[$e|7]", label="send item to store0/0"]; - n_3 -> n_5 [id="[$e|2]", label="send payment to store0/0"]; + n_4 -> n_5 [id="[$e|4]", label="receive accepted"]; + n_1 -> n_3 [id="[$e|3]", label="send buy to store0/0"]; + n_4 -> n_3 [id="[$e|8]", label="receive reject"]; + n_1 -> n_2 [id="[$e|9]", label="send more to store0/0"]; + n_2 -> n_1 [id="[$e|0]", label="send item to store0/0"]; + n_3 -> n_4 [id="[$e|5]", label="send payment to store0/0"]; } diff --git a/examples/customer/store0_local_view.dot b/examples/customer/store0_local_view.dot index ee95a60..1b6619f 100644 --- a/examples/customer/store0_local_view.dot +++ b/examples/customer/store0_local_view.dot @@ -1,17 +1,17 @@ digraph store0 { rankdir="LR"; n_0 [label="store0", shape="plaintext"]; - n_1 [id="6", shape=doublecircle, label="5"]; + n_1 [id="5", shape=doublecircle, label="5"]; n_2 [id="1", shape=circle, label="1"]; n_0 -> n_2 [arrowhead=none]; - n_3 [id="2", shape=circle, label="2"]; - n_4 [id="7", shape=doublecircle, label="4"]; - n_5 [id="3", shape=circle, label="3"]; + n_3 [id="2", shape=circle, label="4"]; + n_4 [id="4", shape=circle, label="3"]; + n_5 [id="3", shape=circle, label="2"]; - n_5 -> n_4 [id="[$e|1]", label="receive payment"]; - n_3 -> n_2 [id="[$e|8]", label="receive more"]; - n_3 -> n_5 [id="[$e|9]", label="receive buy"]; - n_2 -> n_3 [id="[$e|6]", label="receive item"]; - n_4 -> n_1 [id="[$e|7]", label="send accepted to customer0/0"]; - n_4 -> n_5 [id="[$e|5]", label="send reject to customer0/0"]; + n_3 -> n_1 [id="[$e|1]", label="send accepted to customer0/0"]; + n_5 -> n_2 [id="[$e|8]", label="receive more"]; + n_3 -> n_4 [id="[$e|9]", label="send reject to customer0/0"]; + n_4 -> n_3 [id="[$e|0]", label="receive payment"]; + n_5 -> n_4 [id="[$e|2]", label="receive buy"]; + n_2 -> n_5 [id="[$e|5]", label="receive item"]; } diff --git a/examples/for-loop-recursion/README.md b/examples/for-loop-recursion/README.md index 15c1f73..e3be83d 100644 --- a/examples/for-loop-recursion/README.md +++ b/examples/for-loop-recursion/README.md @@ -1,9 +1,18 @@ -# Usage - -```erlang -# erl -1> c(forloop). -{ok,funny} -2> forloop:main(). -% deadlock +# For loop receive example + +## Use + +```bash +./_build/default/bin/chorer ./examples/customer/customer.erl main0 ./examples/customer ``` + +## Description + +Features: + +- receive in una funzione ricorsiva +- avviene un deadlock perché il main rimane in attesa di un messaggio ma nel sistema ci sono solo due processi + +## Results + +LV corretta. In GV manca da implementare il sistema per capire se è in uno stato finale. Verrebbe poi notificato il deadlock! \ No newline at end of file diff --git a/examples/for-loop-recursion/main0_global_view.dot b/examples/for-loop-recursion/main0_global_view.dot index 9845deb..6083cae 100644 --- a/examples/for-loop-recursion/main0_global_view.dot +++ b/examples/for-loop-recursion/main0_global_view.dot @@ -1,11 +1,18 @@ digraph global { rankdir="LR"; n_0 [label="global", shape="plaintext"]; - n_1 [id="1", shape=circle, label="1"]; - n_0 -> n_1 [arrowhead=none]; - n_2 [id="2", shape=circle, label="2"]; - n_3 [id="3", shape=circle, label="3"]; + n_1 [id="5", shape=circle, label="6"]; + n_2 [id="1", shape=circle, label="1"]; + n_0 -> n_2 [arrowhead=none]; + n_3 [id="2", shape=circle, label="2"]; + n_4 [id="4", shape=circle, label="4"]; + n_5 [id="7", shape=circle, label="5"]; + n_6 [id="3", shape=circle, label="3"]; - n_1 -> n_2 [id="[$e|0]", label="main0/0Δdummy1/0"]; - n_2 -> n_3 [id="[$e|1]", label="main0/0Δdummy1/1"]; + n_6 -> n_4 [id="[$e|5]", label="dummy1/1→main0/0:integer"]; + n_4 -> n_1 [id="[$e|0]", label="dummy1/0→main0/0:integer"]; + n_5 -> n_1 [id="[$e|6]", label="dummy1/1→main0/0:integer"]; + n_3 -> n_6 [id="[$e|3]", label="main0/0Δdummy1/1"]; + n_6 -> n_5 [id="[$e|4]", label="dummy1/0→main0/0:integer"]; + n_2 -> n_3 [id="[$e|1]", label="main0/0Δdummy1/0"]; } diff --git a/examples/for-loop-recursion/main0_local_view.dot b/examples/for-loop-recursion/main0_local_view.dot index 7d6a7a5..2e006bd 100644 --- a/examples/for-loop-recursion/main0_local_view.dot +++ b/examples/for-loop-recursion/main0_local_view.dot @@ -4,9 +4,9 @@ digraph main0 { n_1 [id="1", shape=circle, label="1"]; n_0 -> n_1 [arrowhead=none]; n_2 [id="2", shape=circle, label="2"]; - n_3 [id="3", shape=circle, label="3"]; + n_3 [id="3", shape=doublecircle, label="3"]; - n_3 -> n_3 [id="[$e|5]", label="receive Num"]; n_1 -> n_2 [id="[$e|0]", label="spawn dummy1/0"]; - n_2 -> n_3 [id="[$e|2]", label="spawn dummy1/1"]; + n_2 -> n_3 [id="[$e|4]", label="spawn dummy1/1"]; + n_3 -> n_3 [id="[$e|1]", label="receive Num"]; } diff --git a/examples/function-call/README.md b/examples/function-call/README.md index 47b21b4..e0efcea 100644 --- a/examples/function-call/README.md +++ b/examples/function-call/README.md @@ -1,11 +1,17 @@ -# Usage - -```erlang -# erl -1> c(funny). -{ok,funny} -2> funny:main(). -Hello from dummy (1) -Hello from dummy (2) -ok +# Function call example + +## Use + +```bash +./_build/default/bin/chorer ./examples/function-call/funny.erl main0 examples/function-call ``` + +## Description + +Features: + +- due call identiche a recv_dummy + +## Results + +LV del main sbagliata, perché durante la minimizzazione toglie la seconda receive e quindi la GV è sbagliata \ No newline at end of file diff --git a/examples/function-call/main0_global_view.dot b/examples/function-call/main0_global_view.dot index 072df90..d7c5fcd 100644 --- a/examples/function-call/main0_global_view.dot +++ b/examples/function-call/main0_global_view.dot @@ -4,6 +4,10 @@ digraph global { n_1 [id="1", shape=circle, label="1"]; n_0 -> n_1 [arrowhead=none]; n_2 [id="2", shape=circle, label="2"]; + n_3 [id="4", shape=circle, label="4"]; + n_4 [id="3", shape=circle, label="3"]; + n_2 -> n_3 [id="[$e|2]", label="dummy1/0→main0/0:{pid_self,hello2}"]; + n_2 -> n_4 [id="[$e|1]", label="dummy1/0→main0/0:{pid_self,hello1}"]; n_1 -> n_2 [id="[$e|0]", label="main0/0Δdummy1/0"]; } diff --git a/examples/function-call/main0_local_view.dot b/examples/function-call/main0_local_view.dot index 0b74324..8b10c6b 100644 --- a/examples/function-call/main0_local_view.dot +++ b/examples/function-call/main0_local_view.dot @@ -6,6 +6,6 @@ digraph main0 { n_2 [id="2", shape=circle, label="2"]; n_3 [id="3", shape=doublecircle, label="3"]; - n_2 -> n_3 [id="[$e|2]", label="receive {_,Msg}"]; n_1 -> n_2 [id="[$e|3]", label="spawn dummy1/0"]; + n_2 -> n_3 [id="[$e|0]", label="receive {_,Msg}"]; } diff --git a/examples/hello/README.md b/examples/hello/README.md new file mode 100644 index 0000000..f85d839 --- /dev/null +++ b/examples/hello/README.md @@ -0,0 +1,19 @@ +# Hello example + +## Use + +```bash +./_build/default/bin/chorer ./examples/hello/hello.erl greet0 examples/hello +``` + +## Description + +Features: + +- uso di self per autoinviarsi messaggi +- simulaizione dell'if nondeterministico dove in un ramo concludo e nell'altro vado in ricorsione + +## Results + +LV giusta, GV sbagliata perché nello stato 2 non esegue la seconda send e va direttaente alla recv. +Non è stato implementata la biforcazione quando in uno stato c'è contemporaneamente una recv o un altra transizione. \ No newline at end of file diff --git a/examples/hello/greet0_local_view.dot b/examples/hello/greet0_local_view.dot index 9390f2d..5649cf8 100644 --- a/examples/hello/greet0_local_view.dot +++ b/examples/hello/greet0_local_view.dot @@ -6,7 +6,8 @@ digraph greet0 { n_2 [id="2", shape=circle, label="2"]; n_3 [id="3", shape=doublecircle, label="3"]; - n_2 -> n_3 [id="[$e|3]", label="receive _"]; - n_2 -> n_1 [id="[$e|4]", label="send hello2 to pid_self"]; - n_1 -> n_2 [id="[$e|1]", label="send hello1 to pid_self"]; + n_2 -> n_1 [id="[$e|5]", label="send hello2 to pid_self"]; + n_2 -> n_3 [id="[$e|0]", label="receive hello2"]; + n_2 -> n_3 [id="[$e|6]", label="receive hello1"]; + n_1 -> n_2 [id="[$e|3]", label="send hello1 to pid_self"]; } diff --git a/examples/hello/hello.erl b/examples/hello/hello.erl index 170bfdc..a1e64fb 100644 --- a/examples/hello/hello.erl +++ b/examples/hello/hello.erl @@ -10,6 +10,7 @@ greet() -> greet(); false -> receive - _ -> done + hello1 -> done; + hello2 -> done end end. diff --git a/examples/high-order-fun/README.md b/examples/high-order-fun/README.md new file mode 100644 index 0000000..83599d0 --- /dev/null +++ b/examples/high-order-fun/README.md @@ -0,0 +1,18 @@ +# High order function example + +## Use + +```bash +./_build/default/bin/chorer ./examples/high-order-fun/hof.erl greet0 examples/high-order-fun +``` + +## Description + +Features: + +- uso di hof su spawn e come call di funzione su variabile +- uso di self() a sinistra della operazione di send + +## Results + +LV e GV corrette. \ No newline at end of file diff --git a/examples/high-order-fun/greet0_global_view.dot b/examples/high-order-fun/greet0_global_view.dot index a63b10e..587f55e 100644 --- a/examples/high-order-fun/greet0_global_view.dot +++ b/examples/high-order-fun/greet0_global_view.dot @@ -1,36 +1,41 @@ digraph global { rankdir="LR"; n_0 [label="global", shape="plaintext"]; - n_1 [id="15", shape=circle, label="4"]; - n_2 [id="12", shape=circle, label="8"]; - n_3 [id="11", shape=circle, label="9"]; - n_4 [id="17", shape=circle, label="6"]; - n_5 [id="14", shape=circle, label="10"]; - n_6 [id="6", shape=circle, label="3"]; - n_7 [id="13", shape=circle, label="12"]; - n_8 [id="10", shape=circle, label="11"]; - n_9 [id="1", shape=circle, label="1"]; - n_0 -> n_9 [arrowhead=none]; - n_10 [id="9", shape=circle, label="7"]; - n_11 [id="2", shape=circle, label="13"]; - n_12 [id="8", shape=circle, label="5"]; - n_13 [id="3", shape=circle, label="2"]; + n_1 [id="5", shape=circle, label="5"]; + n_2 [id="15", shape=circle, label="15"]; + n_3 [id="12", shape=circle, label="12"]; + n_4 [id="11", shape=circle, label="11"]; + n_5 [id="17", shape=circle, label="17"]; + n_6 [id="18", shape=circle, label="18"]; + n_7 [id="14", shape=circle, label="14"]; + n_8 [id="6", shape=circle, label="6"]; + n_9 [id="13", shape=circle, label="13"]; + n_10 [id="10", shape=circle, label="10"]; + n_11 [id="1", shape=circle, label="1"]; + n_0 -> n_11 [arrowhead=none]; + n_12 [id="9", shape=circle, label="9"]; + n_13 [id="2", shape=circle, label="2"]; + n_14 [id="8", shape=circle, label="8"]; + n_15 [id="4", shape=circle, label="4"]; + n_16 [id="7", shape=circle, label="7"]; + n_17 [id="3", shape=circle, label="3"]; + n_18 [id="16", shape=circle, label="16"]; - n_4 -> n_8 [id="[$e|16]", label="greet0/0→anonfun_15/0:hello"]; - n_5 -> n_11 [id="[$e|19]", label="greet0/0→anonfun_15/0:hello"]; - n_12 -> n_3 [id="[$e|10]", label="greet0/0→anonfun_10/0:hello"]; - n_6 -> n_12 [id="[$e|12]", label="greet0/0→anonfun_15/0:hello"]; - n_8 -> n_11 [id="[$e|21]", label="greet0/0→anonfun_10/0:hello"]; - n_4 -> n_7 [id="[$e|13]", label="greet0/0→anonfun_10/0:hello"]; - n_12 -> n_2 [id="[$e|11]", label="greet0/0→greet0/0:hello"]; - n_1 -> n_5 [id="[$e|0]", label="greet0/0→greet0/0:hello"]; - n_2 -> n_11 [id="[$e|20]", label="greet0/0→anonfun_10/0:hello"]; - n_7 -> n_11 [id="[$e|22]", label="greet0/0→anonfun_15/0:hello"]; - n_6 -> n_1 [id="[$e|6]", label="greet0/0→anonfun_10/0:hello"]; - n_1 -> n_10 [id="[$e|7]", label="greet0/0→anonfun_15/0:hello"]; - n_6 -> n_4 [id="[$e|4]", label="greet0/0→greet0/0:hello"]; - n_13 -> n_6 [id="[$e|8]", label="greet0/0Δanonfun_10/0"]; - n_10 -> n_11 [id="[$e|15]", label="greet0/0→greet0/0:hello"]; - n_9 -> n_13 [id="[$e|1]", label="greet0/0Δanonfun_15/0"]; - n_3 -> n_11 [id="[$e|23]", label="greet0/0→greet0/0:hello"]; + n_3 -> n_6 [id="[$e|16]", label="greet0/0→greet0/0:hello"]; + n_8 -> n_4 [id="[$e|9]", label="greet0/0→greet0/0:hello"]; + n_8 -> n_3 [id="[$e|10]", label="greet0/0→anonfun_15/0:hello"]; + n_14 -> n_7 [id="[$e|12]", label="greet0/0→anonfun_15/0:hello"]; + n_15 -> n_16 [id="[$e|5]", label="greet0/0→anonfun_15/0:hello"]; + n_12 -> n_2 [id="[$e|13]", label="greet0/0→anonfun_10/0:hello"]; + n_16 -> n_9 [id="[$e|11]", label="greet0/0→anonfun_10/0:hello"]; + n_11 -> n_13 [id="[$e|0]", label="greet0/0Δanonfun_15/0"]; + n_15 -> n_14 [id="[$e|6]", label="greet0/0→anonfun_10/0:hello"]; + n_17 -> n_1 [id="[$e|3]", label="greet0/0→anonfun_15/0:hello"]; + n_17 -> n_15 [id="[$e|2]", label="greet0/0→greet0/0:hello"]; + n_1 -> n_12 [id="[$e|7]", label="greet0/0→greet0/0:hello"]; + n_17 -> n_8 [id="[$e|4]", label="greet0/0→anonfun_10/0:hello"]; + n_1 -> n_10 [id="[$e|8]", label="greet0/0→anonfun_10/0:hello"]; + n_10 -> n_18 [id="[$e|14]", label="greet0/0→greet0/0:hello"]; + n_4 -> n_5 [id="[$e|15]", label="greet0/0→anonfun_15/0:hello"]; + n_13 -> n_17 [id="[$e|1]", label="greet0/0Δanonfun_10/0"]; } diff --git a/examples/high-order-fun/greet0_local_view.dot b/examples/high-order-fun/greet0_local_view.dot index a1c41f3..d88e0ea 100644 --- a/examples/high-order-fun/greet0_local_view.dot +++ b/examples/high-order-fun/greet0_local_view.dot @@ -1,19 +1,19 @@ digraph greet0 { rankdir="LR"; n_0 [label="greet0", shape="plaintext"]; - n_1 [id="5", shape=doublecircle, label="5"]; + n_1 [id="5", shape=circle, label="4"]; n_2 [id="1", shape=circle, label="1"]; n_0 -> n_2 [arrowhead=none]; - n_3 [id="2", shape=circle, label="2"]; + n_3 [id="2", shape=doublecircle, label="7"]; n_4 [id="8", shape=circle, label="3"]; n_5 [id="4", shape=circle, label="6"]; n_6 [id="7", shape=circle, label="5"]; - n_7 [id="3", shape=circle, label="4"]; + n_7 [id="3", shape=circle, label="2"]; - n_7 -> n_6 [id="[$e|5]", label="spawn anonfun_10/0"]; - n_2 -> n_3 [id="[$e|0]", label="spawn anonfun_15/0"]; - n_3 -> n_4 [id="[$e|3]", label="send hello to anonfun_15/0"]; - n_5 -> n_5 [id="[$e|7]", label="receive hello"]; - n_4 -> n_7 [id="[$e|4]", label="send hello to pid_self"]; - n_6 -> n_5 [id="[$e|1]", label="send hello to anonfun_10/0"]; + n_1 -> n_6 [id="[$e|5]", label="spawn anonfun_10/0"]; + n_5 -> n_3 [id="[$e|6]", label="receive hello"]; + n_7 -> n_4 [id="[$e|3]", label="send hello to anonfun_15/0"]; + n_6 -> n_5 [id="[$e|7]", label="send hello to anonfun_10/0"]; + n_4 -> n_1 [id="[$e|4]", label="send hello to pid_self"]; + n_2 -> n_7 [id="[$e|1]", label="spawn anonfun_15/0"]; } diff --git a/examples/if-cases/README.md b/examples/if-cases/README.md index 2b6579b..5523c7e 100644 --- a/examples/if-cases/README.md +++ b/examples/if-cases/README.md @@ -1,9 +1,18 @@ -# Usage - -```erlang -# erl -1> c(ifcases). -{ok,ifcases} -2> ifcases:main(). -% random print +# If example + +## Use + +```bash +./_build/default/bin/chorer ./examples/if-cases/ifcases.erl main0 examples/if-cases ``` + +## Description + +Features: + +- uso di if per diversificare la computazione +- passaggio di pid tra più processi + +## Results + +LV corrette, GV non produce trasizioni dove passa la stringa probabilmente perché la variabile non viene valutata per bene \ No newline at end of file diff --git a/examples/if-cases/a0_local_view.dot b/examples/if-cases/a0_local_view.dot index 54a70dd..25847a2 100644 --- a/examples/if-cases/a0_local_view.dot +++ b/examples/if-cases/a0_local_view.dot @@ -6,7 +6,7 @@ digraph a0 { n_2 [id="2", shape=doublecircle, label="3"]; n_3 [id="3", shape=circle, label="2"]; - n_3 -> n_2 [id="[$e|2]", label="send "Hi, i'm A" to Pid"]; - n_1 -> n_3 [id="[$e|1]", label="receive Pid"]; - n_3 -> n_3 [id="[$e|0]", label="receive Pid"]; + n_1 -> n_3 [id="[$e|2]", label="receive Pid"]; + n_3 -> n_3 [id="[$e|1]", label="receive Pid"]; + n_3 -> n_2 [id="[$e|0]", label="send 'Hi, i'm A' to Pid"]; } diff --git a/examples/if-cases/b0_local_view.dot b/examples/if-cases/b0_local_view.dot index 123dd08..8795d82 100644 --- a/examples/if-cases/b0_local_view.dot +++ b/examples/if-cases/b0_local_view.dot @@ -6,7 +6,7 @@ digraph b0 { n_2 [id="2", shape=doublecircle, label="3"]; n_3 [id="3", shape=circle, label="2"]; - n_1 -> n_3 [id="[$e|2]", label="receive Pid"]; - n_3 -> n_3 [id="[$e|1]", label="receive Pid"]; - n_3 -> n_2 [id="[$e|0]", label="send "Hi, i'm B" to Pid"]; + n_3 -> n_2 [id="[$e|2]", label="send 'Hi, i'm B' to Pid"]; + n_1 -> n_3 [id="[$e|1]", label="receive Pid"]; + n_3 -> n_3 [id="[$e|0]", label="receive Pid"]; } diff --git a/examples/if-cases/c0_local_view.dot b/examples/if-cases/c0_local_view.dot index bcab1de..96364ec 100644 --- a/examples/if-cases/c0_local_view.dot +++ b/examples/if-cases/c0_local_view.dot @@ -6,7 +6,7 @@ digraph c0 { n_2 [id="2", shape=doublecircle, label="3"]; n_3 [id="3", shape=circle, label="2"]; - n_3 -> n_2 [id="[$e|2]", label="send "Hi, i'm C" to Pid"]; - n_1 -> n_3 [id="[$e|1]", label="receive Pid"]; - n_3 -> n_3 [id="[$e|0]", label="receive Pid"]; + n_1 -> n_3 [id="[$e|2]", label="receive Pid"]; + n_3 -> n_3 [id="[$e|1]", label="receive Pid"]; + n_3 -> n_2 [id="[$e|0]", label="send 'Hi, i'm C' to Pid"]; } diff --git a/examples/if-cases/main0_global_view.dot b/examples/if-cases/main0_global_view.dot index 2f9f54b..342301d 100644 --- a/examples/if-cases/main0_global_view.dot +++ b/examples/if-cases/main0_global_view.dot @@ -1,57 +1,73 @@ digraph global { rankdir="LR"; n_0 [label="global", shape="plaintext"]; - n_1 [id="34", shape=circle, label="18"]; - n_2 [id="20", shape=circle, label="10"]; - n_3 [id="27", shape=circle, label="19"]; - n_4 [id="25", shape=circle, label="14"]; - n_5 [id="28", shape=circle, label="6"]; - n_6 [id="12", shape=circle, label="16"]; - n_7 [id="18", shape=circle, label="7"]; - n_8 [id="14", shape=circle, label="9"]; - n_9 [id="6", shape=circle, label="13"]; - n_10 [id="13", shape=circle, label="22"]; - n_11 [id="24", shape=circle, label="8"]; - n_12 [id="10", shape=circle, label="3"]; - n_13 [id="30", shape=circle, label="20"]; - n_14 [id="22", shape=circle, label="5"]; - n_15 [id="1", shape=circle, label="1"]; - n_0 -> n_15 [arrowhead=none]; - n_16 [id="9", shape=circle, label="15"]; - n_17 [id="2", shape=circle, label="23"]; - n_18 [id="4", shape=circle, label="2"]; - n_19 [id="31", shape=circle, label="17"]; - n_20 [id="32", shape=circle, label="4"]; - n_21 [id="7", shape=circle, label="21"]; - n_22 [id="3", shape=circle, label="12"]; - n_23 [id="16", shape=circle, label="11"]; + n_1 [id="33", shape=circle, label="33"]; + n_2 [id="34", shape=circle, label="34"]; + n_3 [id="20", shape=circle, label="20"]; + n_4 [id="27", shape=circle, label="27"]; + n_5 [id="29", shape=circle, label="29"]; + n_6 [id="23", shape=circle, label="23"]; + n_7 [id="25", shape=circle, label="25"]; + n_8 [id="5", shape=circle, label="5"]; + n_9 [id="28", shape=circle, label="28"]; + n_10 [id="15", shape=circle, label="15"]; + n_11 [id="19", shape=circle, label="19"]; + n_12 [id="12", shape=circle, label="12"]; + n_13 [id="11", shape=circle, label="11"]; + n_14 [id="17", shape=circle, label="17"]; + n_15 [id="18", shape=circle, label="18"]; + n_16 [id="14", shape=circle, label="14"]; + n_17 [id="6", shape=circle, label="6"]; + n_18 [id="13", shape=circle, label="13"]; + n_19 [id="24", shape=circle, label="24"]; + n_20 [id="10", shape=circle, label="10"]; + n_21 [id="30", shape=circle, label="30"]; + n_22 [id="22", shape=circle, label="22"]; + n_23 [id="1", shape=circle, label="1"]; + n_0 -> n_23 [arrowhead=none]; + n_24 [id="26", shape=circle, label="26"]; + n_25 [id="9", shape=circle, label="9"]; + n_26 [id="2", shape=circle, label="2"]; + n_27 [id="21", shape=circle, label="21"]; + n_28 [id="8", shape=circle, label="8"]; + n_29 [id="4", shape=circle, label="4"]; + n_30 [id="31", shape=circle, label="31"]; + n_31 [id="32", shape=circle, label="32"]; + n_32 [id="7", shape=circle, label="7"]; + n_33 [id="3", shape=circle, label="3"]; + n_34 [id="16", shape=circle, label="16"]; - n_11 -> n_9 [id="[$e|26]", label="main0/0→b0/0:a0/0"]; - n_13 -> n_17 [id="[$e|51]", label="main0/0→c0/0:a0/0"]; - n_14 -> n_19 [id="[$e|20]", label="main0/0→c0/0:b0/0"]; - n_18 -> n_12 [id="[$e|3]", label="main0/0Δb0/0"]; - n_8 -> n_4 [id="[$e|8]", label="main0/0→b0/0:c0/0"]; - n_23 -> n_17 [id="[$e|41]", label="main0/0→b0/0:c0/0"]; - n_12 -> n_20 [id="[$e|28]", label="main0/0Δc0/0"]; - n_14 -> n_16 [id="[$e|6]", label="main0/0→a0/0:c0/0"]; - n_1 -> n_17 [id="[$e|52]", label="main0/0→b0/0:c0/0"]; - n_2 -> n_3 [id="[$e|12]", label="main0/0→b0/0:a0/0"]; - n_5 -> n_6 [id="[$e|5]", label="main0/0→c0/0:a0/0"]; - n_11 -> n_22 [id="[$e|11]", label="main0/0→c0/0:b0/0"]; - n_9 -> n_17 [id="[$e|42]", label="main0/0→c0/0:b0/0"]; - n_5 -> n_13 [id="[$e|9]", label="main0/0→a0/0:b0/0"]; - n_20 -> n_8 [id="[$e|25]", label="main0/0→a0/0:b0/0"]; - n_2 -> n_10 [id="[$e|1]", label="main0/0→a0/0:c0/0"]; - n_20 -> n_11 [id="[$e|4]", label="main0/0→a0/0:c0/0"]; - n_7 -> n_1 [id="[$e|18]", label="main0/0→a0/0:b0/0"]; - n_8 -> n_23 [id="[$e|13]", label="main0/0→c0/0:a0/0"]; - n_7 -> n_21 [id="[$e|32]", label="main0/0→b0/0:c0/0"]; - n_15 -> n_18 [id="[$e|17]", label="main0/0Δa0/0"]; - n_20 -> n_2 [id="[$e|22]", label="main0/0→c0/0:b0/0"]; - n_20 -> n_7 [id="[$e|0]", label="main0/0→c0/0:a0/0"]; - n_10 -> n_17 [id="[$e|50]", label="main0/0→b0/0:a0/0"]; - n_19 -> n_17 [id="[$e|40]", label="main0/0→a0/0:c0/0"]; - n_20 -> n_5 [id="[$e|29]", label="main0/0→b0/0:c0/0"]; - n_20 -> n_14 [id="[$e|30]", label="main0/0→b0/0:a0/0"]; - n_3 -> n_17 [id="[$e|10]", label="main0/0→a0/0:c0/0"]; + n_34 -> n_9 [id="[$e|26]", label="main0/0→a0/0:b0/0"]; + n_28 -> n_15 [id="[$e|16]", label="main0/0→c0/0:b0/0"]; + n_20 -> n_22 [id="[$e|20]", label="main0/0→b0/0:a0/0"]; + n_29 -> n_8 [id="[$e|3]", label="main0/0→a0/0:b0/0"]; + n_27 -> n_1 [id="[$e|31]", label="main0/0→b0/0:a0/0"]; + n_29 -> n_20 [id="[$e|8]", label="main0/0→c0/0:b0/0"]; + n_33 -> n_29 [id="[$e|2]", label="main0/0Δc0/0"]; + n_32 -> n_34 [id="[$e|14]", label="main0/0→b0/0:c0/0"]; + n_15 -> n_21 [id="[$e|28]", label="main0/0→b0/0:a0/0"]; + n_29 -> n_28 [id="[$e|6]", label="main0/0→a0/0:c0/0"]; + n_17 -> n_16 [id="[$e|12]", label="main0/0→c0/0:a0/0"]; + n_28 -> n_14 [id="[$e|15]", label="main0/0→b0/0:a0/0"]; + n_14 -> n_5 [id="[$e|27]", label="main0/0→c0/0:b0/0"]; + n_29 -> n_32 [id="[$e|5]", label="main0/0→c0/0:a0/0"]; + n_17 -> n_18 [id="[$e|11]", label="main0/0→a0/0:b0/0"]; + n_13 -> n_6 [id="[$e|21]", label="main0/0→c0/0:a0/0"]; + n_8 -> n_13 [id="[$e|9]", label="main0/0→b0/0:c0/0"]; + n_10 -> n_4 [id="[$e|25]", label="main0/0→b0/0:c0/0"]; + n_26 -> n_33 [id="[$e|1]", label="main0/0Δb0/0"]; + n_29 -> n_17 [id="[$e|4]", label="main0/0→b0/0:c0/0"]; + n_25 -> n_3 [id="[$e|18]", label="main0/0→c0/0:b0/0"]; + n_32 -> n_10 [id="[$e|13]", label="main0/0→a0/0:b0/0"]; + n_16 -> n_24 [id="[$e|24]", label="main0/0→a0/0:b0/0"]; + n_22 -> n_2 [id="[$e|32]", label="main0/0→a0/0:c0/0"]; + n_25 -> n_11 [id="[$e|17]", label="main0/0→a0/0:c0/0"]; + n_12 -> n_19 [id="[$e|22]", label="main0/0→b0/0:c0/0"]; + n_23 -> n_26 [id="[$e|0]", label="main0/0Δa0/0"]; + n_18 -> n_7 [id="[$e|23]", label="main0/0→c0/0:a0/0"]; + n_29 -> n_25 [id="[$e|7]", label="main0/0→b0/0:a0/0"]; + n_11 -> n_30 [id="[$e|29]", label="main0/0→c0/0:b0/0"]; + n_20 -> n_27 [id="[$e|19]", label="main0/0→a0/0:c0/0"]; + n_3 -> n_31 [id="[$e|30]", label="main0/0→a0/0:c0/0"]; + n_8 -> n_12 [id="[$e|10]", label="main0/0→c0/0:a0/0"]; } diff --git a/examples/serverclient/README.md b/examples/serverclient/README.md new file mode 100644 index 0000000..4805e0d --- /dev/null +++ b/examples/serverclient/README.md @@ -0,0 +1,24 @@ +# Sever Client example + +## Use + +```bash +./_build/default/bin/chorer ./examples/serverclient/serverclient.erl main0 examples/serverclient +``` + +## Description + +Features: + +- spawn in un ciclo +- passaggio di pid e messaggi + +## Results + +LV e GV corrette con un solo client. + +## Other + +Se si aggiunge nel main un client, il risulato della GV è interessante ma sbagliato. + +Questo è un buon esempio per capire il problema di generalizzare le spawn, come viene affrontato nel paper di riferimento. Cosa dovrei scrivere nella local view se eseguo due volte la spawn di client? nella local view del client quando faccio self() dovrei ritornare client0/N invece che di 0 così nella global view metcha esattamente quello corrente. diff --git a/examples/serverclient/client0_local_view.dot b/examples/serverclient/client0_local_view.dot index 04b0258..5790013 100644 --- a/examples/serverclient/client0_local_view.dot +++ b/examples/serverclient/client0_local_view.dot @@ -1,14 +1,14 @@ digraph client0 { rankdir="LR"; n_0 [label="client0", shape="plaintext"]; - n_1 [id="5", shape=doublecircle, label="4"]; - n_2 [id="1", shape=circle, label="1"]; - n_0 -> n_2 [arrowhead=none]; - n_3 [id="2", shape=circle, label="2"]; + n_1 [id="1", shape=circle, label="1"]; + n_0 -> n_1 [arrowhead=none]; + n_2 [id="2", shape=doublecircle, label="4"]; + n_3 [id="4", shape=circle, label="2"]; n_4 [id="3", shape=circle, label="3"]; - n_4 -> n_1 [id="[$e|1]", label="send done to Handle"]; - n_4 -> n_4 [id="[$e|3]", label="send next to Handle"]; - n_3 -> n_4 [id="[$e|6]", label="receive {res,Handle}"]; - n_2 -> n_3 [id="[$e|2]", label="send {req,pid_self} to server0/0"]; + n_3 -> n_4 [id="[$e|3]", label="receive {res,Handle}"]; + n_4 -> n_4 [id="[$e|7]", label="send next to Handle"]; + n_1 -> n_3 [id="[$e|2]", label="send {req,pid_self} to server0/0"]; + n_4 -> n_2 [id="[$e|5]", label="send done to Handle"]; } diff --git a/examples/serverclient/main0_global_view.dot b/examples/serverclient/main0_global_view.dot index 0e0ee56..2a22c1e 100644 --- a/examples/serverclient/main0_global_view.dot +++ b/examples/serverclient/main0_global_view.dot @@ -1,163 +1,20 @@ digraph global { rankdir="LR"; n_0 [label="global", shape="plaintext"]; - n_1 [id="33", shape=circle, label="33"]; - n_2 [id="34", shape=circle, label="34"]; - n_3 [id="20", shape=circle, label="20"]; - n_4 [id="58", shape=circle, label="58"]; - n_5 [id="57", shape=circle, label="57"]; - n_6 [id="27", shape=circle, label="27"]; - n_7 [id="47", shape=circle, label="47"]; - n_8 [id="29", shape=circle, label="29"]; - n_9 [id="23", shape=circle, label="23"]; - n_10 [id="55", shape=circle, label="55"]; - n_11 [id="25", shape=circle, label="25"]; - n_12 [id="68", shape=circle, label="68"]; - n_13 [id="36", shape=circle, label="36"]; - n_14 [id="5", shape=circle, label="5"]; - n_15 [id="63", shape=circle, label="63"]; - n_16 [id="28", shape=circle, label="28"]; - n_17 [id="64", shape=circle, label="64"]; - n_18 [id="15", shape=circle, label="15"]; - n_19 [id="42", shape=circle, label="42"]; - n_20 [id="19", shape=circle, label="19"]; - n_21 [id="12", shape=circle, label="12"]; - n_22 [id="11", shape=circle, label="11"]; - n_23 [id="17", shape=circle, label="17"]; - n_24 [id="53", shape=circle, label="53"]; - n_25 [id="50", shape=circle, label="50"]; - n_26 [id="62", shape=circle, label="62"]; - n_27 [id="67", shape=circle, label="67"]; - n_28 [id="54", shape=circle, label="54"]; - n_29 [id="18", shape=circle, label="18"]; - n_30 [id="61", shape=circle, label="61"]; - n_31 [id="37", shape=circle, label="37"]; - n_32 [id="51", shape=circle, label="51"]; - n_33 [id="14", shape=circle, label="14"]; - n_34 [id="66", shape=circle, label="66"]; - n_35 [id="6", shape=circle, label="6"]; - n_36 [id="38", shape=circle, label="38"]; - n_37 [id="13", shape=circle, label="13"]; - n_38 [id="24", shape=circle, label="24"]; - n_39 [id="10", shape=circle, label="10"]; - n_40 [id="43", shape=circle, label="43"]; - n_41 [id="30", shape=circle, label="30"]; - n_42 [id="59", shape=circle, label="59"]; - n_43 [id="40", shape=circle, label="40"]; - n_44 [id="22", shape=circle, label="22"]; - n_45 [id="65", shape=circle, label="65"]; - n_46 [id="39", shape=circle, label="39"]; - n_47 [id="60", shape=circle, label="60"]; - n_48 [id="1", shape=circle, label="1"]; - n_0 -> n_48 [arrowhead=none]; - n_49 [id="45", shape=circle, label="45"]; - n_50 [id="26", shape=circle, label="26"]; - n_51 [id="9", shape=circle, label="9"]; - n_52 [id="2", shape=circle, label="2"]; - n_53 [id="21", shape=circle, label="21"]; - n_54 [id="44", shape=circle, label="44"]; - n_55 [id="46", shape=circle, label="46"]; - n_56 [id="8", shape=circle, label="8"]; - n_57 [id="48", shape=circle, label="48"]; - n_58 [id="4", shape=circle, label="4"]; - n_59 [id="35", shape=circle, label="35"]; - n_60 [id="31", shape=circle, label="31"]; - n_61 [id="32", shape=circle, label="32"]; - n_62 [id="41", shape=circle, label="41"]; - n_63 [id="7", shape=circle, label="7"]; - n_64 [id="3", shape=circle, label="3"]; - n_65 [id="52", shape=circle, label="52"]; - n_66 [id="56", shape=circle, label="56"]; - n_67 [id="49", shape=circle, label="49"]; - n_68 [id="16", shape=circle, label="16"]; + n_1 [id="5", shape=circle, label="5"]; + n_2 [id="6", shape=circle, label="6"]; + n_3 [id="1", shape=circle, label="1"]; + n_0 -> n_3 [arrowhead=none]; + n_4 [id="2", shape=circle, label="2"]; + n_5 [id="4", shape=circle, label="4"]; + n_6 [id="7", shape=circle, label="7"]; + n_7 [id="3", shape=circle, label="3"]; - n_9 -> n_36 [id="[$e|39]", label="client0/1→handle_req1/0:done"]; - n_56 -> n_37 [id="[$e|11]", label="server0/0Δhandle_req1/0"]; - n_45 -> n_12 [id="[$e|85]", label="client0/0→handle_req1/0:done"]; - n_53 -> n_17 [id="[$e|77]", label="server0/0Δhandle_req1/0"]; - n_61 -> n_32 [id="[$e|55]", label="client0/1→handle_req1/0:done"]; - n_10 -> n_10 [id="[$e|84]", label="client0/0→handle_req1/0:next"]; - n_33 -> n_38 [id="[$e|22]", label="client0/0→handle_req1/0:done"]; - n_61 -> n_61 [id="[$e|75]", label="client0/0→handle_req1/0:next"]; - n_58 -> n_35 [id="[$e|4]", label="client0/1→server0/0:{req,pid_self}"]; - n_30 -> n_30 [id="[$e|87]", label="client0/1→handle_req1/0:next"]; - n_38 -> n_46 [id="[$e|40]", label="server0/0→client0/1:{res,handle_req1/0}"]; - n_9 -> n_9 [id="[$e|64]", label="client0/1→handle_req1/0:next"]; - n_11 -> n_11 [id="[$e|66]", label="client0/0→handle_req1/0:next"]; - n_1 -> n_24 [id="[$e|57]", label="server0/0→client0/0:{res,handle_req1/0}"]; - n_3 -> n_3 [id="[$e|54]", label="client0/1→handle_req1/0:next"]; - n_41 -> n_67 [id="[$e|52]", label="client0/1→handle_req1/0:done"]; - n_52 -> n_64 [id="[$e|1]", label="main0/0Δclient0/0"]; - n_50 -> n_19 [id="[$e|44]", label="server0/0→client0/0:{res,handle_req1/0}"]; - n_28 -> n_10 [id="[$e|59]", label="server0/0→client0/0:{res,handle_req1/0}"]; - n_58 -> n_14 [id="[$e|3]", label="client0/0→server0/0:{req,pid_self}"]; - n_29 -> n_20 [id="[$e|17]", label="server0/0→client0/0:{res,handle_req1/0}"]; - n_41 -> n_41 [id="[$e|72]", label="client0/0→handle_req1/0:next"]; - n_45 -> n_45 [id="[$e|88]", label="client0/0→handle_req1/0:next"]; - n_59 -> n_66 [id="[$e|60]", label="client0/0→handle_req1/0:done"]; - n_68 -> n_6 [id="[$e|26]", label="server0/0Δhandle_req1/0"]; - n_3 -> n_61 [id="[$e|31]", label="server0/0→client0/0:{res,handle_req1/0}"]; - n_29 -> n_3 [id="[$e|18]", label="server0/0→client0/1:{res,handle_req1/0}"]; - n_40 -> n_54 [id="[$e|46]", label="server0/0→client0/1:{res,handle_req1/0}"]; - n_11 -> n_11 [id="[$e|65]", label="client0/1→handle_req1/0:next"]; - n_35 -> n_39 [id="[$e|8]", label="server0/0Δhandle_req1/0"]; - n_10 -> n_15 [id="[$e|76]", label="client0/0→handle_req1/0:done"]; - n_9 -> n_9 [id="[$e|63]", label="client0/0→handle_req1/0:next"]; - n_41 -> n_57 [id="[$e|51]", label="client0/0→handle_req1/0:done"]; - n_39 -> n_22 [id="[$e|9]", label="client0/0→server0/0:{req,pid_self}"]; - n_18 -> n_18 [id="[$e|41]", label="client0/1→handle_req1/0:next"]; - n_23 -> n_8 [id="[$e|28]", label="client0/1→server0/0:{req,pid_self}"]; - n_37 -> n_33 [id="[$e|12]", label="server0/0→client0/0:{res,handle_req1/0}"]; - n_47 -> n_30 [id="[$e|69]", label="server0/0→client0/1:{res,handle_req1/0}"]; - n_61 -> n_61 [id="[$e|74]", label="client0/1→handle_req1/0:next"]; - n_37 -> n_18 [id="[$e|13]", label="server0/0→client0/1:{res,handle_req1/0}"]; - n_63 -> n_56 [id="[$e|6]", label="client0/1→server0/0:{req,pid_self}"]; - n_60 -> n_25 [id="[$e|53]", label="server0/0→client0/1:{res,handle_req1/0}"]; - n_63 -> n_51 [id="[$e|7]", label="server0/0→client0/0:{res,handle_req1/0}"]; - n_51 -> n_68 [id="[$e|14]", label="client0/1→server0/0:{req,pid_self}"]; - n_5 -> n_4 [id="[$e|62]", label="server0/0→client0/0:{res,handle_req1/0}"]; - n_8 -> n_55 [id="[$e|48]", label="server0/0Δhandle_req1/0"]; - n_16 -> n_49 [id="[$e|47]", label="client0/1→handle_req1/0:done"]; - n_11 -> n_62 [id="[$e|43]", label="client0/0→handle_req1/0:done"]; - n_68 -> n_40 [id="[$e|45]", label="server0/0Δhandle_req1/0"]; - n_21 -> n_44 [id="[$e|20]", label="client0/1→handle_req1/0:done"]; - n_20 -> n_60 [id="[$e|30]", label="client0/0→handle_req1/0:done"]; - n_33 -> n_9 [id="[$e|21]", label="server0/0→client0/1:{res,handle_req1/0}"]; - n_59 -> n_59 [id="[$e|79]", label="client0/0→handle_req1/0:next"]; - n_20 -> n_20 [id="[$e|50]", label="client0/0→handle_req1/0:next"]; - n_6 -> n_16 [id="[$e|27]", label="server0/0→client0/1:{res,handle_req1/0}"]; - n_48 -> n_52 [id="[$e|0]", label="main0/0Δserver0/0"]; - n_61 -> n_65 [id="[$e|56]", label="client0/0→handle_req1/0:done"]; - n_4 -> n_4 [id="[$e|86]", label="client0/0→handle_req1/0:next"]; - n_21 -> n_53 [id="[$e|19]", label="client0/0→server0/0:{req,pid_self}"]; - n_18 -> n_50 [id="[$e|24]", label="client0/1→handle_req1/0:done"]; - n_22 -> n_29 [id="[$e|16]", label="server0/0Δhandle_req1/0"]; - n_51 -> n_23 [id="[$e|15]", label="client0/0→handle_req1/0:done"]; - n_7 -> n_7 [id="[$e|83]", label="client0/1→handle_req1/0:next"]; - n_51 -> n_51 [id="[$e|25]", label="client0/0→handle_req1/0:next"]; - n_53 -> n_28 [id="[$e|58]", label="server0/0Δhandle_req1/0"]; - n_3 -> n_1 [id="[$e|32]", label="client0/1→handle_req1/0:done"]; - n_64 -> n_58 [id="[$e|2]", label="main0/0Δclient0/1"]; - n_9 -> n_31 [id="[$e|38]", label="client0/0→handle_req1/0:done"]; - n_20 -> n_41 [id="[$e|29]", label="server0/0→client0/1:{res,handle_req1/0}"]; - n_4 -> n_34 [id="[$e|80]", label="client0/0→handle_req1/0:done"]; - n_68 -> n_47 [id="[$e|68]", label="server0/0Δhandle_req1/0"]; - n_13 -> n_5 [id="[$e|61]", label="server0/0Δhandle_req1/0"]; - n_11 -> n_43 [id="[$e|42]", label="client0/1→handle_req1/0:done"]; - n_14 -> n_63 [id="[$e|5]", label="server0/0Δhandle_req1/0"]; - n_16 -> n_16 [id="[$e|70]", label="client0/1→handle_req1/0:next"]; - n_54 -> n_42 [id="[$e|67]", label="client0/1→handle_req1/0:done"]; - n_39 -> n_21 [id="[$e|10]", label="server0/0→client0/1:{res,handle_req1/0}"]; - n_33 -> n_33 [id="[$e|37]", label="client0/0→handle_req1/0:next"]; - n_44 -> n_13 [id="[$e|36]", label="client0/0→server0/0:{req,pid_self}"]; - n_41 -> n_41 [id="[$e|73]", label="client0/1→handle_req1/0:next"]; - n_30 -> n_27 [id="[$e|82]", label="client0/1→handle_req1/0:done"]; - n_18 -> n_11 [id="[$e|23]", label="server0/0→client0/0:{res,handle_req1/0}"]; - n_55 -> n_7 [id="[$e|49]", label="server0/0→client0/1:{res,handle_req1/0}"]; - n_53 -> n_2 [id="[$e|34]", label="server0/0Δhandle_req1/0"]; - n_54 -> n_54 [id="[$e|81]", label="client0/1→handle_req1/0:next"]; - n_2 -> n_59 [id="[$e|35]", label="server0/0→client0/0:{res,handle_req1/0}"]; - n_7 -> n_26 [id="[$e|71]", label="client0/1→handle_req1/0:done"]; - n_21 -> n_21 [id="[$e|33]", label="client0/1→handle_req1/0:next"]; - n_17 -> n_45 [id="[$e|78]", label="server0/0→client0/0:{res,handle_req1/0}"]; + n_1 -> n_2 [id="[$e|4]", label="server0/0→client0/0:{res,handle_req1/0}"]; + n_4 -> n_7 [id="[$e|1]", label="main0/0Δclient0/0"]; + n_5 -> n_1 [id="[$e|3]", label="server0/0Δhandle_req1/0"]; + n_2 -> n_2 [id="[$e|6]", label="client0/0→handle_req1/0:next"]; + n_3 -> n_4 [id="[$e|0]", label="main0/0Δserver0/0"]; + n_7 -> n_5 [id="[$e|2]", label="client0/0→server0/0:{req,pid_self}"]; + n_2 -> n_6 [id="[$e|5]", label="client0/0→handle_req1/0:done"]; } diff --git a/examples/serverclient/main0_local_view.dot b/examples/serverclient/main0_local_view.dot index efaf4c1..c42704a 100644 --- a/examples/serverclient/main0_local_view.dot +++ b/examples/serverclient/main0_local_view.dot @@ -4,10 +4,8 @@ digraph main0 { n_1 [id="1", shape=circle, label="1"]; n_0 -> n_1 [arrowhead=none]; n_2 [id="2", shape=circle, label="2"]; - n_3 [id="4", shape=circle, label="3"]; - n_4 [id="3", shape=doublecircle, label="4"]; + n_3 [id="3", shape=doublecircle, label="3"]; - n_3 -> n_4 [id="[$e|1]", label="spawn client0/1"]; + n_2 -> n_3 [id="[$e|1]", label="spawn client0/0"]; n_1 -> n_2 [id="[$e|0]", label="spawn server0/0"]; - n_2 -> n_3 [id="[$e|2]", label="spawn client0/0"]; } diff --git a/examples/serverclient/serverclient.erl b/examples/serverclient/serverclient.erl index 97933ad..21c2408 100644 --- a/examples/serverclient/serverclient.erl +++ b/examples/serverclient/serverclient.erl @@ -38,5 +38,4 @@ main() -> S = spawn(?MODULE, server, []), register(server, S), spawn(?MODULE, client, []), - spawn(?MODULE, client, []), done. diff --git a/examples/test/foo3/test0_global_view.dot b/examples/test/foo3/test0_global_view.dot index 8b23dbc..7900a27 100644 --- a/examples/test/foo3/test0_global_view.dot +++ b/examples/test/foo3/test0_global_view.dot @@ -1,11 +1,36 @@ digraph global { rankdir="LR"; n_0 [label="global", shape="plaintext"]; - n_1 [id="1", shape=circle, label="1"]; - n_0 -> n_1 [arrowhead=none]; - n_2 [id="2", shape=circle, label="2"]; - n_3 [id="3", shape=circle, label="3"]; + n_1 [id="15", shape=circle, label="4"]; + n_2 [id="12", shape=circle, label="8"]; + n_3 [id="11", shape=circle, label="9"]; + n_4 [id="17", shape=circle, label="6"]; + n_5 [id="14", shape=circle, label="10"]; + n_6 [id="6", shape=circle, label="3"]; + n_7 [id="13", shape=circle, label="12"]; + n_8 [id="10", shape=circle, label="11"]; + n_9 [id="1", shape=circle, label="1"]; + n_0 -> n_9 [arrowhead=none]; + n_10 [id="9", shape=circle, label="7"]; + n_11 [id="2", shape=circle, label="13"]; + n_12 [id="8", shape=circle, label="5"]; + n_13 [id="3", shape=circle, label="2"]; - n_1 -> n_2 [id="[$e|0]", label="test0/0Δa1/0"]; - n_2 -> n_3 [id="[$e|1]", label="test0/0Δb1/0"]; + n_7 -> n_11 [id="[$e|22]", label="a1/0→test0/0:3"]; + n_1 -> n_10 [id="[$e|0]", label="a1/0→test0/0:3"]; + n_10 -> n_11 [id="[$e|8]", label="a1/0→test0/0:1"]; + n_5 -> n_11 [id="[$e|19]", label="a1/0→test0/0:3"]; + n_3 -> n_11 [id="[$e|23]", label="a1/0→test0/0:1"]; + n_6 -> n_12 [id="[$e|7]", label="a1/0→test0/0:3"]; + n_6 -> n_1 [id="[$e|11]", label="b1/0→test0/0:2"]; + n_4 -> n_8 [id="[$e|1]", label="a1/0→test0/0:3"]; + n_1 -> n_5 [id="[$e|2]", label="a1/0→test0/0:1"]; + n_2 -> n_11 [id="[$e|20]", label="b1/0→test0/0:2"]; + n_12 -> n_2 [id="[$e|4]", label="a1/0→test0/0:1"]; + n_8 -> n_11 [id="[$e|21]", label="b1/0→test0/0:2"]; + n_4 -> n_7 [id="[$e|9]", label="b1/0→test0/0:2"]; + n_9 -> n_13 [id="[$e|6]", label="test0/0Δa1/0"]; + n_12 -> n_3 [id="[$e|13]", label="b1/0→test0/0:2"]; + n_6 -> n_4 [id="[$e|5]", label="a1/0→test0/0:1"]; + n_13 -> n_6 [id="[$e|16]", label="test0/0Δb1/0"]; } diff --git a/examples/test/foo6/README.md b/examples/test/foo6/README.md new file mode 100644 index 0000000..311ffcf --- /dev/null +++ b/examples/test/foo6/README.md @@ -0,0 +1,18 @@ +# Foo6 example + +## Use + +```bash +./_build/default/bin/chorer ./examples/test/foo6/foo6.erl test0 examples/test/foo6 +``` + +## Description + +Features: + +- two definitions for client_gen +- multiple variable argument passing + +## Results + +Correct LV. Wrong GV. diff --git a/examples/test/foo6/foo6.erl b/examples/test/foo6/foo6.erl index 1db24bc..74a1dfd 100644 --- a/examples/test/foo6/foo6.erl +++ b/examples/test/foo6/foo6.erl @@ -1,23 +1,24 @@ -module(foo6). --export([test/0,client_server/1,server/0,client_gen/2,client/1]). +-export([test/0, client_server/1, server/0, client_gen/2, client/1]). -test() -> +test() -> client_server(5). client_server(N) -> - S = spawn(foo6,server,[]), - client_gen(S,N). + S = spawn(foo6, server, []), + client_gen(S, N). server() -> - receive + receive X -> X end, server(). -client_gen(S,1) -> - spawn(foo6,client,[S]); -client_gen(S,N) -> - spawn(foo6,client,[S]). +client_gen(S, 1) -> + spawn(foo6, client, [S]); +client_gen(S, N) -> + spawn(foo6, client, [S]), + client_gen(S, N - 1). client(S) -> - S ! hello. \ No newline at end of file + S ! hello. diff --git a/examples/test/foo6/test0_global_view.dot b/examples/test/foo6/test0_global_view.dot index e3c0c96..2293cd2 100644 --- a/examples/test/foo6/test0_global_view.dot +++ b/examples/test/foo6/test0_global_view.dot @@ -1,12 +1,19 @@ digraph global { rankdir="LR"; n_0 [label="global", shape="plaintext"]; - n_1 [id="1", shape=circle, label="1"]; - n_0 -> n_1 [arrowhead=none]; - n_2 [id="2", shape=circle, label="2"]; - n_3 [id="3", shape=circle, label="3"]; + n_1 [id="5", shape=circle, label="5"]; + n_2 [id="6", shape=circle, label="6"]; + n_3 [id="1", shape=circle, label="1"]; + n_0 -> n_3 [arrowhead=none]; + n_4 [id="2", shape=circle, label="2"]; + n_5 [id="4", shape=circle, label="4"]; + n_6 [id="7", shape=circle, label="7"]; + n_7 [id="3", shape=circle, label="3"]; - n_2 -> n_3 [id="[$e|3]", label="test0/0Δclient1/0"]; - n_2 -> n_3 [id="[$e|1]", label="test0/0Δclient1/1"]; - n_1 -> n_2 [id="[$e|0]", label="test0/0Δserver0/0"]; + n_5 -> n_1 [id="[$e|3]", label="test0/0Δclient1/0"]; + n_4 -> n_5 [id="[$e|2]", label="test0/0Δclient1/1"]; + n_2 -> n_6 [id="[$e|5]", label="test0/0Δclient1/0"]; + n_4 -> n_7 [id="[$e|1]", label="test0/0Δclient1/0"]; + n_5 -> n_2 [id="[$e|4]", label="test0/0Δclient1/1"]; + n_3 -> n_4 [id="[$e|0]", label="test0/0Δserver0/0"]; } diff --git a/examples/test/foo6/test0_local_view.dot b/examples/test/foo6/test0_local_view.dot index 05b8ce2..d60f0cd 100644 --- a/examples/test/foo6/test0_local_view.dot +++ b/examples/test/foo6/test0_local_view.dot @@ -6,7 +6,7 @@ digraph test0 { n_2 [id="2", shape=circle, label="2"]; n_3 [id="3", shape=doublecircle, label="3"]; - n_2 -> n_3 [id="[$e|2]", label="spawn client1/0"]; - n_1 -> n_2 [id="[$e|1]", label="spawn server0/0"]; - n_2 -> n_3 [id="[$e|0]", label="spawn client1/1"]; + n_2 -> n_3 [id="[$e|3]", label="spawn client1/0"]; + n_1 -> n_2 [id="[$e|5]", label="spawn server0/0"]; + n_2 -> n_2 [id="[$e|4]", label="spawn client1/1"]; } diff --git a/examples/test/ping/README.md b/examples/test/ping/README.md new file mode 100644 index 0000000..b4ef3cc --- /dev/null +++ b/examples/test/ping/README.md @@ -0,0 +1,18 @@ +# Ping example + +## Use + +```bash +./_build/default/bin/chorer ./examples/test/ping/ping.erl start0 examples/test/ping +``` + +## Description + +Features: + +- complex variable argument passing +- complex send and recv + +## Results + +Wrong LV and GV \ No newline at end of file diff --git a/examples/test/ping/start0_global_view.dot b/examples/test/ping/start0_global_view.dot index f571c10..1df8ff2 100644 --- a/examples/test/ping/start0_global_view.dot +++ b/examples/test/ping/start0_global_view.dot @@ -6,6 +6,6 @@ digraph global { n_2 [id="2", shape=circle, label="2"]; n_3 [id="3", shape=circle, label="3"]; - n_2 -> n_3 [id="[$e|0]", label="start0/0→start0/0:3"]; - n_1 -> n_2 [id="[$e|1]", label="start0/0Δpong0/0"]; + n_1 -> n_2 [id="[$e|0]", label="start0/0Δpong0/0"]; + n_2 -> n_3 [id="[$e|1]", label="start0/0→start0/0:3"]; } diff --git a/examples/test/ping/start0_local_view.dot b/examples/test/ping/start0_local_view.dot index b7fb69d..add592f 100644 --- a/examples/test/ping/start0_local_view.dot +++ b/examples/test/ping/start0_local_view.dot @@ -1,16 +1,16 @@ digraph start0 { rankdir="LR"; n_0 [label="start0", shape="plaintext"]; - n_1 [id="5", shape=circle, label="5"]; - n_2 [id="6", shape=doublecircle, label="4"]; + n_1 [id="5", shape=doublecircle, label="5"]; + n_2 [id="6", shape=circle, label="4"]; n_3 [id="1", shape=circle, label="1"]; n_0 -> n_3 [arrowhead=none]; n_4 [id="2", shape=circle, label="2"]; n_5 [id="3", shape=circle, label="3"]; - n_5 -> n_2 [id="[$e|4]", label="receive kill"]; - n_5 -> n_1 [id="[$e|6]", label="receive N"]; - n_1 -> n_5 [id="[$e|2]", label="send {pid_self,pid_self} to Pong"]; + n_2 -> n_5 [id="[$e|3]", label="send {pid_self,pid_self} to Pong"]; + n_5 -> n_2 [id="[$e|4]", label="receive N"]; + n_5 -> n_1 [id="[$e|0]", label="receive kill"]; n_3 -> n_4 [id="[$e|1]", label="spawn pong0/0"]; n_4 -> n_5 [id="[$e|7]", label="send 3 to pid_self"]; } diff --git a/examples/ticktackloop/README.md b/examples/ticktackloop/README.md new file mode 100644 index 0000000..6202b1d --- /dev/null +++ b/examples/ticktackloop/README.md @@ -0,0 +1,17 @@ +# Tick tack loop example + +## Use + +```bash +./_build/default/bin/chorer ./examples/ticktackloop/tictacloop.erl start0 examples/ticktackloop +``` + +## Description + +Features: + +- loop di scambi di messaggi nella GV + +## Results + +LV e GV corrette. \ No newline at end of file diff --git a/examples/ticktackloop/start0_global_view.dot b/examples/ticktackloop/start0_global_view.dot index f0ab167..c6af126 100644 --- a/examples/ticktackloop/start0_global_view.dot +++ b/examples/ticktackloop/start0_global_view.dot @@ -1,16 +1,16 @@ digraph global { rankdir="LR"; n_0 [label="global", shape="plaintext"]; - n_1 [id="5", shape=circle, label="4"]; + n_1 [id="5", shape=circle, label="5"]; n_2 [id="1", shape=circle, label="1"]; n_0 -> n_2 [arrowhead=none]; n_3 [id="2", shape=circle, label="2"]; - n_4 [id="4", shape=circle, label="5"]; + n_4 [id="4", shape=circle, label="4"]; n_5 [id="3", shape=circle, label="3"]; - n_3 -> n_5 [id="[$e|3]", label="start0/0Δtic_loop0/0"]; - n_2 -> n_3 [id="[$e|2]", label="start0/0Δtac_loop0/0"]; - n_1 -> n_4 [id="[$e|1]", label="tic_loop0/0→tac_loop0/0:tic"]; - n_5 -> n_1 [id="[$e|4]", label="start0/0→tic_loop0/0:tac"]; - n_4 -> n_1 [id="[$e|0]", label="tac_loop0/0→tic_loop0/0:tac"]; + n_4 -> n_1 [id="[$e|3]", label="tic_loop0/0→tac_loop0/0:tic"]; + n_5 -> n_4 [id="[$e|2]", label="start0/0→tic_loop0/0:tac"]; + n_3 -> n_5 [id="[$e|1]", label="start0/0Δtic_loop0/0"]; + n_1 -> n_4 [id="[$e|4]", label="tac_loop0/0→tic_loop0/0:tac"]; + n_2 -> n_3 [id="[$e|0]", label="start0/0Δtac_loop0/0"]; } diff --git a/examples/ticktackloop/start0_local_view.dot b/examples/ticktackloop/start0_local_view.dot index b3ae192..16180a2 100644 --- a/examples/ticktackloop/start0_local_view.dot +++ b/examples/ticktackloop/start0_local_view.dot @@ -7,7 +7,7 @@ digraph start0 { n_3 [id="4", shape=circle, label="2"]; n_4 [id="3", shape=doublecircle, label="4"]; - n_1 -> n_3 [id="[$e|2]", label="spawn tac_loop0/0"]; - n_2 -> n_4 [id="[$e|1]", label="send tac to tic_loop0/0"]; - n_3 -> n_2 [id="[$e|0]", label="spawn tic_loop0/0"]; + n_3 -> n_2 [id="[$e|2]", label="spawn tic_loop0/0"]; + n_1 -> n_3 [id="[$e|1]", label="spawn tac_loop0/0"]; + n_2 -> n_4 [id="[$e|0]", label="send tac to tic_loop0/0"]; } diff --git a/examples/ticktackstop/README.md b/examples/ticktackstop/README.md new file mode 100644 index 0000000..2a5cc09 --- /dev/null +++ b/examples/ticktackstop/README.md @@ -0,0 +1,17 @@ +# Tick tack stop example + +## Use + +```bash +./_build/default/bin/chorer ./examples/ticktackloop/tictacloop.erl start0 examples/ticktackloop +``` + +## Description + +Features: + +- aggiunta di un processo che ferma randomicamente il loop di messaggi + +## Results + +LV corrette, nella GV dovrebbe riapparire il loop ma così non avviene. \ No newline at end of file diff --git a/examples/ticktackstop/start0_global_view.dot b/examples/ticktackstop/start0_global_view.dot index 70b9fbd..aaa3ac7 100644 --- a/examples/ticktackstop/start0_global_view.dot +++ b/examples/ticktackstop/start0_global_view.dot @@ -2,19 +2,29 @@ digraph global { rankdir="LR"; n_0 [label="global", shape="plaintext"]; n_1 [id="5", shape=circle, label="6"]; - n_2 [id="1", shape=circle, label="1"]; - n_0 -> n_2 [arrowhead=none]; - n_3 [id="2", shape=circle, label="2"]; - n_4 [id="8", shape=circle, label="4"]; - n_5 [id="4", shape=circle, label="5"]; - n_6 [id="7", shape=circle, label="7"]; - n_7 [id="3", shape=circle, label="3"]; + n_2 [id="12", shape=circle, label="5"]; + n_3 [id="11", shape=circle, label="11"]; + n_4 [id="14", shape=circle, label="4"]; + n_5 [id="10", shape=circle, label="9"]; + n_6 [id="1", shape=circle, label="1"]; + n_0 -> n_6 [arrowhead=none]; + n_7 [id="2", shape=circle, label="2"]; + n_8 [id="8", shape=circle, label="10"]; + n_9 [id="4", shape=circle, label="7"]; + n_10 [id="7", shape=circle, label="8"]; + n_11 [id="3", shape=circle, label="3"]; - n_2 -> n_3 [id="[$e|3]", label="start0/0Δtac_loop0/0"]; - n_4 -> n_6 [id="[$e|1]", label="random0/0→tic_loop0/0:stop"]; - n_5 -> n_1 [id="[$e|6]", label="tic_loop0/0→tac_loop0/0:tic"]; - n_7 -> n_4 [id="[$e|4]", label="start0/0Δrandom0/0"]; - n_6 -> n_1 [id="[$e|7]", label="tic_loop0/0→tac_loop0/0:stop"]; - n_3 -> n_7 [id="[$e|5]", label="start0/0Δtic_loop0/0"]; - n_7 -> n_5 [id="[$e|0]", label="start0/0→tic_loop0/0:tac"]; + n_7 -> n_11 [id="[$e|11]", label="start0/0Δtic_loop0/0"]; + n_1 -> n_10 [id="[$e|12]", label="tic_loop0/0→tac_loop0/0:tic"]; + n_6 -> n_7 [id="[$e|8]", label="start0/0Δtac_loop0/0"]; + n_10 -> n_8 [id="[$e|1]", label="random0/0→tic_loop0/0:stop"]; + n_1 -> n_5 [id="[$e|6]", label="random0/0→tic_loop0/0:stop"]; + n_5 -> n_9 [id="[$e|14]", label="tic_loop0/0→tac_loop0/0:stop"]; + n_3 -> n_9 [id="[$e|7]", label="tic_loop0/0→tac_loop0/0:stop"]; + n_2 -> n_9 [id="[$e|16]", label="tic_loop0/0→tac_loop0/0:stop"]; + n_4 -> n_2 [id="[$e|2]", label="random0/0→tic_loop0/0:stop"]; + n_4 -> n_1 [id="[$e|5]", label="start0/0→tic_loop0/0:tac"]; + n_8 -> n_9 [id="[$e|15]", label="tic_loop0/0→tac_loop0/0:stop"]; + n_11 -> n_4 [id="[$e|9]", label="start0/0Δrandom0/0"]; + n_5 -> n_3 [id="[$e|10]", label="tic_loop0/0→tac_loop0/0:tic"]; } diff --git a/examples/ticktackstop/start0_local_view.dot b/examples/ticktackstop/start0_local_view.dot index 16de98a..2f9039c 100644 --- a/examples/ticktackstop/start0_local_view.dot +++ b/examples/ticktackstop/start0_local_view.dot @@ -1,14 +1,15 @@ digraph start0 { rankdir="LR"; n_0 [label="start0", shape="plaintext"]; - n_1 [id="5", shape=circle, label="2"]; + n_1 [id="5", shape=circle, label="3"]; n_2 [id="1", shape=circle, label="1"]; n_0 -> n_2 [arrowhead=none]; - n_3 [id="2", shape=circle, label="3"]; - n_4 [id="3", shape=doublecircle, label="4"]; + n_3 [id="2", shape=circle, label="4"]; + n_4 [id="4", shape=doublecircle, label="5"]; + n_5 [id="3", shape=circle, label="2"]; - n_3 -> n_4 [id="[$e|1]", label="send tac to tic_loop0/0"]; - n_3 -> n_4 [id="[$e|4]", label="spawn random0/0"]; - n_2 -> n_1 [id="[$e|2]", label="spawn tac_loop0/0"]; - n_1 -> n_3 [id="[$e|0]", label="spawn tic_loop0/0"]; + n_3 -> n_4 [id="[$e|3]", label="send tac to tic_loop0/0"]; + n_1 -> n_3 [id="[$e|1]", label="spawn random0/0"]; + n_2 -> n_5 [id="[$e|2]", label="spawn tac_loop0/0"]; + n_5 -> n_1 [id="[$e|0]", label="spawn tic_loop0/0"]; } diff --git a/examples/trick/README.md b/examples/trick/README.md new file mode 100644 index 0000000..3211a41 --- /dev/null +++ b/examples/trick/README.md @@ -0,0 +1,23 @@ +# Tick tack stop example + +## Use + +```bash +./_build/default/bin/chorer ./examples/trick/trick.erl main0 examples/trick +``` + +## Description + +Features: + +- numerose register +- scambi di messaggi asincroni +- match funzionante, rende alcuni messaggi dangling + +## Results + +LV e GV corrette. + +## Other + +In trick2, si può vedere come mettendo _ alle linee 15 e 18 aggiunge transizioni nella GV. \ No newline at end of file diff --git a/examples/trick/main0_global_view.dot b/examples/trick/main0_global_view.dot index 638d9da..7e99862 100644 --- a/examples/trick/main0_global_view.dot +++ b/examples/trick/main0_global_view.dot @@ -1,24 +1,25 @@ digraph global { rankdir="LR"; n_0 [label="global", shape="plaintext"]; - n_1 [id="5", shape=circle, label="7"]; - n_2 [id="6", shape=circle, label="9"]; - n_3 [id="10", shape=circle, label="4"]; + n_1 [id="5", shape=circle, label="5"]; + n_2 [id="6", shape=circle, label="6"]; + n_3 [id="10", shape=circle, label="10"]; n_4 [id="1", shape=circle, label="1"]; n_0 -> n_4 [arrowhead=none]; - n_5 [id="9", shape=circle, label="5"]; + n_5 [id="9", shape=circle, label="9"]; n_6 [id="2", shape=circle, label="2"]; n_7 [id="8", shape=circle, label="8"]; - n_8 [id="4", shape=circle, label="6"]; - n_9 [id="3", shape=circle, label="3"]; + n_8 [id="4", shape=circle, label="4"]; + n_9 [id="7", shape=circle, label="7"]; + n_10 [id="3", shape=circle, label="3"]; - n_4 -> n_6 [id="[$e|3]", label="main0/0Δa0/0"]; - n_3 -> n_8 [id="[$e|8]", label="a0/0→b0/0:v2"]; - n_3 -> n_5 [id="[$e|2]", label="a0/0→c0/0:v1"]; - n_8 -> n_1 [id="[$e|6]", label="a0/0→c0/0:v1"]; - n_9 -> n_3 [id="[$e|5]", label="main0/0Δc0/0"]; - n_1 -> n_2 [id="[$e|9]", label="b0/0→c0/0:v2"]; - n_6 -> n_9 [id="[$e|1]", label="main0/0Δb0/0"]; - n_7 -> n_2 [id="[$e|4]", label="b0/0→c0/0:v2"]; - n_5 -> n_7 [id="[$e|0]", label="a0/0→b0/0:v2"]; + n_8 -> n_1 [id="[$e|3]", label="a0/0→b0/0:v2"]; + n_7 -> n_3 [id="[$e|8]", label="b0/0→c0/0:v2"]; + n_10 -> n_8 [id="[$e|2]", label="main0/0Δc0/0"]; + n_2 -> n_7 [id="[$e|6]", label="a0/0→b0/0:v2"]; + n_1 -> n_9 [id="[$e|5]", label="a0/0→c0/0:v1"]; + n_6 -> n_10 [id="[$e|1]", label="main0/0Δb0/0"]; + n_8 -> n_2 [id="[$e|4]", label="a0/0→c0/0:v1"]; + n_4 -> n_6 [id="[$e|0]", label="main0/0Δa0/0"]; + n_9 -> n_5 [id="[$e|7]", label="b0/0→c0/0:v2"]; } diff --git a/examples/violation/README.md b/examples/violation/README.md new file mode 100644 index 0000000..9a59fd7 --- /dev/null +++ b/examples/violation/README.md @@ -0,0 +1,17 @@ +# Violation example + +## Use + +```bash +./_build/default/bin/chorer ./examples/violation/meViolation.erl main0 examples/violation +``` + +## Description + +Features: + +- complex program that shows mutual exclusion violation + +## Results + +Hard to know. diff --git a/examples/violation/incrementer0_local_view.dot b/examples/violation/incrementer0_local_view.dot new file mode 100644 index 0000000..dd42aae --- /dev/null +++ b/examples/violation/incrementer0_local_view.dot @@ -0,0 +1,19 @@ +digraph incrementer0 { + rankdir="LR"; + n_0 [label="incrementer0", shape="plaintext"]; + n_1 [id="5", shape=doublecircle, label="7"]; + n_2 [id="6", shape=circle, label="5"]; + n_3 [id="1", shape=circle, label="1"]; + n_0 -> n_3 [arrowhead=none]; + n_4 [id="2", shape=circle, label="2"]; + n_5 [id="4", shape=circle, label="6"]; + n_6 [id="7", shape=circle, label="3"]; + n_7 [id="3", shape=circle, label="4"]; + + n_7 -> n_2 [id="[$e|2]", label="receive X"]; + n_6 -> n_7 [id="[$e|3]", label="send {read,pid_self} to varManager1/0"]; + n_4 -> n_6 [id="[$e|0]", label="receive answer"]; + n_5 -> n_1 [id="[$e|1]", label="send {release} to meManager0/0"]; + n_2 -> n_5 [id="[$e|5]", label="send {write,write} to varManager1/0"]; + n_3 -> n_4 [id="[$e|4]", label="send {request,pid_self} to meManager0/0"]; +} diff --git a/examples/violation/main0_global_view.dot b/examples/violation/main0_global_view.dot new file mode 100644 index 0000000..c0919f5 --- /dev/null +++ b/examples/violation/main0_global_view.dot @@ -0,0 +1,271 @@ +digraph global { + rankdir="LR"; + n_0 [label="global", shape="plaintext"]; + n_1 [id="33", shape=circle, label="33"]; + n_2 [id="34", shape=circle, label="34"]; + n_3 [id="20", shape=circle, label="20"]; + n_4 [id="58", shape=circle, label="58"]; + n_5 [id="119", shape=circle, label="119"]; + n_6 [id="129", shape=circle, label="129"]; + n_7 [id="57", shape=circle, label="57"]; + n_8 [id="98", shape=circle, label="98"]; + n_9 [id="91", shape=circle, label="91"]; + n_10 [id="78", shape=circle, label="78"]; + n_11 [id="102", shape=circle, label="102"]; + n_12 [id="27", shape=circle, label="27"]; + n_13 [id="118", shape=circle, label="118"]; + n_14 [id="114", shape=circle, label="114"]; + n_15 [id="89", shape=circle, label="89"]; + n_16 [id="47", shape=circle, label="47"]; + n_17 [id="29", shape=circle, label="29"]; + n_18 [id="23", shape=circle, label="23"]; + n_19 [id="110", shape=circle, label="110"]; + n_20 [id="72", shape=circle, label="72"]; + n_21 [id="122", shape=circle, label="122"]; + n_22 [id="55", shape=circle, label="55"]; + n_23 [id="82", shape=circle, label="82"]; + n_24 [id="117", shape=circle, label="117"]; + n_25 [id="25", shape=circle, label="25"]; + n_26 [id="120", shape=circle, label="120"]; + n_27 [id="68", shape=circle, label="68"]; + n_28 [id="83", shape=circle, label="83"]; + n_29 [id="36", shape=circle, label="36"]; + n_30 [id="94", shape=circle, label="94"]; + n_31 [id="84", shape=circle, label="84"]; + n_32 [id="5", shape=circle, label="5"]; + n_33 [id="81", shape=circle, label="81"]; + n_34 [id="74", shape=circle, label="74"]; + n_35 [id="92", shape=circle, label="92"]; + n_36 [id="63", shape=circle, label="63"]; + n_37 [id="28", shape=circle, label="28"]; + n_38 [id="64", shape=circle, label="64"]; + n_39 [id="86", shape=circle, label="86"]; + n_40 [id="15", shape=circle, label="15"]; + n_41 [id="87", shape=circle, label="87"]; + n_42 [id="42", shape=circle, label="42"]; + n_43 [id="19", shape=circle, label="19"]; + n_44 [id="12", shape=circle, label="12"]; + n_45 [id="11", shape=circle, label="11"]; + n_46 [id="116", shape=circle, label="116"]; + n_47 [id="112", shape=circle, label="112"]; + n_48 [id="99", shape=circle, label="99"]; + n_49 [id="17", shape=circle, label="17"]; + n_50 [id="53", shape=circle, label="53"]; + n_51 [id="50", shape=circle, label="50"]; + n_52 [id="62", shape=circle, label="62"]; + n_53 [id="67", shape=circle, label="67"]; + n_54 [id="54", shape=circle, label="54"]; + n_55 [id="18", shape=circle, label="18"]; + n_56 [id="61", shape=circle, label="61"]; + n_57 [id="113", shape=circle, label="113"]; + n_58 [id="37", shape=circle, label="37"]; + n_59 [id="80", shape=circle, label="80"]; + n_60 [id="51", shape=circle, label="51"]; + n_61 [id="14", shape=circle, label="14"]; + n_62 [id="66", shape=circle, label="66"]; + n_63 [id="93", shape=circle, label="93"]; + n_64 [id="132", shape=circle, label="132"]; + n_65 [id="100", shape=circle, label="100"]; + n_66 [id="6", shape=circle, label="6"]; + n_67 [id="126", shape=circle, label="126"]; + n_68 [id="38", shape=circle, label="38"]; + n_69 [id="13", shape=circle, label="13"]; + n_70 [id="24", shape=circle, label="24"]; + n_71 [id="10", shape=circle, label="10"]; + n_72 [id="79", shape=circle, label="79"]; + n_73 [id="43", shape=circle, label="43"]; + n_74 [id="30", shape=circle, label="30"]; + n_75 [id="71", shape=circle, label="71"]; + n_76 [id="59", shape=circle, label="59"]; + n_77 [id="40", shape=circle, label="40"]; + n_78 [id="22", shape=circle, label="22"]; + n_79 [id="105", shape=circle, label="105"]; + n_80 [id="106", shape=circle, label="106"]; + n_81 [id="101", shape=circle, label="101"]; + n_82 [id="65", shape=circle, label="65"]; + n_83 [id="73", shape=circle, label="73"]; + n_84 [id="131", shape=circle, label="131"]; + n_85 [id="39", shape=circle, label="39"]; + n_86 [id="123", shape=circle, label="123"]; + n_87 [id="108", shape=circle, label="108"]; + n_88 [id="60", shape=circle, label="60"]; + n_89 [id="1", shape=circle, label="1"]; + n_0 -> n_89 [arrowhead=none]; + n_90 [id="115", shape=circle, label="115"]; + n_91 [id="45", shape=circle, label="45"]; + n_92 [id="26", shape=circle, label="26"]; + n_93 [id="133", shape=circle, label="133"]; + n_94 [id="76", shape=circle, label="76"]; + n_95 [id="9", shape=circle, label="9"]; + n_96 [id="2", shape=circle, label="2"]; + n_97 [id="104", shape=circle, label="104"]; + n_98 [id="97", shape=circle, label="97"]; + n_99 [id="21", shape=circle, label="21"]; + n_100 [id="127", shape=circle, label="127"]; + n_101 [id="107", shape=circle, label="107"]; + n_102 [id="44", shape=circle, label="44"]; + n_103 [id="69", shape=circle, label="69"]; + n_104 [id="46", shape=circle, label="46"]; + n_105 [id="95", shape=circle, label="95"]; + n_106 [id="77", shape=circle, label="77"]; + n_107 [id="8", shape=circle, label="8"]; + n_108 [id="96", shape=circle, label="96"]; + n_109 [id="124", shape=circle, label="124"]; + n_110 [id="48", shape=circle, label="48"]; + n_111 [id="88", shape=circle, label="88"]; + n_112 [id="109", shape=circle, label="109"]; + n_113 [id="130", shape=circle, label="130"]; + n_114 [id="103", shape=circle, label="103"]; + n_115 [id="128", shape=circle, label="128"]; + n_116 [id="4", shape=circle, label="4"]; + n_117 [id="70", shape=circle, label="70"]; + n_118 [id="35", shape=circle, label="35"]; + n_119 [id="121", shape=circle, label="121"]; + n_120 [id="31", shape=circle, label="31"]; + n_121 [id="32", shape=circle, label="32"]; + n_122 [id="85", shape=circle, label="85"]; + n_123 [id="41", shape=circle, label="41"]; + n_124 [id="7", shape=circle, label="7"]; + n_125 [id="90", shape=circle, label="90"]; + n_126 [id="75", shape=circle, label="75"]; + n_127 [id="3", shape=circle, label="3"]; + n_128 [id="52", shape=circle, label="52"]; + n_129 [id="56", shape=circle, label="56"]; + n_130 [id="125", shape=circle, label="125"]; + n_131 [id="49", shape=circle, label="49"]; + n_132 [id="111", shape=circle, label="111"]; + n_133 [id="16", shape=circle, label="16"]; + + n_125 -> n_21 [id="[$e|120]", label="incrementer0/0→varManager1/0:{write,write}"]; + n_33 -> n_57 [id="[$e|111]", label="incrementer0/1→meManager0/0:{release}"]; + n_110 -> n_52 [id="[$e|60]", label="varManager1/0→incrementer0/0:Val"]; + n_60 -> n_53 [id="[$e|65]", label="incrementer0/0→varManager1/0:{write,write}"]; + n_91 -> n_7 [id="[$e|55]", label="incrementer0/1→meManager0/0:{release}"]; + n_133 -> n_99 [id="[$e|19]", label="incrementer0/0→meManager0/0:{request,pid_self}"]; + n_44 -> n_40 [id="[$e|13]", label="incrementer0/0→varManager1/0:{write,write}"]; + n_76 -> n_33 [id="[$e|79]", label="incrementer0/0→varManager1/0:{write,write}"]; + n_22 -> n_20 [id="[$e|70]", label="incrementer0/1→meManager0/0:{release}"]; + n_40 -> n_3 [id="[$e|18]", label="incrementer0/0→meManager0/0:{release}"]; + n_92 -> n_118 [id="[$e|33]", label="meManager0/0→incrementer0/1:answer"]; + n_127 -> n_116 [id="[$e|2]", label="main0/0Δincrementer0/0"]; + n_35 -> n_109 [id="[$e|122]", label="incrementer0/0→varManager1/0:{write,write}"]; + n_31 -> n_46 [id="[$e|114]", label="incrementer0/1→varManager1/0:{write,write}"]; + n_116 -> n_32 [id="[$e|3]", label="main0/0Δincrementer0/1"]; + n_58 -> n_110 [id="[$e|46]", label="incrementer0/0→varManager1/0:{read,pid_self}"]; + n_103 -> n_65 [id="[$e|98]", label="incrementer0/0→meManager0/0:{release}"]; + n_75 -> n_114 [id="[$e|101]", label="incrementer0/1→meManager0/0:{release}"]; + n_78 -> n_74 [id="[$e|28]", label="incrementer0/0→meManager0/0:{request,pid_self}"]; + n_41 -> n_5 [id="[$e|117]", label="incrementer0/0→meManager0/0:{release}"]; + n_1 -> n_73 [id="[$e|41]", label="incrementer0/1→varManager1/0:{read,pid_self}"]; + n_50 -> n_103 [id="[$e|67]", label="varManager1/0→incrementer0/0:Val"]; + n_7 -> n_106 [id="[$e|75]", label="incrementer0/1→varManager1/0:{write,write}"]; + n_73 -> n_22 [id="[$e|53]", label="varManager1/0→incrementer0/1:Val"]; + n_39 -> n_13 [id="[$e|116]", label="incrementer0/0→varManager1/0:{write,write}"]; + n_131 -> n_36 [id="[$e|61]", label="varManager1/0→incrementer0/0:Val"]; + n_133 -> n_78 [id="[$e|20]", label="incrementer0/1→varManager1/0:{write,write}"]; + n_22 -> n_83 [id="[$e|71]", label="incrementer0/1→varManager1/0:{write,write}"]; + n_129 -> n_126 [id="[$e|73]", label="incrementer0/1→varManager1/0:{write,write}"]; + n_2 -> n_91 [id="[$e|43]", label="varManager1/0→incrementer0/1:Val"]; + n_95 -> n_45 [id="[$e|9]", label="incrementer0/1→varManager1/0:{read,pid_self}"]; + n_68 -> n_131 [id="[$e|47]", label="incrementer0/0→varManager1/0:{read,pid_self}"]; + n_54 -> n_117 [id="[$e|68]", label="incrementer0/1→meManager0/0:{release}"]; + n_103 -> n_81 [id="[$e|99]", label="incrementer0/0→varManager1/0:{write,write}"]; + n_82 -> n_35 [id="[$e|90]", label="incrementer0/1→varManager1/0:{write,write}"]; + n_53 -> n_108 [id="[$e|94]", label="incrementer0/0→meManager0/0:{release}"]; + n_7 -> n_94 [id="[$e|74]", label="incrementer0/0→varManager1/0:{write,write}"]; + n_72 -> n_132 [id="[$e|109]", label="incrementer0/1→meManager0/0:{release}"]; + n_69 -> n_49 [id="[$e|15]", label="incrementer0/1→varManager1/0:{write,write}"]; + n_63 -> n_130 [id="[$e|123]", label="incrementer0/1→varManager1/0:{write,write}"]; + n_36 -> n_111 [id="[$e|86]", label="incrementer0/0→meManager0/0:{release}"]; + n_52 -> n_39 [id="[$e|84]", label="incrementer0/0→meManager0/0:{release}"]; + n_99 -> n_17 [id="[$e|27]", label="meManager0/0→incrementer0/0:answer"]; + n_38 -> n_9 [id="[$e|89]", label="incrementer0/0→varManager1/0:{write,write}"]; + n_106 -> n_112 [id="[$e|107]", label="incrementer0/0→varManager1/0:{write,write}"]; + n_66 -> n_107 [id="[$e|6]", label="meManager0/0→incrementer0/0:answer"]; + n_65 -> n_64 [id="[$e|130]", label="incrementer0/0→varManager1/0:{write,write}"]; + n_17 -> n_68 [id="[$e|36]", label="incrementer0/1→varManager1/0:{write,write}"]; + n_107 -> n_71 [id="[$e|8]", label="incrementer0/0→varManager1/0:{read,pid_self}"]; + n_16 -> n_56 [id="[$e|59]", label="varManager1/0→incrementer0/1:Val"]; + n_88 -> n_28 [id="[$e|81]", label="incrementer0/1→varManager1/0:{write,write}"]; + n_91 -> n_4 [id="[$e|56]", label="incrementer0/0→varManager1/0:{write,write}"]; + n_12 -> n_29 [id="[$e|34]", label="meManager0/0→incrementer0/1:answer"]; + n_37 -> n_58 [id="[$e|35]", label="meManager0/0→incrementer0/0:answer"]; + n_34 -> n_80 [id="[$e|104]", label="incrementer0/1→varManager1/0:{write,write}"]; + n_51 -> n_38 [id="[$e|62]", label="varManager1/0→incrementer0/0:Val"]; + n_83 -> n_79 [id="[$e|103]", label="incrementer0/1→meManager0/0:{release}"]; + n_74 -> n_77 [id="[$e|38]", label="meManager0/0→incrementer0/0:answer"]; + n_89 -> n_96 [id="[$e|0]", label="main0/0ΔmeManager0/0"]; + n_105 -> n_100 [id="[$e|125]", label="incrementer0/0→meManager0/0:{release}"]; + n_98 -> n_6 [id="[$e|127]", label="incrementer0/0→meManager0/0:{release}"]; + n_111 -> n_26 [id="[$e|118]", label="incrementer0/0→varManager1/0:{write,write}"]; + n_126 -> n_101 [id="[$e|105]", label="incrementer0/1→meManager0/0:{release}"]; + n_36 -> n_15 [id="[$e|87]", label="incrementer0/0→varManager1/0:{write,write}"]; + n_123 -> n_50 [id="[$e|51]", label="incrementer0/0→varManager1/0:{read,pid_self}"]; + n_122 -> n_24 [id="[$e|115]", label="incrementer0/1→meManager0/0:{release}"]; + n_25 -> n_1 [id="[$e|31]", label="incrementer0/0→varManager1/0:{write,write}"]; + n_4 -> n_72 [id="[$e|77]", label="incrementer0/1→varManager1/0:{write,write}"]; + n_49 -> n_18 [id="[$e|21]", label="incrementer0/1→meManager0/0:{release}"]; + n_59 -> n_47 [id="[$e|110]", label="incrementer0/0→varManager1/0:{write,write}"]; + n_102 -> n_129 [id="[$e|54]", label="varManager1/0→incrementer0/1:Val"]; + n_85 -> n_51 [id="[$e|48]", label="incrementer0/1→varManager1/0:{write,write}"]; + n_62 -> n_30 [id="[$e|92]", label="incrementer0/0→meManager0/0:{release}"]; + n_20 -> n_97 [id="[$e|102]", label="incrementer0/1→varManager1/0:{write,write}"]; + n_60 -> n_82 [id="[$e|63]", label="incrementer0/0→meManager0/0:{release}"]; + n_94 -> n_87 [id="[$e|106]", label="incrementer0/1→varManager1/0:{write,write}"]; + n_29 -> n_16 [id="[$e|45]", label="incrementer0/1→varManager1/0:{read,pid_self}"]; + n_81 -> n_93 [id="[$e|131]", label="incrementer0/0→meManager0/0:{release}"]; + n_27 -> n_8 [id="[$e|96]", label="incrementer0/0→meManager0/0:{release}"]; + n_91 -> n_76 [id="[$e|57]", label="incrementer0/1→varManager1/0:{write,write}"]; + n_56 -> n_122 [id="[$e|83]", label="incrementer0/1→varManager1/0:{write,write}"]; + n_25 -> n_2 [id="[$e|32]", label="incrementer0/1→varManager1/0:{read,pid_self}"]; + n_99 -> n_37 [id="[$e|26]", label="incrementer0/1→varManager1/0:{write,write}"]; + n_48 -> n_84 [id="[$e|129]", label="incrementer0/0→meManager0/0:{release}"]; + n_56 -> n_31 [id="[$e|82]", label="incrementer0/1→meManager0/0:{release}"]; + n_62 -> n_105 [id="[$e|93]", label="incrementer0/0→varManager1/0:{write,write}"]; + n_85 -> n_60 [id="[$e|49]", label="varManager1/0→incrementer0/0:Val"]; + n_27 -> n_48 [id="[$e|97]", label="incrementer0/0→varManager1/0:{write,write}"]; + n_71 -> n_44 [id="[$e|10]", label="varManager1/0→incrementer0/0:Val"]; + n_38 -> n_125 [id="[$e|88]", label="incrementer0/0→meManager0/0:{release}"]; + n_10 -> n_19 [id="[$e|108]", label="incrementer0/1→varManager1/0:{write,write}"]; + n_52 -> n_41 [id="[$e|85]", label="incrementer0/0→varManager1/0:{write,write}"]; + n_18 -> n_120 [id="[$e|29]", label="incrementer0/0→meManager0/0:{request,pid_self}"]; + n_60 -> n_62 [id="[$e|64]", label="incrementer0/1→varManager1/0:{write,write}"]; + n_2 -> n_102 [id="[$e|42]", label="incrementer0/0→varManager1/0:{write,write}"]; + n_121 -> n_42 [id="[$e|40]", label="incrementer0/1→varManager1/0:{read,pid_self}"]; + n_61 -> n_43 [id="[$e|17]", label="incrementer0/0→varManager1/0:{write,write}"]; + n_96 -> n_127 [id="[$e|1]", label="main0/0ΔvarManager1/0"]; + n_30 -> n_67 [id="[$e|124]", label="incrementer0/0→varManager1/0:{write,write}"]; + n_76 -> n_59 [id="[$e|78]", label="incrementer0/1→meManager0/0:{release}"]; + n_128 -> n_27 [id="[$e|66]", label="varManager1/0→incrementer0/0:Val"]; + n_42 -> n_54 [id="[$e|52]", label="varManager1/0→incrementer0/1:Val"]; + n_43 -> n_92 [id="[$e|24]", label="incrementer0/1→meManager0/0:{request,pid_self}"]; + n_129 -> n_34 [id="[$e|72]", label="incrementer0/1→meManager0/0:{release}"]; + n_69 -> n_133 [id="[$e|14]", label="incrementer0/1→meManager0/0:{release}"]; + n_118 -> n_104 [id="[$e|44]", label="incrementer0/1→varManager1/0:{read,pid_self}"]; + n_17 -> n_85 [id="[$e|37]", label="incrementer0/0→varManager1/0:{read,pid_self}"]; + n_44 -> n_61 [id="[$e|12]", label="incrementer0/0→meManager0/0:{release}"]; + n_124 -> n_95 [id="[$e|7]", label="meManager0/0→incrementer0/1:answer"]; + n_88 -> n_23 [id="[$e|80]", label="incrementer0/1→meManager0/0:{release}"]; + n_23 -> n_14 [id="[$e|112]", label="incrementer0/1→varManager1/0:{write,write}"]; + n_61 -> n_55 [id="[$e|16]", label="incrementer0/1→meManager0/0:{request,pid_self}"]; + n_45 -> n_69 [id="[$e|11]", label="varManager1/0→incrementer0/1:Val"]; + n_108 -> n_115 [id="[$e|126]", label="incrementer0/1→varManager1/0:{write,write}"]; + n_54 -> n_75 [id="[$e|69]", label="incrementer0/1→varManager1/0:{write,write}"]; + n_53 -> n_98 [id="[$e|95]", label="incrementer0/1→varManager1/0:{write,write}"]; + n_70 -> n_121 [id="[$e|30]", label="meManager0/0→incrementer0/1:answer"]; + n_8 -> n_113 [id="[$e|128]", label="incrementer0/0→varManager1/0:{write,write}"]; + n_117 -> n_11 [id="[$e|100]", label="incrementer0/1→varManager1/0:{write,write}"]; + n_4 -> n_10 [id="[$e|76]", label="incrementer0/1→meManager0/0:{release}"]; + n_28 -> n_90 [id="[$e|113]", label="incrementer0/1→meManager0/0:{release}"]; + n_120 -> n_123 [id="[$e|39]", label="meManager0/0→incrementer0/0:answer"]; + n_9 -> n_86 [id="[$e|121]", label="incrementer0/0→meManager0/0:{release}"]; + n_82 -> n_63 [id="[$e|91]", label="incrementer0/0→varManager1/0:{write,write}"]; + n_55 -> n_70 [id="[$e|22]", label="incrementer0/0→varManager1/0:{write,write}"]; + n_3 -> n_12 [id="[$e|25]", label="incrementer0/1→meManager0/0:{request,pid_self}"]; + n_15 -> n_119 [id="[$e|119]", label="incrementer0/0→meManager0/0:{release}"]; + n_77 -> n_128 [id="[$e|50]", label="incrementer0/0→varManager1/0:{read,pid_self}"]; + n_55 -> n_25 [id="[$e|23]", label="meManager0/0→incrementer0/1:answer"]; + n_32 -> n_124 [id="[$e|5]", label="incrementer0/1→meManager0/0:{request,pid_self}"]; + n_104 -> n_88 [id="[$e|58]", label="varManager1/0→incrementer0/1:Val"]; + n_32 -> n_66 [id="[$e|4]", label="incrementer0/0→meManager0/0:{request,pid_self}"]; +} diff --git a/examples/violation/main0_local_view.dot b/examples/violation/main0_local_view.dot new file mode 100644 index 0000000..757b63b --- /dev/null +++ b/examples/violation/main0_local_view.dot @@ -0,0 +1,15 @@ +digraph main0 { + rankdir="LR"; + n_0 [label="main0", shape="plaintext"]; + n_1 [id="5", shape=circle, label="3"]; + n_2 [id="1", shape=circle, label="1"]; + n_0 -> n_2 [arrowhead=none]; + n_3 [id="2", shape=circle, label="2"]; + n_4 [id="4", shape=doublecircle, label="5"]; + n_5 [id="3", shape=circle, label="4"]; + + n_1 -> n_5 [id="[$e|2]", label="spawn incrementer0/0"]; + n_5 -> n_4 [id="[$e|3]", label="spawn incrementer0/1"]; + n_3 -> n_1 [id="[$e|0]", label="spawn varManager1/0"]; + n_2 -> n_3 [id="[$e|1]", label="spawn meManager0/0"]; +} diff --git a/examples/violation/meManager0_local_view.dot b/examples/violation/meManager0_local_view.dot new file mode 100644 index 0000000..571db27 --- /dev/null +++ b/examples/violation/meManager0_local_view.dot @@ -0,0 +1,12 @@ +digraph meManager0 { + rankdir="LR"; + n_0 [label="meManager0", shape="plaintext"]; + n_1 [id="1", shape=circle, label="1"]; + n_0 -> n_1 [arrowhead=none]; + n_2 [id="2", shape=circle, label="2"]; + n_3 [id="3", shape=circle, label="3"]; + + n_1 -> n_2 [id="[$e|2]", label="receive {request,Pid}"]; + n_2 -> n_3 [id="[$e|1]", label="send answer to Pid"]; + n_3 -> n_1 [id="[$e|4]", label="receive {release}"]; +} diff --git a/examples/violation/varManager1_local_view.dot b/examples/violation/varManager1_local_view.dot new file mode 100644 index 0000000..cb467ad --- /dev/null +++ b/examples/violation/varManager1_local_view.dot @@ -0,0 +1,11 @@ +digraph varManager1 { + rankdir="LR"; + n_0 [label="varManager1", shape="plaintext"]; + n_1 [id="1", shape=circle, label="1"]; + n_0 -> n_1 [arrowhead=none]; + n_2 [id="4", shape=circle, label="2"]; + + n_1 -> n_2 [id="[$e|0]", label="receive {read,Pid}"]; + n_2 -> n_1 [id="[$e|10]", label="send Val to Pid"]; + n_1 -> n_1 [id="[$e|7]", label="receive {write,NewVal}"]; +} diff --git a/src/choreography/actor_emul.erl b/src/choreography/actor_emul.erl index 269f4bb..032e5ce 100644 --- a/src/choreography/actor_emul.erl +++ b/src/choreography/actor_emul.erl @@ -45,7 +45,7 @@ proc_loop(Data) -> ProcName = Data#actor_info.fun_name, % io:fwrite("[EMUL] ID ~p~n", [ProcName]), LV = share:get_localview(ProcName), - G = LV#wip_lv.graph, + G = LV#wip_lv.min_graph, % timer:sleep(200), VCurr = Data#actor_info.current_state, FirstMarkedE = Data#actor_info.first_marked_edges, diff --git a/src/choreography/eval.erl b/src/choreography/eval.erl index fa30187..9d0d082 100644 --- a/src/choreography/eval.erl +++ b/src/choreography/eval.erl @@ -29,6 +29,7 @@ function_list(ContList, Data) -> fun(FunctionBody, AccData) -> case FunctionBody of {clause, _, Vars, Guard, Content} -> + % io:fwrite("Clause ~p~n", [Vars]), ets:insert(?ARGUMENTS, {Data#wip_lv.fun_name, Vars}), clause(Content, Vars, Guard, AccData#wip_lv{last_vertex = 1}, "arg"); C -> @@ -301,8 +302,15 @@ generic_call(Name, ArgList, Data) -> LastV = Data#wip_lv.last_vertex, NewG = NewD#wip_lv.graph, NewRet = NewD#wip_lv.ret_var, + EM = NewD#wip_lv.edge_map, NewLastV = merge_graph(G, NewG, LastV), - Data#wip_lv{ret_var = NewRet, last_vertex = NewLastV} + % io:fwrite("LastV ~p VarRet ~p~n", [LastV, NewRet]), + % io:fwrite("OldEM ~p NewEM ~p~n", [Data#wip_lv.edge_map, EM]), + Data#wip_lv{ + ret_var = NewRet, + last_vertex = NewLastV, + edge_map = maps:merge(Data#wip_lv.edge_map, EM) + } end. %%% TODO: eval argument list @@ -382,7 +390,7 @@ var_to_string(Var) -> case SType of "integer" -> integer_to_list(Val); "float" -> io_lib:format("~.2f", [Val]); - "string" -> "\"" ++ Val ++ "\""; + "string" -> "\'" ++ Val ++ "\'"; "atom" -> share:atol(Val); "list" -> format_list(Val, fun var_to_string/1); "tuple" -> format_tuple(Val, fun var_to_string/1); diff --git a/src/choreography/gv.erl b/src/choreography/gv.erl index 42d1051..94c9a8d 100644 --- a/src/choreography/gv.erl +++ b/src/choreography/gv.erl @@ -18,7 +18,9 @@ generate(Settings, EntryPoint) -> _ -> % io:fwrite("Creating the globalview starting from ~p~n", [EntryPoint]), G = create_globalview(EntryPoint), - share:save_graph(G, Settings, EntryPoint, global), + MinG = fsa:minimize(G), + Data = #wip_lv{graph = G, min_graph = MinG}, + share:save_graph(Data, Settings, EntryPoint, global), finished end. @@ -277,16 +279,16 @@ add_spawn_to_global(SLabel, EmulProcName, Data) -> {VNew, NewMap}. get_local_vars(ProcId, Label, FunSName) -> - EM = share:get_edgedata(FunSName), + EM = share:get_edgedata(element(1, remove_id_from_proc(ProcId))), InputData = maps:get(Label, EM, []), - % io:fwrite("[GV] EmulProcName ~p Label ~p Input ~p~n", [ProcId, Label, EM]), + % io:fwrite("[GV] EmulProcName ~p Label ~p Input ~p~n", [FunSName, Label, EM]), % add input data to local vars case InputData of [] -> []; _ -> - [{_, Input}] = ets:lookup(?ARGUMENTS, FunSName), - % io:fwrite("[GV] for fun ~p found ~p~n", [atol(FuncName), Input]), + [{_, Input}] = ets:lookup(?ARGUMENTS, atol(FunSName)), + % io:fwrite("[GV] for fun ~p found ~p~n", [atol(FunSName), Input]), {LL, Remain} = lists:foldl( fun({var, _, Name}, {A, In}) -> case In of diff --git a/src/choreography/lv.erl b/src/choreography/lv.erl index 8330044..0c883ec 100644 --- a/src/choreography/lv.erl +++ b/src/choreography/lv.erl @@ -25,10 +25,10 @@ create_localview(ActorName, Settings, Save) -> io:fwrite("Error: Actor ~p's AST not found~n", [ActorName]), no_graph; ActorAst -> - io:fwrite("[LV] Creating a localview for ~p~n", [ActorName]), LV = share:get_localview(ActorName), case LV of not_found -> + io:fwrite("[LV] Creating a localview for ~p~n", [ActorName]), BaseData = #wip_lv{ fun_name = ActorName, fun_ast = ActorAst, settings = Settings }, @@ -37,10 +37,10 @@ create_localview(ActorName, Settings, Save) -> G = LVData#wip_lv.graph, set_final_state(G), MinG = fsa:minimize(G), - NewLV = LVData#wip_lv{graph = MinG}, + NewLV = LVData#wip_lv{min_graph = MinG}, ets:insert(?LOCALVIEW, {ActorName, NewLV}), case Save or Settings#setting.save_all of - true -> share:save_graph(G, Settings, ActorName, local); + true -> share:save_graph(NewLV, Settings, ActorName, local); false -> done end, NewLV; diff --git a/src/share/common_data.hrl b/src/share/common_data.hrl index b323b7a..4d6c602 100644 --- a/src/share/common_data.hrl +++ b/src/share/common_data.hrl @@ -41,6 +41,7 @@ fun_name = "", fun_ast = {}, graph = digraph:new(), + min_graph = digraph:new(), last_vertex = 1, local_vars = [], ret_var = #variable{}, diff --git a/src/share/fsa.erl b/src/share/fsa.erl index 6447ed5..387f50f 100644 --- a/src/share/fsa.erl +++ b/src/share/fsa.erl @@ -12,6 +12,7 @@ %%% book: Programming Languages, Second edition, McGraw-Hill, 2011 minimize(NFA) -> % Convert a NFA to a DFA + remove_unreachable(NFA), DFA = subset_construction(NFA), % Minimization of the DFA remove_unreachable(DFA), @@ -61,6 +62,7 @@ subset_construction(NFA) -> FirstDFAState = eps_clos(NFA, [1]), %%% Create a list of DFA states and transitions {DFAStateL, DFATransitionsL} = subset_construction(NFA, sfroml([FirstDFAState])), + % io:fwrite("LIST OF DFA STATES ~p~n", [stol(DFAStateL)]), %%% Convert the list of DFA state in the DFA graph vertex VertexEquivalanceM = convert_statel_to_graph(NFA, DFA, FirstDFAState, DFAStateL), %%% Convert the list of DFA transition in the DFA graph edges @@ -108,22 +110,30 @@ subset_construction(NFA, StateS, TransS, MarkedS) -> %%% Convert a list of DFA state in a given DFA graph: %%% a set of NFA states equals to a graph vertex -convert_statel_to_graph(NFA, DFA, FirstDFAState, DFAStateL) -> - RetM = #{FirstDFAState => share:add_vertex(DFA)}, - FoldFun = fun(DFAState, AccM) -> - case DFAState =:= FirstDFAState of - true -> - AccM; - false -> - DFAVertex = share:add_vertex(DFA), - case is_final_state(NFA, sets:to_list(DFAState)) of - true -> set_as_final(DFA, DFAVertex); - false -> ?UNDEFINED - end, - maps:put(DFAState, DFAVertex, AccM) - end - end, - sets:fold(FoldFun, RetM, DFAStateL). +convert_statel_to_graph(NFA, DFA, FirstDFAStateL, DFAStateL) -> + FirstDFAVertex = share:add_vertex(DFA), + establish_final(NFA, DFA, FirstDFAStateL, FirstDFAVertex), + RetM = #{FirstDFAStateL => FirstDFAVertex}, + sets:fold( + fun(DFAState, AccM) -> + case DFAState =:= FirstDFAStateL of + true -> + AccM; + false -> + DFAVertex = share:add_vertex(DFA), + establish_final(NFA, DFA, DFAState, DFAVertex), + maps:put(DFAState, DFAVertex, AccM) + end + end, + RetM, + DFAStateL + ). + +establish_final(NFA, DFA, DFAState, DFAVertex) -> + case is_final_state(NFA, stol(DFAState)) of + true -> set_as_final(DFA, DFAVertex); + false -> ?UNDEFINED + end. %%% Convert a DFA transition list to equivalents graph edges in the DFA graph convert_transl_to_graph(DFA, DFAVertexEquivM, DFATransitionsL) -> @@ -310,7 +320,10 @@ is_final_state(G, L) when is_list(L) -> is_final_state(G, V) -> {V, L} = digraph:vertex(G, V), %%% All label's states are numbers, execept for final states - not is_integer(L). + case string:find(share:atol(L), ?FINALTAG) of + nomatch -> false; + _ -> true + end. %%% Set a state as final set_as_final(G, V) -> @@ -337,9 +350,9 @@ bfs_with_raname(G, VL, MarkedV, LastLabel) -> Last = lists:foldl( fun(I, AccI) -> LNum = AccI + 1, - C = is_final_state(G, I), + Cond = is_final_state(G, I), FinalL = - case C of + case Cond of true -> ?FINALTAG ++ integer_to_list(LNum); false -> LNum end, diff --git a/src/share/share.erl b/src/share/share.erl index 9be5136..b85061a 100644 --- a/src/share/share.erl +++ b/src/share/share.erl @@ -128,7 +128,8 @@ get_base_label(SetPm, Label) -> ltoa(L) when is_list(L) -> list_to_atom(L); ltoa(L) when is_atom(L) -> L. atol(A) when is_atom(A) -> atom_to_list(A); -atol(A) when is_list(A) -> A. +atol(A) when is_list(A) -> A; +atol(A) when is_number(A) -> integer_to_list(A). if_final_get_n(L) when not is_integer(L) -> NewL = re:replace(L, ?FINALTAG, "", [{return, list}]), @@ -151,13 +152,13 @@ should_minimize(S) -> _ -> true end. -save_graph(G, Settings, FunName, Mode) -> +save_graph(Data, Settings, FunName, Mode) -> OutputDir = Settings#setting.output_dir, Minimize = should_minimize(atol(FunName) ++ " " ++ atol(Mode)), ToSaveG = case Minimize of - true -> fsa:minimize(G); - false -> G + true -> Data#wip_lv.min_graph; + false -> Data#wip_lv.graph end, save_graph_to_file(ToSaveG, OutputDir, FunName, Mode). diff --git a/test.py b/test.py index 1a2a53f..b79f8f7 100755 --- a/test.py +++ b/test.py @@ -15,7 +15,8 @@ ("./examples/function-call/funny.erl","main0","examples/function-call"), ("./examples/high-order-fun/hof.erl","greet0","examples/high-order-fun"), ("./examples/if-cases/ifcases.erl","main0","examples/if-cases"), - ("./examples/test/barber/barber.erl","test0","examples/test/barber"), + ("./examples/violation/meViolation.erl", "", "examples/violation"), + ("./examples/test/barber/barber.erl","main0","examples/test/barber"), ("./examples/test/foo1/foo1.erl","test0","examples/test/foo1"), ("./examples/test/foo2/foo2.erl","test0","examples/test/foo2"), ("./examples/test/foo3/foo3.erl","test0","examples/test/foo3"), From d793dbe645c19cc7439dc9fcbcaf2fb5aa2ea003 Mon Sep 17 00:00:00 2001 From: geno Date: Sun, 17 Mar 2024 19:55:36 +0100 Subject: [PATCH 11/11] added documentation --- doc/actor_emul.html | 145 +++ {docs => doc/assets}/codebeam.md | 0 {docs => doc/assets}/thesis.pdf | Bin {docs => doc/assets}/thesis_presentation.pdf | Bin doc/chorer.html | 59 + doc/digraph_to_dot.html | 47 + doc/edoc-extensions.css | 65 + doc/edoc-info | 3 + doc/erlang.png | Bin 0 -> 2109 bytes doc/eval.html | 164 +++ doc/fsa.html | 42 + doc/github-markdown.css | 1195 ++++++++++++++++++ doc/gv.html | 38 + doc/index.html | 17 + doc/lv.html | 53 + doc/md.html | 50 + doc/modules-frame.html | 21 + doc/overview-summary.html | 17 + doc/prism-core.min.js.v1.26.0 | 1 + doc/prism-dark.min.css.v1.26.0 | 1 + doc/prism-elixir.min.js.v1.26.0 | 1 + doc/prism-erlang.min.js.v1.26.0 | 1 + doc/prism-okaidia.min.css.v1.26.0 | 1 + doc/prism-twilight.min.css.v1.26.0 | 1 + doc/prism.css | 1 + doc/prism.js | 1 + doc/prism.min.css.v1.26.0 | 1 + doc/share.html | 200 +++ doc/stylesheet.css | 55 + docs/index.html | 1 - rebar.config | 4 + src/choreography/actor_emul.erl | 58 +- src/choreography/eval.erl | 36 + src/choreography/gv.erl | 135 +- src/choreography/lv.erl | 9 + src/choreography/md.erl | 31 +- src/chorer.erl | 15 +- src/share/common_data.hrl | 1 - src/share/digraph_to_dot.erl | 17 +- src/share/fsa.erl | 10 + src/share/share.erl | 14 +- 41 files changed, 2423 insertions(+), 88 deletions(-) create mode 100644 doc/actor_emul.html rename {docs => doc/assets}/codebeam.md (100%) rename {docs => doc/assets}/thesis.pdf (100%) rename {docs => doc/assets}/thesis_presentation.pdf (100%) create mode 100644 doc/chorer.html create mode 100644 doc/digraph_to_dot.html create mode 100644 doc/edoc-extensions.css create mode 100644 doc/edoc-info create mode 100644 doc/erlang.png create mode 100644 doc/eval.html create mode 100644 doc/fsa.html create mode 100644 doc/github-markdown.css create mode 100644 doc/gv.html create mode 100644 doc/index.html create mode 100644 doc/lv.html create mode 100644 doc/md.html create mode 100644 doc/modules-frame.html create mode 100644 doc/overview-summary.html create mode 100644 doc/prism-core.min.js.v1.26.0 create mode 100644 doc/prism-dark.min.css.v1.26.0 create mode 100644 doc/prism-elixir.min.js.v1.26.0 create mode 100644 doc/prism-erlang.min.js.v1.26.0 create mode 100644 doc/prism-okaidia.min.css.v1.26.0 create mode 100644 doc/prism-twilight.min.css.v1.26.0 create mode 100644 doc/prism.css create mode 100644 doc/prism.js create mode 100644 doc/prism.min.css.v1.26.0 create mode 100644 doc/share.html create mode 100644 doc/stylesheet.css delete mode 100644 docs/index.html diff --git a/doc/actor_emul.html b/doc/actor_emul.html new file mode 100644 index 0000000..24cdd65 --- /dev/null +++ b/doc/actor_emul.html @@ -0,0 +1,145 @@ + + + + +Module actor_emul + + + + +
+ +

Module actor_emul

+ + This module simulate an actor's localview during a globalview. + + +

Description

+ This module simulate an actor's localview during a globalview. +

Function Index

+ + + + + + + + + + + + + +
add_proc_localvars/2 + Add a variable to the local variables of the localview.
add_proc_mess_queue/2 + Add a message to the message queue of the process.
add_proc_spawnvars/2 + Add a variable to the spawn arguments of the localview.
del_proc_mess_queue/2 + Delete a message from the message queue of the process.
get_proc_data/1 + Get the all the data of the process.
get_proc_edge_info/2 + Get the informations of a localview's edge.
get_proc_edges/1 + Get all the localview's current edges.
get_proc_localvars/1 + Get the list of the local variables.
get_proc_mess_queue/1 + Get the message queue of the process.
get_proc_out_degree/1 + Get all the number of the localview's current edges.
proc_loop/1 + Loop function to simulate a process.
set_proc_data/2 + Set the all the data of the process.
use_proc_transition/2 + Use a transition of the localview.
+ +

Function Details

+ +

add_proc_localvars/2

+
+

add_proc_localvars(P, V) -> any()

+

+

+ Add a variable to the local variables of the localview.

+ +

add_proc_mess_queue/2

+
+

add_proc_mess_queue(P, M) -> any()

+

+

+ Add a message to the message queue of the process.

+ +

add_proc_spawnvars/2

+
+

add_proc_spawnvars(P, V) -> any()

+

+

+ Add a variable to the spawn arguments of the localview.

+ +

del_proc_mess_queue/2

+
+

del_proc_mess_queue(P, M) -> any()

+

+

+ Delete a message from the message queue of the process.

+ +

get_proc_data/1

+
+

get_proc_data(P) -> any()

+

+

+ Get the all the data of the process.

+ +

get_proc_edge_info/2

+
+

get_proc_edge_info(P, E) -> any()

+

+

+ Get the informations of a localview's edge.

+ +

get_proc_edges/1

+
+

get_proc_edges(P) -> any()

+

+

+ Get all the localview's current edges.

+ +

get_proc_localvars/1

+
+

get_proc_localvars(P) -> any()

+

+

+ Get the list of the local variables.

+ +

get_proc_mess_queue/1

+
+

get_proc_mess_queue(P) -> any()

+

+

+ Get the message queue of the process.

+ +

get_proc_out_degree/1

+
+

get_proc_out_degree(P) -> any()

+

+

+ Get all the number of the localview's current edges.

+ +

proc_loop/1

+
+

proc_loop(Data) -> any()

+

+

+ Loop function to simulate a process.

+ +

set_proc_data/2

+
+

set_proc_data(P, Data) -> any()

+

+

+ Set the all the data of the process.

+ +

use_proc_transition/2

+
+

use_proc_transition(P, E) -> any()

+

+

+ Use a transition of the localview.

+
+ + +

Generated by EDoc

+ + diff --git a/docs/codebeam.md b/doc/assets/codebeam.md similarity index 100% rename from docs/codebeam.md rename to doc/assets/codebeam.md diff --git a/docs/thesis.pdf b/doc/assets/thesis.pdf similarity index 100% rename from docs/thesis.pdf rename to doc/assets/thesis.pdf diff --git a/docs/thesis_presentation.pdf b/doc/assets/thesis_presentation.pdf similarity index 100% rename from docs/thesis_presentation.pdf rename to doc/assets/thesis_presentation.pdf diff --git a/doc/chorer.html b/doc/chorer.html new file mode 100644 index 0000000..ab987f6 --- /dev/null +++ b/doc/chorer.html @@ -0,0 +1,59 @@ + + + + +Module chorer + + + + +
+ +

Module chorer

+ + The main module of the program. + + +

Description

+ The main module of the program. + It initialize the ets tables and generetes the localviews and the globalview. +

Function Index

+ + + +
generate/2 + Generate the localviews and the globalview with base settings.
generate/3 + Generate the localviews and the globalview specifing the output directory.
main/1 + Function called when the tool is used from the CLI (Command Line Interface).
+ +

Function Details

+ +

generate/2

+
+

generate(InputFile, EntryPoint) -> atom() +

  • InputFile = string()
  • EntryPoint = atom()

+

+

+ Generate the localviews and the globalview with base settings.

+ +

generate/3

+
+

generate(InputFile, EntryPoint, OutDir) -> atom() +

  • InputFile = string()
  • EntryPoint = atom()
  • OutDir = string()

+

+

+ Generate the localviews and the globalview specifing the output directory. + It initialize the ets tables and generates the localviews and globalview.

+ +

main/1

+
+

main(Args) -> any()

+

+

+ Function called when the tool is used from the CLI (Command Line Interface).

+
+ + +

Generated by EDoc

+ + diff --git a/doc/digraph_to_dot.html b/doc/digraph_to_dot.html new file mode 100644 index 0000000..02a32b3 --- /dev/null +++ b/doc/digraph_to_dot.html @@ -0,0 +1,47 @@ + + + + +Module digraph_to_dot + + + + +
+ +

Module digraph_to_dot

+ + Module based from + jkrukoff. + + +

Description

+ Module based from + jkrukoff.

+ + Features added: +
    +
  • distinctions between initial and final states
  • +
  • changed orientation of graphs from left to right
  • +
  • enanched format
  • +
+

Function Index

+ +
convert/2 + Convert a graph to a dot graph.
+ +

Function Details

+ +

convert/2

+
+

convert(Graph, Name) -> Serialized +

+

+

+ Convert a graph to a dot graph.

+
+ + +

Generated by EDoc

+ + diff --git a/doc/edoc-extensions.css b/doc/edoc-extensions.css new file mode 100644 index 0000000..46d3a14 --- /dev/null +++ b/doc/edoc-extensions.css @@ -0,0 +1,65 @@ +@import url("github-markdown.css"); +@import url("prism.css"); + +body { + box-sizing: border-box; + min-width: 200px; + max-width: 980px; + margin: 0 auto; + padding: 45px; +} +@media (max-width: 767px) { + body { + padding: 15px; + } +} +/* Don't apply the table style to the top-level navigation bar. */ +.navbar table { + display: table; + width: 100%; +} +.navbar table tr, +.navbar table th, +.navbar table td { + border: 0; +} +/* Keep the same font side inside code blocks than everywhere else. */ +.markdown-body pre code, +code[class*="language-"] { + font-size: 85%; +} +/* Force the color for link on code blocks used for @see tags. */ +.markdown-body a code, +.markdown-body a code span.token { + color: var(--color-accent-fg); +} +/* Copy the style of code blocks. */ +.markdown-body .spec { + background: #f5f2f0; + padding: 1em; + margin: .5em 0; + overflow: auto; + border-radius: 6px; +} +/* Improve margins inside function spec blocks so that: + - empty paragraphs don't add useless margins + - the final top and bottom margins are equal */ +.markdown-body .spec p, +.markdown-body .spec ul { + margin-top: 16px; + margin-bottom: 0; +} +.markdown-body .spec p:first-child, +.markdown-body .spec p:empty { + margin-top: 0; +} +/* Put the function prototype in bold characters. */ +.markdown-body .spec > p > code:first-child { + font-weight: bold; +} +/* Add some margin below the module short description between the table + of contents in the Description section. This text isn't in a +

. */ +.index + p { + margin-top: 16px; +} diff --git a/doc/edoc-info b/doc/edoc-info new file mode 100644 index 0000000..b303ea4 --- /dev/null +++ b/doc/edoc-info @@ -0,0 +1,3 @@ +%% encoding: UTF-8 +{application,chorer}. +{modules,[actor_emul,chorer,digraph_to_dot,eval,fsa,gv,lv,md,share]}. diff --git a/doc/erlang.png b/doc/erlang.png new file mode 100644 index 0000000000000000000000000000000000000000..987a618e2403af895bfaf8c2f929e3a4f3746659 GIT binary patch literal 2109 zcmV-D2*US?P)rez_nr%N ze)-p~%6|a|LA_bA=l=$|3jjqS$tjbGG?@TN0w$Azq7Z{YeQxKcpLO55vno1^u23DP&V=i9-KAAsU*ECy^#OtaDC!lVSo!+|-%T+LhTHP^Oqwx8m)b4r3V28JmV&6M#iG)&0;P`j>XGfomEIEK6wPkhI{{K?3#uAGq$!`N_F)TNX zAvuspF?^;c9h%CPWyTDc_03%r4N8+Yzzo_VSfa!zo_7F6D?<+-+KkHwXiWQR=Mr(9|K@{{xEjfDvAbS9uNCP&{)NNCoC?XA$aRe>R8-> z5N<#S_)$d|EYpJfPC?{`$Y~f4yjH&dxHXIGG8wiaLBD6usC87cg+dd&3WLJd4_TcmEeAOz8R>ikgW(9821 z{34Se09Y?KoG<_Y;DDSoyTk>fUN0YO5)3^Za{&s1JbidC9}56{px+f|K_0;YuL5h} z_9J3y%7ucwM)E4K#=Cn7tCjjRkKjnQuiFcM6{17Jt#5F}7z8~RYqW24xV?kAU6xQN zh+h4|SmO1;TdsVOaOeD*kKf}6I7=6ZNig_rtqV?Ov1HrU(P%Hi#6npSe>%qGaNK1w zW$v+r`r0>#p~AN^8b)#7Yesu(ys(>3SCYb4sF9%A9=kMHrLmzk}E&WPG~Jx z9!r{qo5M184t;<7I`t1AsNjv912EeKkHKtOSl%wbcjFh7L6|G?Q+{?radOvuEW$>1 zoc+c&F+u$^0f}1_2dN&lS#I#p3e&+|YGHlMzRC)%&8TnGt+p*;Oz z`0=D=n|qcN+f@07;QjB@ktLhZ`+qz;(xYDli^Pex&&wwU2V4N-a3b@veqHg2cvCRb zoi=ZerLk!4t5!s3?|ARuWx_4-VCgl|TY2qa@$Dr~5QdiT8?$oPpZhaF5UOZ&x=+I9 zt((`6wBPM((BS{;2lmSB;o%z{>=mg*1k2oLjI=+zcf5$4BIZmkOrjrE z*VY(<@FO?zBVDc+Q~Lh;LnlYodZ$J3tmWJBN4j~wVOWelzexhft2nY6A3PZAcm!q} z931CL#1Ki6;HM{agTbKF>3(R-yuF1&Apn3Nh@PGvv)K$mkVqu*^z@vaFgQ3kFfg!s z^=f26@{Ny=_w@7x1qHF$bEk5X$)wR}0s{l>V!TCGM=R5Ei1Ll8u7Z*N0G1CPgB zyLPP|0H{-FRUDJv`Ea=9fX zC63D4+FBlumz$eAJv~j5q*|@^_xC?_>XiL0K@bH61$;i=&CLx(QGb8`8#iu{BnjJW zHUvSgUcK7T&~W(h;koN8t5vB~Ha0dgnane1&RA#87dVcaOpEMM)6>)E&YiPZEXBpe zlarHk89g;+G#U#E3hL_W002xT6UTApOeR%UR_5g7q^73!_4PG2Hi|@|ii(Pfi3vIY z0ES^?Mx1IOizO0?e0_a!9483k`PtCk-rm~Unwpw=?b@~O?(WdgP^bMMAYlLg{dIM9 zOy}OcxVTs%k(@q#n$PF+`TXkYYA%;cr_*5ofWcr$PEL-Ai772Db)3`L*|~G)&eqn} zq@*OrbXim`UAiO`3XdK=%H#1=D%HHV>FMbqAtCAM=@!e}C6Cc))ai5zg~H3rYjkup zD=RBMKR+`wv!kN}1^{3fR#a3}RaLcP#}20|H!^bT)~%G3lp{xu!0_{Wr2hW?>({UQ z`T1F`)|D$)*3{IP&1UDKhLn_)sMYHH{QRkzV=$M?#W2idGFh!wf*`b7ZGC-xVPT=c zV1Vs&!otFoN~M>VQ$G_G6}5No-m0pqwzjr;?W@INu~;m#k*%qz(P%VUt#;3zJ^lUt zU0q%G?%kVzvF7cqQmLw|tA~e&XIqun*x2Ug=9-!s48ty7ycil9Di(|7aybkD7#y?%lgQ z9`Ewy%eDpgxlvJ3Cr+GTFc>(F+cg;(8TPc>y?b|jeEgLwR}LLIBoqp1+1c4_HrvO? z$J5g@G&D3gIC$2ITrQ7`iwh4AfA;K|OePZu1oriTVVG1Zl}e@S)~)mK@UU1cI-Ty| z!Gj8gg2UmUD2ibif*{e+(R4bU#bU|j@{Joe^7(uSf+8X!q*7@_M1;L=AqbM3oXp{H nT3T9A6wS=c+_!HZolgHhw9g$%O4Wbp00000NkvXXu0mjf3HKBY literal 0 HcmV?d00001 diff --git a/doc/eval.html b/doc/eval.html new file mode 100644 index 0000000..782daa6 --- /dev/null +++ b/doc/eval.html @@ -0,0 +1,164 @@ + + + + +Module eval + + + + +
+ +

Module eval

+ + This module evaluate the AST of the expressions in the Erlang language. + + +

Description

+ This module evaluate the AST of the expressions in the Erlang language. + This module is usable only in the lv module. +

Function Index

+ + + + + + + + + + + + + + + +
anon_fun/3 + Evaluate the definition of an anonymous function.
atom/2 + Evaluate an atom.
case_pm/3 + Evaluate a case expression.
clause/5 + Evaluate a single clause (might be from case, receive or if).
function_call/3 + Evaluate the call of a function.
function_list/2 + Evaluate the clauses of a function.
if_pm/2 + Evaluate a if expression.
list/3 + Evaluate a list.
map/2 + Evaluate a map.
match/3 + Evaluate a variable declaration.
operation/4 + Evaluate an operation.
receive_pm/2 + Evaluate a receive expression.
simple_type/3 + Evaluate a basic type.
tuple/2 + Evaluate a tuple.
variable/2 + Evaluate a variable.
+ +

Function Details

+ +

anon_fun/3

+
+

anon_fun(Content, Line, Data) -> any()

+

+

+ Evaluate the definition of an anonymous function.

+ +

atom/2

+
+

atom(Val, Data) -> any()

+

+

+ Evaluate an atom.

+ +

case_pm/3

+
+

case_pm(Content, PMList, Data) -> any()

+

+

+ Evaluate a case expression.

+ +

clause/5

+
+

clause(Code, Vars, Guards, Data, BaseLabel) -> any()

+

+

+ Evaluate a single clause (might be from case, receive or if).

+ +

function_call/3

+
+

function_call(Function, ArgList, Data) -> any()

+

+

+ Evaluate the call of a function.

+ +

function_list/2

+
+

function_list(ContList, Data) -> any()

+

+

+ Evaluate the clauses of a function.

+ +

if_pm/2

+
+

if_pm(PMList, Data) -> any()

+

+

+ Evaluate a if expression.

+ +

list/3

+
+

list(HeadList, TailList, Data) -> any()

+

+

+ Evaluate a list.

+ +

map/2

+
+

map(Val, Data) -> any()

+

+

+ Evaluate a map. TODO

+ +

match/3

+
+

match(RightContent, LeftContent, Data) -> any()

+

+

+ Evaluate a variable declaration.

+ +

operation/4

+
+

operation(Symbol, LeftContent, RightContent, Data) -> any()

+

+

+ Evaluate an operation.

+ +

receive_pm/2

+
+

receive_pm(PMList, Data) -> any()

+

+

+ Evaluate a receive expression.

+ +

simple_type/3

+
+

simple_type(Type, Val, Data) -> any()

+

+

+ Evaluate a basic type.

+ +

tuple/2

+
+

tuple(Val, Data) -> any()

+

+

+ Evaluate a tuple.

+ +

variable/2

+
+

variable(VarName, Data) -> any()

+

+

+ Evaluate a variable.

+
+ + +

Generated by EDoc

+ + diff --git a/doc/fsa.html b/doc/fsa.html new file mode 100644 index 0000000..95669c3 --- /dev/null +++ b/doc/fsa.html @@ -0,0 +1,42 @@ + + + + +Module fsa + + + + +
+ +

Module fsa

+ + This module manage an FSA. + + +

Description

+ This module manage an FSA. + A choreography is basically an FSA (finite state automaton). This module + implements the basics automata's operations needed for the project. +

Function Index

+ +
minimize/1 + Minimize an FSA, using algorithms from Simone Martini and Maurizio Gabbrielli's + book: Programming Languages, Second edition, McGraw-Hill, 2011.
+ +

Function Details

+ +

minimize/1

+
+

minimize(NFA) -> digraph:graph() +

+

+

+ Minimize an FSA, using algorithms from Simone Martini and Maurizio Gabbrielli's + book: Programming Languages, Second edition, McGraw-Hill, 2011

+
+ + +

Generated by EDoc

+ + diff --git a/doc/github-markdown.css b/doc/github-markdown.css new file mode 100644 index 0000000..d32a314 --- /dev/null +++ b/doc/github-markdown.css @@ -0,0 +1,1195 @@ +@media (prefers-color-scheme: dark) { + .markdown-body, + [data-theme="dark"] { + /*dark*/ + color-scheme: dark; + --color-prettylights-syntax-comment: #8b949e; + --color-prettylights-syntax-constant: #79c0ff; + --color-prettylights-syntax-entity: #d2a8ff; + --color-prettylights-syntax-storage-modifier-import: #c9d1d9; + --color-prettylights-syntax-entity-tag: #7ee787; + --color-prettylights-syntax-keyword: #ff7b72; + --color-prettylights-syntax-string: #a5d6ff; + --color-prettylights-syntax-variable: #ffa657; + --color-prettylights-syntax-brackethighlighter-unmatched: #f85149; + --color-prettylights-syntax-invalid-illegal-text: #f0f6fc; + --color-prettylights-syntax-invalid-illegal-bg: #8e1519; + --color-prettylights-syntax-carriage-return-text: #f0f6fc; + --color-prettylights-syntax-carriage-return-bg: #b62324; + --color-prettylights-syntax-string-regexp: #7ee787; + --color-prettylights-syntax-markup-list: #f2cc60; + --color-prettylights-syntax-markup-heading: #1f6feb; + --color-prettylights-syntax-markup-italic: #c9d1d9; + --color-prettylights-syntax-markup-bold: #c9d1d9; + --color-prettylights-syntax-markup-deleted-text: #ffdcd7; + --color-prettylights-syntax-markup-deleted-bg: #67060c; + --color-prettylights-syntax-markup-inserted-text: #aff5b4; + --color-prettylights-syntax-markup-inserted-bg: #033a16; + --color-prettylights-syntax-markup-changed-text: #ffdfb6; + --color-prettylights-syntax-markup-changed-bg: #5a1e02; + --color-prettylights-syntax-markup-ignored-text: #c9d1d9; + --color-prettylights-syntax-markup-ignored-bg: #1158c7; + --color-prettylights-syntax-meta-diff-range: #d2a8ff; + --color-prettylights-syntax-brackethighlighter-angle: #8b949e; + --color-prettylights-syntax-sublimelinter-gutter-mark: #484f58; + --color-prettylights-syntax-constant-other-reference-link: #a5d6ff; + --color-fg-default: #e6edf3; + --color-fg-muted: #848d97; + --color-fg-subtle: #6e7681; + --color-canvas-default: #0d1117; + --color-canvas-subtle: #161b22; + --color-border-default: #30363d; + --color-border-muted: #21262d; + --color-neutral-muted: rgba(110,118,129,0.4); + --color-accent-fg: #2f81f7; + --color-accent-emphasis: #1f6feb; + --color-success-fg: #3fb950; + --color-success-emphasis: #238636; + --color-attention-fg: #d29922; + --color-attention-emphasis: #9e6a03; + --color-attention-subtle: rgba(187,128,9,0.15); + --color-danger-fg: #f85149; + --color-danger-emphasis: #da3633; + --color-done-fg: #a371f7; + --color-done-emphasis: #8957e5; + } +} + +@media (prefers-color-scheme: light) { + .markdown-body, + [data-theme="light"] { + /*light*/ + color-scheme: light; + --color-prettylights-syntax-comment: #57606a; + --color-prettylights-syntax-constant: #0550ae; + --color-prettylights-syntax-entity: #6639ba; + --color-prettylights-syntax-storage-modifier-import: #24292f; + --color-prettylights-syntax-entity-tag: #116329; + --color-prettylights-syntax-keyword: #cf222e; + --color-prettylights-syntax-string: #0a3069; + --color-prettylights-syntax-variable: #953800; + --color-prettylights-syntax-brackethighlighter-unmatched: #82071e; + --color-prettylights-syntax-invalid-illegal-text: #f6f8fa; + --color-prettylights-syntax-invalid-illegal-bg: #82071e; + --color-prettylights-syntax-carriage-return-text: #f6f8fa; + --color-prettylights-syntax-carriage-return-bg: #cf222e; + --color-prettylights-syntax-string-regexp: #116329; + --color-prettylights-syntax-markup-list: #3b2300; + --color-prettylights-syntax-markup-heading: #0550ae; + --color-prettylights-syntax-markup-italic: #24292f; + --color-prettylights-syntax-markup-bold: #24292f; + --color-prettylights-syntax-markup-deleted-text: #82071e; + --color-prettylights-syntax-markup-deleted-bg: #ffebe9; + --color-prettylights-syntax-markup-inserted-text: #116329; + --color-prettylights-syntax-markup-inserted-bg: #dafbe1; + --color-prettylights-syntax-markup-changed-text: #953800; + --color-prettylights-syntax-markup-changed-bg: #ffd8b5; + --color-prettylights-syntax-markup-ignored-text: #eaeef2; + --color-prettylights-syntax-markup-ignored-bg: #0550ae; + --color-prettylights-syntax-meta-diff-range: #8250df; + --color-prettylights-syntax-brackethighlighter-angle: #57606a; + --color-prettylights-syntax-sublimelinter-gutter-mark: #8c959f; + --color-prettylights-syntax-constant-other-reference-link: #0a3069; + --color-fg-default: #1F2328; + --color-fg-muted: #656d76; + --color-fg-subtle: #6e7781; + --color-canvas-default: #ffffff; + --color-canvas-subtle: #f6f8fa; + --color-border-default: #d0d7de; + --color-border-muted: hsla(210,18%,87%,1); + --color-neutral-muted: rgba(175,184,193,0.2); + --color-accent-fg: #0969da; + --color-accent-emphasis: #0969da; + --color-success-fg: #1a7f37; + --color-success-emphasis: #1f883d; + --color-attention-fg: #9a6700; + --color-attention-emphasis: #9a6700; + --color-attention-subtle: #fff8c5; + --color-danger-fg: #d1242f; + --color-danger-emphasis: #cf222e; + --color-done-fg: #8250df; + --color-done-emphasis: #8250df; + } +} + +.markdown-body { + -ms-text-size-adjust: 100%; + -webkit-text-size-adjust: 100%; + margin: 0; + color: var(--color-fg-default); + background-color: var(--color-canvas-default); + font-family: -apple-system,BlinkMacSystemFont,"Segoe UI","Noto Sans",Helvetica,Arial,sans-serif,"Apple Color Emoji","Segoe UI Emoji"; + font-size: 16px; + line-height: 1.5; + word-wrap: break-word; +} + +.markdown-body .octicon { + display: inline-block; + fill: currentColor; + vertical-align: text-bottom; +} + +.markdown-body h1:hover .anchor .octicon-link:before, +.markdown-body h2:hover .anchor .octicon-link:before, +.markdown-body h3:hover .anchor .octicon-link:before, +.markdown-body h4:hover .anchor .octicon-link:before, +.markdown-body h5:hover .anchor .octicon-link:before, +.markdown-body h6:hover .anchor .octicon-link:before { + width: 16px; + height: 16px; + content: ' '; + display: inline-block; + background-color: currentColor; + -webkit-mask-image: url("data:image/svg+xml,"); + mask-image: url("data:image/svg+xml,"); +} + +.markdown-body details, +.markdown-body figcaption, +.markdown-body figure { + display: block; +} + +.markdown-body summary { + display: list-item; +} + +.markdown-body [hidden] { + display: none !important; +} + +.markdown-body a { + background-color: transparent; + color: var(--color-accent-fg); + text-decoration: none; +} + +.markdown-body abbr[title] { + border-bottom: none; + -webkit-text-decoration: underline dotted; + text-decoration: underline dotted; +} + +.markdown-body b, +.markdown-body strong { + font-weight: var(--base-text-weight-semibold, 600); +} + +.markdown-body dfn { + font-style: italic; +} + +.markdown-body h1 { + margin: .67em 0; + font-weight: var(--base-text-weight-semibold, 600); + padding-bottom: .3em; + font-size: 2em; + border-bottom: 1px solid var(--color-border-muted); +} + +.markdown-body mark { + background-color: var(--color-attention-subtle); + color: var(--color-fg-default); +} + +.markdown-body small { + font-size: 90%; +} + +.markdown-body sub, +.markdown-body sup { + font-size: 75%; + line-height: 0; + position: relative; + vertical-align: baseline; +} + +.markdown-body sub { + bottom: -0.25em; +} + +.markdown-body sup { + top: -0.5em; +} + +.markdown-body img { + border-style: none; + max-width: 100%; + box-sizing: content-box; + background-color: var(--color-canvas-default); +} + +.markdown-body code, +.markdown-body kbd, +.markdown-body pre, +.markdown-body samp { + font-family: monospace; + font-size: 1em; +} + +.markdown-body figure { + margin: 1em 40px; +} + +.markdown-body hr { + box-sizing: content-box; + overflow: hidden; + background: transparent; + border-bottom: 1px solid var(--color-border-muted); + height: .25em; + padding: 0; + margin: 24px 0; + background-color: var(--color-border-default); + border: 0; +} + +.markdown-body input { + font: inherit; + margin: 0; + overflow: visible; + font-family: inherit; + font-size: inherit; + line-height: inherit; +} + +.markdown-body [type=button], +.markdown-body [type=reset], +.markdown-body [type=submit] { + -webkit-appearance: button; + appearance: button; +} + +.markdown-body [type=checkbox], +.markdown-body [type=radio] { + box-sizing: border-box; + padding: 0; +} + +.markdown-body [type=number]::-webkit-inner-spin-button, +.markdown-body [type=number]::-webkit-outer-spin-button { + height: auto; +} + +.markdown-body [type=search]::-webkit-search-cancel-button, +.markdown-body [type=search]::-webkit-search-decoration { + -webkit-appearance: none; + appearance: none; +} + +.markdown-body ::-webkit-input-placeholder { + color: inherit; + opacity: .54; +} + +.markdown-body ::-webkit-file-upload-button { + -webkit-appearance: button; + appearance: button; + font: inherit; +} + +.markdown-body a:hover { + text-decoration: underline; +} + +.markdown-body ::placeholder { + color: var(--color-fg-subtle); + opacity: 1; +} + +.markdown-body hr::before { + display: table; + content: ""; +} + +.markdown-body hr::after { + display: table; + clear: both; + content: ""; +} + +.markdown-body table { + border-spacing: 0; + border-collapse: collapse; + display: block; + width: max-content; + max-width: 100%; + overflow: auto; +} + +.markdown-body td, +.markdown-body th { + padding: 0; +} + +.markdown-body details summary { + cursor: pointer; +} + +.markdown-body details:not([open])>*:not(summary) { + display: none !important; +} + +.markdown-body a:focus, +.markdown-body [role=button]:focus, +.markdown-body input[type=radio]:focus, +.markdown-body input[type=checkbox]:focus { + outline: 2px solid var(--color-accent-fg); + outline-offset: -2px; + box-shadow: none; +} + +.markdown-body a:focus:not(:focus-visible), +.markdown-body [role=button]:focus:not(:focus-visible), +.markdown-body input[type=radio]:focus:not(:focus-visible), +.markdown-body input[type=checkbox]:focus:not(:focus-visible) { + outline: solid 1px transparent; +} + +.markdown-body a:focus-visible, +.markdown-body [role=button]:focus-visible, +.markdown-body input[type=radio]:focus-visible, +.markdown-body input[type=checkbox]:focus-visible { + outline: 2px solid var(--color-accent-fg); + outline-offset: -2px; + box-shadow: none; +} + +.markdown-body a:not([class]):focus, +.markdown-body a:not([class]):focus-visible, +.markdown-body input[type=radio]:focus, +.markdown-body input[type=radio]:focus-visible, +.markdown-body input[type=checkbox]:focus, +.markdown-body input[type=checkbox]:focus-visible { + outline-offset: 0; +} + +.markdown-body kbd { + display: inline-block; + padding: 3px 5px; + font: 11px ui-monospace,SFMono-Regular,SF Mono,Menlo,Consolas,Liberation Mono,monospace; + line-height: 10px; + color: var(--color-fg-default); + vertical-align: middle; + background-color: var(--color-canvas-subtle); + border: solid 1px var(--color-neutral-muted); + border-bottom-color: var(--color-neutral-muted); + border-radius: 6px; + box-shadow: inset 0 -1px 0 var(--color-neutral-muted); +} + +.markdown-body h1, +.markdown-body h2, +.markdown-body h3, +.markdown-body h4, +.markdown-body h5, +.markdown-body h6 { + margin-top: 24px; + margin-bottom: 16px; + font-weight: var(--base-text-weight-semibold, 600); + line-height: 1.25; +} + +.markdown-body h2 { + font-weight: var(--base-text-weight-semibold, 600); + padding-bottom: .3em; + font-size: 1.5em; + border-bottom: 1px solid var(--color-border-muted); +} + +.markdown-body h3 { + font-weight: var(--base-text-weight-semibold, 600); + font-size: 1.25em; +} + +.markdown-body h4 { + font-weight: var(--base-text-weight-semibold, 600); + font-size: 1em; +} + +.markdown-body h5 { + font-weight: var(--base-text-weight-semibold, 600); + font-size: .875em; +} + +.markdown-body h6 { + font-weight: var(--base-text-weight-semibold, 600); + font-size: .85em; + color: var(--color-fg-muted); +} + +.markdown-body p { + margin-top: 0; + margin-bottom: 10px; +} + +.markdown-body blockquote { + margin: 0; + padding: 0 1em; + color: var(--color-fg-muted); + border-left: .25em solid var(--color-border-default); +} + +.markdown-body ul, +.markdown-body ol { + margin-top: 0; + margin-bottom: 0; + padding-left: 2em; +} + +.markdown-body ol ol, +.markdown-body ul ol { + list-style-type: lower-roman; +} + +.markdown-body ul ul ol, +.markdown-body ul ol ol, +.markdown-body ol ul ol, +.markdown-body ol ol ol { + list-style-type: lower-alpha; +} + +.markdown-body dd { + margin-left: 0; +} + +.markdown-body tt, +.markdown-body code, +.markdown-body samp { + font-family: ui-monospace,SFMono-Regular,SF Mono,Menlo,Consolas,Liberation Mono,monospace; + font-size: 12px; +} + +.markdown-body pre { + margin-top: 0; + margin-bottom: 0; + font-family: ui-monospace,SFMono-Regular,SF Mono,Menlo,Consolas,Liberation Mono,monospace; + font-size: 12px; + word-wrap: normal; +} + +.markdown-body .octicon { + display: inline-block; + overflow: visible !important; + vertical-align: text-bottom; + fill: currentColor; +} + +.markdown-body input::-webkit-outer-spin-button, +.markdown-body input::-webkit-inner-spin-button { + margin: 0; + -webkit-appearance: none; + appearance: none; +} + +.markdown-body .mr-2 { + margin-right: var(--base-size-8, 8px) !important; +} + +.markdown-body::before { + display: table; + content: ""; +} + +.markdown-body::after { + display: table; + clear: both; + content: ""; +} + +.markdown-body>*:first-child { + margin-top: 0 !important; +} + +.markdown-body>*:last-child { + margin-bottom: 0 !important; +} + +.markdown-body a:not([href]) { + color: inherit; + text-decoration: none; +} + +.markdown-body .absent { + color: var(--color-danger-fg); +} + +.markdown-body .anchor { + float: left; + padding-right: 4px; + margin-left: -20px; + line-height: 1; +} + +.markdown-body .anchor:focus { + outline: none; +} + +.markdown-body p, +.markdown-body blockquote, +.markdown-body ul, +.markdown-body ol, +.markdown-body dl, +.markdown-body table, +.markdown-body pre, +.markdown-body details { + margin-top: 0; + margin-bottom: 16px; +} + +.markdown-body blockquote>:first-child { + margin-top: 0; +} + +.markdown-body blockquote>:last-child { + margin-bottom: 0; +} + +.markdown-body h1 .octicon-link, +.markdown-body h2 .octicon-link, +.markdown-body h3 .octicon-link, +.markdown-body h4 .octicon-link, +.markdown-body h5 .octicon-link, +.markdown-body h6 .octicon-link { + color: var(--color-fg-default); + vertical-align: middle; + visibility: hidden; +} + +.markdown-body h1:hover .anchor, +.markdown-body h2:hover .anchor, +.markdown-body h3:hover .anchor, +.markdown-body h4:hover .anchor, +.markdown-body h5:hover .anchor, +.markdown-body h6:hover .anchor { + text-decoration: none; +} + +.markdown-body h1:hover .anchor .octicon-link, +.markdown-body h2:hover .anchor .octicon-link, +.markdown-body h3:hover .anchor .octicon-link, +.markdown-body h4:hover .anchor .octicon-link, +.markdown-body h5:hover .anchor .octicon-link, +.markdown-body h6:hover .anchor .octicon-link { + visibility: visible; +} + +.markdown-body h1 tt, +.markdown-body h1 code, +.markdown-body h2 tt, +.markdown-body h2 code, +.markdown-body h3 tt, +.markdown-body h3 code, +.markdown-body h4 tt, +.markdown-body h4 code, +.markdown-body h5 tt, +.markdown-body h5 code, +.markdown-body h6 tt, +.markdown-body h6 code { + padding: 0 .2em; + font-size: inherit; +} + +.markdown-body summary h1, +.markdown-body summary h2, +.markdown-body summary h3, +.markdown-body summary h4, +.markdown-body summary h5, +.markdown-body summary h6 { + display: inline-block; +} + +.markdown-body summary h1 .anchor, +.markdown-body summary h2 .anchor, +.markdown-body summary h3 .anchor, +.markdown-body summary h4 .anchor, +.markdown-body summary h5 .anchor, +.markdown-body summary h6 .anchor { + margin-left: -40px; +} + +.markdown-body summary h1, +.markdown-body summary h2 { + padding-bottom: 0; + border-bottom: 0; +} + +.markdown-body ul.no-list, +.markdown-body ol.no-list { + padding: 0; + list-style-type: none; +} + +.markdown-body ol[type="a s"] { + list-style-type: lower-alpha; +} + +.markdown-body ol[type="A s"] { + list-style-type: upper-alpha; +} + +.markdown-body ol[type="i s"] { + list-style-type: lower-roman; +} + +.markdown-body ol[type="I s"] { + list-style-type: upper-roman; +} + +.markdown-body ol[type="1"] { + list-style-type: decimal; +} + +.markdown-body div>ol:not([type]) { + list-style-type: decimal; +} + +.markdown-body ul ul, +.markdown-body ul ol, +.markdown-body ol ol, +.markdown-body ol ul { + margin-top: 0; + margin-bottom: 0; +} + +.markdown-body li>p { + margin-top: 16px; +} + +.markdown-body li+li { + margin-top: .25em; +} + +.markdown-body dl { + padding: 0; +} + +.markdown-body dl dt { + padding: 0; + margin-top: 16px; + font-size: 1em; + font-style: italic; + font-weight: var(--base-text-weight-semibold, 600); +} + +.markdown-body dl dd { + padding: 0 16px; + margin-bottom: 16px; +} + +.markdown-body table th { + font-weight: var(--base-text-weight-semibold, 600); +} + +.markdown-body table th, +.markdown-body table td { + padding: 6px 13px; + border: 1px solid var(--color-border-default); +} + +.markdown-body table td>:last-child { + margin-bottom: 0; +} + +.markdown-body table tr { + background-color: var(--color-canvas-default); + border-top: 1px solid var(--color-border-muted); +} + +.markdown-body table tr:nth-child(2n) { + background-color: var(--color-canvas-subtle); +} + +.markdown-body table img { + background-color: transparent; +} + +.markdown-body img[align=right] { + padding-left: 20px; +} + +.markdown-body img[align=left] { + padding-right: 20px; +} + +.markdown-body .emoji { + max-width: none; + vertical-align: text-top; + background-color: transparent; +} + +.markdown-body span.frame { + display: block; + overflow: hidden; +} + +.markdown-body span.frame>span { + display: block; + float: left; + width: auto; + padding: 7px; + margin: 13px 0 0; + overflow: hidden; + border: 1px solid var(--color-border-default); +} + +.markdown-body span.frame span img { + display: block; + float: left; +} + +.markdown-body span.frame span span { + display: block; + padding: 5px 0 0; + clear: both; + color: var(--color-fg-default); +} + +.markdown-body span.align-center { + display: block; + overflow: hidden; + clear: both; +} + +.markdown-body span.align-center>span { + display: block; + margin: 13px auto 0; + overflow: hidden; + text-align: center; +} + +.markdown-body span.align-center span img { + margin: 0 auto; + text-align: center; +} + +.markdown-body span.align-right { + display: block; + overflow: hidden; + clear: both; +} + +.markdown-body span.align-right>span { + display: block; + margin: 13px 0 0; + overflow: hidden; + text-align: right; +} + +.markdown-body span.align-right span img { + margin: 0; + text-align: right; +} + +.markdown-body span.float-left { + display: block; + float: left; + margin-right: 13px; + overflow: hidden; +} + +.markdown-body span.float-left span { + margin: 13px 0 0; +} + +.markdown-body span.float-right { + display: block; + float: right; + margin-left: 13px; + overflow: hidden; +} + +.markdown-body span.float-right>span { + display: block; + margin: 13px auto 0; + overflow: hidden; + text-align: right; +} + +.markdown-body code, +.markdown-body tt { + padding: .2em .4em; + margin: 0; + font-size: 85%; + white-space: break-spaces; + background-color: var(--color-neutral-muted); + border-radius: 6px; +} + +.markdown-body code br, +.markdown-body tt br { + display: none; +} + +.markdown-body del code { + text-decoration: inherit; +} + +.markdown-body samp { + font-size: 85%; +} + +.markdown-body pre code { + font-size: 100%; +} + +.markdown-body pre>code { + padding: 0; + margin: 0; + word-break: normal; + white-space: pre; + background: transparent; + border: 0; +} + +.markdown-body .highlight { + margin-bottom: 16px; +} + +.markdown-body .highlight pre { + margin-bottom: 0; + word-break: normal; +} + +.markdown-body .highlight pre, +.markdown-body pre { + padding: 16px; + overflow: auto; + font-size: 85%; + line-height: 1.45; + color: var(--color-fg-default); + background-color: var(--color-canvas-subtle); + border-radius: 6px; +} + +.markdown-body pre code, +.markdown-body pre tt { + display: inline; + max-width: auto; + padding: 0; + margin: 0; + overflow: visible; + line-height: inherit; + word-wrap: normal; + background-color: transparent; + border: 0; +} + +.markdown-body .csv-data td, +.markdown-body .csv-data th { + padding: 5px; + overflow: hidden; + font-size: 12px; + line-height: 1; + text-align: left; + white-space: nowrap; +} + +.markdown-body .csv-data .blob-num { + padding: 10px 8px 9px; + text-align: right; + background: var(--color-canvas-default); + border: 0; +} + +.markdown-body .csv-data tr { + border-top: 0; +} + +.markdown-body .csv-data th { + font-weight: var(--base-text-weight-semibold, 600); + background: var(--color-canvas-subtle); + border-top: 0; +} + +.markdown-body [data-footnote-ref]::before { + content: "["; +} + +.markdown-body [data-footnote-ref]::after { + content: "]"; +} + +.markdown-body .footnotes { + font-size: 12px; + color: var(--color-fg-muted); + border-top: 1px solid var(--color-border-default); +} + +.markdown-body .footnotes ol { + padding-left: 16px; +} + +.markdown-body .footnotes ol ul { + display: inline-block; + padding-left: 16px; + margin-top: 16px; +} + +.markdown-body .footnotes li { + position: relative; +} + +.markdown-body .footnotes li:target::before { + position: absolute; + top: -8px; + right: -8px; + bottom: -8px; + left: -24px; + pointer-events: none; + content: ""; + border: 2px solid var(--color-accent-emphasis); + border-radius: 6px; +} + +.markdown-body .footnotes li:target { + color: var(--color-fg-default); +} + +.markdown-body .footnotes .data-footnote-backref g-emoji { + font-family: monospace; +} + +.markdown-body .pl-c { + color: var(--color-prettylights-syntax-comment); +} + +.markdown-body .pl-c1, +.markdown-body .pl-s .pl-v { + color: var(--color-prettylights-syntax-constant); +} + +.markdown-body .pl-e, +.markdown-body .pl-en { + color: var(--color-prettylights-syntax-entity); +} + +.markdown-body .pl-smi, +.markdown-body .pl-s .pl-s1 { + color: var(--color-prettylights-syntax-storage-modifier-import); +} + +.markdown-body .pl-ent { + color: var(--color-prettylights-syntax-entity-tag); +} + +.markdown-body .pl-k { + color: var(--color-prettylights-syntax-keyword); +} + +.markdown-body .pl-s, +.markdown-body .pl-pds, +.markdown-body .pl-s .pl-pse .pl-s1, +.markdown-body .pl-sr, +.markdown-body .pl-sr .pl-cce, +.markdown-body .pl-sr .pl-sre, +.markdown-body .pl-sr .pl-sra { + color: var(--color-prettylights-syntax-string); +} + +.markdown-body .pl-v, +.markdown-body .pl-smw { + color: var(--color-prettylights-syntax-variable); +} + +.markdown-body .pl-bu { + color: var(--color-prettylights-syntax-brackethighlighter-unmatched); +} + +.markdown-body .pl-ii { + color: var(--color-prettylights-syntax-invalid-illegal-text); + background-color: var(--color-prettylights-syntax-invalid-illegal-bg); +} + +.markdown-body .pl-c2 { + color: var(--color-prettylights-syntax-carriage-return-text); + background-color: var(--color-prettylights-syntax-carriage-return-bg); +} + +.markdown-body .pl-sr .pl-cce { + font-weight: bold; + color: var(--color-prettylights-syntax-string-regexp); +} + +.markdown-body .pl-ml { + color: var(--color-prettylights-syntax-markup-list); +} + +.markdown-body .pl-mh, +.markdown-body .pl-mh .pl-en, +.markdown-body .pl-ms { + font-weight: bold; + color: var(--color-prettylights-syntax-markup-heading); +} + +.markdown-body .pl-mi { + font-style: italic; + color: var(--color-prettylights-syntax-markup-italic); +} + +.markdown-body .pl-mb { + font-weight: bold; + color: var(--color-prettylights-syntax-markup-bold); +} + +.markdown-body .pl-md { + color: var(--color-prettylights-syntax-markup-deleted-text); + background-color: var(--color-prettylights-syntax-markup-deleted-bg); +} + +.markdown-body .pl-mi1 { + color: var(--color-prettylights-syntax-markup-inserted-text); + background-color: var(--color-prettylights-syntax-markup-inserted-bg); +} + +.markdown-body .pl-mc { + color: var(--color-prettylights-syntax-markup-changed-text); + background-color: var(--color-prettylights-syntax-markup-changed-bg); +} + +.markdown-body .pl-mi2 { + color: var(--color-prettylights-syntax-markup-ignored-text); + background-color: var(--color-prettylights-syntax-markup-ignored-bg); +} + +.markdown-body .pl-mdr { + font-weight: bold; + color: var(--color-prettylights-syntax-meta-diff-range); +} + +.markdown-body .pl-ba { + color: var(--color-prettylights-syntax-brackethighlighter-angle); +} + +.markdown-body .pl-sg { + color: var(--color-prettylights-syntax-sublimelinter-gutter-mark); +} + +.markdown-body .pl-corl { + text-decoration: underline; + color: var(--color-prettylights-syntax-constant-other-reference-link); +} + +.markdown-body g-emoji { + display: inline-block; + min-width: 1ch; + font-family: "Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol"; + font-size: 1em; + font-style: normal !important; + font-weight: var(--base-text-weight-normal, 400); + line-height: 1; + vertical-align: -0.075em; +} + +.markdown-body g-emoji img { + width: 1em; + height: 1em; +} + +.markdown-body .task-list-item { + list-style-type: none; +} + +.markdown-body .task-list-item label { + font-weight: var(--base-text-weight-normal, 400); +} + +.markdown-body .task-list-item.enabled label { + cursor: pointer; +} + +.markdown-body .task-list-item+.task-list-item { + margin-top: 4px; +} + +.markdown-body .task-list-item .handle { + display: none; +} + +.markdown-body .task-list-item-checkbox { + margin: 0 .2em .25em -1.4em; + vertical-align: middle; +} + +.markdown-body .contains-task-list:dir(rtl) .task-list-item-checkbox { + margin: 0 -1.6em .25em .2em; +} + +.markdown-body .contains-task-list { + position: relative; +} + +.markdown-body .contains-task-list:hover .task-list-item-convert-container, +.markdown-body .contains-task-list:focus-within .task-list-item-convert-container { + display: block; + width: auto; + height: 24px; + overflow: visible; + clip: auto; +} + +.markdown-body ::-webkit-calendar-picker-indicator { + filter: invert(50%); +} + +.markdown-body .markdown-alert { + padding: var(--base-size-8) var(--base-size-16); + margin-bottom: 16px; + color: inherit; + border-left: .25em solid var(--color-border-default); +} + +.markdown-body .markdown-alert>:first-child { + margin-top: 0; +} + +.markdown-body .markdown-alert>:last-child { + margin-bottom: 0; +} + +.markdown-body .markdown-alert .markdown-alert-title { + display: flex; + font-weight: var(--base-text-weight-medium, 500); + align-items: center; + line-height: 1; +} + +.markdown-body .markdown-alert.markdown-alert-note { + border-left-color: var(--color-accent-emphasis); +} + +.markdown-body .markdown-alert.markdown-alert-note .markdown-alert-title { + color: var(--color-accent-fg); +} + +.markdown-body .markdown-alert.markdown-alert-important { + border-left-color: var(--color-done-emphasis); +} + +.markdown-body .markdown-alert.markdown-alert-important .markdown-alert-title { + color: var(--color-done-fg); +} + +.markdown-body .markdown-alert.markdown-alert-warning { + border-left-color: var(--color-attention-emphasis); +} + +.markdown-body .markdown-alert.markdown-alert-warning .markdown-alert-title { + color: var(--color-attention-fg); +} + +.markdown-body .markdown-alert.markdown-alert-tip { + border-left-color: var(--color-success-emphasis); +} + +.markdown-body .markdown-alert.markdown-alert-tip .markdown-alert-title { + color: var(--color-success-fg); +} + +.markdown-body .markdown-alert.markdown-alert-caution { + border-left-color: var(--color-danger-emphasis); +} + +.markdown-body .markdown-alert.markdown-alert-caution .markdown-alert-title { + color: var(--color-danger-fg); +} diff --git a/doc/gv.html b/doc/gv.html new file mode 100644 index 0000000..7b83c34 --- /dev/null +++ b/doc/gv.html @@ -0,0 +1,38 @@ + + + + +Module gv + + + + +
+ +

Module gv

+ + This module generetes the localview. + + +

Description

+ This module generetes the localview. + Must be used after md:extract and lv:generate. +

Function Index

+ +
generate/2 + Generate the glabal view from an entrypoint and save it in a specified folder.
+ +

Function Details

+ +

generate/2

+
+

generate(Settings, EntryPoint) -> any()

+

+

+ Generate the glabal view from an entrypoint and save it in a specified folder.

+
+ + +

Generated by EDoc

+ + diff --git a/doc/index.html b/doc/index.html new file mode 100644 index 0000000..71a0038 --- /dev/null +++ b/doc/index.html @@ -0,0 +1,17 @@ + + + +The chorer application + + + + + + +<h2>This page uses frames</h2> +<p>Your browser does not accept frames. +<br>You should go to the <a href="overview-summary.html">non-frame version</a> instead. +</p> + + + \ No newline at end of file diff --git a/doc/lv.html b/doc/lv.html new file mode 100644 index 0000000..2e66ce9 --- /dev/null +++ b/doc/lv.html @@ -0,0 +1,53 @@ + + + + +Module lv + + + + +
+ +

Module lv

+ + This module generate a localview for each possible actor. + + +

Description

+ This module generate a localview for each possible actor. + Must be used after md:extract. +

Function Index

+ + + +
create_localview/3
eval_codeline/2
generate/1 + A localview is generated for each possible actor.
+ +

Function Details

+ +

create_localview/3

+
+

create_localview(ActorName, Settings, Save) -> any()

+

+
+ +

eval_codeline/2

+
+

eval_codeline(CodeLine, Data) -> any()

+

+
+ +

generate/1

+
+

generate(Settings) -> any()

+

+

+ A localview is generated for each possible actor. + md:extract must be used before this function.

+
+ + +

Generated by EDoc

+ + diff --git a/doc/md.html b/doc/md.html new file mode 100644 index 0000000..911b0a1 --- /dev/null +++ b/doc/md.html @@ -0,0 +1,50 @@ + + + + +Module md + + + + +
+ +

Module md

+ + The metadata extractor module. + + +

Description

+ The metadata extractor module. + This module extract all the essential metadata prior to the localviews + and globalview generation. +

Function Index

+ + +
extract/1 + Extract the metadata: the AST (abstract syntax tree) for each function + and all the Actor List.
parse_file/1 + Return the AST of the file localted in Path.
+ +

Function Details

+ +

extract/1

+
+

extract(InputFile) -> any()

+

+

+ Extract the metadata: the AST (abstract syntax tree) for each function + and all the Actor List.

+ +

parse_file/1

+
+

parse_file(Path) -> any()

+

+

+ Return the AST of the file localted in Path.

+
+ + +

Generated by EDoc

+ + diff --git a/doc/modules-frame.html b/doc/modules-frame.html new file mode 100644 index 0000000..3114826 --- /dev/null +++ b/doc/modules-frame.html @@ -0,0 +1,21 @@ + + + +The chorer application + + + + +

Modules

+ + + + + + + + + +
actor_emul
chorer
digraph_to_dot
eval
fsa
gv
lv
md
share
+ + \ No newline at end of file diff --git a/doc/overview-summary.html b/doc/overview-summary.html new file mode 100644 index 0000000..136fc5b --- /dev/null +++ b/doc/overview-summary.html @@ -0,0 +1,17 @@ + + + + +The chorer application + + + + + +

The chorer application

+ +
+ +

Generated by EDoc

+ + diff --git a/doc/prism-core.min.js.v1.26.0 b/doc/prism-core.min.js.v1.26.0 new file mode 100644 index 0000000..6aa6722 --- /dev/null +++ b/doc/prism-core.min.js.v1.26.0 @@ -0,0 +1 @@ +var _self="undefined"!=typeof window?window:"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope?self:{},Prism=function(u){var t=/(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i,n=0,e={},M={manual:u.Prism&&u.Prism.manual,disableWorkerMessageHandler:u.Prism&&u.Prism.disableWorkerMessageHandler,util:{encode:function e(n){return n instanceof W?new W(n.type,e(n.content),n.alias):Array.isArray(n)?n.map(e):n.replace(/&/g,"&").replace(/=l.reach);y+=m.value.length,m=m.next){var k=m.value;if(t.length>n.length)return;if(!(k instanceof W)){var x,b=1;if(h){if(!(x=z(p,y,n,f))||x.index>=n.length)break;var w=x.index,A=x.index+x[0].length,P=y;for(P+=m.value.length;P<=w;)m=m.next,P+=m.value.length;if(P-=m.value.length,y=P,m.value instanceof W)continue;for(var E=m;E!==t.tail&&(Pl.reach&&(l.reach=j);var C=m.prev;S&&(C=I(t,C,S),y+=S.length),q(t,C,b);var N=new W(o,g?M.tokenize(L,g):L,d,L);if(m=I(t,C,N),O&&I(t,m,O),1l.reach&&(l.reach=_.reach)}}}}}}(e,a,n,a.head,0),function(e){var n=[],t=e.head.next;for(;t!==e.tail;)n.push(t.value),t=t.next;return n}(a)},hooks:{all:{},add:function(e,n){var t=M.hooks.all;t[e]=t[e]||[],t[e].push(n)},run:function(e,n){var t=M.hooks.all[e];if(t&&t.length)for(var r,a=0;r=t[a++];)r(n)}},Token:W};function W(e,n,t,r){this.type=e,this.content=n,this.alias=t,this.length=0|(r||"").length}function z(e,n,t,r){e.lastIndex=n;var a=e.exec(t);if(a&&r&&a[1]){var i=a[1].length;a.index+=i,a[0]=a[0].slice(i)}return a}function i(){var e={value:null,prev:null,next:null},n={value:null,prev:e,next:null};e.next=n,this.head=e,this.tail=n,this.length=0}function I(e,n,t){var r=n.next,a={value:t,prev:n,next:r};return n.next=a,r.prev=a,e.length++,a}function q(e,n,t){for(var r=n.next,a=0;a"+a.content+""},!u.document)return u.addEventListener&&(M.disableWorkerMessageHandler||u.addEventListener("message",function(e){var n=JSON.parse(e.data),t=n.language,r=n.code,a=n.immediateClose;u.postMessage(M.highlight(r,M.languages[t],t)),a&&u.close()},!1)),M;var r=M.util.currentScript();function a(){M.manual||M.highlightAll()}if(r&&(M.filename=r.src,r.hasAttribute("data-manual")&&(M.manual=!0)),!M.manual){var l=document.readyState;"loading"===l||"interactive"===l&&r&&r.defer?document.addEventListener("DOMContentLoaded",a):window.requestAnimationFrame?window.requestAnimationFrame(a):window.setTimeout(a,16)}return M}(_self);"undefined"!=typeof module&&module.exports&&(module.exports=Prism),"undefined"!=typeof global&&(global.Prism=Prism); \ No newline at end of file diff --git a/doc/prism-dark.min.css.v1.26.0 b/doc/prism-dark.min.css.v1.26.0 new file mode 100644 index 0000000..e592b5b --- /dev/null +++ b/doc/prism-dark.min.css.v1.26.0 @@ -0,0 +1 @@ +code[class*=language-],pre[class*=language-]{color:#fff;background:0 0;text-shadow:0 -.1em .2em #000;font-family:Consolas,Monaco,'Andale Mono','Ubuntu Mono',monospace;font-size:1em;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none}@media print{code[class*=language-],pre[class*=language-]{text-shadow:none}}:not(pre)>code[class*=language-],pre[class*=language-]{background:#4c3f33}pre[class*=language-]{padding:1em;margin:.5em 0;overflow:auto;border:.3em solid #7a6651;border-radius:.5em;box-shadow:1px 1px .5em #000 inset}:not(pre)>code[class*=language-]{padding:.15em .2em .05em;border-radius:.3em;border:.13em solid #7a6651;box-shadow:1px 1px .3em -.1em #000 inset;white-space:normal}.token.cdata,.token.comment,.token.doctype,.token.prolog{color:#997f66}.token.punctuation{opacity:.7}.token.namespace{opacity:.7}.token.boolean,.token.constant,.token.number,.token.property,.token.symbol,.token.tag{color:#d1939e}.token.attr-name,.token.builtin,.token.char,.token.inserted,.token.selector,.token.string{color:#bce051}.language-css .token.string,.style .token.string,.token.entity,.token.operator,.token.url,.token.variable{color:#f4b73d}.token.atrule,.token.attr-value,.token.keyword{color:#d1939e}.token.important,.token.regex{color:#e90}.token.bold,.token.important{font-weight:700}.token.italic{font-style:italic}.token.entity{cursor:help}.token.deleted{color:red} \ No newline at end of file diff --git a/doc/prism-elixir.min.js.v1.26.0 b/doc/prism-elixir.min.js.v1.26.0 new file mode 100644 index 0000000..ec0d974 --- /dev/null +++ b/doc/prism-elixir.min.js.v1.26.0 @@ -0,0 +1 @@ +Prism.languages.elixir={doc:{pattern:/@(?:doc|moduledoc)\s+(?:("""|''')[\s\S]*?\1|("|')(?:\\(?:\r\n|[\s\S])|(?!\2)[^\\\r\n])*\2)/,inside:{attribute:/^@\w+/,string:/['"][\s\S]+/}},comment:{pattern:/#.*/,greedy:!0},regex:{pattern:/~[rR](?:("""|''')(?:\\[\s\S]|(?!\1)[^\\])+\1|([\/|"'])(?:\\.|(?!\2)[^\\\r\n])+\2|\((?:\\.|[^\\)\r\n])+\)|\[(?:\\.|[^\\\]\r\n])+\]|\{(?:\\.|[^\\}\r\n])+\}|<(?:\\.|[^\\>\r\n])+>)[uismxfr]*/,greedy:!0},string:[{pattern:/~[cCsSwW](?:("""|''')(?:\\[\s\S]|(?!\1)[^\\])+\1|([\/|"'])(?:\\.|(?!\2)[^\\\r\n])+\2|\((?:\\.|[^\\)\r\n])+\)|\[(?:\\.|[^\\\]\r\n])+\]|\{(?:\\.|#\{[^}]+\}|#(?!\{)|[^#\\}\r\n])+\}|<(?:\\.|[^\\>\r\n])+>)[csa]?/,greedy:!0,inside:{}},{pattern:/("""|''')[\s\S]*?\1/,greedy:!0,inside:{}},{pattern:/("|')(?:\\(?:\r\n|[\s\S])|(?!\1)[^\\\r\n])*\1/,greedy:!0,inside:{}}],atom:{pattern:/(^|[^:]):\w+/,lookbehind:!0,alias:"symbol"},module:{pattern:/\b[A-Z]\w*\b/,alias:"class-name"},"attr-name":/\b\w+\??:(?!:)/,argument:{pattern:/(^|[^&])&\d+/,lookbehind:!0,alias:"variable"},attribute:{pattern:/@\w+/,alias:"variable"},function:/\b[_a-zA-Z]\w*[?!]?(?:(?=\s*(?:\.\s*)?\()|(?=\/\d))/,number:/\b(?:0[box][a-f\d_]+|\d[\d_]*)(?:\.[\d_]+)?(?:e[+-]?[\d_]+)?\b/i,keyword:/\b(?:after|alias|and|case|catch|cond|def(?:callback|delegate|exception|impl|macro|module|n|np|p|protocol|struct)?|do|else|end|fn|for|if|import|not|or|quote|raise|require|rescue|try|unless|unquote|use|when)\b/,boolean:/\b(?:false|nil|true)\b/,operator:[/\bin\b|&&?|\|[|>]?|\\\\|::|\.\.\.?|\+\+?|-[->]?|<[-=>]|>=|!==?|\B!|=(?:==?|[>~])?|[*\/^]/,{pattern:/([^<])<(?!<)/,lookbehind:!0},{pattern:/([^>])>(?!>)/,lookbehind:!0}],punctuation:/<<|>>|[.,%\[\]{}()]/},Prism.languages.elixir.string.forEach(function(e){e.inside={interpolation:{pattern:/#\{[^}]+\}/,inside:{delimiter:{pattern:/^#\{|\}$/,alias:"punctuation"},rest:Prism.languages.elixir}}}}); \ No newline at end of file diff --git a/doc/prism-erlang.min.js.v1.26.0 b/doc/prism-erlang.min.js.v1.26.0 new file mode 100644 index 0000000..7d041ab --- /dev/null +++ b/doc/prism-erlang.min.js.v1.26.0 @@ -0,0 +1 @@ +Prism.languages.erlang={comment:/%.+/,string:{pattern:/"(?:\\.|[^\\"\r\n])*"/,greedy:!0},"quoted-function":{pattern:/'(?:\\.|[^\\'\r\n])+'(?=\()/,alias:"function"},"quoted-atom":{pattern:/'(?:\\.|[^\\'\r\n])+'/,alias:"atom"},boolean:/\b(?:false|true)\b/,keyword:/\b(?:after|case|catch|end|fun|if|of|receive|try|when)\b/,number:[/\$\\?./,/\b\d+#[a-z0-9]+/i,/(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i],function:/\b[a-z][\w@]*(?=\()/,variable:{pattern:/(^|[^@])(?:\b|\?)[A-Z_][\w@]*/,lookbehind:!0},operator:[/[=\/<>:]=|=[:\/]=|\+\+?|--?|[=*\/!]|\b(?:and|andalso|band|bnot|bor|bsl|bsr|bxor|div|not|or|orelse|rem|xor)\b/,{pattern:/(^|[^<])<(?!<)/,lookbehind:!0},{pattern:/(^|[^>])>(?!>)/,lookbehind:!0}],atom:/\b[a-z][\w@]*/,punctuation:/[()[\]{}:;,.#|]|<<|>>/}; \ No newline at end of file diff --git a/doc/prism-okaidia.min.css.v1.26.0 b/doc/prism-okaidia.min.css.v1.26.0 new file mode 100644 index 0000000..dc0b418 --- /dev/null +++ b/doc/prism-okaidia.min.css.v1.26.0 @@ -0,0 +1 @@ +code[class*=language-],pre[class*=language-]{color:#f8f8f2;background:0 0;text-shadow:0 1px rgba(0,0,0,.3);font-family:Consolas,Monaco,'Andale Mono','Ubuntu Mono',monospace;font-size:1em;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none}pre[class*=language-]{padding:1em;margin:.5em 0;overflow:auto;border-radius:.3em}:not(pre)>code[class*=language-],pre[class*=language-]{background:#272822}:not(pre)>code[class*=language-]{padding:.1em;border-radius:.3em;white-space:normal}.token.cdata,.token.comment,.token.doctype,.token.prolog{color:#8292a2}.token.punctuation{color:#f8f8f2}.token.namespace{opacity:.7}.token.constant,.token.deleted,.token.property,.token.symbol,.token.tag{color:#f92672}.token.boolean,.token.number{color:#ae81ff}.token.attr-name,.token.builtin,.token.char,.token.inserted,.token.selector,.token.string{color:#a6e22e}.language-css .token.string,.style .token.string,.token.entity,.token.operator,.token.url,.token.variable{color:#f8f8f2}.token.atrule,.token.attr-value,.token.class-name,.token.function{color:#e6db74}.token.keyword{color:#66d9ef}.token.important,.token.regex{color:#fd971f}.token.bold,.token.important{font-weight:700}.token.italic{font-style:italic}.token.entity{cursor:help} \ No newline at end of file diff --git a/doc/prism-twilight.min.css.v1.26.0 b/doc/prism-twilight.min.css.v1.26.0 new file mode 100644 index 0000000..e598be8 --- /dev/null +++ b/doc/prism-twilight.min.css.v1.26.0 @@ -0,0 +1 @@ +code[class*=language-],pre[class*=language-]{color:#fff;background:0 0;font-family:Consolas,Monaco,'Andale Mono','Ubuntu Mono',monospace;font-size:1em;text-align:left;text-shadow:0 -.1em .2em #000;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none}:not(pre)>code[class*=language-],pre[class*=language-]{background:#141414}pre[class*=language-]{border-radius:.5em;border:.3em solid #545454;box-shadow:1px 1px .5em #000 inset;margin:.5em 0;overflow:auto;padding:1em}pre[class*=language-]::-moz-selection{background:#27292a}pre[class*=language-]::selection{background:#27292a}code[class*=language-] ::-moz-selection,code[class*=language-]::-moz-selection,pre[class*=language-] ::-moz-selection,pre[class*=language-]::-moz-selection{text-shadow:none;background:hsla(0,0%,93%,.15)}code[class*=language-] ::selection,code[class*=language-]::selection,pre[class*=language-] ::selection,pre[class*=language-]::selection{text-shadow:none;background:hsla(0,0%,93%,.15)}:not(pre)>code[class*=language-]{border-radius:.3em;border:.13em solid #545454;box-shadow:1px 1px .3em -.1em #000 inset;padding:.15em .2em .05em;white-space:normal}.token.cdata,.token.comment,.token.doctype,.token.prolog{color:#777}.token.punctuation{opacity:.7}.token.namespace{opacity:.7}.token.boolean,.token.deleted,.token.number,.token.tag{color:#ce6849}.token.builtin,.token.constant,.token.keyword,.token.property,.token.selector,.token.symbol{color:#f9ed99}.language-css .token.string,.style .token.string,.token.attr-name,.token.attr-value,.token.char,.token.entity,.token.inserted,.token.operator,.token.string,.token.url,.token.variable{color:#909e6a}.token.atrule{color:#7385a5}.token.important,.token.regex{color:#e8c062}.token.bold,.token.important{font-weight:700}.token.italic{font-style:italic}.token.entity{cursor:help}.language-markup .token.attr-name,.language-markup .token.punctuation,.language-markup .token.tag{color:#ac885c}.token{position:relative;z-index:1}.line-highlight.line-highlight{background:hsla(0,0%,33%,.25);background:linear-gradient(to right,hsla(0,0%,33%,.1) 70%,hsla(0,0%,33%,0));border-bottom:1px dashed #545454;border-top:1px dashed #545454;margin-top:.75em;z-index:0}.line-highlight.line-highlight:before,.line-highlight.line-highlight[data-end]:after{background-color:#8693a6;color:#f4f1ef} \ No newline at end of file diff --git a/doc/prism.css b/doc/prism.css new file mode 100644 index 0000000..8c4cc05 --- /dev/null +++ b/doc/prism.css @@ -0,0 +1 @@ +code[class*=language-],pre[class*=language-]{color:#000;background:0 0;text-shadow:0 1px #fff;font-family:Consolas,Monaco,'Andale Mono','Ubuntu Mono',monospace;font-size:1em;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none}code[class*=language-] ::-moz-selection,code[class*=language-]::-moz-selection,pre[class*=language-] ::-moz-selection,pre[class*=language-]::-moz-selection{text-shadow:none;background:#b3d4fc}code[class*=language-] ::selection,code[class*=language-]::selection,pre[class*=language-] ::selection,pre[class*=language-]::selection{text-shadow:none;background:#b3d4fc}@media print{code[class*=language-],pre[class*=language-]{text-shadow:none}}pre[class*=language-]{padding:1em;margin:.5em 0;overflow:auto}:not(pre)>code[class*=language-],pre[class*=language-]{background:#f5f2f0}:not(pre)>code[class*=language-]{padding:.1em;border-radius:.3em;white-space:normal}.token.cdata,.token.comment,.token.doctype,.token.prolog{color:#708090}.token.punctuation{color:#999}.token.namespace{opacity:.7}.token.boolean,.token.constant,.token.deleted,.token.number,.token.property,.token.symbol,.token.tag{color:#905}.token.attr-name,.token.builtin,.token.char,.token.inserted,.token.selector,.token.string{color:#690}.language-css .token.string,.style .token.string,.token.entity,.token.operator,.token.url{color:#9a6e3a;background:hsla(0,0%,100%,.5)}.token.atrule,.token.attr-value,.token.keyword{color:#07a}.token.class-name,.token.function{color:#dd4a68}.token.important,.token.regex,.token.variable{color:#e90}.token.bold,.token.important{font-weight:700}.token.italic{font-style:italic}.token.entity{cursor:help} \ No newline at end of file diff --git a/doc/prism.js b/doc/prism.js new file mode 100644 index 0000000..bfd4850 --- /dev/null +++ b/doc/prism.js @@ -0,0 +1 @@ +var _self="undefined"!=typeof window?window:"undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope?self:{},Prism=function(u){var t=/(?:^|\s)lang(?:uage)?-([\w-]+)(?=\s|$)/i,n=0,e={},M={manual:u.Prism&&u.Prism.manual,disableWorkerMessageHandler:u.Prism&&u.Prism.disableWorkerMessageHandler,util:{encode:function e(n){return n instanceof W?new W(n.type,e(n.content),n.alias):Array.isArray(n)?n.map(e):n.replace(/&/g,"&").replace(/=l.reach);y+=m.value.length,m=m.next){var k=m.value;if(t.length>n.length)return;if(!(k instanceof W)){var x,b=1;if(h){if(!(x=z(p,y,n,f))||x.index>=n.length)break;var w=x.index,A=x.index+x[0].length,P=y;for(P+=m.value.length;P<=w;)m=m.next,P+=m.value.length;if(P-=m.value.length,y=P,m.value instanceof W)continue;for(var E=m;E!==t.tail&&(Pl.reach&&(l.reach=j);var C=m.prev;S&&(C=I(t,C,S),y+=S.length),q(t,C,b);var N=new W(o,g?M.tokenize(L,g):L,d,L);if(m=I(t,C,N),O&&I(t,m,O),1l.reach&&(l.reach=_.reach)}}}}}}(e,a,n,a.head,0),function(e){var n=[],t=e.head.next;for(;t!==e.tail;)n.push(t.value),t=t.next;return n}(a)},hooks:{all:{},add:function(e,n){var t=M.hooks.all;t[e]=t[e]||[],t[e].push(n)},run:function(e,n){var t=M.hooks.all[e];if(t&&t.length)for(var r,a=0;r=t[a++];)r(n)}},Token:W};function W(e,n,t,r){this.type=e,this.content=n,this.alias=t,this.length=0|(r||"").length}function z(e,n,t,r){e.lastIndex=n;var a=e.exec(t);if(a&&r&&a[1]){var i=a[1].length;a.index+=i,a[0]=a[0].slice(i)}return a}function i(){var e={value:null,prev:null,next:null},n={value:null,prev:e,next:null};e.next=n,this.head=e,this.tail=n,this.length=0}function I(e,n,t){var r=n.next,a={value:t,prev:n,next:r};return n.next=a,r.prev=a,e.length++,a}function q(e,n,t){for(var r=n.next,a=0;a"+a.content+""},!u.document)return u.addEventListener&&(M.disableWorkerMessageHandler||u.addEventListener("message",function(e){var n=JSON.parse(e.data),t=n.language,r=n.code,a=n.immediateClose;u.postMessage(M.highlight(r,M.languages[t],t)),a&&u.close()},!1)),M;var r=M.util.currentScript();function a(){M.manual||M.highlightAll()}if(r&&(M.filename=r.src,r.hasAttribute("data-manual")&&(M.manual=!0)),!M.manual){var l=document.readyState;"loading"===l||"interactive"===l&&r&&r.defer?document.addEventListener("DOMContentLoaded",a):window.requestAnimationFrame?window.requestAnimationFrame(a):window.setTimeout(a,16)}return M}(_self);"undefined"!=typeof module&&module.exports&&(module.exports=Prism),"undefined"!=typeof global&&(global.Prism=Prism);Prism.languages.erlang={comment:/%.+/,string:{pattern:/"(?:\\.|[^\\"\r\n])*"/,greedy:!0},"quoted-function":{pattern:/'(?:\\.|[^\\'\r\n])+'(?=\()/,alias:"function"},"quoted-atom":{pattern:/'(?:\\.|[^\\'\r\n])+'/,alias:"atom"},boolean:/\b(?:false|true)\b/,keyword:/\b(?:after|case|catch|end|fun|if|of|receive|try|when)\b/,number:[/\$\\?./,/\b\d+#[a-z0-9]+/i,/(?:\b\d+(?:\.\d*)?|\B\.\d+)(?:e[+-]?\d+)?/i],function:/\b[a-z][\w@]*(?=\()/,variable:{pattern:/(^|[^@])(?:\b|\?)[A-Z_][\w@]*/,lookbehind:!0},operator:[/[=\/<>:]=|=[:\/]=|\+\+?|--?|[=*\/!]|\b(?:and|andalso|band|bnot|bor|bsl|bsr|bxor|div|not|or|orelse|rem|xor)\b/,{pattern:/(^|[^<])<(?!<)/,lookbehind:!0},{pattern:/(^|[^>])>(?!>)/,lookbehind:!0}],atom:/\b[a-z][\w@]*/,punctuation:/[()[\]{}:;,.#|]|<<|>>/}; \ No newline at end of file diff --git a/doc/prism.min.css.v1.26.0 b/doc/prism.min.css.v1.26.0 new file mode 100644 index 0000000..8c4cc05 --- /dev/null +++ b/doc/prism.min.css.v1.26.0 @@ -0,0 +1 @@ +code[class*=language-],pre[class*=language-]{color:#000;background:0 0;text-shadow:0 1px #fff;font-family:Consolas,Monaco,'Andale Mono','Ubuntu Mono',monospace;font-size:1em;text-align:left;white-space:pre;word-spacing:normal;word-break:normal;word-wrap:normal;line-height:1.5;-moz-tab-size:4;-o-tab-size:4;tab-size:4;-webkit-hyphens:none;-moz-hyphens:none;-ms-hyphens:none;hyphens:none}code[class*=language-] ::-moz-selection,code[class*=language-]::-moz-selection,pre[class*=language-] ::-moz-selection,pre[class*=language-]::-moz-selection{text-shadow:none;background:#b3d4fc}code[class*=language-] ::selection,code[class*=language-]::selection,pre[class*=language-] ::selection,pre[class*=language-]::selection{text-shadow:none;background:#b3d4fc}@media print{code[class*=language-],pre[class*=language-]{text-shadow:none}}pre[class*=language-]{padding:1em;margin:.5em 0;overflow:auto}:not(pre)>code[class*=language-],pre[class*=language-]{background:#f5f2f0}:not(pre)>code[class*=language-]{padding:.1em;border-radius:.3em;white-space:normal}.token.cdata,.token.comment,.token.doctype,.token.prolog{color:#708090}.token.punctuation{color:#999}.token.namespace{opacity:.7}.token.boolean,.token.constant,.token.deleted,.token.number,.token.property,.token.symbol,.token.tag{color:#905}.token.attr-name,.token.builtin,.token.char,.token.inserted,.token.selector,.token.string{color:#690}.language-css .token.string,.style .token.string,.token.entity,.token.operator,.token.url{color:#9a6e3a;background:hsla(0,0%,100%,.5)}.token.atrule,.token.attr-value,.token.keyword{color:#07a}.token.class-name,.token.function{color:#dd4a68}.token.important,.token.regex,.token.variable{color:#e90}.token.bold,.token.important{font-weight:700}.token.italic{font-style:italic}.token.entity{cursor:help} \ No newline at end of file diff --git a/doc/share.html b/doc/share.html new file mode 100644 index 0000000..22aad01 --- /dev/null +++ b/doc/share.html @@ -0,0 +1,200 @@ + + + + +Module share + + + + +
+ +

Module share

+ + Module with some common functions used everywhere in the project. + + +

Description

+ Module with some common functions used everywhere in the project. +

Function Index

+ + + + + + + + + + + + + + + + + + + + + + + +
add_vertex/1
atol/1
del_vertex/2
error/3
find_var/2
first/1 + Pick first element from a list.
get_base_label/2
get_edgedata/1
get_fun_ast/1
get_graph/1
get_localview/1
if_final_get_n/1
inc_spawn_counter/1
is_erlvar/1 + Return true if first letter's atom is uppercase (it's a variable in erlang), + otherwise false.
is_uppercase/1 + If the input character is uppercase return true, otherwise false.
ltoa/1
merge_fun_ar/2
parse_actor_string/1
remove_last/1 + Remove the last element from a list.
save_graph/4
save_graph_to_file/4
should_minimize/1
warning/3
+ +

Function Details

+ +

add_vertex/1

+
+

add_vertex(G) -> digraph:vertex() +

+

+
+ +

atol/1

+
+

atol(A) -> any()

+

+
+ +

del_vertex/2

+
+

del_vertex(G, V) -> any()

+

+
+ +

error/3

+
+

error(String, Content, RetData) -> any()

+

+
+ +

find_var/2

+
+

find_var(Tail, Name) -> any()

+

+
+ +

first/1

+
+

first(X1) -> any()

+

+

+ Pick first element from a list

+ +

get_base_label/2

+
+

get_base_label(SetPm, Label) -> any()

+

+
+ +

get_edgedata/1

+
+

get_edgedata(FunName) -> any()

+

+
+ +

get_fun_ast/1

+
+

get_fun_ast(FunName) -> any()

+

+
+ +

get_graph/1

+
+

get_graph(FunName) -> any()

+

+
+ +

get_localview/1

+
+

get_localview(FunName) -> any()

+

+
+ +

if_final_get_n/1

+
+

if_final_get_n(L) -> any()

+

+
+ +

inc_spawn_counter/1

+
+

inc_spawn_counter(Name) -> any()

+

+
+ +

is_erlvar/1

+
+

is_erlvar(Name) -> any()

+

+

+ Return true if first letter's atom is uppercase (it's a variable in erlang), + otherwise false.

+ +

is_uppercase/1

+
+

is_uppercase(Char) -> any()

+

+

+ If the input character is uppercase return true, otherwise false.

+ +

ltoa/1

+
+

ltoa(L) -> any()

+

+
+ +

merge_fun_ar/2

+
+

merge_fun_ar(Name, Arity) -> any()

+

+
+ +

parse_actor_string/1

+
+

parse_actor_string(String) -> any()

+

+
+ +

remove_last/1

+
+

remove_last(Item) -> any()

+

+

+ Remove the last element from a list.

+ +

save_graph/4

+
+

save_graph(Data, Settings, FunName, Mode) -> any()

+

+
+ +

save_graph_to_file/4

+
+

save_graph_to_file(Graph, Dir, FileName, Type) -> any()

+

+
+ +

should_minimize/1

+
+

should_minimize(S) -> any()

+

+
+ +

warning/3

+
+

warning(String, Content, RetData) -> any()

+

+
+
+ + +

Generated by EDoc

+ + diff --git a/doc/stylesheet.css b/doc/stylesheet.css new file mode 100644 index 0000000..ab170c0 --- /dev/null +++ b/doc/stylesheet.css @@ -0,0 +1,55 @@ +/* standard EDoc style sheet */ +body { + font-family: Verdana, Arial, Helvetica, sans-serif; + margin-left: .25in; + margin-right: .2in; + margin-top: 0.2in; + margin-bottom: 0.2in; + color: #000000; + background-color: #ffffff; +} +h1,h2 { + margin-left: -0.2in; +} +div.navbar { + background-color: #add8e6; + padding: 0.2em; +} +h2.indextitle { + padding: 0.4em; + background-color: #add8e6; +} +h3.function,h3.typedecl { + background-color: #add8e6; + padding-left: 1em; +} +div.spec { + margin-left: 2em; + background-color: #eeeeee; +} +a.module { + text-decoration:none +} +a.module:hover { + background-color: #eeeeee; +} +ul.definitions { + list-style-type: none; +} +ul.index { + list-style-type: none; + background-color: #eeeeee; +} + +/* + * Minor style tweaks + */ +ul { + list-style-type: square; +} +table { + border-collapse: collapse; +} +td { + padding: 3 +} diff --git a/docs/index.html b/docs/index.html deleted file mode 100644 index efe5048..0000000 --- a/docs/index.html +++ /dev/null @@ -1 +0,0 @@ -

Hello world!

\ No newline at end of file diff --git a/rebar.config b/rebar.config index 5cf9f99..b99d000 100644 --- a/rebar.config +++ b/rebar.config @@ -6,6 +6,10 @@ {apps, [test]} ]}. +{project_plugins, [rebar3_edoc_extensions]}. +{prismjs_theme, "default"}. +{prismjs_languages, ["erlang"]}. + {compiler_error_format, rich}. {plugins, [rebar3_auto]}. \ No newline at end of file diff --git a/src/choreography/actor_emul.erl b/src/choreography/actor_emul.erl index 032e5ce..f6a0d0c 100644 --- a/src/choreography/actor_emul.erl +++ b/src/choreography/actor_emul.erl @@ -1,3 +1,8 @@ +%%%------------------------------------------------------------------- +%%% @doc +%%% This module simulate an actor's localview during a globalview. +%%% @end +%%%------------------------------------------------------------------- -module(actor_emul). -include("../share/common_data.hrl"). @@ -22,25 +27,56 @@ %%% API %%%=================================================================== +%%% @doc +%%% Use a transition of the localview. use_proc_transition(P, E) -> P ! {use_transition, E}. + +%%% @doc +%%% Get all the localview's current edges. get_proc_edges(P) -> send_recv(P, {self(), get_edges}). + +%%% @doc +%%% Get all the number of the localview's current edges. get_proc_out_degree(P) -> send_recv(P, {self(), get_out_degree}). + +%%% @doc +%%% Get the informations of a localview's edge. get_proc_edge_info(P, E) -> send_recv(P, {self(), get_edge_info, E}). + +%%% @doc +%%% Get the list of the local variables. get_proc_localvars(P) -> send_recv(P, {self(), get_local_vars}). + +%%% @doc +%%% Add a variable to the spawn arguments of the localview. add_proc_spawnvars(P, V) -> P ! {add_spawn_var, V}. + +%%% @doc +%%% Add a variable to the local variables of the localview. add_proc_localvars(P, V) -> P ! {add_local_var, V}. + +%%% @doc +%%% Get the all the data of the process. get_proc_data(P) -> send_recv(P, {self(), get_data}). + +%%% @doc +%%% Set the all the data of the process. set_proc_data(P, Data) -> P ! {set_data, Data}. + +%%% @doc +%%% Get the message queue of the process. get_proc_mess_queue(P) -> send_recv(P, {self(), get_mess_queue}). + +%%% @doc +%%% Add a message to the message queue of the process. add_proc_mess_queue(P, M) -> P ! {add_mess_queue, M}. -del_proc_mess_queue(P, M) -> P ! {del_mess_queue, M}. -send_recv(P, Data) -> - P ! Data, - receive - {D} -> D - end. +%%% @doc +%%% Delete a message from the message queue of the process. +del_proc_mess_queue(P, M) -> P ! {del_mess_queue, M}. +%%% @doc +%%% Loop function to simulate a process. proc_loop(Data) -> ProcName = Data#actor_info.fun_name, % io:fwrite("[EMUL] ID ~p~n", [ProcName]), @@ -135,4 +171,14 @@ proc_loop(Data) -> ok end. +%%%=================================================================== +%%% Internal Functions +%%%=================================================================== + filter_marked_edges(EdgeL, MarkedE) -> [E || E <- EdgeL, not lists:member(E, MarkedE)]. + +send_recv(P, Data) -> + P ! Data, + receive + {D} -> D + end. diff --git a/src/choreography/eval.erl b/src/choreography/eval.erl index 9d0d082..2b9d307 100644 --- a/src/choreography/eval.erl +++ b/src/choreography/eval.erl @@ -1,3 +1,9 @@ +%%%------------------------------------------------------------------- +%%% @doc +%%% This module evaluate the AST of the expressions in the Erlang language. +%%% This module is usable only in the `lv' module. +%%% @end +%%%------------------------------------------------------------------- -module(eval). -include("../share/common_data.hrl"). @@ -24,6 +30,8 @@ %%% API %%%=================================================================== +%%% @doc +%%% Evaluate the clauses of a function. function_list(ContList, Data) -> lists:foldl( fun(FunctionBody, AccData) -> @@ -40,6 +48,8 @@ function_list(ContList, Data) -> ContList ). +%%% @doc +%%% Evaluate a single clause (might be from `case', `receive' or `if'). clause(Code, Vars, Guards, Data, BaseLabel) -> % io:fwrite("[CLAUSE] Code ~p~n Vars ~p~n Guards ~p~n", [Code, Vars, Guards]), LocalV = Data#wip_lv.local_vars, @@ -55,6 +65,8 @@ clause(Code, Vars, Guards, Data, BaseLabel) -> Code ). +%%% @doc +%%% Evaluate a variable declaration. match(RightContent, LeftContent, Data) -> case RightContent of {var, _, VarName} -> match_with_var(VarName, LeftContent, Data); @@ -63,17 +75,25 @@ match(RightContent, LeftContent, Data) -> R -> share:warning("[MATCH] couldn't understand line", R, Data) end. +%%% @doc +%%% Evaluate a `case' expression. case_pm(Content, PMList, Data) -> NewData = lv:eval_codeline(Content, Data), %% TODO: save the returning variable? pattern_matching(PMList, "match", NewData). +%%% @doc +%%% Evaluate a `if' expression. if_pm(PMList, Data) -> pattern_matching(PMList, "if", Data). +%%% @doc +%%% Evaluate a `receive' expression. receive_pm(PMList, Data) -> pattern_matching(PMList, "receive", Data). +%%% @doc +%%% Evaluate an operation. operation(Symbol, LeftContent, RightContent, Data) -> case Symbol of '!' -> send(LeftContent, RightContent, Data); @@ -81,6 +101,8 @@ operation(Symbol, LeftContent, RightContent, Data) -> _ -> share:warning("operation not yet implemented", Symbol, Data) end. +%%% @doc +%%% Evaluate the call of a function. function_call(Function, ArgList, Data) -> case Function of {atom, _, Name} -> call_by_atom(Name, ArgList, Data); @@ -89,6 +111,8 @@ function_call(Function, ArgList, Data) -> F -> share:warning("couldn't call function pattern", F, Data) end. +%%% @doc +%%% Evaluate the definition of an anonymous function. anon_fun(Content, Line, Data) -> case Content of {clauses, A} -> @@ -99,10 +123,14 @@ anon_fun(Content, Line, Data) -> share:warning("not recognized content in anon_fun", Content, Data) end. +%%% @doc +%%% Evaluate a basic type. simple_type(Type, Val, Data) -> VarRet = #variable{type = Type, value = Val}, Data#wip_lv{ret_var = VarRet}. +%%% @doc +%%% Evaluate an atom. atom(Val, Data) -> %%% check if is a registerd atom, return the pid case ets:lookup(?REGISTERDB, Val) of @@ -110,6 +138,8 @@ atom(Val, Data) -> [{_, Pid}] -> simple_type(pid, Pid, Data) end. +%%% @doc +%%% Evaluate a list. list(HeadList, TailList, Data) -> NDH = lv:eval_codeline(HeadList, Data), NDT = lv:eval_codeline(TailList, NDH), @@ -118,9 +148,13 @@ list(HeadList, TailList, Data) -> NewVal = [Var] ++ VarList#variable.value, simple_type(list, NewVal, NDT). +%%% @doc +%%% Evaluate a map. TODO map(Val, Data) -> share:warning("TODO map evaluation", Val, Data). +%%% @doc +%%% Evaluate a tuple. tuple(Val, Data) -> {NewVal, NewData} = lists:foldl( fun(I, {A, D}) -> @@ -132,6 +166,8 @@ tuple(Val, Data) -> ), simple_type(tuple, NewVal, NewData). +%%% @doc +%%% Evaluate a variable. variable(VarName, Data) -> Var = share:find_var(Data#wip_lv.local_vars, VarName), RetV = diff --git a/src/choreography/gv.erl b/src/choreography/gv.erl index 94c9a8d..4678c8d 100644 --- a/src/choreography/gv.erl +++ b/src/choreography/gv.erl @@ -1,3 +1,9 @@ +%%%------------------------------------------------------------------- +%%% @doc +%%% This module generetes the localview. +%%% Must be used after `md:extract' and `lv:generate'. +%%% @end +%%%------------------------------------------------------------------- -module(gv). -include("../share/common_data.hrl"). @@ -8,7 +14,8 @@ %%% API %%%=================================================================== -%%% Generate the glabal view from an entrypoint and save it in a specified folder +%%% @doc +%%% Generate the glabal view from an entrypoint and save it in a specified folder. generate(Settings, EntryPoint) -> MainGraph = share:get_localview(EntryPoint), case MainGraph of @@ -35,7 +42,7 @@ create_globalview(Name) -> N = share:inc_spawn_counter(Name), MainProcPid = spawn(actor_emul, proc_loop, [#actor_info{fun_name = Name, id = N}]), PidKey = share:atol(Name) ++ ?SEPARATOR ++ integer_to_list(N), - ProcPidMap = #{ltoa(PidKey) => MainProcPid}, + ProcPidMap = #{share:ltoa(PidKey) => MainProcPid}, % initialize first branch progress_procs(RetG, [new_branch(RetG, VNew, ProcPidMap)]). @@ -132,7 +139,7 @@ gen_branch_foreach_mess(BranchData, MessageQueue, ProcName, BaseList) -> %%% Format the send label for the global view format_send_label(ProcFrom, ProcTo, Data) -> - atol(ProcFrom) ++ "→" ++ atol(ProcTo) ++ ":" ++ atol(Data). + share:atol(ProcFrom) ++ "→" ++ share:atol(ProcTo) ++ ":" ++ share:atol(Data). %%% Create a duplicate for a branch object dup_branch(Data) -> @@ -228,7 +235,7 @@ is_lists_edgerecv(ProcPid, EL) -> lists:foldl( fun(E, A) -> {E, _, _, Label} = actor_emul:get_proc_edge_info(ProcPid, E), - A or is_substring(atol(Label), "receive") + A or is_substring(share:atol(Label), "receive") end, false, EL @@ -238,7 +245,7 @@ is_lists_edgerecv(ProcPid, EL) -> eval_edge(EdgeInfo, ProcName, ProcPid, BData) -> {Edge, _, _, PLabel} = EdgeInfo, % io:fwrite("Proc ~p eval label ~p~n", [ProcName, PLabel]), - SLabel = atol(PLabel), + SLabel = share:atol(PLabel), IsArg = is_substring(SLabel, "arg"), IsSpawn = is_substring(SLabel, "spawn"), IsSend = is_substring(SLabel, "send"), @@ -257,10 +264,11 @@ eval_edge(EdgeInfo, ProcName, ProcPid, BData) -> {BData, false} end. +%%% If SubS is substring of S return True, otherwise False. is_substring(S, SubS) -> is_list(string:find(S, SubS)). -%%% Add a spanw transition to the global view +%%% Add a spawn transition to the global view add_spawn_to_global(SLabel, EmulProcName, Data) -> % get proc name FunSpawned = string:prefix(SLabel, "spawn "), @@ -273,7 +281,6 @@ add_spawn_to_global(SLabel, EmulProcName, Data) -> lists:foreach(fun(Var) -> actor_emul:add_proc_spawnvars(FuncPid, Var) end, LocalList), % create the edge on the global graph VNew = share:add_vertex(Data#branch.graph), - %%% Δ means spawned NewLabel = share:atol(EmulProcName) ++ "Δ" ++ FunSpawned, digraph:add_edge(Data#branch.graph, Data#branch.last_vertex, VNew, NewLabel), {VNew, NewMap}. @@ -287,7 +294,7 @@ get_local_vars(ProcId, Label, FunSName) -> [] -> []; _ -> - [{_, Input}] = ets:lookup(?ARGUMENTS, atol(FunSName)), + [{_, Input}] = ets:lookup(?ARGUMENTS, share:atol(FunSName)), % io:fwrite("[GV] for fun ~p found ~p~n", [atol(FunSName), Input]), {LL, Remain} = lists:foldl( fun({var, _, Name}, {A, In}) -> @@ -315,10 +322,10 @@ get_local_vars(ProcId, Label, FunSName) -> end. %%% Evaluate a send transition of an actor -manage_send(SLabel, Data, ProcName, ProcPid, Edge) -> +manage_send(SendLabel, Data, ProcName, ProcPid, Edge) -> ProcPidMap = Data#branch.proc_pid_m, - DataSent = get_data_from_label(SLabel), - ProcSentTemp = share:ltoa(get_proc_from_label(SLabel)), + DataSent = get_data_from_label(SendLabel), + ProcSentTemp = share:ltoa(get_proc_from_label(SendLabel)), IsVar = share:is_erlvar(ProcSentTemp), ProcSentName = case IsVar of @@ -328,26 +335,31 @@ manage_send(SLabel, Data, ProcName, ProcPid, Edge) -> ProcSentPid = maps:get(ProcSentName, ProcPidMap, no_pid), case ProcSentPid of no_pid -> - io:fwrite("[SEND-ERR] no pid found for: ~p~n", [ProcSentName]), + io:fwrite("[SEND-ERR] no pid found for: ~p~n", [ProcSentTemp]), {Data, false}; P -> actor_emul:add_proc_mess_queue(P, new_message(ProcName, DataSent, Edge)), - %%% NOTE: the last operation MUST be the use_proc_transition, otherwise the final graph might be wrong + %%% NOTE: the last operation MUST be use_proc_transition, otherwise the final graph might be wrong actor_emul:use_proc_transition(ProcPid, Edge), {Data, true} end. %%% Evaluate a receive transition of an actor manage_recv(ProcPid, Message) -> - EL = actor_emul:get_proc_edges(ProcPid), - %%% IMPORTANT TODO: evaluation of the edge's order not implemented!! - IsRecv = is_lists_edgerecv(ProcPid, EL), + EdgeList = actor_emul:get_proc_edges(ProcPid), + IsRecvList = is_lists_edgerecv(ProcPid, EdgeList), %io:fwrite("IsRECV ~p EL ~p~n", [IsRecv, EL]), From = Message#message.from, - case IsRecv of + case IsRecvList of false -> - % TODO: manage when is not ONLY a receive edge - % the following piece of code is old, check before uncommenting + % TODO: manage when is not ONLY a receive edge, like: + % 3 + % /recv + % 1 -> 2 + % \send + % 4 + % + % The following piece of code is old, check before uncommenting % {NewL, NOp} = lists:foldl( % fun(E, A) -> % EInfo = get_proc_edge_info(ProcPid, E), @@ -362,22 +374,24 @@ manage_recv(ProcPid, Message) -> % {H, T, NOp}; ?UNDEFINED; true -> + %%% IMPORTANT TODO: evaluation of the edge's order not implemented!! + %%% Evaluate edges in order as in the code {_, EdgeChoosen} = lists:foldl( - fun(E, {B, Ret}) -> - case B of + fun(Edge, {AlreadyFound, RetEdge}) -> + case AlreadyFound of true -> - {B, Ret}; + {AlreadyFound, RetEdge}; false -> - {E, _, _, ELabel} = actor_emul:get_proc_edge_info(ProcPid, E), - IsIt = is_pm_msg_compatible(ProcPid, From, ELabel, Message), - case IsIt of - true -> {true, E}; - false -> {B, Ret} + {_, _, _, ELabel} = actor_emul:get_proc_edge_info(ProcPid, Edge), + IsCompatible = is_pm_msg_compatible(ProcPid, From, ELabel, Message), + case IsCompatible of + true -> {true, Edge}; + false -> {AlreadyFound, RetEdge} end end end, {false, ?UNDEFINED}, - EL + EdgeList ), EdgeChoosen end. @@ -404,61 +418,66 @@ check_vars(ProcPid, VarName) -> %%% Check if a pattern metching match a message, then register the new variables is_pm_msg_compatible(ProcPid, CallingProc, PatternMatching, Message) -> - {RetBool, RegList} = check_msg_comp( + {IsCompatible, ToRegisterList} = check_msg_comp( ProcPid, CallingProc, PatternMatching, Message#message.data ), % io:fwrite("Reg List ~p~n", [RegList]), lists:foreach( fun(Item) -> register_var(Item) end, - RegList + ToRegisterList ), - RetBool. + IsCompatible. %%% Check if a pattern metching match a message check_msg_comp(ProcPid, CallingProc, PatternMatching, Message) -> - MessageS = atol(Message), - PatternMS = lists:flatten(string:replace(atol(PatternMatching), "receive ", "")), - [FirstPChar | RestP] = PatternMS, - [FirstMChar | RestM] = MessageS, + MessageS = share:atol(Message), + PatternMS = lists:flatten(string:replace(share:atol(PatternMatching), "receive ", "")), + [FirstPtmtChar | RestPtmt] = PatternMS, + [FirstMessChar | RestMess] = MessageS, IsFirstCharUpperCase = share:is_erlvar(PatternMS), if - %%% hierarchy - ([FirstPChar] =:= "{") and ([FirstMChar] =:= "{") -> - ContentP = share:remove_last(RestP), - ContentM = share:remove_last(RestM), - PL = string:split(ContentP, ",", all), - A = lists:enumerate(PL), - ML = string:split(ContentM, ",", all), - B = lists:enumerate(ML), - BoolList = [ - check_msg_comp(ProcPid, CallingProc, IA, IB) - || {BA, IA} <- A, {BB, IB} <- B, BA =:= BB - ], - and_rec(BoolList); + ([FirstPtmtChar] =:= "{") and ([FirstMessChar] =:= "{") -> + check_tuple(ProcPid, CallingProc, RestPtmt, RestMess); PatternMS =:= MessageS -> {true, []}; IsFirstCharUpperCase -> - {true, [{ProcPid, ltoa(PatternMS), check_pid_self(Message, CallingProc)}]}; - [FirstPChar] =:= "_" -> + {true, [{ProcPid, share:ltoa(PatternMS), check_pid_self(Message, CallingProc)}]}; + [FirstPtmtChar] =:= "_" -> {true, []}; true -> {false, []} end. +%%% Check if the rest of the tuple is compatible +check_tuple(ProcPid, CallingProc, RestPtmt, RestMess) -> + ContentPtmt = share:remove_last(RestPtmt), + ContentMess = share:remove_last(RestMess), + ContentPtmtList = string:split(ContentPtmt, ",", all), + EnumPtmt = lists:enumerate(ContentPtmtList), + ContentMessList = string:split(ContentMess, ",", all), + EnumMess = lists:enumerate(ContentMessList), + BoolList = [ + check_msg_comp(ProcPid, CallingProc, DataPtmt, DataMess) + || {IndexPtmt, DataPtmt} <- EnumPtmt, + {IndexMess, DataMess} <- EnumMess, + IndexPtmt =:= IndexMess + ], + and_rec(BoolList). + %%% Register a actor's variable register_var(Data) -> {ProcPid, Name, Value} = Data, %%% type = pid to change, for now it's ok like this because I only focus on pid exchange - V = #variable{name = ltoa(Name), type = pid, value = ltoa(Value)}, + V = #variable{name = share:ltoa(Name), type = pid, value = share:ltoa(Value)}, % io:fwrite("Added Var ~p~n", [V]), actor_emul:add_proc_localvars(ProcPid, V). -%%% Substitute pif_self to pid_procId +%%% Substitute pif_self to pid_ProcId check_pid_self(Data, ProcId) -> % io:fwrite("[C]Data ~p proc id ~p~n", [Data, ProcId]), - lists:flatten(string:replace(atol(Data), "pid_self", atol(ProcId))). + lists:flatten(string:replace(share:atol(Data), "pid_self", share:atol(ProcId))). -%%% Custom recursive logic and +%%% Custom recursive and operation and_rec([]) -> {true, []}; and_rec([{B, L} | T]) -> @@ -470,7 +489,7 @@ and_rec([{B, L} | T]) -> {B, []} end. -%%% Add a send/recv vertex to the global view, with some checks for recusive edges +%%% Add a vertex to the global view, with some checks for recusive edges complex_add_vertex(Proc1, EdgeInfo1, Proc2, EdgeInfo2, Data, Label) -> StateM = Data#branch.states_m, VLast = Data#branch.last_vertex, @@ -510,7 +529,6 @@ complex_add_vertex(Proc1, EdgeInfo1, Proc2, EdgeInfo2, Data, Label) -> end; _ -> %%% Match First vertex - %io:fwrite("[ADD]First defined!!~n"), digraph:add_edge(G, VLast, Vfirst, Label), {Vfirst, StateM} end; @@ -556,8 +574,3 @@ stop_processes(DataL) when is_list(DataL) -> ); stop_processes(ProcMap) -> maps:foreach(fun(_K, V) -> V ! stop end, ProcMap). - -atol(A) when is_list(A) -> A; -atol(A) when is_atom(A) -> atom_to_list(A). -ltoa(L) when is_atom(L) -> L; -ltoa(L) when is_list(L) -> list_to_atom(L). diff --git a/src/choreography/lv.erl b/src/choreography/lv.erl index 0c883ec..2dfcc48 100644 --- a/src/choreography/lv.erl +++ b/src/choreography/lv.erl @@ -1,3 +1,9 @@ +%%%------------------------------------------------------------------- +%%% @doc +%%% This module generate a localview for each possible actor. +%%% Must be used after `md:extract'. +%%% @end +%%%------------------------------------------------------------------- -module(lv). -include("../share/common_data.hrl"). @@ -8,6 +14,9 @@ %%% API %%%=================================================================== +%%% @doc +%%% A localview is generated for each possible actor. +%%% `md:extract' must be used before this function. generate(Settings) -> [{_, ActorList}] = ets:lookup(?DBMANAGER, ?ACTORLIST), lists:foreach( diff --git a/src/choreography/md.erl b/src/choreography/md.erl index ec5a6de..3989a15 100644 --- a/src/choreography/md.erl +++ b/src/choreography/md.erl @@ -1,3 +1,10 @@ +%%%------------------------------------------------------------------- +%%% @doc +%%% The metadata extractor module. +%%% This module extract all the essential metadata prior to the localviews +%%% and globalview generation. +%%% @end +%%%------------------------------------------------------------------- -module(md). -include("../share/common_data.hrl"). @@ -8,22 +15,24 @@ %%% API %%%=================================================================== +%%% @doc +%%% Extract the metadata: the AST (abstract syntax tree) for each function +%%% and all the Actor List. extract(InputFile) -> - gen_ast(InputFile), - gen_fun_ast_and_exported(). + gen_fun_ast_and_exported(parse_file(InputFile)). -parse_file(Path) -> element(2, epp_dodger:quick_parse_file(Path)). +%%% @doc +%%% Return the AST of the file localted in Path. +parse_file(Path) -> + element(2, epp_dodger:quick_parse_file(Path)). %%%=================================================================== %%% Internal Functions %%%=================================================================== -gen_ast(InputFile) -> - Ast = parse_file(InputFile), - ets:insert(?DBMANAGER, {?INPUTAST, Ast}). - -gen_fun_ast_and_exported() -> - [{_, Ast}] = ets:lookup(?DBMANAGER, ?INPUTAST), +%%% Parse all the file and save the Ast of each function and also all the possible actors. +%%% All the exported functions are cosidereted possible actors. +gen_fun_ast_and_exported(Ast) -> List = lists:foldl( fun(CodeLine, AccList) -> @@ -32,7 +41,9 @@ gen_fun_ast_and_exported() -> AccList ++ [share:merge_fun_ar(N, A) || {N, A} <- AtrList]; {function, Line, Name, Arity, FunAst} -> % io:fwrite("[MD] Found ~p~n", [share:merge_fun_ar(Name, Arity)]), - ets:insert(?FUNAST, {share:merge_fun_ar(Name, Arity), {function, Line, FunAst}}), + ets:insert(?FUNAST, { + share:merge_fun_ar(Name, Arity), {function, Line, FunAst} + }), AccList; _ -> AccList diff --git a/src/chorer.erl b/src/chorer.erl index d7d1683..309806e 100644 --- a/src/chorer.erl +++ b/src/chorer.erl @@ -1,3 +1,9 @@ +%%%------------------------------------------------------------------------------ +%%% @doc +%%% The main module of the program. +%%% It initialize the ets tables and generetes the localviews and the globalview. +%%% @end +%%%------------------------------------------------------------------------------ -module(chorer). -include("share/common_data.hrl"). @@ -8,14 +14,21 @@ %%% API %%%=================================================================== +%%% @doc +%%% Function called when the tool is used from the CLI (Command Line Interface). main([InputFile, EntryPoint, OutputDir] = _Args) -> - generate(InputFile, list_to_atom(EntryPoint), OutputDir). + generate(InputFile, share:ltoa(EntryPoint), OutputDir). +%%% @doc +%%% Generate the localviews and the globalview with base settings. -spec generate(InputFile, EntryPoint) -> atom() when InputFile :: string(), EntryPoint :: atom(). generate(InputFile, EntryPoint) -> generate(InputFile, EntryPoint, #setting{}). +%%% @doc +%%% Generate the localviews and the globalview specifing the output directory. +%%% It initialize the ets tables and generates the localviews and globalview. -spec generate(InputFile, EntryPoint, OutDir) -> atom() when InputFile :: string(), EntryPoint :: atom(), diff --git a/src/share/common_data.hrl b/src/share/common_data.hrl index 4d6c602..1270589 100644 --- a/src/share/common_data.hrl +++ b/src/share/common_data.hrl @@ -8,7 +8,6 @@ -define(ANYDATA, any). -define(CLINE, curr_line). --define(INPUTAST, input_ast). -define(ACTORLIST, actor_list). -define(FUNAST, fun_ast). -define(ARGUMENTS, args). diff --git a/src/share/digraph_to_dot.erl b/src/share/digraph_to_dot.erl index f839b37..dea594d 100644 --- a/src/share/digraph_to_dot.erl +++ b/src/share/digraph_to_dot.erl @@ -1,11 +1,14 @@ -%%%------------------------------------------------------------------- -%%% Module based from: -%%% https://github.com/jkrukoff/digraph_export/blob/master/src/digraph_export_dot.erl +%%% @doc +%%% Module based from +%%% jkrukoff. %%% %%% Features added: -%%% - distinctions between initial and final states -%%% - left to right orientation of graphs -%%% - enanched format for +%%%
    +%%%
  • distinctions between initial and final states
  • +%%%
  • changed orientation of graphs from left to right
  • +%%%
  • enanched format
  • +%%%
+%%% @end %%%------------------------------------------------------------------- -module(digraph_to_dot). -include("common_data.hrl"). @@ -17,6 +20,8 @@ %%% API %%%=================================================================== +%%% @doc +%%% Convert a graph to a dot graph. -spec convert(Graph, Name) -> Serialized when Graph :: digraph:graph(), Name :: unicode:charlist(), diff --git a/src/share/fsa.erl b/src/share/fsa.erl index 387f50f..0025dda 100644 --- a/src/share/fsa.erl +++ b/src/share/fsa.erl @@ -1,3 +1,10 @@ +%%%=================================================================== +%%% @doc +%%% This module manage an FSA. +%%% A choreography is basically an FSA (finite state automaton). This module +%%% implements the basics automata's operations needed for the project. +%%% @end +%%%=================================================================== -module(fsa). -include("common_data.hrl"). @@ -8,8 +15,11 @@ %%% API %%%=================================================================== +%%% @doc %%% Minimize an FSA, using algorithms from Simone Martini and Maurizio Gabbrielli's %%% book: Programming Languages, Second edition, McGraw-Hill, 2011 +-spec minimize(NFA) -> digraph:graph() when + NFA :: digraph:graph(). minimize(NFA) -> % Convert a NFA to a DFA remove_unreachable(NFA), diff --git a/src/share/share.erl b/src/share/share.erl index b85061a..56b17c0 100644 --- a/src/share/share.erl +++ b/src/share/share.erl @@ -1,3 +1,8 @@ +%%%------------------------------------------------------------------- +%%% @doc +%%% Module with some common functions used everywhere in the project. +%%% @end +%%%------------------------------------------------------------------- -module(share). -include("common_data.hrl"). @@ -32,6 +37,7 @@ %%% API %%%=================================================================== +%%% @doc %%% Pick first element from a list first([]) -> []; first([H | _]) -> H. @@ -60,12 +66,15 @@ del_vertex(G, V) -> [digraph:add_vertex(G, Ver, Ver - 1) || Ver <- digraph:vertices(G), Ver > V], digraph:del_vertex(G, V). -%%% Return true if first letter's atom is uppercase (it's a variable in erlang), otherwise false. +%%% @doc +%%% Return true if first letter's atom is uppercase (it's a variable in erlang), +%%% otherwise false. is_erlvar(Name) -> SName = atol(Name), [FirstChar | _] = SName, is_uppercase([FirstChar]). +%%% @doc %%% If the input character is uppercase return true, otherwise false. is_uppercase(Char) when (is_list(Char)) and (length(Char) =:= 1) -> (Char >= "A") and (Char =< "Z"). @@ -162,7 +171,8 @@ save_graph(Data, Settings, FunName, Mode) -> end, save_graph_to_file(ToSaveG, OutputDir, FunName, Mode). -%%% Remove the last element from a list +%%% @doc +%%% Remove the last element from a list. remove_last(Item) -> ItemList = atol(Item), {Rest, _} = lists:split(length(ItemList) - 1, ItemList),