comp.lang.ada
 help / color / mirror / Atom feed
From: Vincent Smeets <Vincent.Smeets@CCI.Sema.de>
Subject: Re: Data Elaboration
Date: Fri, 22 Jun 2001 08:04:27 +0200
Date: 2001-06-22T08:04:27+02:00	[thread overview]
Message-ID: <3B32DFEB.1786FEE5@CCI.Sema.de> (raw)
In-Reply-To: 3B327146.C1B43717@boeing.com

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  6:04 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 [this message]
2001-06-22  7:23     ` Martin Dowie
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