-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.ts
33 lines (26 loc) · 964 Bytes
/
index.ts
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
import { spawn } from "child_process";
import { DeserializeLuau } from "./luauVM";
function GenByteCode(fileName: string): Promise<Buffer> // byte code
{
return new Promise((resolve, reject) => {
let luauCompiler = spawn("luau-compile", ["--binary", fileName]); // get the textual representation of the bytecode from the luau compiler
let byteCode = Buffer.from("");
luauCompiler.stdout.on("data", (data) => {
byteCode = Buffer.concat([byteCode, data]);
});
luauCompiler.stderr.on("data", (data) => {
console.error(data.toString());
});
luauCompiler.on("close", (code) => {
//console.log(`child process exited with code ${code}`);
console.log("LC > Bytecode compiled successfully");
resolve(byteCode);
});
})
}
async function main()
{
let byteCode = await GenByteCode("test.lua");
DeserializeLuau(byteCode);
}
main();