From 655f1e3b19d7844e82ea9216484f8a7a796d86c6 Mon Sep 17 00:00:00 2001 From: FellippeHeitor Date: Mon, 19 Jul 2021 22:25:15 -0300 Subject: [PATCH 01/31] Sends call stack to IDE when an error occurs. --- source/ide/ide_methods.bas | 7 ++++++- source/utilities/vwatch/vwatch.bm | 18 ++++++++++-------- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/source/ide/ide_methods.bas b/source/ide/ide_methods.bas index 42a8cdc8d..90785e722 100644 --- a/source/ide/ide_methods.bas +++ b/source/ide/ide_methods.bas @@ -6428,6 +6428,7 @@ SUB DebugMode cmd$ = "call stack" GOSUB SendCommand + IF BypassRequestCallStack THEN GOTO ShowCallStack dummy = DarkenFGBG(0) clearStatusWindow 0 setStatusMessage 1, "Requesting call stack...", 7 @@ -6443,6 +6444,7 @@ SUB DebugMode IF cmd$ = "call stack" THEN 'display call stack callstacklist$ = value$ + ShowCallStack: retval = idecallstackbox PCOPY 3, 0: SCREEN , , 3, 0 clearStatusWindow 0 @@ -6510,6 +6512,7 @@ SUB DebugMode SELECT CASE cmd$ CASE "breakpoint", "line number" + BypassRequestCallStack = 0 l = CVL(value$) idecy = l debugnextline = l @@ -6542,10 +6545,12 @@ SUB DebugMode clearStatusWindow 1 COLOR , 4 setStatusMessage 1, "Error occurred on line" + STR$(l), 13 + BypassRequestCallStack = -1 PauseMode = -1 CASE "call stack size" 'call stack is only received without having been - 'requested when the program is about to quit + 'requested when the program is about to quit or + 'when an error just occurred callStackLength = CVL(value$) start! = TIMER DO diff --git a/source/utilities/vwatch/vwatch.bm b/source/utilities/vwatch/vwatch.bm index 1bbc5e785..04ed1f1fe 100644 --- a/source/utilities/vwatch/vwatch.bm +++ b/source/utilities/vwatch/vwatch.bm @@ -65,10 +65,7 @@ SUB vwatch (localVariables AS _OFFSET) END IF IF vwatch_linenumber = 0 THEN - cmd$ = "call stack size:" + MKL$(callStackLength) - GOSUB SendCommand - cmd$ = "call stack:" + vwatch_callstack - GOSUB SendCommand + GOSUB SendCallStack cmd$ = "quit:Program ended." GOSUB SendCommand CLOSE #ide @@ -77,6 +74,7 @@ SUB vwatch (localVariables AS _OFFSET) EXIT SUB ELSEIF vwatch_linenumber = -1 THEN 'report an error in the most recent line + GOSUB SendCallStack cmd$ = "error:" + MKL$(lastLine) GOSUB SendCommand EXIT SUB @@ -168,10 +166,7 @@ SUB vwatch (localVariables AS _OFFSET) REDIM vwatch_breakpoints(UBOUND(vwatch_breakpoints)) AS _BYTE CASE "call stack" 'send call stack history" - cmd$ = "call stack size:" + MKL$(callStackLength) - GOSUB SendCommand - cmd$ = "call stack:" + vwatch_callstack - GOSUB SendCommand + GOSUB SendCallStack CASE "local" i = CVL(value$) address = localVariables + LEN(address) * i @@ -217,6 +212,13 @@ SUB vwatch (localVariables AS _OFFSET) END IF RETURN + SendCallStack: + cmd$ = "call stack size:" + MKL$(callStackLength) + GOSUB SendCommand + cmd$ = "call stack:" + vwatch_callstack + GOSUB SendCommand + RETURN + SendCommand: cmd$ = cmd$ + endc$ PUT #ide, , cmd$ From 10ce193ba9f6a9c2974bb96c15ad5bffa0b328ed Mon Sep 17 00:00:00 2001 From: FellippeHeitor Date: Mon, 19 Jul 2021 22:55:03 -0300 Subject: [PATCH 02/31] Prevents showing the call stack dialog when it's empty. --- source/ide/ide_methods.bas | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/source/ide/ide_methods.bas b/source/ide/ide_methods.bas index 90785e722..23dff7625 100644 --- a/source/ide/ide_methods.bas +++ b/source/ide/ide_methods.bas @@ -1582,7 +1582,13 @@ FUNCTION ide2 (ignore) END IF IF KB = KEY_F4 THEN - GOTO showCallStackDialog + IF callStackLength > 0 THEN + GOTO showCallStackDialog + ELSE + result = idemessagebox("$DEBUG MODE", "No call stack log available.", "") + PCOPY 3, 0: SCREEN , , 3, 0 + GOTO ideloop + END IF END IF IF KB = KEY_F5 THEN 'Note: F5 or SHIFT+F5 accepted @@ -6432,7 +6438,6 @@ SUB DebugMode dummy = DarkenFGBG(0) clearStatusWindow 0 setStatusMessage 1, "Requesting call stack...", 7 - noFocusMessage = -1 start! = TIMER DO @@ -6453,6 +6458,7 @@ SUB DebugMode clearStatusWindow 0 setStatusMessage 1, "Error retrieving call stack.", 2 END IF + noFocusMessage = NOT noFocusMessage END IF CASE 16128 'F5 PauseMode = 0 From 4d1787395250866433fb6412acee6d825d845e31 Mon Sep 17 00:00:00 2001 From: FellippeHeitor Date: Mon, 19 Jul 2021 23:13:00 -0300 Subject: [PATCH 03/31] Allows END IF and END SELECT to be steppable. --- source/qb64.bas | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/source/qb64.bas b/source/qb64.bas index 455010358..60345abb3 100644 --- a/source/qb64.bas +++ b/source/qb64.bas @@ -6043,6 +6043,10 @@ DO IF LEN(layout$) = 0 THEN layout$ = l$ ELSE layout$ = layout$ + sp + l$ END IF + IF vWatchOn = 1 AND inclinenumber(inclevel) = 0 THEN + PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_local_vars);" + END IF + PRINT #12, "}" FOR i = 1 TO controlvalue(controllevel) PRINT #12, "}" @@ -6180,9 +6184,14 @@ DO controllevel = controllevel - 1 IF EveryCaseSet(SelectCaseCounter) THEN PRINT #12, "} /* End of SELECT EVERYCASE ELSE */" END IF + PRINT #12, "sc_" + str2$(controlid(controllevel)) + "_end:;" IF controltype(controllevel) < 10 OR controltype(controllevel) > 17 THEN a$ = "END SELECT without SELECT CASE": GOTO errmes + IF vWatchOn = 1 AND inclinenumber(inclevel) = 0 THEN + PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_local_vars);" + END IF + IF SelectCaseCounter > 0 AND SelectCaseHasCaseBlock(SelectCaseCounter) = 0 THEN 'warn user of empty SELECT CASE block IF NOT IgnoreWarnings THEN From aefde3eb555d3c04ad99ffcedfd1ad9faa0eb48f Mon Sep 17 00:00:00 2001 From: FellippeHeitor Date: Tue, 20 Jul 2021 01:06:30 -0300 Subject: [PATCH 04/31] Implements Set Next Line. Allows arbitrarily changing the execution order from the IDE. Ctrl+G in $DEBUG mode to launch the Set Next Line dialog. --- source/ide/ide_methods.bas | 19 +++++ source/qb64.bas | 112 +++++++++++++++++++++++++----- source/utilities/vwatch/vwatch.bi | 3 +- source/utilities/vwatch/vwatch.bm | 13 +++- 4 files changed, 127 insertions(+), 20 deletions(-) diff --git a/source/ide/ide_methods.bas b/source/ide/ide_methods.bas index 23dff7625..a5247f427 100644 --- a/source/ide/ide_methods.bas +++ b/source/ide/ide_methods.bas @@ -6512,6 +6512,15 @@ SUB DebugMode cmd$ = "clear all breakpoints" GOSUB SendCommand GOSUB UpdateDisplay + CASE 103, 71 'g, G + IF _KEYDOWN(100306) OR _KEYDOWN(100305) THEN + result = idesetnextlinebox + PCOPY 3, 0: SCREEN , , 3, 0 + IF result > 0 THEN + cmd$ = "set next line:" + MKL$(result) + GOSUB SendCommand + END IF + END IF END SELECT GOSUB GetCommand @@ -11463,7 +11472,17 @@ SUB idegotobox ideselect = 0 END SUB +FUNCTION idesetnextlinebox + a2$ = "" + v$ = ideinputbox$("Set Next Line", "#Line", a2$, "0123456789", 30, 8) + IF v$ = "" THEN EXIT FUNCTION + v& = VAL(v$) + IF v& < 1 THEN v& = 1 + IF v& > iden THEN v& = iden + + idesetnextlinebox = v& +END FUNCTION diff --git a/source/qb64.bas b/source/qb64.bas index 60345abb3..d4bd6956b 100644 --- a/source/qb64.bas +++ b/source/qb64.bas @@ -778,6 +778,8 @@ DIM SHARED findidinternal AS LONG DIM SHARED currentid AS LONG 'is the index of the last ID accessed DIM SHARED linenumber AS LONG, reallinenumber AS LONG, totallinenumber AS LONG, definingtypeerror AS LONG DIM SHARED wholeline AS STRING +DIM SHARED firstLineNumberLabelvWatch AS LONG, lastLineNumberLabelvWatch AS LONG +DIM SHARED vWatchUsedLabels AS STRING DIM SHARED linefragment AS STRING 'COMMON SHARED bitmask() AS _INTEGER64 'COMMON SHARED bitmaskinv() AS _INTEGER64 @@ -1455,6 +1457,8 @@ duplicateConstWarning = 0 emptySCWarning = 0 warningListItems = 0 lastWarningHeader = "" +vWatchUsedLabels = SPACE$(1000) +firstLineNumberLabelvWatch = 0 REDIM SHARED warning$(1000) REDIM SHARED warningLines(1000) AS LONG REDIM SHARED warningIncLines(1000) AS LONG @@ -5297,9 +5301,30 @@ DO PRINT #12, "exit_subfunc:;" IF vWatchOn = 1 THEN IF NoChecks = 0 THEN - PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_local_vars);" + vWatchTagLabel linenumber: IF firstLineNumberLabelvWatch = 0 THEN firstLineNumberLabelvWatch = linenumber + IF lastLineNumberLabelvWatch <> linenumber THEN PRINT #12, "VWATCH_LABEL_" + str2$(linenumber) + ":;": lastLineNumberLabelvWatch = linenumber + PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE;" END IF PRINT #12, "*__LONG_VWATCH_SUBLEVEL=*__LONG_VWATCH_SUBLEVEL- 1 ;" + + IF subfunc <> "SUB_VWATCH" THEN + PRINT #12, "goto VWATCH_SKIPSETNEXTLINE;" + PRINT #12, "VWATCH_SETNEXTLINE:;" + PRINT #12, "switch (*__LONG_VWATCH_GOTO) {" + FOR i = firstLineNumberLabelvWatch TO lastLineNumberLabelvWatch + IF ASC(vWatchUsedLabels, i) = 1 THEN + PRINT #12, " case " + str2$(i) + ":" + PRINT #12, " goto VWATCH_LABEL_" + str2$(i) + ";" + PRINT #12, " break;" + END IF + NEXT + PRINT #12, " default:" + PRINT #12, " *__LONG_VWATCH_GOTO=*__LONG_VWATCH_LINENUMBER;" + PRINT #12, " goto VWATCH_SETNEXTLINE;" + PRINT #12, "}" + PRINT #12, "VWATCH_SKIPSETNEXTLINE:;" + END IF + firstLineNumberLabelvWatch = 0 END IF 'release _MEM lock for this scope @@ -5575,7 +5600,9 @@ DO IF stringprocessinghappened THEN e$ = cleanupstringprocessingcall$ + e$ + ")" IF (typ AND ISSTRING) THEN a$ = "WHILE ERROR! Cannot accept a STRING type.": GOTO errmes IF NoChecks = 0 AND vWatchOn = 1 THEN - PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_local_vars);" + vWatchTagLabel linenumber: IF firstLineNumberLabelvWatch = 0 THEN firstLineNumberLabelvWatch = linenumber + IF lastLineNumberLabelvWatch <> linenumber THEN PRINT #12, "VWATCH_LABEL_" + str2$(linenumber) + ":;": lastLineNumberLabelvWatch = linenumber + PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE;" END IF PRINT #12, "while((" + e$ + ")||new_error){" ELSE @@ -5634,13 +5661,17 @@ DO IF (typ AND ISSTRING) THEN a$ = "DO ERROR! Cannot accept a STRING type.": GOTO errmes IF whileuntil = 1 THEN PRINT #12, "while((" + e$ + ")||new_error){" ELSE PRINT #12, "while((!(" + e$ + "))||new_error){" IF NoChecks = 0 AND vWatchOn = 1 THEN - PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_local_vars);" + vWatchTagLabel linenumber: IF firstLineNumberLabelvWatch = 0 THEN firstLineNumberLabelvWatch = linenumber + IF lastLineNumberLabelvWatch <> linenumber THEN PRINT #12, "VWATCH_LABEL_" + str2$(linenumber) + ":;": lastLineNumberLabelvWatch = linenumber + PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE;" END IF controltype(controllevel) = 4 ELSE controltype(controllevel) = 3 IF vWatchOn = 1 AND inclinenumber(inclevel) = 0 AND NoChecks = 0 THEN - PRINT #12, "do{*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_local_vars);" + vWatchTagLabel linenumber: IF firstLineNumberLabelvWatch = 0 THEN firstLineNumberLabelvWatch = linenumber + IF lastLineNumberLabelvWatch <> linenumber THEN PRINT #12, "VWATCH_LABEL_" + str2$(linenumber) + ":;": lastLineNumberLabelvWatch = linenumber + PRINT #12, "do{*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE;" ELSE PRINT #12, "do{" END IF @@ -5674,14 +5705,18 @@ DO IF (typ AND ISSTRING) THEN a$ = "LOOP ERROR! Cannot accept a STRING type.": GOTO errmes PRINT #12, "dl_continue_" + str2$(controlid(controllevel)) + ":;" IF NoChecks = 0 AND vWatchOn = 1 THEN - PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_local_vars);" + vWatchTagLabel linenumber: IF firstLineNumberLabelvWatch = 0 THEN firstLineNumberLabelvWatch = linenumber + IF lastLineNumberLabelvWatch <> linenumber THEN PRINT #12, "VWATCH_LABEL_" + str2$(linenumber) + ":;": lastLineNumberLabelvWatch = linenumber + PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE;" END IF IF whileuntil = 1 THEN PRINT #12, "}while((" + e$ + ")&&(!new_error));" ELSE PRINT #12, "}while((!(" + e$ + "))&&(!new_error));" ELSE PRINT #12, "dl_continue_" + str2$(controlid(controllevel)) + ":;" IF NoChecks = 0 AND vWatchOn = 1 THEN - PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_local_vars);" + vWatchTagLabel linenumber: IF firstLineNumberLabelvWatch = 0 THEN firstLineNumberLabelvWatch = linenumber + IF lastLineNumberLabelvWatch <> linenumber THEN PRINT #12, "VWATCH_LABEL_" + str2$(linenumber) + ":;": lastLineNumberLabelvWatch = linenumber + PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE;" END IF IF controltype(controllevel) = 4 THEN @@ -5834,7 +5869,9 @@ DO IF Error_Happened THEN GOTO errmes IF NoChecks = 0 AND vWatchOn = 1 THEN - PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_local_vars);" + vWatchTagLabel linenumber: IF firstLineNumberLabelvWatch = 0 THEN firstLineNumberLabelvWatch = linenumber + IF lastLineNumberLabelvWatch <> linenumber THEN PRINT #12, "VWATCH_LABEL_" + str2$(linenumber) + ":;": lastLineNumberLabelvWatch = linenumber + PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE;" END IF PRINT #12, "fornext_step" + u$ + "=" + e$ + ";" @@ -5921,7 +5958,9 @@ DO IF NoChecks = 0 THEN PRINT #12, "S_" + str2$(statementn) + ":;": dynscope = 1 IF vWatchOn = 1 AND inclinenumber(inclevel) = 0 THEN - PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_local_vars);" + vWatchTagLabel linenumber: IF firstLineNumberLabelvWatch = 0 THEN firstLineNumberLabelvWatch = linenumber + IF lastLineNumberLabelvWatch <> linenumber THEN PRINT #12, "VWATCH_LABEL_" + str2$(linenumber) + ":;": lastLineNumberLabelvWatch = linenumber + PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE;" END IF END IF FOR i = controllevel TO 1 STEP -1 @@ -5962,7 +6001,9 @@ DO IF NoChecks = 0 THEN PRINT #12, "S_" + str2$(statementn) + ":;": dynscope = 1 IF vWatchOn = 1 AND inclinenumber(inclevel) = 0 THEN - PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_local_vars);" + vWatchTagLabel linenumber: IF firstLineNumberLabelvWatch = 0 THEN firstLineNumberLabelvWatch = linenumber + IF lastLineNumberLabelvWatch <> linenumber THEN PRINT #12, "VWATCH_LABEL_" + str2$(linenumber) + ":;": lastLineNumberLabelvWatch = linenumber + PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE;" END IF END IF @@ -6044,7 +6085,9 @@ DO END IF IF vWatchOn = 1 AND inclinenumber(inclevel) = 0 THEN - PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_local_vars);" + vWatchTagLabel linenumber: IF firstLineNumberLabelvWatch = 0 THEN firstLineNumberLabelvWatch = linenumber + IF lastLineNumberLabelvWatch <> linenumber THEN PRINT #12, "VWATCH_LABEL_" + str2$(linenumber) + ":;": lastLineNumberLabelvWatch = linenumber + PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE;" END IF PRINT #12, "}" @@ -6064,7 +6107,9 @@ DO IF NoChecks = 0 THEN PRINT #12, "S_" + str2$(statementn) + ":;": dynscope = 1 IF vWatchOn = 1 AND inclinenumber(inclevel) = 0 THEN - PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_local_vars);" + vWatchTagLabel linenumber: IF firstLineNumberLabelvWatch = 0 THEN firstLineNumberLabelvWatch = linenumber + IF lastLineNumberLabelvWatch <> linenumber THEN PRINT #12, "VWATCH_LABEL_" + str2$(linenumber) + ":;": lastLineNumberLabelvWatch = linenumber + PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE;" END IF END IF @@ -6189,7 +6234,9 @@ DO IF controltype(controllevel) < 10 OR controltype(controllevel) > 17 THEN a$ = "END SELECT without SELECT CASE": GOTO errmes IF vWatchOn = 1 AND inclinenumber(inclevel) = 0 THEN - PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_local_vars);" + vWatchTagLabel linenumber: IF firstLineNumberLabelvWatch = 0 THEN firstLineNumberLabelvWatch = linenumber + IF lastLineNumberLabelvWatch <> linenumber THEN PRINT #12, "VWATCH_LABEL_" + str2$(linenumber) + ":;": lastLineNumberLabelvWatch = linenumber + PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE;" END IF IF SelectCaseCounter > 0 AND SelectCaseHasCaseBlock(SelectCaseCounter) = 0 THEN @@ -6307,7 +6354,9 @@ DO IF NoChecks = 0 THEN PRINT #12, "S_" + str2$(statementn) + ":;": dynscope = 1 IF vWatchOn = 1 AND inclinenumber(inclevel) = 0 THEN - PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_local_vars);" + vWatchTagLabel linenumber: IF firstLineNumberLabelvWatch = 0 THEN firstLineNumberLabelvWatch = linenumber + IF lastLineNumberLabelvWatch <> linenumber THEN PRINT #12, "VWATCH_LABEL_" + str2$(linenumber) + ":;": lastLineNumberLabelvWatch = linenumber + PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE;" END IF END IF @@ -6495,7 +6544,9 @@ DO IF NoChecks = 0 THEN IF vWatchOn = 1 AND inclinenumber(inclevel) = 0 THEN - PRINT #12, "do{*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_local_vars);" + vWatchTagLabel linenumber: IF firstLineNumberLabelvWatch = 0 THEN firstLineNumberLabelvWatch = linenumber + IF lastLineNumberLabelvWatch <> linenumber THEN PRINT #12, "VWATCH_LABEL_" + str2$(linenumber) + ":;": lastLineNumberLabelvWatch = linenumber + PRINT #12, "do{*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE;" ELSE PRINT #12, "do{" END IF @@ -8842,7 +8893,9 @@ DO IF vWatchOn = 1 THEN - PRINT #12, "*__LONG_VWATCH_LINENUMBER= 0; SUB_VWATCH((ptrszint*)vwatch_local_vars);" + vWatchTagLabel linenumber: IF firstLineNumberLabelvWatch = 0 THEN firstLineNumberLabelvWatch = linenumber + IF lastLineNumberLabelvWatch <> linenumber THEN PRINT #12, "VWATCH_LABEL_" + str2$(linenumber) + ":;": lastLineNumberLabelvWatch = linenumber + PRINT #12, "*__LONG_VWATCH_LINENUMBER= 0; SUB_VWATCH((ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE;" END IF PRINT #12, "if (sub_gl_called) error(271);" PRINT #12, "close_program=1;" @@ -8865,7 +8918,9 @@ DO END IF layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ IF vWatchOn = 1 AND NoChecks = 0 THEN - PRINT #12, "*__LONG_VWATCH_LINENUMBER=-3; SUB_VWATCH((ptrszint*)vwatch_local_vars);" + vWatchTagLabel linenumber: IF firstLineNumberLabelvWatch = 0 THEN firstLineNumberLabelvWatch = linenumber + IF lastLineNumberLabelvWatch <> linenumber THEN PRINT #12, "VWATCH_LABEL_" + str2$(linenumber) + ":;": lastLineNumberLabelvWatch = linenumber + PRINT #12, "*__LONG_VWATCH_LINENUMBER=-3; SUB_VWATCH((ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE;" ELSE PRINT #12, "close_program=1;" PRINT #12, "end();" @@ -14155,18 +14210,41 @@ SUB clearid id = cleariddata END SUB +SUB vWatchTagLabel (this AS LONG) + WHILE this > LEN(vWatchUsedLabels) + vWatchUsedLabels = vWatchUsedLabels + SPACE$(1000) + WEND + ASC(vWatchUsedLabels, this) = 1 +END SUB + SUB closemain xend PRINT #12, "return;" + IF vWatchOn THEN + PRINT #12, "VWATCH_SETNEXTLINE:;" + PRINT #12, "switch (*__LONG_VWATCH_GOTO) {" + FOR i = firstLineNumberLabelvWatch TO lastLineNumberLabelvWatch + IF ASC(vWatchUsedLabels, i) = 1 THEN + PRINT #12, " case " + str2$(i) + ":" + PRINT #12, " goto VWATCH_LABEL_" + str2$(i) + ";" + PRINT #12, " break;" + END IF + NEXT + PRINT #12, " default:" + PRINT #12, " *__LONG_VWATCH_GOTO=*__LONG_VWATCH_LINENUMBER;" + PRINT #12, " goto VWATCH_SETNEXTLINE;" + PRINT #12, "}" + END IF + PRINT #12, "}" PRINT #15, "}" 'end case PRINT #15, "}" PRINT #15, "error(3);" 'no valid return possible closedmain = 1 - + firstLineNumberLabelvWatch = 0 END SUB FUNCTION countelements (a$) diff --git a/source/utilities/vwatch/vwatch.bi b/source/utilities/vwatch/vwatch.bi index d00207667..7c31b07e3 100644 --- a/source/utilities/vwatch/vwatch.bi +++ b/source/utilities/vwatch/vwatch.bi @@ -1,10 +1,11 @@ $CHECKING:OFF -DIM SHARED AS LONG vwatch_linenumber, vwatch_sublevel +DIM SHARED AS LONG vwatch_linenumber, vwatch_sublevel, vwatch_goto DIM SHARED AS STRING vwatch_subname, vwatch_callstack REDIM SHARED vwatch_breakpoints(0) AS _BYTE 'next lines are just to avoid "unused variable" warnings: vwatch_linenumber = 0 vwatch_sublevel = 0 +vwatch_goto = 0 vwatch_breakpoints(0) = 0 vwatch_subname = "" vwatch_callstack = "" diff --git a/source/utilities/vwatch/vwatch.bm b/source/utilities/vwatch/vwatch.bm index 04ed1f1fe..172bb1cea 100644 --- a/source/utilities/vwatch/vwatch.bm +++ b/source/utilities/vwatch/vwatch.bm @@ -3,7 +3,7 @@ $CHECKING:OFF SUB vwatch (localVariables AS _OFFSET) STATIC AS LONG ide, breakpointCount, timeout, startLevel, lastLine STATIC AS LONG callStackLength - STATIC AS _BYTE pauseMode, stepOver, bypass + STATIC AS _BYTE pauseMode, stepOver, bypass, setNextLine STATIC buffer$, endc$ DIM AS LONG i DIM AS _OFFSET address @@ -17,6 +17,8 @@ SUB vwatch (localVariables AS _OFFSET) IF bypass THEN EXIT SUB + vwatch_goto = 0 + IF ide = 0 THEN timeout = 10 endc$ = "" @@ -95,7 +97,8 @@ SUB vwatch (localVariables AS _OFFSET) EXIT SUB END IF - IF vwatch_linenumber = lastLine THEN EXIT SUB + IF vwatch_linenumber = lastLine AND setNextLine = 0 THEN EXIT SUB + setNextLine = 0 lastLine = vwatch_linenumber GOSUB GetCommand @@ -171,6 +174,12 @@ SUB vwatch (localVariables AS _OFFSET) i = CVL(value$) address = localVariables + LEN(address) * i PRINT "Local"; i; "is at"; _MEMGET(m, address, _OFFSET) + CASE "set next line" + pauseMode = -1 + stepOver = 0 + setNextLine = -1 + vwatch_goto = CVL(value$) + EXIT SUB END SELECT GOSUB GetCommand From 5e537862551dfe12b9e67477e21ecd15f88d2516 Mon Sep 17 00:00:00 2001 From: FellippeHeitor Date: Tue, 20 Jul 2021 02:50:54 -0300 Subject: [PATCH 05/31] Implements "Skip Line" Ctrl+P to set line to skip. Ctrl+Line Click to set line to skip with mouse. --- source/ide/ide_global.bas | 1 + source/ide/ide_methods.bas | 90 ++++++++++++++++++-- source/qb64.bas | 132 ++++++++++++++++++------------ source/utilities/vwatch/vwatch.bi | 2 + source/utilities/vwatch/vwatch.bm | 32 +++++++- 5 files changed, 194 insertions(+), 63 deletions(-) diff --git a/source/ide/ide_global.bas b/source/ide/ide_global.bas index 4e81fcff2..00c3c17e2 100644 --- a/source/ide/ide_global.bas +++ b/source/ide/ide_global.bas @@ -42,6 +42,7 @@ DIM SHARED QuickNavTotal AS LONG DIM SHARED QuickNavHistory(0) AS QuickNavType REDIM SHARED IdeBreakpoints(1) AS _BYTE +REDIM SHARED IdeSkipLines(1) AS _BYTE 'GetInput global variables DIM SHARED iCHECKLATER 'the values will be checked later diff --git a/source/ide/ide_methods.bas b/source/ide/ide_methods.bas index a5247f427..6d8415eca 100644 --- a/source/ide/ide_methods.bas +++ b/source/ide/ide_methods.bas @@ -474,6 +474,7 @@ FUNCTION ide2 (ignore) 'new blank text field idet$ = MKL$(0) + MKL$(0): idel = 1: ideli = 1: iden = 1: IdeBmkN = 0 REDIM IdeBreakpoints(iden) AS _BYTE + REDIM IdeSkipLines(iden) AS _BYTE callstacklist$ = "": callStackLength = 0 ideunsaved = -1 idechangemade = 1 @@ -566,6 +567,7 @@ FUNCTION ide2 (ignore) lineinput3buffer = "" iden = n: IF n = 0 THEN idet$ = MKL$(0) + MKL$(0): iden = 1 ELSE idet$ = LEFT$(idet$, i2 - 1) REDIM IdeBreakpoints(iden) AS _BYTE + REDIM IdeSkipLines(iden) AS _BYTE IF ideStartAtLine > 0 AND ideStartAtLine <= iden THEN idecy = ideStartAtLine IF idecy - 10 >= 1 THEN idesy = idecy - 10 @@ -5646,6 +5648,7 @@ FUNCTION ide2 (ignore) ELSE IdeBreakpoints(idecy) = NOT IdeBreakpoints(idecy) END IF + IF IdeBreakpoints(idecy) THEN IdeSkipLines(idecy) = 0 GOTO ideloop END IF @@ -5708,6 +5711,7 @@ FUNCTION ide2 (ignore) ideunsaved = -1 'new blank text field REDIM IdeBreakpoints(1) AS _BYTE + REDIM IdeSkipLines(1) AS _BYTE callstacklist$ = "": callStackLength = 0 idet$ = MKL$(0) + MKL$(0): idel = 1: ideli = 1: iden = 1: IdeBmkN = 0 idesx = 1 @@ -6211,6 +6215,21 @@ SUB DebugMode GOSUB SendCommand END IF + skipCount = 0 + skipList$ = "" + FOR i = 1 TO UBOUND(IdeSkipLines) + IF IdeSkipLines(i) THEN + skipCount = skipCount + 1 + skipList$ = skipList$ + MKL$(i) + END IF + NEXT + IF skipCount THEN + cmd$ = "skip count:" + MKL$(skipCount) + GOSUB SendCommand + cmd$ = "skip list:" + skipList$ + GOSUB SendCommand + END IF + clearStatusWindow 1 IF startPaused THEN cmd$ = "break" @@ -6313,9 +6332,26 @@ SUB DebugMode ideselect = 0 idecytemp = mY - 2 + idesy - 1 IF idecytemp =< iden THEN - IdeBreakpoints(idecytemp) = NOT IdeBreakpoints(idecytemp) - IF IdeBreakpoints(idecytemp) THEN cmd$ = "set breakpoint:" ELSE cmd$ = "clear breakpoint:" - cmd$ = cmd$ + MKL$(idecytemp) + IF _KEYDOWN(100306) OR _KEYDOWN(100305) THEN + IF IdeSkipLines(idecytemp) = -1 THEN + IdeSkipLines(idecytemp) = 0 + cmd$ = "clear skip line:" + MKL$(idecytemp) + ELSE + IdeSkipLines(idecytemp) = -1 + IdeBreakpoints(idecytemp) = 0 + cmd$ = "set skip line:" + MKL$(idecytemp) + END IF + ELSE + IF IdeBreakpoints(idecytemp) THEN + IdeBreakpoints(idecytemp) = 0 + cmd$ = "clear breakpoint:" + ELSE + IdeBreakpoints(idecytemp) = -1 + IdeSkipLines(idecytemp) = 0 + cmd$ = "set breakpoint:" + END IF + cmd$ = cmd$ + MKL$(idecytemp) + END IF GOSUB SendCommand GOSUB UpdateDisplay END IF @@ -6502,7 +6538,12 @@ SUB DebugMode CASE 17152 'F9 IF PauseMode THEN IdeBreakpoints(idecy) = NOT IdeBreakpoints(idecy) - IF IdeBreakpoints(idecy) THEN cmd$ = "set breakpoint:" ELSE cmd$ = "clear breakpoint:" + IF IdeBreakpoints(idecy) THEN + IdeSkipLines(idecy) = 0 + cmd$ = "set breakpoint:" + ELSE + cmd$ = "clear breakpoint:" + END IF cmd$ = cmd$ + MKL$(idecy) GOSUB SendCommand GOSUB UpdateDisplay @@ -6514,13 +6555,24 @@ SUB DebugMode GOSUB UpdateDisplay CASE 103, 71 'g, G IF _KEYDOWN(100306) OR _KEYDOWN(100305) THEN - result = idesetnextlinebox + result = idegetlinenumberbox("Set Next Line") PCOPY 3, 0: SCREEN , , 3, 0 - IF result > 0 THEN + IF result > 0 AND result < iden THEN cmd$ = "set next line:" + MKL$(result) GOSUB SendCommand END IF END IF + CASE 112, 80 'p, P + IF _KEYDOWN(100306) OR _KEYDOWN(100305) THEN + result = idegetlinenumberbox("Skip Line") + PCOPY 3, 0: SCREEN , , 3, 0 + IF result > 0 AND result <= iden THEN + cmd$ = "set skip line:" + MKL$(result) + GOSUB SendCommand + IdeSkipLines(result) = -1 + GOSUB UpdateDisplay + END IF + END IF END SELECT GOSUB GetCommand @@ -8129,6 +8181,13 @@ SUB ideinsline (i, text$) NEXT IdeBreakpoints(i) = 0 + REDIM _PRESERVE IdeSkipLines(iden + 1) AS _BYTE + FOR b = iden + 1 TO i STEP -1 + SWAP IdeSkipLines(b), IdeSkipLines(b - 1) + NEXT + IdeSkipLines(i) = 0 + + text$ = RTRIM$(text$) IF i = -1 THEN i = idel @@ -8696,6 +8755,7 @@ FUNCTION idefiledialog$(programname$, mode AS _BYTE) lineinput3buffer = "" iden = n: IF n = 0 THEN idet$ = MKL$(0) + MKL$(0): iden = 1 ELSE idet$ = LEFT$(idet$, i2 - 1) REDIM IdeBreakpoints(iden) AS _BYTE + REDIM IdeSkipLines(iden) AS _BYTE callstacklist$ = "": callStackLength = 0 ideerror = 1 @@ -9444,14 +9504,23 @@ SUB ideshowtext DO WHILE l > UBOUND(IdeBreakpoints) REDIM _PRESERVE IdeBreakpoints(UBOUND(IdeBreakpoints) + 100) AS _BYTE LOOP + + DO WHILE l > UBOUND(IdeSkipLines) + REDIM _PRESERVE IdeSkipLines(UBOUND(IdeSkipLines) + 100) AS _BYTE + LOOP + IF ShowLineNumbers THEN IF ShowLineNumbersUseBG THEN COLOR , 6 IF vWatchOn = 1 AND IdeBreakpoints(l) <> 0 THEN COLOR , 4 + IF vWatchOn = 1 AND IdeSkipLines(l) <> 0 THEN COLOR 14 _PRINTSTRING (2, y + 3), SPACE$(maxLineNumberLength) IF l <= iden THEN l2$ = STR$(l) IF 2 + maxLineNumberLength - (LEN(l2$) + 1) >= 2 THEN _PRINTSTRING (2 + maxLineNumberLength - (LEN(l2$) + 1), y + 3), l2$ + IF vWatchOn AND IdeSkipLines(l) <> 0 THEN + _PRINTSTRING (2, y + 3), "!" + END IF END IF END IF IF ShowLineNumbersSeparator THEN @@ -9474,6 +9543,9 @@ SUB ideshowtext IF l = debugnextline THEN COLOR 10 _PRINTSTRING (1, y + 3), CHR$(16) + ELSEIF IdeSkipLines(l) <> 0 THEN + COLOR 14 + _PRINTSTRING (1, y + 3), "!" ELSE _PRINTSTRING (1, y + 3), CHR$(179) END IF @@ -11472,16 +11544,16 @@ SUB idegotobox ideselect = 0 END SUB -FUNCTION idesetnextlinebox +FUNCTION idegetlinenumberbox(title$) a2$ = "" - v$ = ideinputbox$("Set Next Line", "#Line", a2$, "0123456789", 30, 8) + v$ = ideinputbox$(title$, "#Line", a2$, "0123456789", 30, 8) IF v$ = "" THEN EXIT FUNCTION v& = VAL(v$) IF v& < 1 THEN v& = 1 IF v& > iden THEN v& = iden - idesetnextlinebox = v& + idegetlinenumberbox = v& END FUNCTION diff --git a/source/qb64.bas b/source/qb64.bas index d4bd6956b..36f9cf23b 100644 --- a/source/qb64.bas +++ b/source/qb64.bas @@ -5301,9 +5301,9 @@ DO PRINT #12, "exit_subfunc:;" IF vWatchOn = 1 THEN IF NoChecks = 0 THEN - vWatchTagLabel linenumber: IF firstLineNumberLabelvWatch = 0 THEN firstLineNumberLabelvWatch = linenumber - IF lastLineNumberLabelvWatch <> linenumber THEN PRINT #12, "VWATCH_LABEL_" + str2$(linenumber) + ":;": lastLineNumberLabelvWatch = linenumber - PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE;" + vWatchTagLabel linenumber, 0 + PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE; if (*__LONG_VWATCH_GOTO<0) goto VWATCH_SKIPLINE;" + vWatchTagLabel 0, -1 END IF PRINT #12, "*__LONG_VWATCH_SUBLEVEL=*__LONG_VWATCH_SUBLEVEL- 1 ;" @@ -5322,6 +5322,18 @@ DO PRINT #12, " *__LONG_VWATCH_GOTO=*__LONG_VWATCH_LINENUMBER;" PRINT #12, " goto VWATCH_SETNEXTLINE;" PRINT #12, "}" + + PRINT #12, "VWATCH_SKIPLINE:;" + PRINT #12, "switch (*__LONG_VWATCH_GOTO) {" + FOR i = firstLineNumberLabelvWatch TO lastLineNumberLabelvWatch + IF ASC(vWatchUsedLabels, i) = 1 THEN + PRINT #12, " case -" + str2$(i) + ":" + PRINT #12, " goto VWATCH_SKIPLABEL_" + str2$(i) + ";" + PRINT #12, " break;" + END IF + NEXT + PRINT #12, "}" + PRINT #12, "VWATCH_SKIPSETNEXTLINE:;" END IF firstLineNumberLabelvWatch = 0 @@ -5600,9 +5612,8 @@ DO IF stringprocessinghappened THEN e$ = cleanupstringprocessingcall$ + e$ + ")" IF (typ AND ISSTRING) THEN a$ = "WHILE ERROR! Cannot accept a STRING type.": GOTO errmes IF NoChecks = 0 AND vWatchOn = 1 THEN - vWatchTagLabel linenumber: IF firstLineNumberLabelvWatch = 0 THEN firstLineNumberLabelvWatch = linenumber - IF lastLineNumberLabelvWatch <> linenumber THEN PRINT #12, "VWATCH_LABEL_" + str2$(linenumber) + ":;": lastLineNumberLabelvWatch = linenumber - PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE;" + vWatchTagLabel linenumber, 0 + PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE; if (*__LONG_VWATCH_GOTO<0) goto VWATCH_SKIPLINE;" END IF PRINT #12, "while((" + e$ + ")||new_error){" ELSE @@ -5661,17 +5672,15 @@ DO IF (typ AND ISSTRING) THEN a$ = "DO ERROR! Cannot accept a STRING type.": GOTO errmes IF whileuntil = 1 THEN PRINT #12, "while((" + e$ + ")||new_error){" ELSE PRINT #12, "while((!(" + e$ + "))||new_error){" IF NoChecks = 0 AND vWatchOn = 1 THEN - vWatchTagLabel linenumber: IF firstLineNumberLabelvWatch = 0 THEN firstLineNumberLabelvWatch = linenumber - IF lastLineNumberLabelvWatch <> linenumber THEN PRINT #12, "VWATCH_LABEL_" + str2$(linenumber) + ":;": lastLineNumberLabelvWatch = linenumber - PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE;" + vWatchTagLabel linenumber, 0 + PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE; if (*__LONG_VWATCH_GOTO<0) goto VWATCH_SKIPLINE;" END IF controltype(controllevel) = 4 ELSE controltype(controllevel) = 3 IF vWatchOn = 1 AND inclinenumber(inclevel) = 0 AND NoChecks = 0 THEN - vWatchTagLabel linenumber: IF firstLineNumberLabelvWatch = 0 THEN firstLineNumberLabelvWatch = linenumber - IF lastLineNumberLabelvWatch <> linenumber THEN PRINT #12, "VWATCH_LABEL_" + str2$(linenumber) + ":;": lastLineNumberLabelvWatch = linenumber - PRINT #12, "do{*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE;" + vWatchTagLabel linenumber, 0 + PRINT #12, "do{*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE; if (*__LONG_VWATCH_GOTO<0) goto VWATCH_SKIPLINE;" ELSE PRINT #12, "do{" END IF @@ -5705,18 +5714,16 @@ DO IF (typ AND ISSTRING) THEN a$ = "LOOP ERROR! Cannot accept a STRING type.": GOTO errmes PRINT #12, "dl_continue_" + str2$(controlid(controllevel)) + ":;" IF NoChecks = 0 AND vWatchOn = 1 THEN - vWatchTagLabel linenumber: IF firstLineNumberLabelvWatch = 0 THEN firstLineNumberLabelvWatch = linenumber - IF lastLineNumberLabelvWatch <> linenumber THEN PRINT #12, "VWATCH_LABEL_" + str2$(linenumber) + ":;": lastLineNumberLabelvWatch = linenumber - PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE;" + vWatchTagLabel linenumber, 0 + PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE; if (*__LONG_VWATCH_GOTO<0) goto VWATCH_SKIPLINE;" END IF IF whileuntil = 1 THEN PRINT #12, "}while((" + e$ + ")&&(!new_error));" ELSE PRINT #12, "}while((!(" + e$ + "))&&(!new_error));" ELSE PRINT #12, "dl_continue_" + str2$(controlid(controllevel)) + ":;" IF NoChecks = 0 AND vWatchOn = 1 THEN - vWatchTagLabel linenumber: IF firstLineNumberLabelvWatch = 0 THEN firstLineNumberLabelvWatch = linenumber - IF lastLineNumberLabelvWatch <> linenumber THEN PRINT #12, "VWATCH_LABEL_" + str2$(linenumber) + ":;": lastLineNumberLabelvWatch = linenumber - PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE;" + vWatchTagLabel linenumber, 0 + PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE; if (*__LONG_VWATCH_GOTO<0) goto VWATCH_SKIPLINE;" END IF IF controltype(controllevel) = 4 THEN @@ -5869,9 +5876,8 @@ DO IF Error_Happened THEN GOTO errmes IF NoChecks = 0 AND vWatchOn = 1 THEN - vWatchTagLabel linenumber: IF firstLineNumberLabelvWatch = 0 THEN firstLineNumberLabelvWatch = linenumber - IF lastLineNumberLabelvWatch <> linenumber THEN PRINT #12, "VWATCH_LABEL_" + str2$(linenumber) + ":;": lastLineNumberLabelvWatch = linenumber - PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE;" + vWatchTagLabel linenumber, 0 + PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE; if (*__LONG_VWATCH_GOTO<0) goto VWATCH_SKIPLINE;" END IF PRINT #12, "fornext_step" + u$ + "=" + e$ + ";" @@ -5958,9 +5964,8 @@ DO IF NoChecks = 0 THEN PRINT #12, "S_" + str2$(statementn) + ":;": dynscope = 1 IF vWatchOn = 1 AND inclinenumber(inclevel) = 0 THEN - vWatchTagLabel linenumber: IF firstLineNumberLabelvWatch = 0 THEN firstLineNumberLabelvWatch = linenumber - IF lastLineNumberLabelvWatch <> linenumber THEN PRINT #12, "VWATCH_LABEL_" + str2$(linenumber) + ":;": lastLineNumberLabelvWatch = linenumber - PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE;" + vWatchTagLabel linenumber, 0 + PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE; if (*__LONG_VWATCH_GOTO<0) goto VWATCH_SKIPLINE;" END IF END IF FOR i = controllevel TO 1 STEP -1 @@ -6001,9 +6006,8 @@ DO IF NoChecks = 0 THEN PRINT #12, "S_" + str2$(statementn) + ":;": dynscope = 1 IF vWatchOn = 1 AND inclinenumber(inclevel) = 0 THEN - vWatchTagLabel linenumber: IF firstLineNumberLabelvWatch = 0 THEN firstLineNumberLabelvWatch = linenumber - IF lastLineNumberLabelvWatch <> linenumber THEN PRINT #12, "VWATCH_LABEL_" + str2$(linenumber) + ":;": lastLineNumberLabelvWatch = linenumber - PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE;" + vWatchTagLabel linenumber, 0 + PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE; if (*__LONG_VWATCH_GOTO<0) goto VWATCH_SKIPLINE;" END IF END IF @@ -6085,9 +6089,8 @@ DO END IF IF vWatchOn = 1 AND inclinenumber(inclevel) = 0 THEN - vWatchTagLabel linenumber: IF firstLineNumberLabelvWatch = 0 THEN firstLineNumberLabelvWatch = linenumber - IF lastLineNumberLabelvWatch <> linenumber THEN PRINT #12, "VWATCH_LABEL_" + str2$(linenumber) + ":;": lastLineNumberLabelvWatch = linenumber - PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE;" + vWatchTagLabel linenumber, 0 + PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE; if (*__LONG_VWATCH_GOTO<0) goto VWATCH_SKIPLINE;" END IF PRINT #12, "}" @@ -6107,9 +6110,8 @@ DO IF NoChecks = 0 THEN PRINT #12, "S_" + str2$(statementn) + ":;": dynscope = 1 IF vWatchOn = 1 AND inclinenumber(inclevel) = 0 THEN - vWatchTagLabel linenumber: IF firstLineNumberLabelvWatch = 0 THEN firstLineNumberLabelvWatch = linenumber - IF lastLineNumberLabelvWatch <> linenumber THEN PRINT #12, "VWATCH_LABEL_" + str2$(linenumber) + ":;": lastLineNumberLabelvWatch = linenumber - PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE;" + vWatchTagLabel linenumber, 0 + PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE; if (*__LONG_VWATCH_GOTO<0) goto VWATCH_SKIPLINE;" END IF END IF @@ -6234,9 +6236,8 @@ DO IF controltype(controllevel) < 10 OR controltype(controllevel) > 17 THEN a$ = "END SELECT without SELECT CASE": GOTO errmes IF vWatchOn = 1 AND inclinenumber(inclevel) = 0 THEN - vWatchTagLabel linenumber: IF firstLineNumberLabelvWatch = 0 THEN firstLineNumberLabelvWatch = linenumber - IF lastLineNumberLabelvWatch <> linenumber THEN PRINT #12, "VWATCH_LABEL_" + str2$(linenumber) + ":;": lastLineNumberLabelvWatch = linenumber - PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE;" + vWatchTagLabel linenumber, 0 + PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE; if (*__LONG_VWATCH_GOTO<0) goto VWATCH_SKIPLINE;" END IF IF SelectCaseCounter > 0 AND SelectCaseHasCaseBlock(SelectCaseCounter) = 0 THEN @@ -6354,9 +6355,8 @@ DO IF NoChecks = 0 THEN PRINT #12, "S_" + str2$(statementn) + ":;": dynscope = 1 IF vWatchOn = 1 AND inclinenumber(inclevel) = 0 THEN - vWatchTagLabel linenumber: IF firstLineNumberLabelvWatch = 0 THEN firstLineNumberLabelvWatch = linenumber - IF lastLineNumberLabelvWatch <> linenumber THEN PRINT #12, "VWATCH_LABEL_" + str2$(linenumber) + ":;": lastLineNumberLabelvWatch = linenumber - PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE;" + vWatchTagLabel linenumber, 0 + PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE; if (*__LONG_VWATCH_GOTO<0) goto VWATCH_SKIPLINE;" END IF END IF @@ -6544,9 +6544,8 @@ DO IF NoChecks = 0 THEN IF vWatchOn = 1 AND inclinenumber(inclevel) = 0 THEN - vWatchTagLabel linenumber: IF firstLineNumberLabelvWatch = 0 THEN firstLineNumberLabelvWatch = linenumber - IF lastLineNumberLabelvWatch <> linenumber THEN PRINT #12, "VWATCH_LABEL_" + str2$(linenumber) + ":;": lastLineNumberLabelvWatch = linenumber - PRINT #12, "do{*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE;" + vWatchTagLabel linenumber, 0 + PRINT #12, "do{*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE; if (*__LONG_VWATCH_GOTO<0) goto VWATCH_SKIPLINE;" ELSE PRINT #12, "do{" END IF @@ -8893,9 +8892,8 @@ DO IF vWatchOn = 1 THEN - vWatchTagLabel linenumber: IF firstLineNumberLabelvWatch = 0 THEN firstLineNumberLabelvWatch = linenumber - IF lastLineNumberLabelvWatch <> linenumber THEN PRINT #12, "VWATCH_LABEL_" + str2$(linenumber) + ":;": lastLineNumberLabelvWatch = linenumber - PRINT #12, "*__LONG_VWATCH_LINENUMBER= 0; SUB_VWATCH((ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE;" + vWatchTagLabel linenumber, 0 + PRINT #12, "*__LONG_VWATCH_LINENUMBER= 0; SUB_VWATCH((ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE; if (*__LONG_VWATCH_GOTO<0) goto VWATCH_SKIPLINE;" END IF PRINT #12, "if (sub_gl_called) error(271);" PRINT #12, "close_program=1;" @@ -8918,9 +8916,8 @@ DO END IF layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ IF vWatchOn = 1 AND NoChecks = 0 THEN - vWatchTagLabel linenumber: IF firstLineNumberLabelvWatch = 0 THEN firstLineNumberLabelvWatch = linenumber - IF lastLineNumberLabelvWatch <> linenumber THEN PRINT #12, "VWATCH_LABEL_" + str2$(linenumber) + ":;": lastLineNumberLabelvWatch = linenumber - PRINT #12, "*__LONG_VWATCH_LINENUMBER=-3; SUB_VWATCH((ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE;" + vWatchTagLabel linenumber, 0 + PRINT #12, "*__LONG_VWATCH_LINENUMBER=-3; SUB_VWATCH((ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE; if (*__LONG_VWATCH_GOTO<0) goto VWATCH_SKIPLINE;" ELSE PRINT #12, "close_program=1;" PRINT #12, "end();" @@ -14210,11 +14207,27 @@ SUB clearid id = cleariddata END SUB -SUB vWatchTagLabel (this AS LONG) - WHILE this > LEN(vWatchUsedLabels) - vWatchUsedLabels = vWatchUsedLabels + SPACE$(1000) - WEND - ASC(vWatchUsedLabels, this) = 1 +SUB vWatchTagLabel (this AS LONG, lastLine AS _BYTE) + STATIC prevLabel AS LONG + + IF lastLine THEN + PRINT #12, "VWATCH_SKIPLABEL_" + str2$(prevLabel) + ":;" + ELSE + WHILE this > LEN(vWatchUsedLabels) + vWatchUsedLabels = vWatchUsedLabels + SPACE$(1000) + WEND + ASC(vWatchUsedLabels, this) = 1 + + IF firstLineNumberLabelvWatch = 0 THEN + firstLineNumberLabelvWatch = this + ELSE + IF prevLabel <> this THEN + PRINT #12, "VWATCH_SKIPLABEL_" + str2$(prevLabel) + ":;" + END IF + END IF + prevLabel = this + IF lastLineNumberLabelvWatch <> this THEN PRINT #12, "VWATCH_LABEL_" + str2$(this) + ":;": lastLineNumberLabelvWatch = this + END IF END SUB SUB closemain @@ -14236,6 +14249,18 @@ SUB closemain PRINT #12, " *__LONG_VWATCH_GOTO=*__LONG_VWATCH_LINENUMBER;" PRINT #12, " goto VWATCH_SETNEXTLINE;" PRINT #12, "}" + + PRINT #12, "VWATCH_SKIPLINE:;" + PRINT #12, "switch (*__LONG_VWATCH_GOTO) {" + FOR i = firstLineNumberLabelvWatch TO lastLineNumberLabelvWatch + IF ASC(vWatchUsedLabels, i) = 1 THEN + PRINT #12, " case -" + str2$(i) + ":" + PRINT #12, " goto VWATCH_SKIPLABEL_" + str2$(i) + ";" + PRINT #12, " break;" + END IF + NEXT + PRINT #12, "}" + END IF PRINT #12, "}" @@ -22704,6 +22729,7 @@ END FUNCTION SUB xend IF vWatchOn = 1 THEN + vWatchTagLabel 0, -1 PRINT #12, "*__LONG_VWATCH_LINENUMBER= 0; SUB_VWATCH((ptrszint*)vwatch_local_vars);" END IF PRINT #12, "sub_end();" diff --git a/source/utilities/vwatch/vwatch.bi b/source/utilities/vwatch/vwatch.bi index 7c31b07e3..5bb830bfa 100644 --- a/source/utilities/vwatch/vwatch.bi +++ b/source/utilities/vwatch/vwatch.bi @@ -2,11 +2,13 @@ $CHECKING:OFF DIM SHARED AS LONG vwatch_linenumber, vwatch_sublevel, vwatch_goto DIM SHARED AS STRING vwatch_subname, vwatch_callstack REDIM SHARED vwatch_breakpoints(0) AS _BYTE +REDIM SHARED vwatch_skiplines(0) AS _BYTE 'next lines are just to avoid "unused variable" warnings: vwatch_linenumber = 0 vwatch_sublevel = 0 vwatch_goto = 0 vwatch_breakpoints(0) = 0 +vwatch_skiplines(0) = 0 vwatch_subname = "" vwatch_callstack = "" $CHECKING:ON diff --git a/source/utilities/vwatch/vwatch.bm b/source/utilities/vwatch/vwatch.bm index 172bb1cea..310062006 100644 --- a/source/utilities/vwatch/vwatch.bm +++ b/source/utilities/vwatch/vwatch.bm @@ -1,7 +1,7 @@ $CHECKING:OFF SUB vwatch (localVariables AS _OFFSET) - STATIC AS LONG ide, breakpointCount, timeout, startLevel, lastLine + STATIC AS LONG ide, breakpointCount, skipCount, timeout, startLevel, lastLine STATIC AS LONG callStackLength STATIC AS _BYTE pauseMode, stepOver, bypass, setNextLine STATIC buffer$, endc$ @@ -41,6 +41,7 @@ SUB vwatch (localVariables AS _OFFSET) END IF CASE "line count" REDIM vwatch_breakpoints(CVL(value$)) AS _BYTE + REDIM vwatch_skiplines(CVL(value$)) AS _BYTE CASE "breakpoint count" breakpointCount = CVL(value$) CASE "breakpoint list" @@ -55,6 +56,20 @@ SUB vwatch (localVariables AS _OFFSET) temp$ = MID$(value$, i * 4 - 3, 4) vwatch_breakpoints(CVL(temp$)) = -1 NEXT + CASE "skip count" + skipCount = CVL(value$) + CASE "skip list" + IF LEN(value$) \ 4 <> skipCount THEN + cmd$ = "quit:Communication error." + GOSUB SendCommand + CLOSE #ide + bypass = -1 + EXIT SUB + END IF + FOR i = 1 TO skipCount + temp$ = MID$(value$, i * 4 - 3, 4) + vwatch_skiplines(CVL(temp$)) = -1 + NEXT CASE "run" IF vwatch_breakpoints(vwatch_linenumber) THEN EXIT DO pauseMode = 0 @@ -109,12 +124,20 @@ SUB vwatch (localVariables AS _OFFSET) cmd$ = "" CASE "set breakpoint" vwatch_breakpoints(CVL(value$)) = -1 + vwatch_skiplines(CVL(value$)) = 0 CASE "clear breakpoint" vwatch_breakpoints(CVL(value$)) = 0 + CASE "set skip line" + vwatch_skiplines(CVL(value$)) = -1 + vwatch_breakpoints(CVL(value$)) = 0 + CASE "clear skip line" + vwatch_skiplines(CVL(value$)) = 0 CASE "clear all breakpoints" REDIM vwatch_breakpoints(UBOUND(vwatch_breakpoints)) AS _BYTE END SELECT + IF vwatch_skiplines(vwatch_linenumber) THEN vwatch_goto = -vwatch_linenumber: EXIT SUB + IF stepOver = -1 AND vwatch_sublevel > startLevel AND vwatch_breakpoints(vwatch_linenumber) = 0 THEN EXIT SUB ELSEIF stepOver = -1 AND vwatch_sublevel = startLevel THEN @@ -163,6 +186,7 @@ SUB vwatch (localVariables AS _OFFSET) EXIT SUB CASE "set breakpoint" vwatch_breakpoints(CVL(value$)) = -1 + vwatch_skiplines(CVL(value$)) = 0 CASE "clear breakpoint" vwatch_breakpoints(CVL(value$)) = 0 CASE "clear all breakpoints" @@ -180,6 +204,11 @@ SUB vwatch (localVariables AS _OFFSET) setNextLine = -1 vwatch_goto = CVL(value$) EXIT SUB + CASE "set skip line" + vwatch_skiplines(CVL(value$)) = -1 + vwatch_breakpoints(CVL(value$)) = 0 + CASE "clear skip line" + vwatch_skiplines(CVL(value$)) = 0 END SELECT GOSUB GetCommand @@ -190,6 +219,7 @@ SUB vwatch (localVariables AS _OFFSET) EXIT SUB Connect: + DIM ideport$ ideport$ = ENVIRON$("QB64DEBUGPORT") IF ideport$ = "" THEN bypass = -1: EXIT SUB From adf963b007edc046e65022858b2b1a671e4b1a86 Mon Sep 17 00:00:00 2001 From: FellippeHeitor Date: Tue, 20 Jul 2021 03:02:29 -0300 Subject: [PATCH 06/31] Allows toggling "Skip Line" before starting program. Ctrl+Line number or Debug->Toggle Skip Line --- source/ide/ide_methods.bas | 30 ++++++++++++++++++++++++++---- 1 file changed, 26 insertions(+), 4 deletions(-) diff --git a/source/ide/ide_methods.bas b/source/ide/ide_methods.bas index 6d8415eca..0506fcc73 100644 --- a/source/ide/ide_methods.bas +++ b/source/ide/ide_methods.bas @@ -342,9 +342,8 @@ FUNCTION ide2 (ignore) menuDesc$(m, i - 1) = "Sets/clears breakpoint at cursor location" menu$(m, i) = "#Clear All Breakpoints F10": i = i + 1 menuDesc$(m, i - 1) = "Removes all breakpoints" - 'menu$(m, i) = "-": i = i + 1 - 'menu$(m, i) = "#Clear All Breakpoints F10": i = i + 1 - 'menuDesc$(m, i - 1) = "Removes all breakpoints" + menu$(m, i) = "Toggle #Skip Line": i = i + 1 + menuDesc$(m, i - 1) = "Sets/clears flag to skip line" menusize(m) = i - 1 m = m + 1: i = 0: OptionsMenuID = m @@ -2962,7 +2961,11 @@ FUNCTION ide2 (ignore) idecytemp = mY - 2 + idesy - 1 IF idecytemp =< iden THEN idecy = idecytemp - GOTO toggleBreakpoint + IF _KEYDOWN(100306) OR _KEYDOWN(100305) THEN + GOTO toggleSkipLine + ELSE + GOTO toggleBreakpoint + END IF END IF END IF END IF @@ -5658,6 +5661,25 @@ FUNCTION ide2 (ignore) GOTO ideloop END IF + IF menu$(m, s) = "Toggle #Skip Line" THEN + PCOPY 3, 0: SCREEN , , 3, 0 + toggleSkipLine: + IF vWatchOn = 0 THEN + result = idemessagebox("Toggle Breakpoint", "Insert $DEBUG metacommand?", "#Yes;#No") + IF result = 1 THEN + ideselect = 0 + ideinsline 1, SCase$("$Debug") + idecy = idecy + 1 + idechangemade = 1 + IdeSkipLines(idecy) = NOT IdeSkipLines(idecy) + END IF + ELSE + IdeSkipLines(idecy) = NOT IdeSkipLines(idecy) + END IF + IF IdeSkipLines(idecy) THEN IdeBreakpoints(idecy) = 0 + GOTO ideloop + END IF + IF menu$(m, s) = "E#xit" THEN PCOPY 2, 0 quickexit: From fcc243f90296f130fbe9c2effac5e3671fd5c6be Mon Sep 17 00:00:00 2001 From: FellippeHeitor Date: Tue, 20 Jul 2021 03:11:16 -0300 Subject: [PATCH 07/31] Moves breakpoints and line skips when deleting lines. --- source/ide/ide_methods.bas | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/source/ide/ide_methods.bas b/source/ide/ide_methods.bas index 0506fcc73..ea082c433 100644 --- a/source/ide/ide_methods.bas +++ b/source/ide/ide_methods.bas @@ -7394,6 +7394,16 @@ SUB idedelline (i) END IF NEXT + FOR b = i TO iden - 1 + SWAP IdeBreakpoints(b), IdeBreakpoints(b + 1) + NEXT + REDIM _PRESERVE IdeBreakpoints(iden - 1) AS _BYTE + + FOR b = i TO iden - 1 + SWAP IdeSkipLines(b), IdeSkipLines(b - 1) + NEXT + REDIM _PRESERVE IdeSkipLines(iden - 1) AS _BYTE + idegotoline i textlen = CVL(MID$(idet$, ideli, 4)) idet$ = LEFT$(idet$, ideli - 1) + RIGHT$(idet$, LEN(idet$) - ideli + 1 - 8 - textlen) @@ -8209,7 +8219,6 @@ SUB ideinsline (i, text$) NEXT IdeSkipLines(i) = 0 - text$ = RTRIM$(text$) IF i = -1 THEN i = idel From 5406492be86d4ceadbcb457e9b553d0690859384 Mon Sep 17 00:00:00 2001 From: Fellippe Heitor Date: Tue, 20 Jul 2021 11:55:31 -0300 Subject: [PATCH 08/31] Changes the shortcut to skip line to Shift+click. Minor visual changes to breakpoint/skip line indicators. --- source/ide/ide_methods.bas | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/source/ide/ide_methods.bas b/source/ide/ide_methods.bas index ea082c433..152aaa52d 100644 --- a/source/ide/ide_methods.bas +++ b/source/ide/ide_methods.bas @@ -2961,7 +2961,7 @@ FUNCTION ide2 (ignore) idecytemp = mY - 2 + idesy - 1 IF idecytemp =< iden THEN idecy = idecytemp - IF _KEYDOWN(100306) OR _KEYDOWN(100305) THEN + IF _KEYDOWN(100304) OR _KEYDOWN(100303) THEN GOTO toggleSkipLine ELSE GOTO toggleBreakpoint @@ -6354,7 +6354,7 @@ SUB DebugMode ideselect = 0 idecytemp = mY - 2 + idesy - 1 IF idecytemp =< iden THEN - IF _KEYDOWN(100306) OR _KEYDOWN(100305) THEN + IF _KEYDOWN(100304) OR _KEYDOWN(100303) THEN IF IdeSkipLines(idecytemp) = -1 THEN IdeSkipLines(idecytemp) = 0 cmd$ = "clear skip line:" + MKL$(idecytemp) @@ -9549,8 +9549,12 @@ SUB ideshowtext l2$ = STR$(l) IF 2 + maxLineNumberLength - (LEN(l2$) + 1) >= 2 THEN _PRINTSTRING (2 + maxLineNumberLength - (LEN(l2$) + 1), y + 3), l2$ - IF vWatchOn AND IdeSkipLines(l) <> 0 THEN - _PRINTSTRING (2, y + 3), "!" + IF vWatchOn THEN + IF IdeBreakpoints(l) <> 0 THEN + _PRINTSTRING (2, y + 3), CHR$(7) + ELSEIF IdeSkipLines(l) <> 0 THEN + _PRINTSTRING (2, y + 3), "!" + END IF END IF END IF END IF @@ -9569,16 +9573,16 @@ SUB ideshowtext END IF COLOR , 1 ELSE - IF vWatchOn = 1 AND IdeBreakpoints(l) <> 0 THEN + IF vWatchOn = 1 AND (IdeBreakpoints(l) <> 0 OR IdeSkipLines(l) <> 0) THEN COLOR 7, 4 IF l = debugnextline THEN COLOR 10 _PRINTSTRING (1, y + 3), CHR$(16) ELSEIF IdeSkipLines(l) <> 0 THEN - COLOR 14 + COLOR 14, 1 _PRINTSTRING (1, y + 3), "!" ELSE - _PRINTSTRING (1, y + 3), CHR$(179) + _PRINTSTRING (1, y + 3), CHR$(7) END IF END IF END IF From 19d22d4c9f3fa5d7660a3799a4c6266a368605ed Mon Sep 17 00:00:00 2001 From: Fellippe Heitor Date: Tue, 20 Jul 2021 11:56:24 -0300 Subject: [PATCH 09/31] Renames `ide` to `ideHost` in vwatch.bm --- source/utilities/vwatch/vwatch.bm | 532 +++++++++++++++--------------- 1 file changed, 266 insertions(+), 266 deletions(-) diff --git a/source/utilities/vwatch/vwatch.bm b/source/utilities/vwatch/vwatch.bm index 310062006..d8b64b6c7 100644 --- a/source/utilities/vwatch/vwatch.bm +++ b/source/utilities/vwatch/vwatch.bm @@ -1,266 +1,266 @@ -$CHECKING:OFF - -SUB vwatch (localVariables AS _OFFSET) - STATIC AS LONG ide, breakpointCount, skipCount, timeout, startLevel, lastLine - STATIC AS LONG callStackLength - STATIC AS _BYTE pauseMode, stepOver, bypass, setNextLine - STATIC buffer$, endc$ - DIM AS LONG i - DIM AS _OFFSET address - DIM AS _MEM m - DIM start!, temp$, cmd$, value$, k& - - DECLARE LIBRARY - SUB vwatch_stoptimers ALIAS stop_timers - SUB vwatch_starttimers ALIAS start_timers - END DECLARE - - IF bypass THEN EXIT SUB - - vwatch_goto = 0 - - IF ide = 0 THEN - timeout = 10 - endc$ = "" - - 'initial setup - GOSUB Connect - - 'send this binary's path/exe name - cmd$ = "me:" + COMMAND$(0) - GOSUB SendCommand - - DO - GOSUB GetCommand - SELECT CASE cmd$ - CASE "vwatch" - IF value$ <> "ok" THEN - CLOSE #ide - bypass = -1 - EXIT SUB - END IF - CASE "line count" - REDIM vwatch_breakpoints(CVL(value$)) AS _BYTE - REDIM vwatch_skiplines(CVL(value$)) AS _BYTE - CASE "breakpoint count" - breakpointCount = CVL(value$) - CASE "breakpoint list" - IF LEN(value$) \ 4 <> breakpointCount THEN - cmd$ = "quit:Communication error." - GOSUB SendCommand - CLOSE #ide - bypass = -1 - EXIT SUB - END IF - FOR i = 1 TO breakpointCount - temp$ = MID$(value$, i * 4 - 3, 4) - vwatch_breakpoints(CVL(temp$)) = -1 - NEXT - CASE "skip count" - skipCount = CVL(value$) - CASE "skip list" - IF LEN(value$) \ 4 <> skipCount THEN - cmd$ = "quit:Communication error." - GOSUB SendCommand - CLOSE #ide - bypass = -1 - EXIT SUB - END IF - FOR i = 1 TO skipCount - temp$ = MID$(value$, i * 4 - 3, 4) - vwatch_skiplines(CVL(temp$)) = -1 - NEXT - CASE "run" - IF vwatch_breakpoints(vwatch_linenumber) THEN EXIT DO - pauseMode = 0 - EXIT SUB - CASE "break" - pauseMode = -1 - EXIT DO - END SELECT - LOOP - END IF - - IF vwatch_linenumber = 0 THEN - GOSUB SendCallStack - cmd$ = "quit:Program ended." - GOSUB SendCommand - CLOSE #ide - bypass = -1 - ide = 0 - EXIT SUB - ELSEIF vwatch_linenumber = -1 THEN - 'report an error in the most recent line - GOSUB SendCallStack - cmd$ = "error:" + MKL$(lastLine) - GOSUB SendCommand - EXIT SUB - ELSEIF vwatch_linenumber = -2 THEN - 'report a new sub/function has been "entered" - IF LEN(vwatch_callstack) > 100000 THEN - vwatch_callstack = "" - callStackLength = 0 - END IF - callStackLength = callStackLength + 1 - IF LEN(vwatch_callstack) THEN vwatch_callstack = vwatch_callstack + CHR$(0) - vwatch_callstack = vwatch_callstack + vwatch_subname$ + ", line" + STR$(lastLine) - EXIT SUB - ELSEIF vwatch_linenumber = -3 THEN - 'handle STOP - instead of quitting, pause execution - pauseMode = -1 - stepOver = 0 - EXIT SUB - END IF - - IF vwatch_linenumber = lastLine AND setNextLine = 0 THEN EXIT SUB - setNextLine = 0 - lastLine = vwatch_linenumber - - GOSUB GetCommand - SELECT CASE cmd$ - CASE "break" - pauseMode = -1 - stepOver = 0 - cmd$ = "" - CASE "set breakpoint" - vwatch_breakpoints(CVL(value$)) = -1 - vwatch_skiplines(CVL(value$)) = 0 - CASE "clear breakpoint" - vwatch_breakpoints(CVL(value$)) = 0 - CASE "set skip line" - vwatch_skiplines(CVL(value$)) = -1 - vwatch_breakpoints(CVL(value$)) = 0 - CASE "clear skip line" - vwatch_skiplines(CVL(value$)) = 0 - CASE "clear all breakpoints" - REDIM vwatch_breakpoints(UBOUND(vwatch_breakpoints)) AS _BYTE - END SELECT - - IF vwatch_skiplines(vwatch_linenumber) THEN vwatch_goto = -vwatch_linenumber: EXIT SUB - - IF stepOver = -1 AND vwatch_sublevel > startLevel AND vwatch_breakpoints(vwatch_linenumber) = 0 THEN - EXIT SUB - ELSEIF stepOver = -1 AND vwatch_sublevel = startLevel THEN - stepOver = 0 - pauseMode = -1 - END IF - - IF vwatch_breakpoints(vwatch_linenumber) = 0 AND pauseMode = 0 THEN - EXIT SUB - END IF - - vwatch_stoptimers - cmd$ = "line number:" - IF vwatch_breakpoints(vwatch_linenumber) THEN cmd$ = "breakpoint:" - cmd$ = cmd$ + MKL$(vwatch_linenumber) - GOSUB SendCommand - - DO 'main loop - SELECT CASE cmd$ - CASE "run" - pauseMode = 0 - stepOver = 0 - vwatch_starttimers - EXIT SUB - CASE "step" - pauseMode = -1 - stepOver = 0 - EXIT SUB - CASE "step over" - pauseMode = -1 - stepOver = -1 - startLevel = vwatch_sublevel - vwatch_starttimers - EXIT SUB - CASE "step out" - pauseMode = -1 - stepOver = -1 - startLevel = vwatch_sublevel - 1 - vwatch_starttimers - EXIT SUB - CASE "free" - CLOSE #ide - ide = 0 - bypass = -1 - vwatch_starttimers - EXIT SUB - CASE "set breakpoint" - vwatch_breakpoints(CVL(value$)) = -1 - vwatch_skiplines(CVL(value$)) = 0 - CASE "clear breakpoint" - vwatch_breakpoints(CVL(value$)) = 0 - CASE "clear all breakpoints" - REDIM vwatch_breakpoints(UBOUND(vwatch_breakpoints)) AS _BYTE - CASE "call stack" - 'send call stack history" - GOSUB SendCallStack - CASE "local" - i = CVL(value$) - address = localVariables + LEN(address) * i - PRINT "Local"; i; "is at"; _MEMGET(m, address, _OFFSET) - CASE "set next line" - pauseMode = -1 - stepOver = 0 - setNextLine = -1 - vwatch_goto = CVL(value$) - EXIT SUB - CASE "set skip line" - vwatch_skiplines(CVL(value$)) = -1 - vwatch_breakpoints(CVL(value$)) = 0 - CASE "clear skip line" - vwatch_skiplines(CVL(value$)) = 0 - END SELECT - - GOSUB GetCommand - _LIMIT 100 - LOOP - - vwatch_starttimers - EXIT SUB - - Connect: - DIM ideport$ - ideport$ = ENVIRON$("QB64DEBUGPORT") - IF ideport$ = "" THEN bypass = -1: EXIT SUB - - start! = TIMER - DO - k& = _KEYHIT - ide = _OPENCLIENT("TCP/IP:" + ideport$ + ":localhost") - _LIMIT 30 - LOOP UNTIL k& = 27 OR ide <> 0 OR TIMER - start! > timeout - IF ide = 0 THEN bypass = -1: EXIT SUB - RETURN - - GetCommand: - GET #ide, , temp$ - buffer$ = buffer$ + temp$ - - IF INSTR(buffer$, endc$) THEN - cmd$ = LEFT$(buffer$, INSTR(buffer$, endc$) - 1) - buffer$ = MID$(buffer$, INSTR(buffer$, endc$) + LEN(endc$)) - - IF INSTR(cmd$, ":") THEN - value$ = MID$(cmd$, INSTR(cmd$, ":") + 1) - cmd$ = LEFT$(cmd$, INSTR(cmd$, ":") - 1) - ELSE - value$ = "" - END IF - ELSE - cmd$ = "": value$ = "" - END IF - RETURN - - SendCallStack: - cmd$ = "call stack size:" + MKL$(callStackLength) - GOSUB SendCommand - cmd$ = "call stack:" + vwatch_callstack - GOSUB SendCommand - RETURN - - SendCommand: - cmd$ = cmd$ + endc$ - PUT #ide, , cmd$ - cmd$ = "" - RETURN -END SUB +$CHECKING:OFF + +SUB vwatch (localVariables AS _OFFSET) + STATIC AS LONG ideHost, breakpointCount, skipCount, timeout, startLevel, lastLine + STATIC AS LONG callStackLength + STATIC AS _BYTE pauseMode, stepOver, bypass, setNextLine + STATIC buffer$, endc$ + DIM AS LONG i + DIM AS _OFFSET address + DIM AS _MEM m + DIM start!, temp$, cmd$, value$, k& + + DECLARE LIBRARY + SUB vwatch_stoptimers ALIAS stop_timers + SUB vwatch_starttimers ALIAS start_timers + END DECLARE + + IF bypass THEN EXIT SUB + + vwatch_goto = 0 + + IF ideHost = 0 THEN + timeout = 10 + endc$ = "" + + 'initial setup + GOSUB Connect + + 'send this binary's path/exe name + cmd$ = "me:" + COMMAND$(0) + GOSUB SendCommand + + DO + GOSUB GetCommand + SELECT CASE cmd$ + CASE "vwatch" + IF value$ <> "ok" THEN + CLOSE #ideHost + bypass = -1 + EXIT SUB + END IF + CASE "line count" + REDIM vwatch_breakpoints(CVL(value$)) AS _BYTE + REDIM vwatch_skiplines(CVL(value$)) AS _BYTE + CASE "breakpoint count" + breakpointCount = CVL(value$) + CASE "breakpoint list" + IF LEN(value$) \ 4 <> breakpointCount THEN + cmd$ = "quit:Communication error." + GOSUB SendCommand + CLOSE #ideHost + bypass = -1 + EXIT SUB + END IF + FOR i = 1 TO breakpointCount + temp$ = MID$(value$, i * 4 - 3, 4) + vwatch_breakpoints(CVL(temp$)) = -1 + NEXT + CASE "skip count" + skipCount = CVL(value$) + CASE "skip list" + IF LEN(value$) \ 4 <> skipCount THEN + cmd$ = "quit:Communication error." + GOSUB SendCommand + CLOSE #ideHost + bypass = -1 + EXIT SUB + END IF + FOR i = 1 TO skipCount + temp$ = MID$(value$, i * 4 - 3, 4) + vwatch_skiplines(CVL(temp$)) = -1 + NEXT + CASE "run" + IF vwatch_breakpoints(vwatch_linenumber) THEN EXIT DO + pauseMode = 0 + EXIT SUB + CASE "break" + pauseMode = -1 + EXIT DO + END SELECT + LOOP + END IF + + IF vwatch_linenumber = 0 THEN + GOSUB SendCallStack + cmd$ = "quit:Program ended." + GOSUB SendCommand + CLOSE #ideHost + bypass = -1 + ideHost = 0 + EXIT SUB + ELSEIF vwatch_linenumber = -1 THEN + 'report an error in the most recent line + GOSUB SendCallStack + cmd$ = "error:" + MKL$(lastLine) + GOSUB SendCommand + EXIT SUB + ELSEIF vwatch_linenumber = -2 THEN + 'report a new sub/function has been "entered" + IF LEN(vwatch_callstack) > 100000 THEN + vwatch_callstack = "" + callStackLength = 0 + END IF + callStackLength = callStackLength + 1 + IF LEN(vwatch_callstack) THEN vwatch_callstack = vwatch_callstack + CHR$(0) + vwatch_callstack = vwatch_callstack + vwatch_subname$ + ", line" + STR$(lastLine) + EXIT SUB + ELSEIF vwatch_linenumber = -3 THEN + 'handle STOP - instead of quitting, pause execution + pauseMode = -1 + stepOver = 0 + EXIT SUB + END IF + + IF vwatch_linenumber = lastLine AND setNextLine = 0 THEN EXIT SUB + setNextLine = 0 + lastLine = vwatch_linenumber + + GOSUB GetCommand + SELECT CASE cmd$ + CASE "break" + pauseMode = -1 + stepOver = 0 + cmd$ = "" + CASE "set breakpoint" + vwatch_breakpoints(CVL(value$)) = -1 + vwatch_skiplines(CVL(value$)) = 0 + CASE "clear breakpoint" + vwatch_breakpoints(CVL(value$)) = 0 + CASE "set skip line" + vwatch_skiplines(CVL(value$)) = -1 + vwatch_breakpoints(CVL(value$)) = 0 + CASE "clear skip line" + vwatch_skiplines(CVL(value$)) = 0 + CASE "clear all breakpoints" + REDIM vwatch_breakpoints(UBOUND(vwatch_breakpoints)) AS _BYTE + END SELECT + + IF vwatch_skiplines(vwatch_linenumber) THEN vwatch_goto = -vwatch_linenumber: EXIT SUB + + IF stepOver = -1 AND vwatch_sublevel > startLevel AND vwatch_breakpoints(vwatch_linenumber) = 0 THEN + EXIT SUB + ELSEIF stepOver = -1 AND vwatch_sublevel = startLevel THEN + stepOver = 0 + pauseMode = -1 + END IF + + IF vwatch_breakpoints(vwatch_linenumber) = 0 AND pauseMode = 0 THEN + EXIT SUB + END IF + + vwatch_stoptimers + cmd$ = "line number:" + IF vwatch_breakpoints(vwatch_linenumber) THEN cmd$ = "breakpoint:" + cmd$ = cmd$ + MKL$(vwatch_linenumber) + GOSUB SendCommand + + DO 'main loop + SELECT CASE cmd$ + CASE "run" + pauseMode = 0 + stepOver = 0 + vwatch_starttimers + EXIT SUB + CASE "step" + pauseMode = -1 + stepOver = 0 + EXIT SUB + CASE "step over" + pauseMode = -1 + stepOver = -1 + startLevel = vwatch_sublevel + vwatch_starttimers + EXIT SUB + CASE "step out" + pauseMode = -1 + stepOver = -1 + startLevel = vwatch_sublevel - 1 + vwatch_starttimers + EXIT SUB + CASE "free" + CLOSE #ideHost + ideHost = 0 + bypass = -1 + vwatch_starttimers + EXIT SUB + CASE "set breakpoint" + vwatch_breakpoints(CVL(value$)) = -1 + vwatch_skiplines(CVL(value$)) = 0 + CASE "clear breakpoint" + vwatch_breakpoints(CVL(value$)) = 0 + CASE "clear all breakpoints" + REDIM vwatch_breakpoints(UBOUND(vwatch_breakpoints)) AS _BYTE + CASE "call stack" + 'send call stack history" + GOSUB SendCallStack + CASE "local" + i = CVL(value$) + address = localVariables + LEN(address) * i + PRINT "Local"; i; "is at"; _MEMGET(m, address, _OFFSET) + CASE "set next line" + pauseMode = -1 + stepOver = 0 + setNextLine = -1 + vwatch_goto = CVL(value$) + EXIT SUB + CASE "set skip line" + vwatch_skiplines(CVL(value$)) = -1 + vwatch_breakpoints(CVL(value$)) = 0 + CASE "clear skip line" + vwatch_skiplines(CVL(value$)) = 0 + END SELECT + + GOSUB GetCommand + _LIMIT 100 + LOOP + + vwatch_starttimers + EXIT SUB + + Connect: + DIM ideport$ + ideport$ = ENVIRON$("QB64DEBUGPORT") + IF ideport$ = "" THEN bypass = -1: EXIT SUB + + start! = TIMER + DO + k& = _KEYHIT + ideHost = _OPENCLIENT("TCP/IP:" + ideport$ + ":localhost") + _LIMIT 30 + LOOP UNTIL k& = 27 OR ideHost <> 0 OR TIMER - start! > timeout + IF ideHost = 0 THEN bypass = -1: EXIT SUB + RETURN + + GetCommand: + GET #ideHost, , temp$ + buffer$ = buffer$ + temp$ + + IF INSTR(buffer$, endc$) THEN + cmd$ = LEFT$(buffer$, INSTR(buffer$, endc$) - 1) + buffer$ = MID$(buffer$, INSTR(buffer$, endc$) + LEN(endc$)) + + IF INSTR(cmd$, ":") THEN + value$ = MID$(cmd$, INSTR(cmd$, ":") + 1) + cmd$ = LEFT$(cmd$, INSTR(cmd$, ":") - 1) + ELSE + value$ = "" + END IF + ELSE + cmd$ = "": value$ = "" + END IF + RETURN + + SendCallStack: + cmd$ = "call stack size:" + MKL$(callStackLength) + GOSUB SendCommand + cmd$ = "call stack:" + vwatch_callstack + GOSUB SendCommand + RETURN + + SendCommand: + cmd$ = cmd$ + endc$ + PUT #ideHost, , cmd$ + cmd$ = "" + RETURN +END SUB From 9ade4aea75dee21ec3b55ec0e4e96d4a615908ac Mon Sep 17 00:00:00 2001 From: FellippeHeitor Date: Tue, 20 Jul 2021 12:50:17 -0300 Subject: [PATCH 10/31] Declares `*vwatch_local_vars` when there are no local vars. --- source/qb64.bas | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source/qb64.bas b/source/qb64.bas index 36f9cf23b..25b82c17b 100644 --- a/source/qb64.bas +++ b/source/qb64.bas @@ -5293,6 +5293,8 @@ DO IF totalLocalVariables > 0 THEN PRINT #13, "void *vwatch_local_vars["; totalLocalVariables; "];" PRINT #13, localVariablesList$ + ELSE + PRINT #13, "void *vwatch_local_vars[0];" END IF END IF @@ -11724,6 +11726,8 @@ IF vWatchOn = 1 THEN IF totalLocalVariables > 0 THEN PRINT #13, "void *vwatch_local_vars["; totalLocalVariables; "];" PRINT #13, localVariablesList$ + ELSE + PRINT #13, "void *vwatch_local_vars[0];" END IF END IF From fe4575a181ac32d6aa1ca4b9499c2afeb8390773 Mon Sep 17 00:00:00 2001 From: FellippeHeitor Date: Tue, 20 Jul 2021 13:08:09 -0300 Subject: [PATCH 11/31] Allows empty procedures when $DEBUG is present. --- source/qb64.bas | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/source/qb64.bas b/source/qb64.bas index 25b82c17b..57d295ab6 100644 --- a/source/qb64.bas +++ b/source/qb64.bas @@ -5309,11 +5309,14 @@ DO END IF PRINT #12, "*__LONG_VWATCH_SUBLEVEL=*__LONG_VWATCH_SUBLEVEL- 1 ;" - IF subfunc <> "SUB_VWATCH" THEN + IF subfunc <> "SUB_VWATCH" AND firstLineNumberLabelvWatch > 0 THEN PRINT #12, "goto VWATCH_SKIPSETNEXTLINE;" PRINT #12, "VWATCH_SETNEXTLINE:;" PRINT #12, "switch (*__LONG_VWATCH_GOTO) {" FOR i = firstLineNumberLabelvWatch TO lastLineNumberLabelvWatch + WHILE i > LEN(vWatchUsedLabels) + vWatchUsedLabels = vWatchUsedLabels + SPACE$(1000) + WEND IF ASC(vWatchUsedLabels, i) = 1 THEN PRINT #12, " case " + str2$(i) + ":" PRINT #12, " goto VWATCH_LABEL_" + str2$(i) + ";" @@ -14215,7 +14218,9 @@ SUB vWatchTagLabel (this AS LONG, lastLine AS _BYTE) STATIC prevLabel AS LONG IF lastLine THEN - PRINT #12, "VWATCH_SKIPLABEL_" + str2$(prevLabel) + ":;" + IF prevLabel > 0 THEN + PRINT #12, "VWATCH_SKIPLABEL_" + str2$(prevLabel) + ":;" + END IF ELSE WHILE this > LEN(vWatchUsedLabels) vWatchUsedLabels = vWatchUsedLabels + SPACE$(1000) @@ -14224,6 +14229,7 @@ SUB vWatchTagLabel (this AS LONG, lastLine AS _BYTE) IF firstLineNumberLabelvWatch = 0 THEN firstLineNumberLabelvWatch = this + prevLabel = 0 ELSE IF prevLabel <> this THEN PRINT #12, "VWATCH_SKIPLABEL_" + str2$(prevLabel) + ":;" @@ -14239,7 +14245,7 @@ SUB closemain PRINT #12, "return;" - IF vWatchOn THEN + IF vWatchOn AND firstLineNumberLabelvWatch > 0 THEN PRINT #12, "VWATCH_SETNEXTLINE:;" PRINT #12, "switch (*__LONG_VWATCH_GOTO) {" FOR i = firstLineNumberLabelvWatch TO lastLineNumberLabelvWatch From dfb33206b4ce2e152045f94a03805f15833149e1 Mon Sep 17 00:00:00 2001 From: FellippeHeitor Date: Tue, 20 Jul 2021 13:16:06 -0300 Subject: [PATCH 12/31] Fixes duplicate SKIP labels in some scenarios. --- source/qb64.bas | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/source/qb64.bas b/source/qb64.bas index 57d295ab6..061415b55 100644 --- a/source/qb64.bas +++ b/source/qb64.bas @@ -14215,11 +14215,12 @@ SUB clearid END SUB SUB vWatchTagLabel (this AS LONG, lastLine AS _BYTE) - STATIC prevLabel AS LONG + STATIC prevLabel AS LONG, prevSkipLabel AS LONG IF lastLine THEN - IF prevLabel > 0 THEN + IF prevLabel > 0 AND prevLabel <> prevSkipLabel THEN PRINT #12, "VWATCH_SKIPLABEL_" + str2$(prevLabel) + ":;" + prevSkipLabel = prevLabel END IF ELSE WHILE this > LEN(vWatchUsedLabels) From 603cc585e843312c8f665f81008352d39f5172f0 Mon Sep 17 00:00:00 2001 From: FellippeHeitor Date: Tue, 20 Jul 2021 17:11:16 -0300 Subject: [PATCH 13/31] Prevents issues when deleting lines in normal mode. --- source/ide/ide_methods.bas | 40 +++++++++++++++++++++----------------- 1 file changed, 22 insertions(+), 18 deletions(-) diff --git a/source/ide/ide_methods.bas b/source/ide/ide_methods.bas index 152aaa52d..3b8f5a04b 100644 --- a/source/ide/ide_methods.bas +++ b/source/ide/ide_methods.bas @@ -7394,15 +7394,17 @@ SUB idedelline (i) END IF NEXT - FOR b = i TO iden - 1 - SWAP IdeBreakpoints(b), IdeBreakpoints(b + 1) - NEXT - REDIM _PRESERVE IdeBreakpoints(iden - 1) AS _BYTE + IF vWatchOn THEN + FOR b = i TO iden - 1 + SWAP IdeBreakpoints(b), IdeBreakpoints(b + 1) + NEXT + REDIM _PRESERVE IdeBreakpoints(iden - 1) AS _BYTE - FOR b = i TO iden - 1 - SWAP IdeSkipLines(b), IdeSkipLines(b - 1) - NEXT - REDIM _PRESERVE IdeSkipLines(iden - 1) AS _BYTE + FOR b = i TO iden - 1 + SWAP IdeSkipLines(b), IdeSkipLines(b - 1) + NEXT + REDIM _PRESERVE IdeSkipLines(iden - 1) AS _BYTE + END IF idegotoline i textlen = CVL(MID$(idet$, ideli, 4)) @@ -8207,17 +8209,19 @@ SUB ideinsline (i, text$) END IF NEXT - REDIM _PRESERVE IdeBreakpoints(iden + 1) AS _BYTE - FOR b = iden + 1 TO i STEP -1 - SWAP IdeBreakpoints(b), IdeBreakpoints(b - 1) - NEXT - IdeBreakpoints(i) = 0 + IF vWatchOn THEN + REDIM _PRESERVE IdeBreakpoints(iden + 1) AS _BYTE + FOR b = iden + 1 TO i STEP -1 + SWAP IdeBreakpoints(b), IdeBreakpoints(b - 1) + NEXT + IdeBreakpoints(i) = 0 - REDIM _PRESERVE IdeSkipLines(iden + 1) AS _BYTE - FOR b = iden + 1 TO i STEP -1 - SWAP IdeSkipLines(b), IdeSkipLines(b - 1) - NEXT - IdeSkipLines(i) = 0 + REDIM _PRESERVE IdeSkipLines(iden + 1) AS _BYTE + FOR b = iden + 1 TO i STEP -1 + SWAP IdeSkipLines(b), IdeSkipLines(b - 1) + NEXT + IdeSkipLines(i) = 0 + END IF text$ = RTRIM$(text$) From 2ca6cb7c9ad620ec453ee1cdea92cfac08b9d7a9 Mon Sep 17 00:00:00 2001 From: FellippeHeitor Date: Tue, 20 Jul 2021 17:12:00 -0300 Subject: [PATCH 14/31] Improves vWatch label injection (`$DEBUG`). --- source/qb64.bas | 63 ++++++++++++++++++++++++++----------------------- 1 file changed, 33 insertions(+), 30 deletions(-) diff --git a/source/qb64.bas b/source/qb64.bas index 061415b55..ade148a1e 100644 --- a/source/qb64.bas +++ b/source/qb64.bas @@ -5303,9 +5303,9 @@ DO PRINT #12, "exit_subfunc:;" IF vWatchOn = 1 THEN IF NoChecks = 0 THEN - vWatchTagLabel linenumber, 0 + vWatchAddLabel linenumber, 0 PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE; if (*__LONG_VWATCH_GOTO<0) goto VWATCH_SKIPLINE;" - vWatchTagLabel 0, -1 + vWatchAddLabel 0, -1 END IF PRINT #12, "*__LONG_VWATCH_SUBLEVEL=*__LONG_VWATCH_SUBLEVEL- 1 ;" @@ -5617,7 +5617,7 @@ DO IF stringprocessinghappened THEN e$ = cleanupstringprocessingcall$ + e$ + ")" IF (typ AND ISSTRING) THEN a$ = "WHILE ERROR! Cannot accept a STRING type.": GOTO errmes IF NoChecks = 0 AND vWatchOn = 1 THEN - vWatchTagLabel linenumber, 0 + vWatchAddLabel linenumber, 0 PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE; if (*__LONG_VWATCH_GOTO<0) goto VWATCH_SKIPLINE;" END IF PRINT #12, "while((" + e$ + ")||new_error){" @@ -5677,14 +5677,14 @@ DO IF (typ AND ISSTRING) THEN a$ = "DO ERROR! Cannot accept a STRING type.": GOTO errmes IF whileuntil = 1 THEN PRINT #12, "while((" + e$ + ")||new_error){" ELSE PRINT #12, "while((!(" + e$ + "))||new_error){" IF NoChecks = 0 AND vWatchOn = 1 THEN - vWatchTagLabel linenumber, 0 + vWatchAddLabel linenumber, 0 PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE; if (*__LONG_VWATCH_GOTO<0) goto VWATCH_SKIPLINE;" END IF controltype(controllevel) = 4 ELSE controltype(controllevel) = 3 IF vWatchOn = 1 AND inclinenumber(inclevel) = 0 AND NoChecks = 0 THEN - vWatchTagLabel linenumber, 0 + vWatchAddLabel linenumber, 0 PRINT #12, "do{*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE; if (*__LONG_VWATCH_GOTO<0) goto VWATCH_SKIPLINE;" ELSE PRINT #12, "do{" @@ -5719,7 +5719,7 @@ DO IF (typ AND ISSTRING) THEN a$ = "LOOP ERROR! Cannot accept a STRING type.": GOTO errmes PRINT #12, "dl_continue_" + str2$(controlid(controllevel)) + ":;" IF NoChecks = 0 AND vWatchOn = 1 THEN - vWatchTagLabel linenumber, 0 + vWatchAddLabel linenumber, 0 PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE; if (*__LONG_VWATCH_GOTO<0) goto VWATCH_SKIPLINE;" END IF IF whileuntil = 1 THEN PRINT #12, "}while((" + e$ + ")&&(!new_error));" ELSE PRINT #12, "}while((!(" + e$ + "))&&(!new_error));" @@ -5727,7 +5727,7 @@ DO PRINT #12, "dl_continue_" + str2$(controlid(controllevel)) + ":;" IF NoChecks = 0 AND vWatchOn = 1 THEN - vWatchTagLabel linenumber, 0 + vWatchAddLabel linenumber, 0 PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE; if (*__LONG_VWATCH_GOTO<0) goto VWATCH_SKIPLINE;" END IF @@ -5881,7 +5881,7 @@ DO IF Error_Happened THEN GOTO errmes IF NoChecks = 0 AND vWatchOn = 1 THEN - vWatchTagLabel linenumber, 0 + vWatchAddLabel linenumber, 0 PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE; if (*__LONG_VWATCH_GOTO<0) goto VWATCH_SKIPLINE;" END IF @@ -5969,7 +5969,7 @@ DO IF NoChecks = 0 THEN PRINT #12, "S_" + str2$(statementn) + ":;": dynscope = 1 IF vWatchOn = 1 AND inclinenumber(inclevel) = 0 THEN - vWatchTagLabel linenumber, 0 + vWatchAddLabel linenumber, 0 PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE; if (*__LONG_VWATCH_GOTO<0) goto VWATCH_SKIPLINE;" END IF END IF @@ -6011,7 +6011,7 @@ DO IF NoChecks = 0 THEN PRINT #12, "S_" + str2$(statementn) + ":;": dynscope = 1 IF vWatchOn = 1 AND inclinenumber(inclevel) = 0 THEN - vWatchTagLabel linenumber, 0 + vWatchAddLabel linenumber, 0 PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE; if (*__LONG_VWATCH_GOTO<0) goto VWATCH_SKIPLINE;" END IF END IF @@ -6094,7 +6094,7 @@ DO END IF IF vWatchOn = 1 AND inclinenumber(inclevel) = 0 THEN - vWatchTagLabel linenumber, 0 + vWatchAddLabel linenumber, 0 PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE; if (*__LONG_VWATCH_GOTO<0) goto VWATCH_SKIPLINE;" END IF @@ -6115,7 +6115,7 @@ DO IF NoChecks = 0 THEN PRINT #12, "S_" + str2$(statementn) + ":;": dynscope = 1 IF vWatchOn = 1 AND inclinenumber(inclevel) = 0 THEN - vWatchTagLabel linenumber, 0 + vWatchAddLabel linenumber, 0 PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE; if (*__LONG_VWATCH_GOTO<0) goto VWATCH_SKIPLINE;" END IF END IF @@ -6241,7 +6241,7 @@ DO IF controltype(controllevel) < 10 OR controltype(controllevel) > 17 THEN a$ = "END SELECT without SELECT CASE": GOTO errmes IF vWatchOn = 1 AND inclinenumber(inclevel) = 0 THEN - vWatchTagLabel linenumber, 0 + vWatchAddLabel linenumber, 0 PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE; if (*__LONG_VWATCH_GOTO<0) goto VWATCH_SKIPLINE;" END IF @@ -6360,7 +6360,7 @@ DO IF NoChecks = 0 THEN PRINT #12, "S_" + str2$(statementn) + ":;": dynscope = 1 IF vWatchOn = 1 AND inclinenumber(inclevel) = 0 THEN - vWatchTagLabel linenumber, 0 + vWatchAddLabel linenumber, 0 PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE; if (*__LONG_VWATCH_GOTO<0) goto VWATCH_SKIPLINE;" END IF END IF @@ -6549,7 +6549,7 @@ DO IF NoChecks = 0 THEN IF vWatchOn = 1 AND inclinenumber(inclevel) = 0 THEN - vWatchTagLabel linenumber, 0 + vWatchAddLabel linenumber, 0 PRINT #12, "do{*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE; if (*__LONG_VWATCH_GOTO<0) goto VWATCH_SKIPLINE;" ELSE PRINT #12, "do{" @@ -8897,7 +8897,7 @@ DO IF vWatchOn = 1 THEN - vWatchTagLabel linenumber, 0 + vWatchAddLabel linenumber, 0 PRINT #12, "*__LONG_VWATCH_LINENUMBER= 0; SUB_VWATCH((ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE; if (*__LONG_VWATCH_GOTO<0) goto VWATCH_SKIPLINE;" END IF PRINT #12, "if (sub_gl_called) error(271);" @@ -8921,7 +8921,7 @@ DO END IF layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ IF vWatchOn = 1 AND NoChecks = 0 THEN - vWatchTagLabel linenumber, 0 + vWatchAddLabel linenumber, 0 PRINT #12, "*__LONG_VWATCH_LINENUMBER=-3; SUB_VWATCH((ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE; if (*__LONG_VWATCH_GOTO<0) goto VWATCH_SKIPLINE;" ELSE PRINT #12, "close_program=1;" @@ -14214,15 +14214,10 @@ SUB clearid id = cleariddata END SUB -SUB vWatchTagLabel (this AS LONG, lastLine AS _BYTE) - STATIC prevLabel AS LONG, prevSkipLabel AS LONG +SUB vWatchAddLabel (this AS LONG, lastLine AS _BYTE) + STATIC prevLabel AS LONG, prevSkip AS LONG - IF lastLine THEN - IF prevLabel > 0 AND prevLabel <> prevSkipLabel THEN - PRINT #12, "VWATCH_SKIPLABEL_" + str2$(prevLabel) + ":;" - prevSkipLabel = prevLabel - END IF - ELSE + IF lastLine = 0 THEN WHILE this > LEN(vWatchUsedLabels) vWatchUsedLabels = vWatchUsedLabels + SPACE$(1000) WEND @@ -14230,14 +14225,22 @@ SUB vWatchTagLabel (this AS LONG, lastLine AS _BYTE) IF firstLineNumberLabelvWatch = 0 THEN firstLineNumberLabelvWatch = this - prevLabel = 0 ELSE - IF prevLabel <> this THEN + IF prevSkip <> prevLabel THEN PRINT #12, "VWATCH_SKIPLABEL_" + str2$(prevLabel) + ":;" + prevSkip = prevLabel END IF END IF - prevLabel = this - IF lastLineNumberLabelvWatch <> this THEN PRINT #12, "VWATCH_LABEL_" + str2$(this) + ":;": lastLineNumberLabelvWatch = this + + IF prevLabel <> this THEN + PRINT #12, "VWATCH_LABEL_" + str2$(this) + ":;" + prevLabel = this + END IF + ELSE + IF prevSkip <> prevLabel THEN + PRINT #12, "VWATCH_SKIPLABEL_" + str2$(prevLabel) + ":;" + prevSkip = prevLabel + END IF END IF END SUB @@ -22740,7 +22743,7 @@ END FUNCTION SUB xend IF vWatchOn = 1 THEN - vWatchTagLabel 0, -1 + vWatchAddLabel 0, -1 PRINT #12, "*__LONG_VWATCH_LINENUMBER= 0; SUB_VWATCH((ptrszint*)vwatch_local_vars);" END IF PRINT #12, "sub_end();" From ec807702ce8a94af6812795638626c5e04edf38b Mon Sep 17 00:00:00 2001 From: FellippeHeitor Date: Tue, 20 Jul 2021 17:28:02 -0300 Subject: [PATCH 15/31] Fixes `Next` lines not being "steppable". --- source/qb64.bas | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source/qb64.bas b/source/qb64.bas index ade148a1e..f9c59e9fc 100644 --- a/source/qb64.bas +++ b/source/qb64.bas @@ -5570,6 +5570,10 @@ DO IF controltype(controllevel) <> 2 THEN a$ = "NEXT without FOR": GOTO errmes IF n <> 1 AND controlvalue(controllevel) <> currentid THEN a$ = "Incorrect variable after NEXT": GOTO errmes PRINT #12, "fornext_continue_" + str2$(controlid(controllevel)) + ":;" + IF vWatchOn = 1 AND inclinenumber(inclevel) = 0 AND NoChecks = 0 THEN + vWatchAddLabel linenumber, 0 + PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE; if (*__LONG_VWATCH_GOTO<0) goto VWATCH_SKIPLINE;" + END IF PRINT #12, "}" PRINT #12, "fornext_exit_" + str2$(controlid(controllevel)) + ":;" controllevel = controllevel - 1 From ba7a0d91d4156c9515faf3e8b776392433060033 Mon Sep 17 00:00:00 2001 From: FellippeHeitor Date: Tue, 20 Jul 2021 20:11:29 -0300 Subject: [PATCH 16/31] Implements contextual menu for $DEBUG mode. --- source/ide/ide_methods.bas | 791 +++++++++++++++++++++++-------------- 1 file changed, 498 insertions(+), 293 deletions(-) diff --git a/source/ide/ide_methods.bas b/source/ide/ide_methods.bas index 3b8f5a04b..be8476b00 100644 --- a/source/ide/ide_methods.bas +++ b/source/ide/ide_methods.bas @@ -342,7 +342,7 @@ FUNCTION ide2 (ignore) menuDesc$(m, i - 1) = "Sets/clears breakpoint at cursor location" menu$(m, i) = "#Clear All Breakpoints F10": i = i + 1 menuDesc$(m, i - 1) = "Removes all breakpoints" - menu$(m, i) = "Toggle #Skip Line": i = i + 1 + menu$(m, i) = "Toggle #Skip Line Ctrl+P": i = i + 1 menuDesc$(m, i - 1) = "Sets/clears flag to skip line" menusize(m) = i - 1 @@ -722,10 +722,15 @@ FUNCTION ide2 (ignore) _RESIZE OFF DebugMode SELECT CASE IdeDebugMode - CASE 1 + CASE 1 'clean exit IdeDebugMode = 0 idefocusline = 0 debugnextline = 0 + CASE 2 'right-click detected; invoke contextual menu + PCOPY 3, 0 + IdeMakeContextualMenu + idecontextualmenu = 1 + GOTO showmenu END SELECT COLOR 0, 7: _PRINTSTRING (1, 1), menubar$ IF idesubwindow <> 0 THEN _RESIZE OFF ELSE _RESIZE ON @@ -4422,20 +4427,27 @@ FUNCTION ide2 (ignore) GOTO ideloop END IF - IF _RESIZE THEN + IF (_RESIZE <> 0) AND IdeDebugMode <> 2 THEN ForceResize = -1: skipdisplay = 0: GOTO ideloop END IF LOOP UNTIL KALT = 0 'wait till alt is released PCOPY 3, 0: SCREEN , , 3, 0 GOTO startmenu2 END IF - IF _EXIT THEN ideexit = 1: GOTO ideloop + IF _EXIT THEN + IF IdeDebugMode = 2 THEN + IdeDebugMode = 9: GOTO EnterDebugMode + ELSE + ideexit = 1: GOTO ideloop + END IF + END IF IF _WINDOWHASFOCUS = 0 AND (os$ = "WIN" OR MacOSX = 1) THEN COLOR 0, 7: _PRINTSTRING (1, 1), menubar$ PCOPY 3, 0: SCREEN , , 3, 0 + IF IdeDebugMode = 2 THEN GOTO EnterDebugMode GOTO ideloop END IF - IF _RESIZE THEN + IF (_RESIZE <> 0) AND IdeDebugMode <> 2 THEN ForceResize = -1: skipdisplay = 0: GOTO ideloop END IF _LIMIT 100 @@ -4445,6 +4457,7 @@ FUNCTION ide2 (ignore) IF mWHEEL THEN PCOPY 3, 0: SCREEN , , 3, 0 + IF IdeDebugMode = 2 THEN GOTO EnterDebugMode GOTO ideloop END IF @@ -4452,6 +4465,16 @@ FUNCTION ide2 (ignore) IF (mX > 1 AND mX < idewx AND mY > 2 AND mY < (idewy - 5)) OR _ (mY >= idewy AND mY < idewy + idesubwindow) THEN PCOPY 3, 0: SCREEN , , 3, 0 + IF IdeDebugMode = 2 THEN + bkpidecy = idecy + idecy = mY - 2 + idesy - 1 + IF idecy > iden THEN idecy = iden + IF bkpidecy <> idecy THEN + ideshowtext + PCOPY 3, 0 + END IF + GOTO showmenu + END IF GOTO invokecontextualmenu ELSE PCOPY 3, 0: SCREEN , , 3, 0 @@ -4484,6 +4507,7 @@ FUNCTION ide2 (ignore) IF mX < xx - 2 OR mX >= xx - 2 + w + 4 OR mY > yy + menusize(m) + 1 OR (mY < yy AND idecontextualmenu = 1) THEN PCOPY 3, 0: SCREEN , , 3, 0 + IF IdeDebugMode = 2 THEN GOTO EnterDebugMode GOTO ideloop END IF END IF @@ -4515,7 +4539,7 @@ FUNCTION ide2 (ignore) END IF IF oldmx <> mX THEN checkmenubarhover: - IF mY = 1 AND idecontextualmenu <> 1 THEN 'Check if we're hovering on menu bar + IF IdeDebugMode <> 2 AND mY = 1 AND idecontextualmenu <> 1 THEN 'Check if we're hovering on menu bar lastm = m FOR i = 1 TO menus x = CVI(MID$(MenuLocations, i * 2 - 1, 2)) @@ -4537,7 +4561,7 @@ FUNCTION ide2 (ignore) IF mB THEN 'top row - IF mY = 1 THEN + IF mY = 1 AND IdeDebugMode <> 2 THEN lastm = m x = 3 FOR i = 1 TO menus @@ -4593,6 +4617,7 @@ FUNCTION ide2 (ignore) IF m > menus AND idecontextualmenu = 0 THEN m = 1 IF KB = KEY_ESC THEN PCOPY 3, 0: SCREEN , , 3, 0 + IF IdeDebugMode = 2 THEN GOTO EnterDebugMode GOTO ideloop END IF IF KB = KEY_DOWN THEN @@ -5243,13 +5268,18 @@ FUNCTION ide2 (ignore) GOTO ideloop END IF - IF menu$(m, s) = "#SUBs... F2" THEN - PCOPY 2, 0 - idesubsjmp: - r$ = idesubs - IF r$ <> "C" THEN ideselect = 0 - PCOPY 3, 0: SCREEN , , 3, 0 - GOTO ideloop + IF menu$(m, s) = "#SUBs... F2" OR menu$(m, s) = "SUBs... F2" THEN + IF IdeDebugMode = 2 THEN + IdeDebugMode = 14 + GOTO EnterDebugMode + ELSE + PCOPY 2, 0 + idesubsjmp: + r$ = idesubs + IF r$ <> "C" THEN ideselect = 0 + PCOPY 3, 0: SCREEN , , 3, 0 + GOTO ideloop + END IF END IF IF menu$(m, s) = "#Line Numbers " + CHR$(16) THEN @@ -5319,15 +5349,6 @@ FUNCTION ide2 (ignore) GOTO ideloop END IF - IF menu$(m, s) = "Call #Stack... F4" THEN - PCOPY 2, 0 - showCallStackDialog: - retval = idecallstackbox - 'retval is ignored - PCOPY 3, 0: SCREEN , , 3, 0 - GOTO ideloop - END IF - IF menu$(m, s) = "#Find... Ctrl+F3" THEN PCOPY 2, 0 idefindjmp: @@ -5636,48 +5657,112 @@ FUNCTION ide2 (ignore) END IF END IF + IF menu$(m, s) = "Call #Stack... F4" OR menu$(m, s) = "Call Stack... F4" THEN + IF IdeDebugMode = 2 THEN + IdeDebugMode = 3 + GOTO EnterDebugMode + ELSE + PCOPY 2, 0 + showCallStackDialog: + retval = idecallstackbox + 'retval is ignored + PCOPY 3, 0: SCREEN , , 3, 0 + GOTO ideloop + END IF + END IF + + IF menu$(m, s) = "#Continue F5" THEN + IdeDebugMode = 4 + GOTO EnterDebugMode + END IF + + IF menu$(m, s) = "Step O#ut F6" THEN + IdeDebugMode = 5 + GOTO EnterDebugMode + END IF + + IF menu$(m, s) = "Step #Over F7" THEN + IdeDebugMode = 6 + GOTO EnterDebugMode + END IF + + IF menu$(m, s) = "Ste#p Into F8" THEN + IdeDebugMode = 7 + GOTO EnterDebugMode + END IF + + IF menu$(m, s) = "#Run To This Line" THEN + IdeDebugMode = 8 + GOTO EnterDebugMode + END IF + + IF menu$(m, s) = "#Exit $DEBUG mode ESC" THEN + IdeDebugMode = 9 + GOTO EnterDebugMode + END IF + IF menu$(m, s) = "Toggle #Breakpoint F9" THEN - PCOPY 3, 0: SCREEN , , 3, 0 - toggleBreakpoint: - IF vWatchOn = 0 THEN - result = idemessagebox("Toggle Breakpoint", "Insert $DEBUG metacommand?", "#Yes;#No") - IF result = 1 THEN - ideselect = 0 - ideinsline 1, SCase$("$Debug") - idecy = idecy + 1 - idechangemade = 1 + IF IdeDebugMode = 2 THEN + IdeDebugMode = 10 + GOTO EnterDebugMode + ELSE + PCOPY 3, 0: SCREEN , , 3, 0 + toggleBreakpoint: + IF vWatchOn = 0 THEN + result = idemessagebox("Toggle Breakpoint", "Insert $DEBUG metacommand?", "#Yes;#No") + IF result = 1 THEN + ideselect = 0 + ideinsline 1, SCase$("$Debug") + idecy = idecy + 1 + idechangemade = 1 + IdeBreakpoints(idecy) = NOT IdeBreakpoints(idecy) + END IF + ELSE IdeBreakpoints(idecy) = NOT IdeBreakpoints(idecy) END IF - ELSE - IdeBreakpoints(idecy) = NOT IdeBreakpoints(idecy) + IF IdeBreakpoints(idecy) THEN IdeSkipLines(idecy) = 0 + GOTO ideloop END IF - IF IdeBreakpoints(idecy) THEN IdeSkipLines(idecy) = 0 - GOTO ideloop END IF - IF menu$(m, s) = "#Clear All Breakpoints F10" THEN - PCOPY 3, 0: SCREEN , , 3, 0 - REDIM IdeBreakpoints(iden) AS _BYTE - GOTO ideloop + IF menu$(m, s) = "#Clear All Breakpoints F10" OR menu$(m, s) = "Clear All Breakpoints F10" THEN + IF IdeDebugMode = 2 THEN + IdeDebugMode = 11 + GOTO EnterDebugMode + ELSE + PCOPY 3, 0: SCREEN , , 3, 0 + REDIM IdeBreakpoints(iden) AS _BYTE + GOTO ideloop + END IF END IF - IF menu$(m, s) = "Toggle #Skip Line" THEN - PCOPY 3, 0: SCREEN , , 3, 0 - toggleSkipLine: - IF vWatchOn = 0 THEN - result = idemessagebox("Toggle Breakpoint", "Insert $DEBUG metacommand?", "#Yes;#No") - IF result = 1 THEN - ideselect = 0 - ideinsline 1, SCase$("$Debug") - idecy = idecy + 1 - idechangemade = 1 + IF menu$(m, s) = "Toggle #Skip Line Ctrl+P" THEN + IF IdeDebugMode = 2 THEN + IdeDebugMode = 12 + GOTO EnterDebugMode + ELSE + PCOPY 3, 0: SCREEN , , 3, 0 + toggleSkipLine: + IF vWatchOn = 0 THEN + result = idemessagebox("Toggle Breakpoint", "Insert $DEBUG metacommand?", "#Yes;#No") + IF result = 1 THEN + ideselect = 0 + ideinsline 1, SCase$("$Debug") + idecy = idecy + 1 + idechangemade = 1 + IdeSkipLines(idecy) = NOT IdeSkipLines(idecy) + END IF + ELSE IdeSkipLines(idecy) = NOT IdeSkipLines(idecy) END IF - ELSE - IdeSkipLines(idecy) = NOT IdeSkipLines(idecy) + IF IdeSkipLines(idecy) THEN IdeBreakpoints(idecy) = 0 + GOTO ideloop END IF - IF IdeSkipLines(idecy) THEN IdeBreakpoints(idecy) = 0 - GOTO ideloop + END IF + + IF menu$(m, s) = "Set #Next Line Ctrl+G" THEN + IdeDebugMode = 13 + GOTO EnterDebugMode END IF IF menu$(m, s) = "E#xit" THEN @@ -6117,17 +6202,65 @@ END FUNCTION SUB DebugMode STATIC PauseMode AS _BYTE + STATIC client& + STATIC buffer$ + STATIC endc$ timeout = 10 _KEYCLEAR - IF IdeDebugMode = 1 THEN - PauseMode = 0 - callStackLength = 0 - callstacklist$ = "" - END IF - SCREEN , , 3, 0 + + SELECT CASE IdeDebugMode + CASE 1 + PauseMode = 0 + callStackLength = 0 + callstacklist$ = "" + buffer$ = "" + client& = 0 + CASE 2 + IdeDebugMode = 1 + GOTO returnFromContextMenu + CASE 3 + IdeDebugMode = 1 + GOTO requestCallStack + CASE 4 + IdeDebugMode = 1 + GOTO requestContinue + CASE 5 + IdeDebugMode = 1 + GOTO requestStepOut + CASE 6 + IdeDebugMode = 1 + GOTO requestStepOver + CASE 7 + IdeDebugMode = 1 + GOTO requestPause + CASE 8 + 'IdeDebugMode = 1 + 'GOTO requestPause + CASE 9 + IdeDebugMode = 1 + GOTO requestQuit + CASE 10 + IdeDebugMode = 1 + GOTO requestToggleBreakpoint + CASE 11 + IdeDebugMode = 1 + GOTO requestClearBreakpoints + CASE 12 + IdeDebugMode = 1 + result = idecy + GOTO requestToggleSkipLine + CASE 13 + IdeDebugMode = 1 + result = idecy + GOTO requestSetNextLine + CASE 14 + IdeDebugMode = 1 + GOTO requestSubsDialog + END SELECT + COLOR 0, 7: _PRINTSTRING (1, 1), SPACE$(LEN(menubar$)) m$ = "$DEBUG MODE ACTIVE" COLOR 0 @@ -6282,6 +6415,33 @@ SUB DebugMode mX = _MOUSEX mY = _MOUSEY + IF mB2 THEN + IF mouseDown2 = 0 THEN + mouseDown2 = -1 + mouseDownOnX2 = mX + mouseDownOnY2 = mY + ELSE + END IF + ELSE + IF mouseDown2 THEN + IF mouseDownOnX2 = mX AND mouseDownOnY2 = mY THEN + IF (mX > 1 AND mX <= 1 + maxLineNumberLength AND mY > 2 AND mY < (idewy - 5) AND ShowLineNumbers) OR _ + (mX = 1 AND mY > 2 AND mY < (idewy - 5) AND ShowLineNumbers = 0) OR _ + (mX > 1 + maxLineNumberLength AND mX < idewx AND mY > 2 AND mY < (idewy - 5)) THEN + bkpidecy = idecy + idecy = mY - 2 + idesy - 1 + IF idecy > iden THEN idecy = iden + IF bkpidecy <> idecy THEN GOSUB UpdateDisplay + IdeDebugMode = 2 + IF PauseMode = 0 THEN GOSUB requestPause: dummy = DarkenFGBG(0) + EXIT SUB + returnFromContextMenu: + END IF + END IF + END IF + mouseDown2 = 0 + END IF + IF mB THEN IF mouseDown = 0 THEN mouseDown = -1 @@ -6474,6 +6634,7 @@ SUB DebugMode IF _KEYDOWN(100306) OR _KEYDOWN(100305) THEN idecy = iden IF bkpidecy <> idecy OR bkpidesy <> idesy THEN GOSUB UpdateDisplay CASE 27 + requestQuit: cmd$ = "free" GOSUB SendCommand CLOSE #client& @@ -6484,11 +6645,13 @@ SUB DebugMode _KEYCLEAR EXIT SUB CASE 15360 'F2 + requestSubsDialog: r$ = idesubs PCOPY 3, 0: SCREEN , , 3, 0 GOSUB UpdateDisplay CASE 15872 'F4 IF PauseMode THEN + requestCallStack: cmd$ = "call stack" GOSUB SendCommand @@ -6519,6 +6682,7 @@ SUB DebugMode noFocusMessage = NOT noFocusMessage END IF CASE 16128 'F5 + requestContinue: PauseMode = 0 debugnextline = 0 cmd$ = "run" @@ -6528,6 +6692,7 @@ SUB DebugMode GOSUB UpdateDisplay dummy = DarkenFGBG(1) CASE 16384 'F6 + requestStepOut: IF PauseMode THEN PauseMode = 0 cmd$ = "step out" @@ -6537,6 +6702,7 @@ SUB DebugMode dummy = DarkenFGBG(1) END IF CASE 16640 'F7 + requestStepOver: IF PauseMode THEN cmd$ = "step over" PauseMode = 0 @@ -6547,6 +6713,7 @@ SUB DebugMode END IF CASE 16896 'F8 IF PauseMode = 0 THEN + requestPause: cmd$ = "break" PauseMode = -1 GOSUB SendCommand @@ -6557,7 +6724,9 @@ SUB DebugMode END IF clearStatusWindow 1 setStatusMessage 1, "Paused.", 2 + IF IdeDebugMode = 2 THEN RETURN CASE 17152 'F9 + requestToggleBreakpoint: IF PauseMode THEN IdeBreakpoints(idecy) = NOT IdeBreakpoints(idecy) IF IdeBreakpoints(idecy) THEN @@ -6571,6 +6740,7 @@ SUB DebugMode GOSUB UpdateDisplay END IF CASE 17408 'F10 + requestClearBreakpoints: REDIM IdeBreakpoints(iden) AS _BYTE cmd$ = "clear all breakpoints" GOSUB SendCommand @@ -6579,6 +6749,7 @@ SUB DebugMode IF _KEYDOWN(100306) OR _KEYDOWN(100305) THEN result = idegetlinenumberbox("Set Next Line") PCOPY 3, 0: SCREEN , , 3, 0 + requestSetNextLine: IF result > 0 AND result < iden THEN cmd$ = "set next line:" + MKL$(result) GOSUB SendCommand @@ -6588,10 +6759,13 @@ SUB DebugMode IF _KEYDOWN(100306) OR _KEYDOWN(100305) THEN result = idegetlinenumberbox("Skip Line") PCOPY 3, 0: SCREEN , , 3, 0 + requestToggleSkipLine: IF result > 0 AND result <= iden THEN - cmd$ = "set skip line:" + MKL$(result) + IdeSkipLines(result) = NOT IdeSkipLines(result) + cmd$ = "set skip line:" + IF IdeSkipLines(result) = 0 THEN cmd$ = "clear skip line:" + cmd$ = cmd$ + MKL$(result) GOSUB SendCommand - IdeSkipLines(result) = -1 GOSUB UpdateDisplay END IF END IF @@ -14220,205 +14394,244 @@ SUB IdeMakeContextualMenu m = idecontextualmenuID: i = 0 menu$(m, i) = "Contextual": i = i + 1 - IF IdeSystem = 1 OR IdeSystem = 2 THEN - 'Figure out if the user wants to search for a selected term - Selection$ = getSelectedText$(0) - sela2$ = Selection$ - IF LEN(Selection$) > 0 THEN - idecontextualSearch$ = Selection$ - IF LEN(sela2$) > 22 THEN - sela2$ = LEFT$(sela2$, 19) + STRING$(3, 250) - END IF - menu$(m, i) = "Find '" + sela2$ + "'": i = i + 1 - menuDesc$(m, i - 1) = "Searches for the text currently selected" - END IF - - 'build SUB/FUNCTION list: - TotalSF = 0 - FOR y = 1 TO iden - a$ = idegetline(y) - a$ = LTRIM$(RTRIM$(a$)) - sf = 0 - nca$ = UCASE$(a$) - IF LEFT$(nca$, 4) = "SUB " THEN sf = 1: sf$ = "SUB " - IF LEFT$(nca$, 9) = "FUNCTION " THEN sf = 2: sf$ = "FUNC " - IF sf THEN - IF RIGHT$(nca$, 7) = " STATIC" THEN - a$ = RTRIM$(LEFT$(a$, LEN(a$) - 7)) - END IF - - IF sf = 1 THEN - a$ = RIGHT$(a$, LEN(a$) - 4) - ELSE - a$ = RIGHT$(a$, LEN(a$) - 9) - END IF - - a$ = LTRIM$(RTRIM$(a$)) - x = INSTR(a$, "(") - IF x THEN - n$ = RTRIM$(LEFT$(a$, x - 1)) - ELSE - n$ = a$ - cleanSubName n$ - END IF - - n2$ = n$ - IF LEN(n2$) > 1 THEN - DO UNTIL alphanumeric(ASC(RIGHT$(n2$, 1))) - n2$ = LEFT$(n$, LEN(n2$) - 1) 'removes sigil, if any - LOOP - END IF - - 'Populate SubFuncLIST() - TotalSF = TotalSF + 1 - REDIM _PRESERVE SubFuncLIST(1 TO TotalSF) AS STRING - SubFuncLIST(TotalSF) = MKL$(y) + CHR$(sf) + n2$ - END IF - NEXT - - 'identify if word or character at current cursor position is in the help system OR a sub/func - a2$ = UCASE$(getWordAtCursor$) - - 'check if cursor is on sub/func/label name - IF LEN(LTRIM$(RTRIM$(Selection$))) > 0 THEN - DO UNTIL alphanumeric(ASC(RIGHT$(Selection$, 1))) - Selection$ = LEFT$(Selection$, LEN(Selection$) - 1) 'removes sigil, if any - IF LEN(Selection$) = 0 THEN EXIT DO - LOOP - Selection$ = LTRIM$(RTRIM$(Selection$)) - END IF - - IF RIGHT$(a2$, 1) = "$" THEN a3$ = LEFT$(a2$, LEN(a2$) - 1) ELSE a3$ = a2$ 'creates a new version without $ - - IF LEN(a3$) > 0 OR LEN(Selection$) > 0 THEN - - FOR CheckSF = 1 TO TotalSF - IF a3$ = UCASE$(MID$(SubFuncLIST(CheckSF), 6)) OR UCASE$(Selection$) = UCASE$(MID$(SubFuncLIST(CheckSF), 6)) THEN - CurrSF$ = FindCurrentSF$(idecy) - IF LEN(CurrSF$) = 0 THEN GOTO SkipCheckCurrSF - - DO UNTIL alphanumeric(ASC(RIGHT$(CurrSF$, 1))) - CurrSF$ = LEFT$(CurrSF$, LEN(CurrSF$) - 1) 'removes sigil, if any - IF LEN(CurrSF$) = 0 THEN EXIT DO - LOOP - CurrSF$ = UCASE$(CurrSF$) - - SkipCheckCurrSF: - IF ASC(SubFuncLIST(CheckSF), 5) = 1 THEN - CursorSF$ = "SUB " - ELSE - CursorSF$ = "FUNCTION " - END IF - CursorSF$ = CursorSF$ + MID$(SubFuncLIST(CheckSF), 6) - - IF UCASE$(CursorSF$) = CurrSF$ THEN - EXIT FOR - ELSE - menu$(m, i) = "#Go To " + CursorSF$: i = i + 1 - menuDesc$(m, i - 1) = "Jumps to procedure definition" - SubFuncLIST(1) = SubFuncLIST(CheckSF) - EXIT FOR - END IF - END IF - NEXT CheckSF - - v = 0 - CurrSF$ = FindCurrentSF$(idecy) - IF validname(a2$) THEN v = HashFind(a2$, HASHFLAG_LABEL, ignore, r) - CheckThisLabel: - IF v THEN - LabelLineNumber = Labels(r).SourceLineNumber - ThisLabelScope$ = FindCurrentSF$(LabelLineNumber) - IF ThisLabelScope$ <> CurrSF$ AND v = 2 THEN - v = HashFindCont(ignore, r) - GOTO CheckThisLabel - END IF - IF LabelLineNumber > 0 AND LabelLineNumber <> idecy THEN - menu$(m, i) = "Go To #Label " + RTRIM$(Labels(r).cn): i = i + 1 - menuDesc$(m, i - 1) = "Jumps to label" - REDIM _PRESERVE SubFuncLIST(1 TO UBOUND(SubFuncLIST) + 1) AS STRING - SubFuncLIST(UBOUND(SubFuncLIST)) = MKL$(Labels(r).SourceLineNumber) - END IF - END IF - END IF - - IF LEN(a2$) > 0 THEN - 'check if a2$ is in help links - lnks = 0 - l2$ = findHelpTopic$(a2$, lnks, -1) - - IF lnks THEN - IF LEN(l2$) > 15 THEN - l2$ = LEFT$(l2$, 12) + STRING$(3, 250) - END IF - IF INSTR(l2$, "PARENTHESIS") = 0 THEN - menu$(m, i) = "#Help On '" + l2$ + "'": i = i + 1 - menuDesc$(m, i - 1) = "Opens help article on the selected term" - END IF - END IF - END IF - - IF i > 1 THEN - menu$(m, i) = "-": i = i + 1 - END IF - - '--------- Check if _RGB mixer should be offered: ----------------------------------------- - a$ = idegetline(idecy) - IF ideselect THEN - IF ideselecty1 <> idecy THEN GOTO NoRGBFound 'multi line selected - END IF - - Found_RGB = 0 - Found_RGB = Found_RGB + INSTR(UCASE$(a$), "RGB(") - Found_RGB = Found_RGB + INSTR(UCASE$(a$), "RGB32(") - Found_RGB = Found_RGB + INSTR(UCASE$(a$), "RGBA(") - Found_RGB = Found_RGB + INSTR(UCASE$(a$), "RGBA32(") - IF Found_RGB THEN - menu$(m, i) = "#RGB Color Mixer...": i = i + 1 - menuDesc$(m, i - 1) = "Allows mixing colors to edit/insert _RGB statements" - menu$(m, i) = "-": i = i + 1 - END IF - NoRGBFound: - '--------- _RGB mixer check done. -------------------------------------------- - - IF (ideselect <> 0) THEN - menu$(m, i) = "Cu#t Shift+Del or Ctrl+X": i = i + 1 - menuDesc$(m, i - 1) = "Deletes selected text and copies it to clipboard" - menu$(m, i) = "#Copy Ctrl+Ins or Ctrl+C": i = i + 1 - menuDesc$(m, i - 1) = "Copies selected text to clipboard" - END IF - - clip$ = _CLIPBOARD$ 'read clipboard - IF LEN(clip$) THEN - menu$(m, i) = "#Paste Shift+Ins or Ctrl+V": i = i + 1 - menuDesc$(m, i - 1) = "Inserts clipboard contents at current location" - END IF - - IF ideselect THEN - menu$(m, i) = "Cl#ear Del": i = i + 1 - menuDesc$(m, i - 1) = "Deletes selected text" - END IF - menu$(m, i) = "Select #All Ctrl+A": i = i + 1 - menuDesc$(m, i - 1) = "Selects all contents of current program" + IF IdeDebugMode = 2 THEN + menu$(m, i) = "#Continue F5": i = i + 1 + menuDesc$(m, i - 1) = "Runs until the end of the current procedure is reached" + menu$(m, i) = "Step O#ut F6": i = i + 1 + menuDesc$(m, i - 1) = "Runs until the end of the current procedure is reached" + menu$(m, i) = "Step #Over F7": i = i + 1 + menuDesc$(m, i - 1) = "Runs the next line of code without entering subs/functions" + menu$(m, i) = "Ste#p Into F8": i = i + 1 + menuDesc$(m, i - 1) = "Runs the next line of code and pauses execution" menu$(m, i) = "-": i = i + 1 - menu$(m, i) = "To#ggle Comment Ctrl+T": i = i + 1 - menuDesc$(m, i - 1) = "Toggles comment (') on the current selection" - menu$(m, i) = "Add Co#mment (') Ctrl+R": i = i + 1 - menuDesc$(m, i - 1) = "Adds comment marker (') to the current selection" - menu$(m, i) = "Remove Comme#nt (') Ctrl+Shift+R": i = i + 1 - menuDesc$(m, i - 1) = "Removes comment marker (') from the current selection" - IF ideselect THEN - y1 = idecy - y2 = ideselecty1 - IF y1 = y2 THEN 'single line selected - a$ = idegetline(idecy) - a2$ = "" - sx1 = ideselectx1: sx2 = idecx - IF sx2 < sx1 THEN SWAP sx1, sx2 - FOR x = sx1 TO sx2 - 1 - IF x <= LEN(a$) THEN a2$ = a2$ + MID$(a$, x, 1) ELSE a2$ = a2$ + " " - NEXT - IF a2$ <> "" THEN + menu$(m, i) = "Set #Next Line Ctrl+G": i = i + 1 + menuDesc$(m, i - 1) = "Jumps to the selected line before continuing execution" + menu$(m, i) = "#Run To This Line": i = i + 1 + menuDesc$(m, i - 1) = "Runs until the selected line is reached" + menu$(m, i) = "-": i = i + 1 + menu$(m, i) = "Toggle #Breakpoint F9": i = i + 1 + menuDesc$(m, i - 1) = "Sets/clears breakpoint at cursor location" + menu$(m, i) = "Clear All Breakpoints F10": i = i + 1 + menuDesc$(m, i - 1) = "Removes all breakpoints" + menu$(m, i) = "Toggle #Skip Line Ctrl+P": i = i + 1 + menuDesc$(m, i - 1) = "Sets/clears flag to skip line" + menu$(m, i) = "-": i = i + 1 + menu$(m, i) = "SUBs... F2": i = i + 1 + menuDesc$(m, i - 1) = "Displays a list of SUB/FUNCTION procedures" + menu$(m, i) = "Call Stack... F4": i = i + 1 + menuDesc$(m, i - 1) = "Displays the call stack of the current program's execution" + menu$(m, i) = "-": i = i + 1 + menu$(m, i) = "#Exit $DEBUG mode ESC": i = i + 1 + menuDesc$(m, i - 1) = "Disconnects from the running program and returns control to the IDE" + ELSE + IF IdeSystem = 1 OR IdeSystem = 2 THEN + 'Figure out if the user wants to search for a selected term + Selection$ = getSelectedText$(0) + sela2$ = Selection$ + IF LEN(Selection$) > 0 THEN + idecontextualSearch$ = Selection$ + IF LEN(sela2$) > 22 THEN + sela2$ = LEFT$(sela2$, 19) + STRING$(3, 250) + END IF + menu$(m, i) = "Find '" + sela2$ + "'": i = i + 1 + menuDesc$(m, i - 1) = "Searches for the text currently selected" + END IF + + 'build SUB/FUNCTION list: + TotalSF = 0 + FOR y = 1 TO iden + a$ = idegetline(y) + a$ = LTRIM$(RTRIM$(a$)) + sf = 0 + nca$ = UCASE$(a$) + IF LEFT$(nca$, 4) = "SUB " THEN sf = 1: sf$ = "SUB " + IF LEFT$(nca$, 9) = "FUNCTION " THEN sf = 2: sf$ = "FUNC " + IF sf THEN + IF RIGHT$(nca$, 7) = " STATIC" THEN + a$ = RTRIM$(LEFT$(a$, LEN(a$) - 7)) + END IF + + IF sf = 1 THEN + a$ = RIGHT$(a$, LEN(a$) - 4) + ELSE + a$ = RIGHT$(a$, LEN(a$) - 9) + END IF + + a$ = LTRIM$(RTRIM$(a$)) + x = INSTR(a$, "(") + IF x THEN + n$ = RTRIM$(LEFT$(a$, x - 1)) + ELSE + n$ = a$ + cleanSubName n$ + END IF + + n2$ = n$ + IF LEN(n2$) > 1 THEN + DO UNTIL alphanumeric(ASC(RIGHT$(n2$, 1))) + n2$ = LEFT$(n$, LEN(n2$) - 1) 'removes sigil, if any + LOOP + END IF + + 'Populate SubFuncLIST() + TotalSF = TotalSF + 1 + REDIM _PRESERVE SubFuncLIST(1 TO TotalSF) AS STRING + SubFuncLIST(TotalSF) = MKL$(y) + CHR$(sf) + n2$ + END IF + NEXT + + 'identify if word or character at current cursor position is in the help system OR a sub/func + a2$ = UCASE$(getWordAtCursor$) + + 'check if cursor is on sub/func/label name + IF LEN(LTRIM$(RTRIM$(Selection$))) > 0 THEN + DO UNTIL alphanumeric(ASC(RIGHT$(Selection$, 1))) + Selection$ = LEFT$(Selection$, LEN(Selection$) - 1) 'removes sigil, if any + IF LEN(Selection$) = 0 THEN EXIT DO + LOOP + Selection$ = LTRIM$(RTRIM$(Selection$)) + END IF + + IF RIGHT$(a2$, 1) = "$" THEN a3$ = LEFT$(a2$, LEN(a2$) - 1) ELSE a3$ = a2$ 'creates a new version without $ + + IF LEN(a3$) > 0 OR LEN(Selection$) > 0 THEN + + FOR CheckSF = 1 TO TotalSF + IF a3$ = UCASE$(MID$(SubFuncLIST(CheckSF), 6)) OR UCASE$(Selection$) = UCASE$(MID$(SubFuncLIST(CheckSF), 6)) THEN + CurrSF$ = FindCurrentSF$(idecy) + IF LEN(CurrSF$) = 0 THEN GOTO SkipCheckCurrSF + + DO UNTIL alphanumeric(ASC(RIGHT$(CurrSF$, 1))) + CurrSF$ = LEFT$(CurrSF$, LEN(CurrSF$) - 1) 'removes sigil, if any + IF LEN(CurrSF$) = 0 THEN EXIT DO + LOOP + CurrSF$ = UCASE$(CurrSF$) + + SkipCheckCurrSF: + IF ASC(SubFuncLIST(CheckSF), 5) = 1 THEN + CursorSF$ = "SUB " + ELSE + CursorSF$ = "FUNCTION " + END IF + CursorSF$ = CursorSF$ + MID$(SubFuncLIST(CheckSF), 6) + + IF UCASE$(CursorSF$) = CurrSF$ THEN + EXIT FOR + ELSE + menu$(m, i) = "#Go To " + CursorSF$: i = i + 1 + menuDesc$(m, i - 1) = "Jumps to procedure definition" + SubFuncLIST(1) = SubFuncLIST(CheckSF) + EXIT FOR + END IF + END IF + NEXT CheckSF + + v = 0 + CurrSF$ = FindCurrentSF$(idecy) + IF validname(a2$) THEN v = HashFind(a2$, HASHFLAG_LABEL, ignore, r) + CheckThisLabel: + IF v THEN + LabelLineNumber = Labels(r).SourceLineNumber + ThisLabelScope$ = FindCurrentSF$(LabelLineNumber) + IF ThisLabelScope$ <> CurrSF$ AND v = 2 THEN + v = HashFindCont(ignore, r) + GOTO CheckThisLabel + END IF + IF LabelLineNumber > 0 AND LabelLineNumber <> idecy THEN + menu$(m, i) = "Go To #Label " + RTRIM$(Labels(r).cn): i = i + 1 + menuDesc$(m, i - 1) = "Jumps to label" + REDIM _PRESERVE SubFuncLIST(1 TO UBOUND(SubFuncLIST) + 1) AS STRING + SubFuncLIST(UBOUND(SubFuncLIST)) = MKL$(Labels(r).SourceLineNumber) + END IF + END IF + END IF + + IF LEN(a2$) > 0 THEN + 'check if a2$ is in help links + lnks = 0 + l2$ = findHelpTopic$(a2$, lnks, -1) + + IF lnks THEN + IF LEN(l2$) > 15 THEN + l2$ = LEFT$(l2$, 12) + STRING$(3, 250) + END IF + IF INSTR(l2$, "PARENTHESIS") = 0 THEN + menu$(m, i) = "#Help On '" + l2$ + "'": i = i + 1 + menuDesc$(m, i - 1) = "Opens help article on the selected term" + END IF + END IF + END IF + + IF i > 1 THEN + menu$(m, i) = "-": i = i + 1 + END IF + + '--------- Check if _RGB mixer should be offered: ----------------------------------------- + a$ = idegetline(idecy) + IF ideselect THEN + IF ideselecty1 <> idecy THEN GOTO NoRGBFound 'multi line selected + END IF + + Found_RGB = 0 + Found_RGB = Found_RGB + INSTR(UCASE$(a$), "RGB(") + Found_RGB = Found_RGB + INSTR(UCASE$(a$), "RGB32(") + Found_RGB = Found_RGB + INSTR(UCASE$(a$), "RGBA(") + Found_RGB = Found_RGB + INSTR(UCASE$(a$), "RGBA32(") + IF Found_RGB THEN + menu$(m, i) = "#RGB Color Mixer...": i = i + 1 + menuDesc$(m, i - 1) = "Allows mixing colors to edit/insert _RGB statements" + menu$(m, i) = "-": i = i + 1 + END IF + NoRGBFound: + '--------- _RGB mixer check done. -------------------------------------------- + + IF (ideselect <> 0) THEN + menu$(m, i) = "Cu#t Shift+Del or Ctrl+X": i = i + 1 + menuDesc$(m, i - 1) = "Deletes selected text and copies it to clipboard" + menu$(m, i) = "#Copy Ctrl+Ins or Ctrl+C": i = i + 1 + menuDesc$(m, i - 1) = "Copies selected text to clipboard" + END IF + + clip$ = _CLIPBOARD$ 'read clipboard + IF LEN(clip$) THEN + menu$(m, i) = "#Paste Shift+Ins or Ctrl+V": i = i + 1 + menuDesc$(m, i - 1) = "Inserts clipboard contents at current location" + END IF + + IF ideselect THEN + menu$(m, i) = "Cl#ear Del": i = i + 1 + menuDesc$(m, i - 1) = "Deletes selected text" + END IF + menu$(m, i) = "Select #All Ctrl+A": i = i + 1 + menuDesc$(m, i - 1) = "Selects all contents of current program" + menu$(m, i) = "-": i = i + 1 + menu$(m, i) = "To#ggle Comment Ctrl+T": i = i + 1 + menuDesc$(m, i - 1) = "Toggles comment (') on the current selection" + menu$(m, i) = "Add Co#mment (') Ctrl+R": i = i + 1 + menuDesc$(m, i - 1) = "Adds comment marker (') to the current selection" + menu$(m, i) = "Remove Comme#nt (') Ctrl+Shift+R": i = i + 1 + menuDesc$(m, i - 1) = "Removes comment marker (') from the current selection" + IF ideselect THEN + y1 = idecy + y2 = ideselecty1 + IF y1 = y2 THEN 'single line selected + a$ = idegetline(idecy) + a2$ = "" + sx1 = ideselectx1: sx2 = idecx + IF sx2 < sx1 THEN SWAP sx1, sx2 + FOR x = sx1 TO sx2 - 1 + IF x <= LEN(a$) THEN a2$ = a2$ + MID$(a$, x, 1) ELSE a2$ = a2$ + " " + NEXT + IF a2$ <> "" THEN + menu$(m, i) = "#Increase Indent TAB": i = i + 1 + menuDesc$(m, i - 1) = "Increases indentation of the current selection" + menu$(m, i) = "#Decrease Indent" + menuDesc$(m, i) = "Decreases indentation of the current selection" + IF INSTR(_OS$, "WIN") OR INSTR(_OS$, "MAC") THEN menu$(m, i) = menu$(m, i) + " Shift+TAB" + i = i + 1 + menu$(m, i) = "-": i = i + 1 + END IF + ELSE menu$(m, i) = "#Increase Indent TAB": i = i + 1 menuDesc$(m, i - 1) = "Increases indentation of the current selection" menu$(m, i) = "#Decrease Indent" @@ -14428,43 +14641,35 @@ SUB IdeMakeContextualMenu menu$(m, i) = "-": i = i + 1 END IF ELSE - menu$(m, i) = "#Increase Indent TAB": i = i + 1 - menuDesc$(m, i - 1) = "Increases indentation of the current selection" - menu$(m, i) = "#Decrease Indent" - menuDesc$(m, i) = "Decreases indentation of the current selection" - IF INSTR(_OS$, "WIN") OR INSTR(_OS$, "MAC") THEN menu$(m, i) = menu$(m, i) + " Shift+TAB" - i = i + 1 menu$(m, i) = "-": i = i + 1 END IF - ELSE + menu$(m, i) = "New #SUB...": i = i + 1 + menuDesc$(m, i - 1) = "Creates a new subprocedure at the end of the current program" + menu$(m, i) = "New #FUNCTION...": i = i + 1 + menuDesc$(m, i - 1) = "Creates a new function at the end of the current program" + ELSEIF IdeSystem = 3 THEN + IF (Help_Select = 2) THEN + menu$(m, i) = "#Copy Ctrl+Ins or Ctrl+C": i = i + 1 + menuDesc$(m, i - 1) = "Copies selected text to clipboard" + END IF + menu$(m, i) = "Select #All Ctrl+A": i = i + 1 + menuDesc$(m, i - 1) = "Selects all contents of current article" menu$(m, i) = "-": i = i + 1 + menu$(m, i) = "#Contents Page": i = i + 1 + menuDesc$(m, i - 1) = "Displays help contents page" + menu$(m, i) = "Keyword #Index": i = i + 1 + menuDesc$(m, i - 1) = "Displays keyword index page" + menu$(m, i) = "#Keywords by Usage": i = i + 1 + menuDesc$(m, i - 1) = "Displays keywords index by usage" + menu$(m, i) = "-": i = i + 1 + menu$(m, i) = "#Update Current Page": i = i + 1 + menuDesc$(m, i - 1) = "Downloads the latest version of this article from the wiki" + menu$(m, i) = "Update All #Pages...": i = i + 1 + menuDesc$(m, i - 1) = "Downloads the latest version of all articles from the wiki" + menu$(m, i) = "-": i = i + 1 + menu$(m, i) = "Clo#se Help ESC": i = i + 1 + menuDesc$(m, i - 1) = "Closes help window" END IF - menu$(m, i) = "New #SUB...": i = i + 1 - menuDesc$(m, i - 1) = "Creates a new subprocedure at the end of the current program" - menu$(m, i) = "New #FUNCTION...": i = i + 1 - menuDesc$(m, i - 1) = "Creates a new function at the end of the current program" - ELSEIF IdeSystem = 3 THEN - IF (Help_Select = 2) THEN - menu$(m, i) = "#Copy Ctrl+Ins or Ctrl+C": i = i + 1 - menuDesc$(m, i - 1) = "Copies selected text to clipboard" - END IF - menu$(m, i) = "Select #All Ctrl+A": i = i + 1 - menuDesc$(m, i - 1) = "Selects all contents of current article" - menu$(m, i) = "-": i = i + 1 - menu$(m, i) = "#Contents Page": i = i + 1 - menuDesc$(m, i - 1) = "Displays help contents page" - menu$(m, i) = "Keyword #Index": i = i + 1 - menuDesc$(m, i - 1) = "Displays keyword index page" - menu$(m, i) = "#Keywords by Usage": i = i + 1 - menuDesc$(m, i - 1) = "Displays keywords index by usage" - menu$(m, i) = "-": i = i + 1 - menu$(m, i) = "#Update Current Page": i = i + 1 - menuDesc$(m, i - 1) = "Downloads the latest version of this article from the wiki" - menu$(m, i) = "Update All #Pages...": i = i + 1 - menuDesc$(m, i - 1) = "Downloads the latest version of all articles from the wiki" - menu$(m, i) = "-": i = i + 1 - menu$(m, i) = "Clo#se Help ESC": i = i + 1 - menuDesc$(m, i - 1) = "Closes help window" END IF menusize(m) = i - 1 END SUB From b56ceb924d8099d191eac4dee14a894d25ce9bc3 Mon Sep 17 00:00:00 2001 From: FellippeHeitor Date: Tue, 20 Jul 2021 20:11:45 -0300 Subject: [PATCH 17/31] Fixes vWatch labels not being added. --- source/qb64.bas | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/qb64.bas b/source/qb64.bas index f9c59e9fc..f65867a6b 100644 --- a/source/qb64.bas +++ b/source/qb64.bas @@ -5571,7 +5571,7 @@ DO IF n <> 1 AND controlvalue(controllevel) <> currentid THEN a$ = "Incorrect variable after NEXT": GOTO errmes PRINT #12, "fornext_continue_" + str2$(controlid(controllevel)) + ":;" IF vWatchOn = 1 AND inclinenumber(inclevel) = 0 AND NoChecks = 0 THEN - vWatchAddLabel linenumber, 0 + vWatchAddLabel linenumber, 0 PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_local_vars); if (*__LONG_VWATCH_GOTO>0) goto VWATCH_SETNEXTLINE; if (*__LONG_VWATCH_GOTO<0) goto VWATCH_SKIPLINE;" END IF PRINT #12, "}" @@ -14239,6 +14239,7 @@ SUB vWatchAddLabel (this AS LONG, lastLine AS _BYTE) IF prevLabel <> this THEN PRINT #12, "VWATCH_LABEL_" + str2$(this) + ":;" prevLabel = this + lastLineNumberLabelvWatch = this END IF ELSE IF prevSkip <> prevLabel THEN From 2097f35a8ba4e64e235a8004a4c438d3791ebeb7 Mon Sep 17 00:00:00 2001 From: FellippeHeitor Date: Tue, 20 Jul 2021 22:28:03 -0300 Subject: [PATCH 18/31] Implements "Run To This Line". --- source/ide/ide_methods.bas | 33 +++++++++++++++++++++++-------- source/utilities/vwatch/vwatch.bm | 16 ++++++++++++++- 2 files changed, 40 insertions(+), 9 deletions(-) diff --git a/source/ide/ide_methods.bas b/source/ide/ide_methods.bas index be8476b00..a5acb1a4d 100644 --- a/source/ide/ide_methods.bas +++ b/source/ide/ide_methods.bas @@ -6237,8 +6237,9 @@ SUB DebugMode IdeDebugMode = 1 GOTO requestPause CASE 8 - 'IdeDebugMode = 1 - 'GOTO requestPause + IdeDebugMode = 1 + result = idecy + GOTO requestRunToThisLine CASE 9 IdeDebugMode = 1 GOTO requestQuit @@ -6747,12 +6748,28 @@ SUB DebugMode GOSUB UpdateDisplay CASE 103, 71 'g, G IF _KEYDOWN(100306) OR _KEYDOWN(100305) THEN - result = idegetlinenumberbox("Set Next Line") - PCOPY 3, 0: SCREEN , , 3, 0 - requestSetNextLine: - IF result > 0 AND result < iden THEN - cmd$ = "set next line:" + MKL$(result) - GOSUB SendCommand + IF _KEYDOWN(100304) OR _KEYDOWN(100303) THEN + result = idegetlinenumberbox("Run To Line") + PCOPY 3, 0: SCREEN , , 3, 0 + requestRunToThisLine: + IF result > 0 AND result < iden THEN + PauseMode = 0 + debugnextline = 0 + cmd$ = "run to line:" + MKL$(result) + GOSUB SendCommand + clearStatusWindow 1 + setStatusMessage 1, "Running...", 10 + GOSUB UpdateDisplay + dummy = DarkenFGBG(1) + END IF + ELSE + result = idegetlinenumberbox("Set Next Line") + PCOPY 3, 0: SCREEN , , 3, 0 + requestSetNextLine: + IF result > 0 AND result < iden THEN + cmd$ = "set next line:" + MKL$(result) + GOSUB SendCommand + END IF END IF END IF CASE 112, 80 'p, P diff --git a/source/utilities/vwatch/vwatch.bm b/source/utilities/vwatch/vwatch.bm index d8b64b6c7..4e2fbfd35 100644 --- a/source/utilities/vwatch/vwatch.bm +++ b/source/utilities/vwatch/vwatch.bm @@ -2,7 +2,7 @@ $CHECKING:OFF SUB vwatch (localVariables AS _OFFSET) STATIC AS LONG ideHost, breakpointCount, skipCount, timeout, startLevel, lastLine - STATIC AS LONG callStackLength + STATIC AS LONG callStackLength, runToLine STATIC AS _BYTE pauseMode, stepOver, bypass, setNextLine STATIC buffer$, endc$ DIM AS LONG i @@ -121,6 +121,7 @@ SUB vwatch (localVariables AS _OFFSET) CASE "break" pauseMode = -1 stepOver = 0 + runToLine = 0 cmd$ = "" CASE "set breakpoint" vwatch_breakpoints(CVL(value$)) = -1 @@ -145,6 +146,13 @@ SUB vwatch (localVariables AS _OFFSET) pauseMode = -1 END IF + IF runToLine > 0 AND runToLine <> vwatch_linenumber THEN + EXIT SUB + ELSEIF runToLine > 0 AND runToLine = vwatch_linenumber THEN + pauseMode = -1 + runToLine = 0 + END IF + IF vwatch_breakpoints(vwatch_linenumber) = 0 AND pauseMode = 0 THEN EXIT SUB END IF @@ -162,6 +170,12 @@ SUB vwatch (localVariables AS _OFFSET) stepOver = 0 vwatch_starttimers EXIT SUB + CASE "run to line" + pauseMode = 0 + stepOver = 0 + runToLine = CVL(value$) + vwatch_starttimers + EXIT SUB CASE "step" pauseMode = -1 stepOver = 0 From fb94a16bfe21c130b013232a43d8e6ecdafb59e6 Mon Sep 17 00:00:00 2001 From: FellippeHeitor Date: Tue, 20 Jul 2021 22:48:14 -0300 Subject: [PATCH 19/31] Adds Ctrl+P to skip line; Ctrl+Shift+G to run to line. --- source/ide/ide_methods.bas | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/source/ide/ide_methods.bas b/source/ide/ide_methods.bas index a5acb1a4d..c9faede59 100644 --- a/source/ide/ide_methods.bas +++ b/source/ide/ide_methods.bas @@ -3201,6 +3201,10 @@ FUNCTION ide2 (ignore) GOTO ctrlOpen END IF + IF KCONTROL AND UCASE$(K$) = "P" THEN 'Debug -> Toggle Skip Line + GOTO toggleSkipLine + END IF + IF (NOT KSHIFT) AND KCONTROL AND UCASE$(K$) = "R" THEN 'Comment (add ') - R for REMark GOTO ctrlAddComment END IF @@ -5691,7 +5695,7 @@ FUNCTION ide2 (ignore) GOTO EnterDebugMode END IF - IF menu$(m, s) = "#Run To This Line" THEN + IF menu$(m, s) = "#Run To This Line Ctrl+Shift+G" THEN IdeDebugMode = 8 GOTO EnterDebugMode END IF @@ -6749,7 +6753,7 @@ SUB DebugMode CASE 103, 71 'g, G IF _KEYDOWN(100306) OR _KEYDOWN(100305) THEN IF _KEYDOWN(100304) OR _KEYDOWN(100303) THEN - result = idegetlinenumberbox("Run To Line") + result = idegetlinenumberbox("Run To Line", idecy) PCOPY 3, 0: SCREEN , , 3, 0 requestRunToThisLine: IF result > 0 AND result < iden THEN @@ -6763,7 +6767,7 @@ SUB DebugMode dummy = DarkenFGBG(1) END IF ELSE - result = idegetlinenumberbox("Set Next Line") + result = idegetlinenumberbox("Set Next Line", idecy) PCOPY 3, 0: SCREEN , , 3, 0 requestSetNextLine: IF result > 0 AND result < iden THEN @@ -6774,7 +6778,7 @@ SUB DebugMode END IF CASE 112, 80 'p, P IF _KEYDOWN(100306) OR _KEYDOWN(100305) THEN - result = idegetlinenumberbox("Skip Line") + result = idegetlinenumberbox("Skip Line", idecy) PCOPY 3, 0: SCREEN , , 3, 0 requestToggleSkipLine: IF result > 0 AND result <= iden THEN @@ -11774,8 +11778,9 @@ SUB idegotobox ideselect = 0 END SUB -FUNCTION idegetlinenumberbox(title$) - a2$ = "" +FUNCTION idegetlinenumberbox(title$, initialValue&) + a2$ = str2$(initialValue&) + IF a2$ = "0" THEN a2$ = "" v$ = ideinputbox$(title$, "#Line", a2$, "0123456789", 30, 8) IF v$ = "" THEN EXIT FUNCTION @@ -14423,7 +14428,7 @@ SUB IdeMakeContextualMenu menu$(m, i) = "-": i = i + 1 menu$(m, i) = "Set #Next Line Ctrl+G": i = i + 1 menuDesc$(m, i - 1) = "Jumps to the selected line before continuing execution" - menu$(m, i) = "#Run To This Line": i = i + 1 + menu$(m, i) = "#Run To This Line Ctrl+Shift+G": i = i + 1 menuDesc$(m, i - 1) = "Runs until the selected line is reached" menu$(m, i) = "-": i = i + 1 menu$(m, i) = "Toggle #Breakpoint F9": i = i + 1 From 1cad7db996ede0615a3e9b5490effbba8315c775 Mon Sep 17 00:00:00 2001 From: FellippeHeitor Date: Wed, 21 Jul 2021 00:02:15 -0300 Subject: [PATCH 20/31] Prevents adding `goto` re:undefined vWatch labels. --- source/qb64.bas | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/qb64.bas b/source/qb64.bas index f65867a6b..55e7e556f 100644 --- a/source/qb64.bas +++ b/source/qb64.bas @@ -14225,7 +14225,6 @@ SUB vWatchAddLabel (this AS LONG, lastLine AS _BYTE) WHILE this > LEN(vWatchUsedLabels) vWatchUsedLabels = vWatchUsedLabels + SPACE$(1000) WEND - ASC(vWatchUsedLabels, this) = 1 IF firstLineNumberLabelvWatch = 0 THEN firstLineNumberLabelvWatch = this @@ -14237,6 +14236,7 @@ SUB vWatchAddLabel (this AS LONG, lastLine AS _BYTE) END IF IF prevLabel <> this THEN + ASC(vWatchUsedLabels, this) = 1 PRINT #12, "VWATCH_LABEL_" + str2$(this) + ":;" prevLabel = this lastLineNumberLabelvWatch = this From fc95dd4d9ebe41668745841143c703de88d2a2e0 Mon Sep 17 00:00:00 2001 From: FellippeHeitor Date: Wed, 21 Jul 2021 00:13:55 -0300 Subject: [PATCH 21/31] Prevents endless loop with F8 key (start paused). --- source/ide/ide_methods.bas | 1 + 1 file changed, 1 insertion(+) diff --git a/source/ide/ide_methods.bas b/source/ide/ide_methods.bas index c9faede59..a18e216f1 100644 --- a/source/ide/ide_methods.bas +++ b/source/ide/ide_methods.bas @@ -1574,6 +1574,7 @@ FUNCTION ide2 (ignore) END IF IF KB = KEY_F8 OR startPausedPending = -1 THEN + startPausedPending = 0 GOTO startPausedMenuHandler END IF From b9e65ceca540741526d12f18700538d7f1f5c15b Mon Sep 17 00:00:00 2001 From: FellippeHeitor Date: Wed, 21 Jul 2021 08:55:49 -0300 Subject: [PATCH 22/31] Center target line when searching (F3, Ctrl+F3, Alt+F3). --- source/ide/ide_methods.bas | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/ide/ide_methods.bas b/source/ide/ide_methods.bas index a18e216f1..0829fc367 100644 --- a/source/ide/ide_methods.bas +++ b/source/ide/ide_methods.bas @@ -5461,6 +5461,7 @@ FUNCTION ide2 (ignore) IF x THEN ideselect = 1 idecx = x: idecy = y + idecentercurrentline ideselectx1 = x + LEN(s$): ideselecty1 = y found = 1 @@ -8232,6 +8233,7 @@ SUB idefindagain (showFlags AS _BYTE) IF idefindbackwards = 0 THEN idefindbackwards = 1 ELSE idefindbackwards = 0 idefindinvert = 0 END IF + idecentercurrentline EXIT SUB END IF From f09bea827b5b24f5c095dcb226e8ce0c6851715e Mon Sep 17 00:00:00 2001 From: FellippeHeitor Date: Wed, 21 Jul 2021 09:30:48 -0300 Subject: [PATCH 23/31] Refines variable collection code ($DEBUG). --- source/qb64.bas | 99 ++++++++++++++++++++++++++++++++----------------- 1 file changed, 65 insertions(+), 34 deletions(-) diff --git a/source/qb64.bas b/source/qb64.bas index 55e7e556f..3730ffca2 100644 --- a/source/qb64.bas +++ b/source/qb64.bas @@ -5282,20 +5282,7 @@ DO layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ IF vWatchOn = 1 THEN - totalLocalVariables = 0 - localVariablesList$ = "" - FOR i = 1 TO totalVariablesCreated - IF usedVariableList(i).scope = subfuncn THEN - totalLocalVariables = totalLocalVariables + 1 - localVariablesList$ = localVariablesList$ + "vwatch_local_vars[" + str2$(totalLocalVariables - 1) + "] = &" + usedVariableList(i).cname + ";" + CRLF - END IF - NEXT - IF totalLocalVariables > 0 THEN - PRINT #13, "void *vwatch_local_vars["; totalLocalVariables; "];" - PRINT #13, localVariablesList$ - ELSE - PRINT #13, "void *vwatch_local_vars[0];" - END IF + vWatchVariable "", 1 END IF staticarraylist = "": staticarraylistn = 0 'remove previously listed arrays @@ -11722,20 +11709,7 @@ END IF CLOSE #fh IF vWatchOn = 1 THEN - totalLocalVariables = 0 - localVariablesList$ = "" - FOR i = 1 TO totalVariablesCreated - IF usedVariableList(i).scope = 0 THEN - totalLocalVariables = totalLocalVariables + 1 - localVariablesList$ = localVariablesList$ + "vwatch_local_vars[" + str2$(totalLocalVariables - 1) + "] = &" + usedVariableList(i).cname + ";" + CRLF - END IF - NEXT - IF totalLocalVariables > 0 THEN - PRINT #13, "void *vwatch_local_vars["; totalLocalVariables; "];" - PRINT #13, localVariablesList$ - ELSE - PRINT #13, "void *vwatch_local_vars[0];" - END IF + vWatchVariable "", 1 END IF @@ -13714,6 +13688,7 @@ FUNCTION allocarray (n2$, elements$, elementsize, udt) 'Begin creation of array descriptor (if array has not been defined yet) IF arraydesc = 0 THEN PRINT #defdatahandle, "ptrszint *" + n$ + "=NULL;" + vWatchVariable n$, 0 PRINT #13, "if (!" + n$ + "){" PRINT #13, n$ + "=(ptrszint*)mem_static_malloc(" + str2(4 * nume + 4 + 1) + "*ptrsz);" '+1 is for the lock 'create _MEM lock @@ -14218,6 +14193,56 @@ SUB clearid id = cleariddata END SUB +SUB vWatchVariable (this$, action AS _BYTE) + STATIC totalLocalVariables AS LONG, localVariablesList$ + STATIC totalMainModuleVariables AS LONG, mainModuleVariablesList$ + STATIC exclusions$ + + IF LEN(exclusions$) = 0 THEN + exclusions$ = "@__LONG_VWATCH_LINENUMBER@__LONG_VWATCH_SUBLEVEL@__LONG_VWATCH_GOTO@" + _ + "@__STRING_VWATCH_SUBNAME@__STRING_VWATCH_CALLSTACK@__ARRAY_BYTE_VWATCH_BREAKPOINTS" + _ + "@__ARRAY_BYTE_VWATCH_SKIPLINES@" + END IF + + SELECT CASE action + CASE 0 'add + IF INSTR(exclusions$, "@" + this$ + "@") > 0 OR LEFT$(this$, 12) = "_SUB_VWATCH_" THEN + EXIT SUB + END IF + + IF subfunc = "" THEN + totalMainModuleVariables = totalMainModuleVariables + 1 + mainModuleVariablesList$ = mainModuleVariablesList$ + "vwatch_local_vars[" + str2$(totalMainModuleVariables - 1) + "] = &" + this$ + ";" + CRLF + ELSE + totalLocalVariables = totalLocalVariables + 1 + localVariablesList$ = localVariablesList$ + "vwatch_local_vars[" + str2$(totalLocalVariables - 1) + "] = &" + this$ + ";" + CRLF + END IF + manageVariableList RTRIM$(id.cn), this$, 0 + CASE 1 'dump to data[].txt & reset + IF subfunc = "" THEN + IF totalMainModuleVariables > 0 THEN + PRINT #13, "void *vwatch_local_vars["; totalMainModuleVariables; "];" + PRINT #13, mainModuleVariablesList$ + ELSE + PRINT #13, "void *vwatch_local_vars[0];" + END IF + + mainModuleVariablesList$ = "" + totalMainModuleVariables = 0 + ELSE + IF totalLocalVariables > 0 THEN + PRINT #13, "void *vwatch_local_vars["; totalLocalVariables; "];" + PRINT #13, localVariablesList$ + ELSE + PRINT #13, "void *vwatch_local_vars[0];" + END IF + + localVariablesList$ = "" + totalLocalVariables = 0 + END IF + END SELECT +END SUB + SUB vWatchAddLabel (this AS LONG, lastLine AS _BYTE) STATIC prevLabel AS LONG, prevSkip AS LONG @@ -14429,6 +14454,7 @@ FUNCTION dim2 (varname$, typ2$, method, elements$) clearid id.n = cvarname$ id.t = UDTTYPE + i + vWatchVariable n$, 0 IF cmemlist(idn + 1) THEN id.t = id.t + ISINCONVENTIONALMEMORY IF f THEN @@ -14595,6 +14621,7 @@ FUNCTION dim2 (varname$, typ2$, method, elements$) clearid id.n = cvarname$ id.t = STRINGTYPE + ISFIXEDLENGTH + vWatchVariable n$, 0 IF cmemlist(idn + 1) THEN id.t = id.t + ISINCONVENTIONALMEMORY IF f THEN PRINT #13, "if(" + n$ + "==NULL){" @@ -14692,6 +14719,7 @@ FUNCTION dim2 (varname$, typ2$, method, elements$) clearid id.n = cvarname$ id.t = STRINGTYPE + vWatchVariable n$, 0 IF cmemlist(idn + 1) THEN IF f THEN PRINT #defdatahandle, "qbs *" + n$ + "=NULL;" IF f THEN PRINT #13, "if (!" + n$ + ")" + n$ + "=qbs_new_cmem(0,0);" @@ -14794,6 +14822,7 @@ FUNCTION dim2 (varname$, typ2$, method, elements$) END IF 'standard bit-length variable n$ = scope2$ + n$ + vWatchVariable n$, 0 PRINT #defdatahandle, ct$ + " *" + n$ + "=NULL;" PRINT #13, "if(" + n$ + "==NULL){" PRINT #13, "cmem_sp-=4;" @@ -14875,6 +14904,7 @@ FUNCTION dim2 (varname$, typ2$, method, elements$) n$ = scope2$ + n$ clearid id.t = BYTETYPE: IF unsgn THEN id.t = id.t + ISUNSIGNED + vWatchVariable n$, 0 IF f = 1 THEN PRINT #defdatahandle, ct$ + " *" + n$ + "=NULL;" IF f = 1 THEN PRINT #13, "if(" + n$ + "==NULL){" IF cmemlist(idn + 1) THEN @@ -14957,6 +14987,7 @@ FUNCTION dim2 (varname$, typ2$, method, elements$) n$ = scope2$ + n$ clearid id.t = INTEGERTYPE: IF unsgn THEN id.t = id.t + ISUNSIGNED + vWatchVariable n$, 0 IF f = 1 THEN PRINT #defdatahandle, ct$ + " *" + n$ + "=NULL;" IF f = 1 THEN PRINT #13, "if(" + n$ + "==NULL){" IF cmemlist(idn + 1) THEN @@ -15044,6 +15075,7 @@ FUNCTION dim2 (varname$, typ2$, method, elements$) n$ = scope2$ + n$ clearid id.t = OFFSETTYPE: IF unsgn THEN id.t = id.t + ISUNSIGNED + vWatchVariable n$, 0 IF f = 1 THEN PRINT #defdatahandle, ct$ + " *" + n$ + "=NULL;" IF f = 1 THEN PRINT #13, "if(" + n$ + "==NULL){" IF cmemlist(idn + 1) THEN @@ -15128,6 +15160,7 @@ FUNCTION dim2 (varname$, typ2$, method, elements$) n$ = scope2$ + n$ clearid id.t = LONGTYPE: IF unsgn THEN id.t = id.t + ISUNSIGNED + vWatchVariable n$, 0 IF f = 1 THEN PRINT #defdatahandle, ct$ + " *" + n$ + "=NULL;" IF f = 1 THEN PRINT #13, "if(" + n$ + "==NULL){" IF cmemlist(idn + 1) THEN @@ -15212,6 +15245,7 @@ FUNCTION dim2 (varname$, typ2$, method, elements$) n$ = scope2$ + n$ clearid id.t = INTEGER64TYPE: IF unsgn THEN id.t = id.t + ISUNSIGNED + vWatchVariable n$, 0 IF f = 1 THEN PRINT #defdatahandle, ct$ + " *" + n$ + "=NULL;" IF f = 1 THEN PRINT #13, "if(" + n$ + "==NULL){" IF cmemlist(idn + 1) THEN @@ -15296,6 +15330,7 @@ FUNCTION dim2 (varname$, typ2$, method, elements$) n$ = scope2$ + n$ clearid id.t = SINGLETYPE + vWatchVariable n$, 0 IF f = 1 THEN PRINT #defdatahandle, ct$ + " *" + n$ + "=NULL;" IF f = 1 THEN PRINT #13, "if(" + n$ + "==NULL){" IF cmemlist(idn + 1) THEN @@ -15378,6 +15413,7 @@ FUNCTION dim2 (varname$, typ2$, method, elements$) n$ = scope2$ + n$ clearid id.t = DOUBLETYPE + vWatchVariable n$, 0 IF f = 1 THEN PRINT #defdatahandle, ct$ + " *" + n$ + "=NULL;" IF f = 1 THEN PRINT #13, "if(" + n$ + "==NULL){" IF cmemlist(idn + 1) THEN @@ -15460,6 +15496,7 @@ FUNCTION dim2 (varname$, typ2$, method, elements$) n$ = scope2$ + n$ clearid id.t = FLOATTYPE + vWatchVariable n$, 0 IF f THEN PRINT #defdatahandle, ct$ + " *" + n$ + "=NULL;" IF f THEN PRINT #13, "if(" + n$ + "==NULL){" IF cmemlist(idn + 1) THEN @@ -15488,9 +15525,6 @@ FUNCTION dim2 (varname$, typ2$, method, elements$) Give_Error "Unknown type": EXIT FUNCTION dim2exitfunc: - IF bypassNextVariable = 0 THEN - manageVariableList cvarname$, n$, 0 - END IF bypassNextVariable = 0 IF dimsfarray THEN @@ -25886,9 +25920,6 @@ SUB manageVariableList (name$, __cname$, action AS _BYTE) CASE ELSE 'find and mark as used IF found THEN usedVariableList(i).used = -1 - ELSE - manageVariableList name$, __cname$, 0 - manageVariableList name$, __cname$, 12 END IF END SELECT END SUB From dd686b4071994818fec939a598d3dc03478b824c Mon Sep 17 00:00:00 2001 From: FellippeHeitor Date: Wed, 21 Jul 2021 09:48:52 -0300 Subject: [PATCH 24/31] Store variable creation data after `regid` is called. --- source/qb64.bas | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/source/qb64.bas b/source/qb64.bas index 3730ffca2..5bc3b8f9e 100644 --- a/source/qb64.bas +++ b/source/qb64.bas @@ -13688,7 +13688,6 @@ FUNCTION allocarray (n2$, elements$, elementsize, udt) 'Begin creation of array descriptor (if array has not been defined yet) IF arraydesc = 0 THEN PRINT #defdatahandle, "ptrszint *" + n$ + "=NULL;" - vWatchVariable n$, 0 PRINT #13, "if (!" + n$ + "){" PRINT #13, n$ + "=(ptrszint*)mem_static_malloc(" + str2(4 * nume + 4 + 1) + "*ptrsz);" '+1 is for the lock 'create _MEM lock @@ -14440,6 +14439,7 @@ FUNCTION dim2 (varname$, typ2$, method, elements$) id.arrayelements = nume id.callname = n$ regid + vWatchVariable n$, 0 IF Error_Happened THEN EXIT FUNCTION GOTO dim2exitfunc END IF @@ -14454,7 +14454,6 @@ FUNCTION dim2 (varname$, typ2$, method, elements$) clearid id.n = cvarname$ id.t = UDTTYPE + i - vWatchVariable n$, 0 IF cmemlist(idn + 1) THEN id.t = id.t + ISINCONVENTIONALMEMORY IF f THEN @@ -14478,6 +14477,7 @@ FUNCTION dim2 (varname$, typ2$, method, elements$) END IF END IF regid + vWatchVariable n$, 0 IF Error_Happened THEN EXIT FUNCTION GOTO dim2exitfunc END IF @@ -14621,7 +14621,6 @@ FUNCTION dim2 (varname$, typ2$, method, elements$) clearid id.n = cvarname$ id.t = STRINGTYPE + ISFIXEDLENGTH - vWatchVariable n$, 0 IF cmemlist(idn + 1) THEN id.t = id.t + ISINCONVENTIONALMEMORY IF f THEN PRINT #13, "if(" + n$ + "==NULL){" @@ -14645,6 +14644,7 @@ FUNCTION dim2 (varname$, typ2$, method, elements$) id.musthave = "$" + str2(bytes) END IF regid + vWatchVariable n$, 0 IF Error_Happened THEN EXIT FUNCTION GOTO dim2exitfunc END IF @@ -14719,7 +14719,6 @@ FUNCTION dim2 (varname$, typ2$, method, elements$) clearid id.n = cvarname$ id.t = STRINGTYPE - vWatchVariable n$, 0 IF cmemlist(idn + 1) THEN IF f THEN PRINT #defdatahandle, "qbs *" + n$ + "=NULL;" IF f THEN PRINT #13, "if (!" + n$ + ")" + n$ + "=qbs_new_cmem(0,0);" @@ -14736,6 +14735,7 @@ FUNCTION dim2 (varname$, typ2$, method, elements$) id.musthave = "$" END IF regid + vWatchVariable n$, 0 IF Error_Happened THEN EXIT FUNCTION GOTO dim2exitfunc END IF @@ -14822,7 +14822,6 @@ FUNCTION dim2 (varname$, typ2$, method, elements$) END IF 'standard bit-length variable n$ = scope2$ + n$ - vWatchVariable n$, 0 PRINT #defdatahandle, ct$ + " *" + n$ + "=NULL;" PRINT #13, "if(" + n$ + "==NULL){" PRINT #13, "cmem_sp-=4;" @@ -14840,6 +14839,7 @@ FUNCTION dim2 (varname$, typ2$, method, elements$) IF unsgn THEN id.musthave = "~`" + str2(bits) ELSE id.musthave = "`" + str2(bits) END IF regid + vWatchVariable n$, 0 IF Error_Happened THEN EXIT FUNCTION GOTO dim2exitfunc END IF @@ -14904,7 +14904,6 @@ FUNCTION dim2 (varname$, typ2$, method, elements$) n$ = scope2$ + n$ clearid id.t = BYTETYPE: IF unsgn THEN id.t = id.t + ISUNSIGNED - vWatchVariable n$, 0 IF f = 1 THEN PRINT #defdatahandle, ct$ + " *" + n$ + "=NULL;" IF f = 1 THEN PRINT #13, "if(" + n$ + "==NULL){" IF cmemlist(idn + 1) THEN @@ -14926,6 +14925,7 @@ FUNCTION dim2 (varname$, typ2$, method, elements$) IF unsgn THEN id.musthave = "~%%" ELSE id.musthave = "%%" END IF regid + vWatchVariable n$, 0 IF Error_Happened THEN EXIT FUNCTION GOTO dim2exitfunc END IF @@ -14987,7 +14987,6 @@ FUNCTION dim2 (varname$, typ2$, method, elements$) n$ = scope2$ + n$ clearid id.t = INTEGERTYPE: IF unsgn THEN id.t = id.t + ISUNSIGNED - vWatchVariable n$, 0 IF f = 1 THEN PRINT #defdatahandle, ct$ + " *" + n$ + "=NULL;" IF f = 1 THEN PRINT #13, "if(" + n$ + "==NULL){" IF cmemlist(idn + 1) THEN @@ -15009,6 +15008,7 @@ FUNCTION dim2 (varname$, typ2$, method, elements$) IF unsgn THEN id.musthave = "~%" ELSE id.musthave = "%" END IF regid + vWatchVariable n$, 0 IF Error_Happened THEN EXIT FUNCTION GOTO dim2exitfunc END IF @@ -15075,7 +15075,6 @@ FUNCTION dim2 (varname$, typ2$, method, elements$) n$ = scope2$ + n$ clearid id.t = OFFSETTYPE: IF unsgn THEN id.t = id.t + ISUNSIGNED - vWatchVariable n$, 0 IF f = 1 THEN PRINT #defdatahandle, ct$ + " *" + n$ + "=NULL;" IF f = 1 THEN PRINT #13, "if(" + n$ + "==NULL){" IF cmemlist(idn + 1) THEN @@ -15097,6 +15096,7 @@ FUNCTION dim2 (varname$, typ2$, method, elements$) IF unsgn THEN id.musthave = "~%&" ELSE id.musthave = "%&" END IF regid + vWatchVariable n$, 0 IF Error_Happened THEN EXIT FUNCTION GOTO dim2exitfunc END IF @@ -15160,7 +15160,6 @@ FUNCTION dim2 (varname$, typ2$, method, elements$) n$ = scope2$ + n$ clearid id.t = LONGTYPE: IF unsgn THEN id.t = id.t + ISUNSIGNED - vWatchVariable n$, 0 IF f = 1 THEN PRINT #defdatahandle, ct$ + " *" + n$ + "=NULL;" IF f = 1 THEN PRINT #13, "if(" + n$ + "==NULL){" IF cmemlist(idn + 1) THEN @@ -15182,6 +15181,7 @@ FUNCTION dim2 (varname$, typ2$, method, elements$) IF unsgn THEN id.musthave = "~&" ELSE id.musthave = "&" END IF regid + vWatchVariable n$, 0 IF Error_Happened THEN EXIT FUNCTION GOTO dim2exitfunc END IF @@ -15245,7 +15245,6 @@ FUNCTION dim2 (varname$, typ2$, method, elements$) n$ = scope2$ + n$ clearid id.t = INTEGER64TYPE: IF unsgn THEN id.t = id.t + ISUNSIGNED - vWatchVariable n$, 0 IF f = 1 THEN PRINT #defdatahandle, ct$ + " *" + n$ + "=NULL;" IF f = 1 THEN PRINT #13, "if(" + n$ + "==NULL){" IF cmemlist(idn + 1) THEN @@ -15267,6 +15266,7 @@ FUNCTION dim2 (varname$, typ2$, method, elements$) IF unsgn THEN id.musthave = "~&&" ELSE id.musthave = "&&" END IF regid + vWatchVariable n$, 0 IF Error_Happened THEN EXIT FUNCTION GOTO dim2exitfunc END IF @@ -15330,7 +15330,6 @@ FUNCTION dim2 (varname$, typ2$, method, elements$) n$ = scope2$ + n$ clearid id.t = SINGLETYPE - vWatchVariable n$, 0 IF f = 1 THEN PRINT #defdatahandle, ct$ + " *" + n$ + "=NULL;" IF f = 1 THEN PRINT #13, "if(" + n$ + "==NULL){" IF cmemlist(idn + 1) THEN @@ -15352,6 +15351,7 @@ FUNCTION dim2 (varname$, typ2$, method, elements$) id.musthave = "!" END IF regid + vWatchVariable n$, 0 IF Error_Happened THEN EXIT FUNCTION GOTO dim2exitfunc END IF @@ -15413,7 +15413,6 @@ FUNCTION dim2 (varname$, typ2$, method, elements$) n$ = scope2$ + n$ clearid id.t = DOUBLETYPE - vWatchVariable n$, 0 IF f = 1 THEN PRINT #defdatahandle, ct$ + " *" + n$ + "=NULL;" IF f = 1 THEN PRINT #13, "if(" + n$ + "==NULL){" IF cmemlist(idn + 1) THEN @@ -15435,6 +15434,7 @@ FUNCTION dim2 (varname$, typ2$, method, elements$) id.musthave = "#" END IF regid + vWatchVariable n$, 0 IF Error_Happened THEN EXIT FUNCTION GOTO dim2exitfunc END IF @@ -15496,7 +15496,6 @@ FUNCTION dim2 (varname$, typ2$, method, elements$) n$ = scope2$ + n$ clearid id.t = FLOATTYPE - vWatchVariable n$, 0 IF f THEN PRINT #defdatahandle, ct$ + " *" + n$ + "=NULL;" IF f THEN PRINT #13, "if(" + n$ + "==NULL){" IF cmemlist(idn + 1) THEN @@ -15518,6 +15517,7 @@ FUNCTION dim2 (varname$, typ2$, method, elements$) id.musthave = "##" END IF regid + vWatchVariable n$, 0 IF Error_Happened THEN EXIT FUNCTION GOTO dim2exitfunc END IF From e3d65b355911d27401e7a0ecdac577fdfba9eb77 Mon Sep 17 00:00:00 2001 From: FellippeHeitor Date: Wed, 21 Jul 2021 12:41:41 -0300 Subject: [PATCH 25/31] Centers target line with warning. --- source/ide/ide_methods.bas | 2 ++ 1 file changed, 2 insertions(+) diff --git a/source/ide/ide_methods.bas b/source/ide/ide_methods.bas index 0829fc367..1a5ba3e67 100644 --- a/source/ide/ide_methods.bas +++ b/source/ide/ide_methods.bas @@ -10653,6 +10653,7 @@ FUNCTION idewarningbox idegotobox_LastLineNum = warningLines(y) AddQuickNavHistory idecy = idegotobox_LastLineNum + idecentercurrentline IF warningIncLines(y) > 0 THEN warningInInclude = idecy warningInIncludeLine = warningIncLines(y) @@ -11778,6 +11779,7 @@ SUB idegotobox idegotobox_LastLineNum = v& AddQuickNavHistory idecy = v& + idecentercurrentline ideselect = 0 END SUB From f286e6b1d9a974a0afb4b74b5ad6486edc1ac830 Mon Sep 17 00:00:00 2001 From: FellippeHeitor Date: Wed, 21 Jul 2021 14:22:37 -0300 Subject: [PATCH 26/31] Removes unused variables in IDE code. --- source/ide/ide_methods.bas | 1 - source/ide/wiki/wiki_methods.bas | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/source/ide/ide_methods.bas b/source/ide/ide_methods.bas index 1a5ba3e67..075d8cb96 100644 --- a/source/ide/ide_methods.bas +++ b/source/ide/ide_methods.bas @@ -14902,7 +14902,6 @@ SUB ideupdatehelpbox i = 0 w2 = LEN(titlestr$) + 4 IF w < w2 THEN w = w2 - IF w < buttonsLen THEN w = buttonsLen IF w > idewx - 4 THEN w = idewx - 4 idepar p, 60, 6, "Update Help" diff --git a/source/ide/wiki/wiki_methods.bas b/source/ide/wiki/wiki_methods.bas index 6244ae001..2cc3cab78 100644 --- a/source/ide/wiki/wiki_methods.bas +++ b/source/ide/wiki/wiki_methods.bas @@ -174,7 +174,7 @@ SUB Help_NewLine IF Help_Pos > help_w THEN help_w = Help_Pos Help_Txt_Len = Help_Txt_Len + 1: ASC(Help_Txt$, Help_Txt_Len) = 13 - Help_Txt_Len = Help_Txt_Len + 1: ASC(Help_Txt$, Help_Txt_Len) = col + Help_BG_Col * 16 + Help_Txt_Len = Help_Txt_Len + 1: ASC(Help_Txt$, Help_Txt_Len) = Help_BG_Col * 16 Help_Txt_Len = Help_Txt_Len + 1: ASC(Help_Txt$, Help_Txt_Len) = 0 Help_Txt_Len = Help_Txt_Len + 1: ASC(Help_Txt$, Help_Txt_Len) = 0 From 46822028f953d935dbb56d43e24a808b49ad8629 Mon Sep 17 00:00:00 2001 From: FellippeHeitor Date: Wed, 21 Jul 2021 14:23:21 -0300 Subject: [PATCH 27/31] Fixes typos in comments (:facepalm:). --- source/qb64.bas | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/qb64.bas b/source/qb64.bas index 5bc3b8f9e..aef5a47c8 100644 --- a/source/qb64.bas +++ b/source/qb64.bas @@ -14055,7 +14055,7 @@ END FUNCTION FUNCTION arrayreference$ (indexes$, typ) arrayprocessinghappened = 1 - '*returns an array reference: idnumber CHR$(179) index$ + '*returns an array reference: idnumber | index$ '*does not take into consideration the type of the array '*expects array id to be passed in the global id structure @@ -15615,7 +15615,7 @@ FUNCTION udtreference$ (o$, a$, typ AS LONG) GOTO udtfindelenext END IF - 'Change e reference to u CHR$(179) 0 reference? + 'Change e reference to u | 0 reference? IF udtetype(E) AND ISUDT THEN u = udtetype(E) AND 511 E = 0 @@ -18451,7 +18451,7 @@ FUNCTION findid& (n2$) ''' END IF 'safeguard END IF - 'optomizations for later comparisons + 'optimizations for later comparisons insf$ = subfunc + SPACE$(256 - LEN(subfunc)) secondarg$ = secondarg$ + SPACE$(256 - LEN(secondarg$)) IF LEN(sc$) THEN scpassed = 1: sc$ = sc$ + SPACE$(8 - LEN(sc$)) ELSE scpassed = 0 From b1ddfd06c70b1f5fc2b800878b15192f1c1fde3c Mon Sep 17 00:00:00 2001 From: FellippeHeitor Date: Wed, 21 Jul 2021 14:24:35 -0300 Subject: [PATCH 28/31] `typ` is undefined in FUNCTION `typ2ctyp$`; uses `t` instead. Could be causing weird issues; might cause weird issues. --- source/qb64.bas | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/qb64.bas b/source/qb64.bas index aef5a47c8..42cc3af22 100644 --- a/source/qb64.bas +++ b/source/qb64.bas @@ -22371,7 +22371,7 @@ FUNCTION typ2ctyp$ (t AS LONG, tstr AS STRING) IF b = 16 THEN ctyp$ = "int16" IF b = 32 THEN ctyp$ = "int32" IF b = 64 THEN ctyp$ = "int64" - IF typ AND ISOFFSET THEN ctyp$ = "ptrszint" + IF t AND ISOFFSET THEN ctyp$ = "ptrszint" IF (t AND ISUNSIGNED) THEN ctyp$ = "u" + ctyp$ END IF IF t AND ISOFFSET THEN From 0724910a2e137724782aca7ee2226e759e4d40b3 Mon Sep 17 00:00:00 2001 From: FellippeHeitor Date: Wed, 21 Jul 2021 14:25:21 -0300 Subject: [PATCH 29/31] Improves detection of used variables; Arrays still to be worked on. --- source/qb64.bas | 55 +++++++++++++++++-------------------------------- 1 file changed, 19 insertions(+), 36 deletions(-) diff --git a/source/qb64.bas b/source/qb64.bas index 42cc3af22..b68594006 100644 --- a/source/qb64.bas +++ b/source/qb64.bas @@ -18555,33 +18555,6 @@ FUNCTION findid& (n2$) id = ids(i) t = id.t - IF id.subfunc = 0 THEN - IF t = 0 THEN - t = id.arraytype - IF t AND ISUDT THEN - manageVariableList "", scope$ + "ARRAY_UDT_" + RTRIM$(id.n), 1 - ELSE - n$ = id2shorttypename$ - IF LEFT$(n$, 1) = "_" THEN - manageVariableList "", scope$ + "ARRAY" + n$ + "_" + RTRIM$(id.n), 2 - ELSE - manageVariableList "", scope$ + "ARRAY_" + n$ + "_" + RTRIM$(id.n), 3 - END IF - END IF - ELSE - IF t AND ISUDT THEN - manageVariableList "", scope$ + "UDT_" + RTRIM$(id.n), 4 - ELSE - n$ = id2shorttypename$ - IF LEFT$(n$, 1) = "_" THEN - 'manageVariableList "", scope$ + MID$(n$, 2) + "_" + RTRIM$(id.n), 5 - ELSE - manageVariableList "", scope$ + n$ + "_" + RTRIM$(id.n), 6 - END IF - END IF - END IF - END IF - currentid = i EXIT FUNCTION @@ -20906,6 +20879,7 @@ FUNCTION refer$ (a2$, typ AS LONG, method AS LONG) n$ = "UDT_" + RTRIM$(id.n) IF id.t = 0 THEN n$ = "ARRAY_" + n$ n$ = scope$ + n$ + manageVariableList "", n$, 1 refer$ = n$ EXIT FUNCTION END IF @@ -20938,6 +20912,7 @@ FUNCTION refer$ (a2$, typ AS LONG, method AS LONG) END IF 'print "REFER:"+r$+","+str2$(typ) + manageVariableList "", r$, 2 refer$ = r$ EXIT FUNCTION END IF @@ -20949,6 +20924,7 @@ FUNCTION refer$ (a2$, typ AS LONG, method AS LONG) n$ = RTRIM$(id.callname) IF method = 1 THEN refer$ = n$ + manageVariableList "", n$, 3 typ = typbak EXIT FUNCTION END IF @@ -20962,6 +20938,7 @@ FUNCTION refer$ (a2$, typ AS LONG, method AS LONG) r$ = "((qbs*)(((uint64*)(" + n$ + "[0]))[" + a$ + "]))" END IF stringprocessinghappened = 1 + manageVariableList "", r$, 4 refer$ = r$ EXIT FUNCTION END IF @@ -20973,6 +20950,7 @@ FUNCTION refer$ (a2$, typ AS LONG, method AS LONG) r$ = r$ + "(" + str2(typ AND 511) + "," r$ = r$ + "(uint8*)(" + n$ + "[0])" + "," r$ = r$ + a$ + ")" + manageVariableList "", r$, 5 refer$ = r$ EXIT FUNCTION ELSE @@ -20999,6 +20977,7 @@ FUNCTION refer$ (a2$, typ AS LONG, method AS LONG) END IF IF t$ = "" THEN Give_Error "Cannot find C type to return array data": EXIT FUNCTION r$ = "((" + t$ + "*)(" + n$ + "[0]))[" + a$ + "]" + manageVariableList "", r$, 6 refer$ = r$ EXIT FUNCTION END IF 'array @@ -21046,6 +21025,7 @@ FUNCTION refer$ (a2$, typ AS LONG, method AS LONG) IF LEFT$(r$, 1) = "*" THEN r$ = RIGHT$(r$, LEN(r$) - 1) typ = typbak END IF + manageVariableList "", r$, 7 refer$ = r$ EXIT FUNCTION END IF 'variable @@ -22114,10 +22094,11 @@ SUB setrefer (a2$, typ2 AS LONG, e2$, method AS LONG) 'we have now established we have 2 pointers to similar data types! 'ASSUME BYTE TYPE!!! src$ = "((char*)" + scope$ + n2$ + ")+(" + o2$ + ")" + manageVariableList "", scope$ + n2$, 8 directudt: IF u <> u2 OR e2 <> 0 THEN Give_Error "Expected = similar user defined type": EXIT SUB dst$ = "((char*)" + lhsscope$ + n$ + ")+(" + o$ + ")" - + manageVariableList "", lhsscope$ + n$, 9 copy_full_udt dst$, src$, 12, 0, u 'print "setFULLUDTrefer!" @@ -22154,7 +22135,7 @@ SUB setrefer (a2$, typ2 AS LONG, e2$, method AS LONG) 'print "setUDTrefer:"+r$,e$ tlayout$ = tl$ IF LEFT$(r$, 1) = "*" THEN r$ = MID$(r$, 2) - manageVariableList "", scope$ + n$, 7 + manageVariableList "", r$, 10 EXIT SUB END IF @@ -22189,7 +22170,7 @@ SUB setrefer (a2$, typ2 AS LONG, e2$, method AS LONG) PRINT #12, cleanupstringprocessingcall$ + "0);" tlayout$ = tl$ IF LEFT$(r$, 1) = "*" THEN r$ = MID$(r$, 2) - manageVariableList "", r$, 8 + manageVariableList "", r$, 11 EXIT SUB END IF @@ -22236,6 +22217,7 @@ SUB setrefer (a2$, typ2 AS LONG, e2$, method AS LONG) IF Error_Happened THEN EXIT SUB ELSE l$ = "if (!new_error) ((" + t$ + "*)(" + n$ + "[0]))[tmp_long]=" + e$ + ";" + manageVariableList "", e$, 12 END IF PRINT #12, l$ @@ -22265,7 +22247,7 @@ SUB setrefer (a2$, typ2 AS LONG, e2$, method AS LONG) IF arrayprocessinghappened THEN arrayprocessinghappened = 0 tlayout$ = tl$ IF LEFT$(r$, 1) = "*" THEN r$ = MID$(r$, 2) - manageVariableList "", r$, 9 + manageVariableList "", r$, 13 EXIT SUB END IF @@ -22297,7 +22279,7 @@ SUB setrefer (a2$, typ2 AS LONG, e2$, method AS LONG) IF arrayprocessinghappened THEN arrayprocessinghappened = 0 tlayout$ = tl$ IF LEFT$(r$, 1) = "*" THEN r$ = MID$(r$, 2) - manageVariableList "", r$, 10 + manageVariableList "", r$, 14 EXIT SUB END IF @@ -22326,8 +22308,7 @@ SUB setrefer (a2$, typ2 AS LONG, e2$, method AS LONG) tlayout$ = tl$ IF LEFT$(r$, 1) = "*" THEN r$ = MID$(r$, 2) - manageVariableList "", r$, 11 - + manageVariableList "", r$, 15 EXIT SUB END IF 'variable @@ -25878,8 +25859,9 @@ SUB dump_udts CLOSE #f END SUB -SUB manageVariableList (name$, __cname$, action AS _BYTE) - DIM findItem AS LONG, cname$, i AS LONG +SUB manageVariableList (__name$, __cname$, action AS _BYTE) + DIM findItem AS LONG, cname$, i AS LONG, name$ + name$ = __name$ cname$ = __cname$ IF LEN(cname$) = 0 THEN EXIT SUB @@ -25914,6 +25896,7 @@ SUB manageVariableList (name$, __cname$, action AS _BYTE) END IF usedVariableList(i).scope = subfuncn usedVariableList(i).cname = cname$ + IF LEN(RTRIM$(id.musthave)) > 0 THEN name$ = name$ + RTRIM$(id.musthave) usedVariableList(i).name = name$ totalVariablesCreated = totalVariablesCreated + 1 END IF From abe46ca87e58e110495dbef1c79ca64feb6ee3dc Mon Sep 17 00:00:00 2001 From: FellippeHeitor Date: Wed, 21 Jul 2021 15:04:27 -0300 Subject: [PATCH 30/31] There's a blk of code that never runs in `FUNCTION isvalidvariable` This is a commit just to show it's known that it's there. And that I was a coward to remove it. Maybe n was supposed to be LEN(a$)? Well, it's not. That breaks compilation. I'll just leave it there. --- source/qb64.bas | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/qb64.bas b/source/qb64.bas index b68594006..ca0308979 100644 --- a/source/qb64.bas +++ b/source/qb64.bas @@ -19755,7 +19755,7 @@ FUNCTION isvalidvariable (a$) NEXT isvalidvariable = 1 - IF i > n THEN EXIT FUNCTION + IF i > n THEN EXIT FUNCTION 'i is always greater than n because n is undefined here. Why didn't I remove this line and the ones below it, which will never run? Cause I'm a coward. F.h. e$ = RIGHT$(a$, LEN(a$) - i - 1) IF e$ = "%%" OR e$ = "~%%" THEN EXIT FUNCTION IF e$ = "%" OR e$ = "~%" THEN EXIT FUNCTION From 77daecccbc12cc7df6dc4894b9e8b0697a5162f6 Mon Sep 17 00:00:00 2001 From: FellippeHeitor Date: Wed, 21 Jul 2021 18:07:21 -0300 Subject: [PATCH 31/31] Gets all used variables to be properly stored. This time it looks like it's been nailed. --- source/qb64.bas | 21 ++++++--------------- 1 file changed, 6 insertions(+), 15 deletions(-) diff --git a/source/qb64.bas b/source/qb64.bas index ca0308979..97eea292f 100644 --- a/source/qb64.bas +++ b/source/qb64.bas @@ -27,6 +27,7 @@ REDIM SHARED PP_TypeMod(0) AS STRING, PP_ConvertedMod(0) AS STRING 'Prepass Name Set_OrderOfOperations DIM SHARED vWatchOn, vWatchRecompileAttempts, vWatchDesiredState, vWatchErrorCall$ +DIM SHARED vWatchNewVariable$ vWatchErrorCall$ = "if (stop_program) {*__LONG_VWATCH_LINENUMBER=0; SUB_VWATCH((ptrszint*)vwatch_local_vars);};if(new_error){bkp_new_error=new_error;new_error=0;*__LONG_VWATCH_LINENUMBER=-1; SUB_VWATCH((ptrszint*)vwatch_local_vars);new_error=bkp_new_error;};" DIM SHARED qb64prefix_set_recompileAttempts, qb64prefix_set_desiredState @@ -7522,6 +7523,7 @@ DO IF optionexplicit THEN a$ = "Variable '" + n$ + "' (" + symbol2fulltypename$(typ$) + ") not defined": GOTO errmes bypassNextVariable = -1 retval = dim2(n$, typ$, method, "") + manageVariableList "", vWatchNewVariable$, 2 IF Error_Happened THEN GOTO errmes 'note: variable created! @@ -14209,6 +14211,7 @@ SUB vWatchVariable (this$, action AS _BYTE) EXIT SUB END IF + vWatchNewVariable$ = this$ IF subfunc = "" THEN totalMainModuleVariables = totalMainModuleVariables + 1 mainModuleVariablesList$ = mainModuleVariablesList$ + "vwatch_local_vars[" + str2$(totalMainModuleVariables - 1) + "] = &" + this$ + ";" + CRLF @@ -16115,6 +16118,7 @@ FUNCTION evaluate$ (a2$, typ AS LONG) IF optionexplicit THEN Give_Error "Variable '" + x$ + "' (" + symbol2fulltypename$(typ$) + ") not defined": EXIT FUNCTION bypassNextVariable = -1 retval = dim2(x$, typ$, 1, "") + manageVariableList "", vWatchNewVariable$, 3 IF Error_Happened THEN EXIT FUNCTION simplevarfound: @@ -18555,6 +18559,8 @@ FUNCTION findid& (n2$) id = ids(i) t = id.t + temp$ = refer$(str2$(i), t, 1) + manageVariableList "", temp$, 1 currentid = i EXIT FUNCTION @@ -20879,7 +20885,6 @@ FUNCTION refer$ (a2$, typ AS LONG, method AS LONG) n$ = "UDT_" + RTRIM$(id.n) IF id.t = 0 THEN n$ = "ARRAY_" + n$ n$ = scope$ + n$ - manageVariableList "", n$, 1 refer$ = n$ EXIT FUNCTION END IF @@ -20912,7 +20917,6 @@ FUNCTION refer$ (a2$, typ AS LONG, method AS LONG) END IF 'print "REFER:"+r$+","+str2$(typ) - manageVariableList "", r$, 2 refer$ = r$ EXIT FUNCTION END IF @@ -20924,7 +20928,6 @@ FUNCTION refer$ (a2$, typ AS LONG, method AS LONG) n$ = RTRIM$(id.callname) IF method = 1 THEN refer$ = n$ - manageVariableList "", n$, 3 typ = typbak EXIT FUNCTION END IF @@ -20938,7 +20941,6 @@ FUNCTION refer$ (a2$, typ AS LONG, method AS LONG) r$ = "((qbs*)(((uint64*)(" + n$ + "[0]))[" + a$ + "]))" END IF stringprocessinghappened = 1 - manageVariableList "", r$, 4 refer$ = r$ EXIT FUNCTION END IF @@ -20950,7 +20952,6 @@ FUNCTION refer$ (a2$, typ AS LONG, method AS LONG) r$ = r$ + "(" + str2(typ AND 511) + "," r$ = r$ + "(uint8*)(" + n$ + "[0])" + "," r$ = r$ + a$ + ")" - manageVariableList "", r$, 5 refer$ = r$ EXIT FUNCTION ELSE @@ -20977,7 +20978,6 @@ FUNCTION refer$ (a2$, typ AS LONG, method AS LONG) END IF IF t$ = "" THEN Give_Error "Cannot find C type to return array data": EXIT FUNCTION r$ = "((" + t$ + "*)(" + n$ + "[0]))[" + a$ + "]" - manageVariableList "", r$, 6 refer$ = r$ EXIT FUNCTION END IF 'array @@ -21025,7 +21025,6 @@ FUNCTION refer$ (a2$, typ AS LONG, method AS LONG) IF LEFT$(r$, 1) = "*" THEN r$ = RIGHT$(r$, LEN(r$) - 1) typ = typbak END IF - manageVariableList "", r$, 7 refer$ = r$ EXIT FUNCTION END IF 'variable @@ -22094,11 +22093,9 @@ SUB setrefer (a2$, typ2 AS LONG, e2$, method AS LONG) 'we have now established we have 2 pointers to similar data types! 'ASSUME BYTE TYPE!!! src$ = "((char*)" + scope$ + n2$ + ")+(" + o2$ + ")" - manageVariableList "", scope$ + n2$, 8 directudt: IF u <> u2 OR e2 <> 0 THEN Give_Error "Expected = similar user defined type": EXIT SUB dst$ = "((char*)" + lhsscope$ + n$ + ")+(" + o$ + ")" - manageVariableList "", lhsscope$ + n$, 9 copy_full_udt dst$, src$, 12, 0, u 'print "setFULLUDTrefer!" @@ -22135,7 +22132,6 @@ SUB setrefer (a2$, typ2 AS LONG, e2$, method AS LONG) 'print "setUDTrefer:"+r$,e$ tlayout$ = tl$ IF LEFT$(r$, 1) = "*" THEN r$ = MID$(r$, 2) - manageVariableList "", r$, 10 EXIT SUB END IF @@ -22170,7 +22166,6 @@ SUB setrefer (a2$, typ2 AS LONG, e2$, method AS LONG) PRINT #12, cleanupstringprocessingcall$ + "0);" tlayout$ = tl$ IF LEFT$(r$, 1) = "*" THEN r$ = MID$(r$, 2) - manageVariableList "", r$, 11 EXIT SUB END IF @@ -22217,7 +22212,6 @@ SUB setrefer (a2$, typ2 AS LONG, e2$, method AS LONG) IF Error_Happened THEN EXIT SUB ELSE l$ = "if (!new_error) ((" + t$ + "*)(" + n$ + "[0]))[tmp_long]=" + e$ + ";" - manageVariableList "", e$, 12 END IF PRINT #12, l$ @@ -22247,7 +22241,6 @@ SUB setrefer (a2$, typ2 AS LONG, e2$, method AS LONG) IF arrayprocessinghappened THEN arrayprocessinghappened = 0 tlayout$ = tl$ IF LEFT$(r$, 1) = "*" THEN r$ = MID$(r$, 2) - manageVariableList "", r$, 13 EXIT SUB END IF @@ -22279,7 +22272,6 @@ SUB setrefer (a2$, typ2 AS LONG, e2$, method AS LONG) IF arrayprocessinghappened THEN arrayprocessinghappened = 0 tlayout$ = tl$ IF LEFT$(r$, 1) = "*" THEN r$ = MID$(r$, 2) - manageVariableList "", r$, 14 EXIT SUB END IF @@ -22308,7 +22300,6 @@ SUB setrefer (a2$, typ2 AS LONG, e2$, method AS LONG) tlayout$ = tl$ IF LEFT$(r$, 1) = "*" THEN r$ = MID$(r$, 2) - manageVariableList "", r$, 15 EXIT SUB END IF 'variable