From 42ce9ab14839c83962268a94f6be8c6b36395270 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, 16 Dec 2022 17:27:11 +0800 Subject: must bind to node --- script/vm/tracer.lua | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) (limited to 'script/vm') diff --git a/script/vm/tracer.lua b/script/vm/tracer.lua index e83cfc11..b53fc33e 100644 --- a/script/vm/tracer.lua +++ b/script/vm/tracer.lua @@ -508,17 +508,22 @@ function mt:getNode(source) return self.nodes[source] or nil end +---@class vm.node +---@field package _tracer vm.tracer + ---@param source parser.object ---@return vm.tracer? local function createTracer(source) - if source._tracer then - return source._tracer + local node = vm.compileNode(source) + local tracer = node._tracer + if tracer then + return tracer end local main = guide.getParentBlock(source) if not main then return nil end - local tracer = setmetatable({ + tracer = setmetatable({ source = source, assigns = {}, assignMap = {}, @@ -529,7 +534,7 @@ local function createTracer(source) main = main, uri = guide.getUri(source), }, mt) - source._tracer = tracer + node._tracer = tracer tracer:collectLocal() -- cgit v1.2.3