OpenCores
URL https://opencores.org/ocsvn/openrisc_me/openrisc_me/trunk

Subversion Repositories openrisc_me

[/] [openrisc/] [trunk/] [gnu-src/] [gcc-4.5.1/] [gcc/] [testsuite/] [ada/] [acats/] [tests/] [c3/] [c3a0002.a] - Blame information for rev 294

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 294 jeremybenn
-- C3A0002.A
2
--
3
--                             Grant of Unlimited Rights
4
--
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
14
--     to do so.
15
--
16
--                                    DISCLAIMER
17
--
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.
24
--*
25
--
26
-- OBJECTIVE:
27
--      Check that access to subprogram type can be used to select and
28
--      invoke procedures with appropriate arguments dynamically.
29
--
30
-- TEST DESCRIPTION:
31
--      Declare an access to procedure type in a package specification.
32
--      Declare three different log procedures that can be referred to by
33
--      the access to procedure type.
34
--
35
--      In the main program, call each procedure indirectly by dereferencing
36
--      the access value.
37
--
38
--
39
-- CHANGE HISTORY:
40
--      06 Dec 94   SAIC    ACVC 2.0
41
--      05 APR 96   SAIC    RM reference change for 2.1
42
--
43
--
44
--!
45
 
46
 
47
package C3A0002_0 is
48
 
49
   TC_Call_Tag : Natural := 0;
50
 
51
   Return_Num          : Float   := 0.0;
52
 
53
   -- Type accesses to any log procedure
54
   type Log_Procedure_Ptr is access procedure
55
      (Angle : in Float);
56
 
57
   procedure Log_Calc_Fast  (Angle : in Float);
58
 
59
   procedure Log_Calc_Acc   (Angle : in Float);
60
 
61
   procedure Log_Calc_Table (Angle : in Float);
62
 
63
end C3A0002_0;
64
 
65
 
66
-----------------------------------------------------------------------------
67
 
68
 
69
package body C3A0002_0 is
70
 
71
   procedure Log_Calc_Fast (Angle : in Float) is
72
   begin
73
      TC_Call_Tag := 1;
74
      Return_Num := Angle;
75
   end Log_Calc_Fast;
76
 
77
 
78
   procedure Log_Calc_Acc (Angle : in Float) is
79
   begin
80
      TC_Call_Tag  := 2;
81
      Return_Num := Angle;
82
   end Log_Calc_Acc;
83
 
84
 
85
   procedure Log_Calc_Table (Angle : in Float) is
86
   begin
87
      TC_Call_Tag := 3;
88
      Return_Num := Angle;
89
   end Log_Calc_Table;
90
 
91
end C3A0002_0;
92
 
93
-----------------------------------------------------------------------------
94
 
95
with Report;
96
with C3A0002_0;
97
 
98
procedure C3A0002 is
99
 
100
   Log_Access : C3A0002_0.Log_Procedure_Ptr;
101
   Theta      : Float := 0.0;
102
 
103
begin
104
 
105
   Report.Test ("C3A0002", "Check that access to subprogram type can be "
106
                         & "used to select and invoke procedures with "
107
                         & "appropriate arguments dynamically" );
108
 
109
   Log_Access := C3A0002_0.Log_Calc_Fast'Access;
110
 
111
   -- Invoking Log procedure designated by access value
112
   Log_Access (Theta);
113
 
114
   If C3A0002_0.TC_Call_Tag /= 1 or C3A0002_0.Return_Num /= 0.0 then
115
      Report.Failed ("Incorrect Log_Calc_Fast result");
116
   end if;
117
 
118
   Theta := 1.0;
119
 
120
   Log_Access := C3A0002_0.Log_Calc_Acc'Access;
121
 
122
   -- Invoking Log procedure designated by access value
123
   Log_Access (Theta);
124
 
125
   If C3A0002_0.TC_Call_Tag /= 2 or C3A0002_0.Return_Num /= 1.0 then
126
      Report.Failed ("Incorrect Log_Calc_Acc result");
127
   end if;
128
 
129
   Theta := -1.0;
130
 
131
   Log_Access := C3A0002_0.Log_Calc_Table'Access;
132
 
133
   -- Invoking Log procedure designated by access value
134
   Log_Access (Theta);
135
 
136
   If C3A0002_0.TC_Call_Tag /= 3 or C3A0002_0.Return_Num /= -1.0 then
137
      Report.Failed ("Incorrect Log_Calc_Table result");
138
   end if;
139
 
140
   Report.Result;
141
 
142
end C3A0002;

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.