Current section

Files

Jump to
orb lib orb iterator.ex
Raw

lib/orb/iterator.ex

defmodule Orb.Iterator do
# def fetch(%Orb.VariableReference{} = var, :valid?), do: {:ok, Orb.I32.le_u(var, ?z)}
# def fetch(%Orb.VariableReference{} = var, :value), do: {:ok, var}
# def fetch(%Orb.VariableReference{} = var, :next), do: {:ok, Orb.I32.add(var, 1)}
@type var_ref :: %Orb.VariableReference{}
@doc """
Calculates whether the iterator is done or not.
"""
@callback valid?(var_ref) :: %Orb.Instruction{} | integer()
@doc """
The type for iterated elements.
"""
@callback value_type() :: atom() | tuple()
@doc """
Extracts or calculates the current element value.
"""
@callback value(var_ref) :: %Orb.Instruction{} | integer() | float()
@doc """
Mutates the iterator advancing it to the next element.
"""
@callback next(var_ref) :: %Orb.Instruction{} | integer() | float()
end