diff options
Diffstat (limited to 'server/src')
-rw-r--r-- | server/src/parser/ast.lua | 4 | ||||
-rw-r--r-- | server/src/parser/grammar.lua | 2 | ||||
-rw-r--r-- | server/src/vm/emmy.lua | 23 | ||||
-rw-r--r-- | server/src/vm/function.lua | 12 | ||||
-rw-r--r-- | server/src/vm/vm.lua | 2 |
5 files changed, 40 insertions, 3 deletions
diff --git a/server/src/parser/ast.lua b/server/src/parser/ast.lua index d6d6c0c9..9903dca2 100644 --- a/server/src/parser/ast.lua +++ b/server/src/parser/ast.lua @@ -1304,6 +1304,10 @@ local Defs = { className, methodName } end, + EmmyOverLoad = function (EmmyFunctionType) + EmmyFunctionType.type = 'emmyOverLoad' + return EmmyFunctionType + end, EmmyIncomplete = function (emmyName) emmyName.type = 'emmyIncomplete' return emmyName diff --git a/server/src/parser/grammar.lua b/server/src/parser/grammar.lua index 11ee6901..50f76d0b 100644 --- a/server/src/parser/grammar.lua +++ b/server/src/parser/grammar.lua @@ -530,6 +530,7 @@ EmmyBody <- 'class' %s+ EmmyClass -> EmmyClass / 'vararg' %s+ EmmyVararg -> EmmyVararg / 'language' %s+ EmmyLanguage -> EmmyLanguage / 'see' %s+ EmmySee -> EmmySee + / 'overload' %s+ EmmyOverLoad -> EmmyOverLoad / EmmyIncomplete EmmyName <- ({} {[a-zA-Z_] [a-zA-Z0-9_]*}) @@ -591,6 +592,7 @@ EmmyFunctionRtn <- ':' %s* EmmyType EmmyFunctionArg <- MustEmmyName %s* ':' %s* EmmyType EmmySee <- {} MustEmmyName %s* '#' %s* MustEmmyName {} +EmmyOverLoad <- EmmyFunctionType ]] grammar 'Lua' [[ diff --git a/server/src/vm/emmy.lua b/server/src/vm/emmy.lua index 42f3a72a..3ad0a472 100644 --- a/server/src/vm/emmy.lua +++ b/server/src/vm/emmy.lua @@ -8,6 +8,7 @@ function mt:clearEmmy() self._emmyReturns = nil self._emmyGeneric = nil self._emmyComment = nil + self._emmyOverLoads = nil end function mt:doEmmy(action) @@ -37,6 +38,8 @@ function mt:doEmmy(action) self:doEmmyFunctionType(action) elseif tp == 'emmySee' then self:doEmmySee(action) + elseif tp == 'emmyOverLoad' then + self:doEmmyOverLoad(action) elseif tp == 'emmyIncomplete' then self:doEmmyIncomplete(action) elseif tp == 'emmyComment' then @@ -64,6 +67,13 @@ function mt:addEmmyReturn(rtn) self._emmyReturns[#self._emmyReturns+1] = rtn end +function mt:addEmmyOverLoad(funcObj) + if not self._emmyOverLoads then + self._emmyOverLoads = {} + end + self._emmyOverLoads[#self._emmyOverLoads+1] = funcObj +end + function mt:getEmmyParams() local params = self._emmyParams self._emmyParams = nil @@ -76,6 +86,12 @@ function mt:getEmmyReturns() return returns end +function mt:getEmmyOverLoads() + local overLoads = self._emmyOverLoads + self._emmyOverLoads = nil + return overLoads +end + function mt:getEmmyGeneric() local generic = self._emmyGeneric self._emmyGeneric = nil @@ -302,12 +318,12 @@ function mt:buildEmmyFunctionType(source) func:setReturn(1, value) end funcObj:bindFunction(func) - self._emmy = funcObj return funcObj end function mt:doEmmyFunctionType(action) local funcObj = self:buildEmmyFunctionType(action) + self._emmy = funcObj return funcObj end @@ -338,3 +354,8 @@ function mt:doEmmySee(action) self:instantSource(action[2]) action[2]:set('emmy see', action) end + +function mt:doEmmyOverLoad(action) + local funcObj = self:buildEmmyFunctionType(action) + self:addEmmyOverLoad(funcObj) +end diff --git a/server/src/vm/function.lua b/server/src/vm/function.lua index 60498033..8f7ac6c2 100644 --- a/server/src/vm/function.lua +++ b/server/src/vm/function.lua @@ -465,7 +465,7 @@ function mt:markGlobal() end end -function mt:setEmmy(params, returns) +function mt:setEmmy(params, returns, overLoads) if params then self._emmyParams = params for _, param in ipairs(params) do @@ -479,6 +479,12 @@ function mt:setEmmy(params, returns) rtn:getSource():set('emmy function', self) end end + if overLoads then + self._emmyOverLoads = overLoads + for _, ol in ipairs(overLoads) do + ol:getSource():set('emmy function', self) + end + end end ---@param comment string @@ -495,6 +501,10 @@ function mt:getEmmyParams() return self._emmyParams end +function mt:getEmmyOverLoads() + return self._emmyOverLoads +end + local function create(source) if not source then error('Function need source') diff --git a/server/src/vm/vm.lua b/server/src/vm/vm.lua index 3a884404..f8632dab 100644 --- a/server/src/vm/vm.lua +++ b/server/src/vm/vm.lua @@ -1097,7 +1097,7 @@ end function mt:createFunction(source) local value = self:createValue('function', source) local func = functionMgr.create(source) - func:setEmmy(self:getEmmyParams(), self:getEmmyReturns()) + func:setEmmy(self:getEmmyParams(), self:getEmmyReturns(), self:getEmmyOverLoads()) func:setComment(self:getEmmyComment()) value:setFunction(func) value:setType('function', 1.0) |