summaryrefslogtreecommitdiff
path: root/server/src/vm
diff options
context:
space:
mode:
authorsumneko <sumneko@hotmail.com>2019-04-30 17:16:13 +0800
committersumneko <sumneko@hotmail.com>2019-04-30 17:16:13 +0800
commite683d90bdb40ed07ad3f1b53ca94b0d299382c74 (patch)
treef6c7f1d8d7906ab6f962ce0660248f0ebf94ba75 /server/src/vm
parentcf97b3bf418d73894bb7849b6c02e40c753425bb (diff)
downloadlua-language-server-e683d90bdb40ed07ad3f1b53ca94b0d299382c74.zip
emmyTableType
Diffstat (limited to 'server/src/vm')
-rw-r--r--server/src/vm/emmy.lua15
-rw-r--r--server/src/vm/ipairs.lua7
-rw-r--r--server/src/vm/local.lua1
-rw-r--r--server/src/vm/value.lua10
4 files changed, 30 insertions, 3 deletions
diff --git a/server/src/vm/emmy.lua b/server/src/vm/emmy.lua
index cf6d7026..a66738e5 100644
--- a/server/src/vm/emmy.lua
+++ b/server/src/vm/emmy.lua
@@ -29,6 +29,7 @@ function mt:doEmmy(action)
elseif tp == 'emmyArrayType' then
self:doEmmyArrayType(action)
elseif tp == 'emmyTableType' then
+ self:doEmmyTableType(action)
elseif tp == 'emmyFunctionType' then
elseif tp == 'emmySee' then
elseif tp == 'emmyIncomplete' then
@@ -237,6 +238,20 @@ function mt:doEmmyArrayType(action)
return type
end
+function mt:doEmmyTableType(action)
+ ---@type emmyMgr
+ local emmyMgr = self.emmyMgr
+ self:instantSource(action)
+ local keyType = self:buildEmmyType(action[1])
+ local valueType = self:buildEmmyType(action[2])
+ local type = emmyMgr:addTableType(action, keyType, valueType)
+ self._emmy = type
+ if self.lsp then
+ self.lsp.global:markGet(self:getUri())
+ end
+ return type
+end
+
function mt:doEmmyIncomplete(action)
self:instantSource(action)
end
diff --git a/server/src/vm/ipairs.lua b/server/src/vm/ipairs.lua
index e27b8584..b8d821ef 100644
--- a/server/src/vm/ipairs.lua
+++ b/server/src/vm/ipairs.lua
@@ -33,10 +33,15 @@ function mt:callNext(func, values, source)
local emmy = tbl:getEmmy()
if emmy then
if emmy.type == 'emmy.arrayType' then
- local key = self:createValue('integer', self:getDefaultSource())
+ local key = self:createValue('integer', source)
local value = self:createValue(emmy:getName(), source)
func:setReturn(1, key)
func:setReturn(2, value)
+ elseif emmy.type == 'emmy.tableType' then
+ local key = self:createValue(emmy:getKeyType():getType(), source)
+ local value = self:createValue(emmy:getValueType():getType(), source)
+ func:setReturn(1, key)
+ func:setReturn(2, value)
end
end
end
diff --git a/server/src/vm/local.lua b/server/src/vm/local.lua
index ad7d80e8..ce47414a 100644
--- a/server/src/vm/local.lua
+++ b/server/src/vm/local.lua
@@ -143,6 +143,7 @@ function mt:setEmmy(emmy)
if emmy.type ~= 'emmy.class'
and emmy.type ~= 'emmy.type'
and emmy.type ~= 'emmy.arrayType'
+ and emmy.type ~= 'emmy.tableType'
then
return
end
diff --git a/server/src/vm/value.lua b/server/src/vm/value.lua
index d974cec0..6cfaec4b 100644
--- a/server/src/vm/value.lua
+++ b/server/src/vm/value.lua
@@ -190,6 +190,8 @@ function mt:getChild(index, source)
if type(index) == 'number' then
value = create(emmy:getName(), source)
end
+ elseif emmy.type == 'emmy.tableType' then
+ value = create(emmy:getValueType():getType(), source)
end
end
if not value then
@@ -587,8 +589,12 @@ function mt:setEmmy(emmy)
end)
elseif emmy.type == 'emmy.arrayType' then
---@type EmmyArrayType
- local EmmyArrayType = emmy
- EmmyArrayType:setValue(self)
+ local emmyArrayType = emmy
+ emmyArrayType:setValue(self)
+ elseif emmy.type == 'emmy.tableType' then
+ ---@type EmmyTableType
+ local emmyTableType = emmy
+ emmyTableType:setValue(self)
else
return
end