2 with Ada
.Strings
.Unbounded
;
5 -- We declare a variable of type Types.T.
6 pragma Elaborate
(Types
);
13 function Throw
(Args
: in Types
.T_Array
) return Types
.T
;
15 -- Ada exceptions can only carry an immutable String in each
16 -- occurence, so we require a global variable to store the last
17 -- exception as a Mal object anyway, and may as well use it for
18 -- simple string messages.
22 Trace
: Ada
.Strings
.Unbounded
.Unbounded_String
;
24 -- Convenient shortcuts.
26 procedure Raise_With
(Message
: in String) with No_Return
;
27 -- Similar to a "raise with Message" Ada statement.
28 -- Store the message into Data,
29 -- store the message and "Uncaught exception: " into Trace,
32 procedure Raise_In_Mal
(E
: in Ada
.Exceptions
.Exception_Occurrence
)
34 -- Raise_With (Ada.Exceptions.Exception_Information (E))
36 procedure Add_Trace_Line
(Action
: in String;
38 -- Appends a line like "Action: Ast" to Trace.
40 procedure Check
(Condition
: in Boolean;
41 Message
: in String) with Inline
;
42 -- Raise_With if Condition fails.
44 -- It is probably more efficient to construct a boolean and call
45 -- this procedure once, as "inline" is only a recommendation.
47 -- Beware of the classical performance issue that the Message is
48 -- formatted even if the Condition does not hold.