aboutsummaryrefslogtreecommitdiffstats
path: root/core/base
diff options
context:
space:
mode:
authors-ol <s-ol@users.noreply.github.com>2020-03-18 17:50:33 +0000
committers-ol <s-ol@users.noreply.github.com>2020-03-18 18:03:04 +0000
commita49382c7b46c7bdf1c105c0783c7bdcd0bb70e4a (patch)
treec1f800736e1905514aa913630ee31a720e770c9e /core/base
parentdocs/internal: add builtins and invoke modules (diff)
downloadalive-a49382c7b46c7bdf1c105c0783c7bdcd0bb70e4a.tar.gz
alive-a49382c7b46c7bdf1c105c0783c7bdcd0bb70e4a.zip
fork ops before eval cycle
Diffstat (limited to 'core/base')
-rw-r--r--core/base/op.moon12
1 files changed, 12 insertions, 0 deletions
diff --git a/core/base/op.moon b/core/base/op.moon
index f338673..08c47ab 100644
--- a/core/base/op.moon
+++ b/core/base/op.moon
@@ -19,6 +19,17 @@ class Op
-- @treturn iterator iterator over `inputs`
all_inputs: => coroutine.wrap -> do_yield @inputs
+ --- create a mutable copy of this Op.
+ --
+ -- Used to wrap insulate eval-cycles from each other. The copy does not have
+ -- `inputs` set, since it is expected that this is (re)set in `setup`.
+ --
+ -- @treturn Value
+ fork: =>
+ with setmetatable {}, getmetatable @
+ .state = {k,v for k,v in pairs @state} if @state
+ .out = @out\fork! if @out
+
--- `Value` instance representing this Op's computed output value.
--
-- Must be set to a `Value` instance once `setup` finishes. Must not change
@@ -92,6 +103,7 @@ class Op
-- @tparam[opt] string type the type-name for `out`
-- @tparam[optchain] any init the initial value for `out`
new: (type, init) =>
+ @state = {}
if type
@out = Value type, init