mirror of
https://github.com/Reuh/anselme.git
synced 2025-10-28 00:59:31 +00:00
Constant aliases
This commit is contained in:
parent
f574e6a775
commit
e222f0fb28
1 changed files with 9 additions and 5 deletions
|
|
@ -124,12 +124,16 @@ local Environment = ast.abstract.Runtime {
|
||||||
|
|
||||||
local get = ast.Function:new(ast.ParameterTuple:new(), call):eval(state)
|
local get = ast.Function:new(ast.ParameterTuple:new(), call):eval(state)
|
||||||
|
|
||||||
local set_param = ast.ParameterTuple:new()
|
if symbol.constant then
|
||||||
set_param:insert_assignment(ast.FunctionParameter:new(ast.Identifier:new("value")))
|
self:define(state, symbol, get)
|
||||||
local assign_expr = ast.Call:new(call.func, call.arguments:with_assignment(ast.Identifier:new("value")))
|
else
|
||||||
local set = ast.Function:new(set_param, assign_expr):eval(state)
|
local set_param = ast.ParameterTuple:new()
|
||||||
|
set_param:insert_assignment(ast.FunctionParameter:new(ast.Identifier:new("value")))
|
||||||
|
local assign_expr = ast.Call:new(call.func, call.arguments:with_assignment(ast.Identifier:new("value")))
|
||||||
|
local set = ast.Function:new(set_param, assign_expr):eval(state)
|
||||||
|
|
||||||
self:define(state, symbol, ast.Overload:new(get, set))
|
self:define(state, symbol, ast.Overload:new(get, set))
|
||||||
|
end
|
||||||
end,
|
end,
|
||||||
|
|
||||||
-- returns bool if variable defined in current or parent environment
|
-- returns bool if variable defined in current or parent environment
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue