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

Clean implementation of 👁️ and no longer increment 🏁 on checkpoint execution (redundant with 👁️)

This commit is contained in:
Étienne Fildadut 2022-10-03 18:10:47 +09:00
parent f79e2f5716
commit 2ff494d108
12 changed files with 115 additions and 77 deletions

View file

@ -397,8 +397,15 @@ local function eval(state, exp)
local fn = selected_variant.variant
if fn.type ~= "function" then
return nil, ("unknown function type %q"):format(fn.type)
-- checkpoint: no args and resume execution
-- checkpoint: no args and can resume execution
elseif fn.subtype == "checkpoint" then
-- set current checkpoint
local s, e = set_variable(state, fn.parent_resumable.namespace.."🔖", {
type = "function reference",
value = { fn.name }
})
if not s then return nil, e end
-- run checkpoint content, eventually resuming
local r, e = run(state, fn.child, not paren_call)
if not r then return nil, e end
return r
@ -423,8 +430,6 @@ local function eval(state, exp)
checkpoint, checkpointe = get_variable(state, fn.namespace.."🔖")
if not checkpoint then return nil, checkpointe end
end
local seen, seene = get_variable(state, fn.namespace.."👁️")
if not seen then return nil, seene end
-- execute lua functions
-- I guess we could technically skip getting & updating the seen and checkpoints vars since they can't be used from Anselme
-- but it's also kinda fun to known how many time a function was ran
@ -501,12 +506,6 @@ local function eval(state, exp)
end
if not ret then return nil, e end
end
-- update function vars
local s, e = set_variable(state, fn.namespace.."👁️", {
type = "number",
value = seen.value + 1
})
if not s then return nil, e end
-- for classes: build resulting object
if fn.subtype == "class" and ret and ret.type == "nil" then
ret = {