summaryrefslogtreecommitdiff
path: root/server/src/vm/dots.lua
blob: e9a1ac1565824b7ac4911cb029c9798e71cef390 (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
local createValue = require 'vm.value'

local mt = {}
mt.__index = mt
mt.type = 'dots'

function mt:set(n, value)
    self[n] = value
end

function mt:get(expect)
    local result = {}
    if expect then
        for i = 1, expect do
            result[i] = self[i] or createValue('any')
        end
    else
        for i = 1, #self do
            result[i] = self[i]
        end
    end
    return result
end

return function ()
    local self = setmetatable({}, mt)
    return self
end