diff options
-rw-r--r-- | dynasm/dasm_x86.lua | 2 | ||||
-rw-r--r-- | dynasm/dynasm.lua | 12 |
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 } | |||
23 | 23 | ||
24 | -- Cache library functions. | 24 | -- Cache library functions. |
25 | local type, tonumber, pairs, ipairs = type, tonumber, pairs, ipairs | 25 | local type, tonumber, pairs, ipairs = type, tonumber, pairs, ipairs |
26 | local assert, unpack, setmetatable = assert, unpack, setmetatable | 26 | local assert, unpack, setmetatable = assert, unpack or table.unpack, setmetatable |
27 | local _s = string | 27 | local _s = string |
28 | local sub, format, byte, char = _s.sub, _s.format, _s.byte, _s.char | 28 | local sub, format, byte, char = _s.sub, _s.format, _s.byte, _s.char |
29 | local find, match, gmatch, gsub = _s.find, _s.match, _s.gmatch, _s.gsub | 29 | 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 = {} | |||
259 | 259 | ||
260 | -- Evaluate condition with a Lua expression. Substitutions already performed. | 260 | -- Evaluate condition with a Lua expression. Substitutions already performed. |
261 | local function cond_eval(cond) | 261 | local function cond_eval(cond) |
262 | local func, err = loadstring("return "..cond) | 262 | local func, err |
263 | if setfenv then | ||
264 | func, err = loadstring("return "..cond, "=expr") | ||
265 | else | ||
266 | -- No globals. All unknown identifiers evaluate to nil. | ||
267 | func, err = load("return "..cond, "=expr", "t", {}) | ||
268 | end | ||
263 | if func then | 269 | if func then |
264 | setfenv(func, {}) -- No globals. All unknown identifiers evaluate to nil. | 270 | if setfenv then |
271 | setfenv(func, {}) -- No globals. All unknown identifiers evaluate to nil. | ||
272 | end | ||
265 | local ok, res = pcall(func) | 273 | local ok, res = pcall(func) |
266 | if ok then | 274 | if ok then |
267 | if res == 0 then return false end -- Oh well. | 275 | if res == 0 then return false end -- Oh well. |