2626#include "state.h"
2727#endif
2828
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. */
3031int janet_dobytes (JanetTable * env , const uint8_t * bytes , int32_t len , const char * sourcePath , Janet * out ) {
3132 JanetParser * parser ;
3233 int errflags = 0 , done = 0 ;
@@ -55,7 +56,7 @@ int janet_dobytes(JanetTable *env, const uint8_t *bytes, int32_t len, const char
5556 JanetSignal status = janet_continue (fiber , janet_wrap_nil (), & ret );
5657 if (status != JANET_SIGNAL_OK && status != JANET_SIGNAL_EVENT ) {
5758 janet_stacktrace_ext (fiber , ret , "" );
58- errflags |= 0x01 ;
59+ errflags |= JANET_DO_ERROR_RUNTIME ;
5960 done = 1 ;
6061 }
6162 } else {
@@ -75,7 +76,7 @@ int janet_dobytes(JanetTable *env, const uint8_t *bytes, int32_t len, const char
7576 janet_eprintf ("%s:%d:%d: compile error: %s\n" , sourcePath ,
7677 line , col , (const char * )cres .error );
7778 }
78- errflags |= 0x02 ;
79+ errflags |= JANET_DO_ERROR_COMPILE ;
7980 done = 1 ;
8081 }
8182 }
@@ -89,7 +90,7 @@ int janet_dobytes(JanetTable *env, const uint8_t *bytes, int32_t len, const char
8990 break ;
9091 case JANET_PARSE_ERROR : {
9192 const char * e = janet_parser_error (parser );
92- errflags |= 0x04 ;
93+ errflags |= JANET_DO_ERROR_PARSE ;
9394 ret = janet_cstringv (e );
9495 int32_t line = (int32_t ) parser -> line ;
9596 int32_t col = (int32_t ) parser -> column ;
0 commit comments