procedure Install_Class_Preconditions_Check (Call_Node : Node_Id) is
Loc : constant Source_Ptr := Sloc (Call_Node);
- function Build_Dynamic_Check_Helper_Call return Node_Id;
- -- Build call to the helper runtime function of the nearest ancestor
- -- of the target subprogram that dynamically evaluates the merged
- -- or-else preconditions.
-
function Build_Error_Message (Subp_Id : Entity_Id) return Node_Id;
-- Build message associated with the class-wide precondition of Subp_Id
-- indicating the call that caused it.
- function Build_Static_Check_Helper_Call return Node_Id;
+ function Build_Helper_Call (Dynamic : Boolean) return Node_Id;
-- Build call to the helper runtime function of the nearest ancestor
- -- of the target subprogram that dynamically evaluates the merged
- -- or-else preconditions.
+ -- of the target subprogram that statically or dynamically (depending on
+ -- the Dynamic flag) evaluates the merged or-else preconditions.
function Class_Preconditions_Subprogram
(Spec_Id : Entity_Id;
-- preconditions; return Empty when not available (which means that no
-- preconditions check is required).
- -------------------------------------
- -- Build_Dynamic_Check_Helper_Call --
- -------------------------------------
-
- function Build_Dynamic_Check_Helper_Call return Node_Id is
- Spec_Id : constant Entity_Id := Entity (Name (Call_Node));
- CW_Subp : constant Entity_Id :=
- Class_Preconditions_Subprogram (Spec_Id,
- Dynamic => True);
- Helper_Id : constant Entity_Id :=
- Dynamic_Call_Helper (CW_Subp);
- Actuals : constant List_Id := New_List;
- A : Node_Id := First_Actual (Call_Node);
-
- begin
- while Present (A) loop
-
- -- Ensure that the evaluation of the actuals will not produce
- -- side effects.
-
- Remove_Side_Effects (A);
-
- Append_To (Actuals, New_Copy_Tree (A));
-
- Next_Actual (A);
- end loop;
-
- return
- Make_Function_Call (Loc,
- Name => New_Occurrence_Of (Helper_Id, Loc),
- Parameter_Associations => Actuals);
- end Build_Dynamic_Check_Helper_Call;
-
-------------------------
-- Build_Error_Message --
-------------------------
return Make_String_Literal (Loc, Name_Buffer (1 .. Name_Len));
end Build_Error_Message;
- ------------------------------------
- -- Build_Static_Check_Helper_Call --
- ------------------------------------
+ -----------------------
+ -- Build_Helper_Call --
+ -----------------------
- function Build_Static_Check_Helper_Call return Node_Id is
+ function Build_Helper_Call (Dynamic : Boolean) return Node_Id is
Actuals : constant List_Id := New_List;
A : Node_Id;
Helper_Id : Entity_Id;
-- Common case
else
- CW_Subp := Class_Preconditions_Subprogram (Spec_Id,
- Dynamic => False);
+ CW_Subp := Class_Preconditions_Subprogram (Spec_Id, Dynamic);
end if;
- Helper_Id := Static_Call_Helper (CW_Subp);
+ if Dynamic then
+ Helper_Id := Dynamic_Call_Helper (CW_Subp);
+ else
+ Helper_Id := Static_Call_Helper (CW_Subp);
+ end if;
F := First_Formal (Helper_Id);
A := First_Actual (Call_Node);
Make_Function_Call (Loc,
Name => New_Occurrence_Of (Helper_Id, Loc),
Parameter_Associations => Actuals);
- end Build_Static_Check_Helper_Call;
+ end Build_Helper_Call;
------------------------------------
-- Class_Preconditions_Subprogram --
-- Build and install the check
- if Dynamic_Check then
- Cond := Build_Dynamic_Check_Helper_Call;
- else
- Cond := Build_Static_Check_Helper_Call;
- end if;
+ Cond := Build_Helper_Call (Dynamic_Check);
if Exception_Locations_Suppressed then
Fail :=