Commit graph

18 commits

Author SHA1 Message Date
9c4cc09021 Copy variables when storing them on the stack 2022-09-17 10:21:06 +02:00
0519be9316 Changed how variables work again
Script variables are not longer saved before entering a block. Only
variables declared as locals and loop variables are saved. This allows a
block to use `set_var` to change a variable.
2022-09-17 10:10:18 +02:00
46e675dedb Cleaner implementation of the variable cache
* Separate implementation that acts as a MutableMapping
  * I'm still not sure about this. Also, there is a design error in
    there, because it's not possible to "return" a value from a block
    unless it's written to a fact.
2022-09-07 21:24:07 +02:00
b79e9f8faf Some comments 2022-09-04 23:44:02 +02:00
cbe1bd65bf loop - Always process the value using the templar
* When the loop value is a list, its items may be templates or
    structures which contain templates. Because of that, they need to go
    through the templar.
2022-09-04 23:37:01 +02:00
91ff8296d6 More cache/loop fixes
* When the loop variable state is restored, the cache must also be
    modified.
  * What needs to be done depends on whether a host fact by the same
    name also exist.
  * Fuck that cache thing. It's going away next time I can hack on this.
2022-09-04 23:20:26 +02:00
57bf02e79d Variable cache - Reset after block execution
* When a block is done executing, local variables must be restored to
    their previous values ; however, host variables may have been
    updated inside the block. Therefore it is necessary to reset the
    variable cache.
2022-09-04 23:16:56 +02:00
d1d997f7ae Actually use the variable cache
* The merged (host+local) variable cache should not be reset at each
    instruction.
2022-09-04 23:14:01 +02:00
7e5eb8e414 Fixed caching problem in set_fact
* Since facts have a lower priority than local variables, set_fact
    should only update the cache if no local variable uses the same
    name
2022-09-04 23:00:15 +02:00
a5b1ac5c4c Better loop variable state handling
* Loops caused local scripts variables to be backed up then restored,
    which would have caused a set_var in a loop to have no effect.
  * Instead, we back up the state of the variable (existing or not,
    value) and either restore the original value or delete the variable
    if it didn't exist.
2022-09-04 22:54:03 +02:00
1b1c1281a2 Use abc for the instruction class and its abstract methods 2022-09-04 22:44:06 +02:00
c587f1479c Fixed weird indentation 2022-09-04 12:21:09 +02:00
36477385a1 Changed the long debugging output for loop/when 2022-09-04 12:20:49 +02:00
cc439110ae Remove allowed field names from instruction data
* It's pointless to have a distinct set of allowed fields for each
    instruction in the program
2022-09-04 11:50:42 +02:00
5ef2ffc55c Debugging support
* Support for dumping parsed programs as strings (both a basic,
    repr-like version and an indented version that is easier to read)
  * Display the parsed program if verbosity is high enough
  * Program tracing if verbosity is high enough
2022-09-04 11:35:07 +02:00
7b44cdc731 create_group - add_host and parent options
* The `add_host` option can be used to add the current host to the
    group being created. It avoids having to use a separate `add_host`
    instruction in this case.
  * The `parent` option can specify the parent group. It avoids having
    to use a separate `add_child` instruction in this case.
2022-09-03 10:43:01 +02:00
5f719d7ab8 "block" instruction implemented
The "block" instruction allows mulitple instructions to be grouped in
order to be executed based on a single condition, in a common loop, with
a local variable scope. In addition, it provides a way to recover from
errors.
2022-09-02 20:26:36 +02:00
17aa8e8c46 Initial import of the WIP plugin 2022-09-02 18:00:22 +02:00