1
0
Fork 0
mirror of https://github.com/Reuh/anselme.git synced 2025-10-28 00:59: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

View file

@ -1,6 +1,8 @@
local ast = require("ast")
local Nil, Return, AutoCall, ArgumentTuple, Flush
local resume_manager = require("state.resume_manager")
local Block = ast.abstract.Node {
type = "block",
@ -34,11 +36,11 @@ local Block = ast.abstract.Node {
_eval = function(self, state)
local r
state.scope:push()
if self:resuming(state) then
local resuming = self:get_resume_data(state)
if self:contains_resume_target(state) then
local anchor = resume_manager:get(state)
local resumed = false
for _, e in ipairs(self.expressions) do
if e == resuming then resumed = true end
if e:contains_anchor(anchor) then resumed = true end
if resumed then
r = e:eval(state)
if AutoCall:issub(r) then
@ -51,7 +53,6 @@ local Block = ast.abstract.Node {
end
else
for _, e in ipairs(self.expressions) do
self:set_resume_data(state, e)
r = e:eval(state)
if AutoCall:issub(r) then
r = r:call(state, ArgumentTuple:new())