@@ -1191,6 +1191,41 @@ module Make<LocationSig Location, InputSig<Location> Input> {
1191
1191
)
1192
1192
) .toString ( )
1193
1193
}
1194
+
1195
+ module Mermaid {
1196
+ private string nodeId ( RelevantNode n ) { nodes ( n , "semmle.order" , result ) }
1197
+
1198
+ private string nodes ( ) {
1199
+ result =
1200
+ concat ( RelevantNode n , string id , string text |
1201
+ id = nodeId ( n ) and
1202
+ text = n .toString ( )
1203
+ |
1204
+ id + "[\"" + text + "\"]" , "\n" order by id
1205
+ )
1206
+ }
1207
+
1208
+ private string edge ( RelevantNode pred , RelevantNode succ , string ord ) {
1209
+ edges ( pred , succ , "semmle.order" , ord ) and
1210
+ exists ( string label |
1211
+ edges ( pred , succ , "semmle.label" , label ) and
1212
+ if label = ""
1213
+ then result = nodeId ( pred ) + " --> " + nodeId ( succ )
1214
+ else result = nodeId ( pred ) + " -- " + label + " --> " + nodeId ( succ )
1215
+ )
1216
+ }
1217
+
1218
+ private string edges ( ) {
1219
+ result =
1220
+ concat ( RelevantNode pred , RelevantNode succ , string edge , string ord |
1221
+ edge = edge ( pred , succ , ord )
1222
+ |
1223
+ edge , "\n" order by ord
1224
+ )
1225
+ }
1226
+
1227
+ query predicate mermaid ( string s ) { s = "flowchart TD\n" + nodes ( ) + "\n\n" + edges ( ) }
1228
+ }
1194
1229
}
1195
1230
1196
1231
/** Provides the input to `ViewCfgQuery`. */
@@ -1263,6 +1298,7 @@ module Make<LocationSig Location, InputSig<Location> Input> {
1263
1298
}
1264
1299
1265
1300
import TestOutput< RelevantNode >
1301
+ import Mermaid
1266
1302
}
1267
1303
1268
1304
/** Provides a set of consistency queries. */
0 commit comments