mirror of
https://github.com/LuaJIT/LuaJIT.git
synced 2025-02-07 15:14:08 +00:00
DynASM: Lua 5.2 compatibility fixes.
This commit is contained in:
parent
ff71394931
commit
6c05739684
@ -23,7 +23,7 @@ local _M = { _info = _info }
|
|||||||
|
|
||||||
-- Cache library functions.
|
-- Cache library functions.
|
||||||
local type, tonumber, pairs, ipairs = type, tonumber, pairs, ipairs
|
local type, tonumber, pairs, ipairs = type, tonumber, pairs, ipairs
|
||||||
local assert, unpack, setmetatable = assert, unpack, setmetatable
|
local assert, unpack, setmetatable = assert, unpack or table.unpack, setmetatable
|
||||||
local _s = string
|
local _s = string
|
||||||
local sub, format, byte, char = _s.sub, _s.format, _s.byte, _s.char
|
local sub, format, byte, char = _s.sub, _s.format, _s.byte, _s.char
|
||||||
local find, match, gmatch, gsub = _s.find, _s.match, _s.gmatch, _s.gsub
|
local find, match, gmatch, gsub = _s.find, _s.match, _s.gmatch, _s.gsub
|
||||||
|
@ -259,9 +259,17 @@ local condstack = {}
|
|||||||
|
|
||||||
-- Evaluate condition with a Lua expression. Substitutions already performed.
|
-- Evaluate condition with a Lua expression. Substitutions already performed.
|
||||||
local function cond_eval(cond)
|
local function cond_eval(cond)
|
||||||
local func, err = loadstring("return "..cond)
|
local func, err
|
||||||
|
if setfenv then
|
||||||
|
func, err = loadstring("return "..cond, "=expr")
|
||||||
|
else
|
||||||
|
-- No globals. All unknown identifiers evaluate to nil.
|
||||||
|
func, err = load("return "..cond, "=expr", "t", {})
|
||||||
|
end
|
||||||
if func then
|
if func then
|
||||||
setfenv(func, {}) -- No globals. All unknown identifiers evaluate to nil.
|
if setfenv then
|
||||||
|
setfenv(func, {}) -- No globals. All unknown identifiers evaluate to nil.
|
||||||
|
end
|
||||||
local ok, res = pcall(func)
|
local ok, res = pcall(func)
|
||||||
if ok then
|
if ok then
|
||||||
if res == 0 then return false end -- Oh well.
|
if res == 0 then return false end -- Oh well.
|
||||||
|
Loading…
Reference in New Issue
Block a user