Lichen

Annotated templates/exceptions.h

792:d70932955645
2017-03-31 Paul Boddie Fixed non-recognition of deferred references in non-module, non-function scopes.
paul@353 1
/* Exception definitions.
paul@353 2
paul@353 3
Copyright (C) 2016 Paul Boddie <paul@boddie.org.uk>
paul@353 4
paul@353 5
This program is free software; you can redistribute it and/or modify it under
paul@353 6
the terms of the GNU General Public License as published by the Free Software
paul@353 7
Foundation; either version 3 of the License, or (at your option) any later
paul@353 8
version.
paul@353 9
paul@353 10
This program is distributed in the hope that it will be useful, but WITHOUT
paul@353 11
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
paul@353 12
FOR A PARTICULAR PURPOSE.  See the GNU General Public License for more
paul@353 13
details.
paul@353 14
paul@353 15
You should have received a copy of the GNU General Public License along with
paul@353 16
this program.  If not, see <http://www.gnu.org/licenses/>.
paul@353 17
*/
paul@353 18
paul@143 19
#ifndef __EXCEPTIONS_H__
paul@143 20
#define __EXCEPTIONS_H__
paul@143 21
paul@143 22
#include "cexcept.h"
paul@143 23
#include "types.h"
paul@143 24
paul@143 25
/* Define the exception type. */
paul@143 26
paul@143 27
typedef struct
paul@143 28
{
paul@143 29
    __attr arg;
paul@143 30
    int raising;
paul@143 31
    int raising_else;
paul@143 32
    int completing;
paul@143 33
} __exc;
paul@143 34
paul@143 35
define_exception_type(__exc);
paul@143 36
#undef define_exception_type
paul@143 37
paul@143 38
extern struct __exception_context __the_exception_context[1];
paul@143 39
paul@143 40
/* More specific macros. */
paul@143 41
paul@143 42
#define __Raise(value) __Throw ((__exc) {value, 1, 0, 0})
paul@143 43
#define __RaiseElse(value) __Throw ((__exc) {value, 0, 1, 0})
paul@143 44
#define __Return(value) __Throw ((__exc) {value, 0, 0, 1})
paul@143 45
#define __Complete __Throw((__exc) {__NULL, 0, 0, 1})
paul@143 46
paul@143 47
#endif /* __EXCEPTIONS_H__ */