From 7e389b1f939365282a18e2db0ffec12fa9cb3f07 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, 18 Feb 2022 18:05:53 +0800 Subject: update --- script/vm/node/compiler.lua | 29 +++++++++++++++++++---------- test/definition/table.lua | 17 ++--------------- 2 files changed, 21 insertions(+), 25 deletions(-) diff --git a/script/vm/node/compiler.lua b/script/vm/node/compiler.lua index a9b77920..003ff884 100644 --- a/script/vm/node/compiler.lua +++ b/script/vm/node/compiler.lua @@ -82,9 +82,12 @@ local valueMap = util.switch() state.declareLiteral(value) m.setNode(source, value) end) - : case 'call' + : case 'select' : call(function (source, value) - m.setNode(source, getReturn(value.node, 1)) + local vararg = value.vararg + if vararg.type == 'call' then + m.setNode(source, getReturn(vararg.node, value.sindex)) + end end) : getMap() @@ -130,13 +133,11 @@ local function compileByParentNode(source) return end local key = guide.getKeyName(source) - for node in m.eachNode(parentNode) do - local f = searchFieldMap[node.type] - if f then - f(node, key, function (field) - compileValue(source, field.value) - end) - end + local f = searchFieldMap[parentNode.type] + if f then + f(parentNode, key, function (field) + compileValue(source, field.value) + end) end end @@ -167,7 +168,15 @@ local compilerMap = util.switch() end) : case 'function.return' : call(function (source) - + local func = source.parent + local index = source.index + if func.returns then + for _, rtn in ipairs(func.returns) do + if rtn[index] then + m.setNode(source, m.compileNode(rtn[index])) + end + end + end end) : getMap() diff --git a/test/definition/table.lua b/test/definition/table.lua index 47cb13ea..9486ae93 100644 --- a/test/definition/table.lua +++ b/test/definition/table.lua @@ -161,26 +161,13 @@ print(x.y.) TEST [[ local function f() - local t = {} - t.field1 = { + local t = { = 1, - y = 1, - z = 1, - } - t.field2 = { - x = 1, - y = 1, - z = 1, - } - t.field3 = { - x = 1, - y = 1, - z = 1, } return t end local t = f() -t.field1. +t. ]] TEST [[ -- cgit v1.2.3