反编译 Lua 中的 _UPVALUE0_ 关键字是什么?
What are _UPVALUE0_ keywords in decompiled Lua?
我已经反编译了一些lua代码,能够理解其中的大部分。
但是有这些 UPVALUE0, UPVALUE1, 等等...我在代码中看到的关键字目前没有在任何地方定义正如我所看到的。
这是一个例子:
local L0_0
L0_0 = module
L0_0((...), package.seeall)
function L0_0(A0_1)
if A0_1 - math.floor(A0_1) > 0 then
error("trying to use bitwise operation on non-integer!")
end
end
bit = {
bxor = function(A0_17, A1_18)
local L2_19, L3_20, L4_21, L5_22
L2_19 = _UPVALUE0_
L3_20 = A0_17
L2_19 = L2_19(L3_20)
L3_20 = _UPVALUE0_
L4_21 = A1_18
L3_20 = L3_20(L4_21)
L4_21 = _UPVALUE1_
L5_22 = L2_19
L4_21(L5_22, L3_20)
L4_21 = {}
L5_22 = math
L5_22 = L5_22.max
L5_22 = L5_22(table.getn(L2_19), table.getn(L3_20))
for _FORV_9_ = 1, L5_22 do
if L2_19[_FORV_9_] ~= L3_20[_FORV_9_] then
L4_21[_FORV_9_] = 1
else
L4_21[_FORV_9_] = 0
end
end
return _UPVALUE2_(L4_21)
end
}
它们是什么意思?
来自https://www.lua.org/pil/6.1.html:
.. is neither a global variable nor a local variable. We call it an
external local variable, or an upvalue. (The term "upvalue" is a
little misleading, because it is a variable, not a value. However,
this term has historical roots in Lua and it is shorter than "external
local variable".)
local i = 0
function inc()
i = i + 1
return i
end
函数inc
中的变量i
是upvalue,因为它不是这个函数中的局部变量,也不是全局变量。
我已经反编译了一些lua代码,能够理解其中的大部分。
但是有这些 UPVALUE0, UPVALUE1, 等等...我在代码中看到的关键字目前没有在任何地方定义正如我所看到的。
这是一个例子:
local L0_0
L0_0 = module
L0_0((...), package.seeall)
function L0_0(A0_1)
if A0_1 - math.floor(A0_1) > 0 then
error("trying to use bitwise operation on non-integer!")
end
end
bit = {
bxor = function(A0_17, A1_18)
local L2_19, L3_20, L4_21, L5_22
L2_19 = _UPVALUE0_
L3_20 = A0_17
L2_19 = L2_19(L3_20)
L3_20 = _UPVALUE0_
L4_21 = A1_18
L3_20 = L3_20(L4_21)
L4_21 = _UPVALUE1_
L5_22 = L2_19
L4_21(L5_22, L3_20)
L4_21 = {}
L5_22 = math
L5_22 = L5_22.max
L5_22 = L5_22(table.getn(L2_19), table.getn(L3_20))
for _FORV_9_ = 1, L5_22 do
if L2_19[_FORV_9_] ~= L3_20[_FORV_9_] then
L4_21[_FORV_9_] = 1
else
L4_21[_FORV_9_] = 0
end
end
return _UPVALUE2_(L4_21)
end
}
它们是什么意思?
来自https://www.lua.org/pil/6.1.html:
.. is neither a global variable nor a local variable. We call it an external local variable, or an upvalue. (The term "upvalue" is a little misleading, because it is a variable, not a value. However, this term has historical roots in Lua and it is shorter than "external local variable".)
local i = 0
function inc()
i = i + 1
return i
end
函数inc
中的变量i
是upvalue,因为它不是这个函数中的局部变量,也不是全局变量。