next up previous contents index
Next: Generic element type Up: Basic translation Previous: Translating null   Contents   Index


Support for generic library methods

The HPJava language itself doesn't currently provide an integrated mechanism for dealing with multiarrays of unspecified rank. In principle the language could be extended to provide support for such arrays. The set of operations on the envisaged abstract multiarrays would be limited: one would not be able to create an instance of an abstract multiarray directly, and no normal subscripting operations would be allowed on an expression of this type. However the standard inquiries on multiarrays would be available. Through the kind of low-level programming described in chapter 7 it would be possible to directly manipulate abstract multiarrays within the HPJava language.

A proposed syntax for abstract multiarray type signatures has the form:

\begin{displaymath}
T \verb$  ...

where $T$ is any Java type other than an array type, and the term $\mbox{\it bras}$ is a string of zero or more bracket pairs, []. This signature represents the abstract multiarray type of a multiarray whose elements have Java type

\begin{displaymath}
T \verb$ $ \mbox{\it bras}
\end{displaymath}

In general it would probably be allowed to declare variables of abstract multiarray type; references could be passed to and returned from methods and constructors; there would be a widening conversion from a concrete multiarray type to an abstract multiarray type (provided there was a widening conversion between the respective component types). It should be possible to test concrete types of referenced multiarrays with the instanceof operator, and to cast expressions of abstract multiarray type back to concrete multarray types. Equality tests comparing an abstract multiarray reference to another, or to a concrete multiarray reference, may be provided, and interconvertible null references might be supported.

This level of support requires fairly extensive changes to the translation rules given in this appendix. For now the HPJava translator supports these abstract multiarray types in a much more restrictive way. There is no special syntax within the HPJava language, but it is possible for externally defined methods and constructors to have parameters of abstract multiarray type. Here ``externally defined'' presumably means ``implemented in standard Java'' (following HPJava-compliant calling conventions). This extension requires minor changes to the HPJava type checker, and only one change to the translation scheme: in the definition of the macro TRANS_ARG in section A.4.15, if $e$ is a multiarray expression of rank $R$, and the corresponding formal parameter of the method or constructor is an abstract multiarray, thenA.8

\begin{displaymath}
\begin{minipage}[t]{\linewidth}\begin{tabbing}
$\mbox{\it TR...
...{\mbox{\small dat}}\left[{e}\right]$\end{tabbing}\end{minipage}\end{displaymath}

The Java implementation should accept an array of ArrayDim objects for the multiarray.



Subsections
next up previous contents index
Next: Generic element type Up: Basic translation Previous: Translating null   Contents   Index
Bryan Carpenter 2003-04-15