aboutsummaryrefslogtreecommitdiffstats
path: root/core
diff options
context:
space:
mode:
authors-ol <s-ol@users.noreply.github.com>2020-03-02 18:00:54 +0000
committers-ol <s-ol@users.noreply.github.com>2020-03-02 18:00:54 +0000
commit79d483435a70c47c1711b3876d66077b4f1041d2 (patch)
treed19181a435bdf3e5ba374c67501df29da2d59d2c /core
parentonly :tick after :setup if dirty (diff)
downloadalive-79d483435a70c47c1711b3876d66077b4f1041d2.tar.gz
alive-79d483435a70c47c1711b3876d66077b4f1041d2.zip
find IO via Result tree, not Registry
Diffstat (limited to 'core')
-rw-r--r--core/invoke.moon2
-rw-r--r--core/registry.moon4
-rw-r--r--core/value.moon20
3 files changed, 15 insertions, 11 deletions
diff --git a/core/invoke.moon b/core/invoke.moon
index ba19cc5..3b2ddd5 100644
--- a/core/invoke.moon
+++ b/core/invoke.moon
@@ -15,7 +15,7 @@ class op_invoke extends Action
eval: (scope, tail) =>
children = L\push -> [L\push expr\eval, scope for expr in *tail]
- @op\setup [result for result in *children]
+ @op\setup [result for result in *children], scope
any_dirty = false
for input in @op\all_inputs!
diff --git a/core/registry.moon b/core/registry.moon
index ac1943a..ebe429c 100644
--- a/core/registry.moon
+++ b/core/registry.moon
@@ -23,10 +23,6 @@ class Registry
active: -> assert Registry.active_registry, "no active Registry!"
--- IO
- add_io: (io) => @io[io] = true
- remove_io: (io) => @io[io] = nil
-
-- public methods
wrap_eval: (fn) => (...) ->
diff --git a/core/value.moon b/core/value.moon
index b882507..b01b28f 100644
--- a/core/value.moon
+++ b/core/value.moon
@@ -1,9 +1,9 @@
-- ALV Value types
-local Scope, Registry, Op, Action, FnDef
+local Scope, Registry, Op, Action, IOInput, FnDef
load_ = ->
import Scope from require 'core.scope'
import Registry from require 'core.registry'
- import Op, Action, FnDef from require 'core.base'
+ import Op, Action, IOInput, FnDef from require 'core.base'
ancestor = (klass) ->
assert klass, "cant find the ancestor of nil"
@@ -29,15 +29,15 @@ class Result
@side_inputs, is_child = {}, {}
for child in *@children
- for d in pairs child.side_inputs
- @side_inputs[d] = true
+ for s, d in pairs child.side_inputs
+ @side_inputs[s] = d
if child.value
is_child[child.value] = true
if @op
for input in @op\all_inputs!
if input.impure or not is_child[input.stream]
- @side_inputs[input] = true
+ @side_inputs[input.stream] = input
is_const: => not next @side_inputs
@@ -57,12 +57,20 @@ class Result
with Result value: @value
.side_inputs = @side_inputs
+ -- tick all IO instances that are effecting this (sub) tree
+ -- should be called once per frame on the root, right before tick
+ tick_io: =>
+ for stream, input in pairs @side_inputs
+ if input.__class == IOInput
+ io = input!
+ io\tick!
+
-- in depth-first order, tick all Ops who have dirty Stream inputs or impulses
--
-- short-circuits if there are no dirty Streams in the entire subtree
tick: =>
any_dirty = false
- for input in pairs @side_inputs
+ for stream, input in pairs @side_inputs
if input\dirty!
any_dirty = true
break