From 84328aded8e4f39ac67e5c5046303e3273eabed9 Mon Sep 17 00:00:00 2001 From: sumneko Date: Wed, 3 Apr 2019 12:26:42 +0800 Subject: =?UTF-8?q?=E5=80=BC=E7=B1=BB=E5=9E=8B=E5=8A=A0=E4=B8=AA=E4=BC=98?= =?UTF-8?q?=E5=85=88=E7=BA=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/vm/value.lua | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'server/src/vm') 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' -- cgit v1.2.3