** Next:** Field declarations
** Up:** Applying the simplify algorithm
** Previous:** Statement expressions
** Contents**
** Index**

###

Local variable declarations

Consider a local variable declaration of the form

where is an optional `final` modifier,
is a type, each term is a simple identifier, ,
followed by zero or more bracket pairs, `[]`

,
and each optional initializer clause is either empty,
or a term ```= `

'', where is an expression or an
array initializer. We must have .
For each variable declarator

with a non-empty initializer, apply the *simplify*
algorithm to , yielding results
and .
If is a multiarray type
we unconditionally break the declaration into a series of transformed,
single-variable declarations, :

where the form of will be described below.
If is *not* a multiarray type,
and all
are empty, the whole declaration
is unchanged in the transformed code.

In any other case,
suppose is the first variable initializer for which
is not empty. We will take the transformed
declaration to be:

with the defined as follows.
If
is empty and is not a composite expression,
then is just:

Otherwise is:

Here, if is not an array initializer, is just equal to .
If is an array initializer, is the array creation expression:

where is the array type of .
If is composite expression ,
one may anticipate this transformation, and arrange to have the *simplify* algorithm treat as if it was originally on the right-hand
side of a top-level assignment. This will avoid the introduction of an
unnecessary temporary.

The case of a local variable declaration appearing in the
initialization section of a `for`-loop header may need some special
treatment--see page .

** Next:** Field declarations
** Up:** Applying the simplify algorithm
** Previous:** Statement expressions
** Contents**
** Index**
Bryan Carpenter
2003-04-15