URL
https://opencores.org/ocsvn/openrisc/openrisc/trunk
Subversion Repositories openrisc
[/] [openrisc/] [trunk/] [gnu-dev/] [or1k-gcc/] [gcc/] [testsuite/] [ada/] [acats/] [tests/] [c3/] [c392011.a] - Rev 720
Compare with Previous | Blame | View Log
-- C392011.A---- 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.--*---- OBJECTIVE:-- Check that if a function call with a controlling result is itself-- a controlling operand of an enclosing call on a dispatching operation,-- then its controlling tag value is determined by the controlling tag-- value of the enclosing call.---- TEST DESCRIPTION:-- The test builds and traverses a "ragged" list; a linked list which-- contains data elements of three different types (all rooted at-- Level_0'Class). The traversal of this list checks the objective-- by calling the dispatching operation "Check" using an item from the-- list, and calling the function create; thus causing the controlling-- result of the function to be determined by evaluating the value of-- the other controlling parameter to the two-parameter Check.------ CHANGE HISTORY:-- 22 SEP 95 SAIC Initial version-- 23 APR 96 SAIC Corrected commentary, differentiated integer.----!----------------------------------------------------------------- C392011_0package C392011_0 istype Level_0 is tagged recordCh_Item : Character;end record;function Create return Level_0;-- primitive dispatching functionprocedure Check( Left, Right: in Level_0 );-- has controlling parametersend C392011_0;-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --with Report;with TCTouch;package body C392011_0 isThe_Character : Character := 'A';function Create return Level_0 isCreated_Item_0 : constant Level_0 := ( Ch_Item => The_Character );beginThe_Character := Character'Succ(The_Character);TCTouch.Touch('A'); -- --- ---- ----- ---- --- -- --- ---- ----- ---- -- Areturn Created_Item_0;end Create;procedure Check( Left, Right: in Level_0 ) isbeginTCTouch.Touch('B'); -- --- ---- ----- ---- --- -- --- ---- ----- ---- -- Bend Check;end C392011_0;----------------------------------------------------------------- C392011_1with C392011_0;package C392011_1 istype Level_1 is new C392011_0.Level_0 with recordInt_Item : Integer;end record;-- note that Create becomes abstract upon this derivation hence:function Create return Level_1;procedure Check( Left, Right: in Level_1 );end C392011_1;-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --with TCTouch;package body C392011_1 isInteger_1 : Integer := 0;function Create return Level_1 isCreated_Item_1 : constant Level_1:= ( C392011_0.Create with Int_Item => Integer_1 );-- note call to ^--------------^ -- AbeginInteger_1 := Integer'Succ(Integer_1);TCTouch.Touch('C'); -- --- ---- ----- ---- --- -- --- ---- ----- ---- -- Creturn Created_Item_1;end Create;procedure Check( Left, Right: in Level_1 ) isbeginTCTouch.Touch('D'); -- --- ---- ----- ---- --- -- --- ---- ----- ---- -- Dend Check;end C392011_1;----------------------------------------------------------------- C392011_2with C392011_1;package C392011_2 istype Level_2 is new C392011_1.Level_1 with recordAnother_Int_Item : Integer;end record;-- note that Create becomes abstract upon this derivation hence:function Create return Level_2;procedure Check( Left, Right: in Level_2 );end C392011_2;-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --with TCTouch;package body C392011_2 isInteger_2 : Integer := 100;function Create return Level_2 isCreated_Item_2 : constant Level_2:= ( C392011_1.Create with Another_Int_Item => Integer_2 );-- note call to ^--------------^ -- ACbeginInteger_2 := Integer'Succ(Integer_2);TCTouch.Touch('E'); -- --- ---- ----- ---- --- -- --- ---- ----- ---- -- Ereturn Created_Item_2;end Create;procedure Check( Left, Right: in Level_2 ) isbeginTCTouch.Touch('F'); -- --- ---- ----- ---- --- -- --- ---- ----- ---- -- Fend Check;end C392011_2;------------------------------------------------------- C392011_2.C392011_3with C392011_0;package C392011_2.C392011_3 istype Wide_Reference is access all C392011_0.Level_0'Class;type Ragged_Element;type List_Pointer is access Ragged_Element;type Ragged_Element is recordData : Wide_Reference;Next : List_Pointer;end record;procedure Build_List;procedure Traverse_List;end C392011_2.C392011_3;-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --package body C392011_2.C392011_3 isThe_List : List_Pointer;procedure Build_List isbegin-- build a list that looks like:-- Level_2, Level_1, Level_2, Level_1, Level_0---- the mechanism is to create each object, "pushing" the existing list-- onto the end: cons( new_item, car, cdr )The_List :=new Ragged_Element'( new C392011_0.Level_0'(C392011_0.Create), null );-- Level_0 >> AThe_List :=new Ragged_Element'( new C392011_1.Level_1'(C392011_1.Create), The_List );-- Level_1 -> Level_0 >> ACThe_List :=new Ragged_Element'( new C392011_2.Level_2'(C392011_2.Create), The_List );-- Level_2 -> Level_1 -> Level_0 >> ACEThe_List :=new Ragged_Element'( new C392011_1.Level_1'(C392011_1.Create), The_List );-- Level_1 -> Level_2 -> Level_1 -> Level_0 >> ACThe_List :=new Ragged_Element'( new C392011_2.Level_2'(C392011_2.Create), The_List );-- Level_2 -> Level_1 -> Level_2 -> Level_1 -> Level_0 >> ACEend Build_List;procedure Traverse_List isNext_Item : List_Pointer := The_List;-- Check that if a function call with a controlling result is itself-- a controlling operand of an enclosing call on a dispatching operation,-- then its controlling tag value is determined by the controlling tag-- value of the enclosing call.-- Level_2 -> Level_1 -> Level_2 -> Level_1 -> Level_0beginwhile Next_Item /= null loop -- here we go!-- these calls better dispatch according to the value in the particular-- list item; causing the call to create to dispatch accordingly.-- why do it twice? To make sure order makes no differenceC392011_0.Check(Next_Item.Data.all, C392011_0.Create);-- Create will touch first, then Check touchesC392011_0.Check(C392011_0.Create, Next_Item.Data.all);-- Here's what's s'pos'd to 'appen:-- Check( Lev_2, Create ) >> ACEF-- Check( Create, Lev_2 ) >> ACEF-- Check( Lev_1, Create ) >> ACD-- Check( Create, Lev_1 ) >> ACD-- Check( Lev_2, Create ) >> ACEF-- Check( Create, Lev_2 ) >> ACEF-- Check( Lev_1, Create ) >> ACD-- Check( Create, Lev_1 ) >> ACD-- Check( Lev_0, Create ) >> AB-- Check( Create, Lev_0 ) >> ABNext_Item := Next_Item.Next;end loop;end Traverse_List;end C392011_2.C392011_3;------------------------------------------------------------------- C392011with Report;with TCTouch;with C392011_2.C392011_3;procedure C392011 isbegin -- Main test procedure.Report.Test ("C392011", "Check that if a function call with a " &"controlling result is itself a controlling " &"operand of an enclosing call on a dispatching " &"operation, then its controlling tag value is " &"determined by the controlling tag value of " &"the enclosing call" );C392011_2.C392011_3.Build_List;TCTouch.Validate( "A" & "AC" & "ACE" & "AC" & "ACE", "Build List" );C392011_2.C392011_3.Traverse_List;TCTouch.Validate( "ACEFACEF" &"ACDACD" &"ACEFACEF" &"ACDACD" &"ABAB","Traverse List" );Report.Result;end C392011;
