forked from Keith-S-Thompson/dhrystone
-
Notifications
You must be signed in to change notification settings - Fork 0
/
d_pack_2.b
159 lines (149 loc) · 4.91 KB
/
d_pack_2.b
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
------------------------------------------------------------------------
--
-- "DHRYSTONE" Benchmark Program
-- -----------------------------
--
-- Version: Ada, Version 2.1
--
-- File: d_pack_2.b (part 5 of 6)
--
-- Date: August 17, 1988
--
-- Author: Reinhold P. Weicker
--
------------------------------------------------------------------------
with Global_Def, Pack_1;
use Global_Def;
package body Pack_2 is
-------------------
function Func_3 (Enum_Par_In: in Enumeration) return boolean;
-- forward declaration
procedure Proc_6 (Enum_Par_In: in Enumeration;
Enum_Par_Out: out Enumeration)
is -- executed once
-- Enum_Par_In = Ident_3, Enum_Par_Out becomes Ident_2
begin
Enum_Par_Out := Enum_Par_In;
if not Func_3 (Enum_Par_In)
then -- not executed
Enum_Par_Out := Ident_4;
end if;
case Enum_Par_In is
when Ident_1 => Enum_Par_Out := Ident_1;
when Ident_2 => if Pack_1.Int_Glob > 100
then Enum_Par_Out := Ident_1;
else Enum_Par_Out := Ident_4;
end if;
when Ident_3 => Enum_Par_Out := Ident_2; -- executed
when Ident_4 => null;
when Ident_5 => Enum_Par_Out := Ident_3;
end case;
end Proc_6;
procedure Proc_7 (Int_Par_In_1,
Int_Par_In_2: in One_To_Fifty;
Int_Par_Out: out One_To_Fifty)
is -- executed three times
-- first call: Int_Par_In_1 = 2, Int_Par_In_2 = 3,
-- Int_Par_Out becomes 7
-- second call: Int_Par_In_1 = 6, Int_Par_In_2 = 10,
-- Int_Par_Out becomes 18
-- third call: Int_Par_In_1 = 10, Int_Par_In_2 = 5,
-- Int_Par_Out becomes 17
Int_Loc: One_To_Fifty;
begin
Int_Loc := Int_Par_In_1 + 2;
Int_Par_Out := Int_Par_In_2 + Int_Loc;
end Proc_7;
procedure Proc_8 (Array_Par_In_Out_1: in out Array_1_Dim_Integer;
Array_Par_In_Out_2: in out Array_2_Dim_Integer;
Int_Par_In_1,
Int_Par_In_2: in integer)
is -- executed once
-- Int_Par_In_1 = 3
-- Int_Par_In_2 = 7
Int_Loc: One_To_Fifty;
begin
Int_Loc := Int_Par_In_1 + 5;
Array_Par_In_Out_1 (Int_Loc) := Int_Par_In_2;
Array_Par_In_Out_1 (Int_Loc+1) :=
Array_Par_In_Out_1 (Int_Loc);
Array_Par_In_Out_1 (Int_Loc+30) := Int_Loc;
for Int_Index in Int_Loc .. Int_Loc+1 loop -- loop body executed twice
Array_Par_In_Out_2 (Int_Loc, Int_Index) := Int_Loc;
end loop;
Array_Par_In_Out_2 (Int_Loc, Int_Loc-1) :=
Array_Par_In_Out_2 (Int_Loc, Int_Loc-1) + 1;
Array_Par_In_Out_2 (Int_Loc+20, Int_Loc) :=
Array_Par_In_Out_1 (Int_Loc);
Pack_1.Int_Glob := 5;
end Proc_8;
function Func_1 (Char_Par_In_1,
Char_Par_In_2: in Capital_Letter)
return Enumeration
is -- executed three times, returns Ident_1 each time
-- first call: Char_Par_In_1 = 'H', Char_Par_In_2 = 'R'
-- second call: Char_Par_In_1 = 'A', Char_Par_In_2 = 'C'
-- third call: Char_Par_In_1 = 'B', Char_Par_In_2 = 'C'
Char_Loc_1, Char_Loc_2: Capital_Letter;
begin
Char_Loc_1 := Char_Par_In_1;
Char_Loc_2 := Char_Loc_1;
if Char_Loc_2 /= Char_Par_In_2
then -- executed
return Ident_1;
else -- not executed
Pack_1.Char_Glob_1 := Char_Loc_1;
return Ident_2;
end if;
end Func_1;
function Func_2 (String_Par_In_1,
String_Par_In_2: in String_30) return boolean
is -- executed once, returns false
-- String_Par_In_1 = "DHRYSTONE PROGRAM, 1'ST STRING"
-- String_Par_In_2 = "DHRYSTONE PROGRAM, 2'ND STRING"
Int_Loc: One_To_Thirty;
Char_Loc: Capital_Letter;
begin
Int_Loc := 2;
while Int_Loc <= 2 loop -- loop body executed once
if Func_1 (String_Par_In_1(Int_Loc),
String_Par_In_2(Int_Loc+1)) = Ident_1
then -- executed
Char_Loc := 'A';
Int_Loc := Int_Loc + 1;
end if;
end loop;
if Char_Loc >= 'W' and Char_Loc < 'Z'
then -- not executed
Int_Loc := 7;
end if;
if Char_Loc = 'R'
then -- not executed
return true;
else -- executed
if String_Par_In_1 = String_Par_In_2
-- if String_Par_In_1 > String_Par_In_2
-- not yet implemented
then -- not executed
Int_Loc := Int_Loc + 7;
Pack_1.Int_Glob := Int_Loc;
return true;
else -- executed
return false;
end if;
end if;
end Func_2;
function Func_3 (Enum_Par_In: in Enumeration) return boolean
is -- executed once, returns true
-- Enum_Par_In = Ident_3
Enum_Loc: Enumeration;
begin
Enum_Loc := Enum_Par_In;
if Enum_Loc = Ident_3
then -- executed
return true;
else -- not executed
return false;
end if;
end Func_3;
end Pack_2;