1
1
Fork 0
mirror of https://github.com/QB64Official/qb64.git synced 2024-07-08 19:35:13 +00:00

Reduces number of commands to get a variable's value.

This commit is contained in:
FellippeHeitor 2021-08-17 00:47:13 -03:00
parent eeff3207d6
commit f279839a7b
3 changed files with 37 additions and 38 deletions

View file

@ -246,24 +246,6 @@ SUB vwatch (globalVariables AS _OFFSET, localVariables AS _OFFSET)
CASE "call stack" CASE "call stack"
'send call stack history 'send call stack history
GOSUB SendCallStack GOSUB SendCallStack
CASE "global var", "local var"
vw_tempIndex = CVL(LEFT$(vw_value$, 4))
vw_localIndex = CVL(MID$(vw_value$, 5, 4))
vw_arrayIndex = CVL(MID$(vw_value$, 9, 4))
vw_scope$ = MID$(vw_value$, 13)
IF vw_cmd$ = "global var" THEN
vw_address = _OFFSET(globalVariables) + LEN(vw_address) * vw_localIndex
ELSE
IF vw_scope$ = LEFT$(vwatch_stack(vwatch_sublevel), INSTR(vwatch_stack(vwatch_sublevel), ",") - 1) THEN
vw_address = _OFFSET(localVariables) + LEN(vw_address) * vw_localIndex
ELSE
GOTO cmdProcessingDone
END IF
END IF
vw_address = _MEMGET(vw_m, vw_address, _OFFSET) 'first resolve pass
vw_address = _MEMGET(vw_m, vw_address, _OFFSET) 'second resolve pass
vw_cmd$ = vw_cmd$ + ":" + MKL$(vw_tempIndex) + MKL$(vw_arrayIndex) + _MK$(_OFFSET, vw_address)
GOSUB SendCommand
CASE "get address" CASE "get address"
vw_tempIndex = CVL(LEFT$(vw_value$, 4)) vw_tempIndex = CVL(LEFT$(vw_value$, 4))
vw_arrayIndex = CVL(MID$(vw_value$, 5, 4)) vw_arrayIndex = CVL(MID$(vw_value$, 5, 4))
@ -274,7 +256,33 @@ SUB vwatch (globalVariables AS _OFFSET, localVariables AS _OFFSET)
vw_m = _MEM(vw_address, vw_varSize) vw_m = _MEM(vw_address, vw_varSize)
vw_m2 = _MEM(_OFFSET(vw_buf$), vw_varSize) vw_m2 = _MEM(_OFFSET(vw_buf$), vw_varSize)
_MEMCOPY vw_m, vw_m.OFFSET, vw_m.SIZE TO vw_m2, vw_m2.OFFSET _MEMCOPY vw_m, vw_m.OFFSET, vw_m.SIZE TO vw_m2, vw_m2.OFFSET
vw_cmd$ = "address read:" + MKL$(vw_tempIndex) + MKL$(vw_arrayIndex) + MKI$(vw_sequence) + vw_buf$ vw_cmd$ = "address read:" + MKL$(vw_tempIndex) + MKL$(vw_arrayIndex) + MKI$(vw_sequence) + _MK$(_OFFSET, vw_address) + vw_buf$
GOSUB SendCommand
CASE "get global address", "get local address"
vw_tempIndex = CVL(LEFT$(vw_value$, 4))
vw_localIndex = CVL(MID$(vw_value$, 5, 4))
vw_arrayIndex = CVL(MID$(vw_value$, 9, 4))
vw_sequence = CVI(MID$(vw_value$, 13, 2))
vw_varSize = CVL(MID$(vw_value$, 15, 4))
vw_scope$ = MID$(vw_value$, 19)
IF vw_cmd$ = "get global address" THEN
vw_address = _OFFSET(globalVariables) + LEN(vw_address) * vw_localIndex
ELSE
IF vw_scope$ = LEFT$(vwatch_stack(vwatch_sublevel), INSTR(vwatch_stack(vwatch_sublevel), ",") - 1) THEN
vw_address = _OFFSET(localVariables) + LEN(vw_address) * vw_localIndex
ELSE
GOTO cmdProcessingDone
END IF
END IF
vw_address = _MEMGET(vw_m, vw_address, _OFFSET) 'first resolve pass
vw_address = _MEMGET(vw_m, vw_address, _OFFSET) 'second resolve pass
'vw_address now points to the actual data
vw_buf$ = SPACE$(vw_varSize)
vw_m = _MEM(vw_address, vw_varSize)
vw_m2 = _MEM(_OFFSET(vw_buf$), vw_varSize)
_MEMCOPY vw_m, vw_m.OFFSET, vw_m.SIZE TO vw_m2, vw_m2.OFFSET
vw_cmd$ = "address read:" + MKL$(vw_tempIndex) + MKL$(vw_arrayIndex) + MKI$(vw_sequence) + _MK$(_OFFSET, vw_address) + vw_buf$
GOSUB SendCommand GOSUB SendCommand
CASE "set global address", "set local address" CASE "set global address", "set local address"
vw_localIndex = CVL(LEFT$(vw_value$, 4)) vw_localIndex = CVL(LEFT$(vw_value$, 4))

View file

@ -139,6 +139,7 @@ FUNCTION ide2 (ignore)
char.sep$ = CHR$(34) + " =<>+-/\^:;,*()." char.sep$ = CHR$(34) + " =<>+-/\^:;,*()."
c$ = idecommand$ c$ = idecommand$
debugnextline = 0
IDEerrorMessage: IDEerrorMessage:
'report any IDE errors which have occurred 'report any IDE errors which have occurred
@ -7383,32 +7384,26 @@ SUB DebugMode
temp$ = MID$(temp$, 9) temp$ = MID$(temp$, 9)
cmd$ = "" cmd$ = ""
IF LEN(usedVariableList(tempIndex&).subfunc) = 0 THEN IF LEN(usedVariableList(tempIndex&).subfunc) = 0 THEN
cmd$ = "global var:" cmd$ = "get global address:"
ELSE ELSE
cmd$ = "local var:" cmd$ = "get local address:"
END IF END IF
GOSUB GetVarSize
IF usedVariableList(tempIndex&).isarray THEN varSize& = LEN(dummy%&)
IF LEN(cmd$) THEN IF LEN(cmd$) THEN
cmd$ = cmd$ + MKL$(tempIndex&) + MKL$(usedVariableList(tempIndex&).localIndex) + MKL$(tempArrayIndex&) + usedVariableList(tempIndex&).subfunc cmd$ = cmd$ + MKL$(tempIndex&) + MKL$(usedVariableList(tempIndex&).localIndex) + MKL$(tempArrayIndex&) + MKI$(1) + MKL$(varSize&) + usedVariableList(tempIndex&).subfunc
GOSUB SendCommand GOSUB SendCommand
END IF END IF
LOOP LOOP
END IF END IF
CASE "hwnd" CASE "hwnd"
debuggeehwnd = _CV(_OFFSET, value$) debuggeehwnd = _CV(_OFFSET, value$)
CASE "global var", "local var"
tempIndex& = CVL(LEFT$(value$, 4))
tempArrayIndex& = CVL(MID$(value$, 5, 4))
address%& = _CV(_OFFSET, MID$(value$, 9))
usedVariableList(tempIndex&).baseAddress = address%&
GOSUB GetVarSize
IF usedVariableList(tempIndex&).isarray THEN varSize& = LEN(dummy%&)
cmd$ = "get address:" + MKL$(tempIndex&) + MKL$(tempArrayIndex&) + MKI$(1) + MKL$(varSize&) + _MK$(_OFFSET, address%&)
GOSUB SendCommand
CASE "address read" CASE "address read"
tempIndex& = CVL(LEFT$(value$, 4)) tempIndex& = CVL(LEFT$(value$, 4))
tempArrayIndex& = CVL(MID$(value$, 5, 4)) tempArrayIndex& = CVL(MID$(value$, 5, 4))
sequence% = CVI(MID$(value$, 9, 2)) sequence% = CVI(MID$(value$, 9, 2))
recvData$ = MID$(value$, 11) address%& = _CV(_OFFSET, MID$(value$, 11, LEN(address%&)))
recvData$ = MID$(value$, 11 + LEN(address%&))
GOSUB GetVarSize GOSUB GetVarSize
IF usedVariableList(tempIndex&).isarray THEN IF usedVariableList(tempIndex&).isarray THEN
IF sequence% = 1 THEN IF sequence% = 1 THEN
@ -7443,14 +7438,10 @@ SUB DebugMode
IF sequence% = 1 THEN IF sequence% = 1 THEN
IF LEN(dummy%&) = 8 THEN IF LEN(dummy%&) = 8 THEN
address%& = _CV(_INTEGER64, LEFT$(recvData$, 8)) 'Pointer to data address%& = _CV(_INTEGER64, LEFT$(recvData$, 8)) 'Pointer to data
usedVariableList(tempIndex&).address = address%&
strLength& = CVL(MID$(recvData$, 9)) strLength& = CVL(MID$(recvData$, 9))
usedVariableList(tempIndex&).strLength = strLength&
ELSE ELSE
address%& = _CV(LONG, LEFT$(recvData$, 4)) 'Pointer to data address%& = _CV(LONG, LEFT$(recvData$, 4)) 'Pointer to data
usedVariableList(tempIndex&).address = address%&
strLength& = CVL(MID$(recvData$, 5)) strLength& = CVL(MID$(recvData$, 5))
usedVariableList(tempIndex&).strLength = strLength&
END IF END IF
cmd$ = "get address:" + MKL$(tempIndex&) + MKL$(tempArrayIndex&) + MKI$(2) + MKL$(strLength&) + _MK$(_OFFSET, address%&) cmd$ = "get address:" + MKL$(tempIndex&) + MKL$(tempArrayIndex&) + MKI$(2) + MKL$(strLength&) + _MK$(_OFFSET, address%&)
GOSUB SendCommand GOSUB SendCommand

View file

@ -109,11 +109,11 @@ DIM SHARED ShowWarnings AS _BYTE, QuietMode AS _BYTE, CMDLineFile AS STRING
DIM SHARED MonochromeLoggingMode AS _BYTE DIM SHARED MonochromeLoggingMode AS _BYTE
TYPE usedVarList TYPE usedVarList
AS LONG id, linenumber, includeLevel, includedLine, scope, localIndex, strLength AS LONG id, linenumber, includeLevel, includedLine, scope, localIndex
AS _BYTE used, watch, isarray AS _BYTE used, watch, isarray
AS STRING name, cname, varType, includedFile, subfunc, mostRecentValue AS STRING name, cname, varType, includedFile, subfunc, mostRecentValue
AS STRING watchRange, indexes, elements, storage 'for Arrays and UDTs AS STRING watchRange, indexes, elements, storage 'for Arrays and UDTs
AS _OFFSET baseAddress, address AS _OFFSET baseAddress
END TYPE END TYPE
DIM SHARED totalVariablesCreated AS LONG DIM SHARED totalVariablesCreated AS LONG