sigma.serialization.ConstantSerializer.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sigma-state_2.12 Show documentation
Show all versions of sigma-state_2.12 Show documentation
Interpreter of a Sigma-State language
The newest version!
package sigma.serialization
import sigma.ast.{SType, SigmaBuilder}
import sigma.ast._
/** This works in tandem with DataSerializer, if you change one make sure to check the other.*/
case class ConstantSerializer(builder: SigmaBuilder)
extends ValueSerializer[Constant[SType]] {
override def opDesc = Constant
override def parse(r: SigmaByteReader): Value[SType] = deserialize(r)
override def serialize(c: Constant[SType], w: SigmaByteWriter): Unit = {
w.putType(c.tpe)
DataSerializer.serialize(c.value, c.tpe, w)
}
def deserialize(r: SigmaByteReader): Constant[SType] = {
val tpe = r.getType()
val obj = DataSerializer.deserialize(tpe, r)
builder.mkConstant(obj, tpe)
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy