26
26
#include "state.h"
27
27
#endif
28
28
29
- /* Run a string */
29
+ /* Run a string of code. The return value is a set of error flags, JANET_DO_ERROR_RUNTIME, JANET_DO_ERROR_COMPILE, and JANET_DOR_ERROR_PARSE if
30
+ * any errors were encountered in those phases. More information is printed to stderr. */
30
31
int janet_dobytes (JanetTable * env , const uint8_t * bytes , int32_t len , const char * sourcePath , Janet * out ) {
31
32
JanetParser * parser ;
32
33
int errflags = 0 , done = 0 ;
@@ -55,7 +56,7 @@ int janet_dobytes(JanetTable *env, const uint8_t *bytes, int32_t len, const char
55
56
JanetSignal status = janet_continue (fiber , janet_wrap_nil (), & ret );
56
57
if (status != JANET_SIGNAL_OK && status != JANET_SIGNAL_EVENT ) {
57
58
janet_stacktrace_ext (fiber , ret , "" );
58
- errflags |= 0x01 ;
59
+ errflags |= JANET_DO_ERROR_RUNTIME ;
59
60
done = 1 ;
60
61
}
61
62
} else {
@@ -75,7 +76,7 @@ int janet_dobytes(JanetTable *env, const uint8_t *bytes, int32_t len, const char
75
76
janet_eprintf ("%s:%d:%d: compile error: %s\n" , sourcePath ,
76
77
line , col , (const char * )cres .error );
77
78
}
78
- errflags |= 0x02 ;
79
+ errflags |= JANET_DO_ERROR_COMPILE ;
79
80
done = 1 ;
80
81
}
81
82
}
@@ -89,7 +90,7 @@ int janet_dobytes(JanetTable *env, const uint8_t *bytes, int32_t len, const char
89
90
break ;
90
91
case JANET_PARSE_ERROR : {
91
92
const char * e = janet_parser_error (parser );
92
- errflags |= 0x04 ;
93
+ errflags |= JANET_DO_ERROR_PARSE ;
93
94
ret = janet_cstringv (e );
94
95
int32_t line = (int32_t ) parser -> line ;
95
96
int32_t col = (int32_t ) parser -> column ;
0 commit comments