diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-04-13 22:14:50 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-04-13 22:14:50 +0800 |
commit | 73a4780aa866737851040239eee52a013b5401d0 (patch) | |
tree | 7770bff33ab194c37dd47ca0dac57f2dc322f422 /script/vm/value.lua | |
parent | b3b71716f689be9115cdde8d6caf0314e76ae523 (diff) | |
download | lua-language-server-73a4780aa866737851040239eee52a013b5401d0.zip |
cleanup
Diffstat (limited to 'script/vm/value.lua')
-rw-r--r-- | script/vm/value.lua | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/script/vm/value.lua b/script/vm/value.lua index 5810f8da..10107212 100644 --- a/script/vm/value.lua +++ b/script/vm/value.lua @@ -8,7 +8,8 @@ function vm.test(source) local node = vm.compileNode(source) local hasTrue, hasFalse for n in node:eachObject() do - if n.type == 'boolean' then + if n.type == 'boolean' + or n.type == 'doc.type.boolean' then if n[1] == true then hasTrue = true end @@ -37,6 +38,19 @@ function vm.test(source) end end +---@param source parser.object +---@return boolean +function vm.isFalsy(source) + if source.type == 'nil' then + return true + end + if source.type == 'boolean' + or source.type == 'doc.type.boolean' then + return source[1] == false + end + return false +end + ---@param v vm.object ---@return string? local function getUnique(v) @@ -77,6 +91,9 @@ end ---@param b vm.node ---@return boolean|nil function vm.equal(a, b) + if not a or not b then + return false + end local nodeA = vm.compileNode(a) local nodeB = vm.compileNode(b) local mapA = {} |