You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
30 lines
657 B
Lua
30 lines
657 B
Lua
--- Helper module for symbolically representing a variable.
|
|
-- @classmod lqc.fsm.var
|
|
-- @alias var
|
|
local Var = {}
|
|
local Var_mt = {
|
|
__index = Var,
|
|
}
|
|
|
|
--- Creates a symbolic representation of a variable.
|
|
-- @param value Value of the variable
|
|
-- @return a new variable object
|
|
function Var.new(value)
|
|
if value == nil then
|
|
error 'Need to provide a value to Var!'
|
|
end
|
|
local var = {
|
|
value = value,
|
|
}
|
|
return setmetatable(var, Var_mt)
|
|
end
|
|
|
|
--- Returns a string representation of the variable
|
|
-- @return string representation of the variable
|
|
function Var:to_string()
|
|
return '{ var, ' .. self.value .. ' }'
|
|
end
|
|
|
|
return Var
|
|
|