From: Aleksey Demakov Date: Sun, 10 May 2009 16:01:08 +0000 (+0000) Subject: add JIT_RESULT_UNDEFINED_LABEL builtin error X-Git-Tag: before.move.to.git~3 X-Git-Url: https://git.unchartedbackwaters.co.uk/w/?a=commitdiff_plain;h=1dd3816a38f864710036f3dc7693c4d13b6fc177;p=francis%2Flibjit.git add JIT_RESULT_UNDEFINED_LABEL builtin error --- diff --git a/ChangeLog b/ChangeLog index fc86490..64a9776 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2009-05-10 Aleksey Demakov + * include/jit/jit-except.h (JIT_RESULT_UNDEFINED_LABEL): + * jit/jit-except.c (jit_exception_builtin): add new builtin + exception. + * jit/jit-internal.h (struct _jit_label_info): add srtuct. (struct _jit_builder): replace label_blocks with label_info. diff --git a/include/jit/jit-except.h b/include/jit/jit-except.h index ccfbcc2..07e7439 100644 --- a/include/jit/jit-except.h +++ b/include/jit/jit-except.h @@ -30,16 +30,17 @@ extern "C" { /* * Builtin exception type codes, and result values for intrinsic functions. */ -#define JIT_RESULT_OK 1 -#define JIT_RESULT_OVERFLOW 0 -#define JIT_RESULT_ARITHMETIC -1 -#define JIT_RESULT_DIVISION_BY_ZERO -2 -#define JIT_RESULT_COMPILE_ERROR -3 -#define JIT_RESULT_OUT_OF_MEMORY -4 -#define JIT_RESULT_NULL_REFERENCE -5 -#define JIT_RESULT_NULL_FUNCTION -6 -#define JIT_RESULT_CALLED_NESTED -7 -#define JIT_RESULT_OUT_OF_BOUNDS -8 +#define JIT_RESULT_OK (1) +#define JIT_RESULT_OVERFLOW (0) +#define JIT_RESULT_ARITHMETIC (-1) +#define JIT_RESULT_DIVISION_BY_ZERO (-2) +#define JIT_RESULT_COMPILE_ERROR (-3) +#define JIT_RESULT_OUT_OF_MEMORY (-4) +#define JIT_RESULT_NULL_REFERENCE (-5) +#define JIT_RESULT_NULL_FUNCTION (-6) +#define JIT_RESULT_CALLED_NESTED (-7) +#define JIT_RESULT_OUT_OF_BOUNDS (-8) +#define JIT_RESULT_UNDEFINED_LABEL (-9) /* * Exception handling function for builtin exceptions. @@ -59,12 +60,13 @@ jit_exception_func jit_exception_set_handler(jit_exception_func handler); jit_exception_func jit_exception_get_handler(void); jit_stack_trace_t jit_exception_get_stack_trace(void); unsigned int jit_stack_trace_get_size(jit_stack_trace_t trace); -jit_function_t jit_stack_trace_get_function - (jit_context_t context, jit_stack_trace_t trace, unsigned int posn); -void *jit_stack_trace_get_pc - (jit_stack_trace_t trace, unsigned int posn); -unsigned int jit_stack_trace_get_offset - (jit_context_t context, jit_stack_trace_t trace, unsigned int posn); +jit_function_t jit_stack_trace_get_function(jit_context_t context, + jit_stack_trace_t trace, + unsigned int posn); +void *jit_stack_trace_get_pc(jit_stack_trace_t trace, unsigned int posn); +unsigned int jit_stack_trace_get_offset(jit_context_t context, + jit_stack_trace_t trace, + unsigned int posn); void jit_stack_trace_free(jit_stack_trace_t trace); #ifdef __cplusplus diff --git a/jit/jit-except.c b/jit/jit-except.c index a4ad75e..afd1461 100644 --- a/jit/jit-except.c +++ b/jit/jit-except.c @@ -24,10 +24,10 @@ #include "jit-rules.h" #include #ifdef HAVE_STDLIB_H - #include +# include #endif #if defined(JIT_BACKEND_INTERP) - #include "jit-interp.h" +# include "jit-interp.h" #endif #include #include "jit-setjmp.h" @@ -195,6 +195,15 @@ void jit_exception_throw(void *object) * @item JIT_RESULT_CALLED_NESTED * An attempt was made to call a nested function from a non-nested context * (value is -7). + * + * @vindex JIT_RESULT_OUT_OF_BOUNDS + * @item JIT_RESULT_OUT_OF_BOUNDS + * The operation resulted in an out of bounds array access (value is -8). + * + * @vindex JIT_RESULT_UNDEFINED_LABEL + * @item JIT_RESULT_UNDEFINED_LABEL + * A branch operation used a label that was not defined anywhere in the + * function (value is -9). * @end table * @end deftypefun @*/ @@ -212,7 +221,8 @@ void jit_exception_builtin(int exception_type) "Null pointer dereferenced", "Null function pointer called", "Nested function called from non-nested context", - "Array index out of bounds" + "Array index out of bounds", + "Undefined label" }; #define num_messages (sizeof(messages) / sizeof(const char *))