diff options
-rw-r--r-- | main-beta.lua | 1 | ||||
-rw-r--r-- | script-beta/parser/guide.lua | 93 |
2 files changed, 51 insertions, 43 deletions
diff --git a/main-beta.lua b/main-beta.lua index 1d1eecae..424ecd14 100644 --- a/main-beta.lua +++ b/main-beta.lua @@ -5,6 +5,7 @@ local fs = require 'bee.filesystem' ROOT = fs.path(rootPath) LANG = LANG or 'en-US' +debug.setcstacklimit(500) collectgarbage('generational', 10, 50) --collectgarbage('incremental', 120, 120, 0) diff --git a/script-beta/parser/guide.lua b/script-beta/parser/guide.lua index faa77745..9f479f17 100644 --- a/script-beta/parser/guide.lua +++ b/script-beta/parser/guide.lua @@ -1439,47 +1439,13 @@ function m.checkSameSimpleAsSetValue(status, ref, start, queue) end end -function m.checkSameSimple(status, simple, data, mode, results, queue) - local ref = data.obj - local start = data.start - local force = data.force - local isCall = data.call - for i = start, #simple do - local sm = simple[i] - if sm ~= '*' and not force and m.getSimpleName(ref) ~= sm then - return - end - force = false - local cmode = mode - if i < #simple then - cmode = 'ref' - end - -- 穿透 self:func 与 mt:func - m.searchSameFieldsCrossMethod(status, ref, i, queue) - -- 穿透赋值 - m.searchSameFieldsInValue(status, ref, i, queue, cmode) - -- 检查形如 a = f() 的分支情况,需要业务层传入 interface.call - m.checkSameSimpleInCall(status, ref, i, queue, mode) - if cmode ~= 'def' then - -- 检查形如 { a = f } 的情况 - m.checkSameSimpleAsTableField(status, ref, i, queue) - -- 检查形如 return m 的情况 - m.checkSameSimpleAsReturn(status, ref, i, queue) - -- 检查形如 a = f 的情况 - m.checkSameSimpleAsSetValue(status, ref, i, queue) - end - if i == #simple then - break - end - -- 检查形如 a = {} 的分支情况 - m.checkSameSimpleInBranch(status, ref, i, queue) - ref = m.getNextRef(ref) - if not ref then +function m.pushResult(status, mode, ref, isCall) + local results = status.results + if mode == 'def' then + if isCall then + results[#results+1] = ref return end - isCall = false - end - if mode == 'def' then if ref.type == 'setglobal' or ref.type == 'setlocal' or ref.type == 'local' then @@ -1497,10 +1463,11 @@ function m.checkSameSimple(status, simple, data, mode, results, queue) results[#results+1] = ref end end + elseif mode == 'ref' then if isCall then results[#results+1] = ref + return end - elseif mode == 'ref' then if ref.type == 'setfield' or ref.type == 'getfield' or ref.type == 'tablefield' then @@ -1526,9 +1493,6 @@ function m.checkSameSimple(status, simple, data, mode, results, queue) results[#results+1] = ref end end - if isCall then - results[#results+1] = ref - end elseif mode == 'field' then if ref.type == 'setfield' or ref.type == 'getfield' @@ -1556,6 +1520,49 @@ function m.checkSameSimple(status, simple, data, mode, results, queue) end end +function m.checkSameSimple(status, simple, data, mode, results, queue) + local ref = data.obj + local start = data.start + local force = data.force + local isCall = data.call + for i = start, #simple do + local sm = simple[i] + if sm ~= '*' and not force and m.getSimpleName(ref) ~= sm then + return + end + force = false + local cmode = mode + if i < #simple then + cmode = 'ref' + end + -- 穿透 self:func 与 mt:func + m.searchSameFieldsCrossMethod(status, ref, i, queue) + -- 穿透赋值 + m.searchSameFieldsInValue(status, ref, i, queue, cmode) + -- 检查形如 a = f() 的分支情况,需要业务层传入 interface.call + m.checkSameSimpleInCall(status, ref, i, queue, mode) + if cmode ~= 'def' then + -- 检查形如 { a = f } 的情况 + m.checkSameSimpleAsTableField(status, ref, i, queue) + -- 检查形如 return m 的情况 + m.checkSameSimpleAsReturn(status, ref, i, queue) + -- 检查形如 a = f 的情况 + m.checkSameSimpleAsSetValue(status, ref, i, queue) + end + if i == #simple then + break + end + -- 检查形如 a = {} 的分支情况 + m.checkSameSimpleInBranch(status, ref, i, queue) + ref = m.getNextRef(ref) + if not ref then + return + end + isCall = false + end + m.pushResult(status, mode, ref, isCall) +end + function m.searchSameFields(status, simple, mode) local first = simple.first local fref = first and first.ref |