aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorCalvin Rose <calsrose@gmail.com>2019-06-20 11:52:43 -0400
committerCalvin Rose <calsrose@gmail.com>2019-06-20 11:55:52 -0400
commit4b4fe80404a6b630ac76b63eefe1076a5a43d0f0 (patch)
tree787a30f75aaa745f1de1c33d05dc1de291a31524
parentAdd some fixes for serializing complex grammars. (diff)
Be more complete with JANET_NO_SOURCEMAPS
This actually removed sourcemaps, not just the top level annotation in bindings.
-rw-r--r--src/boot/boot.c8
-rw-r--r--src/core/compile.c2
-rw-r--r--test/suite7.janet2
3 files changed, 9 insertions, 3 deletions
diff --git a/src/boot/boot.c b/src/boot/boot.c
index fb1f160a..9e9b933c 100644
--- a/src/boot/boot.c
+++ b/src/boot/boot.c
@@ -63,7 +63,13 @@ int main(int argc, const char **argv) {
janet_def(env, "process/config", janet_wrap_table(opts), "Boot options");
/* Run bootstrap script to generate core image */
- status = janet_dobytes(env, janet_gen_boot, janet_gen_boot_size, "boot.janet", NULL);
+ const char *boot_file;
+#ifdef JANET_NO_SOURCEMAPS
+ boot_file = NULL;
+#else
+ boot_file = "boot.janet";
+#endif
+ status = janet_dobytes(env, janet_gen_boot, janet_gen_boot_size, boot_file, NULL);
/* Deinitialize vm */
janet_deinit();
diff --git a/src/core/compile.c b/src/core/compile.c
index 828e7dae..64dc5bad 100644
--- a/src/core/compile.c
+++ b/src/core/compile.c
@@ -629,7 +629,7 @@ JanetFuncDef *janetc_pop_funcdef(JanetCompiler *c) {
}
memcpy(def->bytecode, c->buffer + scope->bytecode_start, s);
janet_v__cnt(c->buffer) = scope->bytecode_start;
- if (NULL != c->mapbuffer) {
+ if (NULL != c->mapbuffer && c->source) {
size_t s = sizeof(JanetSourceMapping) * def->bytecode_length;
def->sourcemap = malloc(s);
if (NULL == def->sourcemap) {
diff --git a/test/suite7.janet b/test/suite7.janet
index 1adefb0b..9c8dbf4c 100644
--- a/test/suite7.janet
+++ b/test/suite7.janet
@@ -83,7 +83,7 @@
(def p (peg/compile grammar))
# Just make sure is valgrind clean.
-(-> p make-image load-image)
+(def p (-> p make-image load-image))
(assert (peg/match p "abc") "complex peg grammar 1")
(assert (peg/match p "[1 2 3 4]") "complex peg grammar 2")