summaryrefslogtreecommitdiff
path: root/script/vm/global.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-11-08 00:01:12 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-11-08 00:01:12 +0800
commit00dd1ed171beda2e892a2460d6e7eff321c775e8 (patch)
tree95a17424f070cc6d0ee7d458011519c82039a378 /script/vm/global.lua
parent34d32a478bcd066baf49ccf36f5f26a132cbfab8 (diff)
downloadlua-language-server-00dd1ed171beda2e892a2460d6e7eff321c775e8.zip
support enums with runtime values
resolved #1411
Diffstat (limited to 'script/vm/global.lua')
-rw-r--r--script/vm/global.lua23
1 files changed, 3 insertions, 20 deletions
diff --git a/script/vm/global.lua b/script/vm/global.lua
index 027b096a..6db3a58c 100644
--- a/script/vm/global.lua
+++ b/script/vm/global.lua
@@ -164,11 +164,9 @@ local function createGlobal(name, cate)
}, mt)
end
----@alias parser.enum string|integer
-
---@class parser.object
---@field package _globalNode vm.global|false
----@field package _enums? parser.enum[]
+---@field package _enums? parser.object[]
---@type table<string, vm.global>
local allGlobals = {}
@@ -378,22 +376,7 @@ local compilerGlobalSwitch = util.switch()
for _, field in ipairs(tbl) do
if field.type == 'tablefield'
or field.type == 'tableindex' then
- if not field.value then
- goto CONTINUE
- end
- local key = guide.getKeyName(field)
- if not key then
- goto CONTINUE
- end
- if field.value.type == 'integer'
- or field.value.type == 'string' then
- source._enums[#source._enums+1] = field.value[1]
- end
- if field.value.type == 'binary'
- or field.value.type == 'unary' then
- source._enums[#source._enums+1] = vm.getNumber(field.value)
- end
- ::CONTINUE::
+ source._enums[#source._enums+1] = field
end
end
end)
@@ -546,7 +529,7 @@ function vm.getGlobalNode(source)
end
---@param source parser.object
----@return parser.enum[]?
+---@return parser.object[]?
function vm.getEnums(source)
return source._enums
end