summaryrefslogtreecommitdiff
path: root/script/vm/value.lua
diff options
context:
space:
mode:
author最萌小汐 <sumneko@hotmail.com>2022-03-08 20:40:35 +0800
committer最萌小汐 <sumneko@hotmail.com>2022-03-08 20:40:35 +0800
commit429a75cb3564b3a9a612fde78aeb7aa937f4a683 (patch)
tree72e24007af8fb31ea81dfe43bc4f0f60d10bba80 /script/vm/value.lua
parent6ef8cb96f7834c99e998b49a4b8632a784b67e89 (diff)
downloadlua-language-server-429a75cb3564b3a9a612fde78aeb7aa937f4a683.zip
stash
Diffstat (limited to 'script/vm/value.lua')
-rw-r--r--script/vm/value.lua45
1 files changed, 45 insertions, 0 deletions
diff --git a/script/vm/value.lua b/script/vm/value.lua
index f2708de1..259dc56a 100644
--- a/script/vm/value.lua
+++ b/script/vm/value.lua
@@ -1,4 +1,5 @@
local nodeMgr = require 'vm.node'
+local guide = require 'parser.guide'
---@class vm.value-manager
local m = {}
@@ -39,4 +40,48 @@ function m.test(source)
end
end
+---@param v vm.node
+---@return string
+local function getUnique(v)
+ if v.type == 'local' then
+ return ('loc:%s@%d'):format(guide.getUri(v), v.start)
+ end
+ if v.type == 'global' then
+ return ('%s:%s'):format(v.cate, v.name)
+ end
+ if v.type == 'boolean' then
+ return ('bool:%s'):format(v[1])
+ end
+ if v.type == 'number' then
+ return ('num:%s'):format(v[1])
+ end
+ if v.type == 'integer' then
+ return ('num:%s'):format(v[1])
+ end
+end
+
+local function nodeToMap(node)
+ local map = {}
+ for n in nodeMgr.eachNode(node) do
+ if n.type == 'local' then
+ map[n] = true
+ end
+ if n.type == 'global' then
+
+ end
+ end
+ return map
+end
+
+---@param a vm.node
+---@param b vm.node
+---@return boolean|nil
+function m.equal(a, b)
+ local compiler = require 'vm.compiler'
+ local nodeA = compiler.compileNode(a)
+ local nodeB = compiler.compileNode(b)
+ local mapA = {}
+ local mapB = {}
+end
+
return m