mirror of
https://github.com/QB64Official/qb64.git
synced 2024-07-07 15:40:24 +00:00
Merge branch 'var-export' into development
This commit is contained in:
commit
5cbe6d87f2
|
@ -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
|
||||
|
|
File diff suppressed because it is too large
Load diff
|
@ -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
|
||||
|
||||
|
|
309
source/qb64.bas
309
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
|
||||
|
@ -778,6 +779,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 +1458,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
|
||||
|
@ -5278,18 +5283,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$
|
||||
END IF
|
||||
vWatchVariable "", 1
|
||||
END IF
|
||||
|
||||
staticarraylist = "": staticarraylistn = 0 'remove previously listed arrays
|
||||
|
@ -5297,9 +5291,45 @@ 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);"
|
||||
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;"
|
||||
vWatchAddLabel 0, -1
|
||||
END IF
|
||||
PRINT #12, "*__LONG_VWATCH_SUBLEVEL=*__LONG_VWATCH_SUBLEVEL- 1 ;"
|
||||
|
||||
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) + ";"
|
||||
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_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
|
||||
END IF
|
||||
|
||||
'release _MEM lock for this scope
|
||||
|
@ -5528,6 +5558,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
|
||||
|
@ -5575,7 +5609,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
|
||||
PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_local_vars);"
|
||||
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){"
|
||||
ELSE
|
||||
|
@ -5634,13 +5669,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
|
||||
PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_local_vars);"
|
||||
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
|
||||
PRINT #12, "do{*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_local_vars);"
|
||||
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{"
|
||||
END IF
|
||||
|
@ -5674,14 +5711,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
|
||||
PRINT #12, "*__LONG_VWATCH_LINENUMBER= " + str2$(linenumber) + "; SUB_VWATCH((ptrszint*)vwatch_local_vars);"
|
||||
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));"
|
||||
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);"
|
||||
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 controltype(controllevel) = 4 THEN
|
||||
|
@ -5834,7 +5873,8 @@ 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);"
|
||||
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, "fornext_step" + u$ + "=" + e$ + ";"
|
||||
|
@ -5921,7 +5961,8 @@ 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);"
|
||||
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
|
||||
FOR i = controllevel TO 1 STEP -1
|
||||
|
@ -5962,7 +6003,8 @@ 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);"
|
||||
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
|
||||
|
||||
|
@ -6043,6 +6085,11 @@ DO
|
|||
IF LEN(layout$) = 0 THEN layout$ = l$ ELSE layout$ = layout$ + sp + l$
|
||||
END IF
|
||||
|
||||
IF vWatchOn = 1 AND inclinenumber(inclevel) = 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, "}"
|
||||
FOR i = 1 TO controlvalue(controllevel)
|
||||
PRINT #12, "}"
|
||||
|
@ -6060,7 +6107,8 @@ 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);"
|
||||
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
|
||||
|
||||
|
@ -6180,9 +6228,15 @@ 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
|
||||
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 SelectCaseCounter > 0 AND SelectCaseHasCaseBlock(SelectCaseCounter) = 0 THEN
|
||||
'warn user of empty SELECT CASE block
|
||||
IF NOT IgnoreWarnings THEN
|
||||
|
@ -6298,7 +6352,8 @@ 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);"
|
||||
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
|
||||
|
||||
|
@ -6486,7 +6541,8 @@ 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);"
|
||||
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{"
|
||||
END IF
|
||||
|
@ -7467,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!
|
||||
|
||||
|
@ -8833,7 +8890,8 @@ DO
|
|||
|
||||
|
||||
IF vWatchOn = 1 THEN
|
||||
PRINT #12, "*__LONG_VWATCH_LINENUMBER= 0; SUB_VWATCH((ptrszint*)vwatch_local_vars);"
|
||||
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);"
|
||||
PRINT #12, "close_program=1;"
|
||||
|
@ -8856,7 +8914,8 @@ 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);"
|
||||
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;"
|
||||
PRINT #12, "end();"
|
||||
|
@ -11652,18 +11711,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$
|
||||
END IF
|
||||
vWatchVariable "", 1
|
||||
END IF
|
||||
|
||||
|
||||
|
@ -14009,7 +14057,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
|
||||
|
@ -14146,18 +14194,128 @@ 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
|
||||
|
||||
vWatchNewVariable$ = this$
|
||||
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
|
||||
|
||||
IF lastLine = 0 THEN
|
||||
WHILE this > LEN(vWatchUsedLabels)
|
||||
vWatchUsedLabels = vWatchUsedLabels + SPACE$(1000)
|
||||
WEND
|
||||
|
||||
IF firstLineNumberLabelvWatch = 0 THEN
|
||||
firstLineNumberLabelvWatch = this
|
||||
ELSE
|
||||
IF prevSkip <> prevLabel THEN
|
||||
PRINT #12, "VWATCH_SKIPLABEL_" + str2$(prevLabel) + ":;"
|
||||
prevSkip = prevLabel
|
||||
END IF
|
||||
END IF
|
||||
|
||||
IF prevLabel <> this THEN
|
||||
ASC(vWatchUsedLabels, this) = 1
|
||||
PRINT #12, "VWATCH_LABEL_" + str2$(this) + ":;"
|
||||
prevLabel = this
|
||||
lastLineNumberLabelvWatch = this
|
||||
END IF
|
||||
ELSE
|
||||
IF prevSkip <> prevLabel THEN
|
||||
PRINT #12, "VWATCH_SKIPLABEL_" + str2$(prevLabel) + ":;"
|
||||
prevSkip = prevLabel
|
||||
END IF
|
||||
END IF
|
||||
END SUB
|
||||
|
||||
SUB closemain
|
||||
xend
|
||||
|
||||
PRINT #12, "return;"
|
||||
|
||||
IF vWatchOn AND firstLineNumberLabelvWatch > 0 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, "}"
|
||||
|
||||
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, "}"
|
||||
PRINT #15, "}" 'end case
|
||||
PRINT #15, "}"
|
||||
PRINT #15, "error(3);" 'no valid return possible
|
||||
|
||||
closedmain = 1
|
||||
|
||||
firstLineNumberLabelvWatch = 0
|
||||
END SUB
|
||||
|
||||
FUNCTION countelements (a$)
|
||||
|
@ -14284,6 +14442,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
|
||||
|
@ -14321,6 +14480,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
|
||||
|
@ -14487,6 +14647,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
|
||||
|
@ -14577,6 +14738,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
|
||||
|
@ -14680,6 +14842,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
|
||||
|
@ -14765,6 +14928,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
|
||||
|
@ -14847,6 +15011,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
|
||||
|
@ -14934,6 +15099,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
|
||||
|
@ -15018,6 +15184,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
|
||||
|
@ -15102,6 +15269,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
|
||||
|
@ -15186,6 +15354,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
|
||||
|
@ -15268,6 +15437,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
|
||||
|
@ -15350,6 +15520,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
|
||||
|
@ -15357,9 +15528,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
|
||||
|
@ -15450,7 +15618,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
|
||||
|
@ -15950,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:
|
||||
|
@ -18286,7 +18455,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
|
||||
|
@ -18390,33 +18559,8 @@ 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
|
||||
|
||||
temp$ = refer$(str2$(i), t, 1)
|
||||
manageVariableList "", temp$, 1
|
||||
currentid = i
|
||||
EXIT FUNCTION
|
||||
|
||||
|
@ -19617,7 +19761,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
|
||||
|
@ -21952,7 +22096,6 @@ SUB setrefer (a2$, typ2 AS LONG, e2$, method AS LONG)
|
|||
directudt:
|
||||
IF u <> u2 OR e2 <> 0 THEN Give_Error "Expected = similar user defined type": EXIT SUB
|
||||
dst$ = "((char*)" + lhsscope$ + n$ + ")+(" + o$ + ")"
|
||||
|
||||
copy_full_udt dst$, src$, 12, 0, u
|
||||
|
||||
'print "setFULLUDTrefer!"
|
||||
|
@ -21989,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 "", scope$ + n$, 7
|
||||
EXIT SUB
|
||||
END IF
|
||||
|
||||
|
@ -22024,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$, 8
|
||||
EXIT SUB
|
||||
END IF
|
||||
|
||||
|
@ -22100,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$, 9
|
||||
EXIT SUB
|
||||
END IF
|
||||
|
||||
|
@ -22132,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$, 10
|
||||
EXIT SUB
|
||||
END IF
|
||||
|
||||
|
@ -22161,8 +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$, 11
|
||||
|
||||
EXIT SUB
|
||||
END IF 'variable
|
||||
|
||||
|
@ -22206,7 +22343,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
|
||||
|
@ -22617,6 +22754,7 @@ END FUNCTION
|
|||
|
||||
SUB xend
|
||||
IF vWatchOn = 1 THEN
|
||||
vWatchAddLabel 0, -1
|
||||
PRINT #12, "*__LONG_VWATCH_LINENUMBER= 0; SUB_VWATCH((ptrszint*)vwatch_local_vars);"
|
||||
END IF
|
||||
PRINT #12, "sub_end();"
|
||||
|
@ -25712,8 +25850,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
|
||||
|
@ -25748,15 +25887,13 @@ 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
|
||||
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
|
||||
|
|
|
@ -1,11 +1,14 @@
|
|||
$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
|
||||
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
|
||||
|
|
|
@ -1,225 +1,280 @@
|
|||
$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 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
|
||||
|
||||
IF ide = 0 THEN
|
||||
timeout = 10
|
||||
endc$ = "<END>"
|
||||
|
||||
'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
|
||||
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 "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
|
||||
cmd$ = "call stack size:" + MKL$(callStackLength)
|
||||
GOSUB SendCommand
|
||||
cmd$ = "call stack:" + vwatch_callstack
|
||||
GOSUB SendCommand
|
||||
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
|
||||
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 THEN EXIT SUB
|
||||
lastLine = vwatch_linenumber
|
||||
|
||||
GOSUB GetCommand
|
||||
SELECT CASE cmd$
|
||||
CASE "break"
|
||||
pauseMode = -1
|
||||
stepOver = 0
|
||||
cmd$ = ""
|
||||
CASE "set breakpoint"
|
||||
vwatch_breakpoints(CVL(value$)) = -1
|
||||
CASE "clear breakpoint"
|
||||
vwatch_breakpoints(CVL(value$)) = 0
|
||||
CASE "clear all breakpoints"
|
||||
REDIM vwatch_breakpoints(UBOUND(vwatch_breakpoints)) AS _BYTE
|
||||
END SELECT
|
||||
|
||||
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
|
||||
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"
|
||||
cmd$ = "call stack size:" + MKL$(callStackLength)
|
||||
GOSUB SendCommand
|
||||
cmd$ = "call stack:" + vwatch_callstack
|
||||
GOSUB SendCommand
|
||||
CASE "local"
|
||||
i = CVL(value$)
|
||||
address = localVariables + LEN(address) * i
|
||||
PRINT "Local"; i; "is at"; _MEMGET(m, address, _OFFSET)
|
||||
END SELECT
|
||||
|
||||
GOSUB GetCommand
|
||||
_LIMIT 100
|
||||
LOOP
|
||||
|
||||
vwatch_starttimers
|
||||
EXIT SUB
|
||||
|
||||
Connect:
|
||||
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
|
||||
|
||||
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, runToLine
|
||||
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$ = "<END>"
|
||||
|
||||
'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
|
||||
runToLine = 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 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
|
||||
|
||||
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 "run to line"
|
||||
pauseMode = 0
|
||||
stepOver = 0
|
||||
runToLine = CVL(value$)
|
||||
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
|
||||
|
|
Loading…
Reference in a new issue