Next: Expression simplification
Up: Pretranslation
Previous: Pretranslation
Contents
Index
Restricted Form
So far as the HPJava translator is concerned, a program is in restricted form if it respects certain limits on the complexity of
expressions involving multiarrays. First we give two definitions:

Composite multiarray expressions are:
 a)
multiarray creation expressions,
 b)
multiarrayvalued method invocation expressions,
 c)
multiarray section expressions, and
 d)
multiarray restriction expressions.

Simple expressions are
 a)
Constant expressions.
 b)
Local variable references.
 c)
Fields referenced using the syntax of a simple identifier, ,
assuming the referenced field is not volatile.
The current HPJava translator also treats fields referenced through the syntax
this.
,
super.
, or
.
, where is a type name,
as being simple, assuming the referenced field is not volatile.
 d)
The keyword this.
Now the restrictions on expressions are:
 A composite multiarray expression may only appear as the
righthandside of a toplevel assignment (or, in the case of
multiarrayvalued method invocation, as a standalone
statement expression). Here, a
toplevel assignment is defined to be an
assignment expression appearing as a
statement expression in a program block. This specifically
excludes assignments appearing in forloop headers. Also note that a
variable declarator with an initializer is not an assignment
expression, so the restricted form does not allow composite
multiarray expressions to appear as initializers in declarations.
 All of the following must be simple expressions:
 a)
the target object in accesses to multiarrayvalued fields,
 b)
the boolean expression in a multiarrayvalued conditional expressions,
and
 c)
the array operand in arrayrestriction expression,
 d)
the array operand of multiarray inquiry operations (rng(),
grp(), etc)^{A.4},
 e)
the range and group parameters of multiarray creation expressions,
 f)
the range expression in the header of overall and at constructs.
In principle reducing a program to restricted form is a straightforward
matter of precomputing subexpressions that break the rules above,
and saving their values in temporary variables introduced by the
pretranslator. Of course the subexpressions of the original
expression are replaced by accesses to the temporaries.
Figures A.2 and A.3 illustrate
the process of expression simplification. The source program is a
slightly esoteric example involving array restriction, taken from section
4.8. In this example pretranslation shifts three
kinds of composite array expressionmultiarray creation,
array section and array restrictioninto toplevel assignments.
In the case of the array creation expressions it simply has to split
the array declarations with initializers to blank declarations plus
an assignment. In the case of the sections and restrictions, it has to
introduce temporaries.
Figure A.2:
Example source program prior to pretranslation.

Figure A.3:
Example source program after pretranslation.

Besides simplifying variables, the pretranslation phase also
breaks up multiarray declarations that declare several
variables, outputting a series of declarations of individual
multiarray variables. This slightly simplifies the work
of the translation phase.
Next: Expression simplification
Up: Pretranslation
Previous: Pretranslation
Contents
Index
Bryan Carpenter
20030415