Skip to content

Commit

Permalink
fix: function arguments works
Browse files Browse the repository at this point in the history
  • Loading branch information
gabrielegenovese committed Feb 16, 2024
1 parent 1bd0ea4 commit edf83ff
Show file tree
Hide file tree
Showing 22 changed files with 755 additions and 744 deletions.
10 changes: 10 additions & 0 deletions examples/airline/agent1_local_view.dot
Original file line number Diff line number Diff line change
@@ -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,_}"];
}
10 changes: 0 additions & 10 deletions examples/airline/agent_local_view.dot

This file was deleted.

2 changes: 2 additions & 0 deletions examples/airline/airline.erl
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ main() ->
spawn(?MODULE, agent, [self()]),
seats(3).

seats(0) ->
stop;
seats(Num) ->
receive
{sell, Pid1} ->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"];
}
11 changes: 11 additions & 0 deletions examples/airline/main0_global_view.dot
Original file line number Diff line number Diff line change
@@ -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"];
}
14 changes: 14 additions & 0 deletions examples/airline/main0_local_view.dot
Original file line number Diff line number Diff line change
@@ -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"];
}
27 changes: 0 additions & 27 deletions examples/airline/main_global_view.dot

This file was deleted.

5 changes: 3 additions & 2 deletions examples/test/foo6/client_gen_local_view.dot
Original file line number Diff line number Diff line change
Expand Up @@ -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"];
}
2 changes: 1 addition & 1 deletion examples/test/foo6/client_local_view.dot
Original file line number Diff line number Diff line change
Expand Up @@ -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"];
}
11 changes: 6 additions & 5 deletions examples/test/foo6/client_server_local_view.dot
Original file line number Diff line number Diff line change
Expand Up @@ -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"];
}
5 changes: 2 additions & 3 deletions examples/test/foo6/foo6.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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.
22 changes: 8 additions & 14 deletions examples/test/foo6/test_global_view.dot
Original file line number Diff line number Diff line change
@@ -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"];
}
11 changes: 6 additions & 5 deletions examples/test/foo6/test_local_view.dot
Original file line number Diff line number Diff line change
Expand Up @@ -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"];
}
9 changes: 5 additions & 4 deletions src/choreography/actor_emul.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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} ->
Expand Down
Loading

0 comments on commit edf83ff

Please sign in to comment.