When a procedure has a call-by-reference parameter, all that has to be passed as an actual parameter is the reference to the variable, in our case the arrayref. For a call-by-value parameter the value of the variable or constant has to be passed as the actual parameter. This implies that the descriptor of a call-by-reference parameter should be one of the strings `` [I'', `` [F'', `` [C'' or `` [Z'' for respectively Pascal types integer, real, char and boolean. The descriptor of a call-by-value parameter should be one of the strings `` I'', `` F'', `` C'' or `` Z'' for the respective types.
The descriptor of the return type is the same as a descriptor of a call-by-value parameter, as a function needs to return a value, not a reference to a value.
When a procedure has call-by-value parameters, it has to be able to pass them as call-by-reference parameters to another procedure. This is why the values passed as call-by-value parameters have to be converted into arrays. This is done by adding the following sequence of instructions to the code[] array of the method that receives the values as call-by-value parameters:
iconst_1 load the size of the array;newarray atype create the array;
dup duplicate the arrayref;
astore next_unused_pos store the arrayref in local variable;
iconst_0 load index of the element to hold the value;
<t>load valindex load the value on the stack;
<t>astore store the value in the element.
In effect it is the same way as the constants are initialized to their constantvalue, except this time we use local variables instead of global constants.
The <t>load instruction loads the value from the local variable at valindex in the local variable table, where <t> is the letter for the type of the array, where i stands for int, f for float, c for char and b for boolean. The valindex is simply the number of the parameter in the parameterlist of the method.
Call-by-reference parameters can just stay the way they are, because they are already references to the variable, and therefore are already arrays of one element.
I used to make the parameters global variables, as I did with the local variables of a procedure or function. I did this because parameters are in effect local variables of a function or procedure. But when you do that, you have the same problem as described in subsection 9.1.3, which should be solved exactly the same way, by passing all parameters as call-by-reference parameters to each of the nested procedures or functions declared in this procedure or function, just as you should do with the local variables.