From cf99f38bcf5037c8052f4c806dd9ace49a3741d6 Mon Sep 17 00:00:00 2001 From: FellippeHeitor Date: Wed, 28 Jun 2017 22:47:17 -0300 Subject: [PATCH] Add _CONTINUE, to jump to the end of FOR..NEXT/DO..LOOP/WHILE..WEND blocks. --- source/qb64.bas | 28 +++++++++++++++++++++++- source/subs_functions/subs_functions.bas | 2 ++ 2 files changed, 29 insertions(+), 1 deletion(-) diff --git a/source/qb64.bas b/source/qb64.bas index 582a6025a..7306ecee5 100644 --- a/source/qb64.bas +++ b/source/qb64.bas @@ -5471,6 +5471,7 @@ DO simplenext: 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)) + ":;" PRINT #12, "}" PRINT #12, "fornext_exit_" + str2$(controlid(controllevel)) + ":;" controllevel = controllevel - 1 @@ -5526,6 +5527,7 @@ DO IF controltype(controllevel) <> 5 THEN a$ = "WEND without WHILE": GOTO errmes + PRINT #12, "ww_continue_" + str2$(controlid(controllevel)) + ":;" PRINT #12, "}" PRINT #12, "ww_exit_" + str2$(controlid(controllevel)) + ":;" controllevel = controllevel - 1 @@ -5593,8 +5595,10 @@ DO IF Error_Happened THEN GOTO errmes IF stringprocessinghappened THEN e$ = cleanupstringprocessingcall$ + e$ + ")" IF (typ AND ISSTRING) THEN a$ = "LOOP ERROR! Cannot accept a STRING type.": GOTO errmes + PRINT #12, "dl_continue_" + str2$(controlid(controllevel)) + ":;" 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 controltype(controllevel) = 4 THEN PRINT #12, "}" ELSE @@ -8260,7 +8264,29 @@ DO END IF END IF - + IF n = 1 THEN + IF firstelement$ = "_CONTINUE" THEN + l$ = "_CONTINUE" + 'scan backwards until previous control level reached + FOR i = controllevel TO 1 STEP -1 + t = controltype(i) + IF t = 2 THEN 'for...next + PRINT #12, "goto fornext_continue_" + str2$(controlid(i)) + ";" + layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ + GOTO finishedline + ELSEIF t = 3 OR t = 4 THEN 'do...loop + PRINT #12, "goto dl_continue_" + str2$(controlid(i)) + ";" + layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ + GOTO finishedline + ELSEIF t = 5 THEN 'while...wend + PRINT #12, "goto ww_continue_" + str2$(controlid(i)) + ";" + layoutdone = 1: IF LEN(layout$) THEN layout$ = layout$ + sp + l$ ELSE layout$ = l$ + GOTO finishedline + END IF + NEXT + a$ = "_CONTINUE outside DO..LOOP/FOR..NEXT/WHILE..WEND block": GOTO errmes + END IF + END IF IF firstelement$ = "RUN" THEN 'RUN l$ = "RUN" diff --git a/source/subs_functions/subs_functions.bas b/source/subs_functions/subs_functions.bas index b97b24175..5f648a7c5 100644 --- a/source/subs_functions/subs_functions.bas +++ b/source/subs_functions/subs_functions.bas @@ -78,6 +78,8 @@ clearid id.n = "_MEMPUT": id.subfunc = 2: id.callname = "sub_stub": regid clearid id.n = "_MEMFILL": id.subfunc = 2: id.callname = "sub_stub": regid +clearid +id.n = "_CONTINUE": id.subfunc = 2: id.callname = "sub_stub": regid clearid