aboutsummaryrefslogtreecommitdiffstats
path: root/alv/base
diff options
context:
space:
mode:
authors-ol <s-ol@users.noreply.github.com>2020-05-08 11:41:56 +0000
committers-ol <s+removethis@s-ol.nu>2025-03-02 14:23:21 +0000
commitbec1ebf1209c5a56ad4208d820222cb497b5f98c (patch)
tree0663fbbd99d580b55b7aa611b415afd946b738bb /alv/base
parentfix docs (diff)
downloadalive-bec1ebf1209c5a56ad4208d820222cb497b5f98c.tar.gz
alive-bec1ebf1209c5a56ad4208d820222cb497b5f98c.zip
rename RTNode.value to RTNode.result (to match Result class)
Diffstat (limited to 'alv/base')
-rw-r--r--alv/base/builtin.moon6
-rw-r--r--alv/base/input.moon13
-rw-r--r--alv/base/match.moon10
-rw-r--r--alv/base/op.moon14
4 files changed, 21 insertions, 22 deletions
diff --git a/alv/base/builtin.moon b/alv/base/builtin.moon
index f675207..5f46f37 100644
--- a/alv/base/builtin.moon
+++ b/alv/base/builtin.moon
@@ -31,7 +31,7 @@ class Builtin
--
-- @tparam Scope scope the active scope
-- @tparam {AST,...} tail the arguments to this expression
- -- @treturn Result the result of this evaluation
+ -- @treturn RTNode the result of this evaluation
eval: (scope, tail) => error "not implemented"
--- free resources
@@ -62,12 +62,12 @@ class Builtin
-- Create a new instance using `tag` and `head` and call `setup` on it.
-- If a previous instance with the same `tag` exists and has the same `head`,
-- it pass it to `setup`. Register the `Builtin` with `tag`, evaluate it
- -- and return the `Result`.
+ -- and return the `RTNode`.
--
-- @tparam Cell cell the `Cell` being evaluated
-- @tparam Scope scope the active scope
-- @tparam Value head the (`AST:eval`d) head of the `Cell` being evaluated
- -- @treturn Result the result of evaluation
+ -- @treturn RTNode the result of evaluation
@eval_cell: (cell, scope, head) =>
last = cell.tag\last!
compatible = last and (last.__class == @) and last.head == head
diff --git a/alv/base/input.moon b/alv/base/input.moon
index dea91c9..a9f0e32 100644
--- a/alv/base/input.moon
+++ b/alv/base/input.moon
@@ -35,7 +35,7 @@ class Input
--- create a new Input.
--
-- @classmethod
- -- @tparam Stream stream
+ -- @tparam Result stream
new: (@stream) =>
assert @stream, "nil passed to Input: #{value}"
@@ -98,26 +98,27 @@ class Input
-- Never marked dirty. Use this for input streams that are only read when
-- another `Input` is dirty.
--
- -- @tparam Stream|RTNode value
+ -- @tparam Result|RTNode value
@cold: (value) ->
if value.__class == RTNode
- value = assert value.value, "Input from result without value!"
+ value = assert value.result, "Input from node without result!"
ColdInput value
--- Create a `hot` `Input`.
--
- -- Behaviour depends on what kind of `Stream` `value` is:
+ -- Behaviour depends on what kind of `Result` `value` is:
--
+ -- - `Constant`: treated like `cold`.
-- - `SigStream`: Marked dirty only if old and new `SigStream` differ.
-- - `EvtStream` and `IOStream`: Marked dirty only if the current
-- `EvtStream` is dirty.
--
-- This is the most common `Input` strategy.
--
- -- @tparam Stream|RTNode value
+ -- @tparam Result|RTNode value
@hot: (value) ->
if value.__class == RTNode
- value = assert value.value, "Input from result without value!"
+ value = assert value.result, "Input from node without result!"
InputType = match_parent value, mapping
assert InputType, "Input from unknown value: #{value}"
diff --git a/alv/base/match.moon b/alv/base/match.moon
index 3a2b3d5..926c970 100644
--- a/alv/base/match.moon
+++ b/alv/base/match.moon
@@ -49,14 +49,12 @@ import Primitive from require 'alv.type'
local Repeat, Sequence, Choice, Optional
-typestr = (result) -> tostring result.value
-
class Pattern
match: (seq) =>
@reset!
num, cap = @capture seq, 1
if num != #seq
- args = table.concat [typestr arg for arg in *seq], ' '
+ args = table.concat [arg.result\fulltype! for arg in *seq], ' '
msg = "couldn't match arguments (#{args}) against pattern #{@}"
error Error 'argument', msg
cap
@@ -86,15 +84,15 @@ class Pattern
cls.__base.__div or= @__div
cls.__base.__unm or= @__unm
---- Base Stream Pattern.
+--- Base Result Pattern.
--
--- When instantiated with `type`, only succeeds for `Stream`s whose value and
+-- When instantiated with `type`, only succeeds for `Result`s whose value and
-- meta types match.
--
-- Otherwise, matches Streams based only on `metatype` for the first match, but
-- using both afterwards (recall mode).
--
--- @function Stream
+-- @function Type
-- @tparam string metatype "value" or "event"
-- @tparam ?string type type name
class Type extends Pattern
diff --git a/alv/base/op.moon b/alv/base/op.moon
index b0a83dc..da90288 100644
--- a/alv/base/op.moon
+++ b/alv/base/op.moon
@@ -46,9 +46,9 @@ class Op
--
-- @tfield table state
- --- `Stream` instance representing this Op's computed output value.
+ --- `Result` instance representing this Op's computed output value.
--
- -- Must be set to a `Stream` instance once `setup` finishes. Must not change
+ -- Must be set to a `Result` instance once `setup` finishes. Must not change
-- type, be removed or replaced outside of `new` and `setup`. If it is a
-- `ValueStream`, it should have a value assigned via `set` or the
-- constructor once `tick` is called the first time. If `out`'s value is not
@@ -56,7 +56,7 @@ class Op
-- `tick``(true)` is called at least on the first eval-cycle the Op goes
-- through, e.g. by using an `Input.hot` with a `ValueStream`.
--
- -- @tfield Stream out
+ -- @tfield Result out
--- table containing `Input`s to this Op.
--
@@ -79,18 +79,18 @@ class Op
--
-- @function new
-- @classmethod
- -- @tparam ?Stream out `out`
+ -- @tparam ?Result out `out`
-- @tparam ?table state `state`
--- parse arguments and patch self.
--
- -- Called once every eval-cycle. `inputs` is a list of `Result`s that are the
+ -- Called once every eval-cycle. `inputs` is a list of `RTNode`s that are the
-- argument to this op. The `inputs` have to be wrapped in `Input` instances
-- to define update behaviour. Use `base.match` to parse them, then delegate to
-- `super:setup` to patch the `Input` instances.
--
-- @function setup
- -- @tparam {Result,...} inputs a sequence of `Result`s
+ -- @tparam {RTNode,...} inputs a sequence of `RTNode`s
-- @tparam Scope scope the active scope
--- handle incoming events and update `out` (optional).
@@ -120,7 +120,7 @@ class Op
-- type is not known at this time.
--
-- @classmethod
- -- @tparam ?Stream out `out`
+ -- @tparam ?Result out `out`
-- @tparam ?table state `state`
new: (@out, @state) =>