next up previous contents
Next: Basic Translation Scheme Up: Compilation Strategies for HPJava Previous: Reachability and Definite (Un)assignment   Contents


Pre-translation

Currently, the HPJava translator has two phases, pre-translation and translation. Pre-translation reduces the source HPJava program to an equivalent HPJava program in a restricted form of the full HPJava language. The translation phase transforms the pre-translated program to a standard Java program. The main reason the current HPJava translator has two phases is to make a basic translation scheme easy and clear by transforming certain complex expressions involving multiarrays into simple expressions in the pre-translation phase. Thus, the restricted form generated by the pre-translator should be suitable for being processed in the translation phase. The basic translation schema in section 4.5 will be applied to the pre-translated HPJava programs. The rules for restricted forms are as follows;

Definition 1   Composite multiarray expressions are multiarray creation expressions, multiarray-valued method invocation expressions, multiarray section expressions, and multiarray restriction expressions.

Definition 2   Simple expressions are constant expressions, Local variable references, Fields referenced using the syntax of a simple identifier, $ f$, assuming the referenced field is not volatile, and the keyword this.

Rule 1   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.

Rule 2   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),
e) the range and group parameters of multiarray creation expressions,
f) the range expression in the header of overall and at constructs.

Figures 4.7 and 4.8 illustrate the process of pre-translation. The source code involves an array section. In this example pre-translation shifts two kinds of composite array expression--multiarray creation and array section--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 section, it has to introduce temporaries. 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.
Figure 4.7: Example source program before pre-translation.

$\displaystyle \begin{minipage}[t]{\linewidth}\small\begin{verbatim}
Procs2 p = ...
...] ;
foo(a [[0 : N / 2 - 1, 0 : N - 1 : 2]]) ;
}\end{verbatim}\end{minipage}
$

Figure 4.8: Example source program after pre-translation.

$\displaystyle \begin{minipage}[t]{\linewidth}\small\begin{verbatim}
Procs2 p = ...
... 2]] ;
foo(__$t0) ;
}\end{verbatim}<tex2html_comment_mark>770\end{minipage}
$


next up previous contents
Next: Basic Translation Scheme Up: Compilation Strategies for HPJava Previous: Reachability and Definite (Un)assignment   Contents
Bryan Carpenter 2004-06-09