Skip to content

Commit

Permalink
Merge pull request #811 from ScorexFoundation/v5.0.1-RC
Browse files Browse the repository at this point in the history
Release candidate v5.0.3
  • Loading branch information
aslesarenko authored Jan 4, 2023
2 parents b369faa + 5e58ce2 commit dab64a3
Show file tree
Hide file tree
Showing 179 changed files with 3,310 additions and 18,723 deletions.
37 changes: 12 additions & 25 deletions build.sbt
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,13 @@ lazy val commonSettings = Seq(
organization := "org.scorexfoundation",
crossScalaVersions := Seq(scala212, scala211),
scalaVersion := scala212,
scalacOptions ++= {
CrossVersion.partialVersion(scalaVersion.value) match {
case Some((2, 12)) => Seq("-Ywarn-unused:_,imports", "-Ywarn-unused:imports")
case Some((2, 11)) => Seq()
case _ => sys.error("Unsupported scala version")
}
},
resolvers += Resolver.sonatypeRepo("public"),
licenses := Seq("CC0" -> url("https://creativecommons.org/publicdomain/zero/1.0/legalcode")),
homepage := Some(url("https://github.com/ScorexFoundation/sigmastate-interpreter")),
Expand Down Expand Up @@ -102,16 +109,6 @@ libraryDependencies ++= Seq(

scalacOptions ++= Seq("-feature", "-deprecation")

// set bytecode version to 8 to fix NoSuchMethodError for various ByteBuffer methods
// see https://github.com/eclipse/jetty.project/issues/3244
// these options applied only in "compile" task since scalac crashes on scaladoc compilation with "-release 8"
// see https://github.com/scala/community-builds/issues/796#issuecomment-423395500
//javacOptions in(Compile, compile) ++= Seq("-target", "8", "-source", "8" )
//scalacOptions in(Compile, compile) ++= Seq("-release", "8")

//uncomment lines below if the Scala compiler hangs to see where it happens
//scalacOptions in Compile ++= Seq("-Xprompt", "-Ydebug", "-verbose" )

parallelExecution in Test := false
publishArtifact in Test := true

Expand Down Expand Up @@ -180,24 +177,14 @@ lazy val sigmaapi = Project("sigma-api", file("sigma-api"))
))
.settings(publish / skip := true)

lazy val sigmaimpl = Project("sigma-impl", file("sigma-impl"))
.dependsOn(
sigmaapi % allConfigDependency,
libraryapi % allConfigDependency,
libraryimpl % allConfigDependency,
library % allConfigDependency)
.settings(libraryDefSettings,
libraryDependencies ++= Seq( scrypto, bouncycastleBcprov ))
.settings(publish / skip := true)

lazy val sigmalibrary = Project("sigma-library", file("sigma-library"))
.dependsOn(
sigmaimpl % allConfigDependency,
common % allConfigDependency,
core % allConfigDependency,
libraryapi % allConfigDependency,
libraryimpl % allConfigDependency,
library % allConfigDependency)
library % allConfigDependency,
sigmaapi % allConfigDependency)
.settings(libraryDefSettings,
libraryDependencies ++= Seq(
scrypto,
Expand All @@ -206,7 +193,7 @@ lazy val sigmalibrary = Project("sigma-library", file("sigma-library"))
.settings(publish / skip := true)

lazy val sigmastate = (project in file("sigmastate"))
.dependsOn(sigmaimpl % allConfigDependency, sigmalibrary % allConfigDependency)
.dependsOn(sigmalibrary % allConfigDependency)
.settings(libraryDefSettings)
.settings(libraryDependencies ++= Seq(
scorexUtil, kiama, fastparse, commonsMath3,
Expand All @@ -219,13 +206,13 @@ lazy val sigmastate = (project in file("sigmastate"))
lazy val sigma = (project in file("."))
.aggregate(
sigmastate, common, core, libraryapi, libraryimpl, library,
sigmaapi, sigmaimpl, sigmalibrary)
sigmaapi, sigmalibrary)
.settings(libraryDefSettings, rootSettings)
.settings(publish / aggregate := false)
.settings(publishLocal / aggregate := false)

lazy val aggregateCompile = ScopeFilter(
inProjects(common, core, libraryapi, libraryimpl, library, sigmaapi, sigmaimpl,
inProjects(common, core, libraryapi, libraryimpl, library, sigmaapi,
sigmalibrary, sigmastate),
inConfigurations(Compile))

Expand Down
27 changes: 0 additions & 27 deletions common/src/main/scala/scalan/TypeDesc.scala
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,6 @@ abstract class RType[A] {
/** Syntactically correct type name (type expression as String) */
def name: String = this.toString

/** Returns true is data size of `x: A` is the same for all `x`.
* This is useful optimizations of calculating sizes of collections. */
def isConstantSize: Boolean

/** Creates empty immutable array of this type. */
def emptyArray: Array[A] = Array.empty[A](classTag)
}
Expand Down Expand Up @@ -61,15 +57,12 @@ object RType {
case ClassTag.Nothing => "Nothing"
case ct => ct.runtimeClass.getSimpleName()
}
override def isConstantSize: Boolean = false
}

/** Descriptor used to represent primitive types. */
case class PrimitiveType[A](classTag: ClassTag[A],
override val emptyArray: Array[A]) extends RType[A] {
override def name: String = classTag.toString()
/** We assume all primitive types have inhabitants of the same size. */
override def isConstantSize: Boolean = true
}

val AnyType : RType[Any] = GeneralType[Any] (ClassTag.Any)
Expand All @@ -86,15 +79,9 @@ object RType {
implicit val DoubleType : RType[Double] = PrimitiveType[Double] (ClassTag.Double, Array.emptyDoubleArray)
implicit val UnitType : RType[Unit] = PrimitiveType[Unit] (ClassTag.Unit, Array[Unit]()(ClassTag.Unit))

/** Descriptor of the type A narrowed to the single inhabitant `value`. */
case class SingletonType[A](value: A, classTag: ClassTag[A])() extends RType[A] {
override def isConstantSize: Boolean = true // since the type has only one inhabitant
}

implicit case object StringType extends RType[String] {
override def classTag: ClassTag[String] = ClassTag[String](classOf[String])
override def name: String = "String"
override def isConstantSize: Boolean = false
}

/** Descriptor of descriptor to represent type of RType[_] instances.
Expand All @@ -103,7 +90,6 @@ object RType {
case object RTypeType extends RType[RType[_]] {
val classTag: ClassTag[RType[_]] = ClassTag[RType[_]](classOf[RType[_]])
override def name: String = s"RType[Any]"
override def isConstantSize: Boolean = false // since all type terms of different size
}
/** Implicitly obtain the single RTypeType descriptor casted to the given type A. */
implicit def rtypeRType[A]: RType[RType[A]] = asType[RType[A]](RTypeType)
Expand All @@ -113,24 +99,14 @@ object RType {
case class PairType[A,B](tFst: RType[A], tSnd: RType[B]) extends RType[(A,B)] {
val classTag: ClassTag[(A, B)] = scala.reflect.classTag[(A,B)]
override def name: String = s"(${tFst.name}, ${tSnd.name})"
override def isConstantSize: Boolean = tFst.isConstantSize && tSnd.isConstantSize
}
implicit def extendPairType[A,B](pt: RType[(A,B)]): PairType[A,B] = pt.asInstanceOf[PairType[A,B]]

implicit def eitherRType[A,B](implicit tA: RType[A], tB: RType[B]): RType[Either[A,B]] = EitherType(tA, tB)

case class EitherType[A,B](tLeft: RType[A], tRight: RType[B]) extends RType[Either[A,B]] {
val classTag: ClassTag[Either[A, B]] = scala.reflect.classTag[Either[A,B]]
override def name: String = s"(${tLeft.name} | ${tRight.name})"
override def isConstantSize: Boolean = tLeft.isConstantSize && tRight.isConstantSize
}

implicit def funcRType[A,B](implicit tDom: RType[A], tRange: RType[B]): RType[A => B] = FuncType(tDom, tRange)

case class FuncType[A,B](tDom: RType[A], tRange: RType[B]) extends RType[A => B] {
val classTag: ClassTag[A => B] = scala.reflect.classTag[A => B]
override def name: String = s"${tDom.name} => ${tRange.name}"
override def isConstantSize: Boolean = false
}

implicit def arrayRType[A](implicit tA: RType[A]): RType[Array[A]] = ArrayType(tA)
Expand All @@ -141,7 +117,6 @@ object RType {
scala.reflect.classTag[Array[A]]
}
override def name: String = s"Array[${tA.name}]"
override def isConstantSize: Boolean = false
}

implicit def optionRType[A](implicit tA: RType[A]): RType[Option[A]] = OptionType(tA)
Expand All @@ -152,7 +127,6 @@ object RType {
scala.reflect.classTag[Option[A]]
}
override def name: String = s"Option[${tA.name}]"
override def isConstantSize: Boolean = tA.isConstantSize
}

/** Underlying type of Thunk[A] values (or by-name values of type A). */
Expand All @@ -166,7 +140,6 @@ object RType {
scala.reflect.classTag[ThunkData[A]]
}
override def name: String = s"Thunk[${tA.name}]"
override def isConstantSize: Boolean = false
}

}
14 changes: 0 additions & 14 deletions common/src/main/scala/scalan/util/CollectionUtil.scala
Original file line number Diff line number Diff line change
Expand Up @@ -329,20 +329,6 @@ object CollectionUtil {
b.result()
}

def partitionByType[B <: A, C <: A]
(implicit tB: ClassTag[B],
cbB: CanBuildFrom[Source[A], B, Source[B]],
cbC: CanBuildFrom[Source[A], C, Source[C]]): (Source[B], Source[C]) = {
val bs = cbB()
val cs = cbC()
for (x <- xs)
if (tB.runtimeClass.isAssignableFrom(x.getClass))
bs += x.asInstanceOf[B]
else
cs += x.asInstanceOf[C]
(bs.result(), cs.result())
}

private def flattenIter(i: Iterator[_]): Iterator[_] = i.flatMap(x => x match {
case nested: GenIterable[_] => nested
case arr: Array[_] => arr.iterator
Expand Down
9 changes: 0 additions & 9 deletions common/src/test/scala/scalan/util/CollectionUtilTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -198,15 +198,6 @@ class CollectionUtilTests extends BaseTests {
}
}

test("partitionByType") {
val xs: List[Any] = List(1, "a", "b", 2, 3, 1.0, 2.0)
val (ints, others) = xs.partitionByType[Integer, Any]
ints shouldBe(List(1,2,3))
val (strs, doubles) = others.partitionByType[String, Double]
strs shouldBe(List("a", "b"))
doubles shouldBe(List(1.0, 2.0))
}

test("mapConserve") {
class A(val x: Int)
val x = new A(10)
Expand Down
12 changes: 7 additions & 5 deletions common/src/test/scala/sigmastate/VersionTesting.scala
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,16 @@ import scala.util.DynamicVariable

trait VersionTesting {

/** In v5.x we run test for only one activated version on the network (== 2).
* In the branch for v6.0 the new version 3 should be added so that the tests run for both.
*/
protected val activatedVersions: Seq[Byte] =
(0 to VersionContext.MaxSupportedScriptVersion).map(_.toByte).toArray[Byte]
(0 to VersionContext.MaxSupportedScriptVersion).map(_.toByte).toArray

private[sigmastate] val _currActivatedVersion = new DynamicVariable[Byte](0)
def activatedVersionInTests: Byte = _currActivatedVersion.value
private[sigmastate] val _currActivatedVersion = new DynamicVariable[Byte](2) // v5.x by default

/** Checks if the current activated script version used in tests corresponds to v4.x. */
def isActivatedVersion4: Boolean = activatedVersionInTests < VersionContext.JitActivationVersion
/** Current activated version used in tests. */
def activatedVersionInTests: Byte = _currActivatedVersion.value

val ergoTreeVersions: Seq[Byte] =
(0 to VersionContext.MaxSupportedScriptVersion).map(_.toByte).toArray[Byte]
Expand Down
4 changes: 2 additions & 2 deletions docs/LangSpec.md
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ class Box {
* @tparam T expected type of the register.
* @return Some(value) if the register is defined AND has the given type.
* None otherwise
* @throws special.sigma.InvalidType exception when the type of the register value is
* @throws InvalidType exception when the type of the register value is
* different from T.
*/
def Ri[T]: Option[T]
Expand Down Expand Up @@ -914,7 +914,7 @@ def decodePoint(bytes: Coll[Byte]): GroupElement
* @tparam T expected type of the variable.
* @return Some(value) if the variable is defined in the context AND has the given type.
* None otherwise
* @throws special.sigma.InvalidType exception when the type of the variable value is
* @throws InvalidType exception when the type of the variable value is
* different from cT.
*/
def getVar[T](tag: Int): Option[T]
Expand Down
80 changes: 0 additions & 80 deletions library-api/src/main/resources/special/collection/Colls.scalan

This file was deleted.

Loading

0 comments on commit dab64a3

Please sign in to comment.