@@ -93,9 +93,9 @@ module SsaFlow {
93
93
result = TSelfToplevelParameterNode ( p .asToplevelSelf ( ) )
94
94
}
95
95
96
- ParameterNodeImpl toParameterNodeImpl ( SsaDefinitionExtNode node ) {
96
+ ParameterNodeImpl toParameterNodeImpl ( SsaDefinitionNodeImpl node ) {
97
97
exists ( SsaImpl:: WriteDefinition def , SsaImpl:: ParameterExt p |
98
- def = node .getDefinitionExt ( ) and
98
+ def = node .getDefinition ( ) and
99
99
result = toParameterNode ( p ) and
100
100
p .isInitializedBy ( def )
101
101
)
@@ -392,10 +392,10 @@ module VariableCapture {
392
392
393
393
// From an assignment or implicit initialization of a captured variable to its flow-insensitive node
394
394
private predicate flowInsensitiveWriteStep (
395
- SsaDefinitionExtNode node1 , CapturedVariableNode node2 , CapturedVariable v
395
+ SsaDefinitionNodeImpl node1 , CapturedVariableNode node2 , CapturedVariable v
396
396
) {
397
397
exists ( CapturedSsaDefinitionExt def |
398
- def = node1 .getDefinitionExt ( ) and
398
+ def = node1 .getDefinition ( ) and
399
399
def .getSourceVariable ( ) = v and
400
400
(
401
401
def instanceof Ssa:: WriteDefinition
@@ -408,11 +408,11 @@ module VariableCapture {
408
408
409
409
// From a captured variable node to its flow-sensitive capture nodes
410
410
private predicate flowInsensitiveReadStep (
411
- CapturedVariableNode node1 , SsaDefinitionExtNode node2 , CapturedVariable v
411
+ CapturedVariableNode node1 , SsaDefinitionNodeImpl node2 , CapturedVariable v
412
412
) {
413
413
exists ( CapturedSsaDefinitionExt def |
414
414
node1 .getVariable ( ) = v and
415
- def = node2 .getDefinitionExt ( ) and
415
+ def = node2 .getDefinition ( ) and
416
416
def .getSourceVariable ( ) = v and
417
417
(
418
418
def instanceof Ssa:: CapturedCallDefinition
@@ -571,8 +571,8 @@ private module Cached {
571
571
}
572
572
573
573
/** Holds if `n` wraps an SSA definition without ingoing flow. */
574
- private predicate entrySsaDefinition ( SsaDefinitionExtNode n ) {
575
- n .getDefinitionExt ( ) =
574
+ private predicate entrySsaDefinition ( SsaDefinitionNodeImpl n ) {
575
+ n .getDefinition ( ) =
576
576
any ( SsaImpl:: WriteDefinition def | not def .( Ssa:: WriteDefinition ) .assigns ( _) )
577
577
}
578
578
@@ -614,7 +614,7 @@ private module Cached {
614
614
// to parameters (which are themselves local sources)
615
615
entrySsaDefinition ( n ) and
616
616
not exists ( SsaImpl:: ParameterExt p |
617
- p .isInitializedBy ( n .( SsaDefinitionExtNode ) . getDefinitionExt ( ) )
617
+ p .isInitializedBy ( n .( SsaDefinitionNodeImpl ) . getDefinition ( ) )
618
618
)
619
619
or
620
620
isStoreTargetNode ( n )
@@ -749,51 +749,38 @@ predicate nodeIsHidden(Node n) {
749
749
}
750
750
751
751
/** An SSA node. */
752
- abstract class SsaNode extends NodeImpl , TSsaNode {
752
+ class SsaNode extends NodeImpl , TSsaNode {
753
753
SsaImpl:: DataFlowIntegration:: SsaNode node ;
754
- SsaImpl:: DefinitionExt def ;
755
754
756
- SsaNode ( ) {
757
- this = TSsaNode ( node ) and
758
- def = node .getDefinitionExt ( )
759
- }
755
+ SsaNode ( ) { this = TSsaNode ( node ) }
760
756
761
- SsaImpl:: DefinitionExt getDefinitionExt ( ) { result = def }
757
+ /** Gets the underlying variable. */
758
+ Variable getVariable ( ) { result = node .getSourceVariable ( ) }
762
759
763
760
/** Holds if this node should be hidden from path explanations. */
764
- abstract predicate isHidden ( ) ;
761
+ predicate isHidden ( ) { any ( ) }
762
+
763
+ override CfgScope getCfgScope ( ) { result = node .getBasicBlock ( ) .getScope ( ) }
765
764
766
765
override Location getLocationImpl ( ) { result = node .getLocation ( ) }
767
766
768
767
override string toStringImpl ( ) { result = node .toString ( ) }
769
768
}
770
769
771
- /** An (extended) SSA definition, viewed as a node in a data flow graph. */
772
- class SsaDefinitionExtNode extends SsaNode {
773
- override SsaImpl:: DataFlowIntegration:: SsaDefinitionExtNode node ;
770
+ class SsaDefinitionNodeImpl extends SsaNode {
771
+ override SsaImpl:: DataFlowIntegration:: SsaDefinitionNode node ;
774
772
775
- /** Gets the underlying variable. */
776
- Variable getVariable ( ) { result = def .getSourceVariable ( ) }
773
+ SsaImpl:: Definition getDefinition ( ) { result = node .getDefinition ( ) }
777
774
778
775
override predicate isHidden ( ) {
779
- not def instanceof Ssa:: WriteDefinition
780
- or
781
- isDesugarNode ( def .( Ssa:: WriteDefinition ) .getWriteAccess ( ) .getExpr ( ) )
782
- or
783
- def = getParameterDef ( _)
776
+ exists ( SsaImpl:: Definition def | def = this .getDefinition ( ) |
777
+ not def instanceof Ssa:: WriteDefinition
778
+ or
779
+ isDesugarNode ( def .( Ssa:: WriteDefinition ) .getWriteAccess ( ) .getExpr ( ) )
780
+ or
781
+ def = getParameterDef ( _)
782
+ )
784
783
}
785
-
786
- override CfgScope getCfgScope ( ) { result = def .getBasicBlock ( ) .getScope ( ) }
787
- }
788
-
789
- class SsaDefinitionNodeImpl extends SsaDefinitionExtNode {
790
- Ssa:: Definition ssaDef ;
791
-
792
- SsaDefinitionNodeImpl ( ) { ssaDef = def }
793
-
794
- override Location getLocationImpl ( ) { result = ssaDef .getLocation ( ) }
795
-
796
- override string toStringImpl ( ) { result = ssaDef .toString ( ) }
797
784
}
798
785
799
786
/**
@@ -833,17 +820,13 @@ class SsaDefinitionNodeImpl extends SsaDefinitionExtNode {
833
820
*/
834
821
class SsaInputNode extends SsaNode {
835
822
override SsaImpl:: DataFlowIntegration:: SsaInputNode node ;
836
-
837
- override predicate isHidden ( ) { any ( ) }
838
-
839
- override CfgScope getCfgScope ( ) { result = node .getDefinitionExt ( ) .getBasicBlock ( ) .getScope ( ) }
840
823
}
841
824
842
825
/** An SSA definition for a `self` variable. */
843
- class SsaSelfDefinitionNode extends SsaDefinitionExtNode {
826
+ class SsaSelfDefinitionNode extends SsaDefinitionNodeImpl {
844
827
private SelfVariable self ;
845
828
846
- SsaSelfDefinitionNode ( ) { self = def . getSourceVariable ( ) }
829
+ SsaSelfDefinitionNode ( ) { self = super . getVariable ( ) }
847
830
848
831
/** Gets the scope in which the `self` variable is declared. */
849
832
Scope getSelfScope ( ) { result = self .getDeclaringScope ( ) }
@@ -1976,9 +1959,9 @@ predicate localMustFlowStep(Node node1, Node node2) {
1976
1959
or
1977
1960
exists ( SsaImpl:: Definition def |
1978
1961
def .( Ssa:: WriteDefinition ) .assigns ( node1 .asExpr ( ) ) and
1979
- node2 .( SsaDefinitionExtNode ) . getDefinitionExt ( ) = def
1962
+ node2 .( SsaDefinitionNodeImpl ) . getDefinition ( ) = def
1980
1963
or
1981
- def = node1 .( SsaDefinitionExtNode ) . getDefinitionExt ( ) and
1964
+ def = node1 .( SsaDefinitionNodeImpl ) . getDefinition ( ) and
1982
1965
node2 .asExpr ( ) = SsaImpl:: getARead ( def )
1983
1966
)
1984
1967
or
@@ -2122,8 +2105,8 @@ class CastNode extends Node {
2122
2105
predicate neverSkipInPathGraph ( Node n ) {
2123
2106
// ensure that all variable assignments are included in the path graph
2124
2107
n =
2125
- any ( SsaDefinitionExtNode def |
2126
- def .getDefinitionExt ( ) instanceof Ssa:: WriteDefinition and
2108
+ any ( SsaDefinitionNodeImpl def |
2109
+ def .getDefinition ( ) instanceof Ssa:: WriteDefinition and
2127
2110
not def .isHidden ( )
2128
2111
)
2129
2112
}
@@ -2446,15 +2429,15 @@ module TypeInference {
2446
2429
}
2447
2430
2448
2431
pragma [ nomagic]
2449
- private predicate ssaDefHasType ( SsaDefinitionExtNode def , Module tp , boolean exact ) {
2432
+ private predicate ssaDefHasType ( SsaDefinitionNodeImpl def , Module tp , boolean exact ) {
2450
2433
exists ( ParameterNodeImpl p |
2451
2434
parameterNodeHasType ( p , tp , exact ) and
2452
2435
p = SsaFlow:: toParameterNodeImpl ( def )
2453
2436
)
2454
2437
or
2455
2438
selfInMethodOrToplevelHasType ( def .getVariable ( ) , tp , exact )
2456
2439
or
2457
- asModulePattern ( def .getDefinitionExt ( ) , tp ) and
2440
+ asModulePattern ( def .getDefinition ( ) , tp ) and
2458
2441
exact = false
2459
2442
}
2460
2443
@@ -2523,11 +2506,11 @@ module TypeInference {
2523
2506
or
2524
2507
parameterNodeHasType ( n , tp , exact )
2525
2508
or
2526
- exists ( SsaDefinitionExtNode def | ssaDefHasType ( def , tp , exact ) |
2509
+ exists ( SsaDefinitionNodeImpl def | ssaDefHasType ( def , tp , exact ) |
2527
2510
n = def or
2528
2511
n .asExpr ( ) =
2529
2512
any ( CfgNodes:: ExprCfgNode read |
2530
- read = def .getDefinitionExt ( ) .getARead ( ) and
2513
+ read = def .getDefinition ( ) . ( SsaImpl :: DefinitionExt ) .getARead ( ) and
2531
2514
not isTypeCheckedRead ( read , _) // could in principle be checked against a new type
2532
2515
)
2533
2516
)
0 commit comments