@@ -17,6 +17,7 @@ private newtype TEdgeKind =
1717 * `EdgeKind`.
1818 */
1919abstract class EdgeKind extends TEdgeKind {
20+ /** Gets a textual representation of this edge kind. */
2021 abstract string toString ( ) ;
2122}
2223
@@ -28,8 +29,6 @@ class GotoEdge extends EdgeKind, TGotoEdge {
2829 final override string toString ( ) { result = "Goto" }
2930}
3031
31- GotoEdge gotoEdge ( ) { result = TGotoEdge ( ) }
32-
3332/**
3433 * A "true" edge, representing the successor of a conditional branch when the
3534 * condition is non-zero.
@@ -38,8 +37,6 @@ class TrueEdge extends EdgeKind, TTrueEdge {
3837 final override string toString ( ) { result = "True" }
3938}
4039
41- TrueEdge trueEdge ( ) { result = TTrueEdge ( ) }
42-
4340/**
4441 * A "false" edge, representing the successor of a conditional branch when the
4542 * condition is zero.
@@ -48,8 +45,6 @@ class FalseEdge extends EdgeKind, TFalseEdge {
4845 final override string toString ( ) { result = "False" }
4946}
5047
51- FalseEdge falseEdge ( ) { result = TFalseEdge ( ) }
52-
5348/**
5449 * An "exception" edge, representing the successor of an instruction when that
5550 * instruction's evaluation throws an exception.
@@ -58,8 +53,6 @@ class ExceptionEdge extends EdgeKind, TExceptionEdge {
5853 final override string toString ( ) { result = "Exception" }
5954}
6055
61- ExceptionEdge exceptionEdge ( ) { result = TExceptionEdge ( ) }
62-
6356/**
6457 * A "default" edge, representing the successor of a `Switch` instruction when
6558 * none of the case values matches the condition value.
@@ -68,8 +61,6 @@ class DefaultEdge extends EdgeKind, TDefaultEdge {
6861 final override string toString ( ) { result = "Default" }
6962}
7063
71- DefaultEdge defaultEdge ( ) { result = TDefaultEdge ( ) }
72-
7364/**
7465 * A "case" edge, representing the successor of a `Switch` instruction when the
7566 * the condition value matches a correponding `case` label.
@@ -91,4 +82,48 @@ class CaseEdge extends EdgeKind, TCaseEdge {
9182 string getMaxValue ( ) { result = maxValue }
9283}
9384
94- CaseEdge caseEdge ( string minValue , string maxValue ) { result = TCaseEdge ( minValue , maxValue ) }
85+ /**
86+ * Predicates to access the single instance of each `EdgeKind` class.
87+ */
88+ module EdgeKind {
89+ /**
90+ * Gets the single instance of the `GotoEdge` class.
91+ */
92+ GotoEdge gotoEdge ( ) { result = TGotoEdge ( ) }
93+
94+ /**
95+ * Gets the single instance of the `TrueEdge` class.
96+ */
97+ TrueEdge trueEdge ( ) { result = TTrueEdge ( ) }
98+
99+ /**
100+ * Gets the single instance of the `FalseEdge` class.
101+ */
102+ FalseEdge falseEdge ( ) { result = TFalseEdge ( ) }
103+
104+ /**
105+ * Gets the single instance of the `ExceptionEdge` class.
106+ */
107+ ExceptionEdge exceptionEdge ( ) { result = TExceptionEdge ( ) }
108+
109+ /**
110+ * Gets the single instance of the `DefaultEdge` class.
111+ */
112+ DefaultEdge defaultEdge ( ) { result = TDefaultEdge ( ) }
113+
114+ /**
115+ * Gets the `CaseEdge` representing a `case` label with the specified lower and upper bounds.
116+ * For example:
117+ * ```
118+ * switch (x) {
119+ * case 1: // Edge kind is `caseEdge("1", "1")`
120+ * return x;
121+ * case 2...8: // Edge kind is `caseEdge("2", "8")`
122+ * return x - 1;
123+ * default: // Edge kind is `defaultEdge()`
124+ * return 0;
125+ * }
126+ * ```
127+ */
128+ CaseEdge caseEdge ( string minValue , string maxValue ) { result = TCaseEdge ( minValue , maxValue ) }
129+ }
0 commit comments