github.com/goccy/go-jit@v0.0.0-20200514131505-ff78d45cf6af/internal/ccall/include/jit/jit-except.h (about) 1 /* 2 * jit-except.h - Exception handling functions. 3 * 4 * Copyright (C) 2004 Southern Storm Software, Pty Ltd. 5 * 6 * The libjit library is free software: you can redistribute it and/or 7 * modify it under the terms of the GNU Lesser General Public License 8 * as published by the Free Software Foundation, either version 2.1 of 9 * the License, or (at your option) any later version. 10 * 11 * The libjit library is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 14 * Lesser General Public License for more details. 15 * 16 * You should have received a copy of the GNU Lesser General Public 17 * License along with the libjit library. If not, see 18 * <http://www.gnu.org/licenses/>. 19 */ 20 21 #ifndef _JIT_EXCEPT_H 22 #define _JIT_EXCEPT_H 23 24 #include <jit/jit-common.h> 25 26 #ifdef __cplusplus 27 extern "C" { 28 #endif 29 30 /* 31 * Builtin exception type codes, and result values for intrinsic functions. 32 */ 33 #define JIT_RESULT_OK (1) 34 #define JIT_RESULT_OVERFLOW (0) 35 #define JIT_RESULT_ARITHMETIC (-1) 36 #define JIT_RESULT_DIVISION_BY_ZERO (-2) 37 #define JIT_RESULT_COMPILE_ERROR (-3) 38 #define JIT_RESULT_OUT_OF_MEMORY (-4) 39 #define JIT_RESULT_NULL_REFERENCE (-5) 40 #define JIT_RESULT_NULL_FUNCTION (-6) 41 #define JIT_RESULT_CALLED_NESTED (-7) 42 #define JIT_RESULT_OUT_OF_BOUNDS (-8) 43 #define JIT_RESULT_UNDEFINED_LABEL (-9) 44 #define JIT_RESULT_MEMORY_FULL (-10000) 45 46 /* 47 * Exception handling function for builtin exceptions. 48 */ 49 typedef void *(*jit_exception_func)(int exception_type); 50 51 /* 52 * External function declarations. 53 */ 54 void *jit_exception_get_last(void); 55 void *jit_exception_get_last_and_clear(void); 56 void jit_exception_set_last(void *object); 57 void jit_exception_clear_last(void); 58 void jit_exception_throw(void *object); 59 void jit_exception_builtin(int exception_type); 60 jit_exception_func jit_exception_set_handler(jit_exception_func handler); 61 jit_exception_func jit_exception_get_handler(void); 62 jit_stack_trace_t jit_exception_get_stack_trace(void); 63 unsigned int jit_stack_trace_get_size(jit_stack_trace_t trace); 64 jit_function_t jit_stack_trace_get_function(jit_context_t context, 65 jit_stack_trace_t trace, 66 unsigned int posn); 67 void *jit_stack_trace_get_pc(jit_stack_trace_t trace, unsigned int posn); 68 unsigned int jit_stack_trace_get_offset(jit_context_t context, 69 jit_stack_trace_t trace, 70 unsigned int posn); 71 void jit_stack_trace_free(jit_stack_trace_t trace); 72 73 #ifdef __cplusplus 74 }; 75 #endif 76 77 #endif /* _JIT_EXCEPT_H */