@@ -262,6 +262,9 @@ private module Cached {
262
262
)
263
263
} or
264
264
TSsaDefinitionNode ( Ssa:: Definition def ) or
265
+ TRawNamespaceSelf ( Namespace ns ) {
266
+ not exists ( Ssa:: SelfDefinition def | def .getSourceVariable ( ) = ns .getModuleSelfVariable ( ) )
267
+ } or
265
268
TNormalParameterNode ( Parameter p ) {
266
269
p instanceof SimpleParameter or
267
270
p instanceof OptionalParameter or
@@ -402,6 +405,8 @@ private module Cached {
402
405
or
403
406
// Needed for stores in type tracking
404
407
TypeTrackerSpecific:: storeStepIntoSourceNode ( _, n , _)
408
+ or
409
+ n instanceof TRawNamespaceSelf
405
410
}
406
411
407
412
cached
@@ -523,6 +528,38 @@ class SsaSelfDefinitionNode extends LocalSourceNode, SsaDefinitionNode {
523
528
Scope getSelfScope ( ) { result = self .getDeclaringScope ( ) }
524
529
}
525
530
531
+ /**
532
+ * A representative for the created or re-opened class/module in a `Namespace` that does
533
+ * not have an SSA definition for `self`.
534
+ */
535
+ class RawNamespaceSelf extends NodeImpl , TRawNamespaceSelf {
536
+ private Namespace namespace ;
537
+
538
+ RawNamespaceSelf ( ) { this = TRawNamespaceSelf ( namespace ) }
539
+
540
+ /** Gets the namespace for which this represents the created or re-opened class/module. */
541
+ Namespace getNamespace ( ) { result = namespace }
542
+
543
+ override CfgScope getCfgScope ( ) { result = namespace .getCfgScope ( ) }
544
+
545
+ override Location getLocationImpl ( ) { result = namespace .getLocation ( ) }
546
+
547
+ override string toStringImpl ( ) { result = namespace .toString ( ) }
548
+ }
549
+
550
+ /**
551
+ * Gets a representative for the created or re-opened class/module in a `Namespace`.
552
+ *
553
+ * This is usually the SSA definition for `self`, but if this node does not exist due to lack of liveness,
554
+ * it is the `RawNamespaceSelf` node.
555
+ */
556
+ LocalSourceNode getNamespaceSelf ( Namespace namespace ) {
557
+ result .( SsaDefinitionNode ) .getDefinition ( ) .( Ssa:: SelfDefinition ) .getSourceVariable ( ) =
558
+ namespace .getModuleSelfVariable ( )
559
+ or
560
+ result = TRawNamespaceSelf ( namespace )
561
+ }
562
+
526
563
/**
527
564
* A value returning statement, viewed as a node in a data flow graph.
528
565
*
0 commit comments