Initial work on pipelines
This commit is contained in:
parent
4b147d64a0
commit
69fc4e24ee
11 changed files with 525 additions and 72 deletions
28
faststreams/pipelines.nim
Normal file
28
faststreams/pipelines.nim
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
import
|
||||
macros,
|
||||
input_stream, output_stream
|
||||
|
||||
export
|
||||
input_stream, output_stream
|
||||
|
||||
macro executePipeline*(start: InputStream, steps: varargs[untyped]) =
|
||||
var input = start
|
||||
result = newStmtList()
|
||||
|
||||
for i in 0 .. steps.len - 2:
|
||||
var
|
||||
step = steps[i]
|
||||
outputVar = genSym(nskVar, "out")
|
||||
output = if i == steps.len - 2: steps[^1]
|
||||
else: newCall(bindSym"memoryOutput")
|
||||
|
||||
result.add quote do:
|
||||
var `outputVar` = `output`
|
||||
`step`(`input`, `outputVar`)
|
||||
|
||||
input = quote do:
|
||||
memoryInput(getOutput(`outputVar`))
|
||||
|
||||
if defined(debugMacros) or defined(debugPipelines):
|
||||
echo result.repr
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue