diff options
Diffstat (limited to 'server/src')
-rw-r--r-- | server/src/emmy/arrayType.lua | 7 | ||||
-rw-r--r-- | server/src/emmy/manager.lua | 10 | ||||
-rw-r--r-- | server/src/parser/ast.lua | 12 | ||||
-rw-r--r-- | server/src/parser/grammar.lua | 9 | ||||
-rw-r--r-- | server/src/vm/emmy.lua | 5 |
5 files changed, 25 insertions, 18 deletions
diff --git a/server/src/emmy/arrayType.lua b/server/src/emmy/arrayType.lua index 3c6a7b7b..c5d73500 100644 --- a/server/src/emmy/arrayType.lua +++ b/server/src/emmy/arrayType.lua @@ -19,17 +19,18 @@ end function mt:setValue(value) self.value = value - self:getSource():get('emmy.typeUnit'):setValue(value) + self._child:setValue(value) end function mt:getValue() return self.value end -return function (manager, source) +return function (manager, source, child) local self = setmetatable({ - name = source[1], + name = child:getName(), source = source.id, + _child = child, _manager = manager, }, mt) return self diff --git a/server/src/emmy/manager.lua b/server/src/emmy/manager.lua index 9b6978b9..fc7180bd 100644 --- a/server/src/emmy/manager.lua +++ b/server/src/emmy/manager.lua @@ -110,13 +110,9 @@ function mt:addType(source) 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 + local typeObj = self:addType(source) + local arrayTypeObj = newArrayType(self, source, typeObj) + return arrayTypeObj end function mt:addTableType(source, keyType, valueType) diff --git a/server/src/parser/ast.lua b/server/src/parser/ast.lua index 52b34343..1d44c848 100644 --- a/server/src/parser/ast.lua +++ b/server/src/parser/ast.lua @@ -1211,9 +1211,11 @@ local Defs = { result.finish = result[#result].finish return result end, - EmmyArrayType = function (typeName) - typeName.type = 'emmyArrayType' - return typeName + EmmyArrayType = function (start, emmy, _, finish) + emmy.type = 'emmyArrayType' + emmy.start = start + emmy.finish = finish - 1 + return emmy end, EmmyTableType = function (start, keyType, valueType, finish) return { @@ -1238,7 +1240,9 @@ local Defs = { return {...} end, EmmyFunctionArgs = function (...) - return {...} + local args = {...} + args[#args] = nil + return args end, EmmyAlias = function (name, emmyName, ...) return { diff --git a/server/src/parser/grammar.lua b/server/src/parser/grammar.lua index c20f5b32..bf725189 100644 --- a/server/src/parser/grammar.lua +++ b/server/src/parser/grammar.lua @@ -68,6 +68,7 @@ defs.Reserved = function (_, _, str) end return false end +defs.None = function () end defs.np = m.Cp() / function (n) return n+1 end m.setmaxstack(1000) @@ -587,7 +588,9 @@ EmmyVararg <- EmmyType EmmyLanguage <- MustEmmyName -EmmyArrayType <- (MustEmmyName '[]') +EmmyArrayType <- ({} MustEmmyName -> EmmyCommonType {} '[' DirtyBR) + -> EmmyArrayType + / ({} PL EmmyCommonType DirtyPR '[' DirtyBR) -> EmmyArrayType EmmyTableType <- ({} 'table' Cut '<' %s* EmmyType %s* ',' %s* EmmyType %s* '>' {}) @@ -595,9 +598,9 @@ EmmyTableType <- ({} 'table' Cut '<' %s* EmmyType %s* ',' %s* EmmyType %s* '> EmmyFunctionType<- ({} 'fun' Cut %s* EmmyFunctionArgs %s* EmmyFunctionRtns {}) -> EmmyFunctionType -EmmyFunctionArgs<- ('(' %s* EmmyFunctionArg %s* (',' %s* EmmyFunctionArg %s*)* ')') +EmmyFunctionArgs<- ('(' %s* EmmyFunctionArg %s* (',' %s* EmmyFunctionArg %s*)* DirtyPR) -> EmmyFunctionArgs - / '(' %nil ')'? + / '(' %nil DirtyPR -> None / %nil EmmyFunctionRtns<- (':' %s* EmmyType (%s* ',' %s* EmmyType)*) -> EmmyFunctionRtns diff --git a/server/src/vm/emmy.lua b/server/src/vm/emmy.lua index 5a15d3b0..45fb13f9 100644 --- a/server/src/vm/emmy.lua +++ b/server/src/vm/emmy.lua @@ -259,7 +259,10 @@ function mt:buildEmmyArrayType(action) ---@type emmyMgr local emmyMgr = self.emmyMgr self:instantSource(action) - action:set('emmy class', action[1]) + for _, obj in ipairs(action) do + self:instantSource(obj) + action:set('emmy class', obj[1]) + end local type = emmyMgr:addArrayType(action) return type end |