Mirror of the gdb-patches mailing list
 help / color / mirror / Atom feed
From: "Pierre Muller" <muller@ics.u-strasbg.fr>
To: "'Gaius Mulley'" <gaius@glam.ac.uk>
Cc: <gdb-patches@sources.redhat.com>, 	<gpc@gnu.de>
Subject: RE: [PATCH] Unbounded array support implemented (for Modula-2)
Date: Fri, 27 Jul 2007 13:28:00 -0000	[thread overview]
Message-ID: <003a01c7d050$7c071af0$741550d0$@u-strasbg.fr> (raw)
In-Reply-To: <87ejiu6nru.fsf@j228-gm.comp.glam.ac.uk>

> > Modula-2 is not the only language supporting unbounded arrays, I
> > would be interested in using the same kind of code for pascal
> > language support.
> 
> sure, I'm all for refactoring code..
> 
> >   Maybe a more general approach would be useful?
> 
> maybe - although I suspect the devil is in the detail.  Basically
> Modula-2 assumes that all unbounded arrays start at index 0 and the
> caller can be legally access all indices 0..HIGH(a).  GNU Modula-2
> implements unbounded arrays by creating a structure whose first field
> is a pointer to type, and the second structure is the HIGH value
> (unsigned int).  So the patches basically detect if the array
> declaration matches a GNU Modula-2 unbounded structure (testing field
> names and types and language).  If so then it maps any reference to
> a[i] onto a->_m2_contents[i] and HIGH(a) onto a->_m2_high.  How does
> GNU Pascal implement unbounded arrays?
  This is basically also the case for parameter unbounded arrays:
the valid indexes are from 0 to high(a) and high(a)
is passed as an additional hidden parameter,
called 
 highA (high in lower case followed by the uppercase name of the parameter)
for free pascal 
and
  open_array_length_0 (or _x for the X+1 open array parameter) for GNU
pascal.

  The open array type can be recongnized by the fact that the
lower bound is 0, while the higher bound is -1.

  Free pascal now also supports global open array variables
which are allocated by using SetLength function. They are
basically hidden pointers.
The high values is at offset -4 (or size of pointer more generally) relative
to 
the pointer address. I don't know if GPC supports this
syntax. Maybe someone from GPC team can answer this question.


Pierre Muller



  



  reply	other threads:[~2007-07-27 13:17 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-07-26  7:07 Gaius Mulley
2007-07-26  7:36 ` Markus Deuling
2007-07-27 12:26   ` Gaius Mulley
2007-07-27 20:22     ` Eli Zaretskii
2007-07-30  8:29       ` Gaius Mulley
2007-07-30 23:34         ` Jim Blandy
2007-07-31  3:01         ` Jim Blandy
2007-07-31 16:47           ` Gaius Mulley
2007-07-31 16:48             ` Jim Blandy
2007-08-01 14:01               ` Gaius Mulley
2007-07-31 19:18             ` Jim Blandy
2007-10-16 16:59               ` Gaius Mulley
2007-10-16 22:04                 ` Jim Blandy
2007-07-26 22:58 ` Pierre Muller
2007-07-27 13:17   ` Gaius Mulley
2007-07-27 13:28     ` Pierre Muller [this message]
2007-07-28  0:59   ` Jim Blandy
2007-07-30  6:29     ` Gaius Mulley

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='003a01c7d050$7c071af0$741550d0$@u-strasbg.fr' \
    --to=muller@ics.u-strasbg.fr \
    --cc=gaius@glam.ac.uk \
    --cc=gdb-patches@sources.redhat.com \
    --cc=gpc@gnu.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox