From c302f165c2713fa1d3258622fcf4e7eb7ec56aca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Fri, 6 Nov 2020 17:47:10 +0800 Subject: =?UTF-8?q?=E6=95=B4=E7=90=86=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- script-beta/parser/guide.lua | 61 +++++++++++++++----------------------------- 1 file changed, 21 insertions(+), 40 deletions(-) (limited to 'script-beta/parser') diff --git a/script-beta/parser/guide.lua b/script-beta/parser/guide.lua index db3696ba..43db26fe 100644 --- a/script-beta/parser/guide.lua +++ b/script-beta/parser/guide.lua @@ -1115,7 +1115,8 @@ local function buildSimpleList(obj, max) or cur.type == 'getglobal' then list[i] = cur break - elseif cur.type == 'select' then + elseif cur.type == 'select' + or cur.type == 'table' then list[i] = cur break elseif cur.type == 'string' then @@ -1146,7 +1147,8 @@ function m.getSimple(obj, max) or obj.type == 'getglobal' or obj.type == 'tablefield' or obj.type == 'tableindex' - or obj.type == 'select' then + or obj.type == 'select' + or obj.type == 'table' then simpleList = buildSimpleList(obj, max) elseif obj.type == 'field' or obj.type == 'method' then @@ -1287,38 +1289,14 @@ function m.checkSameSimpleInValueOfTable(status, value, start, queue) end end -function m.searchFields(status, obj, key, interface, deep) - if obj.type == 'table' then - local keyName = key and ('s|' .. key) - local results = {} - for i = 1, #obj do - local field = obj[i] - if not keyName or keyName == m.getSimpleName(field) then - results[#results+1] = field - end - end - return results - elseif obj.type == 'library' then - local results = {} - if obj.fields then - for i = 1, #obj.fields do - results[i] = obj.fields[i] - end - end - return results - else - local newStatus = m.status(status, interface) - newStatus.deep = deep - local simple = m.getSimple(obj) - if not simple then - return {} - end - simple[#simple+1] = key and ('s|' .. key) or '*' - m.searchSameFields(newStatus, simple, 'field') - local results = newStatus.results - m.cleanResults(results) - return results +function m.searchFields(status, obj, key) + local simple = m.getSimple(obj) + if not simple then + return end + simple[#simple+1] = key and ('s|' .. key) or '*' + m.searchSameFields(status, simple, 'field') + m.cleanResults(status.results) end function m.getObjectValue(obj) @@ -1356,13 +1334,11 @@ function m.getObjectValue(obj) end function m.checkSameSimpleInValueInMetaTable(status, mt, start, queue) - local indexes = m.searchFields(status, mt, '__index') - if not indexes then - return - end + local newStatus = m.status(status) + m.searchFields(newStatus, mt, '__index') local refsStatus = m.status(status) - for i = 1, #indexes do - local indexValue = m.getObjectValue(indexes[i]) + for i = 1, #newStatus.results do + local indexValue = m.getObjectValue(newStatus.results[i]) if indexValue then m.searchRefs(refsStatus, indexValue, 'ref') end @@ -3644,7 +3620,12 @@ end --- 请求对象的域 function m.requestFields(obj, interface, deep) - return m.searchFields(nil, obj, nil, interface, deep) + local status = m.status(nil, interface) + status.deep = deep + + m.searchFields(status, obj) + + return status.results, status.cache.count end --- 请求对象的类型推测 -- cgit v1.2.3