1
0
Fork 0
mirror of https://github.com/suchmememanyskill/TegraExplorer.git synced 2024-11-22 20:06:43 +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; iter->gcDoNotFree = 1;
Variable_t* res = genericCallDirect(args[1], NULL, 0); Variable_t* res = genericCallDirect(args[1], NULL, 0);
if (res == NULL) if (res == NULL) {
return NULL; if (scriptLastError == SCRIPT_BREAK) {
break;
}
else {
return NULL;
}
}
} }
iter->reference = 1; iter->reference = 1;

View file

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

View file

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

View file

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

View file

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