1 (* RTExceptions.def runtime exception handler routines.
3 Copyright (C) 2008-2021 Free Software Foundation, Inc.
4 Contributed by Gaius Mulley <gaius.mulley@southwales.ac.uk>.
6 This file is part of GNU Modula-2.
8 GNU Modula-2 is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 3, or (at your option)
13 GNU Modula-2 is distributed in the hope that it will be useful, but
14 WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 General Public License for more details.
18 Under Section 7 of GPL version 3, you are granted additional
19 permissions described in the GCC Runtime Library Exception, version
20 3.1, as published by the Free Software Foundation.
22 You should have received a copy of the GNU General Public License and
23 a copy of the GCC Runtime Library Exception along with this program;
24 see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
25 <http://www.gnu.org/licenses/>. *)
27 DEFINITION MODULE RTExceptions ;
29 (* Runtime exception handler routines. This should
30 be considered as a system module for GNU Modula-2
31 and allow the compiler to interface with exception
34 FROM SYSTEM IMPORT ADDRESS ;
35 EXPORT QUALIFIED EHBlock,
36 Raise, SetExceptionBlock, GetExceptionBlock,
37 GetTextBuffer, GetTextBufferSize, GetNumber,
38 InitExceptionBlock, KillExceptionBlock,
39 PushHandler, PopHandler,
40 BaseExceptionsThrow, DefaultErrorCatch,
41 IsInExceptionState, SetExceptionState,
42 SwitchExceptionState, GetBaseExceptionBlock,
43 SetExceptionSource, GetExceptionSource ;
47 ProcedureHandler = PROCEDURE ;
51 Raise - invoke the exception handler associated with, number,
52 in the active EHBlock. It keeps a record of the number
53 and message in the EHBlock for later use.
56 PROCEDURE Raise (number: CARDINAL;
57 file: ADDRESS; line: CARDINAL;
58 column: CARDINAL; function: ADDRESS;
63 SetExceptionBlock - sets, source, as the active EHB.
66 PROCEDURE SetExceptionBlock (source: EHBlock) ;
70 GetExceptionBlock - returns the active EHB.
73 PROCEDURE GetExceptionBlock () : EHBlock ;
77 GetTextBuffer - returns the address of the EHB buffer.
80 PROCEDURE GetTextBuffer (e: EHBlock) : ADDRESS ;
84 GetTextBufferSize - return the size of the EHB text buffer.
87 PROCEDURE GetTextBufferSize (e: EHBlock) : CARDINAL ;
91 GetNumber - return the exception number associated with,
95 PROCEDURE GetNumber (source: EHBlock) : CARDINAL ;
99 InitExceptionBlock - creates and returns a new exception block.
102 PROCEDURE InitExceptionBlock () : EHBlock ;
106 KillExceptionBlock - destroys the EHB, e, and all its handlers.
109 PROCEDURE KillExceptionBlock (e: EHBlock) : EHBlock ;
113 PushHandler - install a handler in EHB, e.
116 PROCEDURE PushHandler (e: EHBlock; number: CARDINAL; p: ProcedureHandler) ;
120 PopHandler - removes the handler associated with, number, from
124 PROCEDURE PopHandler (e: EHBlock; number: CARDINAL) ;
128 DefaultErrorCatch - displays the current error message in
129 the current exception block and then
133 PROCEDURE DefaultErrorCatch ;
137 BaseExceptionsThrow - configures the Modula-2 exceptions to call
138 THROW which in turn can be caught by an
139 exception block. If this is not called then
140 a Modula-2 exception will simply call an
141 error message routine and then HALT.
144 PROCEDURE BaseExceptionsThrow ;
148 IsInExceptionState - returns TRUE if the program is currently
149 in the exception state.
152 PROCEDURE IsInExceptionState () : BOOLEAN ;
156 SetExceptionState - returns the current exception state and
157 then sets the current exception state to,
161 PROCEDURE SetExceptionState (to: BOOLEAN) : BOOLEAN ;
165 SwitchExceptionState - assigns, from, with the current exception
166 state and then assigns the current exception
170 PROCEDURE SwitchExceptionState (VAR from: BOOLEAN; to: BOOLEAN) ;
174 GetBaseExceptionBlock - returns the initial language exception block
178 PROCEDURE GetBaseExceptionBlock () : EHBlock ;
182 SetExceptionSource - sets the current exception source to, source.
185 PROCEDURE SetExceptionSource (source: ADDRESS) ;
189 GetExceptionSource - returns the current exception source.
192 PROCEDURE GetExceptionSource () : ADDRESS ;