; ; seh.sh ; ; Structured Exception Handling, the Sapphire way ; ; © 1995-1998 Straylight ; ;----- Licensing note ------------------------------------------------------- ; ; This file is part of Straylight's Sapphire library. ; ; Sapphire is free software; you can redistribute it and/or modify ; it under the terms of the GNU General Public License as published by ; the Free Software Foundation; either version 2, or (at your option) ; any later version. ; ; Sapphire 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 ; along with Sapphire. If not, write to the Free Software Foundation, ; 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. ;----- Overview ------------------------------------------------------------- ; ; Functions provided: ; ; seh_try ; seh_unTry ; seh_throw ; seh_throwErrors ; seh_setListBase ; seh_init [ :LNOT::DEF:seh__dfn GBLL seh__dfn ; --- seh_try --- ; ; On entry: R0 == pointer to catch definition block ; ; On exit: R13 dropped by a (small) amount ; ; Use: Inserts an exception handler at the current position. ; Exceptions are matched against those described in the catch ; block. If there is a handler for the exception, the ; corresponding handler is called, and expected to resume ; normally. Otherwise the tidy-up routine is called and we ; unwind the stack further to find an appropriate handler. ; ; The catch block has the following format: ; ; word B to tidy-up routine ; word 1st exception mask ; word 1st B to catch routine ; word 2nd exception mask ; word 2nd B to catch routine ; ... ; word 0 ; ; An exception mask contains two halfwords. Bits 16-31 are the ; class to match, or -1 for all classes. Bits 0-15 are the ; subtype to match, or -1 for all subtypes. You can do really ; odd things if you set bits 16-31 to -1 and leave 0-15 ; matching specific subtypes -- do this at your own risk. IMPORT seh_try ; --- seh_unTry --- ; ; On entry: -- ; ; On exit: R13 moved to position before corresponding seh_try ; ; Use: Removes the try block marker in the stack at the current ; position. Note that the stack will be unwound to where it ; was when seh_try was called. IMPORT seh_unTry ; --- seh_throw --- ; ; On entry: R0 == exception to match ; R1-R3 == useful bits of information ; ; On exit: Doesn't return, unless you've done something /really/ odd ; ; Use: Throws an exception. The stack is unwound until we find ; a handler which can cope. If there is no handler, we abort ; the program. IMPORT seh_throw ; --- seh_throwErrors --- ; ; On entry: -- ; ; On exit: -- ; ; Use: Sets up an except-style error handler to throw errors ; as SEH exceptions. IMPORT seh_throwErrors ; --- seh_setListBase --- ; ; On entry: R0 == pointer to try block list base, or 0 to use global ; ; On exit: -- ; ; Use: Sets the try block list base. This should only be used by ; coroutine providers, like coRoutine and thread. IMPORT seh_setListBase ; --- seh_init --- ; ; On entry: -- ; ; On exit: -- ; ; Use: Initialises SEH's facilities. IMPORT seh_init ] ;----- That's all, folks ---------------------------------------------------- END