Skip to content

Commit 8a1b2f3

Browse files
committed
Add colored combinator nodes to Mermaid diagram
- join nodes: light blue (#e6f3ff) - union nodes: light orange (#fff0e6) - fixpoint nodes: light green (#e6ffe6) - Remove level annotations from node labels
1 parent cb79a21 commit 8a1b2f3

File tree

2 files changed

+94
-57
lines changed

2 files changed

+94
-57
lines changed

analysis/reactive/src/Reactive.ml

Lines changed: 37 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ module Registry = struct
9797

9898
let nodes : (string, node_info) Hashtbl.t = Hashtbl.create 64
9999
let edges : (string * string, string) Hashtbl.t = Hashtbl.create 128
100+
100101
(* Combinator nodes: (combinator_id, (shape, inputs, output)) *)
101102
let combinators : (string, string * string list * string) Hashtbl.t =
102103
Hashtbl.create 32
@@ -152,19 +153,27 @@ module Registry = struct
152153
Hashtbl.iter
153154
(fun comb_name (_, inputs, output) ->
154155
List.iter
155-
(fun input -> Hashtbl.replace combinator_edges (input, output) comb_name)
156+
(fun input ->
157+
Hashtbl.replace combinator_edges (input, output) comb_name)
156158
inputs)
157159
combinators;
158160
(* Output regular nodes *)
159161
Hashtbl.iter
160-
(fun name info ->
161-
Buffer.add_string buf
162-
(Printf.sprintf " %s[%s L%d]\n" name name info.level))
162+
(fun name _info ->
163+
Buffer.add_string buf (Printf.sprintf " %s[%s]\n" name name))
163164
nodes;
164-
(* Output combinator nodes (diamond shape) *)
165+
(* Output combinator nodes (diamond shape) with classes *)
166+
let join_nodes = ref [] in
167+
let union_nodes = ref [] in
168+
let fixpoint_nodes = ref [] in
165169
Hashtbl.iter
166170
(fun comb_name (shape, _inputs, _output) ->
167-
Buffer.add_string buf (Printf.sprintf " %s{%s}\n" comb_name shape))
171+
Buffer.add_string buf (Printf.sprintf " %s{%s}\n" comb_name shape);
172+
match shape with
173+
| "join" -> join_nodes := comb_name :: !join_nodes
174+
| "union" -> union_nodes := comb_name :: !union_nodes
175+
| "fixpoint" -> fixpoint_nodes := comb_name :: !fixpoint_nodes
176+
| _ -> ())
168177
combinators;
169178
(* Output edges *)
170179
Hashtbl.iter
@@ -194,8 +203,29 @@ module Registry = struct
194203
(* Output edges from combinators to their outputs *)
195204
Hashtbl.iter
196205
(fun comb_name (_shape, _inputs, output) ->
197-
Buffer.add_string buf (Printf.sprintf " %s --> %s\n" comb_name output))
206+
Buffer.add_string buf
207+
(Printf.sprintf " %s --> %s\n" comb_name output))
198208
combinators;
209+
(* Style definitions for combinator types *)
210+
Buffer.add_string buf
211+
"\n classDef joinClass fill:#e6f3ff,stroke:#0066cc\n";
212+
Buffer.add_string buf
213+
" classDef unionClass fill:#fff0e6,stroke:#cc6600\n";
214+
Buffer.add_string buf
215+
" classDef fixpointClass fill:#e6ffe6,stroke:#006600\n";
216+
(* Assign classes to combinator nodes *)
217+
if !join_nodes <> [] then
218+
Buffer.add_string buf
219+
(Printf.sprintf " class %s joinClass\n"
220+
(String.concat "," !join_nodes));
221+
if !union_nodes <> [] then
222+
Buffer.add_string buf
223+
(Printf.sprintf " class %s unionClass\n"
224+
(String.concat "," !union_nodes));
225+
if !fixpoint_nodes <> [] then
226+
Buffer.add_string buf
227+
(Printf.sprintf " class %s fixpointClass\n"
228+
(String.concat "," !fixpoint_nodes));
199229
Buffer.contents buf
200230

201231
(** Print timing stats for all nodes *)

analysis/reanalyze/diagrams/reactive-pipeline-full.mmd

Lines changed: 57 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,54 +1,54 @@
11
graph TD
2-
annotations[annotations L2]
3-
exc_refs.exception_decls[exc_refs.exception_decls L3]
4-
type_deps.same_path_refs[type_deps.same_path_refs L4]
5-
file_collection[file_collection L0]
6-
decl_refs.value_decl_refs[decl_refs.value_decl_refs L7]
7-
type_deps.combined_refs_to[type_deps.combined_refs_to L7]
8-
type_deps.all_type_refs_from[type_deps.all_type_refs_from L8]
9-
type_deps.impl_needing_path2[type_deps.impl_needing_path2 L4]
10-
exc_refs.resolved_refs_from[exc_refs.resolved_refs_from L5]
11-
exc_refs.resolved_refs[exc_refs.resolved_refs L4]
12-
type_deps.impl_to_intf_refs_path2[type_deps.impl_to_intf_refs_path2 L5]
13-
file_deps_map[file_deps_map L2]
14-
decl_refs.with_value_refs[decl_refs.with_value_refs L8]
15-
type_deps.u1[type_deps.u1 L5]
16-
cross_file_items[cross_file_items L2]
17-
decl_refs.decls_by_file[decl_refs.decls_by_file L3]
18-
type_deps.impl_to_intf_refs[type_deps.impl_to_intf_refs L4]
19-
solver.issues_by_file[solver.issues_by_file L17]
20-
liveness.annotated_roots[liveness.annotated_roots L3]
21-
solver.incorrect_dead_decls[solver.incorrect_dead_decls L16]
22-
type_deps.intf_to_impl_refs[type_deps.intf_to_impl_refs L4]
23-
type_deps.decl_by_path[type_deps.decl_by_path L3]
24-
type_deps.u2[type_deps.u2 L6]
25-
solver.live_decls[solver.live_decls L15]
26-
type_deps.impl_decls[type_deps.impl_decls L3]
27-
liveness.all_roots[liveness.all_roots L12]
28-
solver.dead_modules[solver.dead_modules L17]
29-
liveness.external_type_refs[liveness.external_type_refs L10]
30-
decl_refs.combined[decl_refs.combined L12]
31-
type_refs_from[type_refs_from L2]
32-
liveness.type_refs_from[liveness.type_refs_from L9]
33-
solver.dead_decls_by_file[solver.dead_decls_by_file L16]
34-
liveness.external_value_refs[liveness.external_value_refs L7]
35-
liveness.value_refs_from[liveness.value_refs_from L6]
36-
value_refs_from[value_refs_from L2]
37-
solver.modules_with_dead[solver.modules_with_dead L16]
38-
solver.dead_decls[solver.dead_decls L15]
39-
exception_refs_collection[exception_refs_collection L3]
40-
type_deps.intf_decls[type_deps.intf_decls L3]
41-
file_data_collection[file_data_collection L1]
42-
solver.dead_module_issues[solver.dead_module_issues L19]
43-
decl_refs.with_type_refs[decl_refs.with_type_refs L11]
44-
solver.modules_with_live[solver.modules_with_live L16]
45-
decl_refs.type_decl_refs[decl_refs.type_decl_refs L10]
46-
files[files L2]
47-
solver.modules_with_reported[solver.modules_with_reported L18]
48-
liveness.externally_referenced[liveness.externally_referenced L11]
49-
liveness.edges[liveness.edges L13]
50-
liveness.live[liveness.live L14]
51-
decls[decls L2]
2+
annotations[annotations]
3+
exc_refs.exception_decls[exc_refs.exception_decls]
4+
type_deps.same_path_refs[type_deps.same_path_refs]
5+
file_collection[file_collection]
6+
decl_refs.value_decl_refs[decl_refs.value_decl_refs]
7+
type_deps.combined_refs_to[type_deps.combined_refs_to]
8+
type_deps.all_type_refs_from[type_deps.all_type_refs_from]
9+
type_deps.impl_needing_path2[type_deps.impl_needing_path2]
10+
exc_refs.resolved_refs_from[exc_refs.resolved_refs_from]
11+
exc_refs.resolved_refs[exc_refs.resolved_refs]
12+
type_deps.impl_to_intf_refs_path2[type_deps.impl_to_intf_refs_path2]
13+
file_deps_map[file_deps_map]
14+
decl_refs.with_value_refs[decl_refs.with_value_refs]
15+
type_deps.u1[type_deps.u1]
16+
cross_file_items[cross_file_items]
17+
decl_refs.decls_by_file[decl_refs.decls_by_file]
18+
type_deps.impl_to_intf_refs[type_deps.impl_to_intf_refs]
19+
solver.issues_by_file[solver.issues_by_file]
20+
liveness.annotated_roots[liveness.annotated_roots]
21+
solver.incorrect_dead_decls[solver.incorrect_dead_decls]
22+
type_deps.intf_to_impl_refs[type_deps.intf_to_impl_refs]
23+
type_deps.decl_by_path[type_deps.decl_by_path]
24+
type_deps.u2[type_deps.u2]
25+
solver.live_decls[solver.live_decls]
26+
type_deps.impl_decls[type_deps.impl_decls]
27+
liveness.all_roots[liveness.all_roots]
28+
solver.dead_modules[solver.dead_modules]
29+
liveness.external_type_refs[liveness.external_type_refs]
30+
decl_refs.combined[decl_refs.combined]
31+
type_refs_from[type_refs_from]
32+
liveness.type_refs_from[liveness.type_refs_from]
33+
solver.dead_decls_by_file[solver.dead_decls_by_file]
34+
liveness.external_value_refs[liveness.external_value_refs]
35+
liveness.value_refs_from[liveness.value_refs_from]
36+
value_refs_from[value_refs_from]
37+
solver.modules_with_dead[solver.modules_with_dead]
38+
solver.dead_decls[solver.dead_decls]
39+
exception_refs_collection[exception_refs_collection]
40+
type_deps.intf_decls[type_deps.intf_decls]
41+
file_data_collection[file_data_collection]
42+
solver.dead_module_issues[solver.dead_module_issues]
43+
decl_refs.with_type_refs[decl_refs.with_type_refs]
44+
solver.modules_with_live[solver.modules_with_live]
45+
decl_refs.type_decl_refs[decl_refs.type_decl_refs]
46+
files[files]
47+
solver.modules_with_reported[solver.modules_with_reported]
48+
liveness.externally_referenced[liveness.externally_referenced]
49+
liveness.edges[liveness.edges]
50+
liveness.live[liveness.live]
51+
decls[decls]
5252
type_deps.intf_to_impl_refs_join{join}
5353
liveness.external_value_refs_join{join}
5454
type_deps.impl_to_intf_refs_path2_join{join}
@@ -177,3 +177,10 @@ graph TD
177177
type_deps.u1_union --> type_deps.u1
178178
decl_refs.with_type_refs_join --> decl_refs.with_type_refs
179179

180+
classDef joinClass fill:#e6f3ff,stroke:#0066cc
181+
classDef unionClass fill:#fff0e6,stroke:#cc6600
182+
classDef fixpointClass fill:#e6ffe6,stroke:#006600
183+
class decl_refs.with_type_refs_join,decl_refs.combined_join,decl_refs.type_decl_refs_join,liveness.external_type_refs_join,type_deps.impl_needing_path2_join,decl_refs.with_value_refs_join,solver.live_decls_join,type_deps.impl_to_intf_refs_join,decl_refs.value_decl_refs_join,liveness.annotated_roots_join,solver.dead_decls_join,solver.dead_module_issues_join,solver.dead_modules_join,exc_refs.resolved_refs_join,solver.incorrect_dead_decls_join,type_deps.impl_to_intf_refs_path2_join,liveness.external_value_refs_join,type_deps.intf_to_impl_refs_join joinClass
184+
class type_deps.u1_union,type_deps.u2_union,liveness.type_refs_from_union,liveness.all_roots_union,liveness.externally_referenced_union,type_deps.combined_refs_to_union,liveness.value_refs_from_union unionClass
185+
class liveness.live_fp fixpointClass
186+

0 commit comments

Comments
 (0)