Member predicate CallableValue::getArgumentForCall
Gets the argument in call
corresponding to the n
’th positional parameter of this callable.
Use this method instead of call.getArg(n)
to handle the fact that this function might be used as
a bound-method, such that argument n
of the call corresponds to the n+1
parameter of the callable.
This method also gives results when the argument is passed as a keyword argument in call
, as long
as this
is not a builtin function or a builtin method.
Examples:
-
if
this
represents thePythonFunctionValue
fordef func(a, b):
, andcall
representsfunc(10, 20)
, thengetArgumentForCall(call, 0)
will give theControlFlowNode
for10
. -
with
call
representingfunc(b=20, a=10)
,getArgumentForCall(call, 0)
will give theControlFlowNode
for10
. -
if
this
represents thePythonFunctionValue
fordef func(self, a, b):
, andcall
representsfoo.func(10, 20)
, thengetArgumentForCall(call, 1)
will give theControlFlowNode
for10
. Note: There will also exist aBoundMethodValue bm
wherebm.getArgumentForCall(call, 0)
will give theControlFlowNode
for10
(notice the shift in index used).
ControlFlowNode getArgumentForCall(CallNode call, int n)