diff options
| author | s-ol <s+removethis@s-ol.nu> | 2022-02-04 16:11:29 +0000 |
|---|---|---|
| committer | s-ol <s+removethis@s-ol.nu> | 2025-03-02 14:24:49 +0000 |
| commit | 6b2a58f017529b0491ce7b639974f549a4f14889 (patch) | |
| tree | 126bada6853c060385a11d6c3b3bd557c322e8da /alv | |
| parent | add Dummy AST node (diff) | |
| download | alive-6b2a58f017529b0491ce7b639974f549a4f14889.tar.gz alive-6b2a58f017529b0491ce7b639974f549a4f14889.zip | |
lib: use Op:update_out
Diffstat (limited to 'alv')
| -rw-r--r-- | alv/base/op.moon | 9 | ||||
| -rw-r--r-- | alv/builtins.moon | 8 |
2 files changed, 7 insertions, 10 deletions
diff --git a/alv/base/op.moon b/alv/base/op.moon index e751145..4153a52 100644 --- a/alv/base/op.moon +++ b/alv/base/op.moon @@ -170,16 +170,13 @@ class Op -- @tparam Type type -- @tparam[opt] any val initial value update_out: (metatype, type, val) => - same_type = @out and @out.type == type - if same_type and @out.metatype == metatype + if @out and @out.type == type and @out.metatype == metatype -- we can just keep it. do nothing. - return - - -- prefer last value if applicable - val = same_type and @.out! or val + return false ResultType = if metatype == '!' then EvtStream else SigStream @out = ResultType type, val + true --- `\unwrap` all `Input`s in `@inputs` and return a table with the same -- shape. diff --git a/alv/builtins.moon b/alv/builtins.moon index 5fe5e99..622a59e 100644 --- a/alv/builtins.moon +++ b/alv/builtins.moon @@ -441,9 +441,9 @@ to_const = Constant.meta value: class extends Op setup: (inputs) => - super {} input = const!\match inputs - @out = input\type!\mk_const input.result! + super value: Input.hot input + @out = input.result to_sig = Constant.meta meta: @@ -492,7 +492,7 @@ to_evt = Constant.meta else super sig: Input.hot sig_ - @out = @inputs.sig\type!\mk_evt! + @update_out '!', @inputs.sig\type! tick: (setup) => return if setup @@ -514,7 +514,7 @@ In case of collisions, the event that comes first in the argument list wins." setup: (inputs) => values = pattern\match inputs super [Input.hot v for v in *values] - @out = @inputs[1]\type!\mk_evt! + @update_out '!', @inputs[1]\type! tick: => for input in *@inputs |
