Skip to content

Commit

Permalink
Fix Set API, adjust process.j accordingly [closes #50].
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanKarpinski committed Oct 12, 2011
1 parent add194b commit 26c9709
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 5 deletions.
14 changes: 11 additions & 3 deletions j/process.j
Expand Up @@ -211,18 +211,24 @@ end

## building connected and disconnected pipelines ##

add_cmds(set::Set{Cmd}, cmd::Cmd) = add(set, cmd)
add_cmds(set::Set{Cmd}, cmds::Set{Cmds}) = (for cmd=cmds; add(set, cmd); end)

function (&)(cmds::Cmds...)
set = Set{Cmd}()
for cmd = cmds
add(set, cmd)
add_cmds(set, cmd)
end
set
end

add_ports(set::Set{Port}, port::Port) = add(set, port)
add_ports(set::Set{Port}, ports::Set{Ports}) = (for port=ports; add(set, port); end)

function (&)(ports::Ports...)
set = Set{Port}()
for port = ports
add(set, port)
add_ports(set, port)
end
set
end
Expand Down Expand Up @@ -250,7 +256,9 @@ function join(cmds::Cmds)
if length(cmds) > 1
pipeline = Set{Cmd}()
for cmd = cmds
add(pipeline, cmd.pipeline)
for c = cmd.pipeline
add(pipeline, c)
end
end
for cmd = pipeline
cmd.pipeline = pipeline
Expand Down
2 changes: 0 additions & 2 deletions j/set.j
Expand Up @@ -16,11 +16,9 @@ has(s::Set, x) = has(s.hash, x)

add(s::Set, x) = (s.hash[x] = true; s)
add(s::Set, xs...) = (for x=xs; add(s, x); end; s)
add(s::Set, s2::Set) = (for x=s2; add(s, x); end; s) # TODO: set API is broken

del(s::Set, x) = (del(s.hash, x); s)
del(s::Set, xs...) = (for x=xs; del(s, x); end; s)
del(s::Set, s2::Set) = (for x=s2; del(s, x); end; s) # TODO: set API is broken

del_all{T}(s::Set{T}) = (s.hash = HashTable{T,Bool}(); s)

Expand Down

0 comments on commit 26c9709

Please sign in to comment.