]> git.lizzy.rs Git - metalua.git/blobdiff - src/compiler/metalua.mlua
Merge branch 'master' of git@github.com:fab13n/metalua into cleanup
[metalua.git] / src / compiler / metalua.mlua
index 0620638f7e02490b1082dbb135412e56f2a3f1aa..3c3564d0c37b167e47cf329f27cde1ae0ad92d63 100644 (file)
@@ -4,7 +4,7 @@
 
 require 'metalua.compiler'
 require 'metalua.clopts'
-require 'serialize'
+require 'metalua.mlc_xcall'
 
 AST_COMPILE_ERROR_NUMBER        = -1
 RUNTIME_ERROR_NUMBER            = -3
@@ -12,25 +12,6 @@ BYTECODE_SYNTHESE_ERROR_NUMBER  = -100
 
 -{ 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 = { }
 
@@ -156,10 +137,10 @@ local function main (...)
       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]