diff options
Diffstat (limited to 'server/src/emmy')
-rw-r--r-- | server/src/emmy/alias.lua | 42 | ||||
-rw-r--r-- | server/src/emmy/arrayType.lua | 37 | ||||
-rw-r--r-- | server/src/emmy/class.lua | 61 | ||||
-rw-r--r-- | server/src/emmy/field.lua | 45 | ||||
-rw-r--r-- | server/src/emmy/funcType.lua | 64 | ||||
-rw-r--r-- | server/src/emmy/generic.lua | 27 | ||||
-rw-r--r-- | server/src/emmy/init.lua | 1 | ||||
-rw-r--r-- | server/src/emmy/manager.lua | 221 | ||||
-rw-r--r-- | server/src/emmy/param.lua | 70 | ||||
-rw-r--r-- | server/src/emmy/return.lua | 36 | ||||
-rw-r--r-- | server/src/emmy/tableType.lua | 40 | ||||
-rw-r--r-- | server/src/emmy/type.lua | 55 | ||||
-rw-r--r-- | server/src/emmy/typeUnit.lua | 51 |
13 files changed, 0 insertions, 750 deletions
diff --git a/server/src/emmy/alias.lua b/server/src/emmy/alias.lua deleted file mode 100644 index be47cb4f..00000000 --- a/server/src/emmy/alias.lua +++ /dev/null @@ -1,42 +0,0 @@ -local listMgr = require 'vm.list' - ----@class EmmyAlias -local mt = {} -mt.__index = mt -mt.type = 'emmy.alias' - -function mt:getName() - return self.name -end - -function mt:getSource() - return listMgr.get(self.source) -end - -function mt:bindType(type) - if type then - self._bindType = type - else - return self._bindType - end -end - -function mt:addEnum(enum) - self._enum[#self._enum+1] = enum -end - -function mt:eachEnum(callback) - for _, enum in ipairs(self._enum) do - callback(enum) - end -end - -return function (manager, source) - local self = setmetatable({ - name = source[1][1], - source = source.id, - _manager = manager, - _enum = {}, - }, mt) - return self -end diff --git a/server/src/emmy/arrayType.lua b/server/src/emmy/arrayType.lua deleted file mode 100644 index c5d73500..00000000 --- a/server/src/emmy/arrayType.lua +++ /dev/null @@ -1,37 +0,0 @@ -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._child:setValue(value) -end - -function mt:getValue() - return self.value -end - -return function (manager, source, child) - local self = setmetatable({ - name = child:getName(), - source = source.id, - _child = child, - _manager = manager, - }, mt) - return self -end diff --git a/server/src/emmy/class.lua b/server/src/emmy/class.lua deleted file mode 100644 index 6728e2c4..00000000 --- a/server/src/emmy/class.lua +++ /dev/null @@ -1,61 +0,0 @@ -local listMgr = require 'vm.list' - ----@class EmmyClass -local mt = {} -mt.__index = mt -mt.type = 'emmy.class' - -function mt:getType() - return self.name -end - -function mt:getName() - return self.name -end - -function mt:getSource() - return listMgr.get(self.source) -end - -function mt:setValue(value) - self.value = value -end - -function mt:getValue() - return self.value -end - -function mt:eachChild(callback) - self._manager:eachClass(self.name, function (obj) - if obj.type == 'emmy.typeUnit' then - callback(obj) - end - end) -end - -function mt:addField(field) - if not self._fields then - self._fields = {} - end - self._fields[#self._fields+1] = field -end - -function mt:eachField(callback) - if not self._fields then - return - end - ---@param field EmmyField - for _, field in ipairs(self._fields) do - callback(field) - end -end - -return function (manager, name, extends, source) - local self = setmetatable({ - name = name, - source = source.id, - extends = extends, - _manager = manager, - }, mt) - return self -end diff --git a/server/src/emmy/field.lua b/server/src/emmy/field.lua deleted file mode 100644 index f9e9cbf6..00000000 --- a/server/src/emmy/field.lua +++ /dev/null @@ -1,45 +0,0 @@ -local listMgr = require 'vm.list' - ----@class EmmyField -local mt = {} -mt.__index = mt -mt.type = 'emmy.field' - -function mt:getName() - return self.name -end - -function mt:getSource() - return listMgr.get(self.source) -end - -function mt:bindType(type) - if type then - self._bindType = type - else - return self._bindType - end -end - -function mt:bindValue(value) - if value then - self._bindValue = value - else - if self._bindValue then - if not self._bindValue:getSource() then - self._bindValue = nil - end - end - return self._bindValue - end -end - -return function (manager, source) - local self = setmetatable({ - name = source[2][1], - source = source.id, - visible = source[1], - _manager = manager, - }, mt) - return self -end diff --git a/server/src/emmy/funcType.lua b/server/src/emmy/funcType.lua deleted file mode 100644 index 2c073fe2..00000000 --- a/server/src/emmy/funcType.lua +++ /dev/null @@ -1,64 +0,0 @@ -local listMgr = require 'vm.list' - ----@class EmmyFunctionType -local mt = {} -mt.__index = mt -mt.type = 'emmy.functionType' - -function mt:getType() - return 'function' -end - -function mt:getName() - return 'function' -end - -function mt:getSource() - return listMgr.get(self.source) -end - -function mt:setValue(value) - self.value = value -end - -function mt:getValue() - return self.value -end - -function mt:addParam(name, type) - self._params[#self._params+1] = { name, type } -end - -function mt:addReturn(type) - self._returns[#self._returns+1] = type -end - -function mt:eachParam(callback) - for _, data in ipairs(self._params) do - callback(data[1], data[2]) - end -end - -function mt:eachReturn(callback) - for _, rtn in ipairs(self._returns) do - callback(rtn) - end -end - -function mt:bindFunction(func) - if func then - self._bindFunction = func - else - return self._bindFunction - end -end - -return function (manager, source) - local self = setmetatable({ - source = source.id, - _params = {}, - _returns = {}, - _manager = manager, - }, mt) - return self -end diff --git a/server/src/emmy/generic.lua b/server/src/emmy/generic.lua deleted file mode 100644 index 82fd0c4b..00000000 --- a/server/src/emmy/generic.lua +++ /dev/null @@ -1,27 +0,0 @@ -local listMgr = require 'vm.list' - ----@class EmmyGeneric -local mt = {} -mt.__index = mt -mt.type = 'emmy.generic' - -function mt:getName() - return self.name:getName() -end - -function mt:setValue(value) - self._value = value -end - -function mt:getValue() - return self._value -end - -return function (manager, defs) - for _, def in ipairs(defs) do - setmetatable(def, mt) - def._manager = manager - def._binds = {} - end - return defs -end diff --git a/server/src/emmy/init.lua b/server/src/emmy/init.lua deleted file mode 100644 index 769c9e05..00000000 --- a/server/src/emmy/init.lua +++ /dev/null @@ -1 +0,0 @@ -return require 'vm.emmy.emmy' diff --git a/server/src/emmy/manager.lua b/server/src/emmy/manager.lua deleted file mode 100644 index c80e05df..00000000 --- a/server/src/emmy/manager.lua +++ /dev/null @@ -1,221 +0,0 @@ -local listMgr = require 'vm.list' -local sourceMgr = require 'vm.source' -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 newTableType = require 'emmy.tableType' -local newFuncType = require 'emmy.funcType' - -local mt = {} -mt.__index = mt -mt.__name = 'emmyMgr' - -function mt:flushClass(name) - local list = self._class[name] - if not list then - return - end - local version = listMgr.getVersion() - if version == list.version then - return - end - for srcId in pairs(list) do - if not listMgr.get(srcId) then - list[srcId] = nil - end - end - if not next(list) then - self._class[name] = nil - return - end - list.version = version -end - -function mt:eachClassByName(name, callback) - self:flushClass(name) - local list = self._class[name] - if not list then - return - end - for k, class in pairs(list) do - if k ~= 'version' then - local res = callback(class) - if res ~= nil then - return res - end - end - end -end - -function mt:eachClass(...) - local n = select('#', ...) - if n == 1 then - local callback = ... - for name in pairs(self._class) do - local res = self:eachClassByName(name, callback) - if res ~= nil then - return res - end - end - else - local name, callback = ... - return self:eachClassByName(name, callback) - end -end - -function mt:getClass(name) - self:flushClass(name) - local list = self._class[name] - local version = listMgr.getVersion() - if not list then - list = { - version = version, - } - self._class[name] = list - end - return list -end - -function mt:newClass(name, extends, source) - local list = self:getClass(name) - list[source.id] = newClass(self, name, extends, source) - return list[source.id] -end - -function mt:addClass(source) - local className = source[1][1] - local extends = source[2] and source[2][1] - local class = self:newClass(className, extends, source) - return class -end - -function mt:addType(source) - local typeObj = newType(self, source) - for i, obj in ipairs(source) do - local typeUnit = newTypeUnit(self, obj) - local className = obj[1] - if className then - local list = self:getClass(className) - list[source.id] = typeUnit - end - typeUnit:setParent(typeObj) - typeObj._childs[i] = typeUnit - obj:set('emmy.typeUnit', typeUnit) - end - return typeObj -end - -function mt:addArrayType(source) - local typeObj = self:addType(source) - local arrayTypeObj = newArrayType(self, source, typeObj) - return arrayTypeObj -end - -function mt:addTableType(source, keyType, valueType) - local typeObj = newTableType(self, source, keyType, valueType) - return typeObj -end - -function mt:addFunctionType(source) - local typeObj = newFuncType(self, source) - return typeObj -end - -function mt:addAlias(source, typeObj) - local aliasName = source[1][1] - local aliasObj = newAlias(self, source) - aliasObj:bindType(typeObj) - local list = self:getClass(aliasName) - list[source.id] = aliasObj - for i = 3, #source do - aliasObj:addEnum(source[i]) - end - return aliasObj -end - -function mt:addParam(source, bind) - local paramObj = newParam(self, source) - if bind.type == 'emmy.generic' then - paramObj:bindGeneric(bind) - else - paramObj:bindType(bind) - self:eachClass(bind:getType(), function (class) - if class.type == 'emmy.alias' then - class:eachEnum(function (enum) - paramObj:addEnum(enum) - end) - end - end) - end - for i = 3, #source do - paramObj:addEnum(source[i]) - end - paramObj:setOption(source.option) - return paramObj -end - -function mt:addReturn(source, bind, name) - local returnObj = newReturn(self, source, name) - if bind then - if bind.type == 'emmy.generic' then - returnObj:bindGeneric(bind) - else - returnObj:bindType(bind) - end - end - return returnObj -end - -function mt:addField(source, typeObj, value) - local fieldObj = newField(self, source) - fieldObj:bindType(typeObj) - fieldObj:bindValue(value) - return fieldObj -end - -function mt:addGeneric(defs) - local genericObj = newGeneric(self, defs) - return genericObj -end - -function mt:remove() -end - -function mt:count() - local count = 0 - for _, list in pairs(self._class) do - for k in pairs(list) do - if k ~= 'version' then - count = count + 1 - end - end - end - return count -end - -return function () - ---@class emmyMgr - local self = setmetatable({ - _class = {}, - }, mt) - - local source = sourceMgr.dummy() - self:newClass('any', nil, source) - self:newClass('string', 'any', source) - self:newClass('number', 'any', source) - self:newClass('integer', 'number', source) - self:newClass('boolean', 'any', source) - self:newClass('table', 'any', source) - self:newClass('function', 'any', source) - self:newClass('nil', 'any', source) - self:newClass('userdata', 'any', source) - self:newClass('thread', 'any', source) - - return self -end diff --git a/server/src/emmy/param.lua b/server/src/emmy/param.lua deleted file mode 100644 index 12ac0633..00000000 --- a/server/src/emmy/param.lua +++ /dev/null @@ -1,70 +0,0 @@ -local listMgr = require 'vm.list' - ----@class EmmyParam -local mt = {} -mt.__index = mt -mt.type = 'emmy.param' - -function mt:getName() - return self.name -end - -function mt:getType() - if self._bindType then - return self._bindType:getType() - else - return 'any' - end -end - -function mt:getSource() - return listMgr.get(self.source) -end - -function mt:bindType(type) - if type then - self._bindType = type - else - return self._bindType - end -end - -function mt:bindGeneric(generic) - if generic then - self._bindGeneric = generic - else - return self._bindGeneric - end -end - -function mt:addEnum(enum) - self._enum[#self._enum+1] = enum -end - -function mt:eachEnum(callback) - for _, enum in ipairs(self._enum) do - callback(enum) - end -end - -function mt:setOption(option) - self._option = option -end - -function mt:getOption() - return self._option -end - -return function (manager, source) - local self = setmetatable({ - source = source.id, - _manager = manager, - _enum = {}, - }, mt) - if source.type == 'emmyParam' then - self.name = source[1][1] - elseif source.type == 'emmyVararg' then - self.name = '...' - end - return self -end diff --git a/server/src/emmy/return.lua b/server/src/emmy/return.lua deleted file mode 100644 index 1fc97923..00000000 --- a/server/src/emmy/return.lua +++ /dev/null @@ -1,36 +0,0 @@ -local listMgr = require 'vm.list' - ----@class EmmyReturn -local mt = {} -mt.__index = mt -mt.type = 'emmy.return' - -function mt:getSource() - return listMgr.get(self.source) -end - -function mt:bindType(type) - if type then - self._bindType = type - else - return self._bindType - end -end - -function mt:bindGeneric(generic) - if generic then - self._bindGeneric = generic - else - return self._bindGeneric - end -end - -return function (manager, source, name) - local self = setmetatable({ - source = source.id, - name = name and name[1], - option = source.option, - _manager = manager, - }, mt) - return self -end diff --git a/server/src/emmy/tableType.lua b/server/src/emmy/tableType.lua deleted file mode 100644 index 3882cd61..00000000 --- a/server/src/emmy/tableType.lua +++ /dev/null @@ -1,40 +0,0 @@ -local listMgr = require 'vm.list' - ----@class EmmyTableType -local mt = {} -mt.__index = mt -mt.type = 'emmy.tableType' - -function mt:getType() - return 'table' -end - -function mt:getKeyType() - return self.keyType -end - -function mt:getValueType() - return self.valueType -end - -function mt:getSource() - return listMgr.get(self.source) -end - -function mt:setValue(value) - self.value = value -end - -function mt:getValue() - return self.value -end - -return function (manager, source, keyType, valueType) - local self = setmetatable({ - source = source.id, - keyType = keyType, - valueType = valueType, - _manager = manager, - }, mt) - return self -end diff --git a/server/src/emmy/type.lua b/server/src/emmy/type.lua deleted file mode 100644 index b7e451b2..00000000 --- a/server/src/emmy/type.lua +++ /dev/null @@ -1,55 +0,0 @@ -local listMgr = require 'vm.list' - -local function buildName(source) - local names = {} - for i, type in ipairs(source) do - names[i] = type[1] - end - return table.concat(names, '|') -end - ----@class EmmyType -local mt = {} -mt.__index = mt -mt.type = 'emmy.type' - -function mt:getType() - return self.name -end - -function mt:getName() - return self.name -end - -function mt:getSource() - return listMgr.get(self.source) -end - -function mt:eachClass(callback) - for _, typeUnit in ipairs(self._childs) do - ---@type EmmyTypeUnit - local emmyTypeUnit = typeUnit - emmyTypeUnit:getClass(callback) - end -end - -function mt:setValue(value) - self.value = value - for _, typeUnit in ipairs(self._childs) do - typeUnit:setValue(value) - end -end - -function mt:getValue() - return self.value -end - -return function (manager, source) - local self = setmetatable({ - name = buildName(source), - source = source.id, - _manager = manager, - _childs = {}, - }, mt) - return self -end diff --git a/server/src/emmy/typeUnit.lua b/server/src/emmy/typeUnit.lua deleted file mode 100644 index 73d7ea6b..00000000 --- a/server/src/emmy/typeUnit.lua +++ /dev/null @@ -1,51 +0,0 @@ -local listMgr = require 'vm.list' - ----@class EmmyTypeUnit -local mt = {} -mt.__index = mt -mt.type = 'emmy.typeUnit' - -function mt:getType() - return self.name -end - -function mt:getName() - return self.name -end - -function mt:getSource() - return listMgr.get(self.source) -end - -function mt:getClass(callback) - self._manager:eachClass(self:getName(), function (class) - if class.type == 'emmy.class' then - callback(class) - end - end) -end - -function mt:setValue(value) - self.value = value -end - -function mt:getValue() - return self.value -end - -function mt:setParent(parent) - self.parent = parent -end - -function mt:getParent() - return self.parent -end - -return function (manager, source) - local self = setmetatable({ - name = source[1], - source = source.id, - _manager = manager, - }, mt) - return self -end |