diff options
Diffstat (limited to 'server/src/emmy')
-rw-r--r-- | server/src/emmy/generic.lua | 27 | ||||
-rw-r--r-- | server/src/emmy/manager.lua | 36 | ||||
-rw-r--r-- | server/src/emmy/param.lua | 8 | ||||
-rw-r--r-- | server/src/emmy/return.lua | 8 |
4 files changed, 68 insertions, 11 deletions
diff --git a/server/src/emmy/generic.lua b/server/src/emmy/generic.lua new file mode 100644 index 00000000..d47ee585 --- /dev/null +++ b/server/src/emmy/generic.lua @@ -0,0 +1,27 @@ +local listMgr = require 'vm.list' + +---@class EmmyGeneric +local mt = {} +mt.__index = mt +mt.type = 'emmy.generic' + +function mt:getName() + return self.name +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/manager.lua b/server/src/emmy/manager.lua index 7875e322..5213e2f6 100644 --- a/server/src/emmy/manager.lua +++ b/server/src/emmy/manager.lua @@ -1,11 +1,12 @@ -local listMgr = require 'vm.list' -local newClass = require 'emmy.class' -local newType = require 'emmy.type' +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 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 mt = {} mt.__index = mt @@ -107,15 +108,23 @@ function mt:addAlias(source, typeObj) return aliasObj end -function mt:addParam(source, typeObj) +function mt:addParam(source, bind) local paramObj = newParam(self, source) - paramObj:bindType(typeObj) + if bind.type == 'emmy.type' then + paramObj:bindType(bind) + elseif bind.type == 'emmy.generic' then + paramObj:bindGeneric(bind) + end return paramObj end -function mt:addReturn(source, typeObj) +function mt:addReturn(source, bind) local returnObj = newReturn(self, source) - returnObj:bindType(typeObj) + if bind.type == 'emmy.type' then + returnObj:bindType(bind) + elseif bind.type == 'emmy.generic' then + returnObj:bindGeneric(bind) + end return returnObj end @@ -126,6 +135,11 @@ function mt:addField(source, typeObj, value) return fieldObj end +function mt:addGeneric(defs) + local genericObj = newGeneric(self, defs) + return genericObj +end + function mt:remove() end diff --git a/server/src/emmy/param.lua b/server/src/emmy/param.lua index 9c18bfec..84474db6 100644 --- a/server/src/emmy/param.lua +++ b/server/src/emmy/param.lua @@ -21,6 +21,14 @@ function mt:bindType(type) end end +function mt:bindGeneric(generic) + if generic then + self._bindGeneric = generic + else + return self._bindGeneric + end +end + return function (manager, source) local self = setmetatable({ name = source[1][1], diff --git a/server/src/emmy/return.lua b/server/src/emmy/return.lua index 49f6e260..a347267c 100644 --- a/server/src/emmy/return.lua +++ b/server/src/emmy/return.lua @@ -17,6 +17,14 @@ function mt:bindType(type) end end +function mt:bindGeneric(generic) + if generic then + self._bindGeneric = generic + else + return self._bindGeneric + end +end + return function (manager, source) local self = setmetatable({ source = source.id, |