1
0
Fork 0
mirror of https://github.com/suchmememanyskill/TegraExplorer.git synced 2024-11-26 05:42:07 +00:00
TegraExplorer/source/script/ABadIdeaVersion3.c

91 lines
2.2 KiB
C
Raw Normal View History

2021-07-09 21:56:13 +01:00
#ifdef WIN32
#include <stdio.h>
#include "compat.h"
#include "parser.h"
#include "intClass.h"
#include "StringClass.h"
#include "eval.h"
#include "garbageCollector.h"
// TODO: error handling DONE
// TODO: unsolved arrays
// TODO: free-ing vars & script at end
// TODO: implement functions from tsv2
// TODO: add len to string
// TODO: clear old int values from array DONE
// TODO: int and str should be statically included in OP_t DONE
char* readFile(char* path) {
FILE* fp = fopen(path, "r");
if (fp == NULL)
return NULL;
fseek(fp, 0L, SEEK_END);
size_t size = ftell(fp);
fseek(fp, 0L, SEEK_SET);
char* ret = calloc(size + 1, 1);
fread(ret, size, 1, fp);
fclose(fp);
return ret;
}
int main()
{
//gfx_printf("Hello world!\n");
//StartParse("a b c de 0x1 0x10 \"yeet\" + + ");
/*
Variable_t b = newStringVariable("Hello world\n", 1, 0);
callClass("__print__", &b, NULL, NULL);
Variable_t a = newIntVariable(69, 0);
Variable_t c = newIntVariable(1, 0);
Variable_t e = newStringVariable("snake", 1, 0);
Vector_t fuk = newVec(sizeof(Variable_t), 1);
vecAdd(&fuk, c);
Variable_t *d = callClass("+", &a, NULL, &fuk);
callClass("__print__", d, NULL, NULL);
*/
/*
Vector_t v = newVec(sizeof(int), 4);
int a = 69;
vecAdd(&v, a);
vecAdd(&v, a);
vecAdd(&v, a);
vecAdd(&v, a);
vecForEach(int*, b, (&v))
printf("%d\n", *b);
return;
*/
char* script = readFile("input.te");
if (script == NULL)
return;
//parseScript("#REQUIRE VER 3.0.5\nmain = { two = 1 + 1 }");
//ParserRet_t ret = parseScript("a.b.c(1){ a.b.c() }");
2021-07-23 13:03:49 +01:00
//while (1) {
2021-07-23 00:10:03 +01:00
ParserRet_t ret = parseScript(script, strlen(script));
2021-07-09 21:56:13 +01:00
2021-07-23 00:10:03 +01:00
setStaticVars(&ret.staticVarHolder);
initRuntimeVars();
2021-07-09 21:56:13 +01:00
2021-07-23 00:10:03 +01:00
Variable_t* res = eval(ret.main.operations.data, ret.main.operations.count, 1);
2021-07-09 21:56:13 +01:00
2021-07-23 00:10:03 +01:00
exitRuntimeVars();
exitStaticVars(&ret.staticVarHolder);
exitFunction(ret.main.operations.data, ret.main.operations.count);
vecFree(ret.staticVarHolder);
vecFree(ret.main.operations);
2021-07-23 13:03:49 +01:00
//}
2021-07-23 00:10:03 +01:00
free(script);
2021-07-09 21:56:13 +01:00
gfx_printf("done");
}
#endif