<commit_before>#ifdef JIT
#include <stub_ffi.h>
#endif

#include <lua.h>
#include <lualib.h>
#include <lauxlib.h>

#include <psp2/kernel/processmgr.h>
#include <psp2/kernel/threadmgr.h>
#include <debugnet.h>
#include <vita2d.h>

int panic(lua_State *l)
{
	debugNetPrintf(DEBUG, "Lua paniced with '%s!'\n", lua_tostring(l, -1));
	sceKernelExitProcess(0);
	return 0;
}

int print(lua_State *l)
{
	debugNetPrintf(DEBUG, "[Lua] %s\n", lua_tostring(l, -1));
	return 0;
}

int os_sleep(lua_State *l)
{
	sceKernelDelayThread((unsigned int)(luaL_checknumber(l, 1) * 1000000));
	return 0;
}

void test()
{
	debugNetPrintf(DEBUG, "Hello, C!\n");
}

#ifdef JIT
void open_ffi(lua_State *l);
#else
void open_vita2d(lua_State *l);
void open_input(lua_State *l);
void open_http(lua_State *l);
#endif

int main()
{
	#ifdef JIT
		Function funcs[] = 
		{
			{"test", test},
			{NULL, NULL}
		};
		FunctionTable table = { .funcs = funcs, .next = NULL };
		ffi_add_table(&table);
	#endif

	debugNetInit(DEBUGGER_IP, DEBUGGER_PORT, DEBUG);
	debugNetPrintf(DEBUG, "creating\n");
	lua_State *lua = luaL_newstate();
	lua_atpanic(lua, panic);

	luaL_openlibs(lua);
	#ifdef JIT
	open_ffi(lua);
	#else
	open_vita2d(lua);
	open_input(lua);
	open_http(lua);
	#endif

	lua_pushcfunction(lua, print);
	lua_setglobal(lua, "print");
	
	lua_getglobal(lua, "os");
	lua_pushstring(lua, "sleep");
	lua_pushcfunction(lua, os_sleep);
	lua_rawset(lua, -3);
	lua_pop(lua, 1);

	if(luaL_loadfile(lua, "cache0:/VitaDefilerClient/Documents/script.lua") == 0)
	{
		if(lua_pcall(lua, 0, 0, 0) != 0)
		{
			debugNetPrintf(DEBUG, "err: %s\n", lua_tostring(lua, -1));
		}
	}
	else
	{
		debugNetPrintf(DEBUG, "error calling loadfile\n");
	}
	
	sceKernelExitProcess(0);
	return 0;
}<commit_msg>remove debugging code<commit_after>#ifdef JIT
#include <stub_ffi.h>
#endif

#include <lua.h>
#include <lualib.h>
#include <lauxlib.h>

#include <psp2/kernel/processmgr.h>
#include <psp2/kernel/threadmgr.h>
#include <debugnet.h>
#include <vita2d.h>

int panic(lua_State *l)
{
	debugNetPrintf(DEBUG, "Lua paniced with '%s!'\n", lua_tostring(l, -1));
	sceKernelExitProcess(0);
	return 0;
}

int print(lua_State *l)
{
	debugNetPrintf(DEBUG, "[Lua] %s\n", lua_tostring(l, -1));
	return 0;
}

#ifdef JIT
void open_ffi(lua_State *l);
#else
void open_vita2d(lua_State *l);
void open_input(lua_State *l);
void open_http(lua_State *l);
#endif

int main()
{
	debugNetInit(DEBUGGER_IP, DEBUGGER_PORT, DEBUG);
	debugNetPrintf(DEBUG, "creating\n");
	lua_State *lua = luaL_newstate();
	lua_atpanic(lua, panic);

	luaL_openlibs(lua);
	#ifdef JIT
	open_ffi(lua);
	#else
	open_vita2d(lua);
	open_input(lua);
	open_http(lua);
	#endif

	lua_pushcfunction(lua, print);
	lua_setglobal(lua, "print");
	
	if(luaL_loadfile(lua, "cache0:/VitaDefilerClient/Documents/script.lua") == 0)
	{
		if(lua_pcall(lua, 0, 0, 0) != 0)
		{
			debugNetPrintf(DEBUG, "err: %s\n", lua_tostring(lua, -1));
		}
	}
	else
	{
		debugNetPrintf(DEBUG, "error calling loadfile\n");
	}
	
	sceKernelExitProcess(0);
	return 0;
}
{'fraction_non_alphanumeric': 0.16931742876076872, 'fraction_numerical': 0.016235917826375082, 'mean_word_length': 5.355789473684211, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1713674', 'n_tokens_mistral': 1395, 'n_tokens_neox': 1341, 'n_words': 250}