summaryrefslogtreecommitdiff
path: root/server/src/vm/emmy.lua
blob: 949ffa0589741541f37bdadabdbc3d006ec2276b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
local mt = require 'vm.manager'

function mt:clearEmmy()
    self._emmy = nil
end

function mt:doEmmy(action)
    local tp = action.type
    if tp == 'emmyClass' then
        self:doEmmyClass(action)
    elseif tp == 'emmyType' then
        self:doEmmyType(action)
    elseif tp == 'emmyAlias' then
    elseif tp == 'emmyParam' then
    elseif tp == 'emmyReturn' then
    elseif tp == 'emmyField' then
    elseif tp == 'emmyGeneric' then
    elseif tp == 'emmyVararg' then
    elseif tp == 'emmyLanguage' then
    elseif tp == 'emmyArrayType' then
    elseif tp == 'emmyTableType' then
    elseif tp == 'emmyFunctionType' then
    elseif tp == 'emmySee' then
    elseif tp == 'emmyIncomplete' then
        self:doEmmyIncomplete(action)
    end
end

function mt:getEmmy()
    local emmy = self._emmy
    self._emmy = nil
    return emmy
end

function mt:doEmmyClass(action)
    local emmyMgr = self.emmyMgr
    self:instantSource(action)
    local class = emmyMgr:addClass(action)
    local extends = action[2]
    if extends then
        self:instantSource(extends)
        extends:set('target class', extends[1])
    end
    self._emmy = class
    action:set('emmy.class', class)
end

function mt:doEmmyType(action)
    local emmyMgr = self.emmyMgr
    self:instantSource(action)
    local type = emmyMgr:createType(action)
    self._emmy = type
    action:set('emmy.type', type)
    for _, obj in ipairs(action) do
        self:instantSource(obj)
        obj:set('target class', obj[1])
    end
end

function mt:doEmmyIncomplete(action)
    self:instantSource(action)
end