method.pop();
}
// next, iterate over all optional args, until no more arguments
for (int optArgElement = 0; optArgElement < optArgsCount; currentArgElement++, optArgElement++) {
Label noMoreArrayElements = new Label();
Label doneWithElement = new Label();
// confirm we're not past the end of the array
method.dup(); // dup the original array
method.arraylength();
method.pushInt(currentArgElement);
method.if_icmple(noMoreArrayElements); // if length <= start, end loop
// extract item from array
method.dup(); // dup the original array
method.pushInt(currentArgElement); // index for the item
method.arrayload();
optGivenAssignment.nextValue(methodCompiler, optArgs, optArgElement);
method.go_to(doneWithElement);
// otherwise no items left available, use the code for default
method.label(noMoreArrayElements);
optNotGivenAssignment.nextValue(methodCompiler, optArgs, optArgElement);
// end of this element
method.label(doneWithElement);
// normal assignment leaves the value; pop it.
method.pop();
}
// if there's args left and we want them, assign to rest arg
if (restAssignment != null) {
Label emptyArray = new Label();
Label readyForArgs = new Label();
// confirm we're not past the end of the array
method.dup(); // dup the original array
method.arraylength();
method.pushInt(currentArgElement);