diff options
author | sumneko <sumneko@hotmail.com> | 2019-04-29 21:51:50 +0800 |
---|---|---|
committer | sumneko <sumneko@hotmail.com> | 2019-04-29 21:51:50 +0800 |
commit | bb56cb2c21bf6a6c7a6c3bf6bb069bc69c1f903c (patch) | |
tree | 294f29bbb03a357838545c42f6ab15ea5ef942c1 /server/src/emmy | |
parent | ba5e88985b5344789100b1e8d91b68fe1f2cab1a (diff) | |
download | lua-language-server-bb56cb2c21bf6a6c7a6c3bf6bb069bc69c1f903c.zip |
emmy.arrayType
Diffstat (limited to 'server/src/emmy')
-rw-r--r-- | server/src/emmy/arrayType.lua | 36 | ||||
-rw-r--r-- | server/src/emmy/manager.lua | 29 |
2 files changed, 56 insertions, 9 deletions
diff --git a/server/src/emmy/arrayType.lua b/server/src/emmy/arrayType.lua new file mode 100644 index 00000000..3c6a7b7b --- /dev/null +++ b/server/src/emmy/arrayType.lua @@ -0,0 +1,36 @@ +local listMgr = require 'vm.list' + +---@class EmmyArrayType +local mt = {} +mt.__index = mt +mt.type = 'emmy.arrayType' + +function mt:getType() + return 'table' +end + +function mt:getName() + return self.name +end + +function mt:getSource() + return listMgr.get(self.source) +end + +function mt:setValue(value) + self.value = value + self:getSource():get('emmy.typeUnit'):setValue(value) +end + +function mt:getValue() + return self.value +end + +return function (manager, source) + local self = setmetatable({ + name = source[1], + source = source.id, + _manager = manager, + }, mt) + return self +end diff --git a/server/src/emmy/manager.lua b/server/src/emmy/manager.lua index ce766988..45fc1c3d 100644 --- a/server/src/emmy/manager.lua +++ b/server/src/emmy/manager.lua @@ -1,12 +1,13 @@ -local listMgr = require 'vm.list' -local newClass = require 'emmy.class' -local newType = require 'emmy.type' -local newTypeUnit = require 'emmy.typeUnit' -local newAlias = require 'emmy.alias' -local newParam = require 'emmy.param' -local newReturn = require 'emmy.return' -local newField = require 'emmy.field' -local newGeneric = require 'emmy.generic' +local listMgr = require 'vm.list' +local newClass = require 'emmy.class' +local newType = require 'emmy.type' +local newTypeUnit = require 'emmy.typeUnit' +local newAlias = require 'emmy.alias' +local newParam = require 'emmy.param' +local newReturn = require 'emmy.return' +local newField = require 'emmy.field' +local newGeneric = require 'emmy.generic' +local newArrayType = require 'emmy.arrayType' local mt = {} mt.__index = mt @@ -99,6 +100,16 @@ function mt:addType(source) return typeObj end +function mt:addArrayType(source) + local typeObj = newArrayType(self, source) + local typeUnit = newTypeUnit(self, source) + local list = self:getClass(source[1]) + typeUnit:setParent(typeObj) + list[source.id] = typeUnit + source:set('emmy.typeUnit', typeUnit) + return typeObj +end + function mt:addAlias(source, typeObj) local aliasName = source[1][1] local aliasObj = newAlias(self, source) |