1
0

diplomacy: support := composition

This makes it possible to treat chained composition associatively.
x := y :=? z :=* a ...

It also makes it easy to chain multiple optional adapters:
node :=? (Seq(a, b) ++ c ++ d)
This commit is contained in:
Wesley W. Terpstra
2017-10-24 23:34:16 -07:00
parent b48ab985d0
commit e894d64bca
3 changed files with 57 additions and 23 deletions

View File

@ -71,6 +71,12 @@ object TLBuffer
buffer.node :=? x
buffer.node
}
def chain(depth: Int, name: Option[String] = None)(implicit p: Parameters): Seq[TLNode] = {
val buffers = Seq.fill(depth) { LazyModule(new TLBuffer()) }
name.foreach { n => buffers.zipWithIndex.foreach { case (b, i) => b.suggestName(s"${n}_${i}") } }
buffers.map(_.node)
}
}
object TLNodeChain {