1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138
|
-------------------------------------------------------------------------------
-- (C) Altran Praxis Limited
-------------------------------------------------------------------------------
--
-- The SPARK toolset is free software; you can redistribute it and/or modify it
-- under terms of the GNU General Public License as published by the Free
-- Software Foundation; either version 3, or (at your option) any later
-- version. The SPARK toolset is distributed in the hope that it will be
-- useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
-- MERCHANTABILITY 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 Public License distributed with the SPARK toolset; see file
-- COPYING3. If not, go to http://www.gnu.org/licenses for a complete copy of
-- the license.
--
--=============================================================================
separate (ErrorHandler)
package body ErrorAccumulator is
-----------------------------------------------------------------------------
function Is_Active (This : T) return Boolean is
begin
return This.Active;
end Is_Active;
function Is_Error_Continuation (The_Error : Error_Types.StringError) return Boolean is
begin
return ((The_Error.ErrorType = Error_Types.CondlDependencyErr
and then The_Error.MessageId = ErrorHandler.Dependency_Err_Number (ErrorHandler.May_Be_Used_Continue))
or else (The_Error.ErrorType = Error_Types.UncondDependencyErr
and then The_Error.MessageId = ErrorHandler.Dependency_Err_Number (ErrorHandler.Not_Used_Continue)));
end Is_Error_Continuation;
function Is_Error_Start (The_Error : Error_Types.StringError) return Boolean is
begin
return ((The_Error.ErrorType = Error_Types.CondlDependencyErr
and then The_Error.MessageId = ErrorHandler.Dependency_Err_Number (ErrorHandler.May_Be_Used_New))
or else (The_Error.ErrorType = Error_Types.UncondDependencyErr
and then The_Error.MessageId = ErrorHandler.Dependency_Err_Number (ErrorHandler.Not_Used_New)));
end Is_Error_Start;
procedure Start_Msg
(This : out T;
Start_Error : in ErrorHandler.Error_Struct;
Start_Indent : in Natural;
Explanation : in E_Strings.T;
Line_Length : in Natural;
Indent : in Natural)
is
begin
This :=
T'
(Active => True,
Start_Error => Start_Error,
Start_Indent => Start_Indent,
Explanation => Explanation,
Line_Length => Line_Length,
Indent => Indent);
end Start_Msg;
procedure Flush (This : in out T;
Listing : in SPARK_IO.File_Type) is
Unused_New_Start : Natural;
begin
if This.Active then
if not E_Strings.Is_Empty (E_Str => This.Explanation) then
--# accept F, 10, Unused_New_Start, "Expected ineffective assignment";
ErrorHandler.PrintLine
(Listing => Listing,
Start_Pos => This.Start_Indent,
End_Pos => This.Line_Length,
Indent => This.Indent,
Line => This.Explanation,
Add_New_Line => False,
New_Start => Unused_New_Start);
--# end accept;
end if;
SPARK_IO.Put_String (File => Listing,
Item => ".",
Stop => 1);
This.Active := False;
end if;
--# accept Flow, 33, Unused_New_Start, "Expected to be neither referenced nor exported";
end Flush;
procedure Add
(This : in out T;
Error : in ErrorHandler.Error_Struct;
End_Pos, Indent : in Natural;
Listing : in SPARK_IO.File_Type)
is
New_Start : Natural;
function Need_To_Add return Boolean
--# global in Error;
--# in This;
is
begin
return (This.Start_Error.Error.MessageId = ErrorHandler.Dependency_Err_Number (ErrorHandler.May_Be_Used_New) and
Error.Error.ErrorType = Error_Types.CondlDependencyErr and
Error.Error.MessageId = ErrorHandler.Dependency_Err_Number (ErrorHandler.May_Be_Used_Continue))
or else (This.Start_Error.Error.MessageId = ErrorHandler.Dependency_Err_Number (ErrorHandler.Not_Used_New) and
Error.Error.ErrorType = Error_Types.UncondDependencyErr and
Error.Error.MessageId = ErrorHandler.Dependency_Err_Number (ErrorHandler.Not_Used_Continue));
end Need_To_Add;
begin
if This.Active then
if Need_To_Add then
ErrorHandler.PrintLine
(Listing => Listing,
Start_Pos => This.Start_Indent,
End_Pos => End_Pos,
Indent => Indent,
Line => Error.Error.Message,
Add_New_Line => False,
New_Start => New_Start);
This.Start_Indent := New_Start;
elsif Is_Error_Continuation (The_Error => Error.Error) then
SystemErrors.Fatal_Error (Sys_Err => SystemErrors.Other_Internal_Error,
Msg => "in ErrorHandler.ErrorAccumulator.Add");
else
Flush (This => This,
Listing => Listing);
end if;
end if;
end Add;
end ErrorAccumulator;
|