diff --git a/build.sbt b/build.sbt index f9f58c0c91..6c06c611fe 100644 --- a/build.sbt +++ b/build.sbt @@ -75,13 +75,13 @@ val scorexUtil = "org.scorexfoundation" %% "scorex-util" % "0.2.0" val debox = "org.scorexfoundation" %% "debox" % "0.10.0" val spireMacros = "org.typelevel" %% "spire-macros" % "0.17.0-M1" val fastparse = "com.lihaoyi" %% "fastparse" % "2.3.3" -val guava = "com.google.guava" % "guava" % "30.1.1-jre" val scalaCompat = "org.scala-lang.modules" %% "scala-collection-compat" % "2.7.0" val testingDependencies = Seq( - "org.scalatest" %% "scalatest" % "3.0.9" % Test, - "org.scalactic" %% "scalactic" % "3.0.9" % Test, - "org.scalacheck" %% "scalacheck" % "1.14.3" % Test, + "org.scalatest" %% "scalatest" % "3.2.14" % Test, + "org.scalactic" %% "scalactic" % "3.2.14" % Test, + "org.scalacheck" %% "scalacheck" % "1.15.2" % Test, // last supporting Scala 2.11 + "org.scalatestplus" %% "scalacheck-1-15" % "3.2.3.0" % Test, // last supporting Scala 2.11 "com.lihaoyi" %% "pprint" % "0.6.3" % Test, "com.storm-enroute" %% "scalameter" % "0.19" % Test, "junit" % "junit" % "4.12" % Test @@ -101,7 +101,11 @@ libraryDependencies ++= Seq( scorexUtil, "org.bouncycastle" % "bcprov-jdk15on" % "1.+", fastparse, debox, spireMacros, scalaCompat -) ++ testingDependencies +) ++ testingDependencies ++ + (if (scalaVersion.value == scala211) + Seq(circeCore211, circeGeneric211, circeParser211) + else + Seq(circeCore, circeGeneric, circeParser)) lazy val circeCore211 = "io.circe" %% "circe-core" % "0.10.0" lazy val circeGeneric211 = "io.circe" %% "circe-generic" % "0.10.0" @@ -111,12 +115,6 @@ lazy val circeCore = "io.circe" %% "circe-core" % "0.13.0" lazy val circeGeneric = "io.circe" %% "circe-generic" % "0.13.0" lazy val circeParser = "io.circe" %% "circe-parser" % "0.13.0" -libraryDependencies ++= Seq( - if (scalaVersion.value == scala211) circeCore211 else circeCore, - if (scalaVersion.value == scala211) circeGeneric211 else circeGeneric, - if (scalaVersion.value == scala211) circeParser211 else circeParser - ) - scalacOptions ++= Seq("-feature", "-deprecation") parallelExecution in Test := false @@ -147,10 +145,10 @@ usePgpKeyHex("C1FD62B4D44BDF702CDF2B726FF59DA944B150DD") def libraryDefSettings = commonSettings ++ testSettings lazy val common = Project("common", file("common")) - .settings(commonSettings ++ testSettings, + .settings(libraryDefSettings, libraryDependencies ++= Seq( "org.scala-lang" % "scala-reflect" % scalaVersion.value, - debox, scalaCompat, guava + debox, scalaCompat )) .settings(publish / skip := true) @@ -168,14 +166,14 @@ lazy val libraryimpl = Project("library-impl", file("library-impl")) lazy val core = Project("core", file("core")) .dependsOn(common % allConfigDependency, libraryapi % allConfigDependency) - .settings(commonSettings, + .settings(libraryDefSettings, libraryDependencies ++= Seq( debox )) .settings(publish / skip := true) lazy val library = Project("library", file("library")) .dependsOn(common % allConfigDependency, core % allConfigDependency, libraryapi, libraryimpl) - .settings(//commonSettings, - libraryDefSettings ++ testSettings, + .settings( + libraryDefSettings, libraryDependencies ++= Seq( debox )) .settings(publish / skip := true) @@ -234,94 +232,3 @@ lazy val rootSettings = Seq( mappings in (Test, packageBin) ++= (mappings in(Test, packageBin)).all(aggregateCompile).value.flatten, mappings in(Test, packageSrc) ++= (mappings in(Test, packageSrc)).all(aggregateCompile).value.flatten ) - -def runErgoTask(task: String, sigmastateVersion: String, log: Logger): Unit = { - val ergoBranch = "test-coverage" - val sbtEnvVars = Seq("BUILD_ENV" -> "test", "SIGMASTATE_VERSION" -> sigmastateVersion) - - log.info(s"Testing current build in Ergo (branch $ergoBranch):") - val cwd = new File("").absolutePath - val ergoPath = new File(cwd + "/ergo-tests/") - log.info(s"Cleaning $ergoPath") - s"rm -rf ${ergoPath.absolutePath}" ! - - log.info(s"Cloning Ergo branch $ergoBranch into ${ergoPath.absolutePath}") - s"git clone -b $ergoBranch --single-branch https://github.com/ergoplatform/ergo.git ${ergoPath.absolutePath}" ! - - - log.info(s"Updating Ergo in $ergoPath with Sigmastate version $sigmastateVersion") - Process(Seq("sbt", "unlock", "reload", "lock"), ergoPath, sbtEnvVars: _*) ! - - log.info("Updated Ergo lock.sbt:") - Process(Seq("git", "diff", "-U0", "lock.sbt"), ergoPath) ! - - log.info(s"Running Ergo tests in $ergoPath with Sigmastate version $sigmastateVersion") - val res = Process(Seq("sbt", task), ergoPath, sbtEnvVars: _*) ! - - if (res != 0) sys.error(s"Ergo $task failed!") -} - -lazy val ergoUnitTestTask = TaskKey[Unit]("ergoUnitTestTask", "run ergo unit tests with current version") -ergoUnitTestTask := { - val log = streams.value.log - val sigmastateVersion = version.value - runErgoTask("test", sigmastateVersion, log) -} - -commands += Command.command("ergoUnitTest") { state => - "clean" :: - "publishLocal" :: - "ergoUnitTestTask" :: - state -} - -lazy val ergoItTestTask = TaskKey[Unit]("ergoItTestTask", "run ergo it:test with current version") -ergoItTestTask := { - val log = streams.value.log - val sigmastateVersion = version.value - runErgoTask("it:test", sigmastateVersion, log) -} - -commands += Command.command("ergoItTest") { state => - "clean" :: - "publishLocal" :: - "ergoItTestTask" :: - state -} - -def runSpamTestTask(task: String, sigmastateVersion: String, log: Logger): Unit = { - val spamBranch = "master" - val envVars = Seq("SIGMASTATE_VERSION" -> sigmastateVersion, - // SSH_SPAM_REPO_KEY should be set (see Jenkins Credentials Binding Plugin) - "GIT_SSH_COMMAND" -> "ssh -i $SSH_SPAM_REPO_KEY") - - log.info(s"Testing current build with spam tests (branch $spamBranch):") - val cwd = new File("") - val spamPath = new File(cwd.absolutePath + "/spam-tests/") - log.info(s"Cleaning $spamPath") - s"rm -rf ${spamPath.absolutePath}" ! - - log.info(s"Cloning spam tests branch $spamBranch into ${spamPath.absolutePath}") - Process(Seq("git", "clone", "-b", spamBranch, "--single-branch", "git@github.com:greenhat/sigma-spam.git", spamPath.absolutePath), - cwd.getAbsoluteFile, - envVars: _*) ! - - log.info(s"Running spam tests in $spamPath with Sigmastate version $sigmastateVersion") - val res = Process(Seq("sbt", task), spamPath, envVars: _*) ! - - if (res != 0) sys.error(s"Spam $task failed!") -} - -lazy val spamTestTask = TaskKey[Unit]("spamTestTask", "run spam tests with current version") -spamTestTask := { - val log = streams.value.log - val sigmastateVersion = version.value - runSpamTestTask("test", sigmastateVersion, log) -} - -commands += Command.command("spamTest") { state => - "clean" :: - "publishLocal" :: - "spamTestTask" :: - state -} diff --git a/common/src/main/java/java7/compat/Math.java b/common/src/main/java/java7/compat/Math.java deleted file mode 100644 index 72ed8d5de0..0000000000 --- a/common/src/main/java/java7/compat/Math.java +++ /dev/null @@ -1,159 +0,0 @@ -/* - * Copyright (c) 1994, 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package java7.compat; - -/** - * Contains methods introduced since Java 1.8 which are not available in Java 1.7. - * Using this methods supports compatibility with Java 1.7 in non-JVM contexts like - * RoboVM. - * The implementations are copies from JDK 1.8 sources. - *
- * See - * this issue - */ -public final class Math { - /** - * Returns the sum of its arguments, - * throwing an exception if the result overflows an {@code int}. - * - * @param x the first value - * @param y the second value - * @return the result - * @throws ArithmeticException if the result overflows an int - * @since 1.8 - */ - public static int addExact(int x, int y) { - int r = x + y; - // HD 2-12 Overflow iff both arguments have the opposite sign of the result - if (((x ^ r) & (y ^ r)) < 0) { - throw new ArithmeticException("integer overflow"); - } - return r; - } - - /** - * Returns the sum of its arguments, - * throwing an exception if the result overflows a {@code long}. - * - * @param x the first value - * @param y the second value - * @return the result - * @throws ArithmeticException if the result overflows a long - * @since 1.8 - */ - public static long addExact(long x, long y) { - long r = x + y; - // HD 2-12 Overflow iff both arguments have the opposite sign of the result - if (((x ^ r) & (y ^ r)) < 0) { - throw new ArithmeticException("long overflow"); - } - return r; - } - - /** - * Returns the difference of the arguments, - * throwing an exception if the result overflows an {@code int}. - * - * @param x the first value - * @param y the second value to subtract from the first - * @return the result - * @throws ArithmeticException if the result overflows an int - * @since 1.8 - */ - public static int subtractExact(int x, int y) { - int r = x - y; - // HD 2-12 Overflow iff the arguments have different signs and - // the sign of the result is different than the sign of x - if (((x ^ y) & (x ^ r)) < 0) { - throw new ArithmeticException("integer overflow"); - } - return r; - } - - /** - * Returns the difference of the arguments, - * throwing an exception if the result overflows a {@code long}. - * - * @param x the first value - * @param y the second value to subtract from the first - * @return the result - * @throws ArithmeticException if the result overflows a long - * @since 1.8 - */ - public static long subtractExact(long x, long y) { - long r = x - y; - // HD 2-12 Overflow iff the arguments have different signs and - // the sign of the result is different than the sign of x - if (((x ^ y) & (x ^ r)) < 0) { - throw new ArithmeticException("long overflow"); - } - return r; - } - - /** - * Returns the product of the arguments, - * throwing an exception if the result overflows an {@code int}. - * - * @param x the first value - * @param y the second value - * @return the result - * @throws ArithmeticException if the result overflows an int - * @since 1.8 - */ - public static int multiplyExact(int x, int y) { - long r = (long)x * (long)y; - if ((int)r != r) { - throw new ArithmeticException("integer overflow"); - } - return (int)r; - } - - /** - * Returns the product of the arguments, - * throwing an exception if the result overflows a {@code long}. - * - * @param x the first value - * @param y the second value - * @return the result - * @throws ArithmeticException if the result overflows a long - * @since 1.8 - */ - public static long multiplyExact(long x, long y) { - long r = x * y; - long ax = java.lang.Math.abs(x); - long ay = java.lang.Math.abs(y); - if (((ax | ay) >>> 31 != 0)) { - // Some bits greater than 2^31 that might cause overflow - // Check the result using the divide operator - // and check for the special case of Long.MIN_VALUE * -1 - if (((y != 0) && (r / y != x)) || - (x == Long.MIN_VALUE && y == -1)) { - throw new ArithmeticException("long overflow"); - } - } - return r; - } -} diff --git a/common/src/main/java/scalan/Builtin.java b/common/src/main/java/scalan/Builtin.java deleted file mode 100644 index 83a1c37b84..0000000000 --- a/common/src/main/java/scalan/Builtin.java +++ /dev/null @@ -1,17 +0,0 @@ -package scalan; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - - -/** Relate annotated element with internal type or method given by `value` property. -* Applied to entities that should be replaced during virtualization by related type. -* The given related type is said to be pre-virtualized. -* The 'value' is a name of the class which can be resolved in a Scalan cake. E.g. IsoUR*/ -@Target(ElementType.TYPE) -@Retention(RetentionPolicy.RUNTIME) -public @interface Builtin { - String value() default ""; // default value interpreted as "virtualized name is equal to annotated element name" -} diff --git a/common/src/main/java/scalan/Constructor.java b/common/src/main/java/scalan/Constructor.java deleted file mode 100644 index 0caecfe3d9..0000000000 --- a/common/src/main/java/scalan/Constructor.java +++ /dev/null @@ -1,14 +0,0 @@ -package scalan; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** Used in generated wrappers. - * Annotates a wrapper method of the companion of a virtualized type wrapper, - * which (the method) corresponds to the constructor of wrapped type. */ -@Target(ElementType.METHOD) -@Retention(RetentionPolicy.RUNTIME) -public @interface Constructor { -} diff --git a/common/src/main/java/scalan/ContainerType.java b/common/src/main/java/scalan/ContainerType.java deleted file mode 100644 index c3768cda3c..0000000000 --- a/common/src/main/java/scalan/ContainerType.java +++ /dev/null @@ -1,14 +0,0 @@ -package scalan; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** Annotates Special DSL types which implement the interface of containers. -* Each container is described using Cont[_] descriptors. -* Special supporting code is generated for annotated entities. */ -@Target(ElementType.TYPE) -@Retention(RetentionPolicy.CLASS) -public @interface ContainerType { -} diff --git a/common/src/main/java/scalan/Convertible.java b/common/src/main/java/scalan/Convertible.java deleted file mode 100644 index 662f5f6ee3..0000000000 --- a/common/src/main/java/scalan/Convertible.java +++ /dev/null @@ -1,12 +0,0 @@ -package scalan; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** Marks annotated type as having support for generic Converter generation. */ -@Target(ElementType.TYPE) -@Retention(RetentionPolicy.RUNTIME) -public @interface Convertible { -} diff --git a/common/src/main/java/scalan/External.java b/common/src/main/java/scalan/External.java deleted file mode 100644 index e8e2864c7c..0000000000 --- a/common/src/main/java/scalan/External.java +++ /dev/null @@ -1,15 +0,0 @@ -package scalan; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** Relate annotated element with an external type or method given by `value` property. -* For example WOption related to Option is annotated as @External("Option") -* This annotation is used to separate wrapper Entity from user defined virtualized Entity. -* See WrapperEntity object. */ -@Target({ElementType.TYPE, ElementType.METHOD}) -public @interface External { - String value() default ""; // default value interpreted as "external name is equal to annotated element name" -} diff --git a/common/src/main/java/scalan/FunctorType.java b/common/src/main/java/scalan/FunctorType.java deleted file mode 100644 index 9832d78271..0000000000 --- a/common/src/main/java/scalan/FunctorType.java +++ /dev/null @@ -1,13 +0,0 @@ -package scalan; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** Used to annotate container types (like Option, Coll), which have - * functor semantics. Special code is generated for such entities. */ -@Target(ElementType.TYPE) -@Retention(RetentionPolicy.CLASS) -public @interface FunctorType { -} diff --git a/common/src/main/java/scalan/InlineAt.java b/common/src/main/java/scalan/InlineAt.java deleted file mode 100644 index 0590456be7..0000000000 --- a/common/src/main/java/scalan/InlineAt.java +++ /dev/null @@ -1,18 +0,0 @@ -package scalan; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** Specifies the predicate when the annotated method should be inlined. -* The predicate is given by the parsable formula which can be used to -* create runtime predicate functions. -* Default empty string is interpreted as never invoke, in which case scalanizer -* don't perform virtualization of the method body and replace it with delayInvoke. */ -@Target({ElementType.METHOD}) -@Retention(RetentionPolicy.RUNTIME) -public @interface InlineAt { - String Never = ""; - String value() default Never; -} diff --git a/common/src/main/java/scalan/Internal.java b/common/src/main/java/scalan/Internal.java deleted file mode 100644 index 1555984ccc..0000000000 --- a/common/src/main/java/scalan/Internal.java +++ /dev/null @@ -1,14 +0,0 @@ -package scalan; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** Used to annotate type and methods, which should not be virtualized. - * Everything marked @Internal are invisible for virtualization process. - */ -@Target({ElementType.TYPE, ElementType.METHOD}) -@Retention(RetentionPolicy.RUNTIME) -public @interface Internal { -} diff --git a/common/src/main/java/scalan/Isospec.java b/common/src/main/java/scalan/Isospec.java deleted file mode 100644 index d5c2498537..0000000000 --- a/common/src/main/java/scalan/Isospec.java +++ /dev/null @@ -1,12 +0,0 @@ -package scalan; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** Marks annotated type as having support for isomorphic specialization. */ -@Target(ElementType.TYPE) -@Retention(RetentionPolicy.RUNTIME) -public @interface Isospec { -} diff --git a/common/src/main/java/scalan/Liftable.java b/common/src/main/java/scalan/Liftable.java deleted file mode 100644 index 83dc56bc17..0000000000 --- a/common/src/main/java/scalan/Liftable.java +++ /dev/null @@ -1,12 +0,0 @@ -package scalan; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** Marks annotated type as having support for lifting values to IR nodes. */ -@Target(ElementType.TYPE) -@Retention(RetentionPolicy.RUNTIME) -public @interface Liftable { -} diff --git a/common/src/main/java/scalan/NeverInline.java b/common/src/main/java/scalan/NeverInline.java deleted file mode 100644 index 39b63e9a0c..0000000000 --- a/common/src/main/java/scalan/NeverInline.java +++ /dev/null @@ -1,12 +0,0 @@ -package scalan; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** Equvalent to InlineAt(Never). */ -@Target({ElementType.METHOD}) -@Retention(RetentionPolicy.RUNTIME) -public @interface NeverInline { -} diff --git a/common/src/main/java/scalan/OverloadId.java b/common/src/main/java/scalan/OverloadId.java deleted file mode 100644 index c167013698..0000000000 --- a/common/src/main/java/scalan/OverloadId.java +++ /dev/null @@ -1,13 +0,0 @@ -package scalan; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** Assigns an alternative name to the overloaded method. */ -@Target(ElementType.METHOD) -@Retention(RetentionPolicy.RUNTIME) -public @interface OverloadId { - String value(); -} diff --git a/common/src/main/java/scalan/Reified.java b/common/src/main/java/scalan/Reified.java deleted file mode 100644 index 360340f678..0000000000 --- a/common/src/main/java/scalan/Reified.java +++ /dev/null @@ -1,19 +0,0 @@ -package scalan; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** Type argument T should be reified in virtualized code type descriptor Elem[T] available -* in the scope where T is visible. This can be done either by explicitly passing additional -* parameter eT: Elem[T] or by proving that Elem[T] can be retrieved from the other arguments -* of the method or class. For example if x: Rep[T] then eT can be obtained by x.elem. -* The need for reified type arguments come from ClassTag[T], RType[T] context bounds or -* implicit parameters in the source code. -*/ -@Target({ElementType.TYPE}) -@Retention(RetentionPolicy.RUNTIME) -public @interface Reified { - String value() default ""; -} diff --git a/common/src/main/java/scalan/WithMethodCallRecognizers.java b/common/src/main/java/scalan/WithMethodCallRecognizers.java deleted file mode 100644 index 37e229ed01..0000000000 --- a/common/src/main/java/scalan/WithMethodCallRecognizers.java +++ /dev/null @@ -1,17 +0,0 @@ -package scalan; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -/** Marks annotated method or trait/class as having support for pattern matching. - * Extractor methods will be generated by codegen for each method either annotated or - * belonging to the annotated type. - * Extractors can be used in rewriting rules to recognize IR nodes of MethodCall type, - * which represents the call of the annotated method. - */ -@Target({ElementType.METHOD,ElementType.TYPE}) -@Retention(RetentionPolicy.RUNTIME) -public @interface WithMethodCallRecognizers { -} diff --git a/common/src/main/scala/java7/compat/Math.scala b/common/src/main/scala/java7/compat/Math.scala new file mode 100644 index 0000000000..a1a7ce1296 --- /dev/null +++ b/common/src/main/scala/java7/compat/Math.scala @@ -0,0 +1,126 @@ +package java7.compat + +/** + * Contains methods introduced since Java 1.8 which are not available in Java 1.7. + * Using this methods supports compatibility with Java 1.7 in non-JVM contexts like + * RoboVM. + * The implementations are copies from JDK 1.8 sources. + *
+ * See
+ * this issue
+ */
+object Math {
+ /**
+ * Returns the sum of its arguments,
+ * throwing an exception if the result overflows an {@code int}.
+ *
+ * @param x the first value
+ * @param y the second value
+ * @return the result
+ * @throws ArithmeticException if the result overflows an int
+ */
+ def addExact(x: Int, y: Int): Int = {
+ val r = x + y
+ // HD 2-12 Overflow iff both arguments have the opposite sign of the result
+ if (((x ^ r) & (y ^ r)) < 0) {
+ throw new ArithmeticException("integer overflow")
+ }
+ r
+ }
+
+ /**
+ * Returns the sum of its arguments,
+ * throwing an exception if the result overflows a {@code long}.
+ *
+ * @param x the first value
+ * @param y the second value
+ * @return the result
+ * @throws ArithmeticException if the result overflows a long
+ */
+ def addExact(x: Long, y: Long): Long = {
+ val r = x + y
+ if (((x ^ r) & (y ^ r)) < 0) {
+ throw new ArithmeticException("long overflow")
+ }
+ r
+ }
+
+ /**
+ * Returns the difference of the arguments,
+ * throwing an exception if the result overflows an {@code int}.
+ *
+ * @param x the first value
+ * @param y the second value to subtract from the first
+ * @return the result
+ * @throws ArithmeticException if the result overflows an int
+ */
+ def subtractExact(x: Int, y: Int): Int = {
+ val r = x - y
+ // HD 2-12 Overflow iff the arguments have different signs and
+ // the sign of the result is different than the sign of x
+ if (((x ^ y) & (x ^ r)) < 0) {
+ throw new ArithmeticException("integer overflow")
+ }
+ r
+ }
+
+ /**
+ * Returns the difference of the arguments,
+ * throwing an exception if the result overflows a {@code long}.
+ *
+ * @param x the first value
+ * @param y the second value to subtract from the first
+ * @return the result
+ * @throws ArithmeticException if the result overflows a long
+ */
+ def subtractExact(x: Long, y: Long) = {
+ val r = x - y
+ // HD 2-12 Overflow iff the arguments have different signs and
+ // the sign of the result is different than the sign of x
+ if (((x ^ y) & (x ^ r)) < 0) {
+ throw new ArithmeticException("long overflow")
+ }
+ r
+ }
+
+ /**
+ * Returns the product of the arguments,
+ * throwing an exception if the result overflows an {@code int}.
+ *
+ * @param x the first value
+ * @param y the second value
+ * @return the result
+ * @throws ArithmeticException if the result overflows an int
+ */
+ def multiplyExact(x: Int, y: Int) = {
+ val r = x.toLong * y.toLong
+ if (r.toInt != r) {
+ throw new ArithmeticException("integer overflow")
+ }
+ r.toInt
+ }
+
+ /**
+ * Returns the product of the arguments,
+ * throwing an exception if the result overflows a {@code long}.
+ *
+ * @param x the first value
+ * @param y the second value
+ * @return the result
+ * @throws ArithmeticException if the result overflows a long
+ */
+ def multiplyExact(x: Long, y: Long) = {
+ val r = x * y
+ val ax = java.lang.Math.abs(x)
+ val ay = java.lang.Math.abs(y)
+ if ((ax | ay) >>> 31 != 0) {
+ // Some bits greater than 2^31 that might cause overflow
+ // Check the result using the divide operator
+ // and check for the special case of Long.MIN_VALUE * -1
+ if (((y != 0) && (r / y != x)) || (x == Long.MinValue && y == -1)) {
+ throw new ArithmeticException("long overflow")
+ }
+ }
+ r
+ }
+}
diff --git a/common/src/main/scala/scalan/util/ReflectionUtil.scala b/common/src/main/scala/scalan/util/ReflectionUtil.scala
index c463e8a787..15c73b0548 100644
--- a/common/src/main/scala/scalan/util/ReflectionUtil.scala
+++ b/common/src/main/scala/scalan/util/ReflectionUtil.scala
@@ -1,33 +1,19 @@
package scalan.util
-import java.lang.reflect.{Method, AnnotatedElement}
import scala.language.existentials
-import scala.reflect.{classTag, ClassTag}
-import scalan.OverloadId
object ReflectionUtil {
- def jAnnotation[A <: java.lang.annotation.Annotation : ClassTag](element: AnnotatedElement) =
- Option(element.getAnnotation(classTag[A].runtimeClass.asInstanceOf[Class[A]]))
-
- def overloadId(method: Method) = jAnnotation[OverloadId](method).map(_.value)
-
- /** Returns the superclass for an anonymous class produced by mixing in traits; the argument otherwise. */
- def namedSuperclass(clazz: Class[_]) = {
- if (clazz.getSimpleName.contains("$anon$")) {
- val superclass = clazz.getSuperclass
- if (superclass == classOf[Object]) {
- // clazz is composed of traits only, return the first one
- clazz.getInterfaces.head
- } else
- superclass
- } else
- clazz
- }
implicit class ClassOps(val cl: Class[_]) extends AnyVal {
+ /** Special character in the name. */
private def isSpecialChar(c: Char): Boolean = {
('0' <= c && c <= '9') || c == '$'
}
+
+ /** Safe version of `getSimpleName` that works around a bug in Scala compilers 2.11, 2.12.
+ * This method is only used for debugging purposes.
+ * @see https://github.com/scala/bug/issues/5425
+ */
def safeSimpleName: String = {
if (cl.getEnclosingClass == null) return cl.getSimpleName
val simpleName = cl.getName.substring(cl.getEnclosingClass.getName.length)
diff --git a/common/src/main/scala/sigmastate/kiama/rewriting/Rewriter.scala b/common/src/main/scala/sigmastate/kiama/rewriting/Rewriter.scala
index 57ce44d5b0..6a2b8635c9 100644
--- a/common/src/main/scala/sigmastate/kiama/rewriting/Rewriter.scala
+++ b/common/src/main/scala/sigmastate/kiama/rewriting/Rewriter.scala
@@ -11,6 +11,8 @@
package sigmastate.kiama
package rewriting
+import scala.collection.mutable
+
/**
* Strategy-based term rewriting in the style of Stratego (http://strategoxt.org/).
* The implementation here is partially based on the semantics given in "Program
@@ -216,13 +218,11 @@ trait Rewriter {
*/
object Duplicator {
- import com.google.common.base.Function
- import com.google.common.cache.{CacheBuilder, CacheLoader}
import java.lang.reflect.Constructor
type Duper = (Any, Array[AnyRef]) => Any
- object MakeDuper extends Function[Class[_], Duper] {
+ object MakeDuper extends (Class[_] => Duper) {
def apply(clazz : Class[_]) : Duper =
try {
@@ -280,12 +280,25 @@ trait Rewriter {
}
- val cache = CacheBuilder.newBuilder.weakKeys.build(
- CacheLoader.from(MakeDuper)
- )
+ private val cache = mutable.HashMap.empty[Class[_], Duper]
+ /** Obtains a duper for the given class lazily. and memoize it in the `cache` map.
+ * This is the simplest solution, but not the most efficient for concurrent access.
+ */
+ def getDuper(clazz: Class[_]): Duper = synchronized { // TODO optimize: avoid global sync
+ val duper = cache.get(clazz) match {
+ case Some(d) => d
+ case None =>
+ val d = MakeDuper(clazz)
+ cache.put(clazz, d)
+ d
+ }
+ duper
+ }
+
def apply[T <: Product](t : T, children : Array[AnyRef]) : T = {
- val duper = cache.get(t.getClass)
+ val clazz = t.getClass
+ val duper = getDuper(clazz)
duper(t, children).asInstanceOf[T]
}
diff --git a/common/src/test/scala/scalan/BaseTests.scala b/common/src/test/scala/scalan/BaseTests.scala
index 905adda285..64a8c7f615 100644
--- a/common/src/test/scala/scalan/BaseTests.scala
+++ b/common/src/test/scala/scalan/BaseTests.scala
@@ -1,27 +1,30 @@
package scalan
+import org.scalatest.flatspec.AnyFlatSpec
+import org.scalatest.funspec.AnyFunSpec
+
import scala.language.implicitConversions
-import org.scalatest.words.ResultOfStringPassedToVerb
-import org.scalatest.{FlatSpec, _}
+import org.scalatest.verbs.ResultOfStringPassedToVerb
+import org.scalatest.funsuite.AnyFunSuite
/**
* Standard base class for most test suites. See BaseNestedTests and BaseShouldTests for alternatives
*
* See http://doc.scalatest.org/2.2.4/#org.scalatest.FunSuite.
*/
-abstract class BaseTests extends FunSuite with TestUtils
+abstract class BaseTests extends AnyFunSuite with TestUtils
/**
* Standard base class for test suites with nested tests.
*
* See http://doc.scalatest.org/2.2.4/#org.scalatest.FunSpec.
*/
-abstract class BaseNestedTests extends FunSpec with TestUtils
+abstract class BaseNestedTests extends AnyFunSpec with TestUtils
/**
* See http://doc.scalatest.org/2.2.4/#org.scalatest.FlatSpec.
*/
-abstract class BaseShouldTests extends FlatSpec with TestUtils {
+abstract class BaseShouldTests extends AnyFlatSpec with TestUtils {
protected final class InAndIgnoreMethods2(resultOfStringPassedToVerb: ResultOfStringPassedToVerb) {
import resultOfStringPassedToVerb.rest
diff --git a/common/src/test/scala/scalan/TestUtils.scala b/common/src/test/scala/scalan/TestUtils.scala
index 0e1645f71d..a583f590af 100644
--- a/common/src/test/scala/scalan/TestUtils.scala
+++ b/common/src/test/scala/scalan/TestUtils.scala
@@ -2,7 +2,8 @@ package scalan
import scalan.util.FileUtil
import org.scalactic.TripleEquals
-import org.scalatest.{Inside, Matchers, TestSuite}
+import org.scalatest.matchers.should.Matchers
+import org.scalatest.{Inside, TestSuite}
import scalan.util.StringUtil.StringUtilExtensions
/**
diff --git a/common/src/test/scala/sigmastate/VersionTestingProperty.scala b/common/src/test/scala/sigmastate/VersionTestingProperty.scala
index f6d8b6c400..bfa6cace28 100644
--- a/common/src/test/scala/sigmastate/VersionTestingProperty.scala
+++ b/common/src/test/scala/sigmastate/VersionTestingProperty.scala
@@ -1,13 +1,14 @@
package sigmastate
import org.scalactic.source.Position
-import org.scalatest.{PropSpec, Tag}
+import org.scalatest.propspec.AnyPropSpec
+import org.scalatest.Tag
/** Decorator trait which allows to redefine `property` so that it is executed repeatedly for each valid
* [[VersionContext]], which is properly initialized.
* Thus, the properties can be versioned using `VersionContext.current`.
*/
-trait VersionTestingProperty extends PropSpec with VersionTesting {
+trait VersionTestingProperty extends AnyPropSpec with VersionTesting {
/** Redefine `property` so that testFun is executed repeatedly for each valid
* [[VersionContext]] */
diff --git a/core/src/main/scala/scalan/TypeDescs.scala b/core/src/main/scala/scalan/TypeDescs.scala
index fb3c276001..97689c169d 100644
--- a/core/src/main/scala/scalan/TypeDescs.scala
+++ b/core/src/main/scala/scalan/TypeDescs.scala
@@ -233,15 +233,6 @@ abstract class TypeDescs extends Base { self: Scalan =>
final def unapply[T, E <: Elem[T]](s: Ref[T]): Nullable[E] = Nullable(s.elem.asInstanceOf[E])
- /** Get unique method name suitable to be used as HashMap key. */
- def methodKey(m: Method) = {
- val ann = m.getDeclaredAnnotation(classOf[OverloadId])
- if (ann != null)
- s"${m.getName}_${ann.value}"
- else
- m.getName
- }
-
/** Build a mapping between methods of staged class and the corresponding methods of source class.
* The methods are related using names.
* The computed mapping can be used to project MethodCalls IR nodes back to the corresponding
@@ -255,7 +246,7 @@ abstract class TypeDescs extends Base { self: Scalan =>
def declaredMethods(cls: Class[_], srcCls: Class[_], methodNames: Set[String]): Seq[(Method, MethodDesc)] = {
val rmethods = cls.getDeclaredMethods.filter(m => methodNames.contains(m.getName))
val smethods = srcCls.getDeclaredMethods.filter(m => methodNames.contains(m.getName))
- val mapping = CollectionUtil.joinSeqs(rmethods, smethods)(methodKey, methodKey)
+ val mapping = CollectionUtil.joinSeqs(rmethods, smethods)(_.getName, _.getName)
mapping.map { case (rm, sm) =>
(rm, RMethodDesc(sm))
}.toSeq
@@ -273,7 +264,7 @@ abstract class TypeDescs extends Base { self: Scalan =>
val specCls = wrapSpec.getClass
val wMethods = wcls.getDeclaredMethods.filter(m => methodNames.contains(m.getName))
val specMethods = specCls.getDeclaredMethods.filter(m => methodNames.contains(m.getName))
- val mapping = CollectionUtil.joinSeqs(wMethods, specMethods)(methodKey, methodKey)
+ val mapping = CollectionUtil.joinSeqs(wMethods, specMethods)(_.getName, _.getName)
mapping.map { case (wm, sm) =>
(wm, WMethodDesc(wrapSpec, sm))
}.toSeq
diff --git a/core/src/main/scala/scalan/primitives/Thunks.scala b/core/src/main/scala/scalan/primitives/Thunks.scala
index c6d7eb63e1..6f1dc80918 100644
--- a/core/src/main/scala/scalan/primitives/Thunks.scala
+++ b/core/src/main/scala/scalan/primitives/Thunks.scala
@@ -2,7 +2,7 @@ package scalan.primitives
import scala.language.{existentials, implicitConversions}
import scalan.compilation.{GraphVizConfig, GraphVizExport}
-import scalan.{Liftable => _, _}
+import scalan._
import debox.{Set => DSet, Buffer => DBuffer}
import debox.cfor
diff --git a/library-api/src/main/scala/special/SpecialPredef.scala b/library-api/src/main/scala/special/SpecialPredef.scala
index 9c0bbdca99..9152f55d09 100644
--- a/library-api/src/main/scala/special/SpecialPredef.scala
+++ b/library-api/src/main/scala/special/SpecialPredef.scala
@@ -1,7 +1,7 @@
package special
import scala.reflect.ClassTag
-import scalan.{Reified, RType}
+import scalan.RType
object SpecialPredef {
def loopUntil[A](s1: A, isMatch: A => Boolean, step: A => A): A = {
@@ -15,7 +15,7 @@ object SpecialPredef {
def some[A](x: A): Option[A] = Some(x)
- @Reified("A") def none[A](implicit tA: RType[A]): Option[A] = Option.empty[A]
+ def none[A](implicit tA: RType[A]): Option[A] = Option.empty[A]
def optionGetOrElse[A](opt: Option[A], default: A): A = opt.getOrElse(default)
diff --git a/library-api/src/main/scala/special/collection/Colls.scala b/library-api/src/main/scala/special/collection/Colls.scala
index a2b7630e9e..555be23415 100644
--- a/library-api/src/main/scala/special/collection/Colls.scala
+++ b/library-api/src/main/scala/special/collection/Colls.scala
@@ -322,7 +322,7 @@ trait CollBuilder {
/** Construct a new collection from the given list of arguments.
* The arguments should be of the same type for which there should be
* an implicit type descriptor at the call site. */
- @Reified("T") def fromItems[T](items: T*)(implicit cT: RType[T]): Coll[T]
+ def fromItems[T](items: T*)(implicit cT: RType[T]): Coll[T]
/** Deconstruct collection of (A,B) pairs into pair of collections.
* If `xs` is represented as PairColl, then this is O(1) operation (no data is touched). */
diff --git a/library-api/src/main/scala/special/wrappers/WrappersSpec.scala b/library-api/src/main/scala/special/wrappers/WrappersSpec.scala
index baefa6aa3e..0765ba3358 100644
--- a/library-api/src/main/scala/special/wrappers/WrappersSpec.scala
+++ b/library-api/src/main/scala/special/wrappers/WrappersSpec.scala
@@ -1,8 +1,6 @@
package special.wrappers
-import scala.reflect.ClassTag
-import special.SpecialPredef
-import scalan.{NeverInline, RType, WrapSpec}
+import scalan.{RType, WrapSpec}
trait WrapSpecBase extends WrapSpec {
}
@@ -10,14 +8,14 @@ trait WrapSpecBase extends WrapSpec {
/** Wrappers spec for Option */
trait OptionWrapSpec extends WrapSpecBase {
def get[A](xs: Option[A]): A = xs.get
- @NeverInline // TODO codegen: convertion to Thunk is required
+ // TODO codegen: convertion to Thunk is required
def getOrElse[A](xs: Option[A], default: => A): A = xs.getOrElse(default)
def map[A,B](xs: Option[A], f: A => B): Option[B] = xs.map(f)
def flatMap[A,B](xs: Option[A], f: A => Option[B]): Option[B] = xs.flatMap(f)
def filter[A](xs: Option[A], f: A => Boolean): Option[A] = xs.filter(f)
def isDefined[A](xs: Option[A]): Boolean = xs.isDefined
def isEmpty[A](xs: Option[A]): Boolean = xs.isEmpty
- @NeverInline // TODO codegen: fold should have single section, and convertion to Thunk is required
+ // TODO codegen: fold should have single section, and convertion to Thunk is required
def fold[A,B](xs: Option[A], ifEmpty: =>B, f: A => B): B = xs.fold(ifEmpty)(f)
};
diff --git a/library-impl/src/main/scala/special/collection/CollsOverArrays.scala b/library-impl/src/main/scala/special/collection/CollsOverArrays.scala
index 97ef53ed17..6f7c87695d 100644
--- a/library-impl/src/main/scala/special/collection/CollsOverArrays.scala
+++ b/library-impl/src/main/scala/special/collection/CollsOverArrays.scala
@@ -1,13 +1,9 @@
package special.collection
import java.util
-import java.util.Objects
-import special.SpecialPredef
-
-import scala.reflect.ClassTag
import scalan._
import scalan.util.CollectionUtil
-import scalan.{RType, Reified}
+import scalan.RType
import Helpers._
import debox.Buffer
import scalan.RType._
@@ -187,7 +183,6 @@ class CollOverArrayBuilder extends CollBuilder { builder =>
pairCollFromArrays(resA, resB)(tA, tB)
}
- @Reified("T")
override def fromItems[T](items: T*)(implicit cT: RType[T]): Coll[T] = cT match {
case pt: PairType[a,b] =>
val tA = pt.tFst
diff --git a/library/src/main/scala/special/collection/CollsUnit.scala b/library/src/main/scala/special/collection/CollsUnit.scala
index 5571d4b8f6..f43e31e689 100644
--- a/library/src/main/scala/special/collection/CollsUnit.scala
+++ b/library/src/main/scala/special/collection/CollsUnit.scala
@@ -6,7 +6,7 @@ package special.collection {
import CollBuilder._;
import PairColl._;
import WOption._;
- @ContainerType @FunctorType @Liftable @WithMethodCallRecognizers trait Coll[A] extends Def[Coll[A]] {
+ trait Coll[A] extends Def[Coll[A]] {
implicit def eA: Elem[A];
def builder: Ref[CollBuilder];
def length: Ref[Int];
@@ -25,22 +25,22 @@ package special.collection {
def indices: Ref[Coll[Int]];
def flatMap[B](f: Ref[scala.Function1[A, Coll[B]]]): Ref[Coll[B]];
def segmentLength(p: Ref[scala.Function1[A, Boolean]], from: Ref[Int]): Ref[Int];
- @NeverInline def find(p: Ref[scala.Function1[A, Boolean]]): Ref[WOption[A]] = delayInvoke;
+ def find(p: Ref[scala.Function1[A, Boolean]]): Ref[WOption[A]] = delayInvoke;
def indexWhere(p: Ref[scala.Function1[A, Boolean]], from: Ref[Int]): Ref[Int];
- @NeverInline def indexOf(elem: Ref[A], from: Ref[Int]): Ref[Int] = delayInvoke;
+ def indexOf(elem: Ref[A], from: Ref[Int]): Ref[Int] = delayInvoke;
def lastIndexWhere(p: Ref[scala.Function1[A, Boolean]], end: Ref[Int]): Ref[Int];
def take(n: Ref[Int]): Ref[Coll[A]];
def patch(from: Ref[Int], patch: Ref[Coll[A]], replaced: Ref[Int]): Ref[Coll[A]];
def updated(index: Ref[Int], elem: Ref[A]): Ref[Coll[A]];
def updateMany(indexes: Ref[Coll[Int]], values: Ref[Coll[A]]): Ref[Coll[A]];
def unionSet(that: Ref[Coll[A]]): Ref[Coll[A]];
- @NeverInline def diff(that: Ref[Coll[A]]): Ref[Coll[A]] = delayInvoke;
- @NeverInline def intersect(that: Ref[Coll[A]]): Ref[Coll[A]] = delayInvoke;
+ def diff(that: Ref[Coll[A]]): Ref[Coll[A]] = delayInvoke;
+ def intersect(that: Ref[Coll[A]]): Ref[Coll[A]] = delayInvoke;
def slice(from: Ref[Int], until: Ref[Int]): Ref[Coll[A]];
def append(other: Ref[Coll[A]]): Ref[Coll[A]];
def reverse: Ref[Coll[A]]
};
- @WithMethodCallRecognizers trait PairColl[L, R] extends Coll[scala.Tuple2[L, R]] {
+ trait PairColl[L, R] extends Coll[scala.Tuple2[L, R]] {
implicit def eL: Elem[L];
implicit def eR: Elem[R];
def ls: Ref[Coll[L]];
@@ -48,9 +48,9 @@ package special.collection {
def mapFirst[T1](f: Ref[scala.Function1[L, T1]]): Ref[Coll[scala.Tuple2[T1, R]]];
def mapSecond[T1](f: Ref[scala.Function1[R, T1]]): Ref[Coll[scala.Tuple2[L, T1]]]
};
- @Liftable @WithMethodCallRecognizers trait CollBuilder extends Def[CollBuilder] {
+ trait CollBuilder extends Def[CollBuilder] {
def pairColl[A, B](as: Ref[Coll[A]], bs: Ref[Coll[B]]): Ref[PairColl[A, B]];
- @Reified(value = "T") def fromItems[T](items: Ref[T]*)(implicit cT: Elem[T]): Ref[Coll[T]];
+ def fromItems[T](items: Ref[T]*)(implicit cT: Elem[T]): Ref[Coll[T]];
def unzip[A, B](xs: Ref[Coll[scala.Tuple2[A, B]]]): Ref[scala.Tuple2[Coll[A], Coll[B]]];
def xor(left: Ref[Coll[Byte]], right: Ref[Coll[Byte]]): Ref[Coll[Byte]];
def replicate[T](n: Ref[Int], v: Ref[T]): Ref[Coll[T]];
diff --git a/library/src/main/scala/wrappers/scala/WOptions.scala b/library/src/main/scala/wrappers/scala/WOptions.scala
index 02b9082aa0..34c7a26035 100644
--- a/library/src/main/scala/wrappers/scala/WOptions.scala
+++ b/library/src/main/scala/wrappers/scala/WOptions.scala
@@ -4,16 +4,16 @@ package wrappers.scala {
import special.wrappers.WrappersModule
trait WOptions extends Base { self: WrappersModule =>
- @External("Option") @ContainerType @FunctorType @Liftable @WithMethodCallRecognizers trait WOption[A] extends Def[WOption[A]] {
+ trait WOption[A] extends Def[WOption[A]] {
implicit def eA: Elem[A];
- @External def fold[B](ifEmpty: Ref[Thunk[B]], f: Ref[scala.Function1[A, B]]): Ref[B];
- @External def isEmpty: Ref[Boolean];
- @External def isDefined: Ref[Boolean];
- @External def filter(p: Ref[scala.Function1[A, Boolean]]): Ref[WOption[A]];
- @External def flatMap[B](f: Ref[scala.Function1[A, WOption[B]]]): Ref[WOption[B]];
- @External def map[B](f: Ref[scala.Function1[A, B]]): Ref[WOption[B]];
- @External def getOrElse[B](default: Ref[Thunk[B]]): Ref[B];
- @External def get: Ref[A]
+ def fold[B](ifEmpty: Ref[Thunk[B]], f: Ref[scala.Function1[A, B]]): Ref[B];
+ def isEmpty: Ref[Boolean];
+ def isDefined: Ref[Boolean];
+ def filter(p: Ref[scala.Function1[A, Boolean]]): Ref[WOption[A]];
+ def flatMap[B](f: Ref[scala.Function1[A, WOption[B]]]): Ref[WOption[B]];
+ def map[B](f: Ref[scala.Function1[A, B]]): Ref[WOption[B]];
+ def getOrElse[B](default: Ref[Thunk[B]]): Ref[B];
+ def get: Ref[A]
};
trait WOptionCompanion
}
diff --git a/library/src/main/scala/wrappers/scalan/WRTypes.scala b/library/src/main/scala/wrappers/scalan/WRTypes.scala
index 26566be4a7..07795cdada 100644
--- a/library/src/main/scala/wrappers/scalan/WRTypes.scala
+++ b/library/src/main/scala/wrappers/scalan/WRTypes.scala
@@ -13,9 +13,9 @@ package wrappers.scalan {
trait WRTypes extends Base { self: WrappersModule =>
import WRType._;
- @External("RType") @Liftable @WithMethodCallRecognizers trait WRType[A] extends Def[WRType[A]] {
+ trait WRType[A] extends Def[WRType[A]] {
implicit def eA: Elem[A];
- @External def name: Ref[String]
+ def name: Ref[String]
};
trait WRTypeCompanion
}
diff --git a/library/src/main/scala/wrappers/special/WSpecialPredefs.scala b/library/src/main/scala/wrappers/special/WSpecialPredefs.scala
index fc7f0c7401..6a5731fa06 100644
--- a/library/src/main/scala/wrappers/special/WSpecialPredefs.scala
+++ b/library/src/main/scala/wrappers/special/WSpecialPredefs.scala
@@ -6,13 +6,13 @@ package wrappers.special {
trait WSpecialPredefs extends Base { self: WrappersModule =>
import WOption._;
import WSpecialPredef._;
- @External("SpecialPredef") @WithMethodCallRecognizers trait WSpecialPredef extends Def[WSpecialPredef];
+ trait WSpecialPredef extends Def[WSpecialPredef];
trait WSpecialPredefCompanion {
- @External def optionGetOrElse[A](opt: Ref[WOption[A]], default: Ref[A]): Ref[A];
- @External def none[@Reified A](implicit emA: Elem[A]): Ref[WOption[A]];
- @External def some[A](x: Ref[A]): Ref[WOption[A]];
- @External def cast[@Reified T](v: Ref[Any])(implicit emT: Elem[T]): Ref[WOption[T]];
- @External def loopUntil[A](s1: Ref[A], isMatch: Ref[scala.Function1[A, Boolean]], step: Ref[scala.Function1[A, A]]): Ref[A]
+ def optionGetOrElse[A](opt: Ref[WOption[A]], default: Ref[A]): Ref[A];
+ def none[A](implicit emA: Elem[A]): Ref[WOption[A]];
+ def some[A](x: Ref[A]): Ref[WOption[A]];
+ def cast[T](v: Ref[Any])(implicit emT: Elem[T]): Ref[WOption[T]];
+ def loopUntil[A](s1: Ref[A], isMatch: Ref[scala.Function1[A, Boolean]], step: Ref[scala.Function1[A, A]]): Ref[A]
}
}
}
\ No newline at end of file
diff --git a/library/src/test/scala/special/collections/CollsTests.scala b/library/src/test/scala/special/collections/CollsTests.scala
index b22822e2aa..b8a8339276 100644
--- a/library/src/test/scala/special/collections/CollsTests.scala
+++ b/library/src/test/scala/special/collections/CollsTests.scala
@@ -2,7 +2,8 @@ package special.collections
import org.scalacheck.Gen
import org.scalatest.exceptions.TestFailedException
-import org.scalatest.{Matchers, PropSpec}
+import org.scalatest.matchers.should.Matchers
+import org.scalatest.propspec.AnyPropSpec
import org.scalatestplus.scalacheck.ScalaCheckPropertyChecks
import scalan._
import sigmastate.{VersionContext, VersionTestingProperty}
@@ -10,7 +11,7 @@ import special.collection.{Coll, CollOverArray, PairOfCols}
import scala.language.{existentials, implicitConversions}
-class CollsTests extends PropSpec with ScalaCheckPropertyChecks with Matchers with CollGens with VersionTestingProperty { testSuite =>
+class CollsTests extends AnyPropSpec with ScalaCheckPropertyChecks with Matchers with CollGens with VersionTestingProperty { testSuite =>
import Gen._
import special.collection.ExtensionMethods._
diff --git a/sigma-api/src/main/scala/special/sigma/SigmaDsl.scala b/sigma-api/src/main/scala/special/sigma/SigmaDsl.scala
index 38ef31700c..a6864a3302 100644
--- a/sigma-api/src/main/scala/special/sigma/SigmaDsl.scala
+++ b/sigma-api/src/main/scala/special/sigma/SigmaDsl.scala
@@ -14,8 +14,6 @@ import scala.util.Try
* which is used for all cryptographic operations).
* So it is globally and implicitly used in all methods.
* */
-@scalan.Liftable
-@WithMethodCallRecognizers
trait BigInt {
/** Convert this BigInt value to Byte.
* @throws ArithmeticException if overflow happens.
@@ -98,7 +96,7 @@ trait BigInt {
* @return { @code this + that}
*/
def add(that: BigInt): BigInt
- @Internal def +(that: BigInt): BigInt = add(that)
+ def +(that: BigInt): BigInt = add(that)
/** Returns a BigInt whose value is {@code (this - that)}.
*
@@ -106,7 +104,7 @@ trait BigInt {
* @return { @code this - that}
*/
def subtract(that: BigInt): BigInt
- @Internal def -(that: BigInt): BigInt = subtract(that)
+ def -(that: BigInt): BigInt = subtract(that)
/** Returns a BigInt whose value is {@code (this * that)}.
*
@@ -116,7 +114,7 @@ trait BigInt {
* @return { @code this * that}
*/
def multiply(that: BigInt): BigInt
- @Internal def *(that: BigInt): BigInt = multiply(that)
+ def *(that: BigInt): BigInt = multiply(that)
/** Returns a BigInt whose value is {@code (this / that)}.
*
@@ -125,7 +123,7 @@ trait BigInt {
* @throws ArithmeticException if { @code that} is zero.
*/
def divide(that: BigInt): BigInt
- @Internal def /(that: BigInt): BigInt = divide(that)
+ def /(that: BigInt): BigInt = divide(that)
/**
* Returns a BigInt whose value is {@code (this mod m}). This method
@@ -138,7 +136,7 @@ trait BigInt {
* @see #remainder
*/
def mod(m: BigInt): BigInt
- @Internal def %(m: BigInt): BigInt = mod(m)
+ def %(m: BigInt): BigInt = mod(m)
/**
* Returns a BigInt whose value is {@code (this % that)}.
@@ -181,7 +179,7 @@ trait BigInt {
* @return `this & that`
*/
def and(that: BigInt): BigInt
- @Internal def &(that: BigInt): BigInt = and(that)
+ def &(that: BigInt): BigInt = and(that)
/** Returns a BigInteger whose value is `(this | that)`. (This
* method returns a negative BigInteger if and only if either `this` or `that`` is
@@ -191,13 +189,11 @@ trait BigInt {
* @return `this | that`
*/
def or(that: BigInt): BigInt
- @Internal def |(that: BigInt): BigInt = or(that)
+ def |(that: BigInt): BigInt = or(that)
}
/** Base class for points on elliptic curves.
*/
-@scalan.Liftable
-@WithMethodCallRecognizers
trait GroupElement {
/** Checks if the provided element is an identity element. */
def isIdentity: Boolean
@@ -224,8 +220,6 @@ trait GroupElement {
}
/** Proposition which can be proven and verified by sigma protocol. */
-@scalan.Liftable
-@WithMethodCallRecognizers
trait SigmaProp {
def isValid: Boolean
/** Serialized bytes of this sigma proposition taken as ErgoTree and then serialized. */
@@ -233,26 +227,14 @@ trait SigmaProp {
/** Logical AND between this SigmaProp and other SigmaProp.
* This constructs a new CAND node of sigma tree with two children. */
- @OverloadId("and_sigma") def &&(other: SigmaProp): SigmaProp
-
- /** Logical AND between this `SigmaProp` and `Boolean` value on the right.
- * The boolean value will be wrapped into `SigmaProp` using `sigmaProp` function.
- * This constructs a new CAND node of sigma tree with two children. */
- @OverloadId("and_bool") def &&(other: Boolean): SigmaProp
+ def &&(other: SigmaProp): SigmaProp
/** Logical OR between this SigmaProp and other SigmaProp.
* This constructs a new COR node of sigma tree with two children. */
- @OverloadId("or_sigma") def ||(other: SigmaProp): SigmaProp
-
- /** Logical OR between this `SigmaProp` and `Boolean` value on the right.
- * The boolean value will be wrapped into `SigmaProp` using `sigmaProp` function.
- * This constructs a new COR node of sigma tree with two children. */
- @OverloadId("or_bool") def ||(other: Boolean): SigmaProp
+ def ||(other: SigmaProp): SigmaProp
}
/** Represents any value paired with type descriptor. */
-@scalan.Liftable
-@WithMethodCallRecognizers
trait AnyValue {
/** The data value wrapped by this instance. */
def value: Any
@@ -263,8 +245,6 @@ trait AnyValue {
/** Runtime representation of Ergo boxes used during execution of ErgoTree operations.
* @see [[org.ergoplatform.ErgoBox]]
*/
-@scalan.Liftable
-@WithMethodCallRecognizers
trait Box {
/** Blake2b256 hash of this box's content, basically equals to `blake2b256(bytes)` */
def id: Coll[Byte]
@@ -341,32 +321,32 @@ trait Box {
* different from cT.
* @since 2.0
*/
- def getReg[@Reified T](i: Int)(implicit cT: RType[T]): Option[T]
+ def getReg[T](i: Int)(implicit cT: RType[T]): Option[T]
/** Mandatory: Monetary value, in Ergo tokens */
- def R0[@Reified T](implicit cT:RType[T]): Option[T] = this.getReg[T](0)
+ def R0[T](implicit cT:RType[T]): Option[T] = this.getReg[T](0)
/** Mandatory: Guarding script */
- def R1[@Reified T](implicit cT:RType[T]): Option[T] = this.getReg[T](1)
+ def R1[T](implicit cT:RType[T]): Option[T] = this.getReg[T](1)
/** Mandatory: Secondary tokens */
- def R2[@Reified T](implicit cT:RType[T]): Option[T] = this.getReg[T](2)
+ def R2[T](implicit cT:RType[T]): Option[T] = this.getReg[T](2)
/** Mandatory: Reference to transaction and output id where the box was created */
- def R3[@Reified T](implicit cT:RType[T]): Option[T] = this.getReg[T](3)
+ def R3[T](implicit cT:RType[T]): Option[T] = this.getReg[T](3)
/** Non-mandatory register */
- def R4[@Reified T](implicit cT:RType[T]): Option[T] = this.getReg[T](4)
+ def R4[T](implicit cT:RType[T]): Option[T] = this.getReg[T](4)
/** Non-mandatory register */
- def R5[@Reified T](implicit cT:RType[T]): Option[T] = this.getReg[T](5)
+ def R5[T](implicit cT:RType[T]): Option[T] = this.getReg[T](5)
/** Non-mandatory register */
- def R6[@Reified T](implicit cT:RType[T]): Option[T] = this.getReg[T](6)
+ def R6[T](implicit cT:RType[T]): Option[T] = this.getReg[T](6)
/** Non-mandatory register */
- def R7[@Reified T](implicit cT:RType[T]): Option[T] = this.getReg[T](7)
+ def R7[T](implicit cT:RType[T]): Option[T] = this.getReg[T](7)
/** Non-mandatory register */
- def R8[@Reified T](implicit cT:RType[T]): Option[T] = this.getReg[T](8)
+ def R8[T](implicit cT:RType[T]): Option[T] = this.getReg[T](8)
/** Non-mandatory register */
- def R9[@Reified T](implicit cT:RType[T]): Option[T] = this.getReg[T](9)
+ def R9[T](implicit cT:RType[T]): Option[T] = this.getReg[T](9)
/** Secondary tokens */
def tokens: Coll[(Coll[Byte], Long)]
@@ -384,9 +364,8 @@ trait Box {
* @return result of the script execution in the current context
* @since Mainnet
*/
- def executeFromRegister[@Reified T](regId: Byte)(implicit cT:RType[T]): T
+ def executeFromRegister[T](regId: Byte)(implicit cT:RType[T]): T
- @Internal
override def toString = s"Box(id=$id; value=$value; regs=$registers)"
}
@@ -399,7 +378,6 @@ trait Box {
*
* This interface is used as runtime representation of the AvlTree type of ErgoTree.
*/
-@scalan.Liftable
trait AvlTree {
/** Returns digest of the state represented by this tree.
* Authenticated tree digest = root hash bytes ++ tree height
@@ -554,7 +532,6 @@ trait AvlTreeVerifier {
/** Only header fields that can be predicted by a miner.
* @since 2.0
*/
-@scalan.Liftable
trait PreHeader { // Testnet2
/** Block version, to be increased on every soft and hardfork. */
def version: Byte
@@ -582,7 +559,6 @@ trait PreHeader { // Testnet2
/** Represents data of the block header available in Sigma propositions.
* @since 2.0
*/
-@scalan.Liftable
trait Header {
/** Bytes representation of ModifierId of this Header */
def id: Coll[Byte]
@@ -636,8 +612,6 @@ trait Header {
/** Runtime representation of Context ErgoTree type.
* Represents data available in Sigma language using `CONTEXT` global variable.
*/
-@scalan.Liftable
-@WithMethodCallRecognizers
trait Context {
def builder: SigmaDslBuilder
@@ -742,12 +716,9 @@ trait Context {
def currentErgoTreeVersion: Byte
}
-@scalan.Liftable
trait SigmaContract {
def builder: SigmaDslBuilder
- @NeverInline
- @Reified("T")
def Collection[T](items: T*)(implicit cT: RType[T]): Coll[T] = this.builder.Colls.fromItems[T](items:_*)
/** !!! all methods should delegate to builder */
@@ -778,7 +749,6 @@ trait SigmaContract {
def decodePoint(encoded: Coll[Byte]): GroupElement = this.builder.decodePoint(encoded)
- @Reified("T")
def substConstants[T](scriptBytes: Coll[Byte],
positions: Coll[Int],
newValues: Coll[T]): Coll[Byte] = this.builder.substConstants(scriptBytes, positions, newValues)
@@ -794,8 +764,6 @@ trait SigmaContract {
*
* @see SGlobal.WrappedType, CostingSigmaDslBuilder
*/
-@scalan.Liftable
-@WithMethodCallRecognizers
trait SigmaDslBuilder {
/** Access to collection operations. */
@@ -886,7 +854,6 @@ trait SigmaDslBuilder {
* @param newValues new values to be injected into the corresponding positions in ErgoTree.constants array
* @return original scriptBytes array where only specified constants are replaced and all other bytes remain exactly the same
*/
- @Reified("T")
def substConstants[T](scriptBytes: Coll[Byte], positions: Coll[Int], newValues: Coll[T]): Coll[Byte]
/** Decodes the given bytes to the corresponding GroupElement using default serialization.
@@ -896,10 +863,10 @@ trait SigmaDslBuilder {
def decodePoint(encoded: Coll[Byte]): GroupElement
/** Create DSL big integer from existing `java.math.BigInteger`*/
- @Internal def BigInt(n: BigInteger): BigInt
+ def BigInt(n: BigInteger): BigInt
/** Extract `java.math.BigInteger` from DSL's `BigInt` type*/
- @Internal def toBigInteger(n: BigInt): BigInteger
+ def toBigInteger(n: BigInt): BigInteger
/** Construct a new authenticated dictionary with given parameters and tree root digest. */
def avlTree(operationFlags: Byte, digest: Coll[Byte], keyLength: Int, valueLengthOpt: Option[Int]): AvlTree
diff --git a/sigma-library/src/main/scala/special/sigma/SigmaDslUnit.scala b/sigma-library/src/main/scala/special/sigma/SigmaDslUnit.scala
index 5634a05d6d..5bd2ad784b 100644
--- a/sigma-library/src/main/scala/special/sigma/SigmaDslUnit.scala
+++ b/sigma-library/src/main/scala/special/sigma/SigmaDslUnit.scala
@@ -3,7 +3,7 @@ package special.sigma {
import scalan._
trait SigmaDsl extends Base { self: SigmaLibrary =>
- @Liftable @WithMethodCallRecognizers trait BigInt extends Def[BigInt] {
+ trait BigInt extends Def[BigInt] {
def toByte: Ref[Byte];
def toShort: Ref[Short];
def toInt: Ref[Int];
@@ -28,28 +28,24 @@ package special.sigma {
def max(that: Ref[BigInt]): Ref[BigInt];
def negate: Ref[BigInt]
};
- @Liftable @WithMethodCallRecognizers trait GroupElement extends Def[GroupElement] {
+ trait GroupElement extends Def[GroupElement] {
def isInfinity: Ref[Boolean];
def exp(k: Ref[BigInt]): Ref[GroupElement];
def multiply(that: Ref[GroupElement]): Ref[GroupElement];
def negate: Ref[GroupElement];
def getEncoded: Ref[Coll[Byte]]
};
- @Liftable @WithMethodCallRecognizers trait SigmaProp extends Def[SigmaProp] {
+ trait SigmaProp extends Def[SigmaProp] {
def isValid: Ref[Boolean];
def propBytes: Ref[Coll[Byte]];
- @OverloadId(value = "and_sigma") def &&(other: Ref[SigmaProp]): Ref[SigmaProp];
- // manual fix
- @OverloadId(value = "and_bool") def &&(other: Ref[Boolean])(implicit o: Overloaded1): Ref[SigmaProp];
- @OverloadId(value = "or_sigma") def ||(other: Ref[SigmaProp]): Ref[SigmaProp];
- // manual fix
- @OverloadId(value = "or_bool") def ||(other: Ref[Boolean])(implicit o: Overloaded1): Ref[SigmaProp];
+ def &&(other: Ref[SigmaProp]): Ref[SigmaProp];
+ def ||(other: Ref[SigmaProp]): Ref[SigmaProp];
};
- @Liftable @WithMethodCallRecognizers trait AnyValue extends Def[AnyValue] {
+ trait AnyValue extends Def[AnyValue] {
def value: Ref[Any];
def tVal: Ref[WRType[Any]]
};
- @Liftable @WithMethodCallRecognizers trait Box extends Def[Box] {
+ trait Box extends Def[Box] {
def id: Ref[Coll[Byte]];
def value: Ref[Long];
def propositionBytes: Ref[Coll[Byte]];
@@ -71,7 +67,7 @@ package special.sigma {
def creationInfo: Ref[scala.Tuple2[Int, Coll[Byte]]];
def executeFromRegister[T](regId: Ref[Byte])(implicit cT: Elem[T]): Ref[T]
};
- @Liftable trait AvlTree extends Def[AvlTree] {
+ trait AvlTree extends Def[AvlTree] {
def digest: Ref[Coll[Byte]];
def enabledOperations: Ref[Byte];
def keyLength: Ref[Int];
@@ -88,7 +84,7 @@ package special.sigma {
def update(operations: Ref[Coll[scala.Tuple2[Coll[Byte], Coll[Byte]]]], proof: Ref[Coll[Byte]]): Ref[WOption[AvlTree]];
def remove(operations: Ref[Coll[Coll[Byte]]], proof: Ref[Coll[Byte]]): Ref[WOption[AvlTree]]
};
- @Liftable trait PreHeader extends Def[PreHeader] {
+ trait PreHeader extends Def[PreHeader] {
def version: Ref[Byte];
def parentId: Ref[Coll[Byte]];
def timestamp: Ref[Long];
@@ -97,7 +93,7 @@ package special.sigma {
def minerPk: Ref[GroupElement];
def votes: Ref[Coll[Byte]]
};
- @Liftable trait Header extends Def[Header] {
+ trait Header extends Def[Header] {
def id: Ref[Coll[Byte]];
def version: Ref[Byte];
def parentId: Ref[Coll[Byte]];
@@ -114,7 +110,7 @@ package special.sigma {
def powDistance: Ref[BigInt];
def votes: Ref[Coll[Byte]]
};
- @Liftable @WithMethodCallRecognizers trait Context extends Def[Context] {
+ trait Context extends Def[Context] {
def builder: Ref[SigmaDslBuilder];
def OUTPUTS: Ref[Coll[Box]];
def INPUTS: Ref[Coll[Box]];
@@ -129,7 +125,7 @@ package special.sigma {
def getVar[T](id: Ref[Byte])(implicit cT: Elem[T]): Ref[WOption[T]];
def vars: Ref[Coll[AnyValue]]
};
- @Liftable @WithMethodCallRecognizers trait SigmaDslBuilder extends Def[SigmaDslBuilder] {
+ trait SigmaDslBuilder extends Def[SigmaDslBuilder] {
def Colls: Ref[CollBuilder];
def verifyZK(cond: Ref[Thunk[SigmaProp]]): Ref[Boolean];
def atLeast(bound: Ref[Int], props: Ref[Coll[SigmaProp]]): Ref[SigmaProp];
@@ -147,7 +143,7 @@ package special.sigma {
def proveDlog(g: Ref[GroupElement]): Ref[SigmaProp];
def proveDHTuple(g: Ref[GroupElement], h: Ref[GroupElement], u: Ref[GroupElement], v: Ref[GroupElement]): Ref[SigmaProp];
def groupGenerator: Ref[GroupElement];
- @Reified(value = "T") def substConstants[T](scriptBytes: Ref[Coll[Byte]], positions: Ref[Coll[Int]], newValues: Ref[Coll[T]]): Ref[Coll[Byte]];
+ def substConstants[T](scriptBytes: Ref[Coll[Byte]], positions: Ref[Coll[Int]], newValues: Ref[Coll[T]]): Ref[Coll[Byte]];
def decodePoint(encoded: Ref[Coll[Byte]]): Ref[GroupElement];
def avlTree(operationFlags: Ref[Byte], digest: Ref[Coll[Byte]], keyLength: Ref[Int], valueLengthOpt: Ref[WOption[Int]]): Ref[AvlTree];
def xor(l: Ref[Coll[Byte]], r: Ref[Coll[Byte]]): Ref[Coll[Byte]]
diff --git a/sigma-library/src/main/scala/special/sigma/impl/SigmaDslImpl.scala b/sigma-library/src/main/scala/special/sigma/impl/SigmaDslImpl.scala
index efdbd3fc23..8195aed696 100644
--- a/sigma-library/src/main/scala/special/sigma/impl/SigmaDslImpl.scala
+++ b/sigma-library/src/main/scala/special/sigma/impl/SigmaDslImpl.scala
@@ -908,14 +908,6 @@ object SigmaProp extends EntityObject("SigmaProp") {
true, false, element[SigmaProp]))
}
- // manual fix &&
- override def &&(other: Ref[Boolean])(implicit o: Overloaded1): Ref[SigmaProp] = {
- asRep[SigmaProp](mkMethodCall(self,
- SigmaPropClass.getMethod("$amp$amp", classOf[Sym], classOf[Overloaded1]),
- Array[AnyRef](other, o),
- true, false, element[SigmaProp]))
- }
-
// manual fix ||
override def ||(other: Ref[SigmaProp]): Ref[SigmaProp] = {
asRep[SigmaProp](mkMethodCall(self,
@@ -923,14 +915,6 @@ object SigmaProp extends EntityObject("SigmaProp") {
Array[AnyRef](other),
true, false, element[SigmaProp]))
}
-
- // manual fix ||
- override def ||(other: Ref[Boolean])(implicit o: Overloaded1): Ref[SigmaProp] = {
- asRep[SigmaProp](mkMethodCall(self,
- SigmaPropClass.getMethod("$bar$bar", classOf[Sym], classOf[Overloaded1]),
- Array[AnyRef](other, o),
- true, false, element[SigmaProp]))
- }
}
implicit object LiftableSigmaProp
@@ -978,14 +962,6 @@ object SigmaProp extends EntityObject("SigmaProp") {
true, true, element[SigmaProp]))
}
- // manual fix &&
- def &&(other: Ref[Boolean])(implicit o: Overloaded1): Ref[SigmaProp] = {
- asRep[SigmaProp](mkMethodCall(source,
- SigmaPropClass.getMethod("$amp$amp", classOf[Sym], classOf[Overloaded1]),
- Array[AnyRef](other, o),
- true, true, element[SigmaProp]))
- }
-
// manual fix ||
def ||(other: Ref[SigmaProp]): Ref[SigmaProp] = {
asRep[SigmaProp](mkMethodCall(source,
@@ -994,28 +970,6 @@ object SigmaProp extends EntityObject("SigmaProp") {
true, true, element[SigmaProp]))
}
- // manual fix ||
- def ||(other: Ref[Boolean])(implicit o: Overloaded1): Ref[SigmaProp] = {
- asRep[SigmaProp](mkMethodCall(source,
- SigmaPropClass.getMethod("$bar$bar", classOf[Sym], classOf[Overloaded1]),
- Array[AnyRef](other, o),
- true, true, element[SigmaProp]))
- }
-
- def lazyAnd(other: Ref[Thunk[SigmaProp]]): Ref[SigmaProp] = {
- asRep[SigmaProp](mkMethodCall(source,
- SigmaPropClass.getMethod("lazyAnd", classOf[Sym]),
- Array[AnyRef](other),
- true, true, element[SigmaProp]))
- }
-
- def lazyOr(other: Ref[Thunk[SigmaProp]]): Ref[SigmaProp] = {
- asRep[SigmaProp](mkMethodCall(source,
- SigmaPropClass.getMethod("lazyOr", classOf[Sym]),
- Array[AnyRef](other),
- true, true, element[SigmaProp]))
- }
-
// manual fix
def builder: Ref[SigmaDslBuilder] = {
asRep[SigmaDslBuilder](mkMethodCall(source,
@@ -1040,7 +994,7 @@ object SigmaProp extends EntityObject("SigmaProp") {
override protected def collectMethods: Map[java.lang.reflect.Method, MethodDesc] = {
super.collectMethods ++
Elem.declaredMethods(classOf[SigmaProp], classOf[SSigmaProp], Set(
- "isValid", "propBytes", "$amp$amp", "$amp$amp", "$bar$bar", "$bar$bar"
+ "isValid", "propBytes", "$amp$amp", "$bar$bar"
))
}
}
@@ -1084,7 +1038,7 @@ object SigmaProp extends EntityObject("SigmaProp") {
object and_sigma_&& {
def unapply(d: Def[_]): Nullable[(Ref[SigmaProp], Ref[SigmaProp])] = d match {
- case MethodCall(receiver, method, args, _) if method.getName == "$amp$amp" && receiver.elem.isInstanceOf[SigmaPropElem[_]] && { val ann = method.getAnnotation(classOf[scalan.OverloadId]); ann != null && ann.value == "and_sigma" } =>
+ case MethodCall(receiver, method, args, _) if method.getName == "$amp$amp" && receiver.elem.isInstanceOf[SigmaPropElem[_]] =>
val res = (receiver, args(0))
Nullable(res).asInstanceOf[Nullable[(Ref[SigmaProp], Ref[SigmaProp])]]
case _ => Nullable.None
@@ -1092,35 +1046,15 @@ object SigmaProp extends EntityObject("SigmaProp") {
def unapply(exp: Sym): Nullable[(Ref[SigmaProp], Ref[SigmaProp])] = unapply(exp.node)
}
- object and_bool_&& {
- def unapply(d: Def[_]): Nullable[(Ref[SigmaProp], Ref[Boolean])] = d match {
- case MethodCall(receiver, method, args, _) if method.getName == "$amp$amp" && receiver.elem.isInstanceOf[SigmaPropElem[_]] && { val ann = method.getAnnotation(classOf[scalan.OverloadId]); ann != null && ann.value == "and_bool" } =>
- val res = (receiver, args(0))
- Nullable(res).asInstanceOf[Nullable[(Ref[SigmaProp], Ref[Boolean])]]
- case _ => Nullable.None
- }
- def unapply(exp: Sym): Nullable[(Ref[SigmaProp], Ref[Boolean])] = unapply(exp.node)
- }
-
object or_sigma_|| {
def unapply(d: Def[_]): Nullable[(Ref[SigmaProp], Ref[SigmaProp])] = d match {
- case MethodCall(receiver, method, args, _) if method.getName == "$bar$bar" && receiver.elem.isInstanceOf[SigmaPropElem[_]] && { val ann = method.getAnnotation(classOf[scalan.OverloadId]); ann != null && ann.value == "or_sigma" } =>
+ case MethodCall(receiver, method, args, _) if method.getName == "$bar$bar" && receiver.elem.isInstanceOf[SigmaPropElem[_]] =>
val res = (receiver, args(0))
Nullable(res).asInstanceOf[Nullable[(Ref[SigmaProp], Ref[SigmaProp])]]
case _ => Nullable.None
}
def unapply(exp: Sym): Nullable[(Ref[SigmaProp], Ref[SigmaProp])] = unapply(exp.node)
}
-
- object or_bool_|| {
- def unapply(d: Def[_]): Nullable[(Ref[SigmaProp], Ref[Boolean])] = d match {
- case MethodCall(receiver, method, args, _) if method.getName == "$bar$bar" && receiver.elem.isInstanceOf[SigmaPropElem[_]] && { val ann = method.getAnnotation(classOf[scalan.OverloadId]); ann != null && ann.value == "or_bool" } =>
- val res = (receiver, args(0))
- Nullable(res).asInstanceOf[Nullable[(Ref[SigmaProp], Ref[Boolean])]]
- case _ => Nullable.None
- }
- def unapply(exp: Sym): Nullable[(Ref[SigmaProp], Ref[Boolean])] = unapply(exp.node)
- }
}
object SigmaPropCompanionMethods {
diff --git a/sigmastate/src/main/scala/org/ergoplatform/ErgoAddress.scala b/sigmastate/src/main/scala/org/ergoplatform/ErgoAddress.scala
index 1a2b5b2878..251df04e1f 100644
--- a/sigmastate/src/main/scala/org/ergoplatform/ErgoAddress.scala
+++ b/sigmastate/src/main/scala/org/ergoplatform/ErgoAddress.scala
@@ -1,6 +1,8 @@
package org.ergoplatform
-import com.google.common.primitives.Ints
+import java.util
+
+import scorex.utils.Ints
import org.ergoplatform.ErgoAddressEncoder.NetworkPrefix
import scorex.crypto.hash.{Digest32, Blake2b256}
import scorex.util.encode.Base58
diff --git a/sigmastate/src/main/scala/org/ergoplatform/ErgoBox.scala b/sigmastate/src/main/scala/org/ergoplatform/ErgoBox.scala
index f1c883ab60..256f643d93 100644
--- a/sigmastate/src/main/scala/org/ergoplatform/ErgoBox.scala
+++ b/sigmastate/src/main/scala/org/ergoplatform/ErgoBox.scala
@@ -1,6 +1,6 @@
package org.ergoplatform
-import com.google.common.primitives.{Ints, Shorts}
+import scorex.utils.{Ints, Shorts}
import org.ergoplatform.ErgoBox.{NonMandatoryRegisterId, TokenId}
import org.ergoplatform.settings.ErgoAlgos
import scorex.crypto.authds.ADKey
diff --git a/sigmastate/src/main/scala/sigmastate/eval/CostingDataContext.scala b/sigmastate/src/main/scala/sigmastate/eval/CostingDataContext.scala
index 09912c7588..76bafd2fa2 100644
--- a/sigmastate/src/main/scala/sigmastate/eval/CostingDataContext.scala
+++ b/sigmastate/src/main/scala/sigmastate/eval/CostingDataContext.scala
@@ -1,6 +1,6 @@
package sigmastate.eval
-import com.google.common.primitives.{Ints, Longs}
+import scorex.utils.{Ints, Longs}
import java.math.BigInteger
import java.util.Arrays
@@ -143,19 +143,11 @@ case class CSigmaProp(sigmaTree: SigmaBoolean) extends SigmaProp with WrapperOf[
CSigmaProp(CAND.normalized(Array(sigmaTree, other.sigmaTree)))
}
- // TODO refactor: remove this (it shouldn't be used in interpreter)
- override def &&(other: Boolean): SigmaProp =
- CSigmaProp(CAND.normalized(Array(sigmaTree, TrivialProp(other))))
-
override def ||(other: SigmaProp): SigmaProp = other match {
case other: CSigmaProp =>
CSigmaProp(COR.normalized(Array(sigmaTree, other.sigmaTree)))
}
- // TODO refactor: remove this (it shouldn't be used in interpreter)
- override def ||(other: Boolean): SigmaProp =
- CSigmaProp(COR.normalized(Array(sigmaTree, TrivialProp(other))))
-
override def toString: String = s"SigmaProp(${wrappedValue.showToString})"
}
diff --git a/sigmastate/src/main/scala/sigmastate/eval/TreeBuilding.scala b/sigmastate/src/main/scala/sigmastate/eval/TreeBuilding.scala
index 4f8501606f..25f909e8bc 100644
--- a/sigmastate/src/main/scala/sigmastate/eval/TreeBuilding.scala
+++ b/sigmastate/src/main/scala/sigmastate/eval/TreeBuilding.scala
@@ -319,10 +319,6 @@ trait TreeBuilding extends SigmaLibrary { IR: IRContext =>
case OM.isDefined(In(optionSym)) =>
mkOptionIsDefined(optionSym.asValue[SOption[SType]])
- case SigmaM.and_bool_&&(In(prop), In(cond)) => // TODO refactor: remove or cover by tests: it is never executed
- SigmaAnd(Seq(prop.asSigmaProp, mkBoolToSigmaProp(cond.asBoolValue)))
- case SigmaM.or_bool_||(In(prop), In(cond)) => // TODO refactor: remove or cover by tests: it is never executed
- SigmaOr(Seq(prop.asSigmaProp, mkBoolToSigmaProp(cond.asBoolValue)))
case SigmaM.and_sigma_&&(In(p1), In(p2)) =>
SigmaAnd(Seq(p1.asSigmaProp, p2.asSigmaProp))
case SigmaM.or_sigma_||(In(p1), In(p2)) =>
diff --git a/sigmastate/src/main/scala/sigmastate/utils/Extensions.scala b/sigmastate/src/main/scala/sigmastate/utils/Extensions.scala
index 8d8d8d9927..24ee381108 100644
--- a/sigmastate/src/main/scala/sigmastate/utils/Extensions.scala
+++ b/sigmastate/src/main/scala/sigmastate/utils/Extensions.scala
@@ -1,6 +1,6 @@
package sigmastate.utils
-import com.google.common.primitives.{Ints, Longs, Shorts}
+import scorex.utils.{Ints, Longs, Shorts}
import sigmastate.eval.SigmaDsl
import special.collection.Coll
diff --git a/sigmastate/src/test/java/gf2t/GF2_192Test.java b/sigmastate/src/test/java/gf2t/GF2_192Test.java
deleted file mode 100644
index f438907efe..0000000000
--- a/sigmastate/src/test/java/gf2t/GF2_192Test.java
+++ /dev/null
@@ -1,713 +0,0 @@
-/*
- By Leonid Reyzin
-
- This is free and unencumbered software released into the public domain.
-
- Anyone is free to copy, modify, publish, use, compile, sell, or
- distribute this software, either in source code form or as a compiled
- binary, for any purpose, commercial or non-commercial, and by any
- means.
-
- In jurisdictions that recognize copyright laws, the author or authors
- of this software dedicate any and all copyright interest in the
- software to the public domain. We make this dedication for the benefit
- of the public at large and to the detriment of our heirs and
- successors. We intend this dedication to be an overt act of
- relinquishment in perpetuity of all present and future rights to this
- software under copyright law.
-
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
- IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR
- OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
- ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
- OTHER DEALINGS IN THE SOFTWARE.
-
- For more information, please refer to