Python: Refactor get[Named]ArgumentForCall

Also fixed a bug for BoundMethodValue, as highlighted in the expected diff 👍
This commit is contained in:
Rasmus Wriedt Larsen
2020-05-04 20:51:23 +02:00
parent bc92c26e12
commit 838106d49c
2 changed files with 6 additions and 18 deletions

View File

@@ -363,11 +363,7 @@ class CallableValue extends Value {
or
exists(string name |
call.getArgByName(name) = result and
(
this.(PythonFunctionObjectInternal).getScope().getArg(n).getName() = name
or
this.(BoundMethodObjectInternal).getFunction().getScope().getArg(n+1).getName() = name
)
this.getParameter(n).getId() = name
)
or
called instanceof BoundMethodObjectInternal and
@@ -386,19 +382,11 @@ class CallableValue extends Value {
|
exists(int n |
call.getArg(n) = result and
exists(PythonFunctionObjectInternal py |
py = this or py = this.(BoundMethodObjectInternal).getFunction()
|
py.getScope().getArg(n + offset).getName() = name
)
this.getParameter(n+offset).getId() = name
)
or
call.getArgByName(name) = result and
exists(PythonFunctionObjectInternal py |
py = this or py = this.(BoundMethodObjectInternal).getFunction()
|
exists(py.getScope().getArgByName(name))
)
exists(this.getParameterByName(name))
or
called instanceof BoundMethodObjectInternal and
offset = 1 and

View File

@@ -7,11 +7,11 @@
| 23 | ControlFlowNode for Attribute() | Function f | arg1 | ControlFlowNode for w |
| 23 | ControlFlowNode for Attribute() | Function f | arg2 | ControlFlowNode for z |
| 23 | ControlFlowNode for Attribute() | Function f | self | ControlFlowNode for c |
| 23 | ControlFlowNode for Attribute() | Method(Function f, C()) | arg0 | ControlFlowNode for w |
| 23 | ControlFlowNode for Attribute() | Method(Function f, C()) | arg1 | ControlFlowNode for z |
| 23 | ControlFlowNode for Attribute() | Method(Function f, C()) | arg1 | ControlFlowNode for w |
| 23 | ControlFlowNode for Attribute() | Method(Function f, C()) | arg2 | ControlFlowNode for z |
| 24 | ControlFlowNode for Attribute() | Function C.n | arg1 | ControlFlowNode for x |
| 24 | ControlFlowNode for Attribute() | Function C.n | self | ControlFlowNode for c |
| 24 | ControlFlowNode for Attribute() | Method(Function C.n, C()) | self | ControlFlowNode for x |
| 24 | ControlFlowNode for Attribute() | Method(Function C.n, C()) | arg1 | ControlFlowNode for x |
| 25 | ControlFlowNode for Attribute() | Function C.n | arg1 | ControlFlowNode for z |
| 25 | ControlFlowNode for Attribute() | Function C.n | self | ControlFlowNode for y |
| 33 | ControlFlowNode for Attribute() | Function D.foo | arg | ControlFlowNode for IntegerLiteral |