Skip to content

Commit a61c9ef

Browse files
committed
improved ScalaDoc for DeserializeContext
1 parent 334149b commit a61c9ef

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

interpreter/shared/src/main/scala/sigmastate/utxo/transformers.scala

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -532,13 +532,22 @@ object ExtractCreationInfo extends SimpleTransformerCompanion {
532532

533533
trait Deserialize[V <: SType] extends NotReadyValue[V]
534534

535-
/** Extracts context variable as Coll[Byte], deserializes it to script and then executes this script in the current context.
536-
* The original `Coll[Byte]` of the script is available as `getVar[Coll[Byte]](id)`
535+
/** This ErgoTree operation work as macros (i.e. executed before ErgoTree reduction) and
536+
* allows to inline arbitrary expression at the point where it is used in ErgoTree.
537+
*
538+
* This operation is executed before ErgoTree reduction as the following:
539+
* 1) the context variable `id` is checked to have type Coll[Byte], if not, then this
540+
* node remains in the ErgoTree which means the reduction will fail later.
541+
* 2) the bytes collection is deserialized to `expr: Value[V]` using ValueSerializer.deserialize
542+
* 3) `this` node is replaced with the deserialized `expr`
543+
*
544+
* This step are performed for each [[DeserializeContext]] node via single traverse of
545+
* ErgoTree. The resulting ErgoTree is passed to reduction.
546+
*
547+
* NOTE, the original `Coll[Byte]` from context variables is available as `getVar[Coll[Byte]](id)`
548+
*
537549
* @param id identifier of the context variable
538-
* @tparam V result type of the deserialized script.
539-
* @throws InterpreterException if the actual script type doesn't conform to T
540-
* @return result of the script execution in the current context
541-
* @since 2.0
550+
* @param tpe expected type of the deserialized script (i.e. expected type of `expr`).
542551
*/
543552
case class DeserializeContext[V <: SType](id: Byte, tpe: V) extends Deserialize[V] {
544553
override def companion = DeserializeContext

0 commit comments

Comments
 (0)