1
0
Fork 0
mirror of https://github.com/suchmememanyskill/TegraExplorer.git synced 2024-11-08 13:11:54 +00:00

add break

This commit is contained in:
suchmememanyskill 2021-07-10 14:45:09 +02:00
parent 91af9b4437
commit 0bef41c033
5 changed files with 28 additions and 6 deletions

View file

@ -113,8 +113,14 @@ ClassFunction(arrayForEach) {
iter->gcDoNotFree = 1;
Variable_t* res = genericCallDirect(args[1], NULL, 0);
if (res == NULL)
return NULL;
if (res == NULL) {
if (scriptLastError == SCRIPT_BREAK) {
break;
}
else {
return NULL;
}
}
}
iter->reference = 1;

View file

@ -420,7 +420,6 @@ ParserRet_t parseScript(char* in) {
op.token = EquationSeperator;
op.lineNumber = lineNumber;
vecAdd(&lastFunc->operations, op);
}
else {
SCRIPT_PARSER_ERR("Stack count is 1 or state is not a function");

View file

@ -3,10 +3,11 @@
#include <stdarg.h>
s64 scriptCurrentLine;
u8 scriptLastError = 0;
void printScriptError(u8 errLevel, char* message, ...) {
va_list args;
scriptLastError = errLevel;
va_start(args, message);
gfx_printf("\n\n[%s] ", (errLevel == SCRIPT_FATAL) ? "FATAL" : (errLevel == SCRIPT_PARSER_FATAL) ? "PARSE_FATAL" : "WARN");
gfx_vprintf(message, args);

View file

@ -5,9 +5,11 @@ enum {
SCRIPT_FATAL = 0,
SCRIPT_PARSER_FATAL,
SCRIPT_WARN,
SCRIPT_BREAK,
};
extern s64 scriptCurrentLine;
extern u8 scriptLastError;
void printScriptError(u8 errLevel, char* message, ...);

View file

@ -5,6 +5,7 @@
#include "garbageCollector.h"
#include "intClass.h"
#include "standardLibrary.h"
#include "scriptError.h"
#include <string.h>
#ifndef WIN32
@ -37,8 +38,14 @@ ClassFunction(stdWhile) {
while (result->integer.value) {
removePendingReference(result);
Variable_t* res = genericCallDirect(args[1], NULL, 0);
if (res == NULL)
return NULL;
if (res == NULL) {
if (scriptLastError == SCRIPT_BREAK) {
break;
}
else {
return NULL;
}
}
removePendingReference(res);
@ -67,6 +74,11 @@ ClassFunction(stdExit) {
return NULL;
}
ClassFunction(stdBreak) {
scriptLastError = SCRIPT_BREAK;
return NULL;
}
#ifndef WIN32
ClassFunction(stdMountSysmmc){
if (connectMMC(MMC_CONN_EMMC))
@ -108,6 +120,7 @@ enum standardFunctionIndexes {
STD_MOUNTSYSMMC,
STD_MOUNTSAVE,
STD_EXIT,
STD_BREAK,
};
u8 oneIntoneFunction[] = { IntClass, FunctionClass };
@ -121,6 +134,7 @@ ClassFunctionTableEntry_t standardFunctionDefenitions[] = {
[STD_MOUNTSYSMMC] = {"mountsys", stdMountSysmmc, 1, oneStringArgStd},
[STD_MOUNTSAVE] = {"readsave", stdMountSave, 1, oneStringArgStd},
[STD_EXIT] = {"exit", stdExit, 0, 0},
[STD_BREAK] = {"break", stdBreak, 0, 0},
};
ClassFunctionTableEntry_t* searchStdLib(char* funcName) {