Next: Expression simplification
Up: Pre-translation
Previous: Pre-translation
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)
multiarray-valued 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
right-hand-side of a top-level assignment (or, in the case of
multiarray-valued method invocation, as a standalone
statement expression). Here, a
top-level assignment is defined to be an
assignment expression appearing as a
statement expression in a program block. This specifically
excludes assignments appearing in for-loop 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 multiarray-valued fields,
- b)
the boolean expression in a multiarray-valued conditional expressions,
and
- c)
the array operand in array-restriction 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
pre-translator. 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 pre-translation shifts three
kinds of composite array expression--multiarray creation,
array section and array restriction--into top-level 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 pre-translation.
|
Figure A.3:
Example source program after pre-translation.
|
Besides simplifying variables, the pre-translation 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: Pre-translation
Previous: Pre-translation
Contents
Index
Bryan Carpenter
2003-04-15