Skip to content

Commit 69bc72e

Browse files
committed
review修复:删除eval.dump的5.2 compat分支(undump不支持);pcall保护仅限目标VM的dump产物
1 parent eba327f commit 69bc72e

2 files changed

Lines changed: 22 additions & 30 deletions

File tree

extension/script/backend/worker/eval.lua

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -43,23 +43,9 @@ local function generate(name, init)
4343
end
4444

4545
generate("dump", function()
46-
if luaver.LUAVERSION <= 52 then
47-
local compat_dump = assert(load(readfile 'backend.worker.eval.dump'))
48-
return function(content)
49-
local ok, res, err = pcall(compat_dump, content)
50-
if ok and res ~= nil then
51-
return true, res
52-
end
53-
if ok then
54-
return false, 'can not dump function.'
55-
end
56-
return false, res
57-
end
58-
else
59-
local eval_dump = assert(rdebug.load(readfile 'backend.worker.eval.dump'))
60-
return function(content)
61-
return rdebug.eval(eval_dump, content, 0)
62-
end
46+
local eval_dump = assert(rdebug.load(readfile 'backend.worker.eval.dump'))
47+
return function(content)
48+
return rdebug.eval(eval_dump, content, 0)
6349
end
6450
end)
6551

extension/script/backend/worker/parser.lua

Lines changed: 19 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -96,25 +96,31 @@ end
9696
return function (content, syntaxCompatibility)
9797
local err
9898
local bin
99+
local cl, v
99100
if syntaxCompatibility then
100101
bin, err = dumpTarget(content)
102+
if not bin then
103+
local log = require 'common.log'
104+
log.error("ERROR:"..(err or "unknown error"))
105+
return
106+
end
107+
local ok
108+
ok, cl, v = pcall(undump, bin)
109+
if not ok then
110+
local log = require 'common.log'
111+
log.error("ERROR:"..tostring(cl))
112+
return
113+
end
101114
else
102115
local f
103116
f, err = load(content)
104-
if f then
105-
bin = string.dump(f)
117+
if not f then
118+
local log = require 'common.log'
119+
log.error("ERROR:"..(err or "unknown error"))
120+
return
106121
end
107-
end
108-
if not bin then
109-
local log = require 'common.log'
110-
log.error("ERROR:"..(err or "unknown error"))
111-
return
112-
end
113-
local ok, cl, v = pcall(undump, bin)
114-
if not ok then
115-
local log = require 'common.log'
116-
log.error("ERROR:"..tostring(cl))
117-
return
122+
bin = string.dump(f)
123+
cl, v = undump(bin)
118124
end
119125
version = v
120126
local si = { activelines = {}, definelines = {} }

0 commit comments

Comments
 (0)