require 'metalua.compiler'
require 'metalua.clopts'
-require 'serialize'
+require 'metalua.mlc_xcall'
AST_COMPILE_ERROR_NUMBER = -1
RUNTIME_ERROR_NUMBER = -3
-{ extension 'match' }
-function spring_pcall (f, arg, name)
- local pattern =
- [=[lua -l metalua.compiler -l serialize -e ]=]..
- [=["print (serialize (%s ([[%s]], [[%s]])))"]=]
- local cmd = string.format (pattern, f, arg, name)
- --print ("Running the following process: " .. cmd)
- local fd = io.popen (cmd)
- local ast_src = fd:read '*a'
- fd:close()
- --print (data)
- local ast_builder, msg = lua_loadstring(ast_src)
- if not ast_builder then
- error ("can't compile data: "..msg)
- print (ast_src)
- end
- local ast = ast_builder()
- return true, ast
-end
-
local chunks = { }
local runargs = { }
local st, ast
match x with
| `Library{ l } -> st, ast = true, `Call{ `Id 'require', `String{ l } }
- | `Literal{ e } -> st, ast = spring_pcall('mlc.ast_of_luastring', e, 'literal')
+ | `Literal{ e } -> st, ast = mlc_xcall.client_literal (e)
| `File{ f } ->
- st, ast = spring_pcall('mlc.ast_of_luafile', f, '@'..f)
- -- Isolate each file in a separate fenv
+ st, ast = mlc_xcall.client_file (f)
+ -- Isolate each file in a separate fenv
if st then
ast = +{ function (...) -{ast} end (...) }
ast.source = '@'..f -- TODO [EVE]