1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
|
-- CC3601A.ADA
-- Grant of Unlimited Rights
--
-- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
-- F08630-91-C-0015, and DCA100-97-D-0025, the U.S. Government obtained
-- unlimited rights in the software and documentation contained herein.
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
-- this public release, the Government intends to confer upon all
-- recipients unlimited rights equal to those held by the Government.
-- These rights include rights to use, duplicate, release or disclose the
-- released technical data and computer software in whole or in part, in
-- any manner and for any purpose whatsoever, and to have or permit others
-- to do so.
--
-- DISCLAIMER
--
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
-- PARTICULAR PURPOSE OF SAID MATERIAL.
--*
-- CHECK THAT PREDEFINED OPERATORS MAY BE PASSED AS ACTUAL
-- GENERIC SUBPROGRAM PARAMETERS (CHECKS FOR "=" AND "/=" ARE IN
-- CC3601C).
-- R.WILLIAMS 10/9/86
-- JRL 11/15/95 Added unknown discriminant part to all formal
-- private types.
WITH REPORT; USE REPORT;
PROCEDURE CC3601A IS
GENERIC
TYPE T (<>) IS PRIVATE;
V, V1 : T;
KIND : STRING;
WITH FUNCTION F1 (X : IN T) RETURN T;
PACKAGE GP1 IS
R : BOOLEAN := F1 (V) = V1;
END GP1;
PACKAGE BODY GP1 IS
BEGIN
IF NOT (IDENT_BOOL(R)) THEN
FAILED ( "INCORRECT VALUE FOR UNARY OP - " & KIND);
END IF;
END GP1;
GENERIC
TYPE T (<>) IS PRIVATE;
V, V1, V2 : IN T;
KIND : STRING;
WITH FUNCTION F1 (P1 : IN T; P2 : IN T) RETURN T;
PACKAGE GP2 IS
R : BOOLEAN := V /= F1 (V1, V2);
END GP2;
PACKAGE BODY GP2 IS
BEGIN
IF IDENT_BOOL (R) THEN
FAILED ( "INCORRECT VALUE FOR BINARY OP - " & KIND);
END IF;
END GP2;
GENERIC
TYPE T1 (<>) IS PRIVATE;
TYPE T2 (<>) IS PRIVATE;
V1 : T1;
V2 : T2;
KIND : STRING;
WITH FUNCTION F1 (X : IN T1) RETURN T2;
PACKAGE GP3 IS
R : BOOLEAN := F1 (V1) = V2;
END GP3;
PACKAGE BODY GP3 IS
BEGIN
IF NOT (IDENT_BOOL(R)) THEN
FAILED ( "INCORRECT VALUE FOR OP - " & KIND);
END IF;
END GP3;
BEGIN
TEST ( "CC3601A", "CHECK THAT PREDEFINED OPERATORS MAY BE " &
"PASSED AS ACTUAL GENERIC SUBPROGRAM " &
"PARAMETERS" );
BEGIN -- CHECKS WITH RELATIONAL OPERATORS AND LOGICAL OPERATORS AS
-- ACTUAL PARAMETERS.
FOR I1 IN BOOLEAN LOOP
FOR I2 IN BOOLEAN LOOP
COMMENT ( "B1 = " & BOOLEAN'IMAGE (I1) & " AND " &
"B2 = " & BOOLEAN'IMAGE (I2) );
DECLARE
B1 : BOOLEAN := IDENT_BOOL (I1);
B2 : BOOLEAN := IDENT_BOOL (I2);
PACKAGE P1 IS
NEW GP1 (BOOLEAN, NOT B2, B2,
"""NOT"" - 1", "NOT");
PACKAGE P2 IS
NEW GP2 (BOOLEAN, B1 OR B2, B1, B2,
"OR", "OR");
PACKAGE P3 IS
NEW GP2 (BOOLEAN, B1 AND B2, B2, B1,
"AND", "AND");
PACKAGE P4 IS
NEW GP2 (BOOLEAN, B1 /= B2, B1, B2,
"XOR", "XOR");
PACKAGE P5 IS
NEW GP2 (BOOLEAN, B1 < B2, B1, B2,
"<", "<");
PACKAGE P6 IS
NEW GP2 (BOOLEAN, B1 <= B2, B1, B2,
"<=", "<=");
PACKAGE P7 IS
NEW GP2 (BOOLEAN, B1 > B2, B1, B2,
">", ">");
PACKAGE P8 IS
NEW GP2 (BOOLEAN, B1 >= B2, B1, B2,
">=", ">=");
TYPE AB IS ARRAY (BOOLEAN RANGE <> )
OF BOOLEAN;
AB1 : AB (BOOLEAN) := (B1, B2);
AB2 : AB (BOOLEAN) := (B2, B1);
T : AB (B1 .. B2) := (B1 .. B2 => TRUE);
F : AB (B1 .. B2) := (B1 .. B2 => FALSE);
VB1 : AB (B1 .. B1) := (B1 => B2);
VB2 : AB (B2 .. B2) := (B2 => B1);
PACKAGE P9 IS
NEW GP1 (AB, AB1, NOT AB1,
"""NOT"" - 2", "NOT");
PACKAGE P10 IS
NEW GP1 (AB, T, F,
"""NOT"" - 3", "NOT");
PACKAGE P11 IS
NEW GP1 (AB, VB2, (B2 => NOT B1),
"""NOT"" - 4", "NOT");
PACKAGE P12 IS
NEW GP2 (AB, AB1 AND AB2, AB1, AB2,
"AND", "AND");
BEGIN
NULL;
END;
END LOOP;
END LOOP;
END;
DECLARE -- CHECKS WITH ADDING AND MULTIPLYING OPERATORS, "**",
-- AND "ABS".
PACKAGE P1 IS NEW GP1 (INTEGER, -4, -4, """+"" - 1", "+");
PACKAGE P2 IS NEW GP1 (FLOAT, 4.0, 4.0, """+"" - 2", "+");
PACKAGE P3 IS NEW GP1 (DURATION, -4.0, -4.0, """+"" - 3",
"+");
PACKAGE P4 IS NEW GP1 (INTEGER, -4, 4, """-"" - 1", "-");
PACKAGE P5 IS NEW GP1 (FLOAT, 0.0, 0.0, """-"" - 2", "-");
PACKAGE P6 IS NEW GP1 (DURATION, 1.0, -1.0, """-"" - 3",
"-");
PACKAGE P7 IS NEW GP2 (INTEGER, 6, 1, 5, """+"" - 1", "+");
PACKAGE P8 IS NEW GP2 (FLOAT, 6.0, 1.0, 5.0, """+"" - 2",
"+");
PACKAGE P9 IS NEW GP2 (DURATION, 6.0, 1.0, 5.0, """+"" - 3",
"+");
PACKAGE P10 IS NEW GP2 (INTEGER, 1, 6, 5, """-"" - 1",
"-" );
PACKAGE P11 IS NEW GP2 (DURATION, 11.0, 6.0,-5.0,
"""-"" - 2", "-");
PACKAGE P12 IS NEW GP2 (FLOAT, 1.0, 6.0, 5.0, """-"" - 3",
"-");
SUBTYPE SUBINT IS INTEGER RANGE 0 .. 2;
TYPE STR IS ARRAY (SUBINT RANGE <>) OF CHARACTER;
VSTR : STR (0 .. 1) := "AB";
PACKAGE P13 IS NEW GP2 (STR, VSTR (0 .. 0) &
VSTR (1 .. 1),
VSTR (0 .. 0),
VSTR (1 .. 1), """&"" - 1", "&");
PACKAGE P14 IS NEW GP2 (STR, VSTR (1 .. 1) &
VSTR (0 .. 0),
VSTR (1 .. 1),
VSTR (0 .. 0), """&"" - 2", "&");
PACKAGE P15 IS NEW GP2 (INTEGER, 0, -1, 0, """*"" - 1", "*");
PACKAGE P16 IS NEW GP2 (FLOAT, 6.0, 3.0, 2.0, """*"" - 2",
"*");
PACKAGE P17 IS NEW GP2 (INTEGER, 0, 0, 6, """/"" - 1", "/");
PACKAGE P18 IS NEW GP2 (FLOAT, 3.0, 6.0, 2.0, """/"" - 2",
"/");
PACKAGE P19 IS NEW GP2 (INTEGER, -1, -11, 5, "REM", "REM");
PACKAGE P20 IS NEW GP2 (INTEGER, 4, -11, 5, "MOD", "MOD");
PACKAGE P21 IS NEW GP1 (INTEGER, 5, 5, """ABS"" - 1", "ABS");
PACKAGE P22 IS NEW GP1 (FLOAT, -5.0, 5.0, """ABS"" - 2",
"ABS");
PACKAGE P23 IS NEW GP1 (DURATION, 0.0, 0.0, """ABS"" - 3",
"ABS");
PACKAGE P24 IS NEW GP2 (INTEGER, 9, 3, 2, """**"" - 1",
"**");
PACKAGE P25 IS NEW GP2 (INTEGER, 1, 5, 0, """**"" - 2",
"**");
BEGIN
NULL;
END;
DECLARE -- CHECKS WITH ATTRIBUTES.
TYPE WEEKDAY IS (MON, TUES, WED, THUR, FRI);
PACKAGE P1 IS NEW GP1 (WEEKDAY, TUES, WED, "WEEKDAY'SUCC",
WEEKDAY'SUCC);
PACKAGE P2 IS NEW GP1 (WEEKDAY, TUES, MON, "WEEKDAY'PRED",
WEEKDAY'PRED);
PACKAGE P3 IS NEW GP3 (WEEKDAY, STRING, THUR, "THUR",
"WEEKDAY'IMAGE", WEEKDAY'IMAGE);
PACKAGE P4 IS NEW GP3 (STRING, WEEKDAY, "FRI", FRI,
"WEEKDAY'VALUE", WEEKDAY'VALUE);
BEGIN
NULL;
END;
RESULT;
END CC3601A;
|