* src/vm/jit/stack.h (TYPE_VERIFYERROR): Converted most of body to a function.
[cacao.git] / src / vm / exceptions.h
1 /* src/vm/exceptions.h - exception related functions prototypes
2
3    Copyright (C) 1996-2005, 2006 R. Grafl, A. Krall, C. Kruegel,
4    C. Oates, R. Obermaisser, M. Platter, M. Probst, S. Ring,
5    E. Steiner, C. Thalinger, D. Thuernbeck, P. Tomsich, C. Ullrich,
6    J. Wenninger, Institut f. Computersprachen - TU Wien
7
8    This file is part of CACAO.
9
10    This program is free software; you can redistribute it and/or
11    modify it under the terms of the GNU General Public License as
12    published by the Free Software Foundation; either version 2, or (at
13    your option) any later version.
14
15    This program is distributed in the hope that it will be useful, but
16    WITHOUT ANY WARRANTY; without even the implied warranty of
17    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
18    General Public License for more details.
19
20    You should have received a copy of the GNU General Public License
21    along with this program; if not, write to the Free Software
22    Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
23    02110-1301, USA.
24
25    Contact: cacao@cacaojvm.org
26
27    Authors: Christian Thalinger
28
29    Changes: Edwin Steiner
30
31    $Id: exceptions.h 4482 2006-02-07 23:18:23Z edwin $
32
33 */
34
35
36 #ifndef _EXCEPTIONS_H
37 #define _EXCEPTIONS_H
38
39 /* forward typedefs ***********************************************************/
40
41 typedef struct exceptionentry exceptionentry;
42
43 #include "config.h"
44 #include "vm/types.h"
45
46 #include "vm/global.h"
47 #include "native/include/java_lang_String.h"
48 #include "native/include/java_lang_Throwable.h"
49 #include "vm/builtin.h"
50 #include "vm/references.h"
51 #include "vm/method.h"
52
53
54 #if defined(USE_THREADS) && defined(NATIVE_THREADS)
55 #define exceptionptr    builtin_get_exceptionptrptr()
56 #else
57 #define exceptionptr    &_no_threads_exceptionptr
58 #endif
59
60 #if !defined(USE_THREADS) || !defined(NATIVE_THREADS)
61 extern java_objectheader *_no_threads_exceptionptr;
62 #endif
63
64
65 /* exceptionentry **************************************************************
66
67    Datastructure which represents an exception entry in the exception
68    table residing in the data segment.
69
70 *******************************************************************************/
71
72 struct exceptionentry {
73         classref_or_classinfo  catchtype;
74         u1                    *handlerpc;
75         u1                    *endpc;
76         u1                    *startpc;
77 };
78
79
80 /* function prototypes ********************************************************/
81
82 /* load and link exceptions used in the system */
83 bool exceptions_init(void);
84
85
86 /* exception throwing functions */
87
88 void throw_exception(void);
89 void throw_exception_exit(void);
90
91 void throw_main_exception(void);
92 void throw_main_exception_exit(void);
93
94 void throw_cacao_exception_exit(const char *exception,
95                                                                 const char *message, ...);
96
97 void exceptions_throw_outofmemory_exit(void);
98
99
100 /* initialize new exceptions */
101
102 java_objectheader *new_exception(const char *classname);
103
104 java_objectheader *new_exception_message(const char *classname,
105                                                                                  const char *message);
106
107 java_objectheader *new_exception_throwable(const char *classname,
108                                                                                    java_lang_Throwable *cause);
109
110 java_objectheader *new_exception_utfmessage(const char *classname,
111                                                                                         utf *message);
112
113 java_objectheader *new_exception_javastring(const char *classname,
114                                                                                         java_lang_String *message);
115
116 java_objectheader *new_exception_int(const char *classname, s4 i);
117
118
119 /* functions to generate compiler exceptions */
120
121 java_objectheader *new_classformaterror(classinfo *c, const char *message, ...);
122 void exceptions_throw_classformaterror(classinfo *c, const char *message, ...);
123
124 java_objectheader *new_classnotfoundexception(utf *name);
125 java_objectheader *new_noclassdeffounderror(utf *name);
126 java_objectheader *exceptions_new_linkageerror(const char *message,classinfo *c);
127 java_objectheader *exceptions_new_nosuchmethoderror(classinfo *c,
128                                                                                                         utf *name, utf *desc);
129 java_objectheader *new_internalerror(const char *message, ...);
130 java_objectheader *new_verifyerror(methodinfo *m, const char *message, ...);
131 java_objectheader *new_unsupportedclassversionerror(classinfo *c,
132                                                                                                         const char *message, ...);
133 void exceptions_throw_verifyerror_for_stack(methodinfo *m,int type);
134
135 java_objectheader *new_arithmeticexception(void);
136
137 java_objectheader *new_arrayindexoutofboundsexception(s4 index);
138 void exceptions_throw_arrayindexoutofboundsexception(void);
139
140 java_objectheader *new_arraystoreexception(void);
141 java_objectheader *new_classcastexception(void);
142
143 java_objectheader *new_illegalargumentexception(void);
144 void exceptions_throw_illegalargumentexception(void);
145
146 java_objectheader *new_illegalmonitorstateexception(void);
147
148 java_objectheader *new_negativearraysizeexception(void);
149 void exceptions_throw_negativearraysizeexception(void);
150
151 java_objectheader *new_nullpointerexception(void);
152 void exceptions_throw_nullpointerexception(void);
153
154 void classnotfoundexception_to_noclassdeffounderror(void);
155
156 void exceptions_print_exception(java_objectheader *xptr);
157
158 #endif /* _EXCEPTIONS_H */
159
160
161 /*
162  * These are local overrides for various environment variables in Emacs.
163  * Please do not remove this and leave it at the end of the file, where
164  * Emacs will automagically detect them.
165  * ---------------------------------------------------------------------
166  * Local variables:
167  * mode: c
168  * indent-tabs-mode: t
169  * c-basic-offset: 4
170  * tab-width: 4
171  * End:
172  * vim:noexpandtab:sw=4:ts=4:
173  */