Skip to content

Commit e8096a2

Browse files
committed
Remove Line Number handling code (most code will be run out of Storage now, where we know the line number)
Debugger now uses jslPrintPosition to print file+line+col
1 parent baf6218 commit e8096a2

20 files changed

+72
-136
lines changed

ChangeLog

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111
Increase chars shown in strings in console to 60
1212
The first Uncaught error is now saved to a file in Storage called ERROR (`E.setFlags({noErrorSave:true})` disables this) (#2583)
1313
If debugging via bluetooth and we disconnect, quit debugging (locks Bluetooth otherwise)
14+
Remove Line Number handling code (most code will be run out of Storage now, where we know the line number)
15+
Debugger now uses jslPrintPosition to print file+line+col
1416

1517
2v26 : nRF5x: ensure TIMER1_IRQHandler doesn't always wake idle loop up (fix #1900)
1618
Puck.js: On v2.1 ensure Puck.mag behaves like other variants - just returning the last reading (avoids glitches when used with Puck.magOn)

README_BuildProcess.md

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,6 @@ These are set automatically when `SAVE_ON_FLASH` is set (see `jsutils.h`)
180180
* `ESPR_NO_GET_SET` - No Getter/setter functionality
181181
* `ESPR_NO_OBJECT_METHODS` - No methods in objects like `{method() { ... }}`
182182
* `ESPR_NO_PROPERTY_SHORTHAND` - No property shorthand in objects like `{a}`
183-
* `ESPR_NO_LINE_NUMBERS` - disable storing and reporting of Line Numbers. Usually these take 1 var per function, but if we're executing a function from flash we can just work it out from the file when needed
184183
* `ESPR_NO_LET_SCOPING` - don't create scopes for `let` (treat it like `var`, which was the 2v13 and earlier behaviour)
185184
* `ESPR_NO_PROMISES` - Don't include promise-handling functions
186185
* `ESPR_NO_PRETOKENISE` - Don't include code to pretokenise functions marked with `"ram"` - code pretokenised in the IDE can still be executed

boards/BANGLEJS.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,12 +50,11 @@
5050
'DEFINES+=-DESPR_UNICODE_SUPPORT=1',
5151
'DEFINES+=-DESPR_NO_SOFTWARE_SERIAL=1',
5252
'DEFINES+=-DDUMP_IGNORE_VARIABLES=\'"g\\0"\'',
53-
'DEFINES+=-DSAVE_ON_FLASH_MATH',
53+
'DEFINES+=-DSAVE_ON_FLASH_MATH',
5454
'DEFINES+=-DESPR_PACKED_SYMPTR', # Pack builtin symbols' offset into pointer to save 2 bytes/symbol
5555
'DEFINES+=-DESPR_GRAPHICS_INTERNAL=1',
5656
'DEFINES+=-DUSE_FONT_6X8 -DGRAPHICS_PALETTED_IMAGES -DGRAPHICS_ANTIALIAS -DESPR_PBF_FONTS',
5757
'DEFINES+=-DNO_DUMP_HARDWARE_INITIALISATION', # don't dump hardware init - not used and saves 1k of flash
58-
'DEFINES+=-DESPR_NO_LINE_NUMBERS=1', # we execute mainly from flash, so line numbers can be worked out
5958
'DEFINES+=-DAPP_TIMER_OP_QUEUE_SIZE=6', # Bangle.js accelerometer poll handler needs something else in queue size
6059
'DFU_PRIVATE_KEY=targets/nrf5x_dfu/dfu_private_key.pem',
6160
'DFU_SETTINGS=--application-version 0xff --hw-version 52 --sd-req 0x8C,0x91',

boards/BANGLEJS2.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@
5050
#'DEFINES += -DESPR_REGOUT0_1_8V=1', # this increases power draw, so probably not correct!
5151
'DEFINES += -DESPR_LSE_ENABLE', # Ensure low speed external osc enabled
5252
'DEFINES += -DNRF_SDH_BLE_GATT_MAX_MTU_SIZE=131', # 23+x*27 rule as per https://devzone.nordicsemi.com/f/nordic-q-a/44825/ios-mtu-size-why-only-185-bytes
53-
'DEFINES += -DNRF_SDH_BLE_GAP_EVENT_LENGTH=6', # Needed to allow coded phy connections
53+
'DEFINES += -DNRF_SDH_BLE_GAP_EVENT_LENGTH=6', # Needed to allow coded phy connections
5454
'DEFINES += -DCENTRAL_LINK_COUNT=2 -DNRF_SDH_BLE_CENTRAL_LINK_COUNT=2', # allow two outgoing connections at once
5555
'LDFLAGS += -Xlinker --defsym=LD_APP_RAM_BASE=0x3b70', # set RAM base to match MTU=131 + CENTRAL_LINK_COUNT=2 + GAP_EVENT_LENGTH=6
5656
'DEFINES += -DESPR_DCDC_ENABLE=1', # Use DC/DC converter
@@ -67,7 +67,6 @@
6767
'DEFINES+=-DESPR_BATTERY_FULL_VOLTAGE=0.3144',
6868
'DEFINES+=-DUSE_FONT_6X8 -DGRAPHICS_PALETTED_IMAGES -DGRAPHICS_ANTIALIAS -DESPR_PBF_FONTS',
6969
'DEFINES+=-DNO_DUMP_HARDWARE_INITIALISATION', # don't dump hardware init - not used and saves 1k of flash
70-
'DEFINES += -DESPR_NO_LINE_NUMBERS=1', # we execute mainly from flash, so line numbers can be worked out
7170
'INCLUDE += -I$(ROOT)/libs/banglejs -I$(ROOT)/libs/misc',
7271
'WRAPPERSOURCES += libs/banglejs/jswrap_bangle.c',
7372
'WRAPPERSOURCES += libs/graphics/jswrap_font_14.c',

boards/BANGLEJS2_IFLASH.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@
5858
#'DEFINES += -DESPR_REGOUT0_1_8V=1', # this increases power draw, so probably not correct!
5959
'DEFINES += -DESPR_LSE_ENABLE', # Ensure low speed external osc enabled
6060
'DEFINES += -DNRF_SDH_BLE_GATT_MAX_MTU_SIZE=131', # 23+x*27 rule as per https://devzone.nordicsemi.com/f/nordic-q-a/44825/ios-mtu-size-why-only-185-bytes
61-
'DEFINES += -DNRF_SDH_BLE_GAP_EVENT_LENGTH=6', # Needed to allow coded phy connections
61+
'DEFINES += -DNRF_SDH_BLE_GAP_EVENT_LENGTH=6', # Needed to allow coded phy connections
6262
'DEFINES += -DCENTRAL_LINK_COUNT=2 -DNRF_SDH_BLE_CENTRAL_LINK_COUNT=2', # allow two outgoing connections at once
6363
'LDFLAGS += -Xlinker --defsym=LD_APP_RAM_BASE=0x3b70', # set RAM base to match MTU=131 + CENTRAL_LINK_COUNT=2 + GAP_EVENT_LENGTH=6
6464
'DEFINES += -DESPR_DCDC_ENABLE=1', # Use DC/DC converter
@@ -75,7 +75,6 @@
7575
'DEFINES+=-DESPR_BATTERY_FULL_VOLTAGE=0.3144',
7676
'DEFINES+=-DUSE_FONT_6X8 -DGRAPHICS_PALETTED_IMAGES -DGRAPHICS_ANTIALIAS -DESPR_PBF_FONTS',
7777
'DEFINES+=-DNO_DUMP_HARDWARE_INITIALISATION', # don't dump hardware init - not used and saves 1k of flash
78-
'DEFINES += -DESPR_NO_LINE_NUMBERS=1', # we execute mainly from flash, so line numbers can be worked out
7978
'INCLUDE += -I$(ROOT)/libs/banglejs -I$(ROOT)/libs/misc',
8079
'WRAPPERSOURCES += libs/banglejs/jswrap_bangle.c',
8180
'WRAPPERSOURCES += libs/graphics/jswrap_font_14.c',

boards/BANGLEJS2_LINUX.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@
3434
'GRAPHICS',
3535
'FILESYSTEM', # for writing screenshots/etc
3636
'LCD_MEMLCD',
37-
# 'TENSORFLOW'
37+
# 'TENSORFLOW'
3838
],
3939
'makefile' : [
4040
'LINUX=1',
@@ -44,7 +44,6 @@
4444
'DEFINES+=-DESPR_GRAPHICS_INTERNAL=1',
4545
'DEFINES += -DUSE_FONT_6X8 -DGRAPHICS_PALETTED_IMAGES -DESPR_GRAPHICS_3BIT',
4646
'DEFINES += -DNO_DUMP_HARDWARE_INITIALISATION', # don't dump hardware init - not used and saves 1k of flash
47-
'DEFINES += -DESPR_NO_LINE_NUMBERS=1', # we execute mainly from flash, so line numbers can be worked out
4847
'INCLUDE += -I$(ROOT)/libs/banglejs -I$(ROOT)/libs/misc',
4948
'WRAPPERSOURCES += libs/banglejs/jswrap_bangle.c',
5049
'WRAPPERSOURCES += libs/graphics/jswrap_font_6x15.c',
@@ -80,7 +79,7 @@
8079
'BTN1' : { 'pin' : 'D17', 'pinstate' : 'IN_PULLDOWN' }, # Pin negated in software
8180
'LED1' : { 'pin' : 'D8', 'novariable':True }, # Backlight flash for low level debug - but in code we just use 'fake' LEDs
8281
'LCD' : {
83-
'width' : 176, 'height' : 176,
82+
'width' : 176, 'height' : 176,
8483
'bpp' : 3,
8584
'controller' : 'LPM013M126', # LPM013M126C
8685
'pin_cs' : 'D5',

boards/BANGLEJS2_NOFLASH.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,6 @@
6565
'DEFINES+=-DESPR_BATTERY_FULL_VOLTAGE=0.3144',
6666
'DEFINES+=-DUSE_FONT_6X8 -DGRAPHICS_PALETTED_IMAGES -DGRAPHICS_ANTIALIAS -DESPR_PBF_FONTS',
6767
'DEFINES+=-DNO_DUMP_HARDWARE_INITIALISATION', # don't dump hardware init - not used and saves 1k of flash
68-
'DEFINES += -DESPR_NO_LINE_NUMBERS=1', # we execute mainly from flash, so line numbers can be worked out
6968
'INCLUDE += -I$(ROOT)/libs/banglejs -I$(ROOT)/libs/misc',
7069
'WRAPPERSOURCES += libs/banglejs/jswrap_bangle.c',
7170
'WRAPPERSOURCES += libs/graphics/jswrap_font_6x15.c',

boards/EMSCRIPTEN.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,14 +33,13 @@
3333
],
3434
'makefile' : [
3535
'EMSCRIPTEN=1',
36-
'USE_DEBUGGER=0', # We can't use debugger in emulator as we're single-threaded and it uses IRQs on embedded to work
36+
'USE_DEBUGGER=0', # We can't use debugger in emulator as we're single-threaded and it uses IRQs on embedded to work
3737
'DEFINES += -DESPR_HWVERSION=1',
3838
'DEFINES += -DUSE_CALLFUNCTION_HACK', # required to handle calls properly
3939
'DEFINES += -DBANGLEJS -DBANGLEJS_F18 -DEMULATED -DEMSCRIPTEN',
4040
'DEFINES += -DSPIFLASH_BASE=0x8000000 -DSPIFLASH_LENGTH=4194304',
4141
# 'DEFINES+=-DCUSTOM_GETBATTERY=jswrap_banglejs_getBattery',
4242
'DEFINES+=-DDUMP_IGNORE_VARIABLES=\'"g\\0"\'',
43-
'DEFINES += -DESPR_NO_LINE_NUMBERS=1', # we execute mainly from flash, so line numbers can be worked out
4443
'DEFINES+=-DESPR_GRAPHICS_INTERNAL=1',
4544
'DEFINES+=-DUSE_FONT_6X8 -DGRAPHICS_PALETTED_IMAGES -DGRAPHICS_ANTIALIAS',
4645
'INCLUDE += -I$(ROOT)/libs/banglejs -I$(ROOT)/libs/misc',

boards/EMSCRIPTEN2.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,6 @@
4141
'DEFINES += -DSPIFLASH_BASE=0x8000000 -DSPIFLASH_LENGTH=8388608',
4242
# 'DEFINES+=-DCUSTOM_GETBATTERY=jswrap_banglejs_getBattery',
4343
'DEFINES+=-DDUMP_IGNORE_VARIABLES=\'"g\\0"\'',
44-
'DEFINES += -DESPR_NO_LINE_NUMBERS=1', # we execute mainly from flash, so line numbers can be worked out
4544
'DEFINES+=-DESPR_GRAPHICS_INTERNAL=1',
4645
'DEFINES+=-DUSE_FONT_6X8 -DGRAPHICS_PALETTED_IMAGES -DGRAPHICS_ANTIALIAS',
4746
'INCLUDE += -I$(ROOT)/libs/banglejs -I$(ROOT)/libs/misc',
@@ -84,7 +83,7 @@
8483
'BTN1' : { 'pin' : 'D17', 'pinstate' : 'IN_PULLDOWN' }, # Pin negated in software
8584
'LED1' : { 'pin' : 'D8', 'novariable':True }, # Backlight flash for low level debug - but in code we just use 'fake' LEDs
8685
'LCD' : {
87-
'width' : 176, 'height' : 176,
86+
'width' : 176, 'height' : 176,
8887
'bpp' : 3,
8988
'controller' : 'LPM013M126', # LPM013M126C
9089
'pin_cs' : 'D5',

boards/MICROBIT1.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,6 @@
3434
'makefile' : [
3535
'SAVE_ON_FLASH=1',
3636
'DEFINES+=-DSAVE_ON_FLASH_EXTREME',
37-
'DEFINES+=-DESPR_NO_LINE_NUMBERS',
3837
'DEFINES+=-DESPR_LIMIT_DATE_RANGE',
3938
'DEFINES+=-DESPR_PACKED_SYMPTR', # Pack builtin symbols' offset into pointer to save 2 bytes/symbol
4039
'DEFINES+=-DESPR_NO_DAYLIGHT_SAVING',

src/jsflash.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1415,7 +1415,7 @@ bool jsfLoadBootCodeFromFlash(bool isReset) {
14151415
if (jsiStatus & JSIS_FIRST_BOOT) {
14161416
JsVar *code = jsfReadFile(jsfNameFromString(".bootPowerOn"),0,0);
14171417
if (code) {
1418-
jsvUnLock2(jspEvaluateVar(code,0,".bootPowerOn",0), code);
1418+
jsvUnLock2(jspEvaluateVar(code,0,".bootPowerOn"), code);
14191419
jsiCheckErrors(false);
14201420
}
14211421
}
@@ -1437,15 +1437,15 @@ bool jsfLoadBootCodeFromFlash(bool isReset) {
14371437
filename[5] = (char)('0'+i);
14381438
JsVar *code = jsfReadFile(jsfNameFromString(filename),0,0);
14391439
if (code) {
1440-
jsvUnLock2(jspEvaluateVar(code,0,filename,0), code);
1440+
jsvUnLock2(jspEvaluateVar(code,0,filename), code);
14411441
jsiCheckErrors(false);
14421442
}
14431443
}
14441444
}
14451445
// Load normal boot code
14461446
JsVar *code = jsfGetBootCodeFromFlash(isReset);
14471447
if (!code) return false;
1448-
jsvUnLock2(jspEvaluateVar(code,0,"boot code",0), code);
1448+
jsvUnLock2(jspEvaluateVar(code,0,"boot code"), code);
14491449
jsiCheckErrors(false);
14501450
return true;
14511451
}

src/jsinteractive.c

Lines changed: 20 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,6 @@ size_t inputCursorPos = 0; ///< The position of the cursor in the input line
128128
InputState inputState = 0; ///< state for dealing with cursor keys
129129
uint16_t inputPacketLength; ///< When receiving an input packet, the length of it
130130
uint16_t inputStateNumber; ///< Number from when `Esc [ 1234` is sent - for storing line number
131-
uint16_t jsiLineNumberOffset; ///< When we execute code, this is the 'offset' we apply to line numbers in error/debug
132131
bool hasUsedHistory = false; ///< Used to speed up - if we were cycling through history and then edit, we need to copy the string
133132
unsigned char loopsIdling = 0; ///< How many times around the loop have we been entirely idle?
134133
JsErrorFlags lastJsErrorFlags = 0; ///< Compare with jsErrorFlags in order to report errors
@@ -284,8 +283,11 @@ NO_INLINE void jsiConsolePrintString(const char *str) {
284283
}
285284
}
286285

286+
/// Used as a callback for using vcbprintf to write to the console. If given *size_t as user_data it incremenets it with the string length
287287
void vcbprintf_callback_jsiConsolePrintString(const char *str, void* user_data) {
288-
NOT_USED(user_data);
288+
if (user_data) {
289+
*((size_t*)user_data) += strlen(str);
290+
}
289291
jsiConsolePrintString(str);
290292
}
291293

@@ -391,9 +393,9 @@ void jsiMoveCursor(size_t oldX, size_t oldY, size_t newX, size_t newY) {
391393
void jsiMoveCursorChar(JsVar *v, size_t fromCharacter, size_t toCharacter) {
392394
if (fromCharacter==toCharacter) return;
393395
size_t oldX, oldY;
394-
jsvGetLineAndCol(v, fromCharacter, &oldY, &oldX);
396+
jsvGetLineAndCol(v, fromCharacter, &oldY, &oldX, NULL);
395397
size_t newX, newY;
396-
jsvGetLineAndCol(v, toCharacter, &newY, &newX);
398+
jsvGetLineAndCol(v, toCharacter, &newY, &newX, NULL);
397399
jsiMoveCursor(oldX, oldY, newX, newY);
398400
}
399401

@@ -501,7 +503,6 @@ void jsiSoftInit(bool hasBeenReset) {
501503
events = jsvNewEmptyArray();
502504
inputLine = jsvNewFromEmptyString();
503505
inputCursorPos = 0;
504-
jsiLineNumberOffset = 0;
505506
jsiInputLineCursorMoved();
506507
inputLineIterator.var = 0;
507508

@@ -539,7 +540,7 @@ void jsiSoftInit(bool hasBeenReset) {
539540
// Now run initialisation code
540541
JsVar *initCode = jsvObjectGetChildIfExists(execInfo.hiddenRoot, JSI_INIT_CODE_NAME);
541542
if (initCode) {
542-
jsvUnLock2(jspEvaluateVar(initCode, 0, "initcode", 0), initCode);
543+
jsvUnLock2(jspEvaluateVar(initCode, 0, "initcode"), initCode);
543544
jsiCheckErrors(false);
544545
jsvObjectRemoveChild(execInfo.hiddenRoot, JSI_INIT_CODE_NAME);
545546
}
@@ -1239,28 +1240,28 @@ void jsiHandleEnd() {
12391240
/** Page up/down move cursor to beginnint or end */
12401241
void jsiHandlePageUpDown(bool isDown) {
12411242
size_t x,y;
1242-
jsvGetLineAndCol(inputLine, inputCursorPos, &y, &x);
1243+
jsvGetLineAndCol(inputLine, inputCursorPos, &y, &x, NULL);
12431244
if (!isDown) { // up
12441245
inputCursorPos = 0;
12451246
} else { // down
12461247
inputCursorPos = jsvGetStringLength(inputLine);
12471248
}
12481249
size_t newX=x,newY=y;
1249-
jsvGetLineAndCol(inputLine, inputCursorPos, &newY, &newX);
1250+
jsvGetLineAndCol(inputLine, inputCursorPos, &newY, &newX, NULL);
12501251
jsiMoveCursor(x,y,newX,newY);
12511252
}
12521253

12531254
void jsiHandleMoveUpDown(int direction) {
12541255
size_t x,y, lines=jsvGetLinesInString(inputLine);
1255-
jsvGetLineAndCol(inputLine, inputCursorPos, &y, &x);
1256+
jsvGetLineAndCol(inputLine, inputCursorPos, &y, &x, NULL);
12561257
size_t newX=x,newY=y;
12571258
newY = (size_t)((int)newY + direction);
12581259
if (newY<1) newY=1;
12591260
if (newY>lines) newY=lines;
12601261
// work out cursor pos and feed back through - we might not be able to get right to the same place
12611262
// if we move up
12621263
inputCursorPos = jsvGetIndexFromLineAndCol(inputLine, newY, newX);
1263-
jsvGetLineAndCol(inputLine, inputCursorPos, &newY, &newX);
1264+
jsvGetLineAndCol(inputLine, inputCursorPos, &newY, &newX, NULL);
12641265
if (jsiShowInputLine()) {
12651266
jsiMoveCursor(x,y,newX,newY);
12661267
}
@@ -1557,14 +1558,13 @@ void jsiHandleNewLine(bool execute) {
15571558
#endif
15581559
{
15591560
// execute!
1560-
JsVar *v = jspEvaluateVar(lineToExecute, 0, "REPL", jsiLineNumberOffset);
1561+
JsVar *v = jspEvaluateVar(lineToExecute, 0, "REPL");
15611562
// add input line to history
15621563
bool isEmpty = jsvIsEmptyString(lineToExecute);
15631564
// Don't store history if we're not echoing back to the console (it probably wasn't typed by the user)
15641565
if (!isEmpty && jsiEcho())
15651566
jsiHistoryAddLine(lineToExecute);
15661567
jsvUnLock(lineToExecute);
1567-
jsiLineNumberOffset = 0; // forget the current line number now
15681568
// print result (but NOT if we had an error)
15691569
if (jsiEcho() && !jspHasError() && !isEmpty) {
15701570
jsiConsolePrintChar('=');
@@ -1948,8 +1948,7 @@ static void jsiHandleConsoleChar(char ch) {
19481948
if (ch>='0' && ch<='9') {
19491949
inputStateNumber = (uint16_t)(10*inputStateNumber + ch - '0');
19501950
} else {
1951-
if (ch=='d') jsiLineNumberOffset = inputStateNumber;
1952-
else if (ch=='H' /* 72 */) {
1951+
if (ch=='H' /* 72 */) {
19531952
if (inputStateNumber==2) jsiClearInputLine(true); // Erase current line
19541953
} else if (ch==126) {
19551954
if (inputStateNumber==1) jsiHandleHome(); // Numpad Home
@@ -2069,7 +2068,7 @@ static NO_INLINE bool jsiExecuteEventCallbackInner(JsVar *thisVar, JsVar *callba
20692068
} else if (jsvIsFunction(callbackNoNames)) {
20702069
jsvUnLock(jspExecuteFunction(callbackNoNames, thisVar, (int)argCount, argPtr));
20712070
} else if (jsvIsString(callbackNoNames)) {
2072-
jsvUnLock(jspEvaluateVar(callbackNoNames, 0, "event", 0));
2071+
jsvUnLock(jspEvaluateVar(callbackNoNames, 0, "event"));
20732072
} else
20742073
jsError("Unknown type of callback in Event Queue");
20752074
return ok;
@@ -2594,7 +2593,7 @@ void jsiIdle() {
25942593
// load the code we specified
25952594
JsVar *code = jsfReadFile(filename,0,0);
25962595
if (code) // only supply the filename if we're sure it's zero terminated
2597-
jsvUnLock2(jspEvaluateVar(code,0,filename.c[sizeof(filename.c)-1] ? filename.c : "load",0), code);
2596+
jsvUnLock2(jspEvaluateVar(code,0,filename.c[sizeof(filename.c)-1] ? filename.c : "load"), code);
25982597
} else {
25992598
jsiSoftKill();
26002599
jspSoftKill();
@@ -2826,22 +2825,11 @@ void jsiDebuggerLoop() {
28262825
jsiStatus = (jsiStatus & ~JSIS_ECHO_OFF_MASK) | JSIS_IN_DEBUGGER;
28272826

28282827
if (lex) {
2829-
char lineStr[9];
2830-
// Get a string fo the form '1234 ' for the line number
2831-
// ... but only if the line number was set, otherwise use spaces
2832-
#ifndef ESPR_NO_LINE_NUMBERS
2833-
if (lex->lineNumberOffset) {
2834-
itostr((JsVarInt)jslGetLineNumber() + (JsVarInt)lex->lineNumberOffset - 1, lineStr, 10);
2835-
} else
2836-
#endif
2837-
{ // FIXME: Maybe if executing from a Storage file we use line numbers within that file?
2838-
lineStr[0]=0;
2839-
}
2840-
size_t lineLen = strlen(lineStr);
2841-
while (lineLen < sizeof(lineStr)-1) lineStr[lineLen++]=' ';
2842-
lineStr[lineLen] = 0;
2843-
// print the line of code, prefixed by the line number, and with a pointer to the exact character in question
2844-
jslPrintTokenLineMarker(vcbprintf_callback_jsiConsolePrintString, 0, lex, lex->tokenLastStart, lineStr);
2828+
// print the line of code, prefixed by the file/line number, and with a pointer to the exact character in question
2829+
size_t prefixLength = 0;
2830+
jslPrintPosition(vcbprintf_callback_jsiConsolePrintString, &prefixLength, lex, lex->tokenLastStart);
2831+
jsiConsolePrint(" "); prefixLength+=3;
2832+
jslPrintTokenLineMarker(vcbprintf_callback_jsiConsolePrintString, 0, lex, lex->tokenLastStart, prefixLength);
28452833
}
28462834

28472835
while (!(jsiStatus & JSIS_EXIT_DEBUGGER) &&

0 commit comments

Comments
 (0)