diff options
author | 最萌小汐 <sumneko@hotmail.com> | 2022-03-08 20:02:49 +0800 |
---|---|---|
committer | 最萌小汐 <sumneko@hotmail.com> | 2022-03-08 20:02:49 +0800 |
commit | 6ef8cb96f7834c99e998b49a4b8632a784b67e89 (patch) | |
tree | d4fdddfe3f098599e1c6ea4766d7544d3a85fee9 /script/vm/compiler.lua | |
parent | 256b37771a9203ab0c27d5690e35d9a1f9185465 (diff) | |
download | lua-language-server-6ef8cb96f7834c99e998b49a4b8632a784b67e89.zip |
update
Diffstat (limited to 'script/vm/compiler.lua')
-rw-r--r-- | script/vm/compiler.lua | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/script/vm/compiler.lua b/script/vm/compiler.lua index c870cc0e..9e804dfb 100644 --- a/script/vm/compiler.lua +++ b/script/vm/compiler.lua @@ -4,6 +4,7 @@ local localID = require 'vm.local-id' local globalMgr = require 'vm.global-manager' local nodeMgr = require 'vm.node' local genericMgr = require 'vm.generic-manager' +local valueMgr = require 'vm.value' ---@class parser.object ---@field _compiledNodes boolean @@ -402,6 +403,7 @@ local compilerMap = util.switch() m.compileNode(source.parent) end end) + : case 'setlocal' : case 'getlocal' : call(function (source) nodeMgr.setNode(source, m.compileNode(source.node)) @@ -545,6 +547,32 @@ local compilerMap = util.switch() nodeMgr.setNode(source, m.compileNode(type)) end end) + : case 'unary' + : call(function (source) + if source.op.type == 'not' then + local result = valueMgr.test(source[1]) + if result == nil then + nodeMgr.setNode(source, globalMgr.getGlobal('type', 'boolean')) + else + nodeMgr.setNode(source, { + type = 'boolean', + start = source.start, + finish = source.finish, + parent = source, + [1] = not result, + }) + end + end + if source.op.type == '#' then + nodeMgr.setNode(source, globalMgr.getGlobal('type', 'integer')) + end + if source.op.type == '-' then + nodeMgr.setNode(source, globalMgr.getGlobal('type', 'number')) + end + if source.op.type == '~' then + nodeMgr.setNode(source, globalMgr.getGlobal('type', 'integer')) + end + end) : getMap() ---@param source parser.object |