summaryrefslogtreecommitdiff
path: root/dynasm
diff options
context:
space:
mode:
authorMike Pall <mike>2012-02-17 11:40:18 +0100
committerMike Pall <mike>2012-02-17 11:40:18 +0100
commit6c05739684527919293e25668589f17c35a7c129 (patch)
treec77442560161b0b512533b84f865c1fee18bff48 /dynasm
parentff7139493196f8b43bc8912a9ea33d4d5e169796 (diff)
downloadluajit2-6c05739684527919293e25668589f17c35a7c129.tar.gz
DynASM: Lua 5.2 compatibility fixes.
Diffstat (limited to 'dynasm')
-rw-r--r--dynasm/dasm_x86.lua2
-rw-r--r--dynasm/dynasm.lua12
2 files changed, 11 insertions, 3 deletions
diff --git a/dynasm/dasm_x86.lua b/dynasm/dasm_x86.lua
index 13319285..3bebb83c 100644
--- a/dynasm/dasm_x86.lua
+++ b/dynasm/dasm_x86.lua
@@ -23,7 +23,7 @@ local _M = { _info = _info }
-- Cache library functions.
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 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
diff --git a/dynasm/dynasm.lua b/dynasm/dynasm.lua
index b89d6cfc..2ef81647 100644
--- a/dynasm/dynasm.lua
+++ b/dynasm/dynasm.lua
@@ -259,9 +259,17 @@ local condstack = {}
-- Evaluate condition with a Lua expression. Substitutions already performed.
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
- 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)
if ok then
if res == 0 then return false end -- Oh well.