mirror of
https://github.com/github/codeql.git
synced 2025-12-20 02:44:30 +01:00
Python: Add "enclosing callable" for ModuleVariableNode
I've named this `DataFlowModuleScope` since it's not really a callable (and all of the relevant methods are empty anyway).
This commit is contained in:
@@ -185,7 +185,8 @@ private Node update(Node node) {
|
||||
*/
|
||||
newtype TDataFlowCallable =
|
||||
TCallableValue(CallableValue callable) or
|
||||
TClassValue(ClassValue c)
|
||||
TClassValue(ClassValue c) or
|
||||
TModule(Module m)
|
||||
|
||||
/** Represents a callable */
|
||||
abstract class DataFlowCallable extends TDataFlowCallable {
|
||||
@@ -239,6 +240,22 @@ class DataFlowClassValue extends DataFlowCallable, TClassValue {
|
||||
override string getName() { result = c.getName() }
|
||||
}
|
||||
|
||||
class DataFlowModuleScope extends DataFlowCallable, TModule {
|
||||
Module mod;
|
||||
|
||||
DataFlowModuleScope() { this = TModule(mod) }
|
||||
|
||||
override string toString() { result = mod.toString() }
|
||||
|
||||
override CallNode getACall() { none() }
|
||||
|
||||
override Scope getScope() { result = mod }
|
||||
|
||||
override NameNode getParameter(int n) { none() }
|
||||
|
||||
override string getName() { result = mod.getName() }
|
||||
}
|
||||
|
||||
newtype TDataFlowCall =
|
||||
TCallNode(CallNode call) or
|
||||
TSpecialCall(SpecialMethodCallNode special)
|
||||
|
||||
@@ -177,6 +177,10 @@ class ModuleVariableNode extends Node, TModuleVariableNode {
|
||||
result.asVar().getDefinition().(EssaNodeDefinition).definedBy(var, defn)
|
||||
)
|
||||
}
|
||||
|
||||
override DataFlowCallable getEnclosingCallable() { result.(DataFlowModuleScope).getScope() = mod }
|
||||
|
||||
override Location getLocation() { result = mod.getLocation() }
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user