summaryrefslogtreecommitdiff
path: root/server/src/core/value.lua
diff options
context:
space:
mode:
Diffstat (limited to 'server/src/core/value.lua')
-rw-r--r--server/src/core/value.lua17
1 files changed, 14 insertions, 3 deletions
diff --git a/server/src/core/value.lua b/server/src/core/value.lua
index f4aed441..1641ea5e 100644
--- a/server/src/core/value.lua
+++ b/server/src/core/value.lua
@@ -3,20 +3,29 @@ local DefaultSource = { start = 0, finish = 0 }
local mt = {}
mt.__index = mt
mt.type = 'value'
+mt._type = 'any'
function mt:setValue(source, value)
- self.value = value
+ self._value = value
+end
+
+function mt:getValue()
+ return self._value
end
function mt:inference(tp)
if tp == '...' then
error('Value type cant be ...')
end
- if self.type == 'any' and tp ~= 'nil' then
- self.type = tp
+ if self._type == 'any' and tp ~= 'nil' then
+ self._type = tp
end
end
+function mt:getType()
+ return self._type
+end
+
function mt:createField(name, source)
local field = {
type = 'field',
@@ -54,6 +63,7 @@ function mt:rawGetField(name, source)
end
end
end
+ return field
end
function mt:getField(name, source)
@@ -118,6 +128,7 @@ return function (tp, source, value)
end
local self = setmetatable({
source = source or DefaultSource,
+ _type = tp,
}, mt)
if value ~= nil then
self:setValue(source, value)