From b7f7789e46ab8c67d25704be696a1523762b1d80 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Wed, 22 Sep 2021 15:54:44 +0800 Subject: update --- script/parser/guide.lua | 5 +++-- script/parser/newparser.lua | 14 +++++++------- script/vm/getLinks.lua | 6 +++--- 3 files changed, 13 insertions(+), 12 deletions(-) (limited to 'script') diff --git a/script/parser/guide.lua b/script/parser/guide.lua index 4a0ca21f..fb5f3db4 100644 --- a/script/parser/guide.lua +++ b/script/parser/guide.lua @@ -725,10 +725,11 @@ end --- 获取指定的 special function m.eachSpecialOf(ast, name, callback) local root = m.getRoot(ast) - if not root.specials then + local state = root.state + if not state.specials then return end - local specials = root.specials[name] + local specials = state.specials[name] if not specials then return end diff --git a/script/parser/newparser.lua b/script/parser/newparser.lua index de78fd6d..9547a830 100644 --- a/script/parser/newparser.lua +++ b/script/parser/newparser.lua @@ -210,14 +210,13 @@ local parseExp, parseAction local pushError local function addSpecial(name, obj) - local root = State.ast - if not root.specials then - root.specials = {} + if not State.specials then + State.specials = {} end - if not root.specials[name] then - root.specials[name] = {} + if not State.specials[name] then + State.specials[name] = {} end - root.specials[name][#root.specials[name]+1] = obj + State.specials[name][#State.specials[name]+1] = obj obj.special = name end @@ -1739,7 +1738,7 @@ local function parseSimple(node, funcName) } call.args = args str.parent = args - node.parent = args + node.parent = call node = call elseif CharMapStrLH[token] then local str = parseLongString() @@ -3583,6 +3582,7 @@ return function (lua, mode, version, options) elseif mode == 'Action' then State.ast = parseAction() end + State.ast.state = State return State end diff --git a/script/vm/getLinks.lua b/script/vm/getLinks.lua index 161396f6..d2332504 100644 --- a/script/vm/getLinks.lua +++ b/script/vm/getLinks.lua @@ -6,12 +6,12 @@ local files = require 'files' local function getFileLinks(uri) local ws = require 'workspace' local links = {} - local ast = files.getState(uri) - if not ast then + local state = files.getState(uri) + if not state then return links end tracy.ZoneBeginN('getFileLinks') - guide.eachSpecialOf(ast.ast, 'require', function (source) + guide.eachSpecialOf(state.ast, 'require', function (source) local call = source.parent if not call or call.type ~= 'call' then return -- cgit v1.2.3