1
0
Fork 0
mirror of https://github.com/Reuh/anselme.git synced 2025-10-27 16:49:31 +00:00

Constant aliases

This commit is contained in:
Étienne Fildadut 2023-12-28 13:05:52 +01:00
parent f574e6a775
commit e222f0fb28

View file

@ -124,12 +124,16 @@ local Environment = ast.abstract.Runtime {
local get = ast.Function:new(ast.ParameterTuple:new(), call):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)
if symbol.constant then
self:define(state, symbol, get)
else
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,
-- returns bool if variable defined in current or parent environment