From 483832e7a49c232388ce2e30127b1e543d95c014 Mon Sep 17 00:00:00 2001 From: Akemi Izuko Date: Tue, 14 Nov 2023 18:11:43 -0700 Subject: [PATCH] Graphviz: statements --- graphviz/functions/args.dot | 2 +- graphviz/functions/gen_decl.dot | 2 ++ graphviz/functions/gen_return.dot | 2 +- .../{gen_function.dot => gen_subroutine.dot} | 0 graphviz/functions/get_instant.dot | 2 +- graphviz/functions/statements/gen_assign.dot | 31 ++++++++++++++++++ .../functions/statements/gen_if_statement.dot | 32 +++++++++++++++++++ graphviz/functions/statements/gen_loop.dot | 22 +++++++++++++ .../functions/statements/gen_std_output.dot | 17 ++++++++++ graphviz/global_flow.dot | 7 ++-- 10 files changed, 110 insertions(+), 7 deletions(-) rename graphviz/functions/{gen_function.dot => gen_subroutine.dot} (100%) create mode 100644 graphviz/functions/statements/gen_assign.dot create mode 100644 graphviz/functions/statements/gen_if_statement.dot create mode 100644 graphviz/functions/statements/gen_loop.dot create mode 100644 graphviz/functions/statements/gen_std_output.dot diff --git a/graphviz/functions/args.dot b/graphviz/functions/args.dot index e54f060..070d08c 100644 --- a/graphviz/functions/args.dot +++ b/graphviz/functions/args.dot @@ -11,7 +11,7 @@ digraph fn_args { newrank=true; A [label="for each type"]; - B [label="gen_type(GazType)" shape=diamond style=filled fillcolor=lightcoral]; + B [label="get_instant(GazType)" shape=diamond style=filled fillcolor=lightcoral]; C [label="pack into var"]; D [label="return" style=filled fillcolor=lightskyblue]; A -> B -> C -> A; diff --git a/graphviz/functions/gen_decl.dot b/graphviz/functions/gen_decl.dot index a228499..6664a3e 100644 --- a/graphviz/functions/gen_decl.dot +++ b/graphviz/functions/gen_decl.dot @@ -21,6 +21,8 @@ digraph fn_gen_decl { j [label="push to const scope"]; k [label="return" style=filled fillcolor=lightskyblue1]; + {rank=same; b c e f g} + a -> b -> h; a -> c -> h; a -> e -> h; diff --git a/graphviz/functions/gen_return.dot b/graphviz/functions/gen_return.dot index 11c58ea..946e8ad 100644 --- a/graphviz/functions/gen_return.dot +++ b/graphviz/functions/gen_return.dot @@ -13,7 +13,7 @@ digraph fn_gen_return { b [label="gen_if_statement_with_return()" shape=diamond style=filled fillcolor=lightcoral]; c [label="gen_loop_with_return()" shape=diamond style=filled fillcolor=lightcoral]; d [label="return"]; - e [label="gen_type()" shape=diamond style=filled fillcolor=lightcoral]; + e [label="gen correct type"]; f [label="return" style=filled fillcolor=lightskyblue1]; a -> b -> f; diff --git a/graphviz/functions/gen_function.dot b/graphviz/functions/gen_subroutine.dot similarity index 100% rename from graphviz/functions/gen_function.dot rename to graphviz/functions/gen_subroutine.dot diff --git a/graphviz/functions/get_instant.dot b/graphviz/functions/get_instant.dot index 4349329..7025788 100644 --- a/graphviz/functions/get_instant.dot +++ b/graphviz/functions/get_instant.dot @@ -4,7 +4,7 @@ digraph fn_get_instant { node [fontname = "cc wild words"]; edge [fontname = "cc wild words"]; - label="fn_gen_boolean()"; + label="fn_gen_instant(type: GazType)"; fontname=lovebeat; rankdir=TB; newrank=true; diff --git a/graphviz/functions/statements/gen_assign.dot b/graphviz/functions/statements/gen_assign.dot new file mode 100644 index 0000000..1110899 --- /dev/null +++ b/graphviz/functions/statements/gen_assign.dot @@ -0,0 +1,31 @@ +digraph fn_gen_assignment { + labelloc="t"; + graph [fontname = "cc wild words"]; + node [fontname = "cc wild words"]; + edge [fontname = "cc wild words"]; + + label="fn_gen_assignment(type: GazType)"; + fontname=lovebeat; + rankdir=LR; + newrank=true; + + a [label="fork on type"]; + // read from stdinput + b [label="gen_boolean()" shape=diamond style=filled fillcolor=lightcoral]; + c [label="gen_character()" shape=diamond style=filled fillcolor=lightcoral]; + d [label="create real"] + e [label="gen_integer()" shape=diamond style=filled fillcolor=lightcoral]; + f [label="gen_real()" shape=diamond style=filled fillcolor=lightcoral]; + g [label="gen_tuple()" shape=diamond style=filled fillcolor=lightcoral]; + k [label="return" style=filled fillcolor=lightskyblue1]; + + {rank=same; b c e f g} + + a -> b -> k; + a -> c -> k; + a -> e -> k; + a -> g -> k; + a -> d; + d -> e; + d -> f -> k; +} diff --git a/graphviz/functions/statements/gen_if_statement.dot b/graphviz/functions/statements/gen_if_statement.dot new file mode 100644 index 0000000..cd32e03 --- /dev/null +++ b/graphviz/functions/statements/gen_if_statement.dot @@ -0,0 +1,32 @@ +digraph fn_gen_if_statement { + labelloc="t"; + graph [fontname = "cc wild words"]; + node [fontname = "cc wild words"]; + edge [fontname = "cc wild words"]; + + label="fn_gen_if_statement(with_return: Option)"; + fontname=lovebeat; + rankdir=TB; + newrank=true; + + a [label="gen_boolean()" shape=diamond style=filled fillcolor=lightcoral]; + b [label="push new scope"]; + c [label="gen_statement(with_return)" shape=diamond style=filled fillcolor=lightcoral]; + d [label="choice"]; + e [label="else if"]; + f [label="gen_if_statement(with_return)" shape=diamond style=filled fillcolor=lightcoral]; + g [label="else"]; + h [label="push new scope"]; + i [label="gen_statement(with_return)" shape=diamond style=filled fillcolor=lightcoral]; + j [label="return" style=filled fillcolor=lightskyblue1]; + + {rank=same; e g} + {rank=same; f i} + + a -> b -> c -> d; + d -> e -> f -> d; + d -> g -> h -> i -> j; + d -> j; + c -> c [dir=back]; + i -> i [dir=back]; +} diff --git a/graphviz/functions/statements/gen_loop.dot b/graphviz/functions/statements/gen_loop.dot new file mode 100644 index 0000000..514cd54 --- /dev/null +++ b/graphviz/functions/statements/gen_loop.dot @@ -0,0 +1,22 @@ +digraph fn_gen_loop { + labelloc="t"; + graph [fontname = "cc wild words"]; + node [fontname = "cc wild words"]; + edge [fontname = "cc wild words"]; + + label="fn_gen_loop(with_return: Option)"; + fontname=lovebeat; + rankdir=TB; + newrank=true; + + a0 [label="choice"]; + a1 [label="infinite_loop"]; + a2 [label="gen_statement(with_break)" shape=diamond style=filled fillcolor=lightcoral]; + a3 [label="predicate_loop"]; + a4 [label="todo" style=filled fillcolor=magenta]; + a5 [label="return" style=filled fillcolor=lightskyblue1]; + + a0 -> a1 -> a2 -> a5; + a0 -> a3 -> a4; + a2 -> a2 [dir=back]; +} diff --git a/graphviz/functions/statements/gen_std_output.dot b/graphviz/functions/statements/gen_std_output.dot new file mode 100644 index 0000000..c046d64 --- /dev/null +++ b/graphviz/functions/statements/gen_std_output.dot @@ -0,0 +1,17 @@ +digraph fn_gen_std_output { + labelloc="t"; + graph [fontname = "cc wild words"]; + node [fontname = "cc wild words"]; + edge [fontname = "cc wild words"]; + + label="fn_gen_std_output(type: GazType)"; + fontname=lovebeat; + rankdir=TB; + newrank=true; + + a [label="fork on type"]; + b [label="get_instant(type)" shape=diamond style=filled fillcolor=lightcoral]; + c [label="return" style=filled fillcolor=lightskyblue1]; + + a -> b -> c; +} diff --git a/graphviz/global_flow.dot b/graphviz/global_flow.dot index 86fa9e6..f244074 100644 --- a/graphviz/global_flow.dot +++ b/graphviz/global_flow.dot @@ -3,22 +3,21 @@ digraph flow { graph [fontname = "cc wild words"]; node [fontname = "cc wild words"]; edge [fontname = "cc wild words"]; - rank=TB; + rankdir=LR; A0 [label="Global" style=filled fillcolor=gold]; - B0 [label="declare global"]; C0 [label="end generation"]; D0 [label="for each undefined subroutine"]; F0 [label="return" style=filled fillcolor=lightskyblue1]; node [shape=diamond style=filled fillcolor=lightsalmon]; - FA0 [label="fn_gen_global_type(GazType)"]; + FA0 [label="fn_gen_global_decl()"]; FB0 [label="fn_gen_main()"]; FC0 [label="fn_define_subroutine(SubRoutine)"]; FD0 [label="fn_declare_subroutine()"]; FE0 [label="fn_gen_typedef()"]; - A0 -> B0 -> FA0 -> A0; + A0 -> FA0 -> A0; A0 -> C0 -> FB0 -> D0; A0 -> FD0 -> A0; A0 -> FE0 -> A0;