@@ -10,58 +10,22 @@ private import internal.ControlFlowGraphImpl as CfgImpl
10
10
private import internal.Splitting
11
11
12
12
/** An entry node for a given scope. */
13
- class EntryNode extends CfgNode , CfgImpl:: TEntryNode {
13
+ class EntryNode extends CfgNode , CfgImpl:: EntryNode {
14
14
override string getAPrimaryQlClass ( ) { result = "EntryNode" }
15
15
16
- private CfgScope scope ;
17
-
18
- EntryNode ( ) { this = CfgImpl:: TEntryNode ( scope ) }
19
-
20
16
final override EntryBasicBlock getBasicBlock ( ) { result = super .getBasicBlock ( ) }
21
-
22
- final override Location getLocation ( ) { result = scope .getLocation ( ) }
23
-
24
- final override string toString ( ) { result = "enter " + scope }
25
17
}
26
18
27
19
/** An exit node for a given scope, annotated with the type of exit. */
28
- class AnnotatedExitNode extends CfgNode , CfgImpl:: TAnnotatedExitNode {
20
+ class AnnotatedExitNode extends CfgNode , CfgImpl:: AnnotatedExitNode {
29
21
override string getAPrimaryQlClass ( ) { result = "AnnotatedExitNode" }
30
22
31
- private CfgScope scope ;
32
- private boolean normal ;
33
-
34
- AnnotatedExitNode ( ) { this = CfgImpl:: TAnnotatedExitNode ( scope , normal ) }
35
-
36
- /** Holds if this node represent a normal exit. */
37
- final predicate isNormal ( ) { normal = true }
38
-
39
23
final override AnnotatedExitBasicBlock getBasicBlock ( ) { result = super .getBasicBlock ( ) }
40
-
41
- final override Location getLocation ( ) { result = scope .getLocation ( ) }
42
-
43
- final override string toString ( ) {
44
- exists ( string s |
45
- normal = true and s = "normal"
46
- or
47
- normal = false and s = "abnormal"
48
- |
49
- result = "exit " + scope + " (" + s + ")"
50
- )
51
- }
52
24
}
53
25
54
26
/** An exit node for a given scope. */
55
- class ExitNode extends CfgNode , CfgImpl:: TExitNode {
27
+ class ExitNode extends CfgNode , CfgImpl:: ExitNode {
56
28
override string getAPrimaryQlClass ( ) { result = "ExitNode" }
57
-
58
- private CfgScope scope ;
59
-
60
- ExitNode ( ) { this = CfgImpl:: TExitNode ( scope ) }
61
-
62
- final override Location getLocation ( ) { result = scope .getLocation ( ) }
63
-
64
- final override string toString ( ) { result = "exit " + scope }
65
29
}
66
30
67
31
/**
@@ -71,42 +35,16 @@ class ExitNode extends CfgNode, CfgImpl::TExitNode {
71
35
* (dead) code or not important for control flow, and multiple when there are different
72
36
* splits for the AST node.
73
37
*/
74
- class AstCfgNode extends CfgNode , CfgImpl:: TElementNode {
38
+ class AstCfgNode extends CfgNode , CfgImpl:: AstCfgNode {
75
39
/** Gets the name of the primary QL class for this node. */
76
40
override string getAPrimaryQlClass ( ) { result = "AstCfgNode" }
77
-
78
- private CfgImpl:: Splits splits ;
79
- AstNode e ;
80
-
81
- AstCfgNode ( ) { this = CfgImpl:: TElementNode ( _, e , splits ) }
82
-
83
- final override AstNode getNode ( ) { result = e }
84
-
85
- override Location getLocation ( ) { result = e .getLocation ( ) }
86
-
87
- final override string toString ( ) {
88
- exists ( string s | s = e .toString ( ) |
89
- result = "[" + this .getSplitsString ( ) + "] " + s
90
- or
91
- not exists ( this .getSplitsString ( ) ) and result = s
92
- )
93
- }
94
-
95
- /** Gets a comma-separated list of strings for each split in this node, if any. */
96
- final string getSplitsString ( ) {
97
- result = splits .toString ( ) and
98
- result != ""
99
- }
100
-
101
- /** Gets a split for this control flow node, if any. */
102
- final Split getASplit ( ) { result = splits .getASplit ( ) }
103
41
}
104
42
105
43
/** A control-flow node that wraps an AST expression. */
106
44
class ExprCfgNode extends AstCfgNode {
107
45
override string getAPrimaryQlClass ( ) { result = "ExprCfgNode" }
108
46
109
- override Expr e ;
47
+ Expr e ;
110
48
111
49
ExprCfgNode ( ) { e = this .getNode ( ) }
112
50
@@ -146,7 +84,7 @@ class StringComponentCfgNode extends AstCfgNode {
146
84
class RegExpComponentCfgNode extends StringComponentCfgNode {
147
85
override string getAPrimaryQlClass ( ) { result = "RegExpComponentCfgNode" }
148
86
149
- RegExpComponentCfgNode ( ) { e instanceof RegExpComponent }
87
+ RegExpComponentCfgNode ( ) { this . getNode ( ) instanceof RegExpComponent }
150
88
}
151
89
152
90
private AstNode desugar ( AstNode n ) {
@@ -440,9 +378,11 @@ module ExprNodes {
440
378
441
379
/** A control-flow node that wraps an `InClause` AST expression. */
442
380
class InClauseCfgNode extends AstCfgNode {
443
- override string getAPrimaryQlClass ( ) { result = "InClauseCfgNode" }
381
+ private InClauseChildMapping e ;
382
+
383
+ InClauseCfgNode ( ) { e = this .getNode ( ) }
444
384
445
- override InClauseChildMapping e ;
385
+ override string getAPrimaryQlClass ( ) { result = "InClauseCfgNode" }
446
386
447
387
/** Gets the pattern in this `in`-clause. */
448
388
final AstCfgNode getPattern ( ) { e .hasCfgChild ( e .getPattern ( ) , this , result ) }
@@ -488,9 +428,11 @@ module ExprNodes {
488
428
489
429
/** A control-flow node that wraps a `WhenClause` AST expression. */
490
430
class WhenClauseCfgNode extends AstCfgNode {
491
- override string getAPrimaryQlClass ( ) { result = "WhenClauseCfgNode" }
431
+ private WhenClauseChildMapping e ;
492
432
493
- override WhenClauseChildMapping e ;
433
+ WhenClauseCfgNode ( ) { e = this .getNode ( ) }
434
+
435
+ override string getAPrimaryQlClass ( ) { result = "WhenClauseCfgNode" }
494
436
495
437
/** Gets the body of this `when`-clause. */
496
438
final ExprCfgNode getBody ( ) {
@@ -507,9 +449,11 @@ module ExprNodes {
507
449
508
450
/** A control-flow node that wraps a `CasePattern`. */
509
451
class CasePatternCfgNode extends AstCfgNode {
510
- override string getAPrimaryQlClass ( ) { result = "CasePatternCfgNode" }
452
+ CasePattern e ;
511
453
512
- override CasePattern e ;
454
+ CasePatternCfgNode ( ) { e = this .getNode ( ) }
455
+
456
+ override string getAPrimaryQlClass ( ) { result = "CasePatternCfgNode" }
513
457
}
514
458
515
459
private class ArrayPatternChildMapping extends NonExprChildMapping , ArrayPattern {
0 commit comments