diff --git a/gen/function_source.c b/gen/function_source.c index f486ee566..489dfa28a 100644 --- a/gen/function_source.c +++ b/gen/function_source.c @@ -2,9 +2,9 @@ #include "quickjs-libc.h" -const uint32_t qjsc_function_source_size = 314; +const uint32_t qjsc_function_source_size = 320; -const uint8_t qjsc_function_source[314] = { +const uint8_t qjsc_function_source[320] = { 0x13, 0x05, 0x01, 0x30, 0x74, 0x65, 0x73, 0x74, 0x73, 0x2f, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x5f, 0x73, 0x6f, 0x75, 0x72, 0x63, @@ -42,9 +42,9 @@ const uint8_t qjsc_function_source[314] = { 0x00, 0xb0, 0xeb, 0x0b, 0x39, 0x95, 0x00, 0x00, 0x00, 0x63, 0x02, 0x00, 0xf0, 0x30, 0x69, 0x02, 0x00, 0x69, 0x01, 0x00, 0x06, 0x2f, 0xc0, 0x03, - 0x01, 0x01, 0x0e, 0x00, 0x1c, 0x0a, 0x2a, 0x5d, - 0x18, 0x00, 0x10, 0x08, 0x25, 0x76, 0x0e, 0x5d, - 0x18, 0x00, + 0x01, 0x01, 0x14, 0x00, 0x1c, 0x0a, 0x2a, 0x26, + 0x03, 0x39, 0x28, 0x00, 0x10, 0x08, 0x27, 0x11, + 0x12, 0x67, 0x0d, 0x26, 0x03, 0x39, 0x28, 0x00, }; static JSContext *JS_NewCustomContext(JSRuntime *rt) diff --git a/gen/hello_module.c b/gen/hello_module.c index 65cd2e75f..b6f1470bb 100644 --- a/gen/hello_module.c +++ b/gen/hello_module.c @@ -2,9 +2,9 @@ #include "quickjs-libc.h" -const uint32_t qjsc_fib_module_size = 282; +const uint32_t qjsc_fib_module_size = 290; -const uint8_t qjsc_fib_module[282] = { +const uint8_t qjsc_fib_module[290] = { 0x13, 0x03, 0x01, 0x2c, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2f, 0x66, 0x69, 0x62, 0x5f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, 0x65, 0x2e, @@ -19,8 +19,9 @@ const uint8_t qjsc_fib_module[282] = { 0xb5, 0xa8, 0xeb, 0x03, 0xb5, 0x28, 0xd2, 0xb6, 0xad, 0xeb, 0x03, 0xb6, 0x28, 0xde, 0xd2, 0xb6, 0x9f, 0xf0, 0xde, 0xd2, 0xb7, 0x9f, 0xf0, 0x9e, - 0x28, 0xc0, 0x03, 0x02, 0x08, 0x06, 0x00, 0x0f, - 0x0e, 0x10, 0x1b, 0x1a, 0x8d, 0x01, 0x66, 0x75, + 0x28, 0xc0, 0x03, 0x02, 0x08, 0x0e, 0x09, 0x0c, + 0x27, 0x0a, 0x28, 0x02, 0x07, 0x08, 0x11, 0x0a, + 0x07, 0x08, 0x07, 0x08, 0x8d, 0x01, 0x66, 0x75, 0x6e, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x20, 0x66, 0x69, 0x62, 0x28, 0x6e, 0x29, 0x0a, 0x7b, 0x0a, 0x20, 0x20, 0x20, 0x20, 0x69, 0x66, 0x20, 0x28, @@ -43,9 +44,9 @@ const uint8_t qjsc_fib_module[282] = { 0x00, 0x00, }; -const uint32_t qjsc_hello_module_size = 183; +const uint32_t qjsc_hello_module_size = 187; -const uint8_t qjsc_hello_module[183] = { +const uint8_t qjsc_hello_module[187] = { 0x13, 0x07, 0x01, 0x30, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2f, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x5f, 0x6d, 0x6f, 0x64, 0x75, 0x6c, @@ -67,8 +68,9 @@ const uint8_t qjsc_hello_module[183] = { 0x00, 0x00, 0x00, 0x43, 0xe4, 0x00, 0x00, 0x00, 0x04, 0xe6, 0x00, 0x00, 0x00, 0x66, 0x00, 0x00, 0xbd, 0x0a, 0xf0, 0x24, 0x02, 0x00, 0x0e, 0x06, - 0x2f, 0xc0, 0x03, 0x01, 0x01, 0x08, 0x18, 0x28, - 0x36, 0x17, 0x62, 0x00, 0x2a, 0x20, 0x00, + 0x2f, 0xc0, 0x03, 0x01, 0x01, 0x0c, 0x00, 0x04, + 0x08, 0x00, 0x34, 0x10, 0x30, 0x0f, 0x34, 0x10, + 0x2a, 0x20, 0x00, }; static JSContext *JS_NewCustomContext(JSRuntime *rt) diff --git a/gen/test_fib.c b/gen/test_fib.c index efa478d01..282650063 100644 --- a/gen/test_fib.c +++ b/gen/test_fib.c @@ -2,9 +2,9 @@ #include "quickjs-libc.h" -const uint32_t qjsc_test_fib_size = 290; +const uint32_t qjsc_test_fib_size = 294; -const uint8_t qjsc_test_fib[290] = { +const uint8_t qjsc_test_fib[294] = { 0x13, 0x0e, 0x01, 0x28, 0x65, 0x78, 0x61, 0x6d, 0x70, 0x6c, 0x65, 0x73, 0x2f, 0x74, 0x65, 0x73, 0x74, 0x5f, 0x66, 0x69, 0x62, 0x2e, 0x6a, 0x73, @@ -39,9 +39,9 @@ const uint8_t qjsc_test_fib[290] = { 0xea, 0x00, 0x00, 0x00, 0x43, 0xeb, 0x00, 0x00, 0x00, 0x04, 0xed, 0x00, 0x00, 0x00, 0x66, 0x02, 0x00, 0xbd, 0x0a, 0xf0, 0x24, 0x02, 0x00, 0x0e, - 0x06, 0x2f, 0xc0, 0x03, 0x01, 0x01, 0x0a, 0x00, - 0x45, 0x08, 0x6c, 0x36, 0x5b, 0x62, 0x00, 0x2a, - 0x20, 0x00, + 0x06, 0x2f, 0xc0, 0x03, 0x01, 0x01, 0x0e, 0x41, + 0x3c, 0x00, 0x39, 0x06, 0x3b, 0x34, 0x10, 0x30, + 0x0f, 0x34, 0x10, 0x2a, 0x20, 0x00, }; static JSContext *JS_NewCustomContext(JSRuntime *rt) diff --git a/quickjs.c b/quickjs.c index c534a266f..9e5370136 100644 --- a/quickjs.c +++ b/quickjs.c @@ -20414,8 +20414,8 @@ static void emit_source_loc(JSParseState *s) DynBuf *bc = &fd->byte_code; dbuf_putc(bc, OP_source_loc); - dbuf_put_u32(bc, s->last_line_num); - dbuf_put_u32(bc, s->last_col_num); + dbuf_put_u32(bc, s->token.line_num); + dbuf_put_u32(bc, s->token.col_num); } static void emit_op(JSParseState *s, uint8_t val) @@ -24424,6 +24424,7 @@ static __exception int js_parse_expr_binary(JSParseState *s, int level, } if (next_token(s)) return -1; + emit_source_loc(s); if (js_parse_expr_binary(s, level - 1, parse_flags)) return -1; emit_op(s, opcode); diff --git a/tests/test_builtin.js b/tests/test_builtin.js index 2211f5502..c6ea5bb82 100644 --- a/tests/test_builtin.js +++ b/tests/test_builtin.js @@ -7,12 +7,12 @@ function test_exception_source_pos() var e; try { - throw new Error(""); // line 10, column 15 + throw new Error(""); // line 10, column 19 } catch(_e) { e = _e; } - assert(e.stack.includes("test_builtin.js:10:15")); + assert(e.stack.includes("test_builtin.js:10:19")); } // Keep this at the top; it tests source positions. @@ -36,7 +36,7 @@ function test_exception_prepare_stack() }; try { - throw new Error(""); // line 39, column 15 + throw new Error(""); // line 39, column 19 } catch(_e) { e = _e; } @@ -48,7 +48,7 @@ function test_exception_prepare_stack() assert(f.getFunctionName(), 'test_exception_prepare_stack'); assert(f.getFileName().endsWith('test_builtin.js')); assert(f.getLineNumber(), 39); - assert(f.getColumnNumber(), 15); + assert(f.getColumnNumber(), 19); assert(!f.isNative()); } @@ -64,7 +64,7 @@ function test_exception_stack_size_limit() }; try { - throw new Error(""); // line 67, column 15 + throw new Error(""); // line 67, column 19 } catch(_e) { e = _e; } @@ -77,7 +77,7 @@ function test_exception_stack_size_limit() assert(f.getFunctionName(), 'test_exception_stack_size_limit'); assert(f.getFileName().endsWith('test_builtin.js')); assert(f.getLineNumber(), 67); - assert(f.getColumnNumber(), 15); + assert(f.getColumnNumber(), 19); assert(!f.isNative()); }