mirror of
https://github.com/QB64-Phoenix-Edition/QB64pe.git
synced 2024-07-05 21:40:25 +00:00
Improved detection of unused variables.
This commit is contained in:
parent
47685d82b0
commit
738fe6924d
|
@ -1298,14 +1298,16 @@ FUNCTION ide2 (ignore)
|
||||||
IF mX = 1 AND SCREEN(mY, mX) = 26 THEN
|
IF mX = 1 AND SCREEN(mY, mX) = 26 THEN
|
||||||
unusedVariableWarningX = mX
|
unusedVariableWarningX = mX
|
||||||
unusedVariableWarningY = mY
|
unusedVariableWarningY = mY
|
||||||
findItem = INSTR(usedVariableList$, CHR$(1) + MKL$((mY - 3) + idesy) + CHR$(2))
|
findItem = INSTR(usedVariableList$, CHR$(1) + MKL$((mY - 3) + idesy) + CHR$(2) + CHR$(3))
|
||||||
unusedVariableName$ = MID$(usedVariableList$, findItem + 6, INSTR(findItem, usedVariableList$, CHR$(10)) - findItem - 6)
|
unusedVariableName$ = MID$(usedVariableList$, findItem + 6, INSTR(findItem, usedVariableList$, CHR$(5)) - findItem - 6)
|
||||||
findItem = INSTR(unusedVariableName$, CHR$(3))
|
findItem = MID$(usedVariableList$, findItem + 6 + LEN(unusedVariableName$) INSTR(findItem, usedVariableList$, CHR$(3))
|
||||||
unusedVariableName$ = LEFT$(unusedVariableName$, findItem - 1) + " (" + MID$(unusedVariableName$, findItem + 1) + ") "
|
unusedVariableName$ = LEFT$(unusedVariableName$, findItem - 1) + " (" + MID$(unusedVariableName$, findItem + 1) + ") "
|
||||||
unusedVariableWarning$ = LEFT$(" Variable hasn't yet been used: " + unusedVariableName$, idewx - 2)
|
unusedVariableWarning$ = LEFT$(" Variable hasn't yet been used: " + unusedVariableName$, idewx - 2)
|
||||||
LOCATE mY, mX
|
LOCATE mY, mX
|
||||||
COLOR 0, 3
|
COLOR 0, 3
|
||||||
PRINT CHR$(26) + unusedVariableWarning$
|
PRINT CHR$(26) + LEFT$(unusedVariableWarning$, 32);
|
||||||
|
COLOR 15
|
||||||
|
PRINT MID$(unusedVariableWarning$, 33);
|
||||||
|
|
||||||
'shadow
|
'shadow
|
||||||
COLOR 2, 0
|
COLOR 2, 0
|
||||||
|
@ -8541,7 +8543,7 @@ SUB ideshowtext
|
||||||
END IF
|
END IF
|
||||||
|
|
||||||
IF l <= iden THEN
|
IF l <= iden THEN
|
||||||
IF idecompiling = 0 AND INSTR(usedVariableList$, CHR$(1) + MKL$(l) + CHR$(2)) > 0 THEN
|
IF idecompiling = 0 AND INSTR(usedVariableList$, CHR$(1) + MKL$(l) + CHR$(2) + CHR$(4)) > 0 THEN
|
||||||
LOCATE y + 3, 1
|
LOCATE y + 3, 1
|
||||||
prevBG% = _BACKGROUNDCOLOR
|
prevBG% = _BACKGROUNDCOLOR
|
||||||
COLOR 13, 1
|
COLOR 13, 1
|
||||||
|
@ -8929,7 +8931,7 @@ SUB ideshowtext
|
||||||
FOR b = 1 TO IdeBmkN
|
FOR b = 1 TO IdeBmkN
|
||||||
y = IdeBmk(b).y
|
y = IdeBmk(b).y
|
||||||
IF y >= idesy AND y <= idesy + (idewy - 9) THEN
|
IF y >= idesy AND y <= idesy + (idewy - 9) THEN
|
||||||
IF INSTR(usedVariableList$, CHR$(1) + MKL$(y) + CHR$(2)) = 0 THEN
|
IF INSTR(usedVariableList$, CHR$(1) + MKL$(y) + CHR$(2) + CHR$(4)) = 0 THEN
|
||||||
LOCATE 3 + y - idesy, 1: PRINT CHR$(197);
|
LOCATE 3 + y - idesy, 1: PRINT CHR$(197);
|
||||||
END IF
|
END IF
|
||||||
END IF
|
END IF
|
||||||
|
|
|
@ -11631,7 +11631,10 @@ OPEN compilelog$ FOR OUTPUT AS #1: CLOSE #1 'Clear log
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
OPEN "unusedVariableList.txt" FOR OUTPUT AS #1: CLOSE #1
|
||||||
|
OPEN "unusedVariableList.txt" FOR BINARY AS #1
|
||||||
|
PUT #1, 1, usedVariableList$
|
||||||
|
CLOSE #1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -24849,22 +24852,20 @@ SUB manageVariableList (name$, __cname$, action AS _BYTE)
|
||||||
|
|
||||||
SELECT CASE action
|
SELECT CASE action
|
||||||
CASE 0 'add
|
CASE 0 'add
|
||||||
usedVariableList$ = usedVariableList$ + CHR$(1) + MKL$(linenumber) + CHR$(2)
|
s$ = CHR$(4) + MKI$(LEN(cname$)) + cname$ + CHR$(5)
|
||||||
usedVariableList$ = usedVariableList$ + name$ + CHR$(3) + cname$ + CHR$(10)
|
IF INSTR(usedVariableList$, s$) = 0 THEN
|
||||||
totalUnusedVariables = totalUnusedVariables + 1
|
ASC(s$, 1) = 3
|
||||||
'usedVariableList$ = usedVariableList$ + "Adding " + cname$ + " at line" + STR$(linenumber) + CHR$(10)
|
usedVariableList$ = usedVariableList$ + CHR$(1) + MKL$(linenumber) + CHR$(2)
|
||||||
|
usedVariableList$ = usedVariableList$ + s$ + name$ + CHR$(10)
|
||||||
|
totalUnusedVariables = totalUnusedVariables + 1
|
||||||
|
'usedVariableList$ = usedVariableList$ + "Adding " + cname$ + " at line" + STR$(linenumber) + CHR$(10)
|
||||||
|
END IF
|
||||||
CASE ELSE 'find and remove
|
CASE ELSE 'find and remove
|
||||||
s$ = CHR$(3) + cname$ + CHR$(10)
|
s$ = CHR$(3) + cname$ + CHR$(5)
|
||||||
findItem = INSTR(usedVariableList$, s$)
|
findItem = INSTR(usedVariableList$, s$)
|
||||||
IF findItem THEN
|
IF findItem THEN
|
||||||
FOR i = findItem TO 1 STEP -1
|
ASC(usedVariableList$, findItem) = 4
|
||||||
IF ASC(usedVariableList$, i) = 1 THEN
|
totalUnusedVariables = totalUnusedVariables - 1
|
||||||
findItem = INSTR(findItem, usedVariableList$, CHR$(10))
|
|
||||||
usedVariableList$ = LEFT$(usedVariableList$, i - 1) + MID$(usedVariableList$, findItem + 1)
|
|
||||||
totalUnusedVariables = totalUnusedVariables - 1
|
|
||||||
EXIT FOR
|
|
||||||
END IF
|
|
||||||
NEXT
|
|
||||||
END IF
|
END IF
|
||||||
'usedVariableList$ = usedVariableList$ + STR$(action) + " Searching " + cname$ + " at line" + STR$(linenumber) + CHR$(10)
|
'usedVariableList$ = usedVariableList$ + STR$(action) + " Searching " + cname$ + " at line" + STR$(linenumber) + CHR$(10)
|
||||||
END SELECT
|
END SELECT
|
||||||
|
|
Loading…
Reference in a new issue