-- in-place functions are called in the expanded code.
if Nkind (Parent (N)) = N_Object_Declaration and then Has_Task (Typ) then
- Build_Master_Entity (Defining_Identifier (Parent (N)));
+ Build_Master_Entity (Parent (N));
end if;
-- STEP 1: Process component associations
-- for such a type.
if Has_Task (Desig_Typ) then
- Build_Master_Entity (Ptr_Typ);
+ Build_Master_Entity (N);
Build_Master_Renaming (Ptr_Typ);
-- Create a class-wide master because a Master_Id must be generated
elsif not Is_Param_Block_Component_Type (Ptr_Typ)
and then Is_Limited_Class_Wide_Type (Desig_Typ)
then
- Build_Master_Entity (Ptr_Typ);
+ Build_Master_Entity (N);
Build_Master_Renaming (Ptr_Typ);
end if;
end Build_Master;
-- Ensure that the record or array type have a _master
if First then
- Build_Master_Entity (Def_Id);
+ Build_Master_Entity (N);
Build_Master_Renaming (Typ);
M_Id := Master_Id (Typ);
Build_Activation_Chain_Entity (N);
if Has_Task (Typ) or else Has_BIP_Init_Expr then
- Build_Master_Entity (Def_Id);
+ Build_Master_Entity (N);
end if;
end if;
then
-- Ensure that the designated type has a master
- Build_Master_Entity (Def_Id);
+ Build_Master_Entity (Parent (Def_Id));
-- Private and incomplete types complicate the insertion of master
-- renamings because the access type may precede the full view of
if Has_Tasks then
Build_Activation_Chain_Entity (Temp_Decl);
- Build_Master_Entity (Temp_Id);
+ Build_Master_Entity (Temp_Decl);
end if;
Make_Build_In_Place_Call_In_Object_Declaration
Insert_Action (Allocator, Tmp_Decl);
Expander_Mode_Restore;
- Build_Master_Entity (Anon_Type);
+ Build_Master_Entity (Tmp_Decl);
Build_Master_Renaming (Anon_Type);
Make_Build_In_Place_Call_In_Allocator
Expander_Mode_Restore;
Build_Activation_Chain_Entity (Tmp_Decl);
- Build_Master_Entity (Tmp_Id);
+ Build_Master_Entity (Tmp_Decl);
Make_Build_In_Place_Iface_Call_In_Object_Declaration
(Obj_Decl => Tmp_Decl,
-- Build_Master_Entity --
-------------------------
- procedure Build_Master_Entity (Obj_Or_Typ : Entity_Id) is
- Loc : constant Source_Ptr := Sloc (Obj_Or_Typ);
+ procedure Build_Master_Entity (N : Node_Id) is
Context : Node_Id;
Context_Id : Entity_Id;
Decl : Node_Id;
Decls : List_Id;
- Par : Node_Id;
begin
-- No action needed if the run-time has no tasking support
return;
end if;
- if Is_Itype (Obj_Or_Typ) then
- Par := Associated_Node_For_Itype (Obj_Or_Typ);
- else
- Par := Parent (Obj_Or_Typ);
- end if;
-
-- When creating a master for a record component which is either a task
-- or access-to-task, the enclosing record is the master scope and the
-- proper insertion point is the component list.
if Is_Record_Type (Current_Scope) then
- Context := Par;
+ Context := N;
Context_Id := Current_Scope;
Decls := List_Containing (Context);
-- return statement.
else
- Find_Enclosing_Context (Par, Context, Context_Id, Decls);
+ Find_Enclosing_Context (N, Context, Context_Id, Decls);
end if;
pragma Assert (not Is_Finalizer (Context_Id));
return;
end if;
- Decl := Build_Master_Declaration (Loc);
+ Decl := Build_Master_Declaration (Sloc (N));
-- The master is inserted at the start of the declarative list of the
-- context.
-- protected subprogram.
procedure Build_Activation_Chain_Entity (N : Node_Id);
- -- Given a declaration N of an object that is a task, or contains tasks
- -- (other than allocators to tasks) this routine ensures that an activation
- -- chain has been declared in the appropriate scope, building the required
- -- declaration for the chain variable if not. The name of this variable
- -- is always _Chain and it is accessed by name.
+ -- Given a construct N that involves tasks (other than allocators to tasks)
+ -- create a _Chain entity in the appropriate scope to be used as activation
+ -- chain if there is not already one.
function Build_Call_With_Task (N : Node_Id; E : Entity_Id) return Node_Id;
-- N is a node representing the name of a task or an access to a task.
-- For targets where tasks or tasking hierarchies are prohibited, generate:
-- _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
- -- which captures the value of Current_Master. Mark the nearest enclosing
- -- body or block as being a task master.
+ procedure Build_Master_Entity (N : Node_Id);
+ -- Given a construct N that involves or designates tasks, create a _Master
+ -- entity in the appropriate scope if there is not already one, which will
+ -- capture 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;
if Is_Limited_Record (Desig_Type)
and then Is_Class_Wide_Type (Desig_Type)
then
- Build_Master_Entity (Defining_Identifier (Related_Nod));
+ Build_Master_Entity (Related_Nod);
Build_Master_Renaming (Anon_Type);
-- Similarly, if the type is an anonymous access that designates
elsif Has_Task (Desig_Type)
and then Comes_From_Source (Related_Nod)
then
- Build_Master_Entity (Defining_Identifier (Related_Nod));
+ Build_Master_Entity (Related_Nod);
Build_Master_Renaming (Anon_Type);
end if;
end if;
if From_Limited_With (Entity (S))
and then not Is_Class_Wide_Type (Entity (S))
then
- Build_Master_Entity (T);
+ Build_Master_Entity (Def);
Build_Master_Renaming (T);
end if;