3 -- Grant of Unlimited Rights
5 -- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
6 -- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
7 -- unlimited rights in the software and documentation contained herein.
8 -- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
9 -- this public release, the Government intends to confer upon all
10 -- recipients unlimited rights equal to those held by the Government.
11 -- These rights include rights to use, duplicate, release or disclose the
12 -- released technical data and computer software in whole or in part, in
13 -- any manner and for any purpose whatsoever, and to have or permit others
18 -- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
19 -- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
20 -- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
21 -- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
22 -- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
23 -- PARTICULAR PURPOSE OF SAID MATERIAL.
27 -- Check that if a function call with a controlling result is itself
28 -- a controlling operand of an enclosing call on a dispatching operation,
29 -- then its controlling tag value is determined by the controlling tag
30 -- value of the enclosing call.
33 -- The test builds and traverses a "ragged" list; a linked list which
34 -- contains data elements of three different types (all rooted at
35 -- Level_0'Class). The traversal of this list checks the objective
36 -- by calling the dispatching operation "Check" using an item from the
37 -- list, and calling the function create; thus causing the controlling
38 -- result of the function to be determined by evaluating the value of
39 -- the other controlling parameter to the two-parameter Check.
43 -- 22 SEP 95 SAIC Initial version
44 -- 23 APR 96 SAIC Corrected commentary, differentiated integer.
48 ----------------------------------------------------------------- C392011_0
52 type Level_0
is tagged record
56 function Create
return Level_0
;
57 -- primitive dispatching function
59 procedure Check
( Left
, Right
: in Level_0
);
60 -- has controlling parameters
64 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
68 package body C392011_0
is
70 The_Character
: Character := 'A';
72 function Create
return Level_0
is
73 Created_Item_0
: constant Level_0
:= ( Ch_Item
=> The_Character
);
75 The_Character
:= Character'Succ(The_Character
);
76 TCTouch
.Touch
('A'); -- --- ---- ----- ---- --- -- --- ---- ----- ---- -- A
77 return Created_Item_0
;
80 procedure Check
( Left
, Right
: in Level_0
) is
82 TCTouch
.Touch
('B'); -- --- ---- ----- ---- --- -- --- ---- ----- ---- -- B
87 ----------------------------------------------------------------- C392011_1
92 type Level_1
is new C392011_0
.Level_0
with record
96 -- note that Create becomes abstract upon this derivation hence:
98 function Create
return Level_1
;
100 procedure Check
( Left
, Right
: in Level_1
);
104 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
107 package body C392011_1
is
109 Integer_1
: Integer := 0;
111 function Create
return Level_1
is
112 Created_Item_1
: constant Level_1
113 := ( C392011_0
.Create
with Int_Item
=> Integer_1
);
114 -- note call to ^--------------^ -- A
116 Integer_1
:= Integer'Succ(Integer_1
);
117 TCTouch
.Touch
('C'); -- --- ---- ----- ---- --- -- --- ---- ----- ---- -- C
118 return Created_Item_1
;
121 procedure Check
( Left
, Right
: in Level_1
) is
123 TCTouch
.Touch
('D'); -- --- ---- ----- ---- --- -- --- ---- ----- ---- -- D
128 ----------------------------------------------------------------- C392011_2
133 type Level_2
is new C392011_1
.Level_1
with record
134 Another_Int_Item
: Integer;
137 -- note that Create becomes abstract upon this derivation hence:
139 function Create
return Level_2
;
141 procedure Check
( Left
, Right
: in Level_2
);
145 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
148 package body C392011_2
is
150 Integer_2
: Integer := 100;
152 function Create
return Level_2
is
153 Created_Item_2
: constant Level_2
154 := ( C392011_1
.Create
with Another_Int_Item
=> Integer_2
);
155 -- note call to ^--------------^ -- AC
157 Integer_2
:= Integer'Succ(Integer_2
);
158 TCTouch
.Touch
('E'); -- --- ---- ----- ---- --- -- --- ---- ----- ---- -- E
159 return Created_Item_2
;
162 procedure Check
( Left
, Right
: in Level_2
) is
164 TCTouch
.Touch
('F'); -- --- ---- ----- ---- --- -- --- ---- ----- ---- -- F
169 ------------------------------------------------------- C392011_2.C392011_3
172 package C392011_2
.C392011_3
is
174 type Wide_Reference
is access all C392011_0
.Level_0
'Class;
178 type List_Pointer
is access Ragged_Element
;
180 type Ragged_Element
is record
181 Data
: Wide_Reference
;
185 procedure Build_List
;
187 procedure Traverse_List
;
189 end C392011_2
.C392011_3
;
191 -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
193 package body C392011_2
.C392011_3
is
195 The_List
: List_Pointer
;
197 procedure Build_List
is
200 -- build a list that looks like:
201 -- Level_2, Level_1, Level_2, Level_1, Level_0
203 -- the mechanism is to create each object, "pushing" the existing list
204 -- onto the end: cons( new_item, car, cdr )
207 new Ragged_Element
'( new C392011_0.Level_0'(C392011_0
.Create
), null );
211 new Ragged_Element
'( new C392011_1.Level_1'(C392011_1
.Create
), The_List
);
212 -- Level_1 -> Level_0 >> AC
215 new Ragged_Element
'( new C392011_2.Level_2'(C392011_2
.Create
), The_List
);
216 -- Level_2 -> Level_1 -> Level_0 >> ACE
219 new Ragged_Element
'( new C392011_1.Level_1'(C392011_1
.Create
), The_List
);
220 -- Level_1 -> Level_2 -> Level_1 -> Level_0 >> AC
223 new Ragged_Element
'( new C392011_2.Level_2'(C392011_2
.Create
), The_List
);
224 -- Level_2 -> Level_1 -> Level_2 -> Level_1 -> Level_0 >> ACE
228 procedure Traverse_List
is
230 Next_Item
: List_Pointer
:= The_List
;
232 -- Check that if a function call with a controlling result is itself
233 -- a controlling operand of an enclosing call on a dispatching operation,
234 -- then its controlling tag value is determined by the controlling tag
235 -- value of the enclosing call.
237 -- Level_2 -> Level_1 -> Level_2 -> Level_1 -> Level_0
241 while Next_Item
/= null loop -- here we go!
242 -- these calls better dispatch according to the value in the particular
243 -- list item; causing the call to create to dispatch accordingly.
244 -- why do it twice? To make sure order makes no difference
246 C392011_0
.Check
(Next_Item
.Data
.all, C392011_0
.Create
);
247 -- Create will touch first, then Check touches
249 C392011_0
.Check
(C392011_0
.Create
, Next_Item
.Data
.all);
251 -- Here's what's s'pos'd to 'appen:
252 -- Check( Lev_2, Create ) >> ACEF
253 -- Check( Create, Lev_2 ) >> ACEF
254 -- Check( Lev_1, Create ) >> ACD
255 -- Check( Create, Lev_1 ) >> ACD
256 -- Check( Lev_2, Create ) >> ACEF
257 -- Check( Create, Lev_2 ) >> ACEF
258 -- Check( Lev_1, Create ) >> ACD
259 -- Check( Create, Lev_1 ) >> ACD
260 -- Check( Lev_0, Create ) >> AB
261 -- Check( Create, Lev_0 ) >> AB
263 Next_Item
:= Next_Item
.Next
;
267 end C392011_2
.C392011_3
;
269 ------------------------------------------------------------------- C392011
273 with C392011_2
.C392011_3
;
277 begin -- Main test procedure.
279 Report
.Test
("C392011", "Check that if a function call with a " &
280 "controlling result is itself a controlling " &
281 "operand of an enclosing call on a dispatching " &
282 "operation, then its controlling tag value is " &
283 "determined by the controlling tag value of " &
284 "the enclosing call" );
286 C392011_2
.C392011_3
.Build_List
;
287 TCTouch
.Validate
( "A" & "AC" & "ACE" & "AC" & "ACE", "Build List" );
289 C392011_2
.C392011_3
.Traverse_List
;
290 TCTouch
.Validate
( "ACEFACEF" &