-- Initialize calls: they are generated for either declarations or dynamic
-- allocations of controlled objects with no initial value. They are always
- -- followed by an attachment to the current finalization chain. For the
- -- dynamic allocation case, this is the chain attached to the scope of the
- -- access type definition; otherwise, this is the chain of the current
- -- scope.
+ -- followed by an attachment to some finalization chain. For the dynamic
+ -- dynamic allocation case, this is the collection attached to the access
+ -- type definition; otherwise, this is the master of the current scope.
-- Adjust calls: they are generated on two occasions: (1) for declarations
-- or dynamic allocations of controlled objects with an initial value (with
-- is expanded into:
--
-- declare
- -- Mnn : System.Finalization_Primitives.Finalization_Scope_Master;
+ -- Mnn : System.Finalization_Primitives.Finalization_Master;
-- XMN : aliased System.Finalization_Primitives.Master_Node;
-- X : Ctrl;
-- at end
-- _Finalizer;
- -- In the case of a block containing a single controlled object, the scope
- -- master degenerates into a single master node:
+ -- In the case of a block containing a single controlled object, the master
+ -- degenerates into a single master node:
-- declare
-- X : Ctrl := Init;
-- These direct actions must be signalled to the post-processing machinery
-- and this is achieved through the handling of Master_Node objects, which
- -- are the items actually chained in finalization chains of scope masters.
+ -- are the items actually chained in the finalization chains of masters.
-- With the default processing, they are created by Build_Finalizer for the
-- controlled objects spotted by Requires_Cleanup_Actions. But when direct
-- actions are carried out, they are generated by these actions and later
Finalizer_Decls : List_Id := No_List;
-- Local variable declarations
- Finalization_Scope_Master : Entity_Id;
- -- The Finalization Scope Master object
+ Finalization_Master : Entity_Id;
+ -- The Finalization Master object
Finalizer_Stmts : List_Id := No_List;
-- The statement list of the finalizer body
----------------------
procedure Build_Components is
- Constraints : List_Id;
- Scope_Master_Decl : Node_Id;
- Scope_Master_Name : Name_Id;
+ Constraints : List_Id;
+ Master_Decl : Node_Id;
+ Master_Name : Name_Id;
begin
pragma Assert (Present (Decls));
-- If the context contains controlled objects, then we create the
- -- finalization scope master, unless there is a single such object;
- -- in this common case, we'll directly finalize the object.
+ -- finalization master, unless there is a single such object: in
+ -- this common case, we'll directly finalize the object.
if Has_Ctrl_Objs then
if Counter_Val > 1 then
if For_Package_Spec then
- Scope_Master_Name :=
+ Master_Name :=
New_External_Name (Name_uMaster, Suffix => "_spec");
elsif For_Package_Body then
- Scope_Master_Name :=
+ Master_Name :=
New_External_Name (Name_uMaster, Suffix => "_body");
else
- Scope_Master_Name := New_Internal_Name ('M');
+ Master_Name := New_Internal_Name ('M');
end if;
- Finalization_Scope_Master :=
- Make_Defining_Identifier (Loc, Scope_Master_Name);
+ Finalization_Master :=
+ Make_Defining_Identifier (Loc, Master_Name);
- -- The scope master is statically parameterized by the context
+ -- The master is statically parameterized by the context
Constraints := New_List;
Append_To (Constraints,
Append_To (Constraints,
New_Occurrence_Of (Boolean_Literals (For_Package), Loc));
- Scope_Master_Decl :=
+ Master_Decl :=
Make_Object_Declaration (Loc,
- Defining_Identifier => Finalization_Scope_Master,
+ Defining_Identifier => Finalization_Master,
Object_Definition =>
Make_Subtype_Indication (Loc,
Subtype_Mark =>
New_Occurrence_Of
- (RTE (RE_Finalization_Scope_Master), Loc),
+ (RTE (RE_Finalization_Master), Loc),
Constraint =>
Make_Index_Or_Discriminant_Constraint (Loc,
Constraints => Constraints)));
- Prepend_To (Decls, Scope_Master_Decl);
- Analyze (Scope_Master_Decl, Suppress => All_Checks);
+ Prepend_To (Decls, Master_Decl);
+ Analyze (Master_Decl, Suppress => All_Checks);
end if;
if Exceptions_OK then
Name =>
New_Occurrence_Of (RTE (RE_Finalize_Master), Loc),
Parameter_Associations =>
- New_List
- (New_Occurrence_Of (Finalization_Scope_Master, Loc)));
+ New_List (New_Occurrence_Of (Finalization_Master, Loc)));
-- For CodePeer, the exception handlers normally generated here
-- generate complex flowgraphs which result in capacity problems.
-- Create the declaration of the Master_Node for the object and
-- insert it before the declaration of the object itself, except
-- for the case where it is the only object because it will play
- -- the role of a degenerated scope master and therefore needs to
- -- be inserted at the same place the scope master would have been.
+ -- the role of a degenerated master and therefore needs to be
+ -- inserted at the same place the master would have been.
else pragma Assert (No (Finalization_Master_Node (Obj_Id)));
- -- For one object, use the Sloc the scope master would have had
+ -- For one object, use the Sloc the master would have had
if Counter_Val = 1 then
Master_Node_Loc := Sloc (N);
Make_Attribute_Reference (Loc,
Prefix => New_Occurrence_Of (Obj_Id, Loc),
Attribute_Name => Name_Unrestricted_Access),
- New_Occurrence_Of (Finalization_Scope_Master, Loc)));
+ New_Occurrence_Of (Finalization_Master, Loc)));
-- Finalize_Address is not generated in CodePeer mode because the
-- body contains address arithmetic. So we don't want to generate
Prefix =>
New_Occurrence_Of (Master_Node_Id, Loc),
Attribute_Name => Name_Unrestricted_Access),
- New_Occurrence_Of (Finalization_Scope_Master, Loc)));
+ New_Occurrence_Of (Finalization_Master, Loc)));
end if;
end if;
-- level of the program or associated with the declarative part of a
-- subprogram or other closed scopes (block statements, for example).
- type Finalization_Scope_Master
+ type Finalization_Master
(Exceptions_OK : Boolean;
Extra_Info : Boolean;
Library_Level : Boolean) is limited private;
(Object_Address : System.Address;
Finalize_Address : not null Finalize_Address_Ptr;
Node : not null Master_Node_Ptr;
- Master : in out Finalization_Scope_Master);
+ Master : in out Finalization_Master);
-- Associates a controlled object and its master node with a given master.
-- Finalize_Address denotes the operation to be called to finalize the
-- object (which could be a user-declared Finalize procedure or a procedure
procedure Chain_Node_To_Master
(Node : not null Master_Node_Ptr;
- Master : in out Finalization_Scope_Master);
+ Master : in out Finalization_Master);
-- Chain a master node to the given master. This is used to chain the node
-- to the master of the enclosing scope for the objects that need special
-- processing mentioned for Attach_Object_To_Node.
- procedure Finalize_Master (Master : in out Finalization_Scope_Master);
+ procedure Finalize_Master (Master : in out Finalization_Master);
-- Finalizes each of the controlled objects associated with Master, in the
-- reverse of the order in which they were attached. Calls to the procedure
-- with a Master that has already been finalized have no effects.
Next : Master_Node_Ptr := null;
end record;
- -- Finalization scope master type structure. A unique master is associated
+ -- Finalization master type structure. A unique master is associated
-- with each scope containing controlled objects.
- type Finalization_Scope_Master
+ type Finalization_Master
(Exceptions_OK : Boolean;
Extra_Info : Boolean;
Library_Level : Boolean) is limited
RE_Chain_Node_To_Master, -- System.Finalization_Primitives
RE_Finalization_Collection, -- System.Finalization_Primitives
RE_Finalization_Collection_Ptr, -- System.Finalization_Primitives
- RE_Finalization_Scope_Master, -- System.Finalization_Primitives
+ RE_Finalization_Master, -- System.Finalization_Primitives
RE_Finalize_Master, -- System.Finalization_Primitives
RE_Finalize_Object, -- System.Finalization_Primitives
RE_Master_Node, -- System.Finalization_Primitives
RE_Chain_Node_To_Master => System_Finalization_Primitives,
RE_Finalization_Collection => System_Finalization_Primitives,
RE_Finalization_Collection_Ptr => System_Finalization_Primitives,
- RE_Finalization_Scope_Master => System_Finalization_Primitives,
+ RE_Finalization_Master => System_Finalization_Primitives,
RE_Finalize_Master => System_Finalization_Primitives,
RE_Finalize_Object => System_Finalization_Primitives,
RE_Master_Node => System_Finalization_Primitives,