sigma.serialization.SubstConstantsSerializer.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.SCollection.{SByteArray, SIntArray}
import sigma.ast.{SubstConstants, Value}
import sigma.ast.syntax._
import SigmaByteWriter._
import sigma.ast.{SCollection, SType}
import sigma.serialization.CoreByteWriter.DataInfo
object SubstConstantsSerializer extends ValueSerializer[SubstConstants[SType]] {
import sigma.ast.Operations.SubstConstantsInfo._
override def opDesc = SubstConstants
val scriptBytesInfo: DataInfo[SValue] = scriptBytesArg
val positionsInfo: DataInfo[SValue] = positionsArg
val newValuesInfo: DataInfo[SValue] = newValuesArg
def serialize(obj: SubstConstants[SType], w: SigmaByteWriter): Unit = {
w.putValue(obj.scriptBytes, scriptBytesInfo)
w.putValue(obj.positions, positionsInfo)
w.putValue(obj.newValues, newValuesInfo)
}
def parse(r: SigmaByteReader): Value[SType] = {
val scriptBytes = r.getValue().asValue[SByteArray]
val positions = r.getValue().asValue[SIntArray]
val newVals = r.getValue().asValue[SCollection[SType]]
SubstConstants(scriptBytes, positions, newVals)
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy