diff options
| author | Bruce Hill <bruce@bruce-hill.com> | 2019-01-11 15:27:11 -0800 |
|---|---|---|
| committer | Bruce Hill <bruce@bruce-hill.com> | 2019-01-11 15:27:41 -0800 |
| commit | 43e45b145279946f01876efe36e0e7acad4ce8c3 (patch) | |
| tree | 29ea5f774bc7299a7b4eba65cdadf190f6c12a20 /bootstrap.moon | |
| parent | 0f0fb2256a46a8808794d7d4746d112278da3730 (diff) | |
Tweaked code to use both _ENV and _G for better compatibility of
precompiled Lua between Lua 5.2+ and LuaJIT
Diffstat (limited to 'bootstrap.moon')
| -rw-r--r-- | bootstrap.moon | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/bootstrap.moon b/bootstrap.moon index 66c8553..f5b5900 100644 --- a/bootstrap.moon +++ b/bootstrap.moon @@ -24,8 +24,6 @@ compile_error = (source, err_msg, hint=nil)-> error(err_str, 0) MAX_LINE = 80 -- For beautification purposes, try not to make lines much longer than this value ---ENVNAME = jit and "getfenv(1)" or "_ENV" -ENVNAME = jit and "_G" or "_ENV" compile_actions = { [""]: (fn, ...)=> lua = LuaCode! @@ -96,16 +94,16 @@ compile_actions = { @compile(SyntaxTree{type:"Action", "lua", ">", code}) ["1 as lua"]: (code)=> - LuaCode("#{ENVNAME}:compile(", @compile(code), ")") + LuaCode("_ENV:compile(", @compile(code), ")") ["use"]: (path)=> - LuaCode("#{ENVNAME}:use(#{@compile(path)})") + LuaCode("_ENV:use(#{@compile(path)})") ["export"]: (path)=> - LuaCode("#{ENVNAME}:export(#{@compile(path)})") + LuaCode("_ENV:export(#{@compile(path)})") ["run"]: (path)=> - LuaCode("#{ENVNAME}:run(#{@compile(path)})") + LuaCode("_ENV:run(#{@compile(path)})") ["test"]: (body)=> unless body.type == 'Block' @@ -118,8 +116,8 @@ compile_actions = { ["is jit"]: (code)=> LuaCode("jit") ["Lua version"]: (code)=> LuaCode("_VERSION") - ["nomsu environment"]: ()=> LuaCode(ENVNAME) - ["nomsu environment name"]: ()=> LuaCode(ENVNAME\as_lua!) + ["nomsu environment"]: ()=> LuaCode("_ENV") + ["nomsu environment name"]: ()=> LuaCode('"_ENV"') } return compile_actions |
