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 a child function of a library level instantiation
28 -- of a generic can be the instantiation of a child function of
29 -- the generic. Check that the child instance can use its parent's
30 -- declarations and operations, including a formal subprogram of the
34 -- Declare a generic package which simulates a real complex
35 -- abstraction. Declare a generic child function of this package
36 -- which builds a random complex number. Declare a second
37 -- package which defines a random complex number generator. This
38 -- package provides actual parameters for the generic parent package.
40 -- Instantiate the first generic package, then instantiate the child
41 -- generic function as a child unit of the first instance. In the main
42 -- program, check that the operations in both instances perform as
47 -- 06 Dec 94 SAIC ACVC 2.0
48 -- 16 Nov 95 SAIC Update and repair for ACVC 2.0.1
49 -- 19 Oct 96 SAIC ACVC 2.1: Added pragma Elaborate to context
50 -- clause of CA11013_3.
51 -- 27 Feb 97 CTA.PWB Added elaboration pragma at package CA11013_3
54 generic -- Complex number abstraction.
55 type Real_Type
is digits <>;
56 with function Random_Generator
(Seed
: Real_Type
) return Real_Type
;
60 -- Simulate a generic complex number support package. Complex numbers
61 -- are treated as coordinates in the Cartesian plane.
69 function Make
(Real
, Imag
: Real_Type
) -- Create a complex
70 return Complex_Type
; -- number.
72 procedure Components
(Complex_No
: in Complex_Type
;
73 Real_Part
, Imag_Part
: out Real_Type
);
77 --==================================================================--
79 package body CA11013_0
is
81 function Make
(Real
, Imag
: Real_Type
) return Complex_Type
is
85 -------------------------------------------------------------
86 procedure Components
(Complex_No
: in Complex_Type
;
87 Real_Part
, Imag_Part
: out Real_Type
) is
89 Real_Part
:= Complex_No
.Real
;
90 Imag_Part
:= Complex_No
.Imag
;
95 --==================================================================--
97 -- Generic child of complex number package. This child adds a layer of
98 -- functionality to the parent generic.
100 generic -- Random complex number operation.
102 function CA11013_0
.CA11013_1
(Seed
: Real_Type
) return Complex_Type
;
104 --==============================================--
106 function CA11013_0
.CA11013_1
(Seed
: Real_Type
) return Complex_Type
is
108 Random_Real_Part
: Real_Type
:= Random_Generator
(Seed
);
109 -- parent's formal subprogram
110 Random_Imag_Part
: Real_Type
111 := Random_Generator
(Random_Generator
(Seed
));
112 -- parent's formal subprogram
113 Random_Complex_No
: Complex_Type
;
115 begin -- CA11013_0.CA11013_1
117 Random_Complex_No
:= Make
(Random_Real_Part
, Random_Imag_Part
);
118 -- operation from parent
119 return (Random_Complex_No
);
121 end CA11013_0
.CA11013_1
;
123 --==================================================================--
127 -- To be used as actual parameters for random number generator
128 -- in the parent package.
130 type My_Float
is digits 6 range -10.0 .. 100.0;
132 function Random_Complex
(Seed
: My_float
) return My_Float
;
136 --==================================================================--
138 package body CA11013_2
is
140 -- Not a real random number generator.
141 function Random_Complex
(Seed
: My_float
) return My_Float
is
148 --==================================================================--
150 -- Declare instances of the generic complex packages for real type.
151 -- The instance of the child must itself be declared as a child of the
152 -- instance of the parent.
154 with CA11013_0
; -- Complex number.
155 with CA11013_2
; -- Random number generator.
156 pragma Elaborate
(CA11013_0
);
157 package CA11013_3
is new
158 CA11013_0
(Random_Generator
=> CA11013_2
.Random_Complex
,
159 Real_Type
=> CA11013_2
.My_Float
);
161 with CA11013_0
.CA11013_1
; -- Random complex number operation.
163 pragma Elaborate
(CA11013_3
);
164 function CA11013_3
.CA11013_4
is new CA11013_3
.CA11013_1
;
166 --==================================================================--
169 with CA11013_2
; -- Random number generator.
170 with CA11013_3
.CA11013_4
; -- Complex abstraction + Random complex
174 package My_Complex_Pkg
renames CA11013_3
;
175 use type CA11013_2
.My_Float
;
177 My_Complex
: My_Complex_Pkg
.Complex_Type
;
178 My_Literal
: CA11013_2
.My_Float
:= 3.0;
179 My_Real_Part
, My_Imag_Part
: CA11013_2
.My_Float
;
183 Report
.Test
("CA11013", "Check that child instance can use its parent's " &
184 "declarations and operations, including a formal " &
185 "subprogram of the parent");
187 My_Complex
:= CA11013_3
.CA11013_4
(My_Literal
);
188 -- Operation from the generic child function.
190 My_Complex_Pkg
.Components
(My_Complex
, My_Real_Part
, My_Imag_Part
);
191 -- Operation from the generic parent package.
193 if My_Real_Part
/= 6.0 -- Operation from the generic
194 or My_Imag_Part
/= 9.0 -- parent package.
196 Report
.Failed
("Incorrect results from complex operation");