comp.lang.ada
 help / color / mirror / Atom feed
From: "Martin Dowie" <martin.dowie@nospam.baesystems.com>
Subject: Re: Data Elaboration
Date: Fri, 22 Jun 2001 08:23:45 +0100
Date: 2001-06-22T08:23:45+01:00	[thread overview]
Message-ID: <3b32efb0$1@pull.gecm.com> (raw)
In-Reply-To: 3B32DFEB.1786FEE5@CCI.Sema.de

Ok then, here's part 2 of the question! Given that they
will be elaborated in order (I was looking at section 3.3.1
not 3.11 :-(. If I change that to -

  with My_Allocator;

  package Blah is

     Bool1 : Boolean;  -- always elaborates first
    pragma Import (Ada, Bool1);
    pragma Volatile (Bool1);
    for Bool1'Address use My_Allocator (Bool1'Size);

    Bool2 : Boolean;  -- always elaborates second
    pragma Import (Ada, Bool2);
    pragma Volatile (Bool2);
    for Bool2'Address use My_Allocator (Bool2'Size);

     Int1  : Integer;  -- always elaborates third
    pragma Import (Ada, Int1);
    pragma Volatile (Int1);
    for Int'Address use My_Allocator (Int1'Size);

  end Blah;

where My_Allocator assigns memory space from a particular
start address, my objects will always elaborate to the
same locations, yes? (My_Allocator containing a protect
object to ensure sequential calculation of the addresses).

Vincent Smeets <Vincent.Smeets@CCI.Sema.de> wrote in message
news:3B32DFEB.1786FEE5@CCI.Sema.de...
> Jeffrey Carter wrote:
> >
> > Martin Dowie wrote:
> > >
> > > IF I have a package containing data object declarations, is
> > > it specified with the RM that they will be elaborated in
> > > the same order every time? e.g.
> > >
> > > package Blah is
> > >
> > >    Bool1 : Boolean;  -- always elaborates first
> > >
> > >    Bool2 : Boolean;  -- always elaborates second
> > >
> > >    Int1  : Integer;  -- always elaborates third
> > >
> > > end Blah;
> >
> > Yes.
> >
> > ARM 3.11(7) says "The elaboration of a declarative_part consists of the
> > elaboration of the declarative_items, if any, in the order in which they
> > are given in the declarative_part."
>
> The answer is correct but I want to extend it with my practical view.
>
> The above declartions require no special processing. The only thing that
> has to be done is to reserve space in memory. This can be done by
> extending the non initialize data segment or (in case of local
> declarations) by changing the stack pointer. So you see that the
> elaboration of these three variables can be done with one instruction
> (all three at the same time).
>
> An other case are variables initialized by constants. See the following
> declarations:
> Bool1 : Boolean := True;
> Bool2 : Boolean := False;
> Here (in case of global variables), room is allocated in the initialized
> data segment which is initialized at startup of the program by copying
> the values from the Object file to memory. In case of local variables,
> the room is allocated at the stack and initialized. The compiler can
> optimize the elaboration by copying more than one values to more than
> one variables. (It can copy 8 bytes to the memory consiting of Bool1 and
> Bool2).
>
> Consider the case of initialized by Functions/variables. See the
> following declarations:
> Bool1 : Boolean := Pkg2.Func1;
> Bool2 : Boolean := Pkg2.Bool;
> Here the elaboration has to be done in order. The compiler can not know
> if the function Pkg2.Func1 will cange the value of Pkg2.Bool1.
>
>
>
> -- Vincent Smeets                    Competence Center Informatik GmbH
> -- Tel. : +49-5931-805461            Postfach 1225
> -- Fax  : +49-5931-805175            49702 Meppen, Germany
> -- mailto:Vincent.Smeets@CCI.Sema.de http://www.CCI.de/
> -- PGP fingerprint: E2437E38AAA9CA7D A31E7D751F1B6454 8AED7B76





  reply	other threads:[~2001-06-22  7:23 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-06-21 16:22 Data Elaboration Martin Dowie
2001-06-21 22:12 ` Jeffrey Carter
2001-06-22  6:04   ` Vincent Smeets
2001-06-22  7:23     ` Martin Dowie [this message]
2001-06-22  9:29       ` Vincent Smeets
2001-06-22 10:21         ` Martin Dowie
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox