1
1
Fork 0
mirror of https://github.com/QB64-Phoenix-Edition/QB64pe.git synced 2024-07-03 12:21:20 +00:00

Tweak to $COLOR processing order

Move $COLOR commands so they process after the precompile commands (such as $LET), otherwise they may not be included/excluded properly when between $IF blocks.
This commit is contained in:
SteveMcNeill 2019-08-07 09:23:12 -04:00
parent e006fefb12
commit cc16eaac1c

View file

@ -1579,7 +1579,7 @@ DO
DO UNTIL linenumber < UBOUND(InValidLine) 'color information flag for each line
REDIM _PRESERVE InValidLine(UBOUND(InValidLine) + 1000) AS _BIT
LOOP
InValidLine(linenumber) = 0
IF ColorHack = 0 THEN InValidLine(linenumber) = 0
IF LEN(wholeline$) THEN
@ -2814,7 +2814,7 @@ subfuncn = 0
lastLineReturn = 0
lastLine = 0
firstLine = 1
ColorHack = 0
ColorHackSet = 0
FOR i = 0 TO constlast: constdefined(i) = 0: NEXT 'undefine constants
@ -2982,8 +2982,111 @@ DO
'precompiler commands should always be executed FIRST.
IF a3u$ = "$END IF" OR a3u$ = "$ENDIF" THEN
IF DefineElse(ExecCounter) = 0 THEN a$ = "$END IF without $IF": GOTO errmes
DefineElse(ExecCounter) = 0 'We no longer have an $IF block at this level
ExecCounter = ExecCounter - 1
layout$ = "$END IF"
controltype(controllevel) = 0
controllevel = controllevel - 1
GOTO finishednonexec
END IF
IF LEFT$(a3u$, 4) = "$IF " THEN
temp$ = LTRIM$(MID$(a3u$, 4)) 'strip off the $IF and extra spaces
temp$ = RTRIM$(LEFT$(temp$, LEN(temp$) - 4)) 'and strip off the THEN and extra spaces
temp = INSTR(temp$, "=")
ExecCounter = ExecCounter + 1
ExecLevel(ExecCounter) = -1 'default to a skip value
DefineElse(ExecCounter) = 1 '1 says we have an $IF statement at this level
result = EvalPreIF(temp$, a$)
IF a$ <> "" THEN GOTO errmes
IF result <> 0 THEN
ExecLevel(ExecCounter) = ExecLevel(ExecCounter - 1) 'So we inherit the execlevel from above
IF ExecLevel(ExecCounter) = 0 THEN DefineElse(ExecCounter) = DefineElse(ExecCounter) OR 4 'Else if used and conditon found
END IF
controllevel = controllevel + 1
controltype(controllevel) = 6
IF temp = 0 THEN layout$ = "$IF " + temp$ + " THEN": GOTO finishednonexec 'no = sign in the $IF statement, so we're going to assume the user is doing something like $IF flag
l$ = RTRIM$(LEFT$(temp$, temp - 1)): r$ = LTRIM$(MID$(temp$, temp + 1))
layout$ = "$IF " + l$ + " = " + r$ + " THEN"
GOTO finishednonexec
END IF
IF a3u$ = "$ELSE" THEN
IF DefineElse(ExecCounter) = 0 THEN a$ = "$ELSE without $IF": GOTO errmes
IF DefineElse(ExecCounter) AND 2 THEN a$ = "$IF block already has $ELSE statement in it": GOTO errmes
DefineElse(ExecCounter) = DefineElse(ExecCounter) OR 2 'set the flag to declare an $ELSE already in this block
IF DefineElse(ExecCounter) AND 4 THEN 'If we executed code in a previous IF or ELSE IF statement, we can't do it here
ExecLevel(ExecCounter) = -1 'So we inherit the execlevel from above
ELSE
ExecLevel(ExecCounter) = ExecLevel(ExecCounter - 1) 'If we were processing code before, code after this segment is going to be SKIPPED
END IF
layout$ = "$ELSE"
lhscontrollevel = lhscontrollevel - 1
GOTO finishednonexec
END IF
IF LEFT$(a3u$, 5) = "$ELSE" THEN
temp$ = LTRIM$(MID$(a3u$, 6))
IF LEFT$(temp$, 3) = "IF " THEN
IF DefineElse(ExecCounter) = 0 THEN a$ = "$ELSE IF without $IF": GOTO errmes
IF DefineElse(ExecCounter) AND 2 THEN a$ = "$ELSE IF cannot follow $ELSE": GOTO errmes
IF RIGHT$(temp$, 5) <> " THEN" THEN a$ = "$ELSE IF without THEN": GOTO errmes
temp$ = LTRIM$(MID$(temp$, 3)) 'strip off the IF and extra spaces
temp$ = RTRIM$(LEFT$(temp$, LEN(temp$) - 4)) 'and strip off the THEN and extra spaces
IF DefineElse(ExecCounter) AND 4 THEN 'If we executed code in a previous IF or ELSE IF statement, we can't do it here
ExecLevel(ExecCounter) = -1
ELSE
result = EvalPreIF(temp$, a$)
IF a$ <> "" THEN GOTO errmes
IF result <> 0 THEN
ExecLevel(ExecCounter) = ExecLevel(ExecCounter - 1) 'So we inherit the execlevel from above
IF ExecLevel(ExecCounter) = 0 THEN DefineElse(ExecCounter) = DefineElse(ExecCounter) OR 4 'Else if used and conditon found
END IF
END IF
lhscontrollevel = lhscontrollevel - 1
temp = INSTR(temp$, "=")
IF temp = 0 THEN layout$ = "$ELSEIF " + temp$ + " THEN": GOTO finishednonexec 'no = sign in the $IF statement, so we're going to assume the user is doing something like $IF flag
l$ = RTRIM$(LEFT$(temp$, temp - 1)): r$ = LTRIM$(MID$(temp$, temp + 1))
layout$ = "$ELSEIF " + l$ + " = " + r$ + " THEN"
GOTO finishednonexec
END IF
END IF
IF ExecLevel(ExecCounter) THEN 'don't check for any more metacommands except the one's which worth with the precompiler
layoutdone = 0
GOTO finishednonexec 'we don't check for anything inside lines that we've marked for skipping
END IF
IF LEFT$(a3u$, 5) = "$LET " THEN
temp$ = a3u$
temp$ = LTRIM$(MID$(temp$, 5)) 'simply shorten our string to parse
'For starters, let's make certain that we have 3 elements to deal with
temp = INSTR(temp$, "=") 'without an = in there, we can't get a value from the left and right side
l$ = RTRIM$(LEFT$(temp$, temp - 1)): r$ = LTRIM$(MID$(temp$, temp + 1))
layout$ = "$LET " + l$ + " = " + r$
'First look to see if we have an existing setting like this and if so, update it
FOR i = 7 TO UserDefineCount 'UserDefineCount 1-6 are reserved for automatic OS/BIT detection
IF UserDefine(0, i) = l$ THEN UserDefine(1, i) = r$: GOTO finishednonexec
NEXT
'Otherwise create a new setting and set the initial value for it
UserDefineCount = UserDefineCount + 1
IF UserDefineCount > UBOUND(UserDefine, 2) THEN
REDIM _PRESERVE UserDefine(1, UBOUND(UserDefine, 2) + 10) 'Add another 10 elements to the array so it'll expand as the user adds to it
END IF
UserDefine(0, UserDefineCount) = l$
UserDefine(1, UserDefineCount) = r$
GOTO finishednonexec
END IF
IF a3u$ = "$COLOR:0" THEN
IF NOT ColorHack THEN
IF NOT ColorHackSet THEN
ColorHackSet = -1
ColorHack = -1
oldlinenumber = linenumber
wholeline$ = "CONST Black~%% = 0": GOSUB ideprepass
@ -3003,6 +3106,7 @@ DO
wholeline$ = "CONST Yellow~%% = 14": GOSUB ideprepass
wholeline$ = "CONST BrightWhite~%% = 15": GOSUB ideprepass
wholeline$ = "CONST Blink~%% = 16": GOSUB ideprepass
ColorHack = 0
layout$ = "$COLOR:0"
layoutdone = 1
linenumber = oldlinenumber
@ -3013,10 +3117,9 @@ DO
END IF
END IF
IF a3u$ = "$COLOR:32" THEN
IF NOT ColorHack THEN
IF NOT ColorHackSet THEN
ColorHackSet = -1
ColorHack = -1
oldlinenumber = linenumber
wholeline$ = "CONST AliceBlue~& = 4293982463": GOSUB ideprepass
@ -3289,6 +3392,7 @@ DO
wholeline$ = "CONST Yellow~& = 4294967040": GOSUB ideprepass
wholeline$ = "CONST YellowGreen~& = 4288335154": GOSUB ideprepass
wholeline$ = "CONST YellowOrange~& = 4294946370": GOSUB ideprepass
ColorHack = 0
layout$ = "$COLOR:32"
layoutdone = 1
linenumber = oldlinenumber
@ -3300,107 +3404,7 @@ DO
END IF
IF a3u$ = "$END IF" OR a3u$ = "$ENDIF" THEN
IF DefineElse(ExecCounter) = 0 THEN a$ = "$END IF without $IF": GOTO errmes
DefineElse(ExecCounter) = 0 'We no longer have an $IF block at this level
ExecCounter = ExecCounter - 1
layout$ = "$END IF"
controltype(controllevel) = 0
controllevel = controllevel - 1
GOTO finishednonexec
END IF
IF LEFT$(a3u$, 4) = "$IF " THEN
temp$ = LTRIM$(MID$(a3u$, 4)) 'strip off the $IF and extra spaces
temp$ = RTRIM$(LEFT$(temp$, LEN(temp$) - 4)) 'and strip off the THEN and extra spaces
temp = INSTR(temp$, "=")
ExecCounter = ExecCounter + 1
ExecLevel(ExecCounter) = -1 'default to a skip value
DefineElse(ExecCounter) = 1 '1 says we have an $IF statement at this level
result = EvalPreIF(temp$, a$)
IF a$ <> "" THEN GOTO errmes
IF result <> 0 THEN
ExecLevel(ExecCounter) = ExecLevel(ExecCounter - 1) 'So we inherit the execlevel from above
IF ExecLevel(ExecCounter) = 0 THEN DefineElse(ExecCounter) = DefineElse(ExecCounter) OR 4 'Else if used and conditon found
END IF
controllevel = controllevel + 1
controltype(controllevel) = 6
IF temp = 0 THEN layout$ = "$IF " + temp$ + " THEN": GOTO finishednonexec 'no = sign in the $IF statement, so we're going to assume the user is doing something like $IF flag
l$ = RTRIM$(LEFT$(temp$, temp - 1)): r$ = LTRIM$(MID$(temp$, temp + 1))
layout$ = "$IF " + l$ + " = " + r$ + " THEN"
GOTO finishednonexec
END IF
IF a3u$ = "$ELSE" THEN
IF DefineElse(ExecCounter) = 0 THEN a$ = "$ELSE without $IF": GOTO errmes
IF DefineElse(ExecCounter) AND 2 THEN a$ = "$IF block already has $ELSE statement in it": GOTO errmes
DefineElse(ExecCounter) = DefineElse(ExecCounter) OR 2 'set the flag to declare an $ELSE already in this block
IF DefineElse(ExecCounter) AND 4 THEN 'If we executed code in a previous IF or ELSE IF statement, we can't do it here
ExecLevel(ExecCounter) = -1 'So we inherit the execlevel from above
ELSE
ExecLevel(ExecCounter) = ExecLevel(ExecCounter - 1) 'If we were processing code before, code after this segment is going to be SKIPPED
END IF
layout$ = "$ELSE"
lhscontrollevel = lhscontrollevel - 1
GOTO finishednonexec
END IF
IF LEFT$(a3u$, 5) = "$ELSE" THEN
temp$ = LTRIM$(MID$(a3u$, 6))
IF LEFT$(temp$, 3) = "IF " THEN
IF DefineElse(ExecCounter) = 0 THEN a$ = "$ELSE IF without $IF": GOTO errmes
IF DefineElse(ExecCounter) AND 2 THEN a$ = "$ELSE IF cannot follow $ELSE": GOTO errmes
IF RIGHT$(temp$, 5) <> " THEN" THEN a$ = "$ELSE IF without THEN": GOTO errmes
temp$ = LTRIM$(MID$(temp$, 3)) 'strip off the IF and extra spaces
temp$ = RTRIM$(LEFT$(temp$, LEN(temp$) - 4)) 'and strip off the THEN and extra spaces
IF DefineElse(ExecCounter) AND 4 THEN 'If we executed code in a previous IF or ELSE IF statement, we can't do it here
ExecLevel(ExecCounter) = -1
ELSE
result = EvalPreIF(temp$, a$)
IF a$ <> "" THEN GOTO errmes
IF result <> 0 THEN
ExecLevel(ExecCounter) = ExecLevel(ExecCounter - 1) 'So we inherit the execlevel from above
IF ExecLevel(ExecCounter) = 0 THEN DefineElse(ExecCounter) = DefineElse(ExecCounter) OR 4 'Else if used and conditon found
END IF
END IF
lhscontrollevel = lhscontrollevel - 1
temp = INSTR(temp$, "=")
IF temp = 0 THEN layout$ = "$ELSEIF " + temp$ + " THEN": GOTO finishednonexec 'no = sign in the $IF statement, so we're going to assume the user is doing something like $IF flag
l$ = RTRIM$(LEFT$(temp$, temp - 1)): r$ = LTRIM$(MID$(temp$, temp + 1))
layout$ = "$ELSEIF " + l$ + " = " + r$ + " THEN"
GOTO finishednonexec
END IF
END IF
IF ExecLevel(ExecCounter) THEN 'don't check for any more metacommands except the one's which worth with the precompiler
layoutdone = 0
GOTO finishednonexec 'we don't check for anything inside lines that we've marked for skipping
END IF
IF LEFT$(a3u$, 5) = "$LET " THEN
temp$ = a3u$
temp$ = LTRIM$(MID$(temp$, 5)) 'simply shorten our string to parse
'For starters, let's make certain that we have 3 elements to deal with
temp = INSTR(temp$, "=") 'without an = in there, we can't get a value from the left and right side
l$ = RTRIM$(LEFT$(temp$, temp - 1)): r$ = LTRIM$(MID$(temp$, temp + 1))
layout$ = "$LET " + l$ + " = " + r$
'First look to see if we have an existing setting like this and if so, update it
FOR i = 7 TO UserDefineCount 'UserDefineCount 1-6 are reserved for automatic OS/BIT detection
IF UserDefine(0, i) = l$ THEN UserDefine(1, i) = r$: GOTO finishednonexec
NEXT
'Otherwise create a new setting and set the initial value for it
UserDefineCount = UserDefineCount + 1
IF UserDefineCount > UBOUND(UserDefine, 2) THEN
REDIM _PRESERVE UserDefine(1, UBOUND(UserDefine, 2) + 10) 'Add another 10 elements to the array so it'll expand as the user adds to it
END IF
UserDefine(0, UserDefineCount) = l$
UserDefine(1, UserDefineCount) = r$
GOTO finishednonexec
END IF
IF a3u$ = "$VIRTUALKEYBOARD:ON" THEN
'Deprecated; does nothing.