From 10ec319c32e5e2863fa809ddb6187ff3aeef5899 Mon Sep 17 00:00:00 2001 From: Calvin Rose Date: Thu, 27 Feb 2020 00:16:54 -0600 Subject: [PATCH] Add better debug info to amalgamated source. --- src/boot/boot.c | 1 + src/boot/boot.janet | 3 ++- src/include/janet.h | 4 ++-- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/boot/boot.c b/src/boot/boot.c index dd78dadb..2fae36f2 100644 --- a/src/boot/boot.c +++ b/src/boot/boot.c @@ -105,6 +105,7 @@ int main(int argc, const char **argv) { fclose(boot_file); status = janet_dobytes(env, boot_buffer, (int32_t) boot_size, boot_filename, NULL); + free(boot_buffer); /* Deinitialize vm */ janet_deinit(); diff --git a/src/boot/boot.janet b/src/boot/boot.janet index 78c04a12..55328943 100644 --- a/src/boot/boot.janet +++ b/src/boot/boot.janet @@ -2522,7 +2522,8 @@ (defn do-one-flie [fname] - (print "\n/* " fname " */\n") + (print "\n/* " fname " */") + (print "#line 0 \"" fname "\"\n") (def source (slurp fname)) (print (string/replace-all "\r" "" source))) diff --git a/src/include/janet.h b/src/include/janet.h index cc8d7069..46e65558 100644 --- a/src/include/janet.h +++ b/src/include/janet.h @@ -681,8 +681,8 @@ JANET_API int janet_checkint(Janet x); JANET_API int janet_checkint64(Janet x); JANET_API int janet_checksize(Janet x); JANET_API JanetAbstract janet_checkabstract(Janet x, const JanetAbstractType *at); -#define janet_checkintrange(x) ((x) == (int32_t)(x)) -#define janet_checkint64range(x) ((x) == (int64_t)(x)) +#define janet_checkintrange(x) ((x) >= INT32_MIN && (x) <= INT32_MAX && (x) == (int32_t)(x)) +#define janet_checkint64range(x) ((x) >= INT64_MIN && (x) <= INT64_MAX && (x) == (int64_t)(x)) #define janet_unwrap_integer(x) ((int32_t) janet_unwrap_number(x)) #define janet_wrap_integer(x) janet_wrap_number((int32_t)(x))