return Ecount;
end Build_Entry_Count_Expression;
- ------------------------------
- -- Build_Master_Declaration --
- ------------------------------
-
- function Build_Master_Declaration (Loc : Source_Ptr) return Node_Id is
- Master_Decl : Node_Id;
-
- begin
- -- Generate a dummy master if tasks or tasking hierarchies are
- -- prohibited.
-
- -- _Master : constant Integer := Library_Task_Level;
-
- if not Tasking_Allowed
- or else Restrictions.Set (No_Task_Hierarchy)
- or else not RTE_Available (RE_Current_Master)
- then
- Master_Decl :=
- Make_Object_Declaration (Loc,
- Defining_Identifier =>
- Make_Defining_Identifier (Loc, Name_uMaster),
- Constant_Present => True,
- Object_Definition =>
- New_Occurrence_Of (Standard_Integer, Loc),
- Expression =>
- Make_Integer_Literal (Loc, Library_Task_Level));
-
- -- Generate:
- -- _master : constant Integer := Current_Master.all;
-
- else
- Master_Decl :=
- Make_Object_Declaration (Loc,
- Defining_Identifier =>
- Make_Defining_Identifier (Loc, Name_uMaster),
- Constant_Present => True,
- Object_Definition =>
- New_Occurrence_Of (Standard_Integer, Loc),
- Expression =>
- Make_Explicit_Dereference (Loc,
- New_Occurrence_Of (RTE (RE_Current_Master), Loc)));
- end if;
-
- return Master_Decl;
- end Build_Master_Declaration;
-
---------------------------
-- Build_Parameter_Block --
---------------------------
Handled_Statement_Sequence => Hand_Stmt_Seq);
end Build_Lock_Free_Unprotected_Subprogram_Body;
+ ------------------------------
+ -- Build_Master_Declaration --
+ ------------------------------
+
+ function Build_Master_Declaration (Loc : Source_Ptr) return Node_Id is
+ Master_Decl : Node_Id;
+
+ begin
+ -- Generate a dummy master if tasks or tasking hierarchies are
+ -- prohibited:
+ -- _Master : constant Integer := Library_Task_Level;
+
+ if not Tasking_Allowed
+ or else Restrictions.Set (No_Task_Hierarchy)
+ or else not RTE_Available (RE_Current_Master)
+ then
+ Master_Decl :=
+ Make_Object_Declaration (Loc,
+ Defining_Identifier =>
+ Make_Defining_Identifier (Loc, Name_uMaster),
+ Constant_Present => True,
+ Object_Definition =>
+ New_Occurrence_Of (Standard_Integer, Loc),
+ Expression =>
+ Make_Integer_Literal (Loc, Library_Task_Level));
+
+ -- Generate:
+ -- _Master : constant Integer := Current_Master.all;
+
+ else
+ Master_Decl :=
+ Make_Object_Declaration (Loc,
+ Defining_Identifier =>
+ Make_Defining_Identifier (Loc, Name_uMaster),
+ Constant_Present => True,
+ Object_Definition =>
+ New_Occurrence_Of (Standard_Integer, Loc),
+ Expression =>
+ Make_Explicit_Dereference (Loc,
+ New_Occurrence_Of (RTE (RE_Current_Master), Loc)));
+ end if;
+
+ return Master_Decl;
+ end Build_Master_Declaration;
+
-------------------------
-- Build_Master_Entity --
-------------------------
end if;
end Build_Master_Entity;
+ ---------------------------------------
+ -- Build_Master_Renaming_Declaration --
+ ---------------------------------------
+
+ function Build_Master_Renaming_Declaration
+ (Ptr_Typ : Entity_Id;
+ Loc : Source_Ptr) return Node_Id
+ is
+ -- Generate:
+ -- <Ptr_Typ>M : Integer renames _Master;
+ -- and add a numeric suffix to the name to ensure that it is
+ -- unique in case other access types in nested constructs
+ -- are homonyms of this one.
+
+ Master_Id : constant Entity_Id :=
+ Make_Defining_Identifier (Loc,
+ New_External_Name (Chars (Ptr_Typ), 'M', -1));
+
+ Master_Decl : constant Node_Id :=
+ Make_Object_Renaming_Declaration (Loc,
+ Defining_Identifier => Master_Id,
+ Subtype_Mark =>
+ New_Occurrence_Of (Standard_Integer, Loc),
+ Name => Make_Identifier (Loc, Name_uMaster));
+
+ begin
+ return Master_Decl;
+ end Build_Master_Renaming_Declaration;
+
---------------------------
-- Build_Master_Renaming --
---------------------------
(Ptr_Typ : Entity_Id;
Ins_Nod : Node_Id := Empty)
is
- Loc : constant Source_Ptr := Sloc (Ptr_Typ);
+ Loc : constant Source_Ptr := Sloc (Ptr_Typ);
+
Context : Node_Id;
Master_Decl : Node_Id;
- Master_Id : Entity_Id;
begin
-- No action needed if the run-time has no tasking support
return;
end if;
+ Master_Decl := Build_Master_Renaming_Declaration (Ptr_Typ, Loc);
+
-- Determine the proper context to insert the master renaming
if Present (Ins_Nod) then
Context := Parent (Ptr_Typ);
end if;
- -- Generate:
- -- <Ptr_Typ>M : Master_Id renames _Master;
- -- and add a numeric suffix to the name to ensure that it is
- -- unique in case other access types in nested constructs
- -- are homonyms of this one.
-
- Master_Id :=
- Make_Defining_Identifier (Loc,
- New_External_Name (Chars (Ptr_Typ), 'M', -1));
-
- Master_Decl :=
- Make_Object_Renaming_Declaration (Loc,
- Defining_Identifier => Master_Id,
- Subtype_Mark =>
- New_Occurrence_Of (Standard_Integer, Loc),
- Name => Make_Identifier (Loc, Name_uMaster));
-
Insert_Action (Context, Master_Decl);
-- The renamed master now services the access type
- Set_Master_Id (Ptr_Typ, Master_Id);
+ Set_Master_Id (Ptr_Typ, Defining_Identifier (Master_Decl));
end Build_Master_Renaming;
---------------------------
-- For targets supporting tasks, generate:
-- _Master : constant Integer := Current_Master.all;
-- For targets where tasks or tasking hierarchies are prohibited, generate:
- -- _Master : constant Master_Id := 3;
+ -- _Master : constant Integer := Library_Task_Level;
procedure Build_Master_Entity (Obj_Or_Typ : Entity_Id);
-- Given the name of an object or a type which is either a task, contains
- -- tasks or designates tasks, create a _master in the appropriate scope
+ -- tasks or designates tasks, create a _Master in the appropriate scope
-- which captures the value of Current_Master. Mark the nearest enclosing
-- body or block as being a task master.
+ function Build_Master_Renaming_Declaration
+ (Ptr_Typ : Entity_Id;
+ Loc : Source_Ptr) return Node_Id;
+ -- Generate:
+ -- <Ptr_Typ>M : Integer renames _Master;
+
procedure Build_Master_Renaming
(Ptr_Typ : Entity_Id;
Ins_Nod : Node_Id := Empty);
-- Given an access type Ptr_Typ whose designated type is either a task or
-- contains tasks, create a renaming of the form:
--
- -- <Ptr_Typ>M : Master_Id renames _Master;
+ -- <Ptr_Typ>M : Integer renames _Master;
--
- -- where _master denotes the task master of the enclosing context. Ins_Nod
+ -- where _Master denotes the task master of the enclosing context. Ins_Nod
-- is used to provide a specific insertion node for the renaming.
function Build_Protected_Sub_Specification