mirror of
git://gcc.gnu.org/git/gcc.git
synced 2025-04-18 23:31:22 +08:00
a-tags.ads, a-tags.adb (Offset_To_Top): Moved from the package body to the specification because the frontend generates...
2005-12-05 Javier Miranda <miranda@adacore.com> Hristian Kirtchev <kirtchev@adacore.com> * a-tags.ads, a-tags.adb (Offset_To_Top): Moved from the package body to the specification because the frontend generates code that uses this subprogram. (Set_Interface_Table): Add missing assertion. Update documentation describing the run-time structure. (Displace): New subprogram that displaces the pointer to the object to reference one of its secondary dispatch tables. (IW_Membership): Modified to use the new table of interfaces. (Inherit_TSD): Modified to use the new table of interfaces. (Register_Interface_Tag): Use the additional formal to fill the contents of the new table of interfaces. (Set_Interface_Table): New subprogram that stores in the TSD the pointer to the table of interfaces. (Set_Offset_To_Top): Use the additional formal to save copy of the offset value in the table of interfaces. Update structure of GNAT Primary and Secondary dispatch table diagram. Add comment section on GNAT dispatch table prologue. (Offset_To_Signature): Update the constant value of the Signature field. (Dispatch_Table): Update comment on hidden fields in the prologue. (Get_Entry_Index, Get_Prim_Op_Kind, Get_Offset_Index, OSD, Set_Entry_Index, Set_Offset_Index, Set_Prim_Op_Kind, SSD, TSD): Change the type of formal parameter T to Tag, introduce additional assertions. (Get_Num_Prim_Ops, Set_Num_Prim_Ops): Remove an unnecessary type conversion. (Get_Tagged_Kind, Set_Tagged_Kind): New bodies. * exp_ch6.adb (Register_Interface_DT_Entry): Remove the Thunk_Id actual in all the calls to Expand_Interface_Thunk. Instead of referencing the record component containing the tag of the secondary dispatch table we have to use the Offset_To_Top run-time function to get this information; otherwise if the pointer to the base of the object has been displace we get a wrong value if we use the 'position attribute. * exp_disp.adb (Expand_Interface_Thunk): Remove the Thunk_Id actual in all the calls to Expand_Interface_Thunk. (Make_Secondary_DT): Secondary dispatch tables do not have a table of interfaces; hence the call to Set_Interface_Table was clearly wrong. (Collect_All_Interfaces): Modify the internal subprogram Collect to ensure that the interfaces implemented by the ancestors are placed at the header of the generated list. (Expand_Interface_Conversion): Handle the case in which the displacement associated with the interface conversion is not statically known. In this case we generate a call to the new run-time subprogram Displace. (Make_DT): Generate and fill the new table of interfaces. (Ada_Actions, Action_Is_Proc, Action_Nb_Arg): Add entries for Get_Tagged_Kind and Set_Tagged_Kind. (Tagged_Kind): New function that determines the tagged kind of a type with respect to limitedness and concurrency and returns a reference to RE_Tagged_Kind. (Make_Disp_Asynchronous_Select_Body, Make_Disp_Conditional_Select_Body, Make_Disp_Timed_Select_Body): Correctly retrieve the pointer to the primary dispatch table for a type. (Make_DT, Make_Secondary_DT): Set the tagged kind in the primary and secondary dispatch table respectively of a tagged type. * exp_disp.ads (Expand_Interface_Thunk): Remove Thunk_Id formal. (Expand_Interface_Conversion): New subprogram to indicate if the displacement of the type conversion is statically known. (DT_Access_Action): Add values Get_Tagged_Kind and Set_Tagged_Kind. * rtsfind.ads (RE_Offset_To_Top): New entity (RTU_Id): Add Ada_Task_Termination to the list so that it is made accessible to users. (Re_Displace): New entity (RE_Interface_Data): New entity (RE_Set_Interface_Data): New_Entity (RE_Id, RE_Unit_Table): Add entry for RE_Get_Tagged_Kind, Set_Tagged_Kind, RE_Tagged_Kind, RE_TK_Abstract_Limited_Tagged, RE_TK_Abstract_Tagged, RE_TK_Limited_Tagged, RE_TK_Protected, RE_TK_Tagged, RE_TK_Task. * exp_ch3.adb (Init_Secondary_Tags): Modify the subprogram Init_Secondary_Tags_Internal to allow its use with interface types and also to generate the code for the new additional actual required by Set_Offset_To_Top. (Build_Init_Statements): In case of components associated with abstract interface types there is no need to generate a call to its IP. (Freeze_Record_Type): Generate Select Specific Data tables only for concurrent types. (Make_Predefined_Primitive_Specs, Predefined_Primitive_Bodies): Generate the bodies and specifications of the predefined primitive operations dealing with dispatching selects and abort, 'Callable, 'Terminated only for concurrent types. * exp_sel.ads, exp_sel.adb: New files. * exp_ch9.adb (Build_Protected_Entry, Expand_N_Protected_Body, Expand_N_Protected_Type_Declaration, Make_Initialize_Protection): Handle properly protected objects and attach handler in the case of the restricted profile. Move embeded package Select_Expansion_Utilities into a separate external package. (Expand_N_Asynchronous_Select, Expand_N_Conditional_Select, Expand_N_Timed_Entry_Call): Correct calls external package Exp_Sel. (Build_K, Build_S_Assignment): New subprograms, part of the select expansion utilities. (Expand_N_Asynchronous_Select, Expand_N_Conditional_Entry_Call, Expand_N_Timed_Entry_Call): Optimize expansion of select statements where the trigger is a dispatching procedure of a limited tagged type. From-SVN: r108284
This commit is contained in:
parent
e51b97bef7
commit
4d744221db
@ -41,47 +41,53 @@ package body Ada.Tags is
|
||||
|
||||
-- Structure of the GNAT Primary Dispatch Table
|
||||
|
||||
-- +-----------------------+
|
||||
-- | Signature |
|
||||
-- +-----------------------+
|
||||
-- | Offset_To_Top |
|
||||
-- +-----------------------+
|
||||
-- | Typeinfo_Ptr/TSD_Ptr | ---> Type Specific Data
|
||||
-- Tag ---> +-----------------------+ +-------------------+
|
||||
-- | table of | | inheritance depth |
|
||||
-- : primitive ops : +-------------------+
|
||||
-- | pointers | | access level |
|
||||
-- +-----------------------+ +-------------------+
|
||||
-- | expanded name |
|
||||
-- +-------------------+
|
||||
-- | external tag |
|
||||
-- +-------------------+
|
||||
-- | hash table link |
|
||||
-- +-------------------+
|
||||
-- | remotely callable |
|
||||
-- +-------------------+
|
||||
-- | rec ctrler offset |
|
||||
-- +-------------------+
|
||||
-- | num prim ops |
|
||||
-- +-------------------+
|
||||
-- | num interfaces |
|
||||
-- +-------------------+
|
||||
-- Select Specific Data <--- | SSD_Ptr |
|
||||
-- +-----------------------+ +-------------------+
|
||||
-- | table of primitive | | table of |
|
||||
-- : operation : : ancestor :
|
||||
-- | kinds | | tags |
|
||||
-- +-----------------------+ +-------------------+
|
||||
-- | table of | | table of |
|
||||
-- : entry : : interface :
|
||||
-- | indices | | tags |
|
||||
-- +-----------------------+ +-------------------+
|
||||
-- +----------------------+
|
||||
-- | Signature |
|
||||
-- +----------------------+
|
||||
-- | Tagged_Kind |
|
||||
-- +----------------------+
|
||||
-- | Offset_To_Top |
|
||||
-- +----------------------+
|
||||
-- | Typeinfo_Ptr/TSD_Ptr ---> Type Specific Data
|
||||
-- Tag ---> +----------------------+ +-------------------+
|
||||
-- | table of | | inheritance depth |
|
||||
-- : primitive ops : +-------------------+
|
||||
-- | pointers | | access level |
|
||||
-- +----------------------+ +-------------------+
|
||||
-- | expanded name |
|
||||
-- +-------------------+
|
||||
-- | external tag |
|
||||
-- +-------------------+
|
||||
-- | hash table link |
|
||||
-- +-------------------+
|
||||
-- | remotely callable |
|
||||
-- +-------------------+
|
||||
-- | rec ctrler offset |
|
||||
-- +-------------------+
|
||||
-- | num prim ops |
|
||||
-- +-------------------+
|
||||
-- | num interfaces |
|
||||
-- +-------------------+
|
||||
-- | Ifaces_Table_Ptr --> Interface Data
|
||||
-- +-------------------+ +------------+
|
||||
-- Select Specific Data <---- SSD_Ptr | | table |
|
||||
-- +--------------------+ +-------------------+ : of :
|
||||
-- | table of primitive | | table of | | interfaces |
|
||||
-- : operation : : ancestor : +------------+
|
||||
-- | kinds | | tags |
|
||||
-- +--------------------+ +-------------------+
|
||||
-- | table of |
|
||||
-- : entry :
|
||||
-- | indices |
|
||||
-- +--------------------+
|
||||
|
||||
-- Structure of the GNAT Secondary Dispatch Table
|
||||
|
||||
-- +-----------------------+
|
||||
-- | Signature |
|
||||
-- +-----------------------+
|
||||
-- | Tagged_Kind |
|
||||
-- +-----------------------+
|
||||
-- | Offset_To_Top |
|
||||
-- +-----------------------+
|
||||
-- | OSD_Ptr |---> Object Specific Data
|
||||
@ -93,10 +99,77 @@ package body Ada.Tags is
|
||||
-- | op offsets |
|
||||
-- +---------------+
|
||||
|
||||
Offset_To_Signature : constant SSE.Storage_Count :=
|
||||
DT_Typeinfo_Ptr_Size
|
||||
+ DT_Offset_To_Top_Size
|
||||
+ DT_Signature_Size;
|
||||
----------------------------------
|
||||
-- GNAT Dispatch Table Prologue --
|
||||
----------------------------------
|
||||
|
||||
-- GNAT's Dispatch Table prologue contains several fields which are hidden
|
||||
-- in order to preserve compatibility with C++. These fields are accessed
|
||||
-- by address calculations performed in the following manner:
|
||||
|
||||
-- Field : Field_Type :=
|
||||
-- (To_Address (Tag) - Sum_Of_Preceding_Field_Sizes).all;
|
||||
|
||||
-- The bracketed subtraction shifts the pointer (Tag) from the table of
|
||||
-- primitive operations (or thunks) to the field in question. Since the
|
||||
-- result of the subtraction is an address, dereferencing it will obtain
|
||||
-- the actual value of the field.
|
||||
|
||||
-- Guidelines for addition of new hidden fields
|
||||
|
||||
-- Define a Field_Type and Field_Type_Ptr (access to Field_Type) in
|
||||
-- A-Tags.ads for the newly introduced field.
|
||||
|
||||
-- Defined the size of the new field as a constant Field_Name_Size
|
||||
|
||||
-- Introduce an Unchecked_Conversion from System.Address to
|
||||
-- Field_Type_Ptr in A-Tags.ads.
|
||||
|
||||
-- Define the specifications of Get_<Field_Name> and Set_<Field_Name>
|
||||
-- in A-Tags.ads.
|
||||
|
||||
-- Update the GNAT Dispatch Table structure in A-Tags.adb
|
||||
|
||||
-- Provide bodies to the Get_<Field_Name> and Set_<Field_Name> routines.
|
||||
-- The profile of a Get_<Field_Name> routine should resemble:
|
||||
|
||||
-- function Get_<Field_Name> (T : Tag; ...) return Field_Type is
|
||||
-- Field : constant System.Address :=
|
||||
-- To_Address (T) - <Sum_Of_Previous_Field_Sizes>;
|
||||
-- begin
|
||||
-- pragma Assert (Check_Signature (T, <Applicable_DT>));
|
||||
-- <Additional_Assertions>
|
||||
|
||||
-- return To_Field_Type_Ptr (Field).all;
|
||||
-- end Get_<Field_Name>;
|
||||
|
||||
-- The profile of a Set_<Field_Name> routine should resemble:
|
||||
|
||||
-- procedure Set_<Field_Name> (T : Tag; ..., Value : Field_Type) is
|
||||
-- Field : constant System.Address :=
|
||||
-- To_Address (T) - <Sum_Of_Previous_Field_Sizes>;
|
||||
-- begin
|
||||
-- pragma Assert (Check_Signature (T, <Applicable_DT>));
|
||||
-- <Additional_Assertions>
|
||||
|
||||
-- To_Field_Type_Ptr (Field).all := Value;
|
||||
-- end Set_<Field_Name>;
|
||||
|
||||
-- NOTE: For each field in the prologue which precedes the newly added
|
||||
-- one, find and update its respective Sum_Of_Previous_Field_Sizes by
|
||||
-- subtractind Field_Name_Size from it. Falure to do so will clobber the
|
||||
-- previous prologue field.
|
||||
|
||||
K_Typeinfo : constant SSE.Storage_Count := DT_Typeinfo_Ptr_Size;
|
||||
|
||||
K_Offset_To_Top : constant SSE.Storage_Count :=
|
||||
K_Typeinfo + DT_Offset_To_Top_Size;
|
||||
|
||||
K_Tagged_Kind : constant SSE.Storage_Count :=
|
||||
K_Offset_To_Top + DT_Tagged_Kind_Size;
|
||||
|
||||
K_Signature : constant SSE.Storage_Count :=
|
||||
K_Tagged_Kind + DT_Signature_Size;
|
||||
|
||||
subtype Cstring is String (Positive);
|
||||
type Cstring_Ptr is access all Cstring;
|
||||
@ -108,6 +181,20 @@ package body Ada.Tags is
|
||||
pragma Suppress_Initialization (Tag_Table);
|
||||
pragma Suppress (Index_Check, On => Tag_Table);
|
||||
|
||||
-- Declarations for the table of interfaces
|
||||
|
||||
type Interface_Data_Element is record
|
||||
Iface_Tag : Tag;
|
||||
Offset : System.Storage_Elements.Storage_Offset;
|
||||
end record;
|
||||
|
||||
type Interfaces_Array is
|
||||
array (Natural range <>) of Interface_Data_Element;
|
||||
|
||||
type Interface_Data (Nb_Ifaces : Positive) is record
|
||||
Table : Interfaces_Array (1 .. Nb_Ifaces);
|
||||
end record;
|
||||
|
||||
-- Object specific data types
|
||||
|
||||
type Object_Specific_Data_Array is array (Positive range <>) of Positive;
|
||||
@ -171,17 +258,16 @@ package body Ada.Tags is
|
||||
-- Controller Offset: Used to give support to tagged controlled objects
|
||||
-- (see Get_Deep_Controller at s-finimp)
|
||||
|
||||
Ifaces_Table_Ptr : System.Address;
|
||||
-- Pointer to the table of interface tags. It is used to implement the
|
||||
-- membership test associated with interfaces and also for backward
|
||||
-- abstract interface type conversions (Ada 2005:AI-251)
|
||||
|
||||
Num_Prim_Ops : Natural;
|
||||
-- Number of primitive operations of the dispatch table. This field is
|
||||
-- used for additional run-time checks when the run-time is compiled
|
||||
-- with assertions enabled.
|
||||
|
||||
Num_Interfaces : Natural;
|
||||
-- Number of abstract interface types implemented by the tagged type.
|
||||
-- The value Idepth+Num_Interfaces indicates the end of the second table
|
||||
-- stored in the Tags_Table component. It is used to implement the
|
||||
-- membership test associated with interfaces (Ada 2005:AI-251).
|
||||
|
||||
SSD_Ptr : System.Address;
|
||||
-- Pointer to a table of records used in dispatching selects. This
|
||||
-- field has a meaningful value for all tagged types that implement
|
||||
@ -210,6 +296,8 @@ package body Ada.Tags is
|
||||
-- enough space for these additional components, and generates code that
|
||||
-- displaces the _Tag to point after these components.
|
||||
|
||||
-- Signature : Signature_Kind;
|
||||
-- Tagged_Kind : Tagged_Kind;
|
||||
-- Offset_To_Top : Natural;
|
||||
-- Typeinfo_Ptr : System.Address;
|
||||
|
||||
@ -305,11 +393,6 @@ package body Ada.Tags is
|
||||
-- Length of string represented by the given pointer (treating the string
|
||||
-- as a C-style string, which is Nul terminated).
|
||||
|
||||
function Offset_To_Top
|
||||
(T : Tag) return System.Storage_Elements.Storage_Offset;
|
||||
-- Returns the current value of the offset_to_top component available in
|
||||
-- the prologue of the dispatch table.
|
||||
|
||||
function Typeinfo_Ptr (T : Tag) return System.Address;
|
||||
-- Returns the current value of the typeinfo_ptr component available in
|
||||
-- the prologue of the dispatch table.
|
||||
@ -425,21 +508,20 @@ package body Ada.Tags is
|
||||
---------------------
|
||||
|
||||
function Check_Signature (T : Tag; Kind : Signature_Type) return Boolean is
|
||||
Offset_To_Top_Ptr : constant Storage_Offset_Ptr :=
|
||||
To_Storage_Offset_Ptr (To_Address (T)
|
||||
- Offset_To_Signature);
|
||||
Signature : constant Storage_Offset_Ptr :=
|
||||
To_Storage_Offset_Ptr (To_Address (T) - K_Signature);
|
||||
|
||||
Signature : constant Signature_Values :=
|
||||
To_Signature_Values (Offset_To_Top_Ptr.all);
|
||||
Sig_Values : constant Signature_Values :=
|
||||
To_Signature_Values (Signature.all);
|
||||
|
||||
Signature_Id : Signature_Kind;
|
||||
|
||||
begin
|
||||
if Signature (1) /= Valid_Signature then
|
||||
if Sig_Values (1) /= Valid_Signature then
|
||||
Signature_Id := Unknown;
|
||||
|
||||
elsif Signature (2) in Primary_DT .. Abstract_Interface then
|
||||
Signature_Id := Signature (2);
|
||||
elsif Sig_Values (2) in Primary_DT .. Abstract_Interface then
|
||||
Signature_Id := Sig_Values (2);
|
||||
|
||||
else
|
||||
Signature_Id := Unknown;
|
||||
@ -522,6 +604,54 @@ package body Ada.Tags is
|
||||
return Pos >= 0 and then TSD (Obj_Tag).Tags_Table (Pos) = Typ_Tag;
|
||||
end CW_Membership;
|
||||
|
||||
--------------
|
||||
-- Displace --
|
||||
--------------
|
||||
|
||||
function Displace
|
||||
(This : System.Address;
|
||||
T : Tag) return System.Address
|
||||
is
|
||||
Curr_DT : constant Tag := To_Tag_Ptr (This).all;
|
||||
Iface_Table : Interface_Data_Ptr;
|
||||
Obj_Base : System.Address;
|
||||
Obj_DT : Tag;
|
||||
Obj_TSD : Type_Specific_Data_Ptr;
|
||||
|
||||
begin
|
||||
pragma Assert
|
||||
(Check_Signature (Curr_DT, Must_Be_Primary_Or_Secondary_DT));
|
||||
pragma Assert
|
||||
(Check_Signature (T, Must_Be_Interface));
|
||||
|
||||
Obj_Base := This - Offset_To_Top (Curr_DT);
|
||||
Obj_DT := To_Tag_Ptr (Obj_Base).all;
|
||||
|
||||
pragma Assert
|
||||
(Check_Signature (Obj_DT, Must_Be_Primary_DT));
|
||||
|
||||
Obj_TSD := TSD (Obj_DT);
|
||||
Iface_Table := To_Interface_Data_Ptr (Obj_TSD.Ifaces_Table_Ptr);
|
||||
|
||||
if Iface_Table /= null then
|
||||
for Id in 1 .. Iface_Table.Nb_Ifaces loop
|
||||
if Iface_Table.Table (Id).Iface_Tag = T then
|
||||
Obj_Base := Obj_Base + Iface_Table.Table (Id).Offset;
|
||||
Obj_DT := To_Tag_Ptr (Obj_Base).all;
|
||||
|
||||
pragma Assert
|
||||
(Check_Signature (Obj_DT, Must_Be_Secondary_DT));
|
||||
|
||||
return Obj_Base;
|
||||
end if;
|
||||
end loop;
|
||||
end if;
|
||||
|
||||
-- If the object does not implement the interface we must raise CE
|
||||
|
||||
raise Constraint_Error;
|
||||
end Displace;
|
||||
|
||||
-------------------
|
||||
-- IW_Membership --
|
||||
-------------------
|
||||
@ -537,12 +667,12 @@ package body Ada.Tags is
|
||||
-- that are contained in the dispatch table referenced by Obj'Tag.
|
||||
|
||||
function IW_Membership (This : System.Address; T : Tag) return Boolean is
|
||||
Curr_DT : constant Tag := To_Tag_Ptr (This).all;
|
||||
Id : Natural;
|
||||
Last_Id : Natural;
|
||||
Obj_Base : System.Address;
|
||||
Obj_DT : Tag;
|
||||
Obj_TSD : Type_Specific_Data_Ptr;
|
||||
Curr_DT : constant Tag := To_Tag_Ptr (This).all;
|
||||
Iface_Table : Interface_Data_Ptr;
|
||||
Last_Id : Natural;
|
||||
Obj_Base : System.Address;
|
||||
Obj_DT : Tag;
|
||||
Obj_TSD : Type_Specific_Data_Ptr;
|
||||
|
||||
begin
|
||||
pragma Assert
|
||||
@ -554,29 +684,32 @@ package body Ada.Tags is
|
||||
Obj_DT := To_Tag_Ptr (Obj_Base).all;
|
||||
|
||||
pragma Assert
|
||||
(Check_Signature (Curr_DT, Must_Be_Primary_DT));
|
||||
(Check_Signature (Obj_DT, Must_Be_Primary_DT));
|
||||
|
||||
Obj_TSD := TSD (Obj_DT);
|
||||
Last_Id := Obj_TSD.Idepth + Obj_TSD.Num_Interfaces;
|
||||
Last_Id := Obj_TSD.Idepth;
|
||||
|
||||
if Obj_TSD.Num_Interfaces > 0 then
|
||||
-- Look for the tag in the table of interfaces
|
||||
|
||||
-- Traverse the ancestor tags table plus the interface tags table.
|
||||
-- The former part is required for:
|
||||
Iface_Table := To_Interface_Data_Ptr (Obj_TSD.Ifaces_Table_Ptr);
|
||||
|
||||
-- Iface_CW in Typ'Class
|
||||
|
||||
Id := 0;
|
||||
loop
|
||||
if Obj_TSD.Tags_Table (Id) = T then
|
||||
if Iface_Table /= null then
|
||||
for Id in 1 .. Iface_Table.Nb_Ifaces loop
|
||||
if Iface_Table.Table (Id).Iface_Tag = T then
|
||||
return True;
|
||||
end if;
|
||||
|
||||
Id := Id + 1;
|
||||
exit when Id > Last_Id;
|
||||
end loop;
|
||||
end if;
|
||||
|
||||
-- Look for the tag in the ancestor tags table. This is required for:
|
||||
-- Iface_CW in Typ'Class
|
||||
|
||||
for Id in 0 .. Last_Id loop
|
||||
if Obj_TSD.Tags_Table (Id) = T then
|
||||
return True;
|
||||
end if;
|
||||
end loop;
|
||||
|
||||
return False;
|
||||
end IW_Membership;
|
||||
|
||||
@ -652,6 +785,7 @@ package body Ada.Tags is
|
||||
Index : constant Integer := Position - Default_Prim_Op_Count;
|
||||
begin
|
||||
pragma Assert (Check_Signature (T, Must_Be_Primary_DT));
|
||||
pragma Assert (Check_Index (T, Position));
|
||||
pragma Assert (Index > 0);
|
||||
return SSD (T).SSD_Table (Index).Index;
|
||||
end Get_Entry_Index;
|
||||
@ -677,7 +811,7 @@ package body Ada.Tags is
|
||||
if Is_Primary_DT (T) then
|
||||
return TSD (T).Num_Prim_Ops;
|
||||
else
|
||||
return OSD (Interface_Tag (T)).Num_Prim_Ops;
|
||||
return OSD (T).Num_Prim_Ops;
|
||||
end if;
|
||||
end Get_Num_Prim_Ops;
|
||||
|
||||
@ -706,6 +840,7 @@ package body Ada.Tags is
|
||||
Index : constant Integer := Position - Default_Prim_Op_Count;
|
||||
begin
|
||||
pragma Assert (Check_Signature (T, Must_Be_Primary_DT));
|
||||
pragma Assert (Check_Index (T, Position));
|
||||
pragma Assert (Index > 0);
|
||||
return SSD (T).SSD_Table (Index).Kind;
|
||||
end Get_Prim_Op_Kind;
|
||||
@ -715,12 +850,13 @@ package body Ada.Tags is
|
||||
----------------------
|
||||
|
||||
function Get_Offset_Index
|
||||
(T : Interface_Tag;
|
||||
(T : Tag;
|
||||
Position : Positive) return Positive
|
||||
is
|
||||
Index : constant Integer := Position - Default_Prim_Op_Count;
|
||||
begin
|
||||
pragma Assert (Check_Signature (Tag (T), Must_Be_Secondary_DT));
|
||||
pragma Assert (Check_Signature (T, Must_Be_Secondary_DT));
|
||||
pragma Assert (Check_Index (T, Position));
|
||||
pragma Assert (Index > 0);
|
||||
return OSD (T).OSD_Table (Index);
|
||||
end Get_Offset_Index;
|
||||
@ -745,6 +881,18 @@ package body Ada.Tags is
|
||||
return TSD (T).Remotely_Callable;
|
||||
end Get_Remotely_Callable;
|
||||
|
||||
---------------------
|
||||
-- Get_Tagged_Kind --
|
||||
---------------------
|
||||
|
||||
function Get_Tagged_Kind (T : Tag) return Tagged_Kind is
|
||||
Tagged_Kind_Ptr : constant System.Address :=
|
||||
To_Address (T) - K_Tagged_Kind;
|
||||
begin
|
||||
pragma Assert (Check_Signature (T, Must_Be_Primary_Or_Secondary_DT));
|
||||
return To_Tagged_Kind_Ptr (Tagged_Kind_Ptr).all;
|
||||
end Get_Tagged_Kind;
|
||||
|
||||
----------------
|
||||
-- Inherit_DT --
|
||||
----------------
|
||||
@ -766,8 +914,10 @@ package body Ada.Tags is
|
||||
-----------------
|
||||
|
||||
procedure Inherit_TSD (Old_Tag : Tag; New_Tag : Tag) is
|
||||
New_TSD_Ptr : Type_Specific_Data_Ptr;
|
||||
Old_TSD_Ptr : Type_Specific_Data_Ptr;
|
||||
New_TSD_Ptr : Type_Specific_Data_Ptr;
|
||||
New_Iface_Table_Ptr : Interface_Data_Ptr;
|
||||
Old_TSD_Ptr : Type_Specific_Data_Ptr;
|
||||
Old_Iface_Table_Ptr : Interface_Data_Ptr;
|
||||
|
||||
begin
|
||||
pragma Assert (Check_Signature (New_Tag, Must_Be_Primary_Or_Interface));
|
||||
@ -778,18 +928,29 @@ package body Ada.Tags is
|
||||
(Check_Signature (Old_Tag, Must_Be_Primary_Or_Interface));
|
||||
Old_TSD_Ptr := TSD (Old_Tag);
|
||||
New_TSD_Ptr.Idepth := Old_TSD_Ptr.Idepth + 1;
|
||||
New_TSD_Ptr.Num_Interfaces := Old_TSD_Ptr.Num_Interfaces;
|
||||
|
||||
-- Copy the "table of ancestor tags" plus the "table of interfaces"
|
||||
-- of the parent.
|
||||
|
||||
New_TSD_Ptr.Tags_Table
|
||||
(1 .. New_TSD_Ptr.Idepth + New_TSD_Ptr.Num_Interfaces) :=
|
||||
Old_TSD_Ptr.Tags_Table
|
||||
(0 .. Old_TSD_Ptr.Idepth + Old_TSD_Ptr.Num_Interfaces);
|
||||
New_TSD_Ptr.Tags_Table (1 .. New_TSD_Ptr.Idepth) :=
|
||||
Old_TSD_Ptr.Tags_Table (0 .. Old_TSD_Ptr.Idepth);
|
||||
|
||||
-- Copy the table of interfaces of the parent
|
||||
|
||||
if not System."=" (Old_TSD_Ptr.Ifaces_Table_Ptr,
|
||||
System.Null_Address)
|
||||
then
|
||||
Old_Iface_Table_Ptr :=
|
||||
To_Interface_Data_Ptr (Old_TSD_Ptr.Ifaces_Table_Ptr);
|
||||
New_Iface_Table_Ptr :=
|
||||
To_Interface_Data_Ptr (New_TSD_Ptr.Ifaces_Table_Ptr);
|
||||
|
||||
New_Iface_Table_Ptr.Table (1 .. Old_Iface_Table_Ptr.Nb_Ifaces) :=
|
||||
Old_Iface_Table_Ptr.Table (1 .. Old_Iface_Table_Ptr.Nb_Ifaces);
|
||||
end if;
|
||||
|
||||
else
|
||||
New_TSD_Ptr.Idepth := 0;
|
||||
New_TSD_Ptr.Num_Interfaces := 0;
|
||||
New_TSD_Ptr.Idepth := 0;
|
||||
end if;
|
||||
|
||||
New_TSD_Ptr.Tags_Table (0) := New_Tag;
|
||||
@ -845,13 +1006,12 @@ package body Ada.Tags is
|
||||
-------------------
|
||||
|
||||
function Is_Primary_DT (T : Tag) return Boolean is
|
||||
Offset_To_Top_Ptr : constant Storage_Offset_Ptr :=
|
||||
To_Storage_Offset_Ptr (To_Address (T)
|
||||
- Offset_To_Signature);
|
||||
Signature : constant Signature_Values :=
|
||||
To_Signature_Values (Offset_To_Top_Ptr.all);
|
||||
Signature : constant Storage_Offset_Ptr :=
|
||||
To_Storage_Offset_Ptr (To_Address (T) - K_Signature);
|
||||
Sig_Values : constant Signature_Values :=
|
||||
To_Signature_Values (Signature.all);
|
||||
begin
|
||||
return Signature (2) = Primary_DT;
|
||||
return Sig_Values (2) = Primary_DT;
|
||||
end Is_Primary_DT;
|
||||
|
||||
------------
|
||||
@ -876,26 +1036,22 @@ package body Ada.Tags is
|
||||
function Offset_To_Top
|
||||
(T : Tag) return System.Storage_Elements.Storage_Offset
|
||||
is
|
||||
Offset_To_Top_Ptr : constant Storage_Offset_Ptr :=
|
||||
To_Storage_Offset_Ptr (To_Address (T)
|
||||
- DT_Typeinfo_Ptr_Size
|
||||
- DT_Offset_To_Top_Size);
|
||||
|
||||
Offset_To_Top : constant Storage_Offset_Ptr :=
|
||||
To_Storage_Offset_Ptr
|
||||
(To_Address (T) - K_Offset_To_Top);
|
||||
begin
|
||||
return Offset_To_Top_Ptr.all;
|
||||
return Offset_To_Top.all;
|
||||
end Offset_To_Top;
|
||||
|
||||
---------
|
||||
-- OSD --
|
||||
---------
|
||||
|
||||
function OSD
|
||||
(T : Interface_Tag) return Object_Specific_Data_Ptr
|
||||
is
|
||||
OSD_Ptr : Addr_Ptr;
|
||||
|
||||
function OSD (T : Tag) return Object_Specific_Data_Ptr is
|
||||
OSD_Ptr : constant Addr_Ptr :=
|
||||
To_Addr_Ptr (To_Address (T) - K_Typeinfo);
|
||||
begin
|
||||
OSD_Ptr := To_Addr_Ptr (To_Address (T) - DT_Typeinfo_Ptr_Size);
|
||||
pragma Assert (Check_Signature (T, Must_Be_Secondary_DT));
|
||||
return To_Object_Specific_Data_Ptr (OSD_Ptr.all);
|
||||
end OSD;
|
||||
|
||||
@ -952,39 +1108,24 @@ package body Ada.Tags is
|
||||
-- Register_Interface_Tag --
|
||||
----------------------------
|
||||
|
||||
procedure Register_Interface_Tag (T : Tag; Interface_T : Tag) is
|
||||
New_T_TSD : Type_Specific_Data_Ptr;
|
||||
Index : Natural;
|
||||
procedure Register_Interface_Tag
|
||||
(T : Tag;
|
||||
Interface_T : Tag;
|
||||
Position : Positive)
|
||||
is
|
||||
New_T_TSD : Type_Specific_Data_Ptr;
|
||||
Iface_Table : Interface_Data_Ptr;
|
||||
|
||||
begin
|
||||
pragma Assert (Check_Signature (T, Must_Be_Primary_DT));
|
||||
pragma Assert (Check_Signature (Interface_T, Must_Be_Interface));
|
||||
|
||||
New_T_TSD := TSD (T);
|
||||
New_T_TSD := TSD (T);
|
||||
Iface_Table := To_Interface_Data_Ptr (New_T_TSD.Ifaces_Table_Ptr);
|
||||
|
||||
-- Check if the interface is already registered
|
||||
pragma Assert (Position <= Iface_Table.Nb_Ifaces);
|
||||
|
||||
if New_T_TSD.Num_Interfaces > 0 then
|
||||
declare
|
||||
Id : Natural := New_T_TSD.Idepth + 1;
|
||||
Last_Id : constant Natural := New_T_TSD.Idepth
|
||||
+ New_T_TSD.Num_Interfaces;
|
||||
|
||||
begin
|
||||
loop
|
||||
if New_T_TSD.Tags_Table (Id) = Interface_T then
|
||||
return;
|
||||
end if;
|
||||
|
||||
Id := Id + 1;
|
||||
exit when Id > Last_Id;
|
||||
end loop;
|
||||
end;
|
||||
end if;
|
||||
|
||||
New_T_TSD.Num_Interfaces := New_T_TSD.Num_Interfaces + 1;
|
||||
Index := New_T_TSD.Idepth + New_T_TSD.Num_Interfaces;
|
||||
New_T_TSD.Tags_Table (Index) := Interface_T;
|
||||
Iface_Table.Table (Position).Iface_Tag := Interface_T;
|
||||
end Register_Interface_Tag;
|
||||
|
||||
------------------
|
||||
@ -1016,9 +1157,9 @@ package body Ada.Tags is
|
||||
Value : Positive)
|
||||
is
|
||||
Index : constant Integer := Position - Default_Prim_Op_Count;
|
||||
|
||||
begin
|
||||
pragma Assert (Check_Signature (T, Must_Be_Primary_DT));
|
||||
pragma Assert (Check_Index (T, Position));
|
||||
pragma Assert (Index > 0);
|
||||
SSD (T).SSD_Table (Index).Index := Value;
|
||||
end Set_Entry_Index;
|
||||
@ -1044,6 +1185,16 @@ package body Ada.Tags is
|
||||
TSD (T).External_Tag := To_Cstring_Ptr (Value);
|
||||
end Set_External_Tag;
|
||||
|
||||
-------------------------
|
||||
-- Set_Interface_Table --
|
||||
-------------------------
|
||||
|
||||
procedure Set_Interface_Table (T : Tag; Value : System.Address) is
|
||||
begin
|
||||
pragma Assert (Check_Signature (T, Must_Be_Primary_DT));
|
||||
TSD (T).Ifaces_Table_Ptr := Value;
|
||||
end Set_Interface_Table;
|
||||
|
||||
----------------------
|
||||
-- Set_Num_Prim_Ops --
|
||||
----------------------
|
||||
@ -1055,7 +1206,7 @@ package body Ada.Tags is
|
||||
if Is_Primary_DT (T) then
|
||||
TSD (T).Num_Prim_Ops := Value;
|
||||
else
|
||||
OSD (Interface_Tag (T)).Num_Prim_Ops := Value;
|
||||
OSD (T).Num_Prim_Ops := Value;
|
||||
end if;
|
||||
end Set_Num_Prim_Ops;
|
||||
|
||||
@ -1064,13 +1215,14 @@ package body Ada.Tags is
|
||||
----------------------
|
||||
|
||||
procedure Set_Offset_Index
|
||||
(T : Interface_Tag;
|
||||
(T : Tag;
|
||||
Position : Positive;
|
||||
Value : Positive)
|
||||
is
|
||||
Index : constant Integer := Position - Default_Prim_Op_Count;
|
||||
begin
|
||||
pragma Assert (Check_Signature (Tag (T), Must_Be_Secondary_DT));
|
||||
pragma Assert (Check_Signature (T, Must_Be_Secondary_DT));
|
||||
pragma Assert (Check_Index (T, Position));
|
||||
pragma Assert (Index > 0);
|
||||
OSD (T).OSD_Table (Index) := Value;
|
||||
end Set_Offset_Index;
|
||||
@ -1080,27 +1232,78 @@ package body Ada.Tags is
|
||||
-----------------------
|
||||
|
||||
procedure Set_Offset_To_Top
|
||||
(T : Tag;
|
||||
Value : System.Storage_Elements.Storage_Offset)
|
||||
(This : System.Address;
|
||||
Interface_T : Tag;
|
||||
Offset_Value : System.Storage_Elements.Storage_Offset)
|
||||
is
|
||||
Offset_To_Top_Ptr : constant Storage_Offset_Ptr :=
|
||||
To_Storage_Offset_Ptr (To_Address (T)
|
||||
- DT_Typeinfo_Ptr_Size
|
||||
- DT_Offset_To_Top_Size);
|
||||
Prim_DT : Tag;
|
||||
Sec_Base : System.Address;
|
||||
Sec_DT : Tag;
|
||||
Offset_To_Top : Storage_Offset_Ptr;
|
||||
Iface_Table : Interface_Data_Ptr;
|
||||
Obj_TSD : Type_Specific_Data_Ptr;
|
||||
begin
|
||||
pragma Assert (Check_Signature (T, Must_Be_Primary_Or_Secondary_DT));
|
||||
Offset_To_Top_Ptr.all := Value;
|
||||
if System."=" (This, System.Null_Address) then
|
||||
pragma Assert
|
||||
(Check_Signature (Interface_T, Must_Be_Primary_DT));
|
||||
pragma Assert (Offset_Value = 0);
|
||||
|
||||
Offset_To_Top :=
|
||||
To_Storage_Offset_Ptr (To_Address (Interface_T) - K_Offset_To_Top);
|
||||
Offset_To_Top.all := Offset_Value;
|
||||
return;
|
||||
end if;
|
||||
|
||||
-- "This" points to the primary DT and we must save Offset_Value in the
|
||||
-- Offset_To_Top field of the corresponding secondary dispatch table.
|
||||
|
||||
Prim_DT := To_Tag_Ptr (This).all;
|
||||
|
||||
pragma Assert
|
||||
(Check_Signature (Prim_DT, Must_Be_Primary_DT));
|
||||
|
||||
Sec_Base := This + Offset_Value;
|
||||
Sec_DT := To_Tag_Ptr (Sec_Base).all;
|
||||
Offset_To_Top :=
|
||||
To_Storage_Offset_Ptr (To_Address (Sec_DT) - K_Offset_To_Top);
|
||||
|
||||
pragma Assert
|
||||
(Check_Signature (Sec_DT, Must_Be_Primary_Or_Secondary_DT));
|
||||
|
||||
Offset_To_Top.all := Offset_Value;
|
||||
|
||||
-- Save Offset_Value in the table of interfaces of the primary DT. This
|
||||
-- data will be used by the subprogram "Displace" to give support to
|
||||
-- backward abstract interface type conversions.
|
||||
|
||||
Obj_TSD := TSD (Prim_DT);
|
||||
Iface_Table := To_Interface_Data_Ptr (Obj_TSD.Ifaces_Table_Ptr);
|
||||
|
||||
-- Register the offset in the table of interfaces
|
||||
|
||||
if Iface_Table /= null then
|
||||
for Id in 1 .. Iface_Table.Nb_Ifaces loop
|
||||
if Iface_Table.Table (Id).Iface_Tag = Interface_T then
|
||||
Iface_Table.Table (Id).Offset := Offset_Value;
|
||||
return;
|
||||
end if;
|
||||
end loop;
|
||||
end if;
|
||||
|
||||
-- If we arrive here there is some error in the run-time data structure
|
||||
|
||||
raise Program_Error;
|
||||
end Set_Offset_To_Top;
|
||||
|
||||
-------------
|
||||
-- Set_OSD --
|
||||
-------------
|
||||
|
||||
procedure Set_OSD (T : Interface_Tag; Value : System.Address) is
|
||||
OSD_Ptr : Addr_Ptr;
|
||||
procedure Set_OSD (T : Tag; Value : System.Address) is
|
||||
OSD_Ptr : constant Addr_Ptr :=
|
||||
To_Addr_Ptr (To_Address (T) - K_Typeinfo);
|
||||
begin
|
||||
pragma Assert (Check_Signature (Tag (T), Must_Be_Secondary_DT));
|
||||
OSD_Ptr := To_Addr_Ptr (To_Address (T) - DT_Typeinfo_Ptr_Size);
|
||||
pragma Assert (Check_Signature (T, Must_Be_Secondary_DT));
|
||||
OSD_Ptr.all := Value;
|
||||
end Set_OSD;
|
||||
|
||||
@ -1131,6 +1334,7 @@ package body Ada.Tags is
|
||||
Index : constant Integer := Position - Default_Prim_Op_Count;
|
||||
begin
|
||||
pragma Assert (Check_Signature (T, Must_Be_Primary_DT));
|
||||
pragma Assert (Check_Index (T, Position));
|
||||
pragma Assert (Index > 0);
|
||||
SSD (T).SSD_Table (Index).Kind := Value;
|
||||
end Set_Prim_Op_Kind;
|
||||
@ -1165,6 +1369,18 @@ package body Ada.Tags is
|
||||
TSD (T).SSD_Ptr := Value;
|
||||
end Set_SSD;
|
||||
|
||||
---------------------
|
||||
-- Set_Tagged_Kind --
|
||||
---------------------
|
||||
|
||||
procedure Set_Tagged_Kind (T : Tag; Value : Tagged_Kind) is
|
||||
Tagged_Kind_Ptr : constant System.Address :=
|
||||
To_Address (T) - K_Tagged_Kind;
|
||||
begin
|
||||
pragma Assert (Check_Signature (T, Must_Be_Primary_Or_Secondary_DT));
|
||||
To_Tagged_Kind_Ptr (Tagged_Kind_Ptr).all := Value;
|
||||
end Set_Tagged_Kind;
|
||||
|
||||
-------------
|
||||
-- Set_TSD --
|
||||
-------------
|
||||
@ -1173,7 +1389,7 @@ package body Ada.Tags is
|
||||
TSD_Ptr : Addr_Ptr;
|
||||
begin
|
||||
pragma Assert (Check_Signature (T, Must_Be_Primary_Or_Interface));
|
||||
TSD_Ptr := To_Addr_Ptr (To_Address (T) - DT_Typeinfo_Ptr_Size);
|
||||
TSD_Ptr := To_Addr_Ptr (To_Address (T) - K_Typeinfo);
|
||||
TSD_Ptr.all := Value;
|
||||
end Set_TSD;
|
||||
|
||||
@ -1183,6 +1399,7 @@ package body Ada.Tags is
|
||||
|
||||
function SSD (T : Tag) return Select_Specific_Data_Ptr is
|
||||
begin
|
||||
pragma Assert (Check_Signature (T, Must_Be_Primary_DT));
|
||||
return To_Select_Specific_Data_Ptr (TSD (T).SSD_Ptr);
|
||||
end SSD;
|
||||
|
||||
@ -1192,7 +1409,7 @@ package body Ada.Tags is
|
||||
|
||||
function Typeinfo_Ptr (T : Tag) return System.Address is
|
||||
TSD_Ptr : constant Addr_Ptr :=
|
||||
To_Addr_Ptr (To_Address (T) - DT_Typeinfo_Ptr_Size);
|
||||
To_Addr_Ptr (To_Address (T) - K_Typeinfo);
|
||||
begin
|
||||
return TSD_Ptr.all;
|
||||
end Typeinfo_Ptr;
|
||||
@ -1203,8 +1420,9 @@ package body Ada.Tags is
|
||||
|
||||
function TSD (T : Tag) return Type_Specific_Data_Ptr is
|
||||
TSD_Ptr : constant Addr_Ptr :=
|
||||
To_Addr_Ptr (To_Address (T) - DT_Typeinfo_Ptr_Size);
|
||||
To_Addr_Ptr (To_Address (T) - K_Typeinfo);
|
||||
begin
|
||||
pragma Assert (Check_Signature (T, Must_Be_Primary_Or_Interface));
|
||||
return To_Type_Specific_Data_Ptr (TSD_Ptr.all);
|
||||
end TSD;
|
||||
|
||||
|
@ -102,6 +102,11 @@ private
|
||||
|
||||
No_Tag : constant Tag := null;
|
||||
|
||||
type Interface_Data (Nb_Ifaces : Positive);
|
||||
type Interface_Data_Ptr is access all Interface_Data;
|
||||
-- Table of abstract interfaces used to give support to backward interface
|
||||
-- conversions and also to IW_Membership.
|
||||
|
||||
type Object_Specific_Data (Nb_Prim : Positive);
|
||||
type Object_Specific_Data_Ptr is access all Object_Specific_Data;
|
||||
-- Information associated with the secondary dispatch table of tagged-type
|
||||
@ -132,6 +137,18 @@ private
|
||||
POK_Task_Function,
|
||||
POK_Task_Procedure);
|
||||
|
||||
-- Tagged type kinds with respect to concurrency and limitedness
|
||||
|
||||
type Tagged_Kind is
|
||||
(TK_Abstract_Limited_Tagged,
|
||||
TK_Abstract_Tagged,
|
||||
TK_Limited_Tagged,
|
||||
TK_Protected,
|
||||
TK_Tagged,
|
||||
TK_Task);
|
||||
|
||||
type Tagged_Kind_Ptr is access all Tagged_Kind;
|
||||
|
||||
Default_Prim_Op_Count : constant Positive := 15;
|
||||
-- Number of predefined primitive operations added by the Expander for a
|
||||
-- tagged type. It is utilized for indexing in the two auxiliary tables
|
||||
@ -160,6 +177,10 @@ private
|
||||
-- return O in T'Class.
|
||||
-- end Test;
|
||||
|
||||
function Displace (This : System.Address; T : Tag) return System.Address;
|
||||
-- (Ada 2005 (AI-251): Displace "This" to point to the secondary dispatch
|
||||
-- table of T.
|
||||
|
||||
function Get_Access_Level (T : Tag) return Natural;
|
||||
-- Given the tag associated with a type, returns the accessibility level
|
||||
-- of the type.
|
||||
@ -173,7 +194,7 @@ private
|
||||
-- the external name.
|
||||
|
||||
function Get_Offset_Index
|
||||
(T : Interface_Tag;
|
||||
(T : Tag;
|
||||
Position : Positive) return Positive;
|
||||
-- Given a pointer to a secondary dispatch table (T) and a position of an
|
||||
-- operation in the DT, retrieve the corresponding operation's position in
|
||||
@ -204,6 +225,11 @@ private
|
||||
function Get_Remotely_Callable (T : Tag) return Boolean;
|
||||
-- Return the value previously set by Set_Remotely_Callable
|
||||
|
||||
function Get_Tagged_Kind (T : Tag) return Tagged_Kind;
|
||||
-- Given a pointer to either a primary or a secondary dispatch table,
|
||||
-- return the tagged kind of a type in the context of concurrency and
|
||||
-- limitedness.
|
||||
|
||||
procedure Inherit_DT (Old_T : Tag; New_T : Tag; Entry_Count : Natural);
|
||||
-- Entry point used to initialize the DT of a type knowing the tag
|
||||
-- of the direct ancestor and the number of primitive ops that are
|
||||
@ -212,7 +238,12 @@ private
|
||||
procedure Inherit_TSD (Old_Tag : Tag; New_Tag : Tag);
|
||||
-- Initialize the TSD of a type knowing the tag of the direct ancestor
|
||||
|
||||
function OSD (T : Interface_Tag) return Object_Specific_Data_Ptr;
|
||||
function Offset_To_Top
|
||||
(T : Tag) return System.Storage_Elements.Storage_Offset;
|
||||
-- Returns the current value of the offset_to_top component available in
|
||||
-- the prologue of the dispatch table.
|
||||
|
||||
function OSD (T : Tag) return Object_Specific_Data_Ptr;
|
||||
-- Ada 2005 (AI-251): Given a pointer T to a secondary dispatch table,
|
||||
-- retrieve the address of the record containing the Objet Specific
|
||||
-- Data table.
|
||||
@ -228,38 +259,63 @@ private
|
||||
pragma Export (Ada, Parent_Size, "ada__tags__parent_size");
|
||||
-- This procedure is used in s-finimp and is thus exported manually
|
||||
|
||||
procedure Register_Interface_Tag (T : Tag; Interface_T : Tag);
|
||||
procedure Register_Interface_Tag
|
||||
(T : Tag;
|
||||
Interface_T : Tag;
|
||||
Position : Positive);
|
||||
-- Ada 2005 (AI-251): Used to initialize the table of interfaces
|
||||
-- implemented by a type. Required to give support to IW_Membership.
|
||||
-- implemented by a type. Required to give support to backward interface
|
||||
-- conversions and also to IW_Membership.
|
||||
|
||||
procedure Register_Tag (T : Tag);
|
||||
-- Insert the Tag and its associated external_tag in a table for the
|
||||
-- sake of Internal_Tag
|
||||
|
||||
procedure Set_Access_Level (T : Tag; Value : Natural);
|
||||
-- Sets the accessibility level of the tagged type associated with T
|
||||
-- in its TSD.
|
||||
|
||||
procedure Set_Entry_Index (T : Tag; Position : Positive; Value : Positive);
|
||||
-- Set the entry index of a primitive operation in T's TSD table indexed
|
||||
-- by Position.
|
||||
|
||||
procedure Set_Expanded_Name (T : Tag; Value : System.Address);
|
||||
-- Set the address of the string containing the expanded name
|
||||
-- in the Dispatch table.
|
||||
|
||||
procedure Set_External_Tag (T : Tag; Value : System.Address);
|
||||
-- Set the address of the string containing the external tag
|
||||
-- in the Dispatch table.
|
||||
|
||||
procedure Set_Interface_Table (T : Tag; Value : System.Address);
|
||||
-- Ada 2005 (AI-251): Given a pointer T to a dispatch Table, stores the
|
||||
-- pointer to the table of interfaces.
|
||||
|
||||
procedure Set_Num_Prim_Ops (T : Tag; Value : Natural);
|
||||
-- Set the number of primitive operations in the dispatch table of T. This
|
||||
-- is used for debugging purposes.
|
||||
|
||||
procedure Set_Offset_Index
|
||||
(T : Interface_Tag;
|
||||
(T : Tag;
|
||||
Position : Positive;
|
||||
Value : Positive);
|
||||
-- Set the offset value of a primitive operation in a secondary dispatch
|
||||
-- table denoted by T, indexed by Position.
|
||||
|
||||
procedure Set_Offset_To_Top
|
||||
(T : Tag;
|
||||
Value : System.Storage_Elements.Storage_Offset);
|
||||
(This : System.Address;
|
||||
Interface_T : Tag;
|
||||
Offset_Value : System.Storage_Elements.Storage_Offset);
|
||||
-- Ada 2005 (AI-251): Initialize the Offset_To_Top field in the prologue of
|
||||
-- the dispatch table. In primary dispatch tables the value of this field
|
||||
-- is always 0; in secondary dispatch tables this is the offset to the base
|
||||
-- of the enclosing type.
|
||||
-- the dispatch table. In primary dispatch tables the value of "This" is
|
||||
-- not required (and the compiler passes always the Null_Address value) and
|
||||
-- the Offset_Value is always cero; in secondary dispatch tables "This"
|
||||
-- points to the object, Interface_T is the interface for which the
|
||||
-- secondary dispatch table is being initialized, and Offset_Value is the
|
||||
-- distance from "This" to the object component containing the tag of the
|
||||
-- secondary dispatch table.
|
||||
|
||||
procedure Set_OSD (T : Interface_Tag; Value : System.Address);
|
||||
procedure Set_OSD (T : Tag; Value : System.Address);
|
||||
-- Given a pointer T to a secondary dispatch table, store the pointer to
|
||||
-- the record containing the Object Specific Data generated by GNAT.
|
||||
|
||||
@ -278,26 +334,6 @@ private
|
||||
-- Set the kind of a primitive operation in T's TSD table indexed by
|
||||
-- Position.
|
||||
|
||||
procedure Set_SSD (T : Tag; Value : System.Address);
|
||||
-- Given a pointer T to a dispatch Table, stores the pointer to the record
|
||||
-- containing the Select Specific Data generated by GNAT.
|
||||
|
||||
procedure Set_TSD (T : Tag; Value : System.Address);
|
||||
-- Given a pointer T to a dispatch Table, stores the address of the record
|
||||
-- containing the Type Specific Data generated by GNAT.
|
||||
|
||||
procedure Set_Access_Level (T : Tag; Value : Natural);
|
||||
-- Sets the accessibility level of the tagged type associated with T
|
||||
-- in its TSD.
|
||||
|
||||
procedure Set_Expanded_Name (T : Tag; Value : System.Address);
|
||||
-- Set the address of the string containing the expanded name
|
||||
-- in the Dispatch table.
|
||||
|
||||
procedure Set_External_Tag (T : Tag; Value : System.Address);
|
||||
-- Set the address of the string containing the external tag
|
||||
-- in the Dispatch table.
|
||||
|
||||
procedure Set_RC_Offset (T : Tag; Value : SSE.Storage_Offset);
|
||||
-- Sets the Offset of the implicit record controller when the object
|
||||
-- has controlled components. Set to O otherwise.
|
||||
@ -306,6 +342,18 @@ private
|
||||
-- Set to true if the type has been declared in a context described
|
||||
-- in E.4 (18).
|
||||
|
||||
procedure Set_SSD (T : Tag; Value : System.Address);
|
||||
-- Given a pointer T to a dispatch Table, stores the pointer to the record
|
||||
-- containing the Select Specific Data generated by GNAT.
|
||||
|
||||
procedure Set_Tagged_Kind (T : Tag; Value : Tagged_Kind);
|
||||
-- Set the tagged kind of a type in either a primary or a secondary
|
||||
-- dispatch table denoted by T.
|
||||
|
||||
procedure Set_TSD (T : Tag; Value : System.Address);
|
||||
-- Given a pointer T to a dispatch Table, stores the address of the record
|
||||
-- containing the Type Specific Data generated by GNAT.
|
||||
|
||||
function SSD (T : Tag) return Select_Specific_Data_Ptr;
|
||||
-- Given a pointer T to a dispatch Table, retrieves the address of the
|
||||
-- record containing the Select Specific Data in T's TSD.
|
||||
@ -315,33 +363,31 @@ private
|
||||
-- record containing the Type Specific Data generated by GNAT.
|
||||
|
||||
DT_Prologue_Size : constant SSE.Storage_Count :=
|
||||
SSE.Storage_Count
|
||||
(3 * (Standard'Address_Size / System.Storage_Unit));
|
||||
SSE.Storage_Count (4 * (Standard'Address_Size / System.Storage_Unit));
|
||||
-- Size of the first part of the dispatch table
|
||||
|
||||
DT_Signature_Size : constant SSE.Storage_Count :=
|
||||
SSE.Storage_Count
|
||||
(Standard'Address_Size / System.Storage_Unit);
|
||||
SSE.Storage_Count (1 * (Standard'Address_Size / System.Storage_Unit));
|
||||
-- Size of the Signature field of the dispatch table
|
||||
|
||||
DT_Tagged_Kind_Size : constant SSE.Storage_Count :=
|
||||
SSE.Storage_Count (1 * (Standard'Address_Size / System.Storage_Unit));
|
||||
-- Size of the Tagged_Type_Kind field of the dispatch table
|
||||
|
||||
DT_Offset_To_Top_Size : constant SSE.Storage_Count :=
|
||||
SSE.Storage_Count
|
||||
(Standard'Address_Size / System.Storage_Unit);
|
||||
SSE.Storage_Count (1 * (Standard'Address_Size / System.Storage_Unit));
|
||||
-- Size of the Offset_To_Top field of the Dispatch Table
|
||||
|
||||
DT_Typeinfo_Ptr_Size : constant SSE.Storage_Count :=
|
||||
SSE.Storage_Count
|
||||
(Standard'Address_Size / System.Storage_Unit);
|
||||
SSE.Storage_Count (1 * (Standard'Address_Size / System.Storage_Unit));
|
||||
-- Size of the Typeinfo_Ptr field of the Dispatch Table
|
||||
|
||||
DT_Entry_Size : constant SSE.Storage_Count :=
|
||||
SSE.Storage_Count
|
||||
(1 * (Standard'Address_Size / System.Storage_Unit));
|
||||
SSE.Storage_Count (1 * (Standard'Address_Size / System.Storage_Unit));
|
||||
-- Size of each primitive operation entry in the Dispatch Table
|
||||
|
||||
TSD_Prologue_Size : constant SSE.Storage_Count :=
|
||||
SSE.Storage_Count
|
||||
(10 * (Standard'Address_Size / System.Storage_Unit));
|
||||
SSE.Storage_Count (10 * (Standard'Address_Size / System.Storage_Unit));
|
||||
-- Size of the first part of the type specific data
|
||||
|
||||
TSD_Entry_Size : constant SSE.Storage_Count :=
|
||||
@ -396,6 +442,9 @@ private
|
||||
function To_Address is
|
||||
new Unchecked_Conversion (Type_Specific_Data_Ptr, System.Address);
|
||||
|
||||
function To_Interface_Data_Ptr is
|
||||
new Unchecked_Conversion (System.Address, Interface_Data_Ptr);
|
||||
|
||||
function To_Object_Specific_Data_Ptr is
|
||||
new Unchecked_Conversion (System.Address, Object_Specific_Data_Ptr);
|
||||
|
||||
@ -409,10 +458,14 @@ private
|
||||
function To_Tag_Ptr is
|
||||
new Unchecked_Conversion (System.Address, Tag_Ptr);
|
||||
|
||||
function To_Tagged_Kind_Ptr is
|
||||
new Unchecked_Conversion (System.Address, Tagged_Kind_Ptr);
|
||||
|
||||
-- Primitive dispatching operations are always inlined, to facilitate
|
||||
-- use in a minimal/no run-time environment for high integrity use.
|
||||
|
||||
pragma Inline_Always (CW_Membership);
|
||||
pragma Inline_Always (Displace);
|
||||
pragma Inline_Always (IW_Membership);
|
||||
pragma Inline_Always (Get_Access_Level);
|
||||
pragma Inline_Always (Get_Entry_Index);
|
||||
@ -421,6 +474,7 @@ private
|
||||
pragma Inline_Always (Get_Prim_Op_Kind);
|
||||
pragma Inline_Always (Get_RC_Offset);
|
||||
pragma Inline_Always (Get_Remotely_Callable);
|
||||
pragma Inline_Always (Get_Tagged_Kind);
|
||||
pragma Inline_Always (Inherit_DT);
|
||||
pragma Inline_Always (Inherit_TSD);
|
||||
pragma Inline_Always (OSD);
|
||||
@ -430,6 +484,7 @@ private
|
||||
pragma Inline_Always (Set_Entry_Index);
|
||||
pragma Inline_Always (Set_Expanded_Name);
|
||||
pragma Inline_Always (Set_External_Tag);
|
||||
pragma Inline_Always (Set_Interface_Table);
|
||||
pragma Inline_Always (Set_Num_Prim_Ops);
|
||||
pragma Inline_Always (Set_Offset_Index);
|
||||
pragma Inline_Always (Set_Offset_To_Top);
|
||||
@ -440,6 +495,7 @@ private
|
||||
pragma Inline_Always (Set_OSD);
|
||||
pragma Inline_Always (Set_SSD);
|
||||
pragma Inline_Always (Set_TSD);
|
||||
pragma Inline_Always (Set_Tagged_Kind);
|
||||
pragma Inline_Always (SSD);
|
||||
pragma Inline_Always (TSD);
|
||||
|
||||
|
@ -1760,20 +1760,18 @@ package body Exp_Ch3 is
|
||||
procedure Init_Secondary_Tags_Internal (Typ : Entity_Id) is
|
||||
E : Entity_Id;
|
||||
Aux_N : Node_Id;
|
||||
Iface : Entity_Id;
|
||||
|
||||
begin
|
||||
if not Is_Interface (Typ) then
|
||||
-- Climb to the ancestor (if any) handling private types
|
||||
|
||||
-- Climb to the ancestor (if any) handling private types
|
||||
|
||||
if Present (Full_View (Etype (Typ))) then
|
||||
if Full_View (Etype (Typ)) /= Typ then
|
||||
Init_Secondary_Tags_Internal (Full_View (Etype (Typ)));
|
||||
end if;
|
||||
|
||||
elsif Etype (Typ) /= Typ then
|
||||
Init_Secondary_Tags_Internal (Etype (Typ));
|
||||
if Present (Full_View (Etype (Typ))) then
|
||||
if Full_View (Etype (Typ)) /= Typ then
|
||||
Init_Secondary_Tags_Internal (Full_View (Etype (Typ)));
|
||||
end if;
|
||||
|
||||
elsif Etype (Typ) /= Typ then
|
||||
Init_Secondary_Tags_Internal (Etype (Typ));
|
||||
end if;
|
||||
|
||||
if Present (Abstract_Interfaces (Typ))
|
||||
@ -1787,6 +1785,8 @@ package body Exp_Ch3 is
|
||||
Aux_N := Node (ADT);
|
||||
pragma Assert (Present (Aux_N));
|
||||
|
||||
Iface := Find_Interface (Typ, E);
|
||||
|
||||
-- Initialize the pointer to the secondary DT
|
||||
-- associated with the interface
|
||||
|
||||
@ -1801,15 +1801,23 @@ package body Exp_Ch3 is
|
||||
New_Reference_To (Aux_N, Loc)));
|
||||
|
||||
-- Generate:
|
||||
-- Set_Offset_To_Top (DT_Ptr, n);
|
||||
-- Set_Offset_To_Top (Init, Iface'Tag, n);
|
||||
|
||||
Append_To (Body_Stmts,
|
||||
Make_Procedure_Call_Statement (Loc,
|
||||
Name => New_Reference_To
|
||||
(RTE (RE_Set_Offset_To_Top), Loc),
|
||||
Parameter_Associations => New_List (
|
||||
Make_Attribute_Reference (Loc,
|
||||
Prefix => Make_Identifier (Loc, Name_uInit),
|
||||
Attribute_Name => Name_Address),
|
||||
|
||||
Unchecked_Convert_To (RTE (RE_Tag),
|
||||
New_Reference_To (Aux_N, Loc)),
|
||||
New_Reference_To
|
||||
(Node (First_Elmt
|
||||
(Access_Disp_Table (Iface))),
|
||||
Loc)),
|
||||
|
||||
Unchecked_Convert_To (RTE (RE_Storage_Offset),
|
||||
Make_Attribute_Reference (Loc,
|
||||
Prefix =>
|
||||
@ -2118,7 +2126,9 @@ package body Exp_Ch3 is
|
||||
|
||||
-- Case of composite component with its own Init_Proc
|
||||
|
||||
elsif Has_Non_Null_Base_Init_Proc (Typ) then
|
||||
elsif not Is_Interface (Typ)
|
||||
and then Has_Non_Null_Base_Init_Proc (Typ)
|
||||
then
|
||||
Stmts :=
|
||||
Build_Initialization_Call
|
||||
(Loc,
|
||||
@ -4743,18 +4753,15 @@ package body Exp_Ch3 is
|
||||
Append_Freeze_Actions (Def_Id, Predef_List);
|
||||
|
||||
-- Populate the two auxiliary tables used for dispatching
|
||||
-- asynchronous, conditional and timed selects for tagged
|
||||
-- asynchronous, conditional and timed selects for synchronized
|
||||
-- types that implement a limited interface.
|
||||
|
||||
if Ada_Version >= Ada_05
|
||||
and then not Is_Interface (Def_Id)
|
||||
and then not Is_Abstract (Def_Id)
|
||||
and then not Is_Controlled (Def_Id)
|
||||
and then
|
||||
Implements_Interface
|
||||
(Typ => Def_Id,
|
||||
Kind => Any_Limited_Interface,
|
||||
Check_Parent => True)
|
||||
and then Is_Concurrent_Record_Type (Def_Id)
|
||||
and then Implements_Interface (
|
||||
Typ => Def_Id,
|
||||
Kind => Any_Limited_Interface,
|
||||
Check_Parent => True)
|
||||
then
|
||||
Append_Freeze_Actions (Def_Id,
|
||||
Make_Select_Specific_Data_Table (Def_Id));
|
||||
@ -5950,26 +5957,25 @@ package body Exp_Ch3 is
|
||||
end if;
|
||||
|
||||
-- Generate the declarations for the following primitive operations:
|
||||
|
||||
-- disp_asynchronous_select
|
||||
-- disp_conditional_select
|
||||
-- disp_get_prim_op_kind
|
||||
-- disp_get_task_id
|
||||
-- disp_timed_select
|
||||
-- for limited interfaces and tagged types that implement a limited
|
||||
-- interface.
|
||||
|
||||
-- for limited interfaces and synchronized types that implement a
|
||||
-- limited interface.
|
||||
|
||||
if Ada_Version >= Ada_05
|
||||
and then
|
||||
((Is_Interface (Tag_Typ)
|
||||
and then Is_Limited_Record (Tag_Typ))
|
||||
or else
|
||||
(not Is_Abstract (Tag_Typ)
|
||||
and then not Is_Controlled (Tag_Typ)
|
||||
and then
|
||||
Implements_Interface
|
||||
(Typ => Tag_Typ,
|
||||
Kind => Any_Limited_Interface,
|
||||
Check_Parent => True)))
|
||||
((Is_Interface (Tag_Typ) and then Is_Limited_Record (Tag_Typ))
|
||||
or else
|
||||
(Is_Concurrent_Record_Type (Tag_Typ)
|
||||
and then Implements_Interface (
|
||||
Typ => Tag_Typ,
|
||||
Kind => Any_Limited_Interface,
|
||||
Check_Parent => True)))
|
||||
then
|
||||
Append_To (Res,
|
||||
Make_Subprogram_Declaration (Loc,
|
||||
@ -6360,20 +6366,18 @@ package body Exp_Ch3 is
|
||||
-- disp_get_task_id
|
||||
-- disp_timed_select
|
||||
|
||||
-- for limited interfaces and tagged types that implement a limited
|
||||
-- interface. The interface versions will have null bodies.
|
||||
-- for limited interfaces and synchronized types that implement a
|
||||
-- limited interface. The interface versions will have null bodies.
|
||||
|
||||
if Ada_Version >= Ada_05
|
||||
and then
|
||||
((Is_Interface (Tag_Typ) and then Is_Limited_Record (Tag_Typ))
|
||||
or else
|
||||
(not Is_Abstract (Tag_Typ)
|
||||
and then not Is_Controlled (Tag_Typ)
|
||||
and then
|
||||
Implements_Interface
|
||||
(Typ => Tag_Typ,
|
||||
Kind => Any_Limited_Interface,
|
||||
Check_Parent => True)))
|
||||
(Is_Concurrent_Record_Type (Tag_Typ)
|
||||
and then Implements_Interface (
|
||||
Typ => Tag_Typ,
|
||||
Kind => Any_Limited_Interface,
|
||||
Check_Parent => True)))
|
||||
then
|
||||
Append_To (Res, Make_Disp_Asynchronous_Select_Body (Tag_Typ));
|
||||
Append_To (Res, Make_Disp_Conditional_Select_Body (Tag_Typ));
|
||||
|
@ -4289,8 +4289,7 @@ package body Exp_Ch6 is
|
||||
Expand_Interface_Thunk
|
||||
(N => Prim,
|
||||
Thunk_Alias => Alias (Prim),
|
||||
Thunk_Id => Thunk_Id,
|
||||
Thunk_Tag => Iface_Tag);
|
||||
Thunk_Id => Thunk_Id);
|
||||
|
||||
Insert_After (N, New_Thunk);
|
||||
|
||||
@ -4341,8 +4340,7 @@ package body Exp_Ch6 is
|
||||
Expand_Interface_Thunk
|
||||
(N => Ancestor_Iface_Prim,
|
||||
Thunk_Alias => Prim_Op,
|
||||
Thunk_Id => Thunk_Id,
|
||||
Thunk_Tag => Iface_Tag);
|
||||
Thunk_Id => Thunk_Id);
|
||||
|
||||
Insert_After (N, New_Thunk);
|
||||
|
||||
@ -4401,8 +4399,7 @@ package body Exp_Ch6 is
|
||||
Expand_Interface_Thunk
|
||||
(N => Prim,
|
||||
Thunk_Alias => Prim,
|
||||
Thunk_Id => Thunk_Id,
|
||||
Thunk_Tag => Iface_Tag);
|
||||
Thunk_Id => Thunk_Id);
|
||||
|
||||
Insert_After (N, New_Thunk);
|
||||
Insert_After (New_Thunk,
|
||||
|
File diff suppressed because it is too large
Load Diff
File diff suppressed because it is too large
Load Diff
@ -184,11 +184,11 @@ package Exp_Disp is
|
||||
Get_Access_Level,
|
||||
Get_Entry_Index,
|
||||
Get_External_Tag,
|
||||
Get_Offset_Index,
|
||||
Get_Prim_Op_Address,
|
||||
Get_Prim_Op_Kind,
|
||||
Get_RC_Offset,
|
||||
Get_Remotely_Callable,
|
||||
Get_Tagged_Kind,
|
||||
Inherit_DT,
|
||||
Inherit_TSD,
|
||||
Register_Interface_Tag,
|
||||
@ -197,6 +197,7 @@ package Exp_Disp is
|
||||
Set_Entry_Index,
|
||||
Set_Expanded_Name,
|
||||
Set_External_Tag,
|
||||
Set_Interface_Table,
|
||||
Set_Offset_Index,
|
||||
Set_OSD,
|
||||
Set_Prim_Op_Address,
|
||||
@ -205,6 +206,7 @@ package Exp_Disp is
|
||||
Set_Remotely_Callable,
|
||||
Set_SSD,
|
||||
Set_TSD,
|
||||
Set_Tagged_Kind,
|
||||
TSD_Entry_Size,
|
||||
TSD_Prologue_Size);
|
||||
|
||||
@ -217,16 +219,17 @@ package Exp_Disp is
|
||||
-- Ada 2005 (AI-251): Displace all the actuals corresponding to class-wide
|
||||
-- interfaces to reference the interface tag of the actual object
|
||||
|
||||
procedure Expand_Interface_Conversion (N : Node_Id);
|
||||
procedure Expand_Interface_Conversion
|
||||
(N : Node_Id;
|
||||
Is_Static : Boolean := True);
|
||||
-- Ada 2005 (AI-251): N is a type-conversion node. Reference the base of
|
||||
-- the object to give access to the interface tag associated with the
|
||||
-- secondary dispatch table
|
||||
-- secondary dispatch table.
|
||||
|
||||
function Expand_Interface_Thunk
|
||||
(N : Node_Id;
|
||||
Thunk_Alias : Node_Id;
|
||||
Thunk_Id : Entity_Id;
|
||||
Thunk_Tag : Entity_Id) return Node_Id;
|
||||
Thunk_Id : Entity_Id) return Node_Id;
|
||||
-- Ada 2005 (AI-251): When a tagged type implements abstract interfaces we
|
||||
-- generate additional subprograms (thunks) to have a layout compatible
|
||||
-- with the C++ ABI. The thunk modifies the value of the first actual of
|
||||
|
220
gcc/ada/exp_sel.adb
Normal file
220
gcc/ada/exp_sel.adb
Normal file
@ -0,0 +1,220 @@
|
||||
------------------------------------------------------------------------------
|
||||
-- --
|
||||
-- GNAT COMPILER COMPONENTS --
|
||||
-- --
|
||||
-- E X P _ S E L --
|
||||
-- --
|
||||
-- B o d y --
|
||||
-- --
|
||||
-- Copyright (C) 1992-2005, Free Software Foundation, Inc. --
|
||||
-- --
|
||||
-- GNAT is free software; you can redistribute it and/or modify it under --
|
||||
-- terms of the GNU General Public License as published by the Free Soft- --
|
||||
-- ware Foundation; either version 2, or (at your option) any later ver- --
|
||||
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
|
||||
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
|
||||
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
|
||||
-- for more details. You should have received a copy of the GNU General --
|
||||
-- Public License distributed with GNAT; see file COPYING. If not, write --
|
||||
-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
|
||||
-- Boston, MA 02110-1301, USA. --
|
||||
-- --
|
||||
-- GNAT was originally developed by the GNAT team at New York University. --
|
||||
-- Extensive contributions were provided by Ada Core Technologies Inc. --
|
||||
-- --
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
with Einfo; use Einfo;
|
||||
with Nlists; use Nlists;
|
||||
with Nmake; use Nmake;
|
||||
with Rtsfind; use Rtsfind;
|
||||
with Stand; use Stand;
|
||||
with Tbuild; use Tbuild;
|
||||
|
||||
package body Exp_Sel is
|
||||
|
||||
-----------------------
|
||||
-- Build_Abort_Block --
|
||||
-----------------------
|
||||
|
||||
function Build_Abort_Block
|
||||
(Loc : Source_Ptr;
|
||||
Abr_Blk_Ent : Entity_Id;
|
||||
Cln_Blk_Ent : Entity_Id;
|
||||
Blk : Node_Id) return Node_Id
|
||||
is
|
||||
begin
|
||||
return
|
||||
Make_Block_Statement (Loc,
|
||||
Identifier => New_Reference_To (Abr_Blk_Ent, Loc),
|
||||
|
||||
Declarations => No_List,
|
||||
|
||||
Handled_Statement_Sequence =>
|
||||
Make_Handled_Sequence_Of_Statements (Loc,
|
||||
Statements =>
|
||||
New_List (
|
||||
Make_Implicit_Label_Declaration (Loc,
|
||||
Defining_Identifier =>
|
||||
Cln_Blk_Ent,
|
||||
Label_Construct =>
|
||||
Blk),
|
||||
Blk),
|
||||
|
||||
Exception_Handlers =>
|
||||
New_List (
|
||||
Make_Exception_Handler (Loc,
|
||||
Exception_Choices =>
|
||||
New_List (
|
||||
New_Reference_To (Stand.Abort_Signal, Loc)),
|
||||
Statements =>
|
||||
New_List (
|
||||
Make_Procedure_Call_Statement (Loc,
|
||||
Name =>
|
||||
New_Reference_To (RTE (
|
||||
RE_Abort_Undefer), Loc),
|
||||
Parameter_Associations => No_List))))));
|
||||
end Build_Abort_Block;
|
||||
|
||||
-------------
|
||||
-- Build_B --
|
||||
-------------
|
||||
|
||||
function Build_B
|
||||
(Loc : Source_Ptr;
|
||||
Decls : List_Id) return Entity_Id
|
||||
is
|
||||
B : constant Entity_Id := Make_Defining_Identifier (Loc,
|
||||
Chars => New_Internal_Name ('B'));
|
||||
|
||||
begin
|
||||
Append_To (Decls,
|
||||
Make_Object_Declaration (Loc,
|
||||
Defining_Identifier =>
|
||||
B,
|
||||
Object_Definition =>
|
||||
New_Reference_To (Standard_Boolean, Loc),
|
||||
Expression =>
|
||||
New_Reference_To (Standard_False, Loc)));
|
||||
|
||||
return B;
|
||||
end Build_B;
|
||||
|
||||
-------------
|
||||
-- Build_C --
|
||||
-------------
|
||||
|
||||
function Build_C
|
||||
(Loc : Source_Ptr;
|
||||
Decls : List_Id) return Entity_Id
|
||||
is
|
||||
C : constant Entity_Id := Make_Defining_Identifier (Loc,
|
||||
Chars => New_Internal_Name ('C'));
|
||||
|
||||
begin
|
||||
Append_To (Decls,
|
||||
Make_Object_Declaration (Loc,
|
||||
Defining_Identifier =>
|
||||
C,
|
||||
Object_Definition =>
|
||||
New_Reference_To (RTE (RE_Prim_Op_Kind), Loc)));
|
||||
|
||||
return C;
|
||||
end Build_C;
|
||||
|
||||
-------------------------
|
||||
-- Build_Cleanup_Block --
|
||||
-------------------------
|
||||
|
||||
function Build_Cleanup_Block
|
||||
(Loc : Source_Ptr;
|
||||
Blk_Ent : Entity_Id;
|
||||
Stmts : List_Id;
|
||||
Clean_Ent : Entity_Id) return Node_Id
|
||||
is
|
||||
Cleanup_Block : constant Node_Id :=
|
||||
Make_Block_Statement (Loc,
|
||||
Identifier => New_Reference_To (Blk_Ent, Loc),
|
||||
Declarations => No_List,
|
||||
Handled_Statement_Sequence =>
|
||||
Make_Handled_Sequence_Of_Statements (Loc,
|
||||
Statements => Stmts),
|
||||
Is_Asynchronous_Call_Block => True);
|
||||
|
||||
begin
|
||||
Set_Entry_Cancel_Parameter (Blk_Ent, Clean_Ent);
|
||||
|
||||
return Cleanup_Block;
|
||||
end Build_Cleanup_Block;
|
||||
|
||||
-------------
|
||||
-- Build_K --
|
||||
-------------
|
||||
|
||||
function Build_K
|
||||
(Loc : Source_Ptr;
|
||||
Decls : List_Id;
|
||||
Obj : Entity_Id) return Entity_Id
|
||||
is
|
||||
K : constant Entity_Id := Make_Defining_Identifier (Loc,
|
||||
Chars => New_Internal_Name ('K'));
|
||||
|
||||
begin
|
||||
Append_To (Decls,
|
||||
Make_Object_Declaration (Loc,
|
||||
Defining_Identifier => K,
|
||||
Object_Definition =>
|
||||
New_Reference_To (RTE (RE_Tagged_Kind), Loc),
|
||||
Expression =>
|
||||
Make_Function_Call (Loc,
|
||||
Name => New_Reference_To (RTE (RE_Get_Tagged_Kind), Loc),
|
||||
Parameter_Associations => New_List (
|
||||
Unchecked_Convert_To (RTE (RE_Tag), Obj)))));
|
||||
|
||||
return K;
|
||||
end Build_K;
|
||||
|
||||
-------------
|
||||
-- Build_S --
|
||||
-------------
|
||||
|
||||
function Build_S
|
||||
(Loc : Source_Ptr;
|
||||
Decls : List_Id) return Entity_Id
|
||||
is
|
||||
S : constant Entity_Id := Make_Defining_Identifier (Loc,
|
||||
Chars => New_Internal_Name ('S'));
|
||||
|
||||
begin
|
||||
Append_To (Decls,
|
||||
Make_Object_Declaration (Loc,
|
||||
Defining_Identifier => S,
|
||||
Object_Definition =>
|
||||
New_Reference_To (Standard_Integer, Loc)));
|
||||
|
||||
return S;
|
||||
end Build_S;
|
||||
|
||||
------------------------
|
||||
-- Build_S_Assignment --
|
||||
------------------------
|
||||
|
||||
function Build_S_Assignment
|
||||
(Loc : Source_Ptr;
|
||||
S : Entity_Id;
|
||||
Obj : Entity_Id;
|
||||
Call_Ent : Entity_Id) return Node_Id
|
||||
is
|
||||
begin
|
||||
return
|
||||
Make_Assignment_Statement (Loc,
|
||||
Name => New_Reference_To (S, Loc),
|
||||
Expression =>
|
||||
Make_Function_Call (Loc,
|
||||
Name => New_Reference_To (RTE (RE_Get_Offset_Index), Loc),
|
||||
Parameter_Associations => New_List (
|
||||
Unchecked_Convert_To (RTE (RE_Tag), Obj),
|
||||
Make_Integer_Literal (Loc, DT_Position (Call_Ent)))));
|
||||
end Build_S_Assignment;
|
||||
|
||||
end Exp_Sel;
|
113
gcc/ada/exp_sel.ads
Normal file
113
gcc/ada/exp_sel.ads
Normal file
@ -0,0 +1,113 @@
|
||||
------------------------------------------------------------------------------
|
||||
-- --
|
||||
-- GNAT COMPILER COMPONENTS --
|
||||
-- --
|
||||
-- E X P _ S E L --
|
||||
-- --
|
||||
-- S p e c --
|
||||
-- --
|
||||
-- Copyright (C) 1992-2005, Free Software Foundation, Inc. --
|
||||
-- --
|
||||
-- GNAT is free software; you can redistribute it and/or modify it under --
|
||||
-- terms of the GNU General Public License as published by the Free Soft- --
|
||||
-- ware Foundation; either version 2, or (at your option) any later ver- --
|
||||
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
|
||||
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
|
||||
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
|
||||
-- for more details. You should have received a copy of the GNU General --
|
||||
-- Public License distributed with GNAT; see file COPYING. If not, write --
|
||||
-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
|
||||
-- Boston, MA 02110-1301, USA. --
|
||||
-- --
|
||||
-- GNAT was originally developed by the GNAT team at New York University. --
|
||||
-- Extensive contributions were provided by Ada Core Technologies Inc. --
|
||||
-- --
|
||||
------------------------------------------------------------------------------
|
||||
|
||||
-- Routines used in Chapter 9 for the expansion of dispatching triggers in
|
||||
-- select statements (Ada 2005: AI-345)
|
||||
|
||||
with Types; use Types;
|
||||
|
||||
package Exp_Sel is
|
||||
|
||||
function Build_Abort_Block
|
||||
(Loc : Source_Ptr;
|
||||
Abr_Blk_Ent : Entity_Id;
|
||||
Cln_Blk_Ent : Entity_Id;
|
||||
Blk : Node_Id) return Node_Id;
|
||||
-- Generate:
|
||||
-- begin
|
||||
-- Blk
|
||||
-- exception
|
||||
-- when Abort_Signal => Abort_Undefer;
|
||||
-- end;
|
||||
-- Abr_Blk_Ent is the name of the generated block, Cln_Blk_Ent is the name
|
||||
-- of the encapsulated cleanup block, Blk is the actual block name.
|
||||
|
||||
function Build_B
|
||||
(Loc : Source_Ptr;
|
||||
Decls : List_Id) return Entity_Id;
|
||||
-- Generate:
|
||||
-- B : Boolean := False;
|
||||
-- Append the object declaration to the list and return its defining
|
||||
-- identifier.
|
||||
|
||||
function Build_C
|
||||
(Loc : Source_Ptr;
|
||||
Decls : List_Id) return Entity_Id;
|
||||
-- Generate:
|
||||
-- C : Ada.Tags.Prim_Op_Kind;
|
||||
-- Append the object declaration to the list and return its defining
|
||||
-- identifier.
|
||||
|
||||
function Build_Cleanup_Block
|
||||
(Loc : Source_Ptr;
|
||||
Blk_Ent : Entity_Id;
|
||||
Stmts : List_Id;
|
||||
Clean_Ent : Entity_Id) return Node_Id;
|
||||
-- Generate:
|
||||
-- declare
|
||||
-- procedure _clean is
|
||||
-- begin
|
||||
-- ...
|
||||
-- end _clean;
|
||||
-- begin
|
||||
-- Stmts
|
||||
-- at end
|
||||
-- _clean;
|
||||
-- end;
|
||||
-- Blk_Ent is the name of the generated block, Stmts is the list of
|
||||
-- encapsulated statements and Clean_Ent is the parameter to the
|
||||
-- _clean procedure.
|
||||
|
||||
function Build_K
|
||||
(Loc : Source_Ptr;
|
||||
Decls : List_Id;
|
||||
Obj : Entity_Id) return Entity_Id;
|
||||
-- Generate
|
||||
-- K : Ada.Tags.Tagged_Kind :=
|
||||
-- Ada.Tags.Get_Tagged_Kind (Ada.Tags.Tag (Obj));
|
||||
-- where Obj is the pointer to a secondary table. Append the object
|
||||
-- declaration to the list and return its defining identifier.
|
||||
|
||||
function Build_S
|
||||
(Loc : Source_Ptr;
|
||||
Decls : List_Id) return Entity_Id;
|
||||
-- Generate:
|
||||
-- S : Integer;
|
||||
-- Append the object declaration to the list and return its defining
|
||||
-- identifier.
|
||||
|
||||
function Build_S_Assignment
|
||||
(Loc : Source_Ptr;
|
||||
S : Entity_Id;
|
||||
Obj : Entity_Id;
|
||||
Call_Ent : Entity_Id) return Node_Id;
|
||||
-- Generate:
|
||||
-- S := Ada.Tags.Get_Offset_Index (
|
||||
-- Ada.Tags.Tag (Obj), DT_Position (Call_Ent));
|
||||
-- where Obj is the pointer to a secondary table, Call_Ent is the entity
|
||||
-- of the dispatching call name. Return the generated assignment.
|
||||
|
||||
end Exp_Sel;
|
@ -120,6 +120,7 @@ package Rtsfind is
|
||||
Ada_Streams,
|
||||
Ada_Tags,
|
||||
Ada_Task_Identification,
|
||||
Ada_Task_Termination,
|
||||
|
||||
-- Children of Ada.Calendar
|
||||
|
||||
@ -488,10 +489,12 @@ package Rtsfind is
|
||||
|
||||
RE_Stream_Access, -- Ada.Streams.Stream_IO
|
||||
|
||||
RE_Abstract_Interface, -- Ada.Tags
|
||||
RE_Addr_Ptr, -- Ada.Tags
|
||||
RE_Address_Array, -- Ada.Tags
|
||||
RE_CW_Membership, -- Ada.Tags
|
||||
RE_IW_Membership, -- Ada.Tags
|
||||
RE_Descendant_Tag, -- Ada.Tags
|
||||
RE_Displace, -- Ada.Tags
|
||||
RE_DT_Entry_Size, -- Ada.Tags
|
||||
RE_DT_Prologue_Size, -- Ada.Tags
|
||||
RE_External_Tag, -- Ada.Tags
|
||||
@ -503,11 +506,16 @@ package Rtsfind is
|
||||
RE_Get_Prim_Op_Kind, -- Ada.Tags
|
||||
RE_Get_RC_Offset, -- Ada.Tags
|
||||
RE_Get_Remotely_Callable, -- Ada.Tags
|
||||
RE_Get_Tagged_Kind, -- Ada.Tags
|
||||
RE_Inherit_DT, -- Ada.Tags
|
||||
RE_Inherit_TSD, -- Ada.Tags
|
||||
RE_Interface_Data, -- Ada.Tags
|
||||
RE_Interface_Tag, -- Ada.Tags
|
||||
RE_Internal_Tag, -- Ada.Tags
|
||||
RE_Is_Descendant_At_Same_Level, -- Ada.Tags
|
||||
RE_IW_Membership, -- Ada.Tags
|
||||
RE_Object_Specific_Data, -- Ada.Tags
|
||||
RE_Offset_To_Top, -- Ada.Tags
|
||||
RE_POK_Function, -- Ada.Tags
|
||||
RE_POK_Procedure, -- Ada.Tags
|
||||
RE_POK_Protected_Entry, -- Ada.Tags
|
||||
@ -517,13 +525,16 @@ package Rtsfind is
|
||||
RE_POK_Task_Function, -- Ada.Tags
|
||||
RE_POK_Task_Procedure, -- Ada.Tags
|
||||
RE_Prim_Op_Kind, -- Ada.Tags
|
||||
RE_Primary_DT, -- Ada.Tags
|
||||
RE_Register_Interface_Tag, -- Ada.Tags
|
||||
RE_Register_Tag, -- Ada.Tags
|
||||
RE_Secondary_DT, -- Ada.Tags
|
||||
RE_Select_Specific_Data, -- Ada.Tags
|
||||
RE_Set_Access_Level, -- Ada.Tags
|
||||
RE_Set_Entry_Index, -- Ada.Tags
|
||||
RE_Set_Expanded_Name, -- Ada.Tags
|
||||
RE_Set_External_Tag, -- Ada.Tags
|
||||
RE_Set_Interface_Table, -- Ada.Tags
|
||||
RE_Set_Num_Prim_Ops, -- Ada.Tags
|
||||
RE_Set_Offset_Index, -- Ada.Tags
|
||||
RE_Set_Offset_To_Top, -- Ada.Tags
|
||||
@ -533,17 +544,20 @@ package Rtsfind is
|
||||
RE_Set_RC_Offset, -- Ada.Tags
|
||||
RE_Set_Remotely_Callable, -- Ada.Tags
|
||||
RE_Set_SSD, -- Ada.Tags
|
||||
RE_Set_Tagged_Kind, -- Ada.Tags
|
||||
RE_Set_TSD, -- Ada.Tags
|
||||
RE_Tag, -- Ada.Tags
|
||||
RE_Tag_Error, -- Ada.Tags
|
||||
RE_Tagged_Kind, -- Ada.Tags
|
||||
RE_TSD_Entry_Size, -- Ada.Tags
|
||||
RE_TSD_Prologue_Size, -- Ada.Tags
|
||||
RE_Interface_Tag, -- Ada.Tags
|
||||
RE_Tag, -- Ada.Tags
|
||||
RE_Address_Array, -- Ada.Tags
|
||||
RE_TK_Abstract_Limited_Tagged, -- Ada.Tags
|
||||
RE_TK_Abstract_Tagged, -- Ada.Tags
|
||||
RE_TK_Limited_Tagged, -- Ada.Tags
|
||||
RE_TK_Protected, -- Ada.Tags
|
||||
RE_TK_Tagged, -- Ada.Tags
|
||||
RE_TK_Task, -- Ada.Tags
|
||||
RE_Valid_Signature, -- Ada.Tags
|
||||
RE_Primary_DT, -- Ada.Tags
|
||||
RE_Secondary_DT, -- Ada.Tags
|
||||
RE_Abstract_Interface, -- Ada.Tags
|
||||
|
||||
RE_Abort_Task, -- Ada.Task_Identification
|
||||
RE_Current_Task, -- Ada.Task_Identification
|
||||
@ -1629,10 +1643,12 @@ package Rtsfind is
|
||||
|
||||
RE_Stream_Access => Ada_Streams_Stream_IO,
|
||||
|
||||
RE_Abstract_Interface => Ada_Tags,
|
||||
RE_Addr_Ptr => Ada_Tags,
|
||||
RE_Address_Array => Ada_Tags,
|
||||
RE_CW_Membership => Ada_Tags,
|
||||
RE_IW_Membership => Ada_Tags,
|
||||
RE_Descendant_Tag => Ada_Tags,
|
||||
RE_Displace => Ada_Tags,
|
||||
RE_DT_Entry_Size => Ada_Tags,
|
||||
RE_DT_Prologue_Size => Ada_Tags,
|
||||
RE_External_Tag => Ada_Tags,
|
||||
@ -1644,11 +1660,16 @@ package Rtsfind is
|
||||
RE_Get_Prim_Op_Kind => Ada_Tags,
|
||||
RE_Get_RC_Offset => Ada_Tags,
|
||||
RE_Get_Remotely_Callable => Ada_Tags,
|
||||
RE_Get_Tagged_Kind => Ada_Tags,
|
||||
RE_Inherit_DT => Ada_Tags,
|
||||
RE_Inherit_TSD => Ada_Tags,
|
||||
RE_Interface_Data => Ada_Tags,
|
||||
RE_Interface_Tag => Ada_Tags,
|
||||
RE_Internal_Tag => Ada_Tags,
|
||||
RE_Is_Descendant_At_Same_Level => Ada_Tags,
|
||||
RE_IW_Membership => Ada_Tags,
|
||||
RE_Object_Specific_Data => Ada_Tags,
|
||||
RE_Offset_To_Top => Ada_Tags,
|
||||
RE_POK_Function => Ada_Tags,
|
||||
RE_POK_Procedure => Ada_Tags,
|
||||
RE_POK_Protected_Entry => Ada_Tags,
|
||||
@ -1658,13 +1679,16 @@ package Rtsfind is
|
||||
RE_POK_Task_Function => Ada_Tags,
|
||||
RE_POK_Task_Procedure => Ada_Tags,
|
||||
RE_Prim_Op_Kind => Ada_Tags,
|
||||
RE_Primary_DT => Ada_Tags,
|
||||
RE_Register_Interface_Tag => Ada_Tags,
|
||||
RE_Register_Tag => Ada_Tags,
|
||||
RE_Secondary_DT => Ada_Tags,
|
||||
RE_Select_Specific_Data => Ada_Tags,
|
||||
RE_Set_Access_Level => Ada_Tags,
|
||||
RE_Set_Entry_Index => Ada_Tags,
|
||||
RE_Set_Expanded_Name => Ada_Tags,
|
||||
RE_Set_External_Tag => Ada_Tags,
|
||||
RE_Set_Interface_Table => Ada_Tags,
|
||||
RE_Set_Num_Prim_Ops => Ada_Tags,
|
||||
RE_Set_Offset_Index => Ada_Tags,
|
||||
RE_Set_Offset_To_Top => Ada_Tags,
|
||||
@ -1674,17 +1698,20 @@ package Rtsfind is
|
||||
RE_Set_RC_Offset => Ada_Tags,
|
||||
RE_Set_Remotely_Callable => Ada_Tags,
|
||||
RE_Set_SSD => Ada_Tags,
|
||||
RE_Set_Tagged_Kind => Ada_Tags,
|
||||
RE_Set_TSD => Ada_Tags,
|
||||
RE_Tag => Ada_Tags,
|
||||
RE_Tag_Error => Ada_Tags,
|
||||
RE_Tagged_Kind => Ada_Tags,
|
||||
RE_TSD_Entry_Size => Ada_Tags,
|
||||
RE_TSD_Prologue_Size => Ada_Tags,
|
||||
RE_Interface_Tag => Ada_Tags,
|
||||
RE_Tag => Ada_Tags,
|
||||
RE_Address_Array => Ada_Tags,
|
||||
RE_TK_Abstract_Limited_Tagged => Ada_Tags,
|
||||
RE_TK_Abstract_Tagged => Ada_Tags,
|
||||
RE_TK_Limited_Tagged => Ada_Tags,
|
||||
RE_TK_Protected => Ada_Tags,
|
||||
RE_TK_Tagged => Ada_Tags,
|
||||
RE_TK_Task => Ada_Tags,
|
||||
RE_Valid_Signature => Ada_Tags,
|
||||
RE_Primary_DT => Ada_Tags,
|
||||
RE_Secondary_DT => Ada_Tags,
|
||||
RE_Abstract_Interface => Ada_Tags,
|
||||
|
||||
RE_Abort_Task => Ada_Task_Identification,
|
||||
RE_Current_Task => Ada_Task_Identification,
|
||||
|
Loading…
x
Reference in New Issue
Block a user