Ver código fonte

DynASM: Lua 5.2 compatibility fixes.

Mike Pall 13 anos atrás
pai
commit
6c05739684
2 arquivos alterados com 11 adições e 3 exclusões
  1. 1 1
      dynasm/dasm_x86.lua
  2. 10 2
      dynasm/dynasm.lua

+ 1 - 1
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

+ 10 - 2
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.