-
Notifications
You must be signed in to change notification settings - Fork 12
/
main.cpp
35 lines (31 loc) · 911 Bytes
/
main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include <iostream>
#include <string>
#include "Decompiler/Decompile.h"
#include "lualib.h"
#include "Luau/Compiler.h"
namespace luau {
struct rbx_lua_bytecode_encoder : public Luau::BytecodeEncoder
{
uint8_t encodeOp(uint8_t op) override
{
return static_cast<std::uint8_t>(op);
};
};
std::string rbx_compile(const std::string &script) {
return Luau::compile(script, {0, 1, 0}, {}, {});
}
}
static void setupState(lua_State* L)
{
luaL_openlibs(L);
luaL_sandbox(L);
}
int main() {
auto bytecode = luau::rbx_compile("local black = lol(); print(black.lol.p:lmao())");
std::unique_ptr<lua_State, void (*)(lua_State*)> globalState(luaL_newstate(), lua_close);
lua_State* L = globalState.get();
setupState(L);
luaL_sandboxthread(L);
std::cout << Luau::Decompiler::decompile(L, bytecode) << std::endl;
return 0;
}