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

Don't commit on function call

This commit is contained in:
Étienne Fildadut 2021-04-12 17:41:17 +02:00
parent e454888b9f
commit 977aa5dadd
2 changed files with 5 additions and 9 deletions

View file

@ -119,7 +119,7 @@ The purpose of this system is both to allow several scripts to run at the same t
Checkpoints are set per function. Paragraphs are expected to be defined inside functions only.
Commiting also happens after a function or paragraph has been manually called.
Commiting also happens after a paragraph has been manually called or resumed from.
### Lines types
@ -533,8 +533,6 @@ $ f
this is text: {f}
```
Functions commit variables after a call.
#### Paragraph calls
Most of the time, you should'nt need to call paragraphs yourself - they will be automatically be set as the active checkpoint when the interperter reach their line, and they will be automatically called when resuming its parent function.
@ -576,7 +574,7 @@ And will resume from the checkpoint like before:
Method style calling is also possible, like with functions.
Paragraphs commit variables after a call.
Paragraphs commit variables after being called (either manually or automatically from resuming a function). The commit always happen after the paragraph's child block has been ran.
Please also be aware that when resuming from a paragraph, Anselme will try to restore the interpreter state as if the function was correctly executed from the start up to this paragraph. This includes:

View file

@ -1,7 +1,7 @@
local expression
local flush_state, to_lua, from_lua, eval_text
local to_lua, from_lua, eval_text
local run, run_block
local run
local unpack = table.unpack or unpack
@ -134,7 +134,6 @@ local function eval(state, exp)
type = "number",
value = state.variables[fn.value.namespace.."👁️"].value + 1
}
flush_state(state)
return r
else
return nil, ("unknown function type %q"):format(fn.value.type)
@ -169,9 +168,8 @@ end
package.loaded[...] = eval
run = require((...):gsub("expression$", "interpreter")).run
run_block = require((...):gsub("expression$", "interpreter")).run_block
expression = require((...):gsub("interpreter%.expression$", "parser.expression"))
local common = require((...):gsub("expression$", "common"))
flush_state, to_lua, from_lua, eval_text = common.flush_state, common.to_lua, common.from_lua, common.eval_text
to_lua, from_lua, eval_text = common.to_lua, common.from_lua, common.eval_text
return eval