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

Replace checkpoint system

The previous system needed to store of the scope and full AST to build a Resumable object, which means that if persisted, updating the resumable script will have no effect.
The new system instead uses an anchor token and does not require any information besides the anchor name.
This commit is contained in:
Étienne Fildadut 2023-12-27 17:06:35 +01:00
parent c4636343b4
commit 56ed6c912b
21 changed files with 217 additions and 234 deletions

35
ast/Anchor.lua Normal file
View file

@ -0,0 +1,35 @@
local ast = require("ast")
local resume_manager
local Anchor
Anchor = ast.abstract.Node {
type = "anchor",
name = nil,
init = function(self, name)
self.name = name
self._list_anchors_cache = { [name] = true }
end,
_hash = function(self)
return ("anchor<%q>"):format(self.name)
end,
_format = function(self, ...)
return "#"..self.name
end,
_eval = function(self, state)
if self:contains_resume_target(state) then
resume_manager:set_reached(state)
end
return Anchor:new(self.name)
end
}
package.loaded[...] = Anchor
resume_manager = require("state.resume_manager")
return Anchor