aboutsummaryrefslogtreecommitdiffstats
path: root/alv
diff options
context:
space:
mode:
authors-ol <s-ol@users.noreply.github.com>2020-05-12 14:20:52 +0000
committers-ol <s-ol@users.noreply.github.com>2020-05-12 14:20:52 +0000
commit2aefc871b35db434fbc07af48cfe1b5f75a73076 (patch)
tree7128f5a336cbc232c593122b0ae65363e81d4c24 /alv
parentmake EvtStreams carry a single value (diff)
downloadalive-2aefc871b35db434fbc07af48cfe1b5f75a73076.tar.gz
alive-2aefc871b35db434fbc07af48cfe1b5f75a73076.zip
RTNode constifies constant SigStreams
Diffstat (limited to 'alv')
-rw-r--r--alv/base/input.moon19
-rw-r--r--alv/rtnode.moon18
2 files changed, 25 insertions, 12 deletions
diff --git a/alv/base/input.moon b/alv/base/input.moon
index b73a476..f29bd10 100644
--- a/alv/base/input.moon
+++ b/alv/base/input.moon
@@ -76,8 +76,11 @@ class Input
metatype: => @result.metatype
--- the current value
- --
- -- @tfield SigStream result
+ -- @tfield Result result
+
+ --- the Input mode
+ -- @tfield string mode `'hot'`, `'cold'` or `'io'`.
+ mode: 'hot'
--- members
-- @section members
@@ -125,17 +128,25 @@ class Input
InputType value
class ColdInput extends Input
+ mode: 'cold'
dirty: => false
class ValueInput extends Input
- setup: (old) => @dirty_setup = not old or @result != old.result
+ new: (result) =>
+ super result
+ @mode = if @result.metatype == '=' then 'cold' else 'hot'
+
+ setup: (old) =>
+ @dirty_setup = not old or @result != old.result
+
finish_setup: => @dirty_setup = nil
+
dirty: =>
return @dirty_setup if @dirty_setup != nil
@result\dirty!
class IOInput extends Input
- io: true
+ mode: 'io'
mapping = {
[Constant]: ValueInput
diff --git a/alv/rtnode.moon b/alv/rtnode.moon
index b10f9a1..23cffa5 100644
--- a/alv/rtnode.moon
+++ b/alv/rtnode.moon
@@ -45,7 +45,7 @@ class RTNode
-- should be called once per frame on the root, right before tick.
poll_io: =>
for result, input in pairs @side_inputs
- result\poll! if input.io
+ result\poll! if input.mode == 'io'
--- in depth-first order, tick all Ops which have dirty Inputs.
--
@@ -120,13 +120,15 @@ class RTNode
is_child[child.result] = true
if @op
- for input in @op\all_inputs!
- continue if input.result.metatype == '='
- if input.io or not is_child[input.result]
- @side_inputs[input.result] = input
-
- if @result and @result.metatype == '='
- assert not (next @side_inputs), "Const result has side_inputs"
+ for i in @op\all_inputs!
+ if i.mode == 'io' or (i.mode == 'hot' and not is_child[i.result])
+ @side_inputs[i.result] = i
+
+ if @result
+ if next @side_inputs
+ assert @result.metatype != '=', "Const result has side_inputs"
+ elseif @result.metatype == '~'
+ @result = @result.type\mk_const @result\unwrap!
{
:RTNode