Skip to content

Commit

Permalink
sigma-ast: fix Scala 2.11 compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
aslesarenko committed Aug 27, 2023
1 parent d479754 commit 6d2bb9d
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 4 deletions.
2 changes: 2 additions & 0 deletions core/shared/src/main/scala/sigma/data/SigmaConstants.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package sigma.data

import sigma.util.CollectionUtil.TraversableOps // used in Scala 2.11

/** Descriptor of a constant which represents some size value.
* @tparam T type of the constant value
* @param value value of the constant
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import sigma.Coll
import sigma.{AnyValue, Header, PreHeader}
import debox.cfor
import sigma.ast.{SBox, SCollection, SContext, SFunc, SGlobal, SInt, SType, SUnit}
import sigma.ast.SType.TypeCode
import sigma.ast.SType.{TypeCode, AnyOps}
import sigma.data.SigmaConstants
import sigmastate.serialization.ValueCodes.OpCode

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ object ValueSerializer extends SigmaSerializerCompanion[Value[SType]] {
private val constantSerializer = ConstantSerializer(builder)
private val constantPlaceholderSerializer = ConstantPlaceholderSerializer(mkConstantPlaceholder)

val serializers = new SparseArrayContainer(Seq[ValueSerializer[_ <: Value[SType]]](
val serializers = SparseArrayContainer.buildForSerializers(Seq[ValueSerializer[_ <: Value[SType]]](
constantSerializer,
constantPlaceholderSerializer,
TupleSerializer(mkTuple),
Expand Down Expand Up @@ -159,10 +159,10 @@ object ValueSerializer extends SigmaSerializerCompanion[Value[SType]] {
LogicalNotSerializer(mkLogicalNot),
OneArgumentOperationSerializer(Negation, mkNegation[SNumericType]),
OneArgumentOperationSerializer(BitInversion, mkBitInversion[SNumericType])
).map(s => (s.opCode, s)))
))

private def serializable(v: Value[SType]): Value[SType] = v match {
case upcast: Upcast[SType, _]@unchecked =>
case upcast: Upcast[SNumericType, _]@unchecked =>
upcast.input
case _ => v
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
package sigmastate.utils

import sigma.ast.SType
import sigmastate.Values.Value
import sigmastate.serialization.ValueSerializer

import scala.reflect.ClassTag

/**
Expand Down Expand Up @@ -62,3 +66,9 @@ class SparseArrayContainer[T: ClassTag](values: Seq[(Byte, T)]) {
}
}

object SparseArrayContainer {
/** Build a container for the given serializers. */
def buildForSerializers(sers: Seq[ValueSerializer[_ <: Value[SType]]]): SparseArrayContainer[ValueSerializer[_ <: Value[SType]]] = {
new SparseArrayContainer(sers.map(s => (s.opCode, s)))
}
}

0 comments on commit 6d2bb9d

Please sign in to comment.