11// TODO: Fix the switch
2-
32import csharp
43
54private newtype TEdgeKind =
6- TGotoEdge ( ) or // Single successor (including fall-through)
7- TTrueEdge ( ) or // 'true' edge of conditional branch
8- TFalseEdge ( ) or // 'false' edge of conditional branch
9- TExceptionEdge ( ) or // Thrown exception
10- TDefaultEdge ( ) or // 'default' label of switch
5+ TGotoEdge ( ) or // Single successor (including fall-through)
6+ TTrueEdge ( ) or // 'true' edge of conditional branch
7+ TFalseEdge ( ) or // 'false' edge of conditional branch
8+ TExceptionEdge ( ) or // Thrown exception
9+ TDefaultEdge ( ) or // 'default' label of switch
1110 TCaseEdge ( )
11+
1212// TCaseEdge(Expr expr, string condition) { // Case label of switch
1313// exists(CaseStmt caseStmt |
1414// hasCaseEdge(caseStmt, minValue, maxValue)
1515// )
1616// }
17-
1817/**
1918 * Represents the kind of an edge in the IR control flow graph. Each
2019 * `Instruction` or `IRBlock` has at most one successor of any single
@@ -29,81 +28,58 @@ abstract class EdgeKind extends TEdgeKind {
2928 * or `IRBlock`.
3029 */
3130class GotoEdge extends EdgeKind , TGotoEdge {
32- override final string toString ( ) {
33- result = "Goto"
34- }
31+ final override string toString ( ) { result = "Goto" }
3532}
3633
37- GotoEdge gotoEdge ( ) {
38- result = TGotoEdge ( )
39- }
34+ GotoEdge gotoEdge ( ) { result = TGotoEdge ( ) }
4035
4136/**
4237 * A "true" edge, representing the successor of a conditional branch when the
4338 * condition is non-zero.
4439 */
4540class TrueEdge extends EdgeKind , TTrueEdge {
46- override final string toString ( ) {
47- result = "True"
48- }
41+ final override string toString ( ) { result = "True" }
4942}
5043
51- TrueEdge trueEdge ( ) {
52- result = TTrueEdge ( )
53- }
44+ TrueEdge trueEdge ( ) { result = TTrueEdge ( ) }
5445
5546/**
5647 * A "false" edge, representing the successor of a conditional branch when the
5748 * condition is zero.
5849 */
5950class FalseEdge extends EdgeKind , TFalseEdge {
60- override final string toString ( ) {
61- result = "False"
62- }
51+ final override string toString ( ) { result = "False" }
6352}
6453
65- FalseEdge falseEdge ( ) {
66- result = TFalseEdge ( )
67- }
54+ FalseEdge falseEdge ( ) { result = TFalseEdge ( ) }
6855
6956/**
7057 * An "exception" edge, representing the successor of an instruction when that
7158 * instruction's evaluation throws an exception.
7259 */
7360class ExceptionEdge extends EdgeKind , TExceptionEdge {
74- override final string toString ( ) {
75- result = "Exception"
76- }
61+ final override string toString ( ) { result = "Exception" }
7762}
7863
79- ExceptionEdge exceptionEdge ( ) {
80- result = TExceptionEdge ( )
81- }
64+ ExceptionEdge exceptionEdge ( ) { result = TExceptionEdge ( ) }
8265
8366/**
8467 * A "default" edge, representing the successor of a `Switch` instruction when
8568 * none of the case values matches the condition value.
8669 */
8770class DefaultEdge extends EdgeKind , TDefaultEdge {
88- override final string toString ( ) {
89- result = "Default"
90- }
71+ final override string toString ( ) { result = "Default" }
9172}
9273
93- DefaultEdge defaultEdge ( ) {
94- result = TDefaultEdge ( )
95- }
74+ DefaultEdge defaultEdge ( ) { result = TDefaultEdge ( ) }
9675
9776///**
9877// * A "case" edge, representing the successor of a `Switch` instruction when the
9978// * the condition value matches a correponding `case` label.
10079// */
10180class CaseEdge extends EdgeKind , TCaseEdge {
102- override final string toString ( ) {
103- result = "CASE"
104- }
81+ final override string toString ( ) { result = "CASE" }
10582}
106-
10783//class CaseEdge extends EdgeKind, TCaseEdge {
10884// string minValue;
10985// string maxValue;
0 commit comments