Skip to content

Commit 690b8dd

Browse files
committed
Allow optional parameters.
1 parent e339bc5 commit 690b8dd

File tree

1 file changed

+13
-6
lines changed

1 file changed

+13
-6
lines changed

com.ibm.wala.cast.python.ml/source/com/ibm/wala/cast/python/ml/client/TensorGenerator.java

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -669,19 +669,26 @@ protected int getArgumentValueNumber(int parameterPosition) {
669669
: this.getNode().getIR().getParameter(parameterPosition + 1);
670670
}
671671

672-
protected int getArgumentValueNumber(PropagationCallGraphBuilder builder, int paramPos) {
672+
protected int getArgumentValueNumber(
673+
PropagationCallGraphBuilder builder, int paramPos, boolean optional) {
673674
Set<Integer> numArgs = this.getNumberOfPossiblePositionalArguments(builder);
674675

675676
if (!numArgs.stream().anyMatch(n -> n >= paramPos + 1))
676-
throw new IllegalStateException(
677-
"Cannot determine value number for parameter at position "
678-
+ paramPos
679-
+ " of "
680-
+ this.getSignature());
677+
if (optional) return -1;
678+
else
679+
throw new IllegalStateException(
680+
"Cannot determine value number for parameter at position "
681+
+ paramPos
682+
+ " of "
683+
+ this.getSignature());
681684

682685
return this.getArgumentValueNumber(paramPos);
683686
}
684687

688+
protected int getArgumentValueNumber(PropagationCallGraphBuilder builder, int paramPos) {
689+
return this.getArgumentValueNumber(builder, paramPos, false);
690+
}
691+
685692
/**
686693
* Returns the set of possible numbers of positional arguments passed to the range function at the
687694
* call.

0 commit comments

Comments
 (0)