You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add support for a limited form of returning values from layer blocks.
With this patch, when a `Data` is returned from a layer block, this will
now cause the creation of a wire of layer-colored probe type that is
driven by a probe of the return value. There is additional handling to
directly return a probe type as well (which enables returning from an
inner layer block up through an outer layer block). If a non-`Data` is
returned, then this will be converted to a `Unit`. This latter behavior
is the current behavior.
Signed-off-by: Schuyler Eldridge <[email protected]>
s"a layerblock associated with layer '${_layer.fullName}' cannot be created under a layerblock of non-ancestor layer '${Builder.layerStack.head.fullName}'"
351
362
)
352
363
364
+
if (layersToCreate.isEmpty)
365
+
return tc.identity(thunk)
366
+
353
367
addLayer(_layer)
354
368
369
+
// Save the append point _before_ the layer block so that we can insert a
370
+
// layer-colored wire once the `thunk` executes.
371
+
valbeforeLayerBlock=newPlaceholder
372
+
373
+
// Track the current layer block. When this is used, this will be the
374
+
// innermost layer block that will be created. This is guaranteed to be
375
+
// non-null as long as `layersToCreate` is not empty.
376
+
varlayerBlock:LayerBlock=null
377
+
378
+
// Recursively create any necessary layers. There are two cases:
379
+
//
380
+
// 1. There are no layers left to create. Run the thunk, create the
381
+
// layer-colored wire, and define it.
382
+
// 2. There are layers left to create. Create the next layer and recurse.
355
383
defcreateLayers(layers: List[Layer])(thunk: =>A):A= layers match {
0 commit comments