1
1
Fork 0
mirror of https://github.com/QB64-Phoenix-Edition/QB64pe.git synced 2024-07-01 15:00:38 +00:00

Adds $ASSERTS, $ASSERTS:CONSOLE and _ASSERT condition[, message$]

This commit is contained in:
FellippeHeitor 2020-01-01 18:20:30 -03:00
parent f1e26b2010
commit 49f265f1c2
4 changed files with 50 additions and 1 deletions

View file

@ -1396,6 +1396,7 @@ extern uint32 qbevent;
extern int32 console;
extern int32 screen_hide_startup;
extern int32 asserts;
//...
int64 exit_code=0;
@ -5426,10 +5427,25 @@ extern uint32 error_goto_line;
extern uint32 error_handling;
extern uint32 error_retry;
void sub__echo(qbs *message);
void sub__assert(int32 expression, qbs *assert_message, int32 passed) {
if (asserts==0) return;
if (expression==0) {
if (console==1 && passed==1) {
sub__echo(assert_message);
error(315);
return;
}
error(314);
}
return;
}
void fix_error(){
char *errtitle = NULL, *errmess = NULL, *cp;
int prevent_handling = 0, len, v;
if ((new_error >= 300) && (new_error <= 313)) prevent_handling = 1;
if ((new_error >= 300) && (new_error <= 315)) prevent_handling = 1;
if (!error_goto_line || error_handling || prevent_handling) {
switch (new_error) {
case 1: cp="NEXT without FOR"; break;
@ -5507,6 +5523,8 @@ void fix_error(){
case 311: cp="Destination memory not initialized"; break;
case 312: cp="Source and destination memory not initialized"; break;
case 313: cp="Source and destination memory have been freed"; break;
case 314: cp="_ASSERT failed"; break;
case 315: cp="_ASSERT failed (check console for description)"; break;
default: cp="Unprintable error"; break;
}

View file

@ -120,6 +120,7 @@ uint8**out_data,int32*out_x,int32 *out_y,int32*out_x_pre_increment,int32*out_x_p
extern void sub__title(qbs *title);
extern void sub__echo(qbs *message);
extern void sub__assert(int32 expression, qbs *assert_message, int32 passed);
extern void sub__finishdrop();
extern int32 func__filedrop();
extern void sub__filedrop(int32 on_off=NULL);

View file

@ -116,6 +116,7 @@ DIM SHARED NoChecks
DIM SHARED Console
DIM SHARED ScreenHide
DIM SHARED Asserts
DIM SHARED OptMax AS LONG
OptMax = 256
REDIM SHARED Opt(1 TO OptMax, 1 TO 10) AS STRING * 256
@ -1345,6 +1346,7 @@ HashAdd "WHILE", f, 0
'clear/init variables
Console = 0
ScreenHide = 0
Asserts = 0
ResolveStaticFunctions = 0
dynamiclibrary = 0
dimsfarray = 0
@ -3447,6 +3449,20 @@ DO
GOTO finishednonexec
END IF
IF a3u$ = "$ASSERTS" THEN
layout$ = "$ASSERTS"
Asserts = 1
GOTO finishednonexec
END IF
IF a3u$ = "$ASSERTS:CONSOLE" THEN
layout$ = "$ASSERTS:CONSOLE"
Asserts = 1
Console = 1
GOTO finishednonexec
END IF
IF a3u$ = "$SCREENHIDE" THEN
layout$ = "$SCREENHIDE"
ScreenHide = 1
@ -11365,6 +11381,12 @@ ELSE
PRINT #18, "int32 screen_hide_startup=0;"
END IF
IF Asserts THEN
PRINT #18, "int32 asserts=1;"
ELSE
PRINT #18, "int32 asserts=0;"
END IF
fh = FREEFILE
OPEN tmpdir$ + "dyninfo.txt" FOR APPEND AS #fh
IF Resize THEN

View file

@ -795,6 +795,14 @@ id.callname = "func__inclerrorline"
id.ret = LONGTYPE - ISPOINTER
regid
clearid
id.n = "_ASSERT"
id.subfunc = 2
id.callname = "sub__assert"
id.args = 2
id.specialformat = "?[,?]"
id.arg = MKL$(INTEGERTYPE - ISPOINTER) + MKL$(STRINGTYPE - ISPOINTER)
regid
clearid
id.n = "_DISPLAY"