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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [ada/] [acats/] [tests/] [c3/] [c3a0003.a] - Blame information for rev 720

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 720 jeremybenn
-- C3A0003.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 a function in a generic instance can be called using
28
--      an access-to-subprogram value.
29
--
30
-- TEST DESCRIPTION:
31
--      Declare a numeric type in the visible part of a generic package.
32
--      Declare an access to function type.  Declare three different sine
33
--      functions that can be referred to by the access to function type.
34
--
35
--      In the main program, instantiate the generic.  Call each function
36
--      indirectly by dereferencing the access value.
37
--
38
--
39
-- CHANGE HISTORY:
40
--      06 Dec 94   SAIC    ACVC 2.0
41
--
42
--!
43
 
44
generic
45
   type Real_Num is digits <>;
46
 
47
package C3A0003_0 is
48
 
49
   TC_Call_Tag : Natural := 0;
50
 
51
   -- Type accesses to any sine function
52
   type Sine_Function_Ptr is access function
53
      (Angle : in Real_Num) return Real_Num;
54
 
55
   function Sine_Calc_Fast  (Angle : in Real_Num) return Real_Num;
56
 
57
   function Sine_Calc_Acc   (Angle : in Real_Num) return Real_Num;
58
 
59
   function Sine_Calc_Table (Angle : in Real_Num) return Real_Num;
60
 
61
end C3A0003_0;
62
 
63
 
64
-----------------------------------------------------------------------------
65
 
66
 
67
package body C3A0003_0 is
68
 
69
   function Sine_Calc_Fast (Angle : in Real_Num) return Real_Num is
70
      Sine_Num : Real_Num := 1.0;
71
   begin
72
      TC_Call_Tag := 1;
73
      return Sine_Num;
74
   end Sine_Calc_Fast;
75
 
76
 
77
   function Sine_Calc_Acc (Angle : in Real_Num) return Real_Num is
78
      Sine_Num : Real_Num := 0.0;
79
   begin
80
      TC_Call_Tag := 2;
81
      return Sine_Num;
82
   end Sine_Calc_Acc;
83
 
84
 
85
   function Sine_Calc_Table (Angle : in Real_Num) return Real_Num is
86
      Sine_Num : Real_Num := -1.0;
87
   begin
88
      TC_Call_Tag := 3;
89
      return Sine_Num;
90
   end Sine_Calc_Table;
91
 
92
end C3A0003_0;
93
 
94
-----------------------------------------------------------------------------
95
 
96
with Report;
97
with C3A0003_0;
98
 
99
procedure C3A0003 is
100
 
101
   type Real is digits 5;
102
 
103
   Subtype Trig_Float is Real range -1.0 .. 1.0;
104
 
105
   package Trig is new C3A0003_0 (Real_Num => Trig_Float);
106
 
107
   Sine_Access : Trig.Sine_Function_Ptr;
108
   X, Theta    : Trig_Float := 0.0;
109
 
110
begin
111
 
112
   Report.Test ("C3A0003", "Check that a function in a generic instance can "
113
                         & "be called using an access-to-subprogram value");
114
 
115
   Sine_Access := Trig.Sine_Calc_Fast'Access;
116
 
117
   -- Invoking Sine function designated by access value
118
   X := Sine_Access.all(Theta);
119
 
120
   If Trig.TC_Call_Tag /= 1 then
121
      Report.Failed ("Incorrect Sine_Calc_Fast result");
122
   end if;
123
 
124
   Sine_Access := Trig.Sine_Calc_Acc'Access;
125
 
126
   -- Invoking Sine function designated by access value
127
   X := Sine_Access.all(Theta);
128
 
129
   If Trig.TC_Call_Tag /= 2 then
130
      Report.Failed ("Incorrect Sine_Calc_Acc result");
131
   end if;
132
 
133
   Sine_Access := Trig.Sine_Calc_Table'Access;
134
 
135
   -- Invoking Sine function designated by access value
136
   X := Sine_Access.all(Theta);
137
 
138
   If Trig.TC_Call_Tag /= 3 then
139
      Report.Failed ("Incorrect Sine_Calc_Table result");
140
   end if;
141
 
142
   Report.Result;
143
 
144
end C3A0003;

powered by: WebSVN 2.1.0

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