From e88c7d0e1a0ce37b9377f86b37d6ed963fd935b0 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, 15 Jun 2022 16:29:20 +0800 Subject: resolve #1154 resolve #1165 infer type by `t and t.x` --- script/vm/runner.lua | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) (limited to 'script/vm/runner.lua') diff --git a/script/vm/runner.lua b/script/vm/runner.lua index 5d561677..05dcbb7a 100644 --- a/script/vm/runner.lua +++ b/script/vm/runner.lua @@ -8,6 +8,7 @@ local guide = require 'parser.guide' ---@field _loc parser.object ---@field _objs parser.object[] ---@field _callback vm.runner.callback +---@field _mark table local mt = {} mt.__index = mt mt._index = 1 @@ -117,6 +118,17 @@ function mt:_lookInto(action, topNode, outNode) if not action then return topNode, outNode end + if self._mark[action] then + return + end + self._mark[action] = true + local top = self._objs[self._index] + if not top then + return topNode, outNode + end + if not guide.isInRange(action, top.finish) then + return topNode, outNode + end local set local value = vm.getObjectValue(action) if value then @@ -232,10 +244,10 @@ function mt:_lookInto(action, topNode, outNode) self:_lookInto(arg, topNode) end end - elseif action.type == 'return' then - for _, rtn in ipairs(action) do - self:_lookInto(rtn, topNode) - end + else + guide.eachSourceContain(action, top.finish, function(source) + self:_lookInto(source, topNode) + end) end ::RETURN:: topNode = self:_fastWard(action.finish, topNode) @@ -275,6 +287,7 @@ function vm.launchRunner(loc, callback) local self = setmetatable({ _loc = loc, _objs = {}, + _mark = {}, _callback = callback, }, mt) -- cgit v1.2.3