| United States-English |
|
|
|
![]() |
HP Pascal/HP-UX Programmer's Guide > Chapter 7 Parameters Hidden Parameters |
|
Hidden parameters do not appear in formal or actual parameter lists, but are nevertheless passed to routines. They are always integers. You must know about hidden parameters in order to debug your program at the assembly language level, and you must include them in the parameter lists of external routines that are not written in Pascal. (For information, see Chapter 9 “External Routines ”.) Table 7-3 “Hidden Parameters ” shows which routines receive hidden parameters, how many hidden parameters they receive, where the hidden parameters are in the physical parameter order, and the values of the hidden parameters. Table 7-3 Hidden Parameters
If a routine has ANYVAR parameters, its physical parameter order contains one hidden parameter for each. In the physical parameter order, each hidden parameter follows its corresponding ANYVAR parameter. The value of each hidden parameter is the size of the corresponding ANYVAR parameter (in bytes). If the routine specifies the UNCHECKABLE_ANYVAR option, no hidden parameters are passed for ANYVAR parameters. The UNCHECKABLE_ANYVAR option is used when calling routines that were not written in Pascal. Example 1
Including hidden parameters (highlighted), the parameter list that appears as p(1,x,y,4,z) in the preceding program is: Table 7-4 Title not available (ANYVAR Parameters )
You can access these hidden parameters with the predefined functions bitsizeof and sizeof. If the UNCHECKABLE_ANYVAR procedure option is specified, bitsizeof and sizeof return the size of the formal parameter (for more information on UNCHECKABLE_ANYVAR, see Chapter 8 “Procedure Options ”). Example 2
The preceding program prints:
The procedure p1 does not specify the option UNCHECKABLE_ANYVAR, so it can access the hidden parameter associated with the actual parameter v. The functions sizeof(parm) and bitsizeof(parm) return the size of the actual parameter v. The procedure p2 specifies the option UNCHECKABLE_ANYVAR, so it cannot access the hidden parameter associated with the actual parameter v, because it is omitted from the physical parameter order. The functions sizeof(parm) and bitsizeof(parm) return the size of the formal parameter parm (that is, the sizes of the type t2). If a routine has generic string parameters, its physical parameter order contains one hidden parameter for each. In the physical parameter order, each hidden parameter follows its corresponding actual string parameter. The value of each hidden parameter is the maximum length of the corresponding actual string parameter. If a routine has an extensible parameter list, its physical parameter order begins with a hidden parameter. The value of the hidden parameter is the number of actual parameters passed, excluding hidden parameters. This value is always greater than or equal to the number of nonextension parameters, because the routine must have a value for each of them. Example
The procedure p has one nonextension parameter, so the value of the hidden parameter for any call to p is at least one. In the first call above, p receives one value from DEFAULT_PARMS; the value of the hidden parameter is one. In the second call, p receives one value from the actual parameter list; the value of the hidden parameter is one. In the third call, p receives two values from the actual parameter list; the value of the hidden parameter is two. In the fourth call, p receives one value from DEFAULT_PARMS and one from the actual parameter list; the value of the hidden parameter is two. For more information on OPTION EXTENSIBLE and OPTION DEFAULT_PARMS, see Chapter 8 “Procedure Options ”. If a routine has multidimensional conformant array parameters, its physical parameter order contains one hidden parameter for each nested conformant array element. In the physical parameter order, each hidden parameter follows the actual parameters for the bounds of its corresponding dimension. The value of each hidden parameter is the size of its corresponding dimension. These hidden parameters are not accessible to the programmer. The program uses them to calculate values of the sizeof function. Example
The call p(a) passes two hidden parameters to p, one for each nested conformant array dimension. Including hidden parameters (highlighted), the parameter list that appears in the preceding program as p(a) is: Table 7-5 Title not available (Multidimensional Conformant Array Parameters )
If a routine has routine parameters, its physical parameter order contains one hidden parameter for each routine parameter. (This is not true of parameters that are routine variables.) These hidden parameters are at the end of the physical parameter order, in the same order as their corresponding routine parameters. The value of a hidden parameter for a specific routine parameter is the static link. This static link allows access to the variables and parameters of the enclosing routines.
Example
Including hidden parameters (highlighted), the physical parameter order that appears in the preceding program as p(actual1,actual2,actual3,100) is: Table 7-6 Title not available (Routine Parameters )
The EXTERNAL SPL VARIABLE directive causes the compiler to pass a hidden parameter that specifies the presence of parameters. The hidden parameter is a 32 bit integer with the mask right justified as required by SPL/V. Example
Including hidden parameters (highlighted), the physical parameter order that appears in the preceding program as ext_spl(1,,i) is: Table 7-7 Title not available (EXTERNAL SPL VARIABLE )
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|||||||||||||||