Skip to content

Commit

Permalink
restructure-part5: sealed RegisterId hierarchy
Browse files Browse the repository at this point in the history
  • Loading branch information
aslesarenko committed Apr 14, 2023
1 parent cd9cf86 commit da65640
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions interpreter/src/main/scala/org/ergoplatform/ErgoBox.scala
Original file line number Diff line number Diff line change
Expand Up @@ -116,14 +116,22 @@ object ErgoBox {

type Amount = Long

trait RegisterId {
/** Represents id of a [[ErgoBox]] register. */
sealed trait RegisterId {
/** Zero-based register index in [0, 9] range. */
val number: Byte

/** Returns zero-based register index in [0, 9] range. */
def asIndex: Int = number.toInt

override def toString: String = "R" + number
}

abstract class MandatoryRegisterId(override val number: Byte, val purpose: String) extends RegisterId
abstract class NonMandatoryRegisterId(override val number: Byte) extends RegisterId
/** Represents id of pre-defined mandatory registers of a box. */
sealed abstract class MandatoryRegisterId(override val number: Byte, val purpose: String) extends RegisterId

/** Represents id of optional registers of a box. */
sealed abstract class NonMandatoryRegisterId(override val number: Byte) extends RegisterId

type AdditionalRegisters = Map[NonMandatoryRegisterId, _ <: EvaluatedValue[_ <: SType]]

Expand Down

0 comments on commit da65640

Please sign in to comment.