]> git.lizzy.rs Git - metalua.git/blobdiff - src/lib/metalua/package2.lua
changed package loader and metalua compiler: instead of running compilations in separ...
[metalua.git] / src / lib / metalua / package2.lua
index 8c765d1ccaf311d379e7970bc4e38080b7eff201..7ab8abc4aab62f49563d016fe88d8321d2df3990 100644 (file)
@@ -45,24 +45,17 @@ end
 
 
 ----------------------------------------------------------------------
--- Execute a metalua module sources compilation in a separate ring.
+-- Execute a metalua module sources compilation in a separate process
 ----------------------------------------------------------------------
 local function spring_load(filename)
-   local env_fast = os.getenv 'LUA_NOSPRINGS'
-
-   if env_fast=='yes' or env_fast=='true' then
-      --print "LUA_NOSPRINGS mode"
-      return mlc.function_of_luafile(filename)
-   else
-      -- run compilation in a separate spring universe:
-      --print "Springs mode"
-      require 'springs'
-      local r = springs.new()
-      r:dostring [[require 'metalua.compiler']]
-      local f = r:call('mlc.function_of_luafile', filename)
-      r:close()
-      return f
-   end
+   local pattern = 
+      [[lua -l metalua.mlc -l -e "print(mlc.luacstring_of_luafile('%s', '%s'))"]]
+   local cmd = string.format (pattern, f, filename, filename)
+   print ("running command: ``" .. cmd .. "''")
+   local fd = io.popen (cmd)
+   local bytecode = fd:read '*a'
+   fd:close()
+   return string.undump (bytecode)
 end
 
 ----------------------------------------------------------------------