]> git.unchartedbackwaters.co.uk Git - francis/libjit.git/commitdiff
add JIT_RESULT_UNDEFINED_LABEL builtin error
authorAleksey Demakov <ademakov@gmail.com>
Sun, 10 May 2009 16:01:08 +0000 (16:01 +0000)
committerAleksey Demakov <ademakov@gmail.com>
Sun, 10 May 2009 16:01:08 +0000 (16:01 +0000)
ChangeLog
include/jit/jit-except.h
jit/jit-except.c

index fc864903a5aea6e1a61452b0a6ce753f0d2de252..64a9776e06fcd8dcd871769ea2e304518741f1f9 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,9 @@
 2009-05-10  Aleksey Demakov  <ademakov@gmail.com>
 
+       * 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.
 
index ccfbcc2c963727e74d020ae570e17020b0201717..07e74396027cf779fd7707b3db7e19a2d257eeca 100644 (file)
@@ -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
index a4ad75e6cb17473b0fccb475f99a8547486e6897..afd1461173a98a1706bf6bff48cf4f643f85be1d 100644 (file)
 #include "jit-rules.h"
 #include <config.h>
 #ifdef HAVE_STDLIB_H
-       #include <stdlib.h>
+include <stdlib.h>
 #endif
 #if defined(JIT_BACKEND_INTERP)
-       #include "jit-interp.h"
+include "jit-interp.h"
 #endif
 #include <stdio.h>
 #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 *))