Usenet.com

www.Usenet.com

Group Index

Comp Thread Archive from Usenet.com

<-- __Chronological__ --> <-- __Thread__ -->

Re: Compiling pointer arithmetic targeting JVM



> Is there any literature that explains how to mimic memory architecture in
> JVM so that we could compile pointer arithmetic inherent in languages like
> C and Pascal.  Thanks for any tips.

You may try converting a pointer to a "fat format" that includes the
base and the offset.  Then

   ptr2 - ptr1  == ptr2.ofs - ptr1.ofs

(it works only if the base is the same, but otherwise it is not valid
ANSI C)

   ptr1 < ptr2  == ptr1.ofs < ptr2.ofs

(likewise)

   ptr1 + delta  == (ptr1.base, ptr1.ofs + delta)
   *ptr  == ptr.base[ptr.ofs]

Array <-> pointer conversion goes on like this:

   array == (array, 0)
   &array[element] == (array, element)

You may experiment with boxing vs. keeping the two parts in separate
variables.

Hope this helps,

Paolo



<-- __Chronological__ --> <-- __Thread__ -->


Usenet.com



Please check out one of the premium Usenet Newsgroup Service Providers below for access to Usenet.