How assignments are performed
Element assignments
Element assignments are performed as follows:
- First to be evaluated are subscripts, POSITION attribute expressions,
locator qualifications of the target variables, and the second and
third arguments of SUBSTR pseudovariable references.
- The expression on the right-hand side is then evaluated.
- For each target variable (in left to right order), the expression
is converted to the characteristics of the target variable according
to the rules for data conversion. The converted value is then assigned
to the target variable.
Aggregate assignments
Aggregate
assignments (array and structure assignments) are expanded into
a series of element assignments as follows:
- The label prefix of the original statement is applied to a null
statement preceding the other generated statements.
- Array and structure assignments, when there are more than one,
are done iteratively.
- Any assignment statement can be generated by a previous array
or structure assignment. The first target variable in an aggregate
assignment is known as the master variable. (It can also be the
first argument of a pseudovariable). If the master variable is an
array, an array expansion is performed; otherwise, a structure expansion
is performed.
- If an aggregate assignment meets a certain set of conditions,
it can be done as a whole instead of being expanded into a series
of element assignments. Two conditions are if the arrays are not
interleaved, or if the structures are contiguous and have the same
format.
In array assignments, all array operands
must have the same number of dimensions and identical bounds. The
array assignment is expanded into a loop as follows:
do J1 = lbound(Master-variable,1) to
hbound(Master-variable,1);
do J2 = lbound(Master-variable,2) to
hbound(Master-variable,2);
·
·
·
do Jn = lbound(Master-variable,N) to
hbound(Master-variable,N);
generated assignment statement
end;
In this expansion, n is the number of dimensions of the master variable that are
to participate in the assignment. In the generated assignment statement,
all array operands are fully subscripted, using (from left to right)
the dummy variables j1 to jn. If an array operand appears with no subscripts, it has only
the subscripts j1 to jn. If cross-section notation is used, the asterisks are replaced
by j1 to jn. If the original assignment statement has a condition prefix,
the generated assignment statement is given this condition prefix.
If the generated assignment statement is a structure assignment,
it is expanded as described next.
In structure assignments where the BY NAME option is not specified:
- None of the operands can be arrays, although they can be structures
that contain arrays.
- All of the structure operands must have the same number, k,
of immediately contained items.
-
The assignment statement is replaced by k generated
assignment statements.
- The ith generated assignment statement is derived from the original assignment
statement by replacing each structure operand by its ith contained item; such generated assignment statements can
require further expansion.
- All generated assignment statements are given the condition
prefix of the original statement.
In structure assignments where the BY NAME option is given, the structure assignment
is expanded according to the steps below, which can generate further array
and structure assignments. None of the operands can be arrays.
- The first item immediately contained in the master variable
is considered.
- If each structure operand and target variable has an immediately
contained item with the same name, an assignment statement is generated
as follows:
- The statement is derived by replacing each structure operand
and target variable with its immediately contained item that has
this name. If any structure contains no such name, no statement
is generated.
- If the generated assignment is a structure or array-of-structures
assignment, BY NAME is appended.
- All generated assignment statements are given the condition
prefix of the original assignment statement.
- A target structure must not contain unions.
- Step 2 is repeated for each of the items immediately contained
in the master variable. The assignments are generated in the order
of the items contained in the master variable.
|
This information center is powered by Eclipse technology. (http://www.eclipse.org)