From be6e0ee6d31d79005691b982c02e7699a7ae3762 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9C=80=E8=90=8C=E5=B0=8F=E6=B1=90?= Date: Mon, 10 Dec 2018 11:03:12 +0800 Subject: =?UTF-8?q?=E5=B8=83=E5=B0=94=E5=92=8C=E6=95=B0=E5=AD=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- server/src/matcher/compile.lua | 18 ++++++++++++++++++ server/test/definition/method.lua | 4 ++-- server/test/find_lib/init.lua | 4 ++-- server/test/type_inference/init.lua | 8 ++++++++ 4 files changed, 30 insertions(+), 4 deletions(-) (limited to 'server') diff --git a/server/src/matcher/compile.lua b/server/src/matcher/compile.lua index bcf2ca91..c6ccedfe 100644 --- a/server/src/matcher/compile.lua +++ b/server/src/matcher/compile.lua @@ -278,13 +278,31 @@ function mt:getString(exp) } end +function mt:getBoolean(exp) + return { + type = 'boolean', + boolean = exp[1], + valuetype = 'boolean', + } +end + +function mt:getNumber(exp) + return { + type = 'number', + number = exp[1], + valuetype = 'number', + } +end + function mt:searchExp(exp) local tp = exp.type if tp == 'nil' then elseif tp == 'string' then return self:getString(exp) elseif tp == 'boolean' then + return self:getBoolean(exp) elseif tp == 'number' then + return self:getNumber(exp) elseif tp == 'name' then return self:checkName(exp) elseif tp == 'simple' then diff --git a/server/test/definition/method.lua b/server/test/definition/method.lua index 05820e97..5e90177b 100644 --- a/server/test/definition/method.lua +++ b/server/test/definition/method.lua @@ -46,7 +46,7 @@ mt.__index = mt function mt:() end -local obj = setmetatable(1, mt) +local obj = setmetatable({}, mt) obj:() ]] @@ -55,7 +55,7 @@ local mt function mt:() end -local obj = setmetatable(1, { __index = mt }) +local obj = setmetatable({}, { __index = mt }) obj:() ]] diff --git a/server/test/find_lib/init.lua b/server/test/find_lib/init.lua index 18b88399..26dbc893 100644 --- a/server/test/find_lib/init.lua +++ b/server/test/find_lib/init.lua @@ -78,7 +78,7 @@ require 'table'.() TEST '*string:sub' [[ local str = 'xxx' -str. = 1 +str.() ]] TEST '*string:sub' [[ @@ -87,7 +87,7 @@ str:(1, 1) ]] TEST '*string:sub' [[ -('xxx'). = 1 +('xxx').() ]] TEST 'bee::filesystem' [[ diff --git a/server/test/type_inference/init.lua b/server/test/type_inference/init.lua index ee47b223..913228bb 100644 --- a/server/test/type_inference/init.lua +++ b/server/test/type_inference/init.lua @@ -26,3 +26,11 @@ end TEST 'string' [[ local = '111' ]] + +TEST 'boolean' [[ +local = true +]] + +TEST 'number' [[ +local = 1 +]] -- cgit v1.2.3