-- C640001.A
|
-- C640001.A
|
--
|
--
|
-- Grant of Unlimited Rights
|
-- Grant of Unlimited Rights
|
--
|
--
|
-- Under contracts F33600-87-D-0337, F33600-84-D-0280, MDA903-79-C-0687,
|
-- 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
|
-- 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 in the software and documentation contained herein.
|
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
|
-- Unlimited rights are defined in DFAR 252.227-7013(a)(19). By making
|
-- this public release, the Government intends to confer upon all
|
-- this public release, the Government intends to confer upon all
|
-- recipients unlimited rights equal to those held by the Government.
|
-- recipients unlimited rights equal to those held by the Government.
|
-- These rights include rights to use, duplicate, release or disclose the
|
-- These rights include rights to use, duplicate, release or disclose the
|
-- released technical data and computer software in whole or in part, in
|
-- 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
|
-- any manner and for any purpose whatsoever, and to have or permit others
|
-- to do so.
|
-- to do so.
|
--
|
--
|
-- DISCLAIMER
|
-- DISCLAIMER
|
--
|
--
|
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
|
-- ALL MATERIALS OR INFORMATION HEREIN RELEASED, MADE AVAILABLE OR
|
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
|
-- DISCLOSED ARE AS IS. THE GOVERNMENT MAKES NO EXPRESS OR IMPLIED
|
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
|
-- WARRANTY AS TO ANY MATTER WHATSOEVER, INCLUDING THE CONDITIONS OF THE
|
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
|
-- SOFTWARE, DOCUMENTATION OR OTHER INFORMATION RELEASED, MADE AVAILABLE
|
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
|
-- OR DISCLOSED, OR THE OWNERSHIP, MERCHANTABILITY, OR FITNESS FOR A
|
-- PARTICULAR PURPOSE OF SAID MATERIAL.
|
-- PARTICULAR PURPOSE OF SAID MATERIAL.
|
--*
|
--*
|
--
|
--
|
-- OBJECTIVE:
|
-- OBJECTIVE:
|
-- Check that the prefix of a subprogram call with an actual parameter
|
-- Check that the prefix of a subprogram call with an actual parameter
|
-- part may be an implicit dereference of an access-to-subprogram value.
|
-- part may be an implicit dereference of an access-to-subprogram value.
|
-- Check that, for an access-to-subprogram type whose designated profile
|
-- Check that, for an access-to-subprogram type whose designated profile
|
-- contains parameters of a tagged generic formal type, an access-to-
|
-- contains parameters of a tagged generic formal type, an access-to-
|
-- subprogram value may designate dispatching and non-dispatching
|
-- subprogram value may designate dispatching and non-dispatching
|
-- operations, and that dereferences of such a value call the appropriate
|
-- operations, and that dereferences of such a value call the appropriate
|
-- subprogram.
|
-- subprogram.
|
--
|
--
|
-- TEST DESCRIPTION:
|
-- TEST DESCRIPTION:
|
-- The test declares a tagged type (Table) with a dispatching operation
|
-- The test declares a tagged type (Table) with a dispatching operation
|
-- (Clear), as well as a derivative (Table2) which overrides that
|
-- (Clear), as well as a derivative (Table2) which overrides that
|
-- operation. A subprogram with the same name and profile as Clear is
|
-- operation. A subprogram with the same name and profile as Clear is
|
-- declared in a separate package -- it is therefore not a dispatching
|
-- declared in a separate package -- it is therefore not a dispatching
|
-- operation of Table. For the purposes of the test, each version of Clear
|
-- operation of Table. For the purposes of the test, each version of Clear
|
-- modifies the components of its parameter in a unique way.
|
-- modifies the components of its parameter in a unique way.
|
--
|
--
|
-- Additionally, an operation (Reset) of type Table is declared which
|
-- Additionally, an operation (Reset) of type Table is declared which
|
-- makes a re-dispatching call to Clear, i.e.,
|
-- makes a re-dispatching call to Clear, i.e.,
|
--
|
--
|
-- procedure Reset (A: in out Table) is
|
-- procedure Reset (A: in out Table) is
|
-- begin
|
-- begin
|
-- ...
|
-- ...
|
-- Clear (Table'Class(A)); -- Re-dispatch based on tag of actual.
|
-- Clear (Table'Class(A)); -- Re-dispatch based on tag of actual.
|
-- ...
|
-- ...
|
-- end Reset;
|
-- end Reset;
|
--
|
--
|
-- An access-to-subprogram type is declared within a generic package,
|
-- An access-to-subprogram type is declared within a generic package,
|
-- with a designated profile which declares a parameter of a generic
|
-- with a designated profile which declares a parameter of a generic
|
-- formal tagged private type.
|
-- formal tagged private type.
|
--
|
--
|
-- The generic is instantiated with type Table. The instance defines an
|
-- The generic is instantiated with type Table. The instance defines an
|
-- array of access-to-subprogram values (which represents a table of
|
-- array of access-to-subprogram values (which represents a table of
|
-- operations to be performed sequentially on a single operand).
|
-- operations to be performed sequentially on a single operand).
|
-- Access values designating the dispatching version of Clear, the
|
-- Access values designating the dispatching version of Clear, the
|
-- non-dispatching version of Clear, and Reset (which re-dispatches to
|
-- non-dispatching version of Clear, and Reset (which re-dispatches to
|
-- Clear) are placed in this array.
|
-- Clear) are placed in this array.
|
--
|
--
|
-- In the instance, each subprogram in the array is called by implicitly
|
-- In the instance, each subprogram in the array is called by implicitly
|
-- dereferencing the corresponding access value. For the dispatching and
|
-- dereferencing the corresponding access value. For the dispatching and
|
-- non-dispatching versions of Clear, the actual parameter passed is of
|
-- non-dispatching versions of Clear, the actual parameter passed is of
|
-- type Table. For Reset, the actual parameter passed is a view conversion
|
-- type Table. For Reset, the actual parameter passed is a view conversion
|
-- of an object of type Table2 to type Table, i.e., Table(Table2_Obj).
|
-- of an object of type Table2 to type Table, i.e., Table(Table2_Obj).
|
-- Since the tag of the operand never changes, the call to Clear within
|
-- Since the tag of the operand never changes, the call to Clear within
|
-- Reset should execute Table2's version of Clear.
|
-- Reset should execute Table2's version of Clear.
|
--
|
--
|
-- The main program verifies that the appropriate version of Clear is
|
-- The main program verifies that the appropriate version of Clear is
|
-- called in each case, by checking that the components of the actual are
|
-- called in each case, by checking that the components of the actual are
|
-- updated as expected.
|
-- updated as expected.
|
--
|
--
|
--
|
--
|
-- CHANGE HISTORY:
|
-- CHANGE HISTORY:
|
-- 06 Dec 94 SAIC ACVC 2.0
|
-- 06 Dec 94 SAIC ACVC 2.0
|
--
|
--
|
--!
|
--!
|
|
|
package C640001_0 is
|
package C640001_0 is
|
|
|
-- Data type artificial for testing purposes.
|
-- Data type artificial for testing purposes.
|
|
|
Row_Len : constant := 10;
|
Row_Len : constant := 10;
|
|
|
T : constant Boolean := True;
|
T : constant Boolean := True;
|
F : constant Boolean := False;
|
F : constant Boolean := False;
|
|
|
type Row_Type is array (1 .. Row_Len) of Boolean;
|
type Row_Type is array (1 .. Row_Len) of Boolean;
|
|
|
function Is_True (A : in Row_Type) return Boolean;
|
function Is_True (A : in Row_Type) return Boolean;
|
function Is_False (A : in Row_Type) return Boolean;
|
function Is_False (A : in Row_Type) return Boolean;
|
|
|
|
|
Init : constant Row_Type := (T, F, T, F, T, F, T, F, T, F);
|
Init : constant Row_Type := (T, F, T, F, T, F, T, F, T, F);
|
|
|
type Table is tagged record -- Tagged type.
|
type Table is tagged record -- Tagged type.
|
Row1 : Row_Type := Init;
|
Row1 : Row_Type := Init;
|
Row2 : Row_Type := Init;
|
Row2 : Row_Type := Init;
|
end record;
|
end record;
|
|
|
procedure Clear (A : in out Table); -- Dispatching operation.
|
procedure Clear (A : in out Table); -- Dispatching operation.
|
|
|
procedure Reset (A : in out Table); -- Re-dispatching operation.
|
procedure Reset (A : in out Table); -- Re-dispatching operation.
|
|
|
-- ...Other operations.
|
-- ...Other operations.
|
|
|
|
|
type Table2 is new Table with null record; -- Extension of Table (but
|
type Table2 is new Table with null record; -- Extension of Table (but
|
-- structurally identical).
|
-- structurally identical).
|
|
|
procedure Clear (A : in out Table2); -- Overrides parent's op.
|
procedure Clear (A : in out Table2); -- Overrides parent's op.
|
|
|
-- ...Other operations.
|
-- ...Other operations.
|
|
|
|
|
end C640001_0;
|
end C640001_0;
|
|
|
|
|
--===================================================================--
|
--===================================================================--
|
|
|
|
|
package body C640001_0 is
|
package body C640001_0 is
|
|
|
function Is_True (A : in Row_Type) return Boolean is
|
function Is_True (A : in Row_Type) return Boolean is
|
begin
|
begin
|
for I in A'Range loop
|
for I in A'Range loop
|
if A(I) /= True then -- Return true if all elements
|
if A(I) /= True then -- Return true if all elements
|
return False; -- of A are True.
|
return False; -- of A are True.
|
end if;
|
end if;
|
end loop;
|
end loop;
|
return True;
|
return True;
|
end Is_True;
|
end Is_True;
|
|
|
|
|
function Is_False (A : in Row_Type) return Boolean is
|
function Is_False (A : in Row_Type) return Boolean is
|
begin
|
begin
|
return A = Row_Type'(others => False); -- Return true if all elements
|
return A = Row_Type'(others => False); -- Return true if all elements
|
end Is_False; -- of A are False.
|
end Is_False; -- of A are False.
|
|
|
|
|
procedure Clear (A : in out Table) is
|
procedure Clear (A : in out Table) is
|
begin
|
begin
|
for I in Row_Type'Range loop -- This version of Clear sets
|
for I in Row_Type'Range loop -- This version of Clear sets
|
A.Row1(I) := False; -- the elements of Row1 only
|
A.Row1(I) := False; -- the elements of Row1 only
|
end loop; -- to False.
|
end loop; -- to False.
|
end Clear;
|
end Clear;
|
|
|
|
|
procedure Reset (A : in out Table) is
|
procedure Reset (A : in out Table) is
|
begin
|
begin
|
Clear (Table'Class(A)); -- Redispatch to appropriate
|
Clear (Table'Class(A)); -- Redispatch to appropriate
|
-- ... Other "reset" activities. -- version of Clear.
|
-- ... Other "reset" activities. -- version of Clear.
|
end Reset;
|
end Reset;
|
|
|
|
|
procedure Clear (A : in out Table2) is
|
procedure Clear (A : in out Table2) is
|
begin
|
begin
|
for I in Row_Type'Range loop -- This version of Clear sets
|
for I in Row_Type'Range loop -- This version of Clear sets
|
A.Row1(I) := True; -- the elements of Row1 only
|
A.Row1(I) := True; -- the elements of Row1 only
|
end loop; -- to True.
|
end loop; -- to True.
|
end Clear;
|
end Clear;
|
|
|
|
|
end C640001_0;
|
end C640001_0;
|
|
|
|
|
--===================================================================--
|
--===================================================================--
|
|
|
|
|
with C640001_0;
|
with C640001_0;
|
package C640001_1 is
|
package C640001_1 is
|
|
|
procedure Clear (T : in out C640001_0.Table); -- Non-dispatching operation.
|
procedure Clear (T : in out C640001_0.Table); -- Non-dispatching operation.
|
|
|
end C640001_1;
|
end C640001_1;
|
|
|
|
|
--===================================================================--
|
--===================================================================--
|
|
|
|
|
package body C640001_1 is
|
package body C640001_1 is
|
|
|
procedure Clear (T : in out C640001_0.Table) is
|
procedure Clear (T : in out C640001_0.Table) is
|
begin
|
begin
|
for I in C640001_0.Row_Type'Range loop -- This version of Clear sets
|
for I in C640001_0.Row_Type'Range loop -- This version of Clear sets
|
T.Row2(I) := True; -- the elements of Row2 only
|
T.Row2(I) := True; -- the elements of Row2 only
|
end loop; -- to True.
|
end loop; -- to True.
|
end Clear;
|
end Clear;
|
|
|
end C640001_1;
|
end C640001_1;
|
|
|
|
|
--===================================================================--
|
--===================================================================--
|
|
|
|
|
-- This unit represents a support package for table-driven processing of
|
-- This unit represents a support package for table-driven processing of
|
-- data objects. Process_Operand performs a set of operations are performed
|
-- data objects. Process_Operand performs a set of operations are performed
|
-- sequentially on a single operand. Note that parameters are provided to
|
-- sequentially on a single operand. Note that parameters are provided to
|
-- specify which subset of operations in the operations table are to be
|
-- specify which subset of operations in the operations table are to be
|
-- performed (ordinarily these might be omitted, but the test requires that
|
-- performed (ordinarily these might be omitted, but the test requires that
|
-- each operation be called individually for a single operand).
|
-- each operation be called individually for a single operand).
|
|
|
generic
|
generic
|
type Tag is tagged private;
|
type Tag is tagged private;
|
package C640001_2 is
|
package C640001_2 is
|
|
|
type Proc_Ptr is access procedure (P: in out Tag);
|
type Proc_Ptr is access procedure (P: in out Tag);
|
|
|
type Op_List is private;
|
type Op_List is private;
|
|
|
procedure Add_Op (Op : in Proc_Ptr; -- Add operation to
|
procedure Add_Op (Op : in Proc_Ptr; -- Add operation to
|
List : in out Op_List); -- to list of ops.
|
List : in out Op_List); -- to list of ops.
|
|
|
procedure Process_Operand (Operand : in out Tag; -- Execute a subset
|
procedure Process_Operand (Operand : in out Tag; -- Execute a subset
|
List : in Op_List; -- of a list of
|
List : in Op_List; -- of a list of
|
First_Op : in Positive; -- operations using
|
First_Op : in Positive; -- operations using
|
Last_Op : in Positive); -- a given operand.
|
Last_Op : in Positive); -- a given operand.
|
|
|
-- ...Other operations.
|
-- ...Other operations.
|
|
|
private
|
private
|
type Op_Array is array (1 .. 3) of Proc_Ptr;
|
type Op_Array is array (1 .. 3) of Proc_Ptr;
|
|
|
type Op_List is record
|
type Op_List is record
|
Top : Natural := 0;
|
Top : Natural := 0;
|
Ops : Op_Array;
|
Ops : Op_Array;
|
end record;
|
end record;
|
end C640001_2;
|
end C640001_2;
|
|
|
|
|
--===================================================================--
|
--===================================================================--
|
|
|
|
|
package body C640001_2 is
|
package body C640001_2 is
|
|
|
procedure Add_Op (Op : in Proc_Ptr;
|
procedure Add_Op (Op : in Proc_Ptr;
|
List : in out Op_List) is
|
List : in out Op_List) is
|
begin
|
begin
|
List.Top := List.Top + 1; -- Artificial; no Constraint_Error protection.
|
List.Top := List.Top + 1; -- Artificial; no Constraint_Error protection.
|
List.Ops(List.Top) := Op;
|
List.Ops(List.Top) := Op;
|
end Add_Op;
|
end Add_Op;
|
|
|
|
|
procedure Process_Operand (Operand : in out Tag;
|
procedure Process_Operand (Operand : in out Tag;
|
List : in Op_List;
|
List : in Op_List;
|
First_Op : in Positive;
|
First_Op : in Positive;
|
Last_Op : in Positive) is
|
Last_Op : in Positive) is
|
begin
|
begin
|
for I in First_Op .. Last_Op loop
|
for I in First_Op .. Last_Op loop
|
List.Ops(I)(Operand); -- Implicit dereference of an
|
List.Ops(I)(Operand); -- Implicit dereference of an
|
end loop; -- access-to-subprogram value.
|
end loop; -- access-to-subprogram value.
|
end Process_Operand;
|
end Process_Operand;
|
|
|
end C640001_2;
|
end C640001_2;
|
|
|
|
|
--===================================================================--
|
--===================================================================--
|
|
|
|
|
with C640001_0;
|
with C640001_0;
|
with C640001_1;
|
with C640001_1;
|
with C640001_2;
|
with C640001_2;
|
|
|
with Report;
|
with Report;
|
procedure C640001 is
|
procedure C640001 is
|
|
|
package Table_Support is new C640001_2 (C640001_0.Table);
|
package Table_Support is new C640001_2 (C640001_0.Table);
|
|
|
Sub_Ptr : Table_Support.Proc_Ptr;
|
Sub_Ptr : Table_Support.Proc_Ptr;
|
My_List : Table_Support.Op_List;
|
My_List : Table_Support.Op_List;
|
My_Table1 : C640001_0.Table; -- Initial values of both Row1 &
|
My_Table1 : C640001_0.Table; -- Initial values of both Row1 &
|
-- Row2 are (T,F,T,F,T,F,T,F,T,F).
|
-- Row2 are (T,F,T,F,T,F,T,F,T,F).
|
My_Table2 : C640001_0.Table2; -- Initial values of both Row1 &
|
My_Table2 : C640001_0.Table2; -- Initial values of both Row1 &
|
-- Row2 are (T,F,T,F,T,F,T,F,T,F).
|
-- Row2 are (T,F,T,F,T,F,T,F,T,F).
|
begin
|
begin
|
Report.Test ("C640001", "Check that, for an access-to-subprogram type " &
|
Report.Test ("C640001", "Check that, for an access-to-subprogram type " &
|
"whose designated profile contains parameters " &
|
"whose designated profile contains parameters " &
|
"of a tagged generic formal type, an access-" &
|
"of a tagged generic formal type, an access-" &
|
"to-subprogram value may designate dispatching " &
|
"to-subprogram value may designate dispatching " &
|
"and non-dispatching operations");
|
"and non-dispatching operations");
|
|
|
--
|
--
|
-- Add subprogram access values to list:
|
-- Add subprogram access values to list:
|
--
|
--
|
|
|
Sub_Ptr := C640001_0.Clear'Access; -- Designates dispatching op.
|
Sub_Ptr := C640001_0.Clear'Access; -- Designates dispatching op.
|
Table_Support.Add_Op (Sub_Ptr, My_List); -- (1st operation on My_List).
|
Table_Support.Add_Op (Sub_Ptr, My_List); -- (1st operation on My_List).
|
|
|
Sub_Ptr := C640001_1.Clear'Access; -- Designates non-dispatching op.
|
Sub_Ptr := C640001_1.Clear'Access; -- Designates non-dispatching op.
|
Table_Support.Add_Op (Sub_Ptr, My_List); -- (2nd operation on My_List).
|
Table_Support.Add_Op (Sub_Ptr, My_List); -- (2nd operation on My_List).
|
|
|
Sub_Ptr := C640001_0.Reset'Access; -- Designates re-dispatching op.
|
Sub_Ptr := C640001_0.Reset'Access; -- Designates re-dispatching op.
|
Table_Support.Add_Op (Sub_Ptr, My_List); -- (3rd operation on My_List).
|
Table_Support.Add_Op (Sub_Ptr, My_List); -- (3rd operation on My_List).
|
|
|
|
|
--
|
--
|
-- Call dispatching operation:
|
-- Call dispatching operation:
|
--
|
--
|
|
|
Table_Support.Process_Operand (My_Table1, My_List, 1, 1); -- Call 1st op.
|
Table_Support.Process_Operand (My_Table1, My_List, 1, 1); -- Call 1st op.
|
|
|
if not C640001_0.Is_False (My_Table1.Row1) then
|
if not C640001_0.Is_False (My_Table1.Row1) then
|
Report.Failed ("Wrong result after calling dispatching operation");
|
Report.Failed ("Wrong result after calling dispatching operation");
|
end if;
|
end if;
|
|
|
|
|
--
|
--
|
-- Call non-dispatching operation:
|
-- Call non-dispatching operation:
|
--
|
--
|
|
|
Table_Support.Process_Operand (My_Table1, My_List, 2, 2); -- Call 2nd op.
|
Table_Support.Process_Operand (My_Table1, My_List, 2, 2); -- Call 2nd op.
|
|
|
if not C640001_0.Is_True (My_Table1.Row2) then
|
if not C640001_0.Is_True (My_Table1.Row2) then
|
Report.Failed ("Wrong result after calling non-dispatching operation");
|
Report.Failed ("Wrong result after calling non-dispatching operation");
|
end if;
|
end if;
|
|
|
|
|
--
|
--
|
-- Call re-dispatching operation:
|
-- Call re-dispatching operation:
|
--
|
--
|
|
|
Table_Support.Process_Operand (C640001_0.Table(My_Table2), -- View conv.
|
Table_Support.Process_Operand (C640001_0.Table(My_Table2), -- View conv.
|
My_List, 3, 3); -- Call 3rd op.
|
My_List, 3, 3); -- Call 3rd op.
|
|
|
if not C640001_0.Is_True (My_Table2.Row1) then
|
if not C640001_0.Is_True (My_Table2.Row1) then
|
Report.Failed ("Wrong result after calling re-dispatching operation");
|
Report.Failed ("Wrong result after calling re-dispatching operation");
|
end if;
|
end if;
|
|
|
|
|
Report.Result;
|
Report.Result;
|
end C640001;
|
end C640001;
|
|
|