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.lua | |
| 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.lua')
| -rw-r--r-- | bootstrap.lua | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/bootstrap.lua b/bootstrap.lua index 844bcca..10d6f3b 100644 --- a/bootstrap.lua +++ b/bootstrap.lua @@ -38,7 +38,6 @@ compile_error = function(source, err_msg, hint) return error(err_str, 0) end local MAX_LINE = 80 -local ENVNAME = jit and "_G" or "_ENV" local compile_actions = { [""] = function(self, fn, ...) local lua = LuaCode() @@ -118,16 +117,16 @@ local compile_actions = { })) end, ["1 as lua"] = function(self, code) - return LuaCode(tostring(ENVNAME) .. ":compile(", self:compile(code), ")") + return LuaCode("_ENV:compile(", self:compile(code), ")") end, ["use"] = function(self, path) - return LuaCode(tostring(ENVNAME) .. ":use(" .. tostring(self:compile(path)) .. ")") + return LuaCode("_ENV:use(" .. tostring(self:compile(path)) .. ")") end, ["export"] = function(self, path) - return LuaCode(tostring(ENVNAME) .. ":export(" .. tostring(self:compile(path)) .. ")") + return LuaCode("_ENV:export(" .. tostring(self:compile(path)) .. ")") end, ["run"] = function(self, path) - return LuaCode(tostring(ENVNAME) .. ":run(" .. tostring(self:compile(path)) .. ")") + return LuaCode("_ENV:run(" .. tostring(self:compile(path)) .. ")") end, ["test"] = function(self, body) if not (body.type == 'Block') then @@ -154,10 +153,10 @@ local compile_actions = { return LuaCode("_VERSION") end, ["nomsu environment"] = function(self) - return LuaCode(ENVNAME) + return LuaCode("_ENV") end, ["nomsu environment name"] = function(self) - return LuaCode(ENVNAME:as_lua()) + return LuaCode('"_ENV"') end } return compile_actions |
