summaryrefslogtreecommitdiff
path: root/server/src/vm
diff options
context:
space:
mode:
authorsumneko <sumneko@hotmail.com>2019-04-03 12:26:42 +0800
committersumneko <sumneko@hotmail.com>2019-04-03 12:26:42 +0800
commit84328aded8e4f39ac67e5c5046303e3273eabed9 (patch)
treee60c663f79ebeb9ca88ac63e3f8b7083250bf8ac /server/src/vm
parent7a3ebede6972dd620ecdf8f70cfbe61ff4ecf262 (diff)
downloadlua-language-server-84328aded8e4f39ac67e5c5046303e3273eabed9.zip
值类型加个优先级
Diffstat (limited to 'server/src/vm')
-rw-r--r--server/src/vm/value.lua14
1 files changed, 14 insertions, 0 deletions
diff --git a/server/src/vm/value.lua b/server/src/vm/value.lua
index 1c7fe04e..7e2c3663 100644
--- a/server/src/vm/value.lua
+++ b/server/src/vm/value.lua
@@ -4,6 +4,13 @@ local listMgr = require 'vm.list'
local Sort = 0
local Watch = setmetatable({}, {__mode = 'kv'})
+local TypeLevel = {
+ ['table'] = 1.0,
+ ['function'] = 0.9,
+ ['string'] = 0.8,
+ ['integer'] = 0.7,
+ ['number'] = 0.6,
+}
local mt = {}
mt.__index = mt
@@ -86,6 +93,13 @@ function mt:getType()
if rate > mRate then
mRate = rate
mType = tp
+ elseif rate == mRate then
+ local level1 = TypeLevel[rate] or 0.0
+ local level2 = TypeLevel[mRate] or 0.0
+ if level1 > level2 then
+ mRate = rate
+ mType = tp
+ end
end
end
return mType or 'any'