-
Notifications
You must be signed in to change notification settings - Fork 0
/
pats_ccomp_exception.h.array
170 lines (138 loc) · 4.41 KB
/
pats_ccomp_exception.h.array
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
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
/* ******************************************************************* */
/* */
/* Applied Type System */
/* */
/* ******************************************************************* */
/*
** ATS/Postiats - Unleashing the Potential of Types!
** Copyright (C) 2011-20?? Hongwei Xi, ATS Trustful Software, Inc.
** All rights reserved
**
** ATS is free software; you can redistribute it and/or modify it under
** the terms of the GNU GENERAL PUBLIC LICENSE (GPL) as published by the
** Free Software Foundation; either version 3, or (at your option) any
** later version.
**
** ATS 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 ATS; see the file COPYING. If not, please write to the
** Free Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA
** 02110-1301, USA.
*/
/* alloca is a bothersome way to allocate temporary memory: it does
not free the memory until a subprogram-return occurs. If, instead,
one uses an automatic array, then (in GCC) the memory is allocated
on the stack but freed when the array goes out of scope.
Here we try to use an automatic array instead of alloca. ONE MUST
BE CAREFUL NOT TO HAVE THE ARRAY GO OUT OF SCOPE PREMATURELY. */
/* ****** ****** */
/*
(* Author: Hongwei Xi *)
(* Authoremail: hwxi AT cs DOT bu DOT edu *)
(* Start time: June, 2013 *)
*/
/*
(* Modified by: Barry Schwartz, who waives copyright claims on this file. *)
*/
/* ****** ****** */
#ifndef PATS_CCOMP_EXCEPTION_H
#define PATS_CCOMP_EXCEPTION_H
/* ****** ****** */
/*
use -D_XOPEN_SOURCE
*/
#include <setjmp.h>
/* ****** ****** */
#define atstype_jmp_buf jmp_buf
#define atspre_setjmp(env, mask) setjmp(env)
#define atspre_longjmp(env, ret) longjmp(env, ret)
/* ****** ****** */
/*
extern
atstype_exncon *atspre_AssertExn_make() ;
extern
atstype_exncon *atspre_NotFoundExn_make() ;
extern
atstype_exncon *atspre_IllegalArgExn_make(const char*) ;
extern
atstype_exncon *atspre_ListSubscriptExn_make() ;
extern
atstype_exncon *atspre_StreamSubscriptExn_make() ;
extern
atstype_exncon *atspre_ArraySubscriptExn_make() ;
extern
atstype_exncon *atspre_MatrixSubscriptExn_make() ;
//
extern atstype_exncon *atspre_NotSomeExn_make() ;
//
extern
atstype_bool atspre_isListSubscriptExn (const atstype_exncon*) ;
extern
atstype_bool atspre_isStreamSubscriptExn (const atstype_exncon*) ;
extern
atstype_bool atspre_isArraySubscriptExn (const atstype_exncon*) ;
extern
atstype_bool atspre_isMatrixSubscriptExn (const atstype_exncon*) ;
//
extern atstype_bool atspre_isNotSomeExn (const atstype_exncon*) ;
*/
/* ****** ****** */
typedef
struct atsexnframe
{
atstype_jmp_buf env ;
atstype_exnconptr exn ;
struct atsexnframe *prev ;
} atsexnframe_t ;
typedef
atsexnframe_t *atsexnframe_ptr ;
/* ****** ****** */
extern
atsexnframe_ptr *my_atsexnframe_getref () ;
/* ****** ****** */
/*
** HX:
** beg-of-WARNING:
** DO NOT USE THE FOLLOWING MACROS:
*/
/* Make atsexnframe_buffer variable-length, simply because how GCC
creates and destroys a variable-length automatic array is
documented in an easy-to-find place in the GCC manual. */
#define \
ATStrywith_try(tmpexn) \
do { \
int flag ; \
atsexnframe_ptr frame ; \
atsexnframe_ptr *framep ; \
int atsexnframe_buffer_size = 1 ; \
{ /* Start of scope of the array. */ \
atsexnframe_t atsexnframe_buffer[atsexnframe_buffer_size] ; \
frame = atsexnframe_buffer ; \
framep = my_atsexnframe_getref() ; \
frame->prev = *framep ; \
*framep = frame ; \
flag = atspre_setjmp(frame->env, 1) ; \
if (flag==0) { /* normal */
#define \
ATStrywith_with(tmpexn) \
*framep = (*framep)->prev ; \
} else { /* flag<>0 : exceptional */ \
tmpexn = (*framep)->exn ; \
*framep = (*framep)->prev ;
#define \
ATStrywith_end(tmpexn) \
} \
} /* End of scope of the array. */ \
} while(0) ; /* end of [do] */
/* end-of-WARNING */
/* ****** ****** */
#endif /* PATS_CCOMP_EXCEPTION_H */
/* ****** ****** */
/* end of [pats_ccomp_exception.h] */
/* local variables: */
/* mode: C */
/* end: */