csys: work in progress: programs and stages
This commit is contained in:
parent
157c013c44
commit
2a64fcb1cf
1 changed files with 18 additions and 11 deletions
|
|
@ -17,18 +17,8 @@ defmodule Scopes.CSys.Program do
|
|||
|
||||
# processors
|
||||
|
||||
def notify(msg, scope) do
|
||||
Environ.notify(env(scope), msg)
|
||||
end
|
||||
|
||||
def forward(msg, scope) do
|
||||
Enum.reduce(syns(scope), false, fn s, _acc -> s.(msg); true end)
|
||||
end
|
||||
|
||||
def std_proc({:parent}, scope) do
|
||||
env = env(scope)
|
||||
syn = synapse(self(), &Function.identity/1, 0)
|
||||
new = neuron({[], Environ.get_stage(env, :basic, :initial), [syn], env})
|
||||
new = create_parent(env(scope))
|
||||
notify({:created, new}, scope)
|
||||
end
|
||||
|
||||
|
|
@ -43,4 +33,21 @@ defmodule Scopes.CSys.Program do
|
|||
def std_proc(msg, scope) do
|
||||
forward(msg, scope) || notify(msg, scope)
|
||||
end
|
||||
|
||||
# processor steps
|
||||
|
||||
def notify(msg, scope) do
|
||||
Environ.notify(env(scope), msg)
|
||||
end
|
||||
|
||||
def forward(msg, scope) do
|
||||
Enum.reduce(syns(scope), false, fn s, _acc -> s.(msg); true end)
|
||||
end
|
||||
|
||||
# step functions
|
||||
|
||||
def create_parent(env) do
|
||||
syn = synapse(self(), &Function.identity/1, 0)
|
||||
neuron({[], Environ.get_stage(env, :basic, :initial), [syn], env})
|
||||
end
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue