next up previous contents index
Next: Methods that return multiarrays Up: Basic translation Previous: Translating variable declarations   Contents   Index


Translating method declarations

There are two cases to consider. The case where the result of the method is not a multiarray, and the case where the result is a multiarray. First we consider the case where the result is not a multiarray.

The general scheme is illustrated in Figure A.14. This scheme is modified in trivial ways if the method has a void result, or involves other modifiers (they are copied to the translated code).

The macro TRANS_PARAMS evaluates to a list of formal parameters. We will define it in terms the simpler macro TRANS_PARAM which operates on a single formal parameter declaration:

\begin{displaymath}
\begin{minipage}[t]{\linewidth}\begin{tabbing}
$\mbox{\it TR...
...(U_{N-1}\verb$ $v_{N-1}\right)$ \\
\end{tabbing}\end{minipage}\end{displaymath}

Now, if $U$ is not a multiarray type, we have

\begin{displaymath}
\begin{minipage}[t]{\linewidth}\begin{tabbing}
$\mbox{\it TR...
...$v\right) \equiv \quad U$\verb$ $$v$\end{tabbing}\end{minipage}\end{displaymath}

Otherwise, if $U$ has the form

\begin{displaymath}
T \verb$ [[$ \mbox{\it attr}_0 \verb$, $ \ldots \verb$, $ \m...
...it attr}_{R-1} \verb$]] $ \mbox{\it bras} \verb$ $ a \verb$ ;$
\end{displaymath}

(where as usual $T$ is a Java type and as usual each term $\mbox{\it attr}_r$ is a single hyphen, -, or a single asterisk, *, and the term $\mbox{\it bras}$ is a string of zero or more bracket pairs, []) then the macro TRANS_PARAM is defined by

\begin{displaymath}
\begin{minipage}[t]{\linewidth}\begin{tabbing}
$\mbox{\it TR...
...as}$\verb$ $$a'_{\mbox{\small dat}}$\end{tabbing}\end{minipage}\end{displaymath}

where $a'_{\mbox{\small bas}}$, $a'_0$, ..., $a'_{R-1}$, and $a'_{\mbox{\small dat}}$ are new formal parameter names that may be obtained from $a$ using the prescription given in Figure A.13 (for example--these are local names so the exact prescription is unimportant). The macro DIMENSION_TYPE is defined in section A.4.2. In other words, each multiarray parameter is split into $2 + R$ parameters.

If, for example, a class in the source program has a method:

\begin{displaymath}
\begin{minipage}[t]{\linewidth}\small\begin{verbatim}void foo(int [[-,-,*]] bar) {...}\end{verbatim}\end{minipage}\end{displaymath}

the translated class can be assumed to have the method:

\begin{displaymath}
\begin{minipage}[t]{\linewidth}\small\begin{verbatim}void...
...m bar__$2,
final APGGroup p) {...}\end{verbatim}\end{minipage}\end{displaymath}

The last parameter $p$ added by the translator will hold the value of the active process group (APG) in effect at the point of invocation of the method.

Figure A.15: Translation of declaration of method returning a multiarray.
SOURCE:

\begin{displaymath}
\begin{minipage}[t]{\linewidth}\begin{tabbing}
$T$\verb$ [[$...
...$) {$ \\
\verb$ $$S$ \\
\verb$}$
\end{tabbing}\end{minipage}\end{displaymath}

TRANSLATION:

\begin{displaymath}
\begin{minipage}[t]{\linewidth}\begin{tabbing}
$T$\verb$ [] ...
...ert{p}\right.\right]$ \\
\verb$}$
\end{tabbing}\end{minipage}\end{displaymath}

where:

\begin{displaymath}
\begin{array}{l}
\mbox{$T$ is a scalar Java type,} \\
\mbo...
...} and {\it TRANS\_PARAMS} are defined in the
text.}
\end{array}\end{displaymath}



Subsections
next up previous contents index
Next: Methods that return multiarrays Up: Basic translation Previous: Translating variable declarations   Contents   Index
Bryan Carpenter 2003-04-15