From 871035d0574b96175f44cdedd0f8256ae74a0534 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Tue, 10 Aug 2021 10:55:32 +0800 Subject: improve --- script/core/noder.lua | 36 ++++++++++++++++++++++++++++++------ 1 file changed, 30 insertions(+), 6 deletions(-) (limited to 'script/core') diff --git a/script/core/noder.lua b/script/core/noder.lua index 1cb49e5e..ac1d96d8 100644 --- a/script/core/noder.lua +++ b/script/core/noder.lua @@ -124,7 +124,15 @@ local getKeyMap = util.switch() end) : case 'tablefield' : call(function (source) - return STRING_CHAR .. (source.field and source.field[1] or ''), source.parent + local t = source.parent + local parent = t.parent + local node + if parent.value == t then + node = parent + else + node = t + end + return STRING_CHAR .. (source.field and source.field[1] or ''), node end) : case 'getmethod' : case 'setmethod' @@ -150,24 +158,40 @@ local getKeyMap = util.switch() end) : case 'tableindex' : call(function (source) + local t = source.parent + local parent = t.parent + local node + if parent.value == t then + node = parent + else + node = t + end local index = source.index if not index then - return ANY_FIELD_CHAR, source.parent + return ANY_FIELD_CHAR, node end if index.type == 'string' then - return STRING_CHAR .. (index[1] or ''), source.parent + return STRING_CHAR .. (index[1] or ''), node elseif index.type == 'boolean' or index.type == 'integer' or index.type == 'number' then - return tostring(index[1] or ''), source.parent + return tostring(index[1] or ''), node elseif index.type ~= 'function' and index.type ~= 'table' then - return ANY_FIELD_CHAR, source.parent + return ANY_FIELD_CHAR, node end end) : case 'tableexp' : call(function (source) - return tostring(source.tindex), source.parent + local t = source.parent + local parent = t.parent + local node + if parent.value == t then + node = parent + else + node = t + end + return tostring(source.tindex), node end) : case 'table' : call(function (source) -- cgit v1.2.3