------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
-- --
|
-- --
|
-- GNAT COMPILER COMPONENTS --
|
-- GNAT COMPILER COMPONENTS --
|
-- --
|
-- --
|
-- E X P _ A T A G --
|
-- E X P _ A T A G --
|
-- --
|
-- --
|
-- S p e c --
|
-- S p e c --
|
-- --
|
-- --
|
-- Copyright (C) 2006-2009, Free Software Foundation, Inc. --
|
-- Copyright (C) 2006-2009, Free Software Foundation, Inc. --
|
-- --
|
-- --
|
-- GNAT is free software; you can redistribute it and/or modify it under --
|
-- 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- --
|
-- terms of the GNU General Public License as published by the Free Soft- --
|
-- ware Foundation; either version 3, or (at your option) any later ver- --
|
-- ware Foundation; either version 3, or (at your option) any later ver- --
|
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
|
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
|
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
|
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
|
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
|
-- 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 --
|
-- for more details. You should have received a copy of the GNU General --
|
-- Public License distributed with GNAT; see file COPYING3. If not, go to --
|
-- Public License distributed with GNAT; see file COPYING3. If not, go to --
|
-- http://www.gnu.org/licenses for a complete copy of the license. --
|
-- http://www.gnu.org/licenses for a complete copy of the license. --
|
-- --
|
-- --
|
-- GNAT was originally developed by the GNAT team at New York University. --
|
-- GNAT was originally developed by the GNAT team at New York University. --
|
-- Extensive contributions were provided by Ada Core Technologies Inc. --
|
-- Extensive contributions were provided by Ada Core Technologies Inc. --
|
-- --
|
-- --
|
------------------------------------------------------------------------------
|
------------------------------------------------------------------------------
|
|
|
with Atree; use Atree;
|
with Atree; use Atree;
|
with Einfo; use Einfo;
|
with Einfo; use Einfo;
|
with Elists; use Elists;
|
with Elists; use Elists;
|
with Exp_Util; use Exp_Util;
|
with Exp_Util; use Exp_Util;
|
with Namet; use Namet;
|
with Namet; use Namet;
|
with Nlists; use Nlists;
|
with Nlists; use Nlists;
|
with Nmake; use Nmake;
|
with Nmake; use Nmake;
|
with Rtsfind; use Rtsfind;
|
with Rtsfind; use Rtsfind;
|
with Sinfo; use Sinfo;
|
with Sinfo; use Sinfo;
|
with Sem_Aux; use Sem_Aux;
|
with Sem_Aux; use Sem_Aux;
|
with Sem_Util; use Sem_Util;
|
with Sem_Util; use Sem_Util;
|
with Stand; use Stand;
|
with Stand; use Stand;
|
with Snames; use Snames;
|
with Snames; use Snames;
|
with Tbuild; use Tbuild;
|
with Tbuild; use Tbuild;
|
|
|
package body Exp_Atag is
|
package body Exp_Atag is
|
|
|
-----------------------
|
-----------------------
|
-- Local Subprograms --
|
-- Local Subprograms --
|
-----------------------
|
-----------------------
|
|
|
function Build_DT
|
function Build_DT
|
(Loc : Source_Ptr;
|
(Loc : Source_Ptr;
|
Tag_Node : Node_Id) return Node_Id;
|
Tag_Node : Node_Id) return Node_Id;
|
-- Build code that displaces the Tag to reference the base of the wrapper
|
-- Build code that displaces the Tag to reference the base of the wrapper
|
-- record
|
-- record
|
--
|
--
|
-- Generates:
|
-- Generates:
|
-- To_Dispatch_Table_Ptr
|
-- To_Dispatch_Table_Ptr
|
-- (To_Address (Tag_Node) - Tag_Node.Prims_Ptr'Position);
|
-- (To_Address (Tag_Node) - Tag_Node.Prims_Ptr'Position);
|
|
|
function Build_TSD
|
function Build_TSD
|
(Loc : Source_Ptr;
|
(Loc : Source_Ptr;
|
Tag_Node_Addr : Node_Id) return Node_Id;
|
Tag_Node_Addr : Node_Id) return Node_Id;
|
-- Build code that retrieves the address of the record containing the Type
|
-- Build code that retrieves the address of the record containing the Type
|
-- Specific Data generated by GNAT.
|
-- Specific Data generated by GNAT.
|
--
|
--
|
-- Generate: To_Type_Specific_Data_Ptr
|
-- Generate: To_Type_Specific_Data_Ptr
|
-- (To_Addr_Ptr (Tag_Node_Addr - Typeinfo_Offset).all);
|
-- (To_Addr_Ptr (Tag_Node_Addr - Typeinfo_Offset).all);
|
|
|
------------------------------------------------
|
------------------------------------------------
|
-- Build_Common_Dispatching_Select_Statements --
|
-- Build_Common_Dispatching_Select_Statements --
|
------------------------------------------------
|
------------------------------------------------
|
|
|
procedure Build_Common_Dispatching_Select_Statements
|
procedure Build_Common_Dispatching_Select_Statements
|
(Loc : Source_Ptr;
|
(Loc : Source_Ptr;
|
DT_Ptr : Entity_Id;
|
DT_Ptr : Entity_Id;
|
Stmts : List_Id)
|
Stmts : List_Id)
|
is
|
is
|
begin
|
begin
|
-- Generate:
|
-- Generate:
|
-- C := get_prim_op_kind (tag! (<type>VP), S);
|
-- C := get_prim_op_kind (tag! (<type>VP), S);
|
|
|
-- where C is the out parameter capturing the call kind and S is the
|
-- where C is the out parameter capturing the call kind and S is the
|
-- dispatch table slot number.
|
-- dispatch table slot number.
|
|
|
Append_To (Stmts,
|
Append_To (Stmts,
|
Make_Assignment_Statement (Loc,
|
Make_Assignment_Statement (Loc,
|
Name =>
|
Name =>
|
Make_Identifier (Loc, Name_uC),
|
Make_Identifier (Loc, Name_uC),
|
Expression =>
|
Expression =>
|
Make_Function_Call (Loc,
|
Make_Function_Call (Loc,
|
Name => New_Occurrence_Of (RTE (RE_Get_Prim_Op_Kind), Loc),
|
Name => New_Occurrence_Of (RTE (RE_Get_Prim_Op_Kind), Loc),
|
Parameter_Associations => New_List (
|
Parameter_Associations => New_List (
|
Unchecked_Convert_To (RTE (RE_Tag),
|
Unchecked_Convert_To (RTE (RE_Tag),
|
New_Reference_To (DT_Ptr, Loc)),
|
New_Reference_To (DT_Ptr, Loc)),
|
Make_Identifier (Loc, Name_uS)))));
|
Make_Identifier (Loc, Name_uS)))));
|
|
|
-- Generate:
|
-- Generate:
|
|
|
-- if C = POK_Procedure
|
-- if C = POK_Procedure
|
-- or else C = POK_Protected_Procedure
|
-- or else C = POK_Protected_Procedure
|
-- or else C = POK_Task_Procedure;
|
-- or else C = POK_Task_Procedure;
|
-- then
|
-- then
|
-- F := True;
|
-- F := True;
|
-- return;
|
-- return;
|
|
|
-- where F is the out parameter capturing the status of a potential
|
-- where F is the out parameter capturing the status of a potential
|
-- entry call.
|
-- entry call.
|
|
|
Append_To (Stmts,
|
Append_To (Stmts,
|
Make_If_Statement (Loc,
|
Make_If_Statement (Loc,
|
|
|
Condition =>
|
Condition =>
|
Make_Or_Else (Loc,
|
Make_Or_Else (Loc,
|
Left_Opnd =>
|
Left_Opnd =>
|
Make_Op_Eq (Loc,
|
Make_Op_Eq (Loc,
|
Left_Opnd =>
|
Left_Opnd =>
|
Make_Identifier (Loc, Name_uC),
|
Make_Identifier (Loc, Name_uC),
|
Right_Opnd =>
|
Right_Opnd =>
|
New_Reference_To (RTE (RE_POK_Procedure), Loc)),
|
New_Reference_To (RTE (RE_POK_Procedure), Loc)),
|
Right_Opnd =>
|
Right_Opnd =>
|
Make_Or_Else (Loc,
|
Make_Or_Else (Loc,
|
Left_Opnd =>
|
Left_Opnd =>
|
Make_Op_Eq (Loc,
|
Make_Op_Eq (Loc,
|
Left_Opnd =>
|
Left_Opnd =>
|
Make_Identifier (Loc, Name_uC),
|
Make_Identifier (Loc, Name_uC),
|
Right_Opnd =>
|
Right_Opnd =>
|
New_Reference_To (RTE (
|
New_Reference_To (RTE (
|
RE_POK_Protected_Procedure), Loc)),
|
RE_POK_Protected_Procedure), Loc)),
|
Right_Opnd =>
|
Right_Opnd =>
|
Make_Op_Eq (Loc,
|
Make_Op_Eq (Loc,
|
Left_Opnd =>
|
Left_Opnd =>
|
Make_Identifier (Loc, Name_uC),
|
Make_Identifier (Loc, Name_uC),
|
Right_Opnd =>
|
Right_Opnd =>
|
New_Reference_To (RTE (
|
New_Reference_To (RTE (
|
RE_POK_Task_Procedure), Loc)))),
|
RE_POK_Task_Procedure), Loc)))),
|
|
|
Then_Statements =>
|
Then_Statements =>
|
New_List (
|
New_List (
|
Make_Assignment_Statement (Loc,
|
Make_Assignment_Statement (Loc,
|
Name => Make_Identifier (Loc, Name_uF),
|
Name => Make_Identifier (Loc, Name_uF),
|
Expression => New_Reference_To (Standard_True, Loc)),
|
Expression => New_Reference_To (Standard_True, Loc)),
|
Make_Simple_Return_Statement (Loc))));
|
Make_Simple_Return_Statement (Loc))));
|
end Build_Common_Dispatching_Select_Statements;
|
end Build_Common_Dispatching_Select_Statements;
|
|
|
-------------------------
|
-------------------------
|
-- Build_CW_Membership --
|
-- Build_CW_Membership --
|
-------------------------
|
-------------------------
|
|
|
procedure Build_CW_Membership
|
procedure Build_CW_Membership
|
(Loc : Source_Ptr;
|
(Loc : Source_Ptr;
|
Obj_Tag_Node : in out Node_Id;
|
Obj_Tag_Node : in out Node_Id;
|
Typ_Tag_Node : Node_Id;
|
Typ_Tag_Node : Node_Id;
|
Related_Nod : Node_Id;
|
Related_Nod : Node_Id;
|
New_Node : out Node_Id)
|
New_Node : out Node_Id)
|
is
|
is
|
Tag_Addr : constant Entity_Id := Make_Defining_Identifier (Loc,
|
Tag_Addr : constant Entity_Id := Make_Defining_Identifier (Loc,
|
New_Internal_Name ('D'));
|
New_Internal_Name ('D'));
|
Obj_TSD : constant Entity_Id := Make_Defining_Identifier (Loc,
|
Obj_TSD : constant Entity_Id := Make_Defining_Identifier (Loc,
|
New_Internal_Name ('D'));
|
New_Internal_Name ('D'));
|
Typ_TSD : constant Entity_Id := Make_Defining_Identifier (Loc,
|
Typ_TSD : constant Entity_Id := Make_Defining_Identifier (Loc,
|
New_Internal_Name ('D'));
|
New_Internal_Name ('D'));
|
Index : constant Entity_Id := Make_Defining_Identifier (Loc,
|
Index : constant Entity_Id := Make_Defining_Identifier (Loc,
|
New_Internal_Name ('D'));
|
New_Internal_Name ('D'));
|
|
|
begin
|
begin
|
-- Generate:
|
-- Generate:
|
|
|
-- Tag_Addr : constant Tag := Address!(Obj_Tag);
|
-- Tag_Addr : constant Tag := Address!(Obj_Tag);
|
-- Obj_TSD : constant Type_Specific_Data_Ptr
|
-- Obj_TSD : constant Type_Specific_Data_Ptr
|
-- := Build_TSD (Tag_Addr);
|
-- := Build_TSD (Tag_Addr);
|
-- Typ_TSD : constant Type_Specific_Data_Ptr
|
-- Typ_TSD : constant Type_Specific_Data_Ptr
|
-- := Build_TSD (Address!(Typ_Tag));
|
-- := Build_TSD (Address!(Typ_Tag));
|
-- Index : constant Integer := Obj_TSD.Idepth - Typ_TSD.Idepth
|
-- Index : constant Integer := Obj_TSD.Idepth - Typ_TSD.Idepth
|
-- Index > 0 and then Obj_TSD.Tags_Table (Index) = Typ'Tag
|
-- Index > 0 and then Obj_TSD.Tags_Table (Index) = Typ'Tag
|
|
|
Insert_Action (Related_Nod,
|
Insert_Action (Related_Nod,
|
Make_Object_Declaration (Loc,
|
Make_Object_Declaration (Loc,
|
Defining_Identifier => Tag_Addr,
|
Defining_Identifier => Tag_Addr,
|
Constant_Present => True,
|
Constant_Present => True,
|
Object_Definition => New_Reference_To (RTE (RE_Address), Loc),
|
Object_Definition => New_Reference_To (RTE (RE_Address), Loc),
|
Expression => Unchecked_Convert_To
|
Expression => Unchecked_Convert_To
|
(RTE (RE_Address), Obj_Tag_Node)));
|
(RTE (RE_Address), Obj_Tag_Node)));
|
|
|
-- Unchecked_Convert_To relocates Obj_Tag_Node and therefore we must
|
-- Unchecked_Convert_To relocates Obj_Tag_Node and therefore we must
|
-- update it.
|
-- update it.
|
|
|
Obj_Tag_Node := Expression (Expression (Parent (Tag_Addr)));
|
Obj_Tag_Node := Expression (Expression (Parent (Tag_Addr)));
|
|
|
Insert_Action (Related_Nod,
|
Insert_Action (Related_Nod,
|
Make_Object_Declaration (Loc,
|
Make_Object_Declaration (Loc,
|
Defining_Identifier => Obj_TSD,
|
Defining_Identifier => Obj_TSD,
|
Constant_Present => True,
|
Constant_Present => True,
|
Object_Definition => New_Reference_To
|
Object_Definition => New_Reference_To
|
(RTE (RE_Type_Specific_Data_Ptr), Loc),
|
(RTE (RE_Type_Specific_Data_Ptr), Loc),
|
Expression => Build_TSD (Loc, New_Reference_To (Tag_Addr, Loc))));
|
Expression => Build_TSD (Loc, New_Reference_To (Tag_Addr, Loc))));
|
|
|
Insert_Action (Related_Nod,
|
Insert_Action (Related_Nod,
|
Make_Object_Declaration (Loc,
|
Make_Object_Declaration (Loc,
|
Defining_Identifier => Typ_TSD,
|
Defining_Identifier => Typ_TSD,
|
Constant_Present => True,
|
Constant_Present => True,
|
Object_Definition => New_Reference_To
|
Object_Definition => New_Reference_To
|
(RTE (RE_Type_Specific_Data_Ptr), Loc),
|
(RTE (RE_Type_Specific_Data_Ptr), Loc),
|
Expression => Build_TSD (Loc,
|
Expression => Build_TSD (Loc,
|
Unchecked_Convert_To (RTE (RE_Address),
|
Unchecked_Convert_To (RTE (RE_Address),
|
Typ_Tag_Node))));
|
Typ_Tag_Node))));
|
|
|
Insert_Action (Related_Nod,
|
Insert_Action (Related_Nod,
|
Make_Object_Declaration (Loc,
|
Make_Object_Declaration (Loc,
|
Defining_Identifier => Index,
|
Defining_Identifier => Index,
|
Constant_Present => True,
|
Constant_Present => True,
|
Object_Definition => New_Occurrence_Of (Standard_Integer, Loc),
|
Object_Definition => New_Occurrence_Of (Standard_Integer, Loc),
|
Expression =>
|
Expression =>
|
Make_Op_Subtract (Loc,
|
Make_Op_Subtract (Loc,
|
Left_Opnd =>
|
Left_Opnd =>
|
Make_Selected_Component (Loc,
|
Make_Selected_Component (Loc,
|
Prefix => New_Reference_To (Obj_TSD, Loc),
|
Prefix => New_Reference_To (Obj_TSD, Loc),
|
Selector_Name =>
|
Selector_Name =>
|
New_Reference_To
|
New_Reference_To
|
(RTE_Record_Component (RE_Idepth), Loc)),
|
(RTE_Record_Component (RE_Idepth), Loc)),
|
|
|
Right_Opnd =>
|
Right_Opnd =>
|
Make_Selected_Component (Loc,
|
Make_Selected_Component (Loc,
|
Prefix => New_Reference_To (Typ_TSD, Loc),
|
Prefix => New_Reference_To (Typ_TSD, Loc),
|
Selector_Name =>
|
Selector_Name =>
|
New_Reference_To
|
New_Reference_To
|
(RTE_Record_Component (RE_Idepth), Loc)))));
|
(RTE_Record_Component (RE_Idepth), Loc)))));
|
|
|
New_Node :=
|
New_Node :=
|
Make_And_Then (Loc,
|
Make_And_Then (Loc,
|
Left_Opnd =>
|
Left_Opnd =>
|
Make_Op_Ge (Loc,
|
Make_Op_Ge (Loc,
|
Left_Opnd => New_Occurrence_Of (Index, Loc),
|
Left_Opnd => New_Occurrence_Of (Index, Loc),
|
Right_Opnd => Make_Integer_Literal (Loc, Uint_0)),
|
Right_Opnd => Make_Integer_Literal (Loc, Uint_0)),
|
|
|
Right_Opnd =>
|
Right_Opnd =>
|
Make_Op_Eq (Loc,
|
Make_Op_Eq (Loc,
|
Left_Opnd =>
|
Left_Opnd =>
|
Make_Indexed_Component (Loc,
|
Make_Indexed_Component (Loc,
|
Prefix =>
|
Prefix =>
|
Make_Selected_Component (Loc,
|
Make_Selected_Component (Loc,
|
Prefix => New_Reference_To (Obj_TSD, Loc),
|
Prefix => New_Reference_To (Obj_TSD, Loc),
|
Selector_Name =>
|
Selector_Name =>
|
New_Reference_To
|
New_Reference_To
|
(RTE_Record_Component (RE_Tags_Table), Loc)),
|
(RTE_Record_Component (RE_Tags_Table), Loc)),
|
Expressions =>
|
Expressions =>
|
New_List (New_Occurrence_Of (Index, Loc))),
|
New_List (New_Occurrence_Of (Index, Loc))),
|
|
|
Right_Opnd => Typ_Tag_Node));
|
Right_Opnd => Typ_Tag_Node));
|
end Build_CW_Membership;
|
end Build_CW_Membership;
|
|
|
--------------
|
--------------
|
-- Build_DT --
|
-- Build_DT --
|
--------------
|
--------------
|
|
|
function Build_DT
|
function Build_DT
|
(Loc : Source_Ptr;
|
(Loc : Source_Ptr;
|
Tag_Node : Node_Id) return Node_Id
|
Tag_Node : Node_Id) return Node_Id
|
is
|
is
|
begin
|
begin
|
return
|
return
|
Make_Function_Call (Loc,
|
Make_Function_Call (Loc,
|
Name => New_Reference_To (RTE (RE_DT), Loc),
|
Name => New_Reference_To (RTE (RE_DT), Loc),
|
Parameter_Associations => New_List (
|
Parameter_Associations => New_List (
|
Unchecked_Convert_To (RTE (RE_Tag), Tag_Node)));
|
Unchecked_Convert_To (RTE (RE_Tag), Tag_Node)));
|
end Build_DT;
|
end Build_DT;
|
|
|
----------------------------
|
----------------------------
|
-- Build_Get_Access_Level --
|
-- Build_Get_Access_Level --
|
----------------------------
|
----------------------------
|
|
|
function Build_Get_Access_Level
|
function Build_Get_Access_Level
|
(Loc : Source_Ptr;
|
(Loc : Source_Ptr;
|
Tag_Node : Node_Id) return Node_Id
|
Tag_Node : Node_Id) return Node_Id
|
is
|
is
|
begin
|
begin
|
return
|
return
|
Make_Selected_Component (Loc,
|
Make_Selected_Component (Loc,
|
Prefix =>
|
Prefix =>
|
Build_TSD (Loc,
|
Build_TSD (Loc,
|
Unchecked_Convert_To (RTE (RE_Address), Tag_Node)),
|
Unchecked_Convert_To (RTE (RE_Address), Tag_Node)),
|
Selector_Name =>
|
Selector_Name =>
|
New_Reference_To
|
New_Reference_To
|
(RTE_Record_Component (RE_Access_Level), Loc));
|
(RTE_Record_Component (RE_Access_Level), Loc));
|
end Build_Get_Access_Level;
|
end Build_Get_Access_Level;
|
|
|
------------------------------------------
|
------------------------------------------
|
-- Build_Get_Predefined_Prim_Op_Address --
|
-- Build_Get_Predefined_Prim_Op_Address --
|
------------------------------------------
|
------------------------------------------
|
|
|
procedure Build_Get_Predefined_Prim_Op_Address
|
procedure Build_Get_Predefined_Prim_Op_Address
|
(Loc : Source_Ptr;
|
(Loc : Source_Ptr;
|
Position : Uint;
|
Position : Uint;
|
Tag_Node : in out Node_Id;
|
Tag_Node : in out Node_Id;
|
New_Node : out Node_Id)
|
New_Node : out Node_Id)
|
is
|
is
|
Ctrl_Tag : Node_Id;
|
Ctrl_Tag : Node_Id;
|
|
|
begin
|
begin
|
Ctrl_Tag := Unchecked_Convert_To (RTE (RE_Address), Tag_Node);
|
Ctrl_Tag := Unchecked_Convert_To (RTE (RE_Address), Tag_Node);
|
|
|
-- Unchecked_Convert_To relocates the controlling tag node and therefore
|
-- Unchecked_Convert_To relocates the controlling tag node and therefore
|
-- we must update it.
|
-- we must update it.
|
|
|
Tag_Node := Expression (Ctrl_Tag);
|
Tag_Node := Expression (Ctrl_Tag);
|
|
|
-- Build code that retrieves the address of the dispatch table
|
-- Build code that retrieves the address of the dispatch table
|
-- containing the predefined Ada primitives:
|
-- containing the predefined Ada primitives:
|
--
|
--
|
-- Generate:
|
-- Generate:
|
-- To_Predef_Prims_Table_Ptr
|
-- To_Predef_Prims_Table_Ptr
|
-- (To_Addr_Ptr (To_Address (Tag) - Predef_Prims_Offset).all);
|
-- (To_Addr_Ptr (To_Address (Tag) - Predef_Prims_Offset).all);
|
|
|
New_Node :=
|
New_Node :=
|
Make_Indexed_Component (Loc,
|
Make_Indexed_Component (Loc,
|
Prefix =>
|
Prefix =>
|
Unchecked_Convert_To (RTE (RE_Predef_Prims_Table_Ptr),
|
Unchecked_Convert_To (RTE (RE_Predef_Prims_Table_Ptr),
|
Make_Explicit_Dereference (Loc,
|
Make_Explicit_Dereference (Loc,
|
Unchecked_Convert_To (RTE (RE_Addr_Ptr),
|
Unchecked_Convert_To (RTE (RE_Addr_Ptr),
|
Make_Function_Call (Loc,
|
Make_Function_Call (Loc,
|
Name =>
|
Name =>
|
Make_Expanded_Name (Loc,
|
Make_Expanded_Name (Loc,
|
Chars => Name_Op_Subtract,
|
Chars => Name_Op_Subtract,
|
Prefix =>
|
Prefix =>
|
New_Reference_To
|
New_Reference_To
|
(RTU_Entity (System_Storage_Elements), Loc),
|
(RTU_Entity (System_Storage_Elements), Loc),
|
Selector_Name =>
|
Selector_Name =>
|
Make_Identifier (Loc,
|
Make_Identifier (Loc,
|
Chars => Name_Op_Subtract)),
|
Chars => Name_Op_Subtract)),
|
Parameter_Associations => New_List (
|
Parameter_Associations => New_List (
|
Ctrl_Tag,
|
Ctrl_Tag,
|
New_Reference_To (RTE (RE_DT_Predef_Prims_Offset),
|
New_Reference_To (RTE (RE_DT_Predef_Prims_Offset),
|
Loc)))))),
|
Loc)))))),
|
Expressions =>
|
Expressions =>
|
New_List (Make_Integer_Literal (Loc, Position)));
|
New_List (Make_Integer_Literal (Loc, Position)));
|
end Build_Get_Predefined_Prim_Op_Address;
|
end Build_Get_Predefined_Prim_Op_Address;
|
|
|
-------------------------
|
-------------------------
|
-- Build_Inherit_Prims --
|
-- Build_Inherit_Prims --
|
-------------------------
|
-------------------------
|
|
|
function Build_Inherit_Prims
|
function Build_Inherit_Prims
|
(Loc : Source_Ptr;
|
(Loc : Source_Ptr;
|
Typ : Entity_Id;
|
Typ : Entity_Id;
|
Old_Tag_Node : Node_Id;
|
Old_Tag_Node : Node_Id;
|
New_Tag_Node : Node_Id;
|
New_Tag_Node : Node_Id;
|
Num_Prims : Nat) return Node_Id
|
Num_Prims : Nat) return Node_Id
|
is
|
is
|
begin
|
begin
|
if RTE_Available (RE_DT) then
|
if RTE_Available (RE_DT) then
|
return
|
return
|
Make_Assignment_Statement (Loc,
|
Make_Assignment_Statement (Loc,
|
Name =>
|
Name =>
|
Make_Slice (Loc,
|
Make_Slice (Loc,
|
Prefix =>
|
Prefix =>
|
Make_Selected_Component (Loc,
|
Make_Selected_Component (Loc,
|
Prefix =>
|
Prefix =>
|
Build_DT (Loc, New_Tag_Node),
|
Build_DT (Loc, New_Tag_Node),
|
Selector_Name =>
|
Selector_Name =>
|
New_Reference_To
|
New_Reference_To
|
(RTE_Record_Component (RE_Prims_Ptr), Loc)),
|
(RTE_Record_Component (RE_Prims_Ptr), Loc)),
|
Discrete_Range =>
|
Discrete_Range =>
|
Make_Range (Loc,
|
Make_Range (Loc,
|
Low_Bound => Make_Integer_Literal (Loc, 1),
|
Low_Bound => Make_Integer_Literal (Loc, 1),
|
High_Bound => Make_Integer_Literal (Loc, Num_Prims))),
|
High_Bound => Make_Integer_Literal (Loc, Num_Prims))),
|
|
|
Expression =>
|
Expression =>
|
Make_Slice (Loc,
|
Make_Slice (Loc,
|
Prefix =>
|
Prefix =>
|
Make_Selected_Component (Loc,
|
Make_Selected_Component (Loc,
|
Prefix =>
|
Prefix =>
|
Build_DT (Loc, Old_Tag_Node),
|
Build_DT (Loc, Old_Tag_Node),
|
Selector_Name =>
|
Selector_Name =>
|
New_Reference_To
|
New_Reference_To
|
(RTE_Record_Component (RE_Prims_Ptr), Loc)),
|
(RTE_Record_Component (RE_Prims_Ptr), Loc)),
|
Discrete_Range =>
|
Discrete_Range =>
|
Make_Range (Loc,
|
Make_Range (Loc,
|
Low_Bound => Make_Integer_Literal (Loc, 1),
|
Low_Bound => Make_Integer_Literal (Loc, 1),
|
High_Bound => Make_Integer_Literal (Loc, Num_Prims))));
|
High_Bound => Make_Integer_Literal (Loc, Num_Prims))));
|
else
|
else
|
return
|
return
|
Make_Assignment_Statement (Loc,
|
Make_Assignment_Statement (Loc,
|
Name =>
|
Name =>
|
Make_Slice (Loc,
|
Make_Slice (Loc,
|
Prefix =>
|
Prefix =>
|
Unchecked_Convert_To
|
Unchecked_Convert_To
|
(Node (Last_Elmt (Access_Disp_Table (Typ))),
|
(Node (Last_Elmt (Access_Disp_Table (Typ))),
|
New_Tag_Node),
|
New_Tag_Node),
|
Discrete_Range =>
|
Discrete_Range =>
|
Make_Range (Loc,
|
Make_Range (Loc,
|
Low_Bound => Make_Integer_Literal (Loc, 1),
|
Low_Bound => Make_Integer_Literal (Loc, 1),
|
High_Bound => Make_Integer_Literal (Loc, Num_Prims))),
|
High_Bound => Make_Integer_Literal (Loc, Num_Prims))),
|
|
|
Expression =>
|
Expression =>
|
Make_Slice (Loc,
|
Make_Slice (Loc,
|
Prefix =>
|
Prefix =>
|
Unchecked_Convert_To
|
Unchecked_Convert_To
|
(Node (Last_Elmt (Access_Disp_Table (Typ))),
|
(Node (Last_Elmt (Access_Disp_Table (Typ))),
|
Old_Tag_Node),
|
Old_Tag_Node),
|
Discrete_Range =>
|
Discrete_Range =>
|
Make_Range (Loc,
|
Make_Range (Loc,
|
Low_Bound => Make_Integer_Literal (Loc, 1),
|
Low_Bound => Make_Integer_Literal (Loc, 1),
|
High_Bound => Make_Integer_Literal (Loc, Num_Prims))));
|
High_Bound => Make_Integer_Literal (Loc, Num_Prims))));
|
end if;
|
end if;
|
end Build_Inherit_Prims;
|
end Build_Inherit_Prims;
|
|
|
-------------------------------
|
-------------------------------
|
-- Build_Get_Prim_Op_Address --
|
-- Build_Get_Prim_Op_Address --
|
-------------------------------
|
-------------------------------
|
|
|
procedure Build_Get_Prim_Op_Address
|
procedure Build_Get_Prim_Op_Address
|
(Loc : Source_Ptr;
|
(Loc : Source_Ptr;
|
Typ : Entity_Id;
|
Typ : Entity_Id;
|
Position : Uint;
|
Position : Uint;
|
Tag_Node : in out Node_Id;
|
Tag_Node : in out Node_Id;
|
New_Node : out Node_Id)
|
New_Node : out Node_Id)
|
is
|
is
|
New_Prefix : Node_Id;
|
New_Prefix : Node_Id;
|
|
|
begin
|
begin
|
pragma Assert
|
pragma Assert
|
(Position <= DT_Entry_Count (First_Tag_Component (Typ)));
|
(Position <= DT_Entry_Count (First_Tag_Component (Typ)));
|
|
|
-- At the end of the Access_Disp_Table list we have the type
|
-- At the end of the Access_Disp_Table list we have the type
|
-- declaration required to convert the tag into a pointer to
|
-- declaration required to convert the tag into a pointer to
|
-- the prims_ptr table (see Freeze_Record_Type).
|
-- the prims_ptr table (see Freeze_Record_Type).
|
|
|
New_Prefix :=
|
New_Prefix :=
|
Unchecked_Convert_To
|
Unchecked_Convert_To
|
(Node (Last_Elmt (Access_Disp_Table (Typ))), Tag_Node);
|
(Node (Last_Elmt (Access_Disp_Table (Typ))), Tag_Node);
|
|
|
-- Unchecked_Convert_To relocates the controlling tag node and therefore
|
-- Unchecked_Convert_To relocates the controlling tag node and therefore
|
-- we must update it.
|
-- we must update it.
|
|
|
Tag_Node := Expression (New_Prefix);
|
Tag_Node := Expression (New_Prefix);
|
|
|
New_Node :=
|
New_Node :=
|
Make_Indexed_Component (Loc,
|
Make_Indexed_Component (Loc,
|
Prefix => New_Prefix,
|
Prefix => New_Prefix,
|
Expressions => New_List (Make_Integer_Literal (Loc, Position)));
|
Expressions => New_List (Make_Integer_Literal (Loc, Position)));
|
end Build_Get_Prim_Op_Address;
|
end Build_Get_Prim_Op_Address;
|
|
|
-----------------------------
|
-----------------------------
|
-- Build_Get_Transportable --
|
-- Build_Get_Transportable --
|
-----------------------------
|
-----------------------------
|
|
|
function Build_Get_Transportable
|
function Build_Get_Transportable
|
(Loc : Source_Ptr;
|
(Loc : Source_Ptr;
|
Tag_Node : Node_Id) return Node_Id
|
Tag_Node : Node_Id) return Node_Id
|
is
|
is
|
begin
|
begin
|
return
|
return
|
Make_Selected_Component (Loc,
|
Make_Selected_Component (Loc,
|
Prefix =>
|
Prefix =>
|
Build_TSD (Loc,
|
Build_TSD (Loc,
|
Unchecked_Convert_To (RTE (RE_Address), Tag_Node)),
|
Unchecked_Convert_To (RTE (RE_Address), Tag_Node)),
|
Selector_Name =>
|
Selector_Name =>
|
New_Reference_To
|
New_Reference_To
|
(RTE_Record_Component (RE_Transportable), Loc));
|
(RTE_Record_Component (RE_Transportable), Loc));
|
end Build_Get_Transportable;
|
end Build_Get_Transportable;
|
|
|
------------------------------------
|
------------------------------------
|
-- Build_Inherit_Predefined_Prims --
|
-- Build_Inherit_Predefined_Prims --
|
------------------------------------
|
------------------------------------
|
|
|
function Build_Inherit_Predefined_Prims
|
function Build_Inherit_Predefined_Prims
|
(Loc : Source_Ptr;
|
(Loc : Source_Ptr;
|
Old_Tag_Node : Node_Id;
|
Old_Tag_Node : Node_Id;
|
New_Tag_Node : Node_Id) return Node_Id
|
New_Tag_Node : Node_Id) return Node_Id
|
is
|
is
|
begin
|
begin
|
return
|
return
|
Make_Assignment_Statement (Loc,
|
Make_Assignment_Statement (Loc,
|
Name =>
|
Name =>
|
Make_Slice (Loc,
|
Make_Slice (Loc,
|
Prefix =>
|
Prefix =>
|
Make_Explicit_Dereference (Loc,
|
Make_Explicit_Dereference (Loc,
|
Unchecked_Convert_To (RTE (RE_Predef_Prims_Table_Ptr),
|
Unchecked_Convert_To (RTE (RE_Predef_Prims_Table_Ptr),
|
Make_Explicit_Dereference (Loc,
|
Make_Explicit_Dereference (Loc,
|
Unchecked_Convert_To (RTE (RE_Addr_Ptr),
|
Unchecked_Convert_To (RTE (RE_Addr_Ptr),
|
New_Tag_Node)))),
|
New_Tag_Node)))),
|
Discrete_Range => Make_Range (Loc,
|
Discrete_Range => Make_Range (Loc,
|
Make_Integer_Literal (Loc, Uint_1),
|
Make_Integer_Literal (Loc, Uint_1),
|
New_Reference_To (RTE (RE_Max_Predef_Prims), Loc))),
|
New_Reference_To (RTE (RE_Max_Predef_Prims), Loc))),
|
|
|
Expression =>
|
Expression =>
|
Make_Slice (Loc,
|
Make_Slice (Loc,
|
Prefix =>
|
Prefix =>
|
Make_Explicit_Dereference (Loc,
|
Make_Explicit_Dereference (Loc,
|
Unchecked_Convert_To (RTE (RE_Predef_Prims_Table_Ptr),
|
Unchecked_Convert_To (RTE (RE_Predef_Prims_Table_Ptr),
|
Make_Explicit_Dereference (Loc,
|
Make_Explicit_Dereference (Loc,
|
Unchecked_Convert_To (RTE (RE_Addr_Ptr),
|
Unchecked_Convert_To (RTE (RE_Addr_Ptr),
|
Old_Tag_Node)))),
|
Old_Tag_Node)))),
|
Discrete_Range =>
|
Discrete_Range =>
|
Make_Range (Loc,
|
Make_Range (Loc,
|
Make_Integer_Literal (Loc, 1),
|
Make_Integer_Literal (Loc, 1),
|
New_Reference_To (RTE (RE_Max_Predef_Prims), Loc))));
|
New_Reference_To (RTE (RE_Max_Predef_Prims), Loc))));
|
end Build_Inherit_Predefined_Prims;
|
end Build_Inherit_Predefined_Prims;
|
|
|
-------------------------
|
-------------------------
|
-- Build_Offset_To_Top --
|
-- Build_Offset_To_Top --
|
-------------------------
|
-------------------------
|
|
|
function Build_Offset_To_Top
|
function Build_Offset_To_Top
|
(Loc : Source_Ptr;
|
(Loc : Source_Ptr;
|
This_Node : Node_Id) return Node_Id
|
This_Node : Node_Id) return Node_Id
|
is
|
is
|
Tag_Node : Node_Id;
|
Tag_Node : Node_Id;
|
|
|
begin
|
begin
|
Tag_Node :=
|
Tag_Node :=
|
Make_Explicit_Dereference (Loc,
|
Make_Explicit_Dereference (Loc,
|
Unchecked_Convert_To (RTE (RE_Tag_Ptr), This_Node));
|
Unchecked_Convert_To (RTE (RE_Tag_Ptr), This_Node));
|
|
|
return
|
return
|
Make_Explicit_Dereference (Loc,
|
Make_Explicit_Dereference (Loc,
|
Unchecked_Convert_To (RTE (RE_Offset_To_Top_Ptr),
|
Unchecked_Convert_To (RTE (RE_Offset_To_Top_Ptr),
|
Make_Function_Call (Loc,
|
Make_Function_Call (Loc,
|
Name =>
|
Name =>
|
Make_Expanded_Name (Loc,
|
Make_Expanded_Name (Loc,
|
Chars => Name_Op_Subtract,
|
Chars => Name_Op_Subtract,
|
Prefix => New_Reference_To
|
Prefix => New_Reference_To
|
(RTU_Entity (System_Storage_Elements), Loc),
|
(RTU_Entity (System_Storage_Elements), Loc),
|
Selector_Name => Make_Identifier (Loc,
|
Selector_Name => Make_Identifier (Loc,
|
Chars => Name_Op_Subtract)),
|
Chars => Name_Op_Subtract)),
|
Parameter_Associations => New_List (
|
Parameter_Associations => New_List (
|
Unchecked_Convert_To (RTE (RE_Address), Tag_Node),
|
Unchecked_Convert_To (RTE (RE_Address), Tag_Node),
|
New_Reference_To (RTE (RE_DT_Offset_To_Top_Offset),
|
New_Reference_To (RTE (RE_DT_Offset_To_Top_Offset),
|
Loc)))));
|
Loc)))));
|
end Build_Offset_To_Top;
|
end Build_Offset_To_Top;
|
|
|
------------------------------------------
|
------------------------------------------
|
-- Build_Set_Predefined_Prim_Op_Address --
|
-- Build_Set_Predefined_Prim_Op_Address --
|
------------------------------------------
|
------------------------------------------
|
|
|
function Build_Set_Predefined_Prim_Op_Address
|
function Build_Set_Predefined_Prim_Op_Address
|
(Loc : Source_Ptr;
|
(Loc : Source_Ptr;
|
Tag_Node : Node_Id;
|
Tag_Node : Node_Id;
|
Position : Uint;
|
Position : Uint;
|
Address_Node : Node_Id) return Node_Id
|
Address_Node : Node_Id) return Node_Id
|
is
|
is
|
begin
|
begin
|
return
|
return
|
Make_Assignment_Statement (Loc,
|
Make_Assignment_Statement (Loc,
|
Name =>
|
Name =>
|
Make_Indexed_Component (Loc,
|
Make_Indexed_Component (Loc,
|
Prefix =>
|
Prefix =>
|
Unchecked_Convert_To (RTE (RE_Predef_Prims_Table_Ptr),
|
Unchecked_Convert_To (RTE (RE_Predef_Prims_Table_Ptr),
|
Make_Explicit_Dereference (Loc,
|
Make_Explicit_Dereference (Loc,
|
Unchecked_Convert_To (RTE (RE_Addr_Ptr), Tag_Node))),
|
Unchecked_Convert_To (RTE (RE_Addr_Ptr), Tag_Node))),
|
Expressions =>
|
Expressions =>
|
New_List (Make_Integer_Literal (Loc, Position))),
|
New_List (Make_Integer_Literal (Loc, Position))),
|
|
|
Expression => Address_Node);
|
Expression => Address_Node);
|
end Build_Set_Predefined_Prim_Op_Address;
|
end Build_Set_Predefined_Prim_Op_Address;
|
|
|
-------------------------------
|
-------------------------------
|
-- Build_Set_Prim_Op_Address --
|
-- Build_Set_Prim_Op_Address --
|
-------------------------------
|
-------------------------------
|
|
|
function Build_Set_Prim_Op_Address
|
function Build_Set_Prim_Op_Address
|
(Loc : Source_Ptr;
|
(Loc : Source_Ptr;
|
Typ : Entity_Id;
|
Typ : Entity_Id;
|
Tag_Node : Node_Id;
|
Tag_Node : Node_Id;
|
Position : Uint;
|
Position : Uint;
|
Address_Node : Node_Id) return Node_Id
|
Address_Node : Node_Id) return Node_Id
|
is
|
is
|
Ctrl_Tag : Node_Id := Tag_Node;
|
Ctrl_Tag : Node_Id := Tag_Node;
|
New_Node : Node_Id;
|
New_Node : Node_Id;
|
|
|
begin
|
begin
|
Build_Get_Prim_Op_Address (Loc, Typ, Position, Ctrl_Tag, New_Node);
|
Build_Get_Prim_Op_Address (Loc, Typ, Position, Ctrl_Tag, New_Node);
|
|
|
return
|
return
|
Make_Assignment_Statement (Loc,
|
Make_Assignment_Statement (Loc,
|
Name => New_Node,
|
Name => New_Node,
|
Expression => Address_Node);
|
Expression => Address_Node);
|
end Build_Set_Prim_Op_Address;
|
end Build_Set_Prim_Op_Address;
|
|
|
-----------------------------
|
-----------------------------
|
-- Build_Set_Size_Function --
|
-- Build_Set_Size_Function --
|
-----------------------------
|
-----------------------------
|
|
|
function Build_Set_Size_Function
|
function Build_Set_Size_Function
|
(Loc : Source_Ptr;
|
(Loc : Source_Ptr;
|
Tag_Node : Node_Id;
|
Tag_Node : Node_Id;
|
Size_Func : Entity_Id) return Node_Id is
|
Size_Func : Entity_Id) return Node_Id is
|
begin
|
begin
|
pragma Assert (Chars (Size_Func) = Name_uSize
|
pragma Assert (Chars (Size_Func) = Name_uSize
|
and then RTE_Record_Component_Available (RE_Size_Func));
|
and then RTE_Record_Component_Available (RE_Size_Func));
|
return
|
return
|
Make_Assignment_Statement (Loc,
|
Make_Assignment_Statement (Loc,
|
Name =>
|
Name =>
|
Make_Selected_Component (Loc,
|
Make_Selected_Component (Loc,
|
Prefix =>
|
Prefix =>
|
Build_TSD (Loc,
|
Build_TSD (Loc,
|
Unchecked_Convert_To (RTE (RE_Address), Tag_Node)),
|
Unchecked_Convert_To (RTE (RE_Address), Tag_Node)),
|
Selector_Name =>
|
Selector_Name =>
|
New_Reference_To
|
New_Reference_To
|
(RTE_Record_Component (RE_Size_Func), Loc)),
|
(RTE_Record_Component (RE_Size_Func), Loc)),
|
Expression =>
|
Expression =>
|
Unchecked_Convert_To (RTE (RE_Size_Ptr),
|
Unchecked_Convert_To (RTE (RE_Size_Ptr),
|
Make_Attribute_Reference (Loc,
|
Make_Attribute_Reference (Loc,
|
Prefix => New_Reference_To (Size_Func, Loc),
|
Prefix => New_Reference_To (Size_Func, Loc),
|
Attribute_Name => Name_Unrestricted_Access)));
|
Attribute_Name => Name_Unrestricted_Access)));
|
end Build_Set_Size_Function;
|
end Build_Set_Size_Function;
|
|
|
------------------------------------
|
------------------------------------
|
-- Build_Set_Static_Offset_To_Top --
|
-- Build_Set_Static_Offset_To_Top --
|
------------------------------------
|
------------------------------------
|
|
|
function Build_Set_Static_Offset_To_Top
|
function Build_Set_Static_Offset_To_Top
|
(Loc : Source_Ptr;
|
(Loc : Source_Ptr;
|
Iface_Tag : Node_Id;
|
Iface_Tag : Node_Id;
|
Offset_Value : Node_Id) return Node_Id is
|
Offset_Value : Node_Id) return Node_Id is
|
begin
|
begin
|
return
|
return
|
Make_Assignment_Statement (Loc,
|
Make_Assignment_Statement (Loc,
|
Make_Explicit_Dereference (Loc,
|
Make_Explicit_Dereference (Loc,
|
Unchecked_Convert_To (RTE (RE_Offset_To_Top_Ptr),
|
Unchecked_Convert_To (RTE (RE_Offset_To_Top_Ptr),
|
Make_Function_Call (Loc,
|
Make_Function_Call (Loc,
|
Name =>
|
Name =>
|
Make_Expanded_Name (Loc,
|
Make_Expanded_Name (Loc,
|
Chars => Name_Op_Subtract,
|
Chars => Name_Op_Subtract,
|
Prefix => New_Reference_To
|
Prefix => New_Reference_To
|
(RTU_Entity (System_Storage_Elements), Loc),
|
(RTU_Entity (System_Storage_Elements), Loc),
|
Selector_Name => Make_Identifier (Loc,
|
Selector_Name => Make_Identifier (Loc,
|
Chars => Name_Op_Subtract)),
|
Chars => Name_Op_Subtract)),
|
Parameter_Associations => New_List (
|
Parameter_Associations => New_List (
|
Unchecked_Convert_To (RTE (RE_Address), Iface_Tag),
|
Unchecked_Convert_To (RTE (RE_Address), Iface_Tag),
|
New_Reference_To (RTE (RE_DT_Offset_To_Top_Offset),
|
New_Reference_To (RTE (RE_DT_Offset_To_Top_Offset),
|
Loc))))),
|
Loc))))),
|
Offset_Value);
|
Offset_Value);
|
end Build_Set_Static_Offset_To_Top;
|
end Build_Set_Static_Offset_To_Top;
|
|
|
---------------
|
---------------
|
-- Build_TSD --
|
-- Build_TSD --
|
---------------
|
---------------
|
|
|
function Build_TSD
|
function Build_TSD
|
(Loc : Source_Ptr;
|
(Loc : Source_Ptr;
|
Tag_Node_Addr : Node_Id) return Node_Id is
|
Tag_Node_Addr : Node_Id) return Node_Id is
|
begin
|
begin
|
return
|
return
|
Unchecked_Convert_To (RTE (RE_Type_Specific_Data_Ptr),
|
Unchecked_Convert_To (RTE (RE_Type_Specific_Data_Ptr),
|
Make_Explicit_Dereference (Loc,
|
Make_Explicit_Dereference (Loc,
|
Prefix => Unchecked_Convert_To (RTE (RE_Addr_Ptr),
|
Prefix => Unchecked_Convert_To (RTE (RE_Addr_Ptr),
|
Make_Function_Call (Loc,
|
Make_Function_Call (Loc,
|
Name =>
|
Name =>
|
Make_Expanded_Name (Loc,
|
Make_Expanded_Name (Loc,
|
Chars => Name_Op_Subtract,
|
Chars => Name_Op_Subtract,
|
Prefix =>
|
Prefix =>
|
New_Reference_To
|
New_Reference_To
|
(RTU_Entity (System_Storage_Elements), Loc),
|
(RTU_Entity (System_Storage_Elements), Loc),
|
Selector_Name =>
|
Selector_Name =>
|
Make_Identifier (Loc,
|
Make_Identifier (Loc,
|
Chars => Name_Op_Subtract)),
|
Chars => Name_Op_Subtract)),
|
|
|
Parameter_Associations => New_List (
|
Parameter_Associations => New_List (
|
Tag_Node_Addr,
|
Tag_Node_Addr,
|
New_Reference_To
|
New_Reference_To
|
(RTE (RE_DT_Typeinfo_Ptr_Size), Loc))))));
|
(RTE (RE_DT_Typeinfo_Ptr_Size), Loc))))));
|
end Build_TSD;
|
end Build_TSD;
|
|
|
end Exp_Atag;
|
end Exp_Atag;
|
|
|