1
1
Fork 0
mirror of https://github.com/QB64-Phoenix-Edition/QB64pe.git synced 2024-06-26 17:10:38 +00:00

Adapts "Send Value" to work with multiple array dimensions.

This commit is contained in:
FellippeHeitor 2021-09-09 20:34:04 -03:00
parent 357178652b
commit 17a116b19d
2 changed files with 88 additions and 46 deletions

View file

@ -390,17 +390,19 @@ SUB vwatch (globalVariables AS _OFFSET, localVariables AS _OFFSET)
vw_cmd$ = "address read:" + MKL$(vw_tempIndex) + MKL$(vw_arrayIndex) + MKL$(vw_element) + MKL$(vw_storage) + vw_buf$
GOSUB SendCommand
CASE "set global address", "set local address"
vw_localIndex = CVL(LEFT$(vw_value$, 4))
vw_isArray = (CVL(MID$(vw_value$, 5, 4)) <> 0)
vw_arrayIndex = CVL(MID$(vw_value$, 9, 4))
vw_isUDT = (CVL(MID$(vw_value$, 13, 4)) <> 0)
vw_elementOffset = CVL(MID$(vw_value$, 17, 4))
vw_arrayElementSize = CVL(MID$(vw_value$, 21, 4))
vw_varSize = CVL(MID$(vw_value$, 25, 4))
vw_i = CVI(MID$(vw_value$, 29, 2))
vw_varType$ = MID$(vw_value$, 31, vw_i)
vw_i = CVI(MID$(vw_value$, 31 + vw_i, 2))
vw_value$ = RIGHT$(vw_value$, vw_i)
vw_getBytes& = 4: GOSUB GetBytes: vw_localIndex = CVL(vw_valueBytes$)
vw_getBytes& = 4: GOSUB GetBytes: vw_isArray = (CVL(vw_valueBytes$) <> 0)
vw_getBytes& = 4: GOSUB GetBytes: vw_arrayTotalDimensions = CVL(vw_valueBytes$)
vw_getBytes& = vw_arrayTotalDimensions: GOSUB GetBytes: vw_arrayIndexes$ = vw_valueBytes$
vw_arrayTotalDimensions = vw_arrayTotalDimensions \ 4
vw_getBytes& = 4: GOSUB GetBytes: vw_isUDT = (CVL(vw_valueBytes$) <> 0)
vw_getBytes& = 4: GOSUB GetBytes: vw_elementOffset = CVL(vw_valueBytes$)
vw_getBytes& = 4: GOSUB GetBytes: vw_arrayElementSize = CVL(vw_valueBytes$)
vw_getBytes& = 4: GOSUB GetBytes: vw_varSize = CVL(vw_valueBytes$)
vw_getBytes& = 2: GOSUB GetBytes: vw_i = CVI(vw_valueBytes$)
vw_getBytes& = vw_i: GOSUB GetBytes: vw_varType$ = vw_valueBytes$
vw_getBytes& = 2: GOSUB GetBytes: vw_i = CVI(vw_valueBytes$)
vw_getBytes& = vw_i: GOSUB GetBytes: vw_value$ = vw_valueBytes$
IF vw_cmd$ = "set global address" THEN
vw_address = _OFFSET(globalVariables) + LEN(vw_address) * vw_localIndex
@ -412,12 +414,24 @@ SUB vwatch (globalVariables AS _OFFSET, localVariables AS _OFFSET)
'--------
IF vw_isArray THEN
vw_lBound = check_lbound%&(vw_address, vw_arrayDimension, vw_arrayTotalDimensions)
vw_uBound = check_ubound%&(vw_address, vw_arrayDimension, vw_arrayTotalDimensions)
IF vw_arrayIndex < vw_lBound OR vw_arrayIndex > vw_uBound THEN
GOTO cmdProcessingDone
END IF
vw_realArrayIndex = 0
vw_blockSize = 1
FOR vw_arrayDimension = 1 TO vw_arrayTotalDimensions
vw_lBound = check_lbound%&(vw_address, vw_arrayDimension, vw_arrayTotalDimensions)
vw_uBound = check_ubound%&(vw_address, vw_arrayDimension, vw_arrayTotalDimensions)
vw_arrayIndex = CVL(MID$(vw_arrayIndexes$, vw_arrayDimension * 4 - 3, 4))
IF vw_arrayIndex < vw_lBound OR vw_arrayIndex > vw_uBound THEN
GOTO cmdProcessingDone
END IF
vw_arrayIndex = (vw_arrayIndex - VAL(STR$(vw_lBound))) * vw_blockSize
vw_realArrayIndex = vw_realArrayIndex + vw_arrayIndex
vw_blockSize = vw_blockSize * VAL(STR$(vw_uBound - vw_lBound + 1))
NEXT
'get the address of where this array's data is stored
vw_buf$ = SPACE$(LEN(vw_dummy%&))
@ -441,9 +455,9 @@ SUB vwatch (globalVariables AS _OFFSET, localVariables AS _OFFSET)
'this is where we calculate the actual array index position in memory
IF vw_arrayElementSize = 0 THEN
vw_address = vw_address + ((vw_arrayIndex - vw_lBound) * vw_varSize)
vw_address = vw_address + (vw_realArrayIndex * vw_varSize)
ELSE
vw_address = vw_address + ((vw_arrayIndex - vw_lBound) * vw_arrayElementSize)
vw_address = vw_address + (vw_realArrayIndex * vw_arrayElementSize)
END IF
ELSE
IF vw_isUDT = 0 THEN
@ -552,7 +566,7 @@ SUB vwatch (globalVariables AS _OFFSET, localVariables AS _OFFSET)
ELSE
vw_cmd$ = "": vw_value$ = ""
END IF
vw_prevValue$ = ""
vw_getBytesPosition& = 1
RETURN
SendCallStack:
@ -577,10 +591,6 @@ SUB vwatch (globalVariables AS _OFFSET, localVariables AS _OFFSET)
RETURN
GetBytes:
IF vw_value$ <> vw_prevValue$ THEN
vw_prevValue$ = vw_value$
vw_getBytesPosition& = 1
END IF
IF vw_getBytes& = 0 THEN vw_valueBytes$ = "": RETURN
vw_valueBytes$ = MID$(vw_value$, vw_getBytesPosition&, vw_getBytes&)
vw_getBytesPosition& = vw_getBytesPosition& + vw_getBytes&

View file

@ -7063,24 +7063,28 @@ SUB DebugMode
estabilishingScope = -1
ELSE
requestVariableWatch:
hidePanel = -1
GOSUB UpdateDisplay
selectVar = 1
filter$ = ""
DO
result$ = idevariablewatchbox$(currentSub$, filter$, selectVar, returnAction)
IF returnAction = 1 THEN
temp$ = GetBytes$("", 0) 'reset buffer
'set address
tempIndex& = CVL(LEFT$(result$, 4))
result$ = MID$(result$, 5)
tempHeader$ = LEFT$(result$, 24)
tempIsArray& = CVL(MID$(result$, 5, 4))
tempArrayIndex& = CVL(MID$(result$, 9, 4))
tempIsUDT& = CVL(MID$(result$, 13, 4))
tempElementOffset& = CVL(MID$(result$, 17, 4))
tempStorage& = CVL(MID$(result$, 25, 4))
i = CVI(MID$(result$, 29, 2))
varType$ = MID$(result$, 31, i)
i = CVI(MID$(result$, 31 + i, 2))
value$ = RIGHT$(result$, i)
tempIndex& = CVL(GetBytes$(result$, 4))
tempLocalIndex& = CVL(GetBytes$(result$, 4))
tempIsArray& = CVL(GetBytes$(result$, 4))
tempArrayIndex& = CVL(GetBytes$(result$, 4))
tempArrayIndexes$ = MKL$(tempArrayIndex&) + GetBytes$(result$, tempArrayIndex&)
tempIsUDT& = CVL(GetBytes$(result$, 4))
tempElementOffset& = CVL(GetBytes$(result$, 4))
tempArrayElementSize& = CVL(GetBytes$(result$, 4))
tempStorage& = CVL(GetBytes$(result$, 4))
i = CVI(GetBytes$(result$, 2))
varType$ = GetBytes$(result$, i)
i = CVI(GetBytes$(result$, 2))
value$ = GetBytes$(result$, i)
IF LEN(usedVariableList(tempIndex&).subfunc) = 0 THEN
cmd$ = "set global address:"
@ -7160,7 +7164,12 @@ SUB DebugMode
END IF
END SELECT
cmd$ = cmd$ + tempHeader$
cmd$ = cmd$ + MKL$(tempLocalIndex&)
cmd$ = cmd$ + MKL$(tempIsArray&)
cmd$ = cmd$ + tempArrayIndexes$
cmd$ = cmd$ + MKL$(tempIsUDT&)
cmd$ = cmd$ + MKL$(tempElementOffset&)
cmd$ = cmd$ + MKL$(tempArrayElementSize&)
cmd$ = cmd$ + MKL$(varSize&)
cmd$ = cmd$ + MKI$(LEN(varType$)) + varType$
cmd$ = cmd$ + MKI$(LEN(value$)) + value$
@ -7172,6 +7181,7 @@ SUB DebugMode
PCOPY 3, 0: SCREEN , , 3, 0
WHILE _MOUSEINPUT: WEND
hidePanel = -1
GOSUB UpdateDisplay
ELSEIF returnAction = 2 THEN
PCOPY 3, 0: SCREEN , , 3, 0
@ -7599,7 +7609,8 @@ SUB DebugMode
IF PauseMode <> 0 AND LEN(variableWatchList$) > 0 THEN
IF WatchListToConsole THEN _CONSOLE ON
totalVisibleVariables = CVL(MID$(variableWatchList$, 5, 4))
showvWatchPanel vWatchPanel, currentSub$, 0
IF hidePanel = 0 THEN showvWatchPanel vWatchPanel, currentSub$, 0
hidePanel = 0
END IF
PCOPY 3, 0
@ -8030,14 +8041,35 @@ FUNCTION idevariablewatchbox$(currentScope$, filter$, selectVar, returnAction)
IF usedVariableList(tempIndex&).subfunc = currentScope$ OR usedVariableList(tempIndex&).subfunc = "" THEN
'scope is valid
tempArrayIndex& = 0
tempArrayIndexes$ = MKL$(0)
tempStorage& = 0
tempIsUDT& = 0
tempElementOffset$ = MKL$(0)
IF usedVariableList(tempIndex&).isarray THEN
v$ = ideinputbox$("Change Value", "#Index to change", temp$, "01234567890", 45, 0, ok)
setArrayRange3:
v$ = ideinputbox$("Change Value", "#Index to change", temp$, "01234567890,", 45, 0, ok)
IF ok THEN
IF LEN(v$) > 0 THEN
tempArrayIndex& = VAL(v$)
WHILE RIGHT$(v$, 1) = ",": v$ = LEFT$(v$, LEN(v$) - 1): WEND
temp$ = lineformat$(v$)
i = countelements(temp$)
IF i <> ABS(ids(usedVariableList(tempIndex&).id).arrayelements) THEN
result = idemessagebox("Error", "Array has" + STR$(ABS(ids(usedVariableList(tempIndex&).id).arrayelements)) + " dimension(s).", "#OK")
temp$ = v$
GOTO setArrayRange3
END IF
tempArrayIndexes$ = MKL$(i * 4)
WHILE i
foundComma = INSTR(v$, ",")
IF foundComma THEN
temp$ = LEFT$(v$, foundComma - 1)
v$ = MID$(v$, foundComma + 1)
ELSE
temp$ = v$
END IF
tempArrayIndexes$ = tempArrayIndexes$ + MKL$(VAL(temp$))
i = i - 1
WEND
ELSE
_CONTINUE
END IF
@ -8162,14 +8194,14 @@ FUNCTION idevariablewatchbox$(currentScope$, filter$, selectVar, returnAction)
storageSlot& = 0
IF LEN(usedVariableList(tempIndex&).storage) = 4 THEN
storageSlot& = CVL(usedVariableList(tempIndex&).storage)
ELSE
i = 5
ELSEIF LEN(usedVariableList(tempIndex&).storage) > 4 THEN
i = 4
DO
i = INSTR(i + 1, variableWatchList$, MKL$(-1) + MKL$(tempIndex&) + MKL$(tempArrayIndex&))
i = INSTR(i + 1, variableWatchList$, MKL$(-1) + MKL$(tempIndex&) + tempArrayIndexes$)
IF i = 0 THEN EXIT DO
IF MID$(variableWatchList$, i + 16, 4) = tempElementOffset$ THEN
IF MID$(variableWatchList$, i + 8 + LEN(tempArrayIndexes$), 4) = tempElementOffset$ THEN
'we found where this element's value is being stored
storageSlot& = CVL(MID$(variableWatchList$, i + 20, 4))
storageSlot& = CVL(MID$(variableWatchList$, i + 16 + LEN(tempArrayIndexes$), 4))
EXIT DO
END IF
LOOP
@ -8189,7 +8221,7 @@ FUNCTION idevariablewatchbox$(currentScope$, filter$, selectVar, returnAction)
temp$ = temp$ + MKL$(tempIndex&)
temp$ = temp$ + MKL$(usedVariableList(tempIndex&).localindex)
temp$ = temp$ + MKL$(usedVariableList(tempIndex&).isarray <> 0)
temp$ = temp$ + MKL$(tempArrayIndex&)
temp$ = temp$ + tempArrayIndexes$
temp$ = temp$ + MKL$(tempIsUDT&)
temp$ = temp$ + tempElementOffset$
temp$ = temp$ + MKL$(usedVariableList(tempIndex&).arrayElementSize)
@ -8239,7 +8271,7 @@ FUNCTION idevariablewatchbox$(currentScope$, filter$, selectVar, returnAction)
IF usedVariableList(y).isarray <> 0 AND LEN(usedVariableList(y).elements) = 0 THEN
'array of native data type
temp$ = GetBytes$("", 0)
temp$ = GetBytes$("", 0) 'reset buffer
temp$ = expandArray$(usedVariableList(y).indexes, "")
DO
temp2$ = GetBytes$(temp$, 4)