1 -- This only serves in the bootstrapping process, it isn't
2 -- included in the final compiler. When compiled with std.lua,
3 -- mlp and bytecode modules, it is able to compile metalua
4 -- sources into .luac bytecode files.
5 -- It allows to precompile files such as
7 print ' *** LOAD BOOTSTRAP with fake MLC'
16 function mlc.function_of_ast (ast)
17 local proto = bytecode.metalua_compile (ast)
18 local dump = bytecode.dump_string (proto)
19 local func = undump(dump)
23 local function compile_file (src_filename)
24 local src_file = io.open (src_filename, 'r')
25 local src = src_file:read '*a'; src_file:close()
26 local lx = mlp.lexer:newstream (src)
27 local ast = mlp.chunk (lx)
28 local proto = bytecode.metalua_compile (ast)
29 local dump = bytecode.dump_string (proto)
30 local dst_filename = src_filename:gsub ("%.mlua$", ".luac")
31 local dst_file = io.open (dst_filename, 'wb')
37 for _, x in ipairs{...} do compile_file (x) end