From 2b0fcec7b17c2c01942a277e938f918dc52ff62c 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, 14 Jun 2022 17:39:10 +0800 Subject: update runner --- script/vm/runner.lua | 26 ++++++++++++++++++++++++-- 1 file changed, 24 insertions(+), 2 deletions(-) (limited to 'script/vm/runner.lua') diff --git a/script/vm/runner.lua b/script/vm/runner.lua index 8823486d..2e301ed3 100644 --- a/script/vm/runner.lua +++ b/script/vm/runner.lua @@ -79,8 +79,30 @@ function mt:_fastWard(pos, node) if newNode then node = newNode:copy() end - else - error('unexpected type: ' .. obj.type) + elseif obj.type == 'doc.cast' then + node = node:copy() + for _, cast in ipairs(obj.casts) do + if cast.mode == '+' then + if cast.optional then + node:addOptional() + end + if cast.extends then + node:merge(vm.compileNode(cast.extends)) + end + elseif cast.mode == '-' then + if cast.optional then + node:removeOptional() + end + if cast.extends then + node:removeNode(vm.compileNode(cast.extends)) + end + else + if cast.extends then + node:clear() + node:merge(vm.compileNode(cast.extends)) + end + end + end end end self._index = math.huge -- cgit v1.2.3