From 913baecb74c522c5b6a45b9ab5bda816f702e25c Mon Sep 17 00:00:00 2001 From: Alexander Slesarenko Date: Mon, 21 Aug 2023 23:16:22 +0200 Subject: [PATCH 01/37] minimize-modules: core-lib module removed --- build.sbt | 55 ++++++++++--------- .../scala/special/CoreLibReflection.scala | 0 .../shared/src/main/scala/special/Types.scala | 0 .../main/scala/special/collection/Colls.scala | 0 .../special/collection/CollsOverArrays.scala | 0 .../scala/special/collection/Extensions.scala | 0 .../scala/special/collection/Helpers.scala | 0 .../scala/special/collection/package.scala | 0 .../main/scala/special/sigma/SigmaDsl.scala | 0 .../main/scala/special/sigma/package.scala | 0 .../scala/special/wrappers/WrappersSpec.scala | 0 .../src/test/scala/special/TypesTests.scala | 0 .../scala/special/collections/CollGens.scala | 0 .../special/collections/CollsTests.scala | 0 14 files changed, 28 insertions(+), 27 deletions(-) rename {core-lib => common}/shared/src/main/scala/special/CoreLibReflection.scala (100%) rename {core-lib => common}/shared/src/main/scala/special/Types.scala (100%) rename {core-lib => common}/shared/src/main/scala/special/collection/Colls.scala (100%) rename {core-lib => common}/shared/src/main/scala/special/collection/CollsOverArrays.scala (100%) rename {core-lib => common}/shared/src/main/scala/special/collection/Extensions.scala (100%) rename {core-lib => common}/shared/src/main/scala/special/collection/Helpers.scala (100%) rename {core-lib => common}/shared/src/main/scala/special/collection/package.scala (100%) rename {core-lib => common}/shared/src/main/scala/special/sigma/SigmaDsl.scala (100%) rename {core-lib => common}/shared/src/main/scala/special/sigma/package.scala (100%) rename {core-lib => common}/shared/src/main/scala/special/wrappers/WrappersSpec.scala (100%) rename {core-lib => common}/shared/src/test/scala/special/TypesTests.scala (100%) rename {core-lib => common}/shared/src/test/scala/special/collections/CollGens.scala (100%) rename {core-lib => common}/shared/src/test/scala/special/collections/CollsTests.scala (100%) diff --git a/build.sbt b/build.sbt index 31d769e1e2..6317755a75 100644 --- a/build.sbt +++ b/build.sbt @@ -193,6 +193,7 @@ lazy val common = crossProject(JVMPlatform, JSPlatform) .settings(commonSettings ++ testSettings2, commonDependenies2, testingDependencies2, + scryptoDependency, publish / skip := true ) .jvmSettings( crossScalaSettings ) @@ -212,32 +213,32 @@ lazy val common = crossProject(JVMPlatform, JSPlatform) lazy val commonJS = common.js .enablePlugins(ScalaJSBundlerPlugin) -lazy val corelib = crossProject(JVMPlatform, JSPlatform) - .in(file("core-lib")) - .dependsOn(common % allConfigDependency) - .settings(commonSettings ++ testSettings2, - commonDependenies2, - testingDependencies2, - crossScalaSettings, - scryptoDependency, - publish / skip := true - ) - .jvmSettings( - crossScalaSettings - ) - .jsSettings( - crossScalaSettingsJS, - libraryDependencies ++= Seq( - "org.scala-js" %%% "scala-js-macrotask-executor" % "1.0.0" - ), - useYarn := true - ) -lazy val corelibJS = corelib.js - .enablePlugins(ScalaJSBundlerPlugin) +//lazy val corelib = crossProject(JVMPlatform, JSPlatform) +// .in(file("core-lib")) +// .dependsOn(common % allConfigDependency) +// .settings(commonSettings ++ testSettings2, +// commonDependenies2, +// testingDependencies2, +// crossScalaSettings, +// scryptoDependency, +// publish / skip := true +// ) +// .jvmSettings( +// crossScalaSettings +// ) +// .jsSettings( +// crossScalaSettingsJS, +// libraryDependencies ++= Seq( +// "org.scala-js" %%% "scala-js-macrotask-executor" % "1.0.0" +// ), +// useYarn := true +// ) +//lazy val corelibJS = corelib.js +// .enablePlugins(ScalaJSBundlerPlugin) lazy val graphir = crossProject(JVMPlatform, JSPlatform) .in(file("graph-ir")) - .dependsOn(common % allConfigDependency, corelib % allConfigDependency) + .dependsOn(common % allConfigDependency) .settings( commonDependenies2, scryptoDependency, @@ -256,7 +257,7 @@ lazy val graphirJS = graphir.js lazy val interpreter = crossProject(JVMPlatform, JSPlatform) .in(file("interpreter")) - .dependsOn(corelib % allConfigDependency) + .dependsOn(common % allConfigDependency) .settings( commonSettings ++ testSettings2, commonDependenies2, @@ -319,7 +320,7 @@ lazy val parsersJS = parsers.js lazy val sdk = crossProject(JVMPlatform, JSPlatform) .in(file("sdk")) - .dependsOn(corelib % allConfigDependency, interpreter % allConfigDependency, parsers % allConfigDependency) + .dependsOn(common % allConfigDependency, interpreter % allConfigDependency, parsers % allConfigDependency) .settings(commonSettings ++ testSettings2, commonDependenies2, testingDependencies2, @@ -396,13 +397,13 @@ lazy val scJS = sc.js lazy val sigma = (project in file(".")) - .aggregate(common.jvm, corelib.jvm, graphir.jvm, interpreter.jvm, parsers.jvm, sc.jvm, sdk.jvm) + .aggregate(common.jvm, graphir.jvm, interpreter.jvm, parsers.jvm, sc.jvm, sdk.jvm) .settings(libraryDefSettings, rootSettings) .settings(publish / aggregate := false) .settings(publishLocal / aggregate := false) lazy val aggregateCompile = ScopeFilter( - inProjects(common.jvm, corelib.jvm, graphir.jvm, interpreter.jvm, parsers.jvm, sc.jvm, sdk.jvm), + inProjects(common.jvm, graphir.jvm, interpreter.jvm, parsers.jvm, sc.jvm, sdk.jvm), inConfigurations(Compile)) lazy val rootSettings = Seq( diff --git a/core-lib/shared/src/main/scala/special/CoreLibReflection.scala b/common/shared/src/main/scala/special/CoreLibReflection.scala similarity index 100% rename from core-lib/shared/src/main/scala/special/CoreLibReflection.scala rename to common/shared/src/main/scala/special/CoreLibReflection.scala diff --git a/core-lib/shared/src/main/scala/special/Types.scala b/common/shared/src/main/scala/special/Types.scala similarity index 100% rename from core-lib/shared/src/main/scala/special/Types.scala rename to common/shared/src/main/scala/special/Types.scala diff --git a/core-lib/shared/src/main/scala/special/collection/Colls.scala b/common/shared/src/main/scala/special/collection/Colls.scala similarity index 100% rename from core-lib/shared/src/main/scala/special/collection/Colls.scala rename to common/shared/src/main/scala/special/collection/Colls.scala diff --git a/core-lib/shared/src/main/scala/special/collection/CollsOverArrays.scala b/common/shared/src/main/scala/special/collection/CollsOverArrays.scala similarity index 100% rename from core-lib/shared/src/main/scala/special/collection/CollsOverArrays.scala rename to common/shared/src/main/scala/special/collection/CollsOverArrays.scala diff --git a/core-lib/shared/src/main/scala/special/collection/Extensions.scala b/common/shared/src/main/scala/special/collection/Extensions.scala similarity index 100% rename from core-lib/shared/src/main/scala/special/collection/Extensions.scala rename to common/shared/src/main/scala/special/collection/Extensions.scala diff --git a/core-lib/shared/src/main/scala/special/collection/Helpers.scala b/common/shared/src/main/scala/special/collection/Helpers.scala similarity index 100% rename from core-lib/shared/src/main/scala/special/collection/Helpers.scala rename to common/shared/src/main/scala/special/collection/Helpers.scala diff --git a/core-lib/shared/src/main/scala/special/collection/package.scala b/common/shared/src/main/scala/special/collection/package.scala similarity index 100% rename from core-lib/shared/src/main/scala/special/collection/package.scala rename to common/shared/src/main/scala/special/collection/package.scala diff --git a/core-lib/shared/src/main/scala/special/sigma/SigmaDsl.scala b/common/shared/src/main/scala/special/sigma/SigmaDsl.scala similarity index 100% rename from core-lib/shared/src/main/scala/special/sigma/SigmaDsl.scala rename to common/shared/src/main/scala/special/sigma/SigmaDsl.scala diff --git a/core-lib/shared/src/main/scala/special/sigma/package.scala b/common/shared/src/main/scala/special/sigma/package.scala similarity index 100% rename from core-lib/shared/src/main/scala/special/sigma/package.scala rename to common/shared/src/main/scala/special/sigma/package.scala diff --git a/core-lib/shared/src/main/scala/special/wrappers/WrappersSpec.scala b/common/shared/src/main/scala/special/wrappers/WrappersSpec.scala similarity index 100% rename from core-lib/shared/src/main/scala/special/wrappers/WrappersSpec.scala rename to common/shared/src/main/scala/special/wrappers/WrappersSpec.scala diff --git a/core-lib/shared/src/test/scala/special/TypesTests.scala b/common/shared/src/test/scala/special/TypesTests.scala similarity index 100% rename from core-lib/shared/src/test/scala/special/TypesTests.scala rename to common/shared/src/test/scala/special/TypesTests.scala diff --git a/core-lib/shared/src/test/scala/special/collections/CollGens.scala b/common/shared/src/test/scala/special/collections/CollGens.scala similarity index 100% rename from core-lib/shared/src/test/scala/special/collections/CollGens.scala rename to common/shared/src/test/scala/special/collections/CollGens.scala diff --git a/core-lib/shared/src/test/scala/special/collections/CollsTests.scala b/common/shared/src/test/scala/special/collections/CollsTests.scala similarity index 100% rename from core-lib/shared/src/test/scala/special/collections/CollsTests.scala rename to common/shared/src/test/scala/special/collections/CollsTests.scala From 83c38cdf5fd033f68e36b5b3d4e2c71c2567c528 Mon Sep 17 00:00:00 2001 From: Alexander Slesarenko Date: Mon, 21 Aug 2023 23:59:42 +0200 Subject: [PATCH 02/37] minimize-modules: graphir module removed --- .github/workflows/ci.yml | 2 +- build.sbt | 48 ++----------------- .../js/src/test/scala/scalan/Platform.scala | 0 .../jvm/src/test/scala/scalan/Platform.scala | 0 .../scalan/compilation/GraphVizExport.scala | 0 .../special/collections/BasicBenchmarks.scala | 0 .../special/collections/BenchmarkGens.scala | 0 .../special/collections/BufferBenchmark.scala | 0 .../special/collections/CollBenchmark.scala | 0 .../special/collections/MapBenchmark.scala | 0 .../special/collections/SymBenchmark.scala | 0 .../shared/src/main/resources/reference.conf | 0 .../shared/src/main/scala/scalan/Base.scala | 0 .../src/main/scala/scalan/DefRewriting.scala | 0 .../src/main/scala/scalan/Entities.scala | 0 .../src/main/scala/scalan/Exceptions.scala | 0 .../main/scala/scalan/GraphIRReflection.scala | 0 .../src/main/scala/scalan/Library.scala | 0 .../src/main/scala/scalan/MethodCalls.scala | 0 .../src/main/scala/scalan/ModuleInfo.scala | 0 .../src/main/scala/scalan/Modules.scala | 0 .../src/main/scala/scalan/MutableLazy.scala | 0 .../shared/src/main/scala/scalan/Scalan.scala | 0 .../src/main/scala/scalan/SigmaLibrary.scala | 0 .../src/main/scala/scalan/TypeDescs.scala | 0 .../src/main/scala/scalan/meta/SSymName.scala | 0 .../main/scala/scalan/primitives/Equal.scala | 0 .../scala/scalan/primitives/Functions.scala | 0 .../scala/scalan/primitives/IfThenElse.scala | 0 .../scala/scalan/primitives/LogicalOps.scala | 0 .../scala/scalan/primitives/NumericOps.scala | 0 .../scala/scalan/primitives/OrderingOps.scala | 0 .../main/scala/scalan/primitives/Thunks.scala | 0 .../main/scala/scalan/primitives/Tuples.scala | 0 .../scala/scalan/primitives/UnBinOps.scala | 0 .../scalan/primitives/UniversalOps.scala | 0 .../main/scala/scalan/staged/AstGraphs.scala | 0 .../scala/scalan/staged/ProgramGraphs.scala | 0 .../scala/scalan/staged/Transforming.scala | 0 .../src/main/scala/scalan/util/Variance.scala | 0 .../scala/special/collection/CollsUnit.scala | 0 .../special/collection/impl/CollsImpl.scala | 0 .../scala/special/sigma/SigmaDslUnit.scala | 0 .../special/sigma/impl/SigmaDslImpl.scala | 0 .../sigma/wrappers/WrappersModule.scala | 0 .../special/wrappers/WrappersModule.scala | 0 .../main/scala/wrappers/scala/WOptions.scala | 0 .../wrappers/scala/impl/WOptionsImpl.scala | 0 .../main/scala/wrappers/scalan/WRTypes.scala | 0 .../wrappers/scalan/impl/WRTypesImpl.scala | 0 .../wrappers/special/WSpecialPredefs.scala | 0 .../special/impl/WSpecialPredefsImpl.scala | 0 .../test/scala/scalan/BaseLiftableTests.scala | 0 .../src/test/scala/scalan/LibraryTests.scala | 0 .../src/test/scala/scalan/TestContexts.scala | 0 .../src/test/scala/scalan/TestLibrary.scala | 0 .../scala/scalan/util/ScalaNameUtil.scala | 0 .../scalan/util/ScalaNameUtilSuite.scala | 0 .../collections/CollsStagingTests.scala | 0 .../scala/special/wrappers/WOptionTests.scala | 0 .../scala/special/wrappers/WRTypeTests.scala | 0 .../wrappers/WSpecialPredefTests.scala | 0 .../special/wrappers/WrappersTests.scala | 0 63 files changed, 4 insertions(+), 46 deletions(-) rename {graph-ir => sc}/js/src/test/scala/scalan/Platform.scala (100%) rename {graph-ir => sc}/jvm/src/test/scala/scalan/Platform.scala (100%) rename {graph-ir => sc}/jvm/src/test/scala/scalan/compilation/GraphVizExport.scala (100%) rename {graph-ir => sc}/jvm/src/test/scala/special/collections/BasicBenchmarks.scala (100%) rename {graph-ir => sc}/jvm/src/test/scala/special/collections/BenchmarkGens.scala (100%) rename {graph-ir => sc}/jvm/src/test/scala/special/collections/BufferBenchmark.scala (100%) rename {graph-ir => sc}/jvm/src/test/scala/special/collections/CollBenchmark.scala (100%) rename {graph-ir => sc}/jvm/src/test/scala/special/collections/MapBenchmark.scala (100%) rename {graph-ir => sc}/jvm/src/test/scala/special/collections/SymBenchmark.scala (100%) rename {graph-ir => sc}/shared/src/main/resources/reference.conf (100%) rename {graph-ir => sc}/shared/src/main/scala/scalan/Base.scala (100%) rename {graph-ir => sc}/shared/src/main/scala/scalan/DefRewriting.scala (100%) rename {graph-ir => sc}/shared/src/main/scala/scalan/Entities.scala (100%) rename {graph-ir => sc}/shared/src/main/scala/scalan/Exceptions.scala (100%) rename {graph-ir => sc}/shared/src/main/scala/scalan/GraphIRReflection.scala (100%) rename {graph-ir => sc}/shared/src/main/scala/scalan/Library.scala (100%) rename {graph-ir => sc}/shared/src/main/scala/scalan/MethodCalls.scala (100%) rename {graph-ir => sc}/shared/src/main/scala/scalan/ModuleInfo.scala (100%) rename {graph-ir => sc}/shared/src/main/scala/scalan/Modules.scala (100%) rename {graph-ir => sc}/shared/src/main/scala/scalan/MutableLazy.scala (100%) rename {graph-ir => sc}/shared/src/main/scala/scalan/Scalan.scala (100%) rename {graph-ir => sc}/shared/src/main/scala/scalan/SigmaLibrary.scala (100%) rename {graph-ir => sc}/shared/src/main/scala/scalan/TypeDescs.scala (100%) rename {graph-ir => sc}/shared/src/main/scala/scalan/meta/SSymName.scala (100%) rename {graph-ir => sc}/shared/src/main/scala/scalan/primitives/Equal.scala (100%) rename {graph-ir => sc}/shared/src/main/scala/scalan/primitives/Functions.scala (100%) rename {graph-ir => sc}/shared/src/main/scala/scalan/primitives/IfThenElse.scala (100%) rename {graph-ir => sc}/shared/src/main/scala/scalan/primitives/LogicalOps.scala (100%) rename {graph-ir => sc}/shared/src/main/scala/scalan/primitives/NumericOps.scala (100%) rename {graph-ir => sc}/shared/src/main/scala/scalan/primitives/OrderingOps.scala (100%) rename {graph-ir => sc}/shared/src/main/scala/scalan/primitives/Thunks.scala (100%) rename {graph-ir => sc}/shared/src/main/scala/scalan/primitives/Tuples.scala (100%) rename {graph-ir => sc}/shared/src/main/scala/scalan/primitives/UnBinOps.scala (100%) rename {graph-ir => sc}/shared/src/main/scala/scalan/primitives/UniversalOps.scala (100%) rename {graph-ir => sc}/shared/src/main/scala/scalan/staged/AstGraphs.scala (100%) rename {graph-ir => sc}/shared/src/main/scala/scalan/staged/ProgramGraphs.scala (100%) rename {graph-ir => sc}/shared/src/main/scala/scalan/staged/Transforming.scala (100%) rename {graph-ir => sc}/shared/src/main/scala/scalan/util/Variance.scala (100%) rename {graph-ir => sc}/shared/src/main/scala/special/collection/CollsUnit.scala (100%) rename {graph-ir => sc}/shared/src/main/scala/special/collection/impl/CollsImpl.scala (100%) rename {graph-ir => sc}/shared/src/main/scala/special/sigma/SigmaDslUnit.scala (100%) rename {graph-ir => sc}/shared/src/main/scala/special/sigma/impl/SigmaDslImpl.scala (100%) rename {graph-ir => sc}/shared/src/main/scala/special/sigma/wrappers/WrappersModule.scala (100%) rename {graph-ir => sc}/shared/src/main/scala/special/wrappers/WrappersModule.scala (100%) rename {graph-ir => sc}/shared/src/main/scala/wrappers/scala/WOptions.scala (100%) rename {graph-ir => sc}/shared/src/main/scala/wrappers/scala/impl/WOptionsImpl.scala (100%) rename {graph-ir => sc}/shared/src/main/scala/wrappers/scalan/WRTypes.scala (100%) rename {graph-ir => sc}/shared/src/main/scala/wrappers/scalan/impl/WRTypesImpl.scala (100%) rename {graph-ir => sc}/shared/src/main/scala/wrappers/special/WSpecialPredefs.scala (100%) rename {graph-ir => sc}/shared/src/main/scala/wrappers/special/impl/WSpecialPredefsImpl.scala (100%) rename {graph-ir => sc}/shared/src/test/scala/scalan/BaseLiftableTests.scala (100%) rename {graph-ir => sc}/shared/src/test/scala/scalan/LibraryTests.scala (100%) rename {graph-ir => sc}/shared/src/test/scala/scalan/TestContexts.scala (100%) rename {graph-ir => sc}/shared/src/test/scala/scalan/TestLibrary.scala (100%) rename {graph-ir => sc}/shared/src/test/scala/scalan/util/ScalaNameUtil.scala (100%) rename {graph-ir => sc}/shared/src/test/scala/scalan/util/ScalaNameUtilSuite.scala (100%) rename {graph-ir => sc}/shared/src/test/scala/special/collections/CollsStagingTests.scala (100%) rename {graph-ir => sc}/shared/src/test/scala/special/wrappers/WOptionTests.scala (100%) rename {graph-ir => sc}/shared/src/test/scala/special/wrappers/WRTypeTests.scala (100%) rename {graph-ir => sc}/shared/src/test/scala/special/wrappers/WSpecialPredefTests.scala (100%) rename {graph-ir => sc}/shared/src/test/scala/special/wrappers/WrappersTests.scala (100%) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index db3427969c..b828c8a34f 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -103,7 +103,7 @@ jobs: key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }} - name: Runs tests and collect coverage - run: sbt -jvm-opts ci/ci.jvmopts ++${{ matrix.scala }} commonJS/test corelibJS/test interpreterJS/test graphirJS/test sdkJS/test scJS/test + run: sbt -jvm-opts ci/ci.jvmopts ++${{ matrix.scala }} commonJS/test interpreterJS/test parsersJS/test sdkJS/test scJS/test - name: Publish a JVM snapshot ${{ github.ref }} if: env.HAS_SECRETS == 'true' diff --git a/build.sbt b/build.sbt index 6317755a75..9474790e54 100644 --- a/build.sbt +++ b/build.sbt @@ -213,48 +213,6 @@ lazy val common = crossProject(JVMPlatform, JSPlatform) lazy val commonJS = common.js .enablePlugins(ScalaJSBundlerPlugin) -//lazy val corelib = crossProject(JVMPlatform, JSPlatform) -// .in(file("core-lib")) -// .dependsOn(common % allConfigDependency) -// .settings(commonSettings ++ testSettings2, -// commonDependenies2, -// testingDependencies2, -// crossScalaSettings, -// scryptoDependency, -// publish / skip := true -// ) -// .jvmSettings( -// crossScalaSettings -// ) -// .jsSettings( -// crossScalaSettingsJS, -// libraryDependencies ++= Seq( -// "org.scala-js" %%% "scala-js-macrotask-executor" % "1.0.0" -// ), -// useYarn := true -// ) -//lazy val corelibJS = corelib.js -// .enablePlugins(ScalaJSBundlerPlugin) - -lazy val graphir = crossProject(JVMPlatform, JSPlatform) - .in(file("graph-ir")) - .dependsOn(common % allConfigDependency) - .settings( - commonDependenies2, - scryptoDependency, - publish / skip := true - ) - .jvmSettings( - crossScalaSettings, - libraryDependencies ++= Seq(scalameter) - ) - .jsSettings( - crossScalaSettingsJS, - useYarn := true - ) -lazy val graphirJS = graphir.js - .enablePlugins(ScalaJSBundlerPlugin) - lazy val interpreter = crossProject(JVMPlatform, JSPlatform) .in(file("interpreter")) .dependsOn(common % allConfigDependency) @@ -352,7 +310,6 @@ lazy val sdkJS = sdk.js lazy val sc = crossProject(JVMPlatform, JSPlatform) .in(file("sc")) .dependsOn( - graphir % allConfigDependency, interpreter % allConfigDependency, parsers % allConfigDependency, sdk % allConfigDependency @@ -362,6 +319,7 @@ lazy val sc = crossProject(JVMPlatform, JSPlatform) commonDependenies2, testingDependencies2, scorexUtilDependency, fastparseDependency, circeDependency, + scryptoDependency, Test / parallelExecution := false ) .settings(publish / skip := true) @@ -397,13 +355,13 @@ lazy val scJS = sc.js lazy val sigma = (project in file(".")) - .aggregate(common.jvm, graphir.jvm, interpreter.jvm, parsers.jvm, sc.jvm, sdk.jvm) + .aggregate(common.jvm, interpreter.jvm, parsers.jvm, sdk.jvm, sc.jvm) .settings(libraryDefSettings, rootSettings) .settings(publish / aggregate := false) .settings(publishLocal / aggregate := false) lazy val aggregateCompile = ScopeFilter( - inProjects(common.jvm, graphir.jvm, interpreter.jvm, parsers.jvm, sc.jvm, sdk.jvm), + inProjects(common.jvm, interpreter.jvm, parsers.jvm, sdk.jvm, sc.jvm), inConfigurations(Compile)) lazy val rootSettings = Seq( diff --git a/graph-ir/js/src/test/scala/scalan/Platform.scala b/sc/js/src/test/scala/scalan/Platform.scala similarity index 100% rename from graph-ir/js/src/test/scala/scalan/Platform.scala rename to sc/js/src/test/scala/scalan/Platform.scala diff --git a/graph-ir/jvm/src/test/scala/scalan/Platform.scala b/sc/jvm/src/test/scala/scalan/Platform.scala similarity index 100% rename from graph-ir/jvm/src/test/scala/scalan/Platform.scala rename to sc/jvm/src/test/scala/scalan/Platform.scala diff --git a/graph-ir/jvm/src/test/scala/scalan/compilation/GraphVizExport.scala b/sc/jvm/src/test/scala/scalan/compilation/GraphVizExport.scala similarity index 100% rename from graph-ir/jvm/src/test/scala/scalan/compilation/GraphVizExport.scala rename to sc/jvm/src/test/scala/scalan/compilation/GraphVizExport.scala diff --git a/graph-ir/jvm/src/test/scala/special/collections/BasicBenchmarks.scala b/sc/jvm/src/test/scala/special/collections/BasicBenchmarks.scala similarity index 100% rename from graph-ir/jvm/src/test/scala/special/collections/BasicBenchmarks.scala rename to sc/jvm/src/test/scala/special/collections/BasicBenchmarks.scala diff --git a/graph-ir/jvm/src/test/scala/special/collections/BenchmarkGens.scala b/sc/jvm/src/test/scala/special/collections/BenchmarkGens.scala similarity index 100% rename from graph-ir/jvm/src/test/scala/special/collections/BenchmarkGens.scala rename to sc/jvm/src/test/scala/special/collections/BenchmarkGens.scala diff --git a/graph-ir/jvm/src/test/scala/special/collections/BufferBenchmark.scala b/sc/jvm/src/test/scala/special/collections/BufferBenchmark.scala similarity index 100% rename from graph-ir/jvm/src/test/scala/special/collections/BufferBenchmark.scala rename to sc/jvm/src/test/scala/special/collections/BufferBenchmark.scala diff --git a/graph-ir/jvm/src/test/scala/special/collections/CollBenchmark.scala b/sc/jvm/src/test/scala/special/collections/CollBenchmark.scala similarity index 100% rename from graph-ir/jvm/src/test/scala/special/collections/CollBenchmark.scala rename to sc/jvm/src/test/scala/special/collections/CollBenchmark.scala diff --git a/graph-ir/jvm/src/test/scala/special/collections/MapBenchmark.scala b/sc/jvm/src/test/scala/special/collections/MapBenchmark.scala similarity index 100% rename from graph-ir/jvm/src/test/scala/special/collections/MapBenchmark.scala rename to sc/jvm/src/test/scala/special/collections/MapBenchmark.scala diff --git a/graph-ir/jvm/src/test/scala/special/collections/SymBenchmark.scala b/sc/jvm/src/test/scala/special/collections/SymBenchmark.scala similarity index 100% rename from graph-ir/jvm/src/test/scala/special/collections/SymBenchmark.scala rename to sc/jvm/src/test/scala/special/collections/SymBenchmark.scala diff --git a/graph-ir/shared/src/main/resources/reference.conf b/sc/shared/src/main/resources/reference.conf similarity index 100% rename from graph-ir/shared/src/main/resources/reference.conf rename to sc/shared/src/main/resources/reference.conf diff --git a/graph-ir/shared/src/main/scala/scalan/Base.scala b/sc/shared/src/main/scala/scalan/Base.scala similarity index 100% rename from graph-ir/shared/src/main/scala/scalan/Base.scala rename to sc/shared/src/main/scala/scalan/Base.scala diff --git a/graph-ir/shared/src/main/scala/scalan/DefRewriting.scala b/sc/shared/src/main/scala/scalan/DefRewriting.scala similarity index 100% rename from graph-ir/shared/src/main/scala/scalan/DefRewriting.scala rename to sc/shared/src/main/scala/scalan/DefRewriting.scala diff --git a/graph-ir/shared/src/main/scala/scalan/Entities.scala b/sc/shared/src/main/scala/scalan/Entities.scala similarity index 100% rename from graph-ir/shared/src/main/scala/scalan/Entities.scala rename to sc/shared/src/main/scala/scalan/Entities.scala diff --git a/graph-ir/shared/src/main/scala/scalan/Exceptions.scala b/sc/shared/src/main/scala/scalan/Exceptions.scala similarity index 100% rename from graph-ir/shared/src/main/scala/scalan/Exceptions.scala rename to sc/shared/src/main/scala/scalan/Exceptions.scala diff --git a/graph-ir/shared/src/main/scala/scalan/GraphIRReflection.scala b/sc/shared/src/main/scala/scalan/GraphIRReflection.scala similarity index 100% rename from graph-ir/shared/src/main/scala/scalan/GraphIRReflection.scala rename to sc/shared/src/main/scala/scalan/GraphIRReflection.scala diff --git a/graph-ir/shared/src/main/scala/scalan/Library.scala b/sc/shared/src/main/scala/scalan/Library.scala similarity index 100% rename from graph-ir/shared/src/main/scala/scalan/Library.scala rename to sc/shared/src/main/scala/scalan/Library.scala diff --git a/graph-ir/shared/src/main/scala/scalan/MethodCalls.scala b/sc/shared/src/main/scala/scalan/MethodCalls.scala similarity index 100% rename from graph-ir/shared/src/main/scala/scalan/MethodCalls.scala rename to sc/shared/src/main/scala/scalan/MethodCalls.scala diff --git a/graph-ir/shared/src/main/scala/scalan/ModuleInfo.scala b/sc/shared/src/main/scala/scalan/ModuleInfo.scala similarity index 100% rename from graph-ir/shared/src/main/scala/scalan/ModuleInfo.scala rename to sc/shared/src/main/scala/scalan/ModuleInfo.scala diff --git a/graph-ir/shared/src/main/scala/scalan/Modules.scala b/sc/shared/src/main/scala/scalan/Modules.scala similarity index 100% rename from graph-ir/shared/src/main/scala/scalan/Modules.scala rename to sc/shared/src/main/scala/scalan/Modules.scala diff --git a/graph-ir/shared/src/main/scala/scalan/MutableLazy.scala b/sc/shared/src/main/scala/scalan/MutableLazy.scala similarity index 100% rename from graph-ir/shared/src/main/scala/scalan/MutableLazy.scala rename to sc/shared/src/main/scala/scalan/MutableLazy.scala diff --git a/graph-ir/shared/src/main/scala/scalan/Scalan.scala b/sc/shared/src/main/scala/scalan/Scalan.scala similarity index 100% rename from graph-ir/shared/src/main/scala/scalan/Scalan.scala rename to sc/shared/src/main/scala/scalan/Scalan.scala diff --git a/graph-ir/shared/src/main/scala/scalan/SigmaLibrary.scala b/sc/shared/src/main/scala/scalan/SigmaLibrary.scala similarity index 100% rename from graph-ir/shared/src/main/scala/scalan/SigmaLibrary.scala rename to sc/shared/src/main/scala/scalan/SigmaLibrary.scala diff --git a/graph-ir/shared/src/main/scala/scalan/TypeDescs.scala b/sc/shared/src/main/scala/scalan/TypeDescs.scala similarity index 100% rename from graph-ir/shared/src/main/scala/scalan/TypeDescs.scala rename to sc/shared/src/main/scala/scalan/TypeDescs.scala diff --git a/graph-ir/shared/src/main/scala/scalan/meta/SSymName.scala b/sc/shared/src/main/scala/scalan/meta/SSymName.scala similarity index 100% rename from graph-ir/shared/src/main/scala/scalan/meta/SSymName.scala rename to sc/shared/src/main/scala/scalan/meta/SSymName.scala diff --git a/graph-ir/shared/src/main/scala/scalan/primitives/Equal.scala b/sc/shared/src/main/scala/scalan/primitives/Equal.scala similarity index 100% rename from graph-ir/shared/src/main/scala/scalan/primitives/Equal.scala rename to sc/shared/src/main/scala/scalan/primitives/Equal.scala diff --git a/graph-ir/shared/src/main/scala/scalan/primitives/Functions.scala b/sc/shared/src/main/scala/scalan/primitives/Functions.scala similarity index 100% rename from graph-ir/shared/src/main/scala/scalan/primitives/Functions.scala rename to sc/shared/src/main/scala/scalan/primitives/Functions.scala diff --git a/graph-ir/shared/src/main/scala/scalan/primitives/IfThenElse.scala b/sc/shared/src/main/scala/scalan/primitives/IfThenElse.scala similarity index 100% rename from graph-ir/shared/src/main/scala/scalan/primitives/IfThenElse.scala rename to sc/shared/src/main/scala/scalan/primitives/IfThenElse.scala diff --git a/graph-ir/shared/src/main/scala/scalan/primitives/LogicalOps.scala b/sc/shared/src/main/scala/scalan/primitives/LogicalOps.scala similarity index 100% rename from graph-ir/shared/src/main/scala/scalan/primitives/LogicalOps.scala rename to sc/shared/src/main/scala/scalan/primitives/LogicalOps.scala diff --git a/graph-ir/shared/src/main/scala/scalan/primitives/NumericOps.scala b/sc/shared/src/main/scala/scalan/primitives/NumericOps.scala similarity index 100% rename from graph-ir/shared/src/main/scala/scalan/primitives/NumericOps.scala rename to sc/shared/src/main/scala/scalan/primitives/NumericOps.scala diff --git a/graph-ir/shared/src/main/scala/scalan/primitives/OrderingOps.scala b/sc/shared/src/main/scala/scalan/primitives/OrderingOps.scala similarity index 100% rename from graph-ir/shared/src/main/scala/scalan/primitives/OrderingOps.scala rename to sc/shared/src/main/scala/scalan/primitives/OrderingOps.scala diff --git a/graph-ir/shared/src/main/scala/scalan/primitives/Thunks.scala b/sc/shared/src/main/scala/scalan/primitives/Thunks.scala similarity index 100% rename from graph-ir/shared/src/main/scala/scalan/primitives/Thunks.scala rename to sc/shared/src/main/scala/scalan/primitives/Thunks.scala diff --git a/graph-ir/shared/src/main/scala/scalan/primitives/Tuples.scala b/sc/shared/src/main/scala/scalan/primitives/Tuples.scala similarity index 100% rename from graph-ir/shared/src/main/scala/scalan/primitives/Tuples.scala rename to sc/shared/src/main/scala/scalan/primitives/Tuples.scala diff --git a/graph-ir/shared/src/main/scala/scalan/primitives/UnBinOps.scala b/sc/shared/src/main/scala/scalan/primitives/UnBinOps.scala similarity index 100% rename from graph-ir/shared/src/main/scala/scalan/primitives/UnBinOps.scala rename to sc/shared/src/main/scala/scalan/primitives/UnBinOps.scala diff --git a/graph-ir/shared/src/main/scala/scalan/primitives/UniversalOps.scala b/sc/shared/src/main/scala/scalan/primitives/UniversalOps.scala similarity index 100% rename from graph-ir/shared/src/main/scala/scalan/primitives/UniversalOps.scala rename to sc/shared/src/main/scala/scalan/primitives/UniversalOps.scala diff --git a/graph-ir/shared/src/main/scala/scalan/staged/AstGraphs.scala b/sc/shared/src/main/scala/scalan/staged/AstGraphs.scala similarity index 100% rename from graph-ir/shared/src/main/scala/scalan/staged/AstGraphs.scala rename to sc/shared/src/main/scala/scalan/staged/AstGraphs.scala diff --git a/graph-ir/shared/src/main/scala/scalan/staged/ProgramGraphs.scala b/sc/shared/src/main/scala/scalan/staged/ProgramGraphs.scala similarity index 100% rename from graph-ir/shared/src/main/scala/scalan/staged/ProgramGraphs.scala rename to sc/shared/src/main/scala/scalan/staged/ProgramGraphs.scala diff --git a/graph-ir/shared/src/main/scala/scalan/staged/Transforming.scala b/sc/shared/src/main/scala/scalan/staged/Transforming.scala similarity index 100% rename from graph-ir/shared/src/main/scala/scalan/staged/Transforming.scala rename to sc/shared/src/main/scala/scalan/staged/Transforming.scala diff --git a/graph-ir/shared/src/main/scala/scalan/util/Variance.scala b/sc/shared/src/main/scala/scalan/util/Variance.scala similarity index 100% rename from graph-ir/shared/src/main/scala/scalan/util/Variance.scala rename to sc/shared/src/main/scala/scalan/util/Variance.scala diff --git a/graph-ir/shared/src/main/scala/special/collection/CollsUnit.scala b/sc/shared/src/main/scala/special/collection/CollsUnit.scala similarity index 100% rename from graph-ir/shared/src/main/scala/special/collection/CollsUnit.scala rename to sc/shared/src/main/scala/special/collection/CollsUnit.scala diff --git a/graph-ir/shared/src/main/scala/special/collection/impl/CollsImpl.scala b/sc/shared/src/main/scala/special/collection/impl/CollsImpl.scala similarity index 100% rename from graph-ir/shared/src/main/scala/special/collection/impl/CollsImpl.scala rename to sc/shared/src/main/scala/special/collection/impl/CollsImpl.scala diff --git a/graph-ir/shared/src/main/scala/special/sigma/SigmaDslUnit.scala b/sc/shared/src/main/scala/special/sigma/SigmaDslUnit.scala similarity index 100% rename from graph-ir/shared/src/main/scala/special/sigma/SigmaDslUnit.scala rename to sc/shared/src/main/scala/special/sigma/SigmaDslUnit.scala diff --git a/graph-ir/shared/src/main/scala/special/sigma/impl/SigmaDslImpl.scala b/sc/shared/src/main/scala/special/sigma/impl/SigmaDslImpl.scala similarity index 100% rename from graph-ir/shared/src/main/scala/special/sigma/impl/SigmaDslImpl.scala rename to sc/shared/src/main/scala/special/sigma/impl/SigmaDslImpl.scala diff --git a/graph-ir/shared/src/main/scala/special/sigma/wrappers/WrappersModule.scala b/sc/shared/src/main/scala/special/sigma/wrappers/WrappersModule.scala similarity index 100% rename from graph-ir/shared/src/main/scala/special/sigma/wrappers/WrappersModule.scala rename to sc/shared/src/main/scala/special/sigma/wrappers/WrappersModule.scala diff --git a/graph-ir/shared/src/main/scala/special/wrappers/WrappersModule.scala b/sc/shared/src/main/scala/special/wrappers/WrappersModule.scala similarity index 100% rename from graph-ir/shared/src/main/scala/special/wrappers/WrappersModule.scala rename to sc/shared/src/main/scala/special/wrappers/WrappersModule.scala diff --git a/graph-ir/shared/src/main/scala/wrappers/scala/WOptions.scala b/sc/shared/src/main/scala/wrappers/scala/WOptions.scala similarity index 100% rename from graph-ir/shared/src/main/scala/wrappers/scala/WOptions.scala rename to sc/shared/src/main/scala/wrappers/scala/WOptions.scala diff --git a/graph-ir/shared/src/main/scala/wrappers/scala/impl/WOptionsImpl.scala b/sc/shared/src/main/scala/wrappers/scala/impl/WOptionsImpl.scala similarity index 100% rename from graph-ir/shared/src/main/scala/wrappers/scala/impl/WOptionsImpl.scala rename to sc/shared/src/main/scala/wrappers/scala/impl/WOptionsImpl.scala diff --git a/graph-ir/shared/src/main/scala/wrappers/scalan/WRTypes.scala b/sc/shared/src/main/scala/wrappers/scalan/WRTypes.scala similarity index 100% rename from graph-ir/shared/src/main/scala/wrappers/scalan/WRTypes.scala rename to sc/shared/src/main/scala/wrappers/scalan/WRTypes.scala diff --git a/graph-ir/shared/src/main/scala/wrappers/scalan/impl/WRTypesImpl.scala b/sc/shared/src/main/scala/wrappers/scalan/impl/WRTypesImpl.scala similarity index 100% rename from graph-ir/shared/src/main/scala/wrappers/scalan/impl/WRTypesImpl.scala rename to sc/shared/src/main/scala/wrappers/scalan/impl/WRTypesImpl.scala diff --git a/graph-ir/shared/src/main/scala/wrappers/special/WSpecialPredefs.scala b/sc/shared/src/main/scala/wrappers/special/WSpecialPredefs.scala similarity index 100% rename from graph-ir/shared/src/main/scala/wrappers/special/WSpecialPredefs.scala rename to sc/shared/src/main/scala/wrappers/special/WSpecialPredefs.scala diff --git a/graph-ir/shared/src/main/scala/wrappers/special/impl/WSpecialPredefsImpl.scala b/sc/shared/src/main/scala/wrappers/special/impl/WSpecialPredefsImpl.scala similarity index 100% rename from graph-ir/shared/src/main/scala/wrappers/special/impl/WSpecialPredefsImpl.scala rename to sc/shared/src/main/scala/wrappers/special/impl/WSpecialPredefsImpl.scala diff --git a/graph-ir/shared/src/test/scala/scalan/BaseLiftableTests.scala b/sc/shared/src/test/scala/scalan/BaseLiftableTests.scala similarity index 100% rename from graph-ir/shared/src/test/scala/scalan/BaseLiftableTests.scala rename to sc/shared/src/test/scala/scalan/BaseLiftableTests.scala diff --git a/graph-ir/shared/src/test/scala/scalan/LibraryTests.scala b/sc/shared/src/test/scala/scalan/LibraryTests.scala similarity index 100% rename from graph-ir/shared/src/test/scala/scalan/LibraryTests.scala rename to sc/shared/src/test/scala/scalan/LibraryTests.scala diff --git a/graph-ir/shared/src/test/scala/scalan/TestContexts.scala b/sc/shared/src/test/scala/scalan/TestContexts.scala similarity index 100% rename from graph-ir/shared/src/test/scala/scalan/TestContexts.scala rename to sc/shared/src/test/scala/scalan/TestContexts.scala diff --git a/graph-ir/shared/src/test/scala/scalan/TestLibrary.scala b/sc/shared/src/test/scala/scalan/TestLibrary.scala similarity index 100% rename from graph-ir/shared/src/test/scala/scalan/TestLibrary.scala rename to sc/shared/src/test/scala/scalan/TestLibrary.scala diff --git a/graph-ir/shared/src/test/scala/scalan/util/ScalaNameUtil.scala b/sc/shared/src/test/scala/scalan/util/ScalaNameUtil.scala similarity index 100% rename from graph-ir/shared/src/test/scala/scalan/util/ScalaNameUtil.scala rename to sc/shared/src/test/scala/scalan/util/ScalaNameUtil.scala diff --git a/graph-ir/shared/src/test/scala/scalan/util/ScalaNameUtilSuite.scala b/sc/shared/src/test/scala/scalan/util/ScalaNameUtilSuite.scala similarity index 100% rename from graph-ir/shared/src/test/scala/scalan/util/ScalaNameUtilSuite.scala rename to sc/shared/src/test/scala/scalan/util/ScalaNameUtilSuite.scala diff --git a/graph-ir/shared/src/test/scala/special/collections/CollsStagingTests.scala b/sc/shared/src/test/scala/special/collections/CollsStagingTests.scala similarity index 100% rename from graph-ir/shared/src/test/scala/special/collections/CollsStagingTests.scala rename to sc/shared/src/test/scala/special/collections/CollsStagingTests.scala diff --git a/graph-ir/shared/src/test/scala/special/wrappers/WOptionTests.scala b/sc/shared/src/test/scala/special/wrappers/WOptionTests.scala similarity index 100% rename from graph-ir/shared/src/test/scala/special/wrappers/WOptionTests.scala rename to sc/shared/src/test/scala/special/wrappers/WOptionTests.scala diff --git a/graph-ir/shared/src/test/scala/special/wrappers/WRTypeTests.scala b/sc/shared/src/test/scala/special/wrappers/WRTypeTests.scala similarity index 100% rename from graph-ir/shared/src/test/scala/special/wrappers/WRTypeTests.scala rename to sc/shared/src/test/scala/special/wrappers/WRTypeTests.scala diff --git a/graph-ir/shared/src/test/scala/special/wrappers/WSpecialPredefTests.scala b/sc/shared/src/test/scala/special/wrappers/WSpecialPredefTests.scala similarity index 100% rename from graph-ir/shared/src/test/scala/special/wrappers/WSpecialPredefTests.scala rename to sc/shared/src/test/scala/special/wrappers/WSpecialPredefTests.scala diff --git a/graph-ir/shared/src/test/scala/special/wrappers/WrappersTests.scala b/sc/shared/src/test/scala/special/wrappers/WrappersTests.scala similarity index 100% rename from graph-ir/shared/src/test/scala/special/wrappers/WrappersTests.scala rename to sc/shared/src/test/scala/special/wrappers/WrappersTests.scala From cbbd0f324f73fcb244afa2cde56eab4670a141b0 Mon Sep 17 00:00:00 2001 From: Alexander Slesarenko Date: Tue, 22 Aug 2023 13:08:34 +0200 Subject: [PATCH 03/37] minimize-modules: move code around --- .../scala/scalan/reflection/JavaImpl.scala | 3 --- .../scalan/{TypeDesc.scala => RType.scala} | 0 .../scala/special/collection/CollType.scala | 11 +++++++++++ .../special/collection/CollsOverArrays.scala | 3 +-- .../scala/special/collection/Helpers.scala | 11 ----------- .../scala/special/collection/package.scala | 19 +++++++++---------- .../main/scala/special/sigma/SigmaDsl.scala | 2 +- .../main/scala/scalan/GraphIRReflection.scala | 3 ++- .../scala/sigmastate/eval/GraphBuilding.scala | 2 +- .../eval}/SigmaLibrary.scala | 3 ++- .../scala/sigmastate/eval/TreeBuilding.scala | 1 - .../scala/special/sigma/SigmaDslUnit.scala | 1 + .../special/sigma/impl/SigmaDslImpl.scala | 9 +++++---- 13 files changed, 33 insertions(+), 35 deletions(-) rename common/shared/src/main/scala/scalan/{TypeDesc.scala => RType.scala} (100%) create mode 100644 common/shared/src/main/scala/special/collection/CollType.scala delete mode 100644 common/shared/src/main/scala/special/collection/Helpers.scala rename sc/shared/src/main/scala/{scalan => sigmastate/eval}/SigmaLibrary.scala (90%) diff --git a/common/jvm/src/main/scala/scalan/reflection/JavaImpl.scala b/common/jvm/src/main/scala/scalan/reflection/JavaImpl.scala index fba9fcd29c..75c46ae352 100644 --- a/common/jvm/src/main/scala/scalan/reflection/JavaImpl.scala +++ b/common/jvm/src/main/scala/scalan/reflection/JavaImpl.scala @@ -134,9 +134,6 @@ object JRConstructor { */ class JRMethod private (val value: Method) extends RMethod { override def invoke(obj: Any, args: AnyRef*): AnyRef = { -// val name = value.getName -// val parameterTypes: Seq[Class[_]] = value.getParameterTypes -// memoize(declaringClass.methods)((name, parameterTypes), this) value.invoke(obj, args:_*) } diff --git a/common/shared/src/main/scala/scalan/TypeDesc.scala b/common/shared/src/main/scala/scalan/RType.scala similarity index 100% rename from common/shared/src/main/scala/scalan/TypeDesc.scala rename to common/shared/src/main/scala/scalan/RType.scala diff --git a/common/shared/src/main/scala/special/collection/CollType.scala b/common/shared/src/main/scala/special/collection/CollType.scala new file mode 100644 index 0000000000..bb14366c0b --- /dev/null +++ b/common/shared/src/main/scala/special/collection/CollType.scala @@ -0,0 +1,11 @@ +package special.collection + +import scalan.RType +import scala.reflect.ClassTag + +/** Type descriptor for `Coll[A]` type. */ +case class CollType[A](tItem: RType[A]) extends RType[Coll[A]] { + override val classTag: ClassTag[Coll[A]] = ClassTag[Coll[A]](classOf[Coll[A]]) + + override def name: String = s"Coll[${tItem.name}]" +} diff --git a/common/shared/src/main/scala/special/collection/CollsOverArrays.scala b/common/shared/src/main/scala/special/collection/CollsOverArrays.scala index 7b91c0f50b..9e93251626 100644 --- a/common/shared/src/main/scala/special/collection/CollsOverArrays.scala +++ b/common/shared/src/main/scala/special/collection/CollsOverArrays.scala @@ -1,10 +1,9 @@ package special.collection import java.util -import scalan._ +import scalan._ // required import scalan.util.CollectionUtil import scalan.RType -import Helpers._ import debox.Buffer import scalan.RType._ import sigmastate.VersionContext diff --git a/common/shared/src/main/scala/special/collection/Helpers.scala b/common/shared/src/main/scala/special/collection/Helpers.scala deleted file mode 100644 index 732603b7e4..0000000000 --- a/common/shared/src/main/scala/special/collection/Helpers.scala +++ /dev/null @@ -1,11 +0,0 @@ -package special.collection - -object Helpers { - private def sameLengthErrorMsg[A,B](xs: Coll[A], ys: Coll[B]) = - s"Collections should have same length but was ${xs.length} and ${ys.length}:\n xs=$xs;\n ys=$ys" - - def requireSameLength[A,B](xs: Coll[A], ys: Coll[B]) = { - require(xs.length == ys.length, sameLengthErrorMsg(xs, ys)) - } - -} diff --git a/common/shared/src/main/scala/special/collection/package.scala b/common/shared/src/main/scala/special/collection/package.scala index b8be71be23..0fea9c92d1 100644 --- a/common/shared/src/main/scala/special/collection/package.scala +++ b/common/shared/src/main/scala/special/collection/package.scala @@ -1,17 +1,9 @@ package special -import scala.language.implicitConversions import scalan.RType -import scala.reflect.{classTag, ClassTag} - -package collection { - /** Type descriptor for `Coll[A]` type. */ - case class CollType[A](tItem: RType[A]) extends RType[Coll[A]] { - override val classTag: ClassTag[Coll[A]] = ClassTag[Coll[A]](classOf[Coll[A]]) - override def name: String = s"Coll[${tItem.name}]" - } -} +import scala.language.implicitConversions +import scala.reflect.classTag package object collection { /** Forces reflection data initialization */ @@ -30,4 +22,11 @@ package object collection { implicit def downcastCollType[A](ct: RType[Coll[A]]): CollType[A] = ct.asInstanceOf[CollType[A]] implicit val collBuilderRType: RType[CollBuilder] = RType.fromClassTag(classTag[CollBuilder]) + + private def sameLengthErrorMsg[A, B](xs: Coll[A], ys: Coll[B]) = + s"Collections should have same length but was ${xs.length} and ${ys.length}:\n xs=$xs;\n ys=$ys" + + def requireSameLength[A, B](xs: Coll[A], ys: Coll[B]) = { + require(xs.length == ys.length, sameLengthErrorMsg(xs, ys)) + } } diff --git a/common/shared/src/main/scala/special/sigma/SigmaDsl.scala b/common/shared/src/main/scala/special/sigma/SigmaDsl.scala index 462c5382ab..325aaa444a 100644 --- a/common/shared/src/main/scala/special/sigma/SigmaDsl.scala +++ b/common/shared/src/main/scala/special/sigma/SigmaDsl.scala @@ -316,7 +316,7 @@ trait 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 `sigmastate.eval.InvalidType` exception when the type of the register value is * different from cT. * @since 2.0 */ diff --git a/sc/shared/src/main/scala/scalan/GraphIRReflection.scala b/sc/shared/src/main/scala/scalan/GraphIRReflection.scala index 4be98bdf10..e271d5d176 100644 --- a/sc/shared/src/main/scala/scalan/GraphIRReflection.scala +++ b/sc/shared/src/main/scala/scalan/GraphIRReflection.scala @@ -2,7 +2,8 @@ package scalan import scalan.primitives.Thunks import scalan.reflection.CommonReflection.registerClassEntry -import scalan.reflection.{mkConstructor, mkMethod, CommonReflection} +import scalan.reflection.{CommonReflection, mkConstructor, mkMethod} +import sigmastate.eval.SigmaLibrary import special.CoreLibReflection import special.collection.Colls import special.sigma.SigmaDsl diff --git a/sc/shared/src/main/scala/sigmastate/eval/GraphBuilding.scala b/sc/shared/src/main/scala/sigmastate/eval/GraphBuilding.scala index a992dbf0d7..347468da89 100644 --- a/sc/shared/src/main/scala/sigmastate/eval/GraphBuilding.scala +++ b/sc/shared/src/main/scala/sigmastate/eval/GraphBuilding.scala @@ -4,7 +4,7 @@ import org.ergoplatform._ import scalan.ExactIntegral.{ByteIsExactIntegral, IntIsExactIntegral, LongIsExactIntegral, ShortIsExactIntegral} import scalan.ExactOrdering.{ByteIsExactOrdering, IntIsExactOrdering, LongIsExactOrdering, ShortIsExactOrdering} import scalan.util.Extensions.ByteOps -import scalan.{ExactIntegral, ExactNumeric, ExactOrdering, Lazy, MutableLazy, Nullable, SigmaLibrary} +import scalan.{ExactIntegral, ExactNumeric, ExactOrdering, Lazy, MutableLazy, Nullable} import sigmastate.Values.Value.Typed import sigmastate.Values._ import sigmastate.interpreter.Interpreter.ScriptEnv diff --git a/sc/shared/src/main/scala/scalan/SigmaLibrary.scala b/sc/shared/src/main/scala/sigmastate/eval/SigmaLibrary.scala similarity index 90% rename from sc/shared/src/main/scala/scalan/SigmaLibrary.scala rename to sc/shared/src/main/scala/sigmastate/eval/SigmaLibrary.scala index 46c235758b..bc1e17d228 100644 --- a/sc/shared/src/main/scala/scalan/SigmaLibrary.scala +++ b/sc/shared/src/main/scala/sigmastate/eval/SigmaLibrary.scala @@ -1,5 +1,6 @@ -package scalan +package sigmastate.eval +import scalan.Library import special.sigma.SigmaDslModule /** Main trait which represents sigma operations in graph IR cake. */ diff --git a/sc/shared/src/main/scala/sigmastate/eval/TreeBuilding.scala b/sc/shared/src/main/scala/sigmastate/eval/TreeBuilding.scala index f6e77f12e0..d0245f5799 100644 --- a/sc/shared/src/main/scala/sigmastate/eval/TreeBuilding.scala +++ b/sc/shared/src/main/scala/sigmastate/eval/TreeBuilding.scala @@ -10,7 +10,6 @@ import sigmastate.serialization.ConstantStore import scala.collection.mutable.ArrayBuffer import SType._ -import scalan.SigmaLibrary import sigmastate.basics.DLogProtocol.ProveDlog import sigmastate.basics.ProveDHTuple import sigmastate.lang.Terms diff --git a/sc/shared/src/main/scala/special/sigma/SigmaDslUnit.scala b/sc/shared/src/main/scala/special/sigma/SigmaDslUnit.scala index 43ba7f5db2..0ac9882574 100644 --- a/sc/shared/src/main/scala/special/sigma/SigmaDslUnit.scala +++ b/sc/shared/src/main/scala/special/sigma/SigmaDslUnit.scala @@ -1,5 +1,6 @@ package special.sigma { import scalan._ + import sigmastate.eval.SigmaLibrary trait SigmaDsl extends Base { self: SigmaLibrary => trait BigInt extends Def[BigInt] { diff --git a/sc/shared/src/main/scala/special/sigma/impl/SigmaDslImpl.scala b/sc/shared/src/main/scala/special/sigma/impl/SigmaDslImpl.scala index 0642168d68..c56beb83cb 100644 --- a/sc/shared/src/main/scala/special/sigma/impl/SigmaDslImpl.scala +++ b/sc/shared/src/main/scala/special/sigma/impl/SigmaDslImpl.scala @@ -1,13 +1,14 @@ package special.sigma -import scala.language.{existentials,implicitConversions} +import scala.language.{existentials, implicitConversions} import scalan._ +import sigmastate.eval.SigmaLibrary + import scala.collection.compat.immutable.ArraySeq package impl { - import scalan.OverloadHack.Overloaded1 - import scalan.reflection.CommonReflection.registerClassEntry - import scalan.reflection.{RClass, RMethod, SRMethod} // manual fix + import scalan.reflection.{RClass, RMethod} + import sigmastate.eval.SigmaLibrary // Abs ----------------------------------- trait SigmaDslDefs extends scalan.Scalan with SigmaDsl { From 0e979b6f7a2ca55d442c4e13a11ed6d3c976df58 Mon Sep 17 00:00:00 2001 From: Alexander Slesarenko Date: Tue, 22 Aug 2023 16:38:28 +0200 Subject: [PATCH 04/37] minimize-modules: move downcastCollType to CollType --- .../main/scala/special/collection/CollType.scala | 13 +++++++++++++ .../src/main/scala/special/collection/package.scala | 9 --------- 2 files changed, 13 insertions(+), 9 deletions(-) diff --git a/common/shared/src/main/scala/special/collection/CollType.scala b/common/shared/src/main/scala/special/collection/CollType.scala index bb14366c0b..1061742705 100644 --- a/common/shared/src/main/scala/special/collection/CollType.scala +++ b/common/shared/src/main/scala/special/collection/CollType.scala @@ -1,6 +1,8 @@ package special.collection import scalan.RType + +import scala.language.implicitConversions import scala.reflect.ClassTag /** Type descriptor for `Coll[A]` type. */ @@ -9,3 +11,14 @@ case class CollType[A](tItem: RType[A]) extends RType[Coll[A]] { override def name: String = s"Coll[${tItem.name}]" } + +object CollType { + /** Conversion to underlying descriptor class. + * Allows syntax like + * + * ```val tColl: RType[Coll[A]] = ...; tColl.tItem``` + * + * where `tItem` is a method of `CollType`, but is not defined on `RType`. + */ + implicit def downcastCollType[A](ct: RType[Coll[A]]): CollType[A] = ct.asInstanceOf[CollType[A]] +} diff --git a/common/shared/src/main/scala/special/collection/package.scala b/common/shared/src/main/scala/special/collection/package.scala index 0fea9c92d1..a683abd7a0 100644 --- a/common/shared/src/main/scala/special/collection/package.scala +++ b/common/shared/src/main/scala/special/collection/package.scala @@ -12,15 +12,6 @@ package object collection { /** Implicit resolution of `Coll[A]` type descriptor, given a descriptor of `A`. */ implicit def collRType[A](implicit tA: RType[A]): RType[Coll[A]] = CollType[A](tA) - /** Conversion to underlying descriptor class. - * Allows syntax like - * - * ```val tColl: RType[Coll[A]] = ...; tColl.tItem``` - * - * where `tItem` is a method of `CollType`, but is not defined on `RType`. - */ - implicit def downcastCollType[A](ct: RType[Coll[A]]): CollType[A] = ct.asInstanceOf[CollType[A]] - implicit val collBuilderRType: RType[CollBuilder] = RType.fromClassTag(classTag[CollBuilder]) private def sameLengthErrorMsg[A, B](xs: Coll[A], ys: Coll[B]) = From d9638b44fc4c5972d57efdcb671808ce4bcde39e Mon Sep 17 00:00:00 2001 From: Alexander Slesarenko Date: Tue, 22 Aug 2023 16:48:45 +0200 Subject: [PATCH 05/37] minimize-modules: rename sigmastate -> sigma in common --- .../js/src/main/scala/scalan/reflection/Platform.scala | 3 +-- .../src/main/scala/scalan/reflection/Platform.scala | 3 +-- .../{sigmastate => sigma}/kiama/util/Collections.scala | 3 +-- .../main/scala/{sigmastate => sigma}/Environment.scala | 2 +- .../scala/{sigmastate => sigma}/RuntimePlatform.scala | 2 +- .../scala/{sigmastate => sigma}/VersionContext.scala | 4 ++-- .../main/scala/{sigmastate => sigma}/kiama/kiama.scala | 2 +- .../kiama/rewriting/CallbackRewriter.scala | 5 +++-- .../kiama/rewriting/PlusStrategy.scala | 2 +- .../kiama/rewriting/Rewriter.scala | 7 ++++--- .../kiama/rewriting/Strategy.scala | 3 +-- .../{sigmastate => sigma}/kiama/util/Comparison.scala | 3 +-- .../src/main/scala/{sigmastate => sigma}/util.scala | 2 +- .../scala/special/collection/CollsOverArrays.scala | 4 ++-- .../scala/{sigmastate => sigma}/VersionTesting.scala | 6 +++--- .../{sigmastate => sigma}/VersionTestingProperty.scala | 2 +- .../test/scala/special/collections/CollsTests.scala | 2 +- .../js/src/main/scala/sigmastate/Platform.scala | 1 + .../jvm/src/main/scala/sigmastate/Platform.scala | 1 + .../main/scala/org/ergoplatform/ErgoBoxCandidate.scala | 2 +- .../scala/org/ergoplatform/ErgoLikeTransaction.scala | 2 +- .../src/main/scala/sigmastate/SigSerializer.scala | 2 +- .../shared/src/main/scala/sigmastate/Values.scala | 4 ++-- .../scala/sigmastate/eval/CostingDataContext.scala | 1 + .../sigmastate/interpreter/ErgoTreeEvaluator.scala | 4 ++-- .../scala/sigmastate/interpreter/Interpreter.scala | 8 +++++--- .../sigmastate/interpreter/ProverInterpreter.scala | 7 ++++--- .../src/main/scala/sigmastate/lang/SigmaBuilder.scala | 1 + .../shared/src/main/scala/sigmastate/lang/Terms.scala | 2 +- .../serialization/BlockValueSerializer.scala | 2 +- .../ConcreteCollectionBooleanConstantSerializer.scala | 2 +- .../serialization/ConcreteCollectionSerializer.scala | 2 +- .../sigmastate/serialization/ErgoTreeSerializer.scala | 5 +++-- .../sigmastate/serialization/FuncValueSerializer.scala | 2 +- .../serialization/GroupElementSerializer.scala | 2 +- .../serialization/MethodCallSerializer.scala | 2 +- .../sigmastate/serialization/TupleSerializer.scala | 2 +- .../sigmastate/serialization/TypeSerializer.scala | 2 +- .../sigmastate/serialization/ValDefSerializer.scala | 2 +- .../transformers/SigmaTransformerSerializer.scala | 2 +- .../shared/src/main/scala/sigmastate/trees.scala | 1 + .../src/main/scala/sigmastate/utils/Helpers.scala | 2 +- .../main/scala/sigmastate/utils/SigmaByteReader.scala | 2 +- .../shared/src/test/scala/sigmastate/TestsBase.scala | 3 ++- .../test/scala/sigmastate/lang/SigmaBuilderTest.scala | 1 + .../src/test/scala/sigmastate/lang/LangTests.scala | 2 +- .../src/main/scala/sigmastate/lang/SigmaBinder.scala | 2 +- .../src/main/scala/sigmastate/lang/SigmaCompiler.scala | 2 +- .../test/scala/sigmastate/ErgoTreeSpecification.scala | 3 ++- .../sigmastate/ScriptVersionSwitchSpecification.scala | 2 +- .../src/test/scala/sigmastate/TypesSpecification.scala | 1 + .../test/scala/sigmastate/eval/ErgoScriptTestkit.scala | 3 ++- .../serialization/DeserializationResilience.scala | 3 ++- .../sigmastate/utxo/SerializationRoundTripSpec.scala | 2 +- .../scala/special/sigma/SigmaDslSpecification.scala | 10 ++++++---- .../test/scala/special/sigma/SigmaDslStaginTests.scala | 3 ++- .../src/test/scala/special/sigma/SigmaDslTesting.scala | 3 ++- .../ergoplatform/sdk/AppkitProvingInterpreter.scala | 3 ++- .../scala/org/ergoplatform/sdk/ContractTemplate.scala | 2 +- 59 files changed, 91 insertions(+), 74 deletions(-) rename common/shared/src/main/scala-2.13/{sigmastate => sigma}/kiama/util/Collections.scala (96%) rename common/shared/src/main/scala/{sigmastate => sigma}/Environment.scala (97%) rename common/shared/src/main/scala/{sigmastate => sigma}/RuntimePlatform.scala (95%) rename common/shared/src/main/scala/{sigmastate => sigma}/VersionContext.scala (98%) rename common/shared/src/main/scala/{sigmastate => sigma}/kiama/kiama.scala (98%) rename common/shared/src/main/scala/{sigmastate => sigma}/kiama/rewriting/CallbackRewriter.scala (97%) rename common/shared/src/main/scala/{sigmastate => sigma}/kiama/rewriting/PlusStrategy.scala (96%) rename common/shared/src/main/scala/{sigmastate => sigma}/kiama/rewriting/Rewriter.scala (99%) rename common/shared/src/main/scala/{sigmastate => sigma}/kiama/rewriting/Strategy.scala (98%) rename common/shared/src/main/scala/{sigmastate => sigma}/kiama/util/Comparison.scala (98%) rename common/shared/src/main/scala/{sigmastate => sigma}/util.scala (98%) rename common/shared/src/test/scala/{sigmastate => sigma}/VersionTesting.scala (93%) rename common/shared/src/test/scala/{sigmastate => sigma}/VersionTestingProperty.scala (98%) diff --git a/common/js/src/main/scala/scalan/reflection/Platform.scala b/common/js/src/main/scala/scalan/reflection/Platform.scala index 7b4c2d74e6..6970bf999d 100644 --- a/common/js/src/main/scala/scalan/reflection/Platform.scala +++ b/common/js/src/main/scala/scalan/reflection/Platform.scala @@ -1,7 +1,6 @@ package scalan.reflection -import sigmastate.RuntimePlatform - +import sigma.RuntimePlatform import scala.collection.mutable /** JS Platform dependent implementation of reflection methods. */ diff --git a/common/jvm/src/main/scala/scalan/reflection/Platform.scala b/common/jvm/src/main/scala/scalan/reflection/Platform.scala index 7129cfb814..8c59a0096e 100644 --- a/common/jvm/src/main/scala/scalan/reflection/Platform.scala +++ b/common/jvm/src/main/scala/scalan/reflection/Platform.scala @@ -1,7 +1,6 @@ package scalan.reflection -import sigmastate.RuntimePlatform - +import sigma.RuntimePlatform import scala.collection.concurrent.TrieMap /** Platform dependent implementation of reflection methods. */ diff --git a/common/shared/src/main/scala-2.13/sigmastate/kiama/util/Collections.scala b/common/shared/src/main/scala-2.13/sigma/kiama/util/Collections.scala similarity index 96% rename from common/shared/src/main/scala-2.13/sigmastate/kiama/util/Collections.scala rename to common/shared/src/main/scala-2.13/sigma/kiama/util/Collections.scala index 14f3936af1..812ac7707d 100644 --- a/common/shared/src/main/scala-2.13/sigmastate/kiama/util/Collections.scala +++ b/common/shared/src/main/scala-2.13/sigma/kiama/util/Collections.scala @@ -8,8 +8,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -package sigmastate.kiama -package util +package sigma.kiama.util object Collections { diff --git a/common/shared/src/main/scala/sigmastate/Environment.scala b/common/shared/src/main/scala/sigma/Environment.scala similarity index 97% rename from common/shared/src/main/scala/sigmastate/Environment.scala rename to common/shared/src/main/scala/sigma/Environment.scala index f15752aa9c..7665b251a5 100644 --- a/common/shared/src/main/scala/sigmastate/Environment.scala +++ b/common/shared/src/main/scala/sigma/Environment.scala @@ -1,4 +1,4 @@ -package sigmastate +package sigma /** Describes the current execution environment. */ sealed abstract class Environment { diff --git a/common/shared/src/main/scala/sigmastate/RuntimePlatform.scala b/common/shared/src/main/scala/sigma/RuntimePlatform.scala similarity index 95% rename from common/shared/src/main/scala/sigmastate/RuntimePlatform.scala rename to common/shared/src/main/scala/sigma/RuntimePlatform.scala index b6d0bc30fb..23d50cbcb3 100644 --- a/common/shared/src/main/scala/sigmastate/RuntimePlatform.scala +++ b/common/shared/src/main/scala/sigma/RuntimePlatform.scala @@ -1,4 +1,4 @@ -package sigmastate +package sigma /** Descriptor of a runtime platform. Can be used to conditionally execute code. */ sealed trait RuntimePlatform { diff --git a/common/shared/src/main/scala/sigmastate/VersionContext.scala b/common/shared/src/main/scala/sigma/VersionContext.scala similarity index 98% rename from common/shared/src/main/scala/sigmastate/VersionContext.scala rename to common/shared/src/main/scala/sigma/VersionContext.scala index ef220d1109..14e6dc8b21 100644 --- a/common/shared/src/main/scala/sigmastate/VersionContext.scala +++ b/common/shared/src/main/scala/sigma/VersionContext.scala @@ -1,6 +1,6 @@ -package sigmastate +package sigma -import sigmastate.VersionContext.JitActivationVersion +import VersionContext.JitActivationVersion import scala.util.DynamicVariable diff --git a/common/shared/src/main/scala/sigmastate/kiama/kiama.scala b/common/shared/src/main/scala/sigma/kiama/kiama.scala similarity index 98% rename from common/shared/src/main/scala/sigmastate/kiama/kiama.scala rename to common/shared/src/main/scala/sigma/kiama/kiama.scala index df8518f88d..d6b69f7b6d 100644 --- a/common/shared/src/main/scala/sigmastate/kiama/kiama.scala +++ b/common/shared/src/main/scala/sigma/kiama/kiama.scala @@ -1,4 +1,4 @@ -package sigmastate +package sigma /** * Kiama is a Scala library for language processing. It is a project of the diff --git a/common/shared/src/main/scala/sigmastate/kiama/rewriting/CallbackRewriter.scala b/common/shared/src/main/scala/sigma/kiama/rewriting/CallbackRewriter.scala similarity index 97% rename from common/shared/src/main/scala/sigmastate/kiama/rewriting/CallbackRewriter.scala rename to common/shared/src/main/scala/sigma/kiama/rewriting/CallbackRewriter.scala index 157f6f172b..c6ed0858ee 100644 --- a/common/shared/src/main/scala/sigmastate/kiama/rewriting/CallbackRewriter.scala +++ b/common/shared/src/main/scala/sigma/kiama/rewriting/CallbackRewriter.scala @@ -8,8 +8,9 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -package sigmastate.kiama -package rewriting +package sigma.kiama.rewriting + +import sigma.kiama.{===>, ==>} /** * Strategy-based term rewriting with callbacks. Clients can register diff --git a/common/shared/src/main/scala/sigmastate/kiama/rewriting/PlusStrategy.scala b/common/shared/src/main/scala/sigma/kiama/rewriting/PlusStrategy.scala similarity index 96% rename from common/shared/src/main/scala/sigmastate/kiama/rewriting/PlusStrategy.scala rename to common/shared/src/main/scala/sigma/kiama/rewriting/PlusStrategy.scala index 26ac3ae2c5..e92f939d96 100644 --- a/common/shared/src/main/scala/sigmastate/kiama/rewriting/PlusStrategy.scala +++ b/common/shared/src/main/scala/sigma/kiama/rewriting/PlusStrategy.scala @@ -8,7 +8,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -package sigmastate.kiama.rewriting +package sigma.kiama.rewriting /** * Helper class to contain commonality of choice in non-deterministic diff --git a/common/shared/src/main/scala/sigmastate/kiama/rewriting/Rewriter.scala b/common/shared/src/main/scala/sigma/kiama/rewriting/Rewriter.scala similarity index 99% rename from common/shared/src/main/scala/sigmastate/kiama/rewriting/Rewriter.scala rename to common/shared/src/main/scala/sigma/kiama/rewriting/Rewriter.scala index 8a1711c9d7..ee53218307 100644 --- a/common/shared/src/main/scala/sigmastate/kiama/rewriting/Rewriter.scala +++ b/common/shared/src/main/scala/sigma/kiama/rewriting/Rewriter.scala @@ -8,10 +8,11 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -package sigmastate.kiama +package sigma.kiama package rewriting import scalan.reflection.{Platform, RClass, RConstructor} +//import sigma.kiama.==> /** * Strategy-based term rewriting in the style of Stratego (http://strategoxt.org/). @@ -23,8 +24,8 @@ import scalan.reflection.{Platform, RClass, RConstructor} */ trait Rewriter { - import sigmastate.kiama.util.Comparison.same - import sigmastate.kiama.util.Collections.{CanBuildFrom, Factory, newBuilder} + import sigma.kiama.util.Comparison.same + import sigma.kiama.util.Collections.{CanBuildFrom, Factory, newBuilder} /** * Rewrite a term. Apply the strategy `s` to a term returning the result term diff --git a/common/shared/src/main/scala/sigmastate/kiama/rewriting/Strategy.scala b/common/shared/src/main/scala/sigma/kiama/rewriting/Strategy.scala similarity index 98% rename from common/shared/src/main/scala/sigmastate/kiama/rewriting/Strategy.scala rename to common/shared/src/main/scala/sigma/kiama/rewriting/Strategy.scala index faf856e8d7..a6e15fcd90 100644 --- a/common/shared/src/main/scala/sigmastate/kiama/rewriting/Strategy.scala +++ b/common/shared/src/main/scala/sigma/kiama/rewriting/Strategy.scala @@ -8,8 +8,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -package sigmastate.kiama -package rewriting +package sigma.kiama.rewriting /** * Any-rewriting strategies. A strategy is a function that takes a term diff --git a/common/shared/src/main/scala/sigmastate/kiama/util/Comparison.scala b/common/shared/src/main/scala/sigma/kiama/util/Comparison.scala similarity index 98% rename from common/shared/src/main/scala/sigmastate/kiama/util/Comparison.scala rename to common/shared/src/main/scala/sigma/kiama/util/Comparison.scala index 91d302a76a..2d45e382fd 100644 --- a/common/shared/src/main/scala/sigmastate/kiama/util/Comparison.scala +++ b/common/shared/src/main/scala/sigma/kiama/util/Comparison.scala @@ -8,8 +8,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -package sigmastate.kiama -package util +package sigma.kiama.util /** * Utility module for comparison routines. diff --git a/common/shared/src/main/scala/sigmastate/util.scala b/common/shared/src/main/scala/sigma/util.scala similarity index 98% rename from common/shared/src/main/scala/sigmastate/util.scala rename to common/shared/src/main/scala/sigma/util.scala index e499ab9825..85c5ef0b2e 100644 --- a/common/shared/src/main/scala/sigmastate/util.scala +++ b/common/shared/src/main/scala/sigma/util.scala @@ -1,4 +1,4 @@ -package sigmastate +package sigma import scalan.util.CollectionUtil diff --git a/common/shared/src/main/scala/special/collection/CollsOverArrays.scala b/common/shared/src/main/scala/special/collection/CollsOverArrays.scala index 9e93251626..fc6f0e3767 100644 --- a/common/shared/src/main/scala/special/collection/CollsOverArrays.scala +++ b/common/shared/src/main/scala/special/collection/CollsOverArrays.scala @@ -6,9 +6,9 @@ import scalan.util.CollectionUtil import scalan.RType import debox.Buffer import scalan.RType._ -import sigmastate.VersionContext -import sigmastate.util.{MaxArrayLength, safeConcatArrays_v5} +import sigma.util.{MaxArrayLength, safeConcatArrays_v5} import debox.cfor +import sigma.VersionContext class CollOverArray[@specialized A](val toArray: Array[A], val builder: CollBuilder) (implicit tA: RType[A]) extends Coll[A] { diff --git a/common/shared/src/test/scala/sigmastate/VersionTesting.scala b/common/shared/src/test/scala/sigma/VersionTesting.scala similarity index 93% rename from common/shared/src/test/scala/sigmastate/VersionTesting.scala rename to common/shared/src/test/scala/sigma/VersionTesting.scala index a92dd7bfa4..a17fc7a7f9 100644 --- a/common/shared/src/test/scala/sigmastate/VersionTesting.scala +++ b/common/shared/src/test/scala/sigma/VersionTesting.scala @@ -1,4 +1,4 @@ -package sigmastate +package sigma import debox.cfor @@ -12,7 +12,7 @@ trait VersionTesting { protected val activatedVersions: Seq[Byte] = (0 to VersionContext.MaxSupportedScriptVersion).map(_.toByte).toArray[Byte] - private[sigmastate] val _currActivatedVersion = new DynamicVariable[Byte](2) // v5.x by default + private[sigma] val _currActivatedVersion = new DynamicVariable[Byte](2) // v5.x by default /** Current activated version used in tests. */ def activatedVersionInTests: Byte = _currActivatedVersion.value @@ -20,7 +20,7 @@ trait VersionTesting { val ergoTreeVersions: Seq[Byte] = (0 to VersionContext.MaxSupportedScriptVersion).map(_.toByte).toArray[Byte] - private[sigmastate] val _currErgoTreeVersion = new DynamicVariable[Byte](0) + private[sigma] val _currErgoTreeVersion = new DynamicVariable[Byte](0) /** Current ErgoTree version assigned dynamically. */ def ergoTreeVersionInTests: Byte = _currErgoTreeVersion.value diff --git a/common/shared/src/test/scala/sigmastate/VersionTestingProperty.scala b/common/shared/src/test/scala/sigma/VersionTestingProperty.scala similarity index 98% rename from common/shared/src/test/scala/sigmastate/VersionTestingProperty.scala rename to common/shared/src/test/scala/sigma/VersionTestingProperty.scala index bfa6cace28..2c25359a89 100644 --- a/common/shared/src/test/scala/sigmastate/VersionTestingProperty.scala +++ b/common/shared/src/test/scala/sigma/VersionTestingProperty.scala @@ -1,4 +1,4 @@ -package sigmastate +package sigma import org.scalactic.source.Position import org.scalatest.propspec.AnyPropSpec diff --git a/common/shared/src/test/scala/special/collections/CollsTests.scala b/common/shared/src/test/scala/special/collections/CollsTests.scala index f1fe708a7f..2c7484193b 100644 --- a/common/shared/src/test/scala/special/collections/CollsTests.scala +++ b/common/shared/src/test/scala/special/collections/CollsTests.scala @@ -6,7 +6,7 @@ import org.scalatest.matchers.should.Matchers import org.scalatest.propspec.AnyPropSpec import org.scalatestplus.scalacheck.ScalaCheckPropertyChecks import scalan._ -import sigmastate.{VersionContext, VersionTestingProperty} +import sigma.{VersionContext, VersionTestingProperty} import special.collection.{Coll, CollOverArray, PairOfCols} import scala.language.{existentials} diff --git a/interpreter/js/src/main/scala/sigmastate/Platform.scala b/interpreter/js/src/main/scala/sigmastate/Platform.scala index 98cf6a9ea3..de3f0a3b7f 100644 --- a/interpreter/js/src/main/scala/sigmastate/Platform.scala +++ b/interpreter/js/src/main/scala/sigmastate/Platform.scala @@ -2,6 +2,7 @@ package sigmastate import org.ergoplatform.ErgoBox import scalan.Nullable +import sigma.VersionContext import sigmastate.Values.{Constant, FalseLeaf, SigmaBoolean, TrueLeaf} import sigmastate.eval.{Evaluation, SigmaDsl} import sigmastate.lang.SigmaBuilder diff --git a/interpreter/jvm/src/main/scala/sigmastate/Platform.scala b/interpreter/jvm/src/main/scala/sigmastate/Platform.scala index f094e290b8..b29941b6d4 100644 --- a/interpreter/jvm/src/main/scala/sigmastate/Platform.scala +++ b/interpreter/jvm/src/main/scala/sigmastate/Platform.scala @@ -2,6 +2,7 @@ package sigmastate import org.ergoplatform.ErgoBox import scalan.Nullable +import sigma.VersionContext import sigmastate.Values.{Constant, FalseLeaf, SigmaBoolean, TrueLeaf} import sigmastate.eval.{Evaluation, SigmaDsl} import sigmastate.lang.SigmaBuilder diff --git a/interpreter/shared/src/main/scala/org/ergoplatform/ErgoBoxCandidate.scala b/interpreter/shared/src/main/scala/org/ergoplatform/ErgoBoxCandidate.scala index da1fdc94fd..7948823cda 100644 --- a/interpreter/shared/src/main/scala/org/ergoplatform/ErgoBoxCandidate.scala +++ b/interpreter/shared/src/main/scala/org/ergoplatform/ErgoBoxCandidate.scala @@ -13,7 +13,7 @@ import special.collection.Coll import sigmastate.eval._ import sigmastate.eval.Extensions._ import sigmastate.serialization.ErgoTreeSerializer.DefaultSerializer -import sigmastate.util.safeNewArray +import sigma.util.safeNewArray import debox.cfor import special.collection.Extensions.CollOps diff --git a/interpreter/shared/src/main/scala/org/ergoplatform/ErgoLikeTransaction.scala b/interpreter/shared/src/main/scala/org/ergoplatform/ErgoLikeTransaction.scala index f5b8a2c15f..2582b84e76 100644 --- a/interpreter/shared/src/main/scala/org/ergoplatform/ErgoLikeTransaction.scala +++ b/interpreter/shared/src/main/scala/org/ergoplatform/ErgoLikeTransaction.scala @@ -9,7 +9,7 @@ import sigmastate.eval.Extensions._ import sigmastate.eval._ import sigmastate.interpreter.ProverResult import sigmastate.serialization.{SigmaSerializer, ValueSerializer} -import sigmastate.util.safeNewArray +import sigma.util.safeNewArray import sigmastate.utils.{SigmaByteReader, SigmaByteWriter} import debox.cfor diff --git a/interpreter/shared/src/main/scala/sigmastate/SigSerializer.scala b/interpreter/shared/src/main/scala/sigmastate/SigSerializer.scala index f003586d85..d71424aa01 100644 --- a/interpreter/shared/src/main/scala/sigmastate/SigSerializer.scala +++ b/interpreter/shared/src/main/scala/sigmastate/SigSerializer.scala @@ -9,7 +9,7 @@ import sigmastate.basics.{CryptoConstants, ProveDHTuple, SecondDHTupleProverMess import sigmastate.interpreter.ErgoTreeEvaluator.{fixedCostOp, perItemCostOp} import sigmastate.interpreter.{ErgoTreeEvaluator, NamedDesc, OperationCostInfo} import sigmastate.serialization.SigmaSerializer -import sigmastate.util.safeNewArray +import sigma.util.safeNewArray import sigmastate.utils.{Helpers, SigmaByteReader, SigmaByteWriter} import debox.cfor import sigmastate.eval.Extensions.ArrayOps diff --git a/interpreter/shared/src/main/scala/sigmastate/Values.scala b/interpreter/shared/src/main/scala/sigmastate/Values.scala index d5326db2b1..d93b5add75 100644 --- a/interpreter/shared/src/main/scala/sigmastate/Values.scala +++ b/interpreter/shared/src/main/scala/sigmastate/Values.scala @@ -2,7 +2,7 @@ package sigmastate import java.math.BigInteger import java.util.{Arrays, Objects} -import sigmastate.kiama.rewriting.Rewriter.{count, everywherebu, strategy} +import sigma.kiama.rewriting.Rewriter.{count, everywherebu, strategy} import org.ergoplatform.settings.ErgoAlgos import org.ergoplatform.validation.ValidationException import scalan.{Nullable, RType} @@ -34,7 +34,7 @@ import sigmastate.serialization.transformers.ProveDHTupleSerializer import sigmastate.utils.{SigmaByteReader, SigmaByteWriter} import special.sigma.{AvlTree, Header, PreHeader, _} import sigmastate.lang.SourceContext -import sigmastate.util.safeNewArray +import sigma.util.safeNewArray import special.collection.Coll import scala.collection.compat.immutable.ArraySeq diff --git a/interpreter/shared/src/main/scala/sigmastate/eval/CostingDataContext.scala b/interpreter/shared/src/main/scala/sigmastate/eval/CostingDataContext.scala index 72cd34b725..a79995313a 100644 --- a/interpreter/shared/src/main/scala/sigmastate/eval/CostingDataContext.scala +++ b/interpreter/shared/src/main/scala/sigmastate/eval/CostingDataContext.scala @@ -10,6 +10,7 @@ import scorex.crypto.authds.avltree.batch._ import scorex.crypto.authds.{ADDigest, ADKey, ADValue, SerializedAdProof} import scorex.crypto.hash.{Blake2b256, Digest32, Sha256} import scorex.utils.{Ints, Longs} +import sigma.VersionContext import sigmastate.SCollection.SByteArray import sigmastate.Values.ErgoTree.EmptyConstants import sigmastate.Values.{ConstantNode, ErgoTree, EvaluatedValue, SValue, SigmaBoolean} diff --git a/interpreter/shared/src/main/scala/sigmastate/interpreter/ErgoTreeEvaluator.scala b/interpreter/shared/src/main/scala/sigmastate/interpreter/ErgoTreeEvaluator.scala index de6ad39789..15b9328d00 100644 --- a/interpreter/shared/src/main/scala/sigmastate/interpreter/ErgoTreeEvaluator.scala +++ b/interpreter/shared/src/main/scala/sigmastate/interpreter/ErgoTreeEvaluator.scala @@ -1,7 +1,7 @@ package sigmastate.interpreter import org.ergoplatform.ErgoLikeContext -import sigmastate.{PerItemCost, VersionContext, TypeBasedCost, FixedCost, SType, JitCost} +import sigmastate.{PerItemCost, TypeBasedCost, FixedCost, SType, JitCost} import sigmastate.Values._ import sigmastate.eval.Profiler import sigmastate.interpreter.ErgoTreeEvaluator.DataEnv @@ -11,7 +11,7 @@ import scalan.util.Extensions._ import sigmastate.interpreter.EvalSettings._ import supertagged.TaggedType import debox.{Buffer => DBuffer} - +import sigma.VersionContext import scala.collection.compat.immutable.ArraySeq import scala.util.DynamicVariable diff --git a/interpreter/shared/src/main/scala/sigmastate/interpreter/Interpreter.scala b/interpreter/shared/src/main/scala/sigmastate/interpreter/Interpreter.scala index e606e72525..59d96ba91a 100644 --- a/interpreter/shared/src/main/scala/sigmastate/interpreter/Interpreter.scala +++ b/interpreter/shared/src/main/scala/sigmastate/interpreter/Interpreter.scala @@ -1,15 +1,14 @@ package sigmastate.interpreter import java.util -import sigmastate.kiama.rewriting.Rewriter.{everywherebu, rule, strategy} -import sigmastate.kiama.rewriting.Strategy +import sigma.kiama.rewriting.Rewriter.{everywherebu, rule, strategy} import org.ergoplatform.ErgoLikeContext import org.ergoplatform.validation.SigmaValidationSettings import org.ergoplatform.validation.ValidationRules._ import sigmastate.basics.DLogProtocol.ProveDlog import sigmastate.SCollection.SByteArray import sigmastate.Values._ -import sigmastate.basics.DLogProtocol.{ProveDlog, DLogInteractiveProver, FirstDLogProverMessage} +import sigmastate.basics.DLogProtocol.{DLogInteractiveProver, FirstDLogProverMessage, ProveDlog} import sigmastate.basics._ import sigmastate.interpreter.Interpreter._ import sigmastate.serialization.{SigmaSerializer, ValueSerializer} @@ -23,7 +22,10 @@ import sigmastate.interpreter.ErgoTreeEvaluator.fixedCostOp import sigmastate.utils.Helpers._ import sigmastate.lang.Terms.ValueOps import debox.cfor +import sigma.VersionContext +import sigma.kiama.rewriting.Strategy import sigmastate.exceptions.{CostLimitException, InterpreterException} + import scala.util.{Success, Try} /** Base (verifying) interpreter of ErgoTrees. diff --git a/interpreter/shared/src/main/scala/sigmastate/interpreter/ProverInterpreter.scala b/interpreter/shared/src/main/scala/sigmastate/interpreter/ProverInterpreter.scala index e9dfa6b052..a0e45359f3 100644 --- a/interpreter/shared/src/main/scala/sigmastate/interpreter/ProverInterpreter.scala +++ b/interpreter/shared/src/main/scala/sigmastate/interpreter/ProverInterpreter.scala @@ -1,11 +1,12 @@ package sigmastate.interpreter -import sigmastate.kiama.rewriting.Rewriter.{everywherebu, everywheretd, rule} -import sigmastate.kiama.rewriting.Strategy +import sigma.kiama.rewriting.Rewriter.{everywherebu, everywheretd, rule} import scalan.util.CollectionUtil._ +import sigma.VersionContext +import sigma.kiama.rewriting.Strategy import sigmastate.TrivialProp.{FalseProp, TrueProp} import sigmastate.Values._ -import sigmastate.VersionContext.MaxSupportedScriptVersion +import sigma.VersionContext.MaxSupportedScriptVersion import sigmastate._ import sigmastate.basics.DLogProtocol._ import sigmastate.basics.VerifierMessage.Challenge diff --git a/interpreter/shared/src/main/scala/sigmastate/lang/SigmaBuilder.scala b/interpreter/shared/src/main/scala/sigmastate/lang/SigmaBuilder.scala index 55d1575ff9..7161fa0c40 100644 --- a/interpreter/shared/src/main/scala/sigmastate/lang/SigmaBuilder.scala +++ b/interpreter/shared/src/main/scala/sigmastate/lang/SigmaBuilder.scala @@ -3,6 +3,7 @@ package sigmastate.lang import debox.cfor import org.ergoplatform.ErgoBox.RegisterId import scalan.Nullable +import sigma.Environment import sigmastate.SCollection.{SByteArray, SIntArray} import sigmastate.SOption.SIntOption import sigmastate.Values._ diff --git a/interpreter/shared/src/main/scala/sigmastate/lang/Terms.scala b/interpreter/shared/src/main/scala/sigmastate/lang/Terms.scala index 4cc8dea0d6..02057217a2 100644 --- a/interpreter/shared/src/main/scala/sigmastate/lang/Terms.scala +++ b/interpreter/shared/src/main/scala/sigmastate/lang/Terms.scala @@ -1,6 +1,6 @@ package sigmastate.lang -import sigmastate.kiama.rewriting.Rewriter._ +import sigma.kiama.rewriting.Rewriter._ import scalan.Nullable import sigmastate.SCollection.{SIntArray, SByteArray} import sigmastate.Values._ diff --git a/interpreter/shared/src/main/scala/sigmastate/serialization/BlockValueSerializer.scala b/interpreter/shared/src/main/scala/sigmastate/serialization/BlockValueSerializer.scala index 522a1310e4..6e4056e275 100644 --- a/interpreter/shared/src/main/scala/sigmastate/serialization/BlockValueSerializer.scala +++ b/interpreter/shared/src/main/scala/sigmastate/serialization/BlockValueSerializer.scala @@ -4,7 +4,7 @@ import sigmastate.Values._ import sigmastate._ import sigmastate.utils.{SigmaByteReader, SigmaByteWriter} import ValueSerializer._ -import sigmastate.util.safeNewArray +import sigma.util.safeNewArray import sigmastate.utils.SigmaByteWriter.{DataInfo, U, Vlq} import debox.cfor diff --git a/interpreter/shared/src/main/scala/sigmastate/serialization/ConcreteCollectionBooleanConstantSerializer.scala b/interpreter/shared/src/main/scala/sigmastate/serialization/ConcreteCollectionBooleanConstantSerializer.scala index c3a2af686d..0419fd6e04 100644 --- a/interpreter/shared/src/main/scala/sigmastate/serialization/ConcreteCollectionBooleanConstantSerializer.scala +++ b/interpreter/shared/src/main/scala/sigmastate/serialization/ConcreteCollectionBooleanConstantSerializer.scala @@ -4,7 +4,7 @@ import sigmastate.{SCollection, SBoolean, ArgInfo} import sigmastate.Values._ import sigmastate.utils.{SigmaByteReader, SigmaByteWriter} import SigmaByteWriter._ -import sigmastate.util.safeNewArray +import sigma.util.safeNewArray import debox.cfor case class ConcreteCollectionBooleanConstantSerializer(cons: (IndexedSeq[Value[SBoolean.type]], SBoolean.type) => Value[SCollection[SBoolean.type]]) diff --git a/interpreter/shared/src/main/scala/sigmastate/serialization/ConcreteCollectionSerializer.scala b/interpreter/shared/src/main/scala/sigmastate/serialization/ConcreteCollectionSerializer.scala index bcbbfe8305..c11452dde8 100644 --- a/interpreter/shared/src/main/scala/sigmastate/serialization/ConcreteCollectionSerializer.scala +++ b/interpreter/shared/src/main/scala/sigmastate/serialization/ConcreteCollectionSerializer.scala @@ -4,7 +4,7 @@ import sigmastate.{SCollection, ArgInfo, SType} import sigmastate.Values._ import sigmastate.utils.{SigmaByteReader, SigmaByteWriter} import ValueSerializer._ -import sigmastate.util.safeNewArray +import sigma.util.safeNewArray import sigmastate.utils.SigmaByteWriter.{DataInfo, U, Vlq} import debox.cfor diff --git a/interpreter/shared/src/main/scala/sigmastate/serialization/ErgoTreeSerializer.scala b/interpreter/shared/src/main/scala/sigmastate/serialization/ErgoTreeSerializer.scala index dd3c9f7d13..735b5f0595 100644 --- a/interpreter/shared/src/main/scala/sigmastate/serialization/ErgoTreeSerializer.scala +++ b/interpreter/shared/src/main/scala/sigmastate/serialization/ErgoTreeSerializer.scala @@ -2,15 +2,16 @@ package sigmastate.serialization import org.ergoplatform.validation.ValidationRules.{CheckDeserializedScriptIsSigmaProp, CheckHeaderSizeBit, CheckPositionLimit} import org.ergoplatform.validation.{SigmaValidationSettings, ValidationException} -import sigmastate.{SType, VersionContext} +import sigmastate.{SType} import sigmastate.Values.{Constant, ErgoTree, UnparsedErgoTree} import sigmastate.lang.DeserializationSigmaBuilder import sigmastate.lang.Terms.ValueOps import sigmastate.utils.{SigmaByteReader, SigmaByteWriter} import sigmastate.Values.ErgoTree.EmptyConstants -import sigmastate.util.safeNewArray +import sigma.util.safeNewArray import sigmastate.utxo.ComplexityTable import debox.cfor +import sigma.VersionContext import sigmastate.exceptions.{SerializerException, ReaderPositionLimitExceeded} import java.util diff --git a/interpreter/shared/src/main/scala/sigmastate/serialization/FuncValueSerializer.scala b/interpreter/shared/src/main/scala/sigmastate/serialization/FuncValueSerializer.scala index c7ab6208e9..d9f9ea752d 100644 --- a/interpreter/shared/src/main/scala/sigmastate/serialization/FuncValueSerializer.scala +++ b/interpreter/shared/src/main/scala/sigmastate/serialization/FuncValueSerializer.scala @@ -4,7 +4,7 @@ import sigmastate.Values._ import sigmastate._ import sigmastate.utils.{SigmaByteReader, SigmaByteWriter} import ValueSerializer._ -import sigmastate.util.safeNewArray +import sigma.util.safeNewArray import sigmastate.utils.SigmaByteWriter.{DataInfo, U, Vlq} import debox.cfor diff --git a/interpreter/shared/src/main/scala/sigmastate/serialization/GroupElementSerializer.scala b/interpreter/shared/src/main/scala/sigmastate/serialization/GroupElementSerializer.scala index f54606082f..0a68a5d95a 100644 --- a/interpreter/shared/src/main/scala/sigmastate/serialization/GroupElementSerializer.scala +++ b/interpreter/shared/src/main/scala/sigmastate/serialization/GroupElementSerializer.scala @@ -3,7 +3,7 @@ package sigmastate.serialization import sigmastate.basics.CryptoConstants import sigmastate.crypto.CryptoFacade import CryptoConstants.EcPointType -import sigmastate.util.safeNewArray +import sigma.util.safeNewArray import sigmastate.utils.{SigmaByteReader, SigmaByteWriter} /** diff --git a/interpreter/shared/src/main/scala/sigmastate/serialization/MethodCallSerializer.scala b/interpreter/shared/src/main/scala/sigmastate/serialization/MethodCallSerializer.scala index 8167790492..e474d8a7c2 100644 --- a/interpreter/shared/src/main/scala/sigmastate/serialization/MethodCallSerializer.scala +++ b/interpreter/shared/src/main/scala/sigmastate/serialization/MethodCallSerializer.scala @@ -4,7 +4,7 @@ import sigmastate.Values._ import sigmastate._ import sigmastate.lang.Terms.STypeSubst import sigmastate.lang.Terms.MethodCall -import sigmastate.util.safeNewArray +import sigma.util.safeNewArray import sigmastate.utils.SigmaByteWriter.{DataInfo, valuesItemInfo} import sigmastate.utils.{SigmaByteReader, SigmaByteWriter} import sigmastate.utxo.ComplexityTable diff --git a/interpreter/shared/src/main/scala/sigmastate/serialization/TupleSerializer.scala b/interpreter/shared/src/main/scala/sigmastate/serialization/TupleSerializer.scala index c400630e6d..a88a17fa5f 100644 --- a/interpreter/shared/src/main/scala/sigmastate/serialization/TupleSerializer.scala +++ b/interpreter/shared/src/main/scala/sigmastate/serialization/TupleSerializer.scala @@ -4,7 +4,7 @@ import sigmastate.{SType, ArgInfo} import sigmastate.Values._ import sigmastate.utils.{SigmaByteWriter, SigmaByteReader} import sigmastate.serialization.ValueSerializer._ -import sigmastate.util.safeNewArray +import sigma.util.safeNewArray import sigmastate.utils.SigmaByteWriter.{DataInfo, U} import debox.cfor diff --git a/interpreter/shared/src/main/scala/sigmastate/serialization/TypeSerializer.scala b/interpreter/shared/src/main/scala/sigmastate/serialization/TypeSerializer.scala index 3d0f44007e..4dc9335ff3 100644 --- a/interpreter/shared/src/main/scala/sigmastate/serialization/TypeSerializer.scala +++ b/interpreter/shared/src/main/scala/sigmastate/serialization/TypeSerializer.scala @@ -3,7 +3,7 @@ package sigmastate.serialization import java.nio.charset.StandardCharsets import org.ergoplatform.validation.ValidationRules.{CheckPrimitiveTypeCode, CheckTypeCode} import sigmastate._ -import sigmastate.util.safeNewArray +import sigma.util.safeNewArray import sigmastate.utils.{SigmaByteReader, SigmaByteWriter} import debox.cfor import sigmastate.exceptions.InvalidTypePrefix diff --git a/interpreter/shared/src/main/scala/sigmastate/serialization/ValDefSerializer.scala b/interpreter/shared/src/main/scala/sigmastate/serialization/ValDefSerializer.scala index e2086a0381..cdac6309f8 100644 --- a/interpreter/shared/src/main/scala/sigmastate/serialization/ValDefSerializer.scala +++ b/interpreter/shared/src/main/scala/sigmastate/serialization/ValDefSerializer.scala @@ -6,7 +6,7 @@ import sigmastate.serialization.OpCodes._ import scorex.util.Extensions._ import sigmastate.utils.{SigmaByteReader, SigmaByteWriter} import ValueSerializer._ -import sigmastate.util.safeNewArray +import sigma.util.safeNewArray import debox.cfor case class ValDefSerializer(override val opDesc: ValueCompanion) extends ValueSerializer[ValDef] { diff --git a/interpreter/shared/src/main/scala/sigmastate/serialization/transformers/SigmaTransformerSerializer.scala b/interpreter/shared/src/main/scala/sigmastate/serialization/transformers/SigmaTransformerSerializer.scala index 9cce78c64b..e7981bb725 100644 --- a/interpreter/shared/src/main/scala/sigmastate/serialization/transformers/SigmaTransformerSerializer.scala +++ b/interpreter/shared/src/main/scala/sigmastate/serialization/transformers/SigmaTransformerSerializer.scala @@ -3,7 +3,7 @@ package sigmastate.serialization.transformers import sigmastate.{SigmaTransformerCompanion, SigmaTransformer} import sigmastate.Values.{SigmaPropValue, SValue} import sigmastate.serialization.ValueSerializer -import sigmastate.util.safeNewArray +import sigma.util.safeNewArray import sigmastate.utils.SigmaByteWriter.{DataInfo, valuesItemInfo} import sigmastate.utils.{SigmaByteReader, SigmaByteWriter} import debox.cfor diff --git a/interpreter/shared/src/main/scala/sigmastate/trees.scala b/interpreter/shared/src/main/scala/sigmastate/trees.scala index 254aa7c317..bbefdf78b9 100644 --- a/interpreter/shared/src/main/scala/sigmastate/trees.scala +++ b/interpreter/shared/src/main/scala/sigmastate/trees.scala @@ -8,6 +8,7 @@ import scalan.ExactOrdering._ import scalan.OverloadHack.Overloaded1 import scalan.{ExactIntegral, ExactOrdering} import scorex.crypto.hash.{Blake2b256, CryptographicHash32, Sha256} +import sigma.VersionContext import sigmastate.ArithOp.OperationImpl import sigmastate.Operations._ import sigmastate.SCollection.{SByteArray, SIntArray} diff --git a/interpreter/shared/src/main/scala/sigmastate/utils/Helpers.scala b/interpreter/shared/src/main/scala/sigmastate/utils/Helpers.scala index 1b16ef05f9..0f9d4aae16 100644 --- a/interpreter/shared/src/main/scala/sigmastate/utils/Helpers.scala +++ b/interpreter/shared/src/main/scala/sigmastate/utils/Helpers.scala @@ -5,7 +5,7 @@ import io.circe.Decoder import org.ergoplatform.settings.ErgoAlgos import scalan.{OverloadHack, RType} import scorex.utils.Ints -import sigmastate.Environment +import sigma.Environment import sigmastate.eval.{CAnyValue, Colls, SigmaDsl} import sigmastate.basics.CryptoConstants.EcPointType import special.collection.Coll diff --git a/interpreter/shared/src/main/scala/sigmastate/utils/SigmaByteReader.scala b/interpreter/shared/src/main/scala/sigmastate/utils/SigmaByteReader.scala index 2faae121d8..00f900c741 100644 --- a/interpreter/shared/src/main/scala/sigmastate/utils/SigmaByteReader.scala +++ b/interpreter/shared/src/main/scala/sigmastate/utils/SigmaByteReader.scala @@ -6,7 +6,7 @@ import scorex.util.serialization.Reader import sigmastate.SType import sigmastate.Values.{SValue, Value} import sigmastate.serialization._ -import sigmastate.util.safeNewArray +import sigma.util.safeNewArray import debox.cfor import sigmastate.exceptions.DeserializeCallDepthExceeded diff --git a/interpreter/shared/src/test/scala/sigmastate/TestsBase.scala b/interpreter/shared/src/test/scala/sigmastate/TestsBase.scala index 4e40d91c23..57ecd5e5e8 100644 --- a/interpreter/shared/src/test/scala/sigmastate/TestsBase.scala +++ b/interpreter/shared/src/test/scala/sigmastate/TestsBase.scala @@ -1,8 +1,9 @@ package sigmastate import org.scalatest.matchers.should.Matchers -import sigmastate.Values.{SigmaPropValue, SigmaBoolean, ErgoTree} +import sigmastate.Values.{ErgoTree, SigmaBoolean, SigmaPropValue} import org.ergoplatform.ErgoTreePredef +import sigma.VersionTesting trait TestsBase extends Matchers with VersionTesting { /** Set this to true to enable debug console output in tests */ diff --git a/interpreter/shared/src/test/scala/sigmastate/lang/SigmaBuilderTest.scala b/interpreter/shared/src/test/scala/sigmastate/lang/SigmaBuilderTest.scala index 8fa3ad0304..393e69454b 100644 --- a/interpreter/shared/src/test/scala/sigmastate/lang/SigmaBuilderTest.scala +++ b/interpreter/shared/src/test/scala/sigmastate/lang/SigmaBuilderTest.scala @@ -4,6 +4,7 @@ import org.scalatest.matchers.should.Matchers import org.scalatest.propspec.AnyPropSpec import org.scalatestplus.scalacheck.ScalaCheckPropertyChecks import scalan.{Nullable, RType} +import sigma.{Environment, VersionContext} import sigmastate.Values._ import sigmastate._ import sigmastate.eval.Extensions.ArrayOps diff --git a/parsers/shared/src/test/scala/sigmastate/lang/LangTests.scala b/parsers/shared/src/test/scala/sigmastate/lang/LangTests.scala index 80ef976e1e..9fc7198543 100644 --- a/parsers/shared/src/test/scala/sigmastate/lang/LangTests.scala +++ b/parsers/shared/src/test/scala/sigmastate/lang/LangTests.scala @@ -74,7 +74,7 @@ trait LangTests extends Matchers with NegativeTesting { def ty(s: String): SType = SigmaParser.parseType(s) def assertSrcCtxForAllNodes(tree: SValue): Unit = { - import sigmastate.kiama.rewriting.Rewriter._ + import sigma.kiama.rewriting.Rewriter._ rewrite(everywherebu(rule[Any] { case node: SValue => withClue(s"Missing sourceContext for $node") { node.sourceContext.isDefined shouldBe true } diff --git a/sc/shared/src/main/scala/sigmastate/lang/SigmaBinder.scala b/sc/shared/src/main/scala/sigmastate/lang/SigmaBinder.scala index f30b25b44c..0bbad9d54a 100644 --- a/sc/shared/src/main/scala/sigmastate/lang/SigmaBinder.scala +++ b/sc/shared/src/main/scala/sigmastate/lang/SigmaBinder.scala @@ -1,9 +1,9 @@ package sigmastate.lang -import sigmastate.kiama.rewriting.CallbackRewriter import org.ergoplatform.ErgoAddressEncoder.NetworkPrefix import org.ergoplatform._ import scalan.Nullable +import sigma.kiama.rewriting.CallbackRewriter import sigmastate.Values._ import sigmastate._ import sigmastate.interpreter.Interpreter.ScriptEnv diff --git a/sc/shared/src/main/scala/sigmastate/lang/SigmaCompiler.scala b/sc/shared/src/main/scala/sigmastate/lang/SigmaCompiler.scala index b3575bcd8c..d37a037a58 100644 --- a/sc/shared/src/main/scala/sigmastate/lang/SigmaCompiler.scala +++ b/sc/shared/src/main/scala/sigmastate/lang/SigmaCompiler.scala @@ -2,7 +2,7 @@ package sigmastate.lang import fastparse.Parsed import fastparse.Parsed.Success -import sigmastate.kiama.rewriting.Rewriter.{everywherebu, rewrite, rule} +import sigma.kiama.rewriting.Rewriter.{everywherebu, rewrite, rule} import org.ergoplatform.ErgoAddressEncoder.NetworkPrefix import org.ergoplatform.Global import sigmastate.Values.{SValue, Value} diff --git a/sc/shared/src/test/scala/sigmastate/ErgoTreeSpecification.scala b/sc/shared/src/test/scala/sigmastate/ErgoTreeSpecification.scala index 20aabb1b00..8025060afc 100644 --- a/sc/shared/src/test/scala/sigmastate/ErgoTreeSpecification.scala +++ b/sc/shared/src/test/scala/sigmastate/ErgoTreeSpecification.scala @@ -5,9 +5,10 @@ import org.ergoplatform.validation.{ValidationException, ValidationRules} import org.ergoplatform.{ErgoAddressEncoder, ErgoBox, ErgoLikeContext, Self} import scalan.RType.asType import scalan.{Nullable, RType} +import sigma.VersionContext import sigmastate.SCollection.{SByteArray, checkValidFlatmap} import sigmastate.Values._ -import sigmastate.VersionContext._ +import sigma.VersionContext._ import sigmastate.eval.{CostingBox, Evaluation, Profiler} import sigmastate.exceptions.{CostLimitException, InterpreterException} import sigmastate.helpers.{ErgoLikeContextTesting, SigmaPPrint} diff --git a/sc/shared/src/test/scala/sigmastate/ScriptVersionSwitchSpecification.scala b/sc/shared/src/test/scala/sigmastate/ScriptVersionSwitchSpecification.scala index d73e81f56a..11bf2602e5 100644 --- a/sc/shared/src/test/scala/sigmastate/ScriptVersionSwitchSpecification.scala +++ b/sc/shared/src/test/scala/sigmastate/ScriptVersionSwitchSpecification.scala @@ -5,7 +5,7 @@ import org.ergoplatform._ import scorex.util.ModifierId import sigmastate.Values.ErgoTree.{DefaultHeader, updateVersionBits} import sigmastate.Values._ -import sigmastate.VersionContext.MaxSupportedScriptVersion +import sigma.VersionContext.MaxSupportedScriptVersion import sigmastate.eval._ import sigmastate.exceptions.InterpreterException import sigmastate.helpers.{ErgoLikeContextTesting, ErgoLikeTestInterpreter} diff --git a/sc/shared/src/test/scala/sigmastate/TypesSpecification.scala b/sc/shared/src/test/scala/sigmastate/TypesSpecification.scala index 6ae4bd2a21..d9432bbc96 100644 --- a/sc/shared/src/test/scala/sigmastate/TypesSpecification.scala +++ b/sc/shared/src/test/scala/sigmastate/TypesSpecification.scala @@ -1,5 +1,6 @@ package sigmastate +import sigma.Environment import sigmastate.SType.isValueOfType import sigmastate.eval.{CSigmaProp, CostingSigmaDslBuilder} import special.sigma.SigmaTestingData diff --git a/sc/shared/src/test/scala/sigmastate/eval/ErgoScriptTestkit.scala b/sc/shared/src/test/scala/sigmastate/eval/ErgoScriptTestkit.scala index 04230fdef9..b1902877e8 100644 --- a/sc/shared/src/test/scala/sigmastate/eval/ErgoScriptTestkit.scala +++ b/sc/shared/src/test/scala/sigmastate/eval/ErgoScriptTestkit.scala @@ -4,6 +4,7 @@ import org.ergoplatform.ErgoAddressEncoder.TestnetNetworkPrefix import org.ergoplatform.validation.ValidationSpecification import org.ergoplatform.{Context => _, _} import scalan.BaseCtxTests +import sigma.VersionContext import sigmastate.Values.{BigIntArrayConstant, EvaluatedValue, SValue, SigmaPropConstant, Value} import sigmastate.helpers.TestingHelpers._ import sigmastate.helpers.{ContextEnrichingTestProvingInterpreter, ErgoLikeContextTesting} @@ -12,7 +13,7 @@ import sigmastate.interpreter.{ContextExtension, ErgoTreeEvaluator} import sigmastate.lang.Terms.ValueOps import sigmastate.lang.{CompilerResult, CompilerSettings, LangTests, SigmaCompiler} import sigmastate.serialization.ErgoTreeSerializer.DefaultSerializer -import sigmastate.{AvlTreeData, CompilerTestsBase, SType, VersionContext} +import sigmastate.{AvlTreeData, CompilerTestsBase, SType} import special.sigma.{ContractsTestkit, Context => DContext} import scala.annotation.unused diff --git a/sc/shared/src/test/scala/sigmastate/serialization/DeserializationResilience.scala b/sc/shared/src/test/scala/sigmastate/serialization/DeserializationResilience.scala index 3a04397881..24bdbb8ca4 100644 --- a/sc/shared/src/test/scala/sigmastate/serialization/DeserializationResilience.scala +++ b/sc/shared/src/test/scala/sigmastate/serialization/DeserializationResilience.scala @@ -9,6 +9,7 @@ import scorex.crypto.authds.avltree.batch.{BatchAVLProver, Insert} import scorex.crypto.authds.{ADKey, ADValue} import scorex.crypto.hash.{Blake2b256, Digest32} import scorex.util.serialization.{Reader, VLQByteBufferReader} +import sigma.Environment import sigmastate.Values.{BlockValue, GetVarInt, IntConstant, SValue, SigmaBoolean, SigmaPropValue, Tuple, ValDef, ValUse} import sigmastate._ import sigmastate.basics.CryptoConstants @@ -18,7 +19,7 @@ import sigmastate.exceptions.{DeserializeCallDepthExceeded, InvalidTypePrefix, R import sigmastate.helpers.{CompilerTestingCommons, ErgoLikeContextTesting, ErgoLikeTestInterpreter} import sigmastate.interpreter.{ContextExtension, CostedProverResult} import sigmastate.serialization.OpCodes._ -import sigmastate.util.safeNewArray +import sigma.util.safeNewArray import sigmastate.utils.Helpers._ import sigmastate.utils.SigmaByteReader import sigmastate.utxo.SizeOf diff --git a/sc/shared/src/test/scala/sigmastate/utxo/SerializationRoundTripSpec.scala b/sc/shared/src/test/scala/sigmastate/utxo/SerializationRoundTripSpec.scala index 54ee4f4857..519a938160 100644 --- a/sc/shared/src/test/scala/sigmastate/utxo/SerializationRoundTripSpec.scala +++ b/sc/shared/src/test/scala/sigmastate/utxo/SerializationRoundTripSpec.scala @@ -9,7 +9,7 @@ import debox.{Buffer => DBuffer} import org.scalatest.matchers.should.Matchers import org.scalatest.propspec.AnyPropSpec import org.scalatestplus.scalacheck.ScalaCheckDrivenPropertyChecks -import sigmastate.util.{MaxArrayLength, safeNewArray} +import sigma.util.{MaxArrayLength, safeNewArray} class SerializationRoundTripSpec extends AnyPropSpec with ScalaCheckDrivenPropertyChecks diff --git a/sc/shared/src/test/scala/special/sigma/SigmaDslSpecification.scala b/sc/shared/src/test/scala/special/sigma/SigmaDslSpecification.scala index ead1af1873..812092d668 100644 --- a/sc/shared/src/test/scala/special/sigma/SigmaDslSpecification.scala +++ b/sc/shared/src/test/scala/special/sigma/SigmaDslSpecification.scala @@ -3,10 +3,10 @@ package special.sigma import java.math.BigInteger import org.ergoplatform._ import org.ergoplatform.settings.ErgoAlgos -import org.scalacheck.{Gen, Arbitrary} -import scalan.{ExactOrdering, RType, ExactIntegral, ExactNumeric} +import org.scalacheck.{Arbitrary, Gen} +import scalan.{ExactIntegral, ExactNumeric, ExactOrdering, RType} import scorex.crypto.authds.avltree.batch._ -import scorex.crypto.authds.{ADDigest, ADValue, ADKey} +import scorex.crypto.authds.{ADDigest, ADKey, ADValue} import scorex.crypto.hash.{Blake2b256, Digest32} import scalan.util.Extensions._ import sigmastate.utils.Extensions._ @@ -27,7 +27,7 @@ import sigmastate.utils.Helpers import sigmastate.utils.Helpers._ import sigmastate.helpers.TestingHelpers._ -import scala.util.{Try, Success, Failure} +import scala.util.{Failure, Success, Try} import OrderingOps._ import org.ergoplatform.ErgoBox.AdditionalRegisters import org.scalacheck.Arbitrary._ @@ -38,8 +38,10 @@ import scorex.util.ModifierId import sigmastate.basics.ProveDHTuple import sigmastate.interpreter._ import org.scalactic.source.Position +import sigma.VersionContext import sigmastate.helpers.SigmaPPrint import sigmastate.exceptions.GraphBuildingException + import scala.collection.compat.immutable.ArraySeq /** This suite tests every method of every SigmaDsl type to be equivalent to diff --git a/sc/shared/src/test/scala/special/sigma/SigmaDslStaginTests.scala b/sc/shared/src/test/scala/special/sigma/SigmaDslStaginTests.scala index 40e53bd860..97ee39d07a 100644 --- a/sc/shared/src/test/scala/special/sigma/SigmaDslStaginTests.scala +++ b/sc/shared/src/test/scala/special/sigma/SigmaDslStaginTests.scala @@ -5,7 +5,8 @@ import special.collection._ import scala.language.reflectiveCalls import scalan.{BaseCtxTests, BaseLiftableTests} -import sigmastate.{VersionContext, eval, TrivialProp} +import sigma.VersionContext +import sigmastate.{eval, TrivialProp} import sigmastate.eval.Extensions._ import sigmastate.eval._ diff --git a/sc/shared/src/test/scala/special/sigma/SigmaDslTesting.scala b/sc/shared/src/test/scala/special/sigma/SigmaDslTesting.scala index 371036fa0d..0f1e84f5b7 100644 --- a/sc/shared/src/test/scala/special/sigma/SigmaDslTesting.scala +++ b/sc/shared/src/test/scala/special/sigma/SigmaDslTesting.scala @@ -19,6 +19,7 @@ import scalan.util.BenchmarkUtil import scalan.util.CollectionUtil._ import scalan.util.Extensions._ import scalan.util.StringUtil.StringUtilExtensions +import sigma.VersionContext import sigmastate.SType.AnyOps import sigmastate.Values.{ByteArrayConstant, Constant, ConstantNode, ErgoTree, IntConstant, SValue} import sigmastate.basics.DLogProtocol.{DLogProverInput, ProveDlog} @@ -34,7 +35,7 @@ import sigmastate.serialization.ValueSerializer import sigmastate.serialization.generators.ObjectGenerators import sigmastate.utils.Helpers._ import sigmastate.utxo.{DeserializeContext, DeserializeRegister, GetVar, OptionGet} -import sigmastate.{SOption, SSigmaProp, SType, SigmaLeaf, VersionContext, eval} +import sigmastate.{SOption, SSigmaProp, SType, SigmaLeaf, eval} import special.collection.{Coll, CollType} import java.util diff --git a/sdk/shared/src/main/scala/org/ergoplatform/sdk/AppkitProvingInterpreter.scala b/sdk/shared/src/main/scala/org/ergoplatform/sdk/AppkitProvingInterpreter.scala index dc289ba4e6..f745103cab 100644 --- a/sdk/shared/src/main/scala/org/ergoplatform/sdk/AppkitProvingInterpreter.scala +++ b/sdk/shared/src/main/scala/org/ergoplatform/sdk/AppkitProvingInterpreter.scala @@ -9,6 +9,7 @@ import org.ergoplatform.sdk.wallet.protocol.context.{BlockchainStateContext, Tra import org.ergoplatform.sdk.wallet.secrets.ExtendedSecretKey import org.ergoplatform.validation.ValidationRules import scalan.util.Extensions.LongOps +import sigma.VersionContext import sigmastate.Values.SigmaBoolean import sigmastate.basics.DLogProtocol.{DLogProverInput, ProveDlog} import sigmastate.basics.{DiffieHellmanTupleProverInput, SigmaProtocolPrivateInput} @@ -16,7 +17,7 @@ import sigmastate.interpreter.Interpreter.{ReductionResult, estimateCryptoVerify import sigmastate.interpreter._ import sigmastate.serialization.SigmaSerializer import sigmastate.utils.{SigmaByteReader, SigmaByteWriter} -import sigmastate.{AvlTreeData, VersionContext} +import sigmastate.{AvlTreeData} import java.util import java.util.{Objects, List => JList} diff --git a/sdk/shared/src/main/scala/org/ergoplatform/sdk/ContractTemplate.scala b/sdk/shared/src/main/scala/org/ergoplatform/sdk/ContractTemplate.scala index c24a9fb4b3..4320555628 100644 --- a/sdk/shared/src/main/scala/org/ergoplatform/sdk/ContractTemplate.scala +++ b/sdk/shared/src/main/scala/org/ergoplatform/sdk/ContractTemplate.scala @@ -13,7 +13,7 @@ import sigmastate.eval.{Colls, _} import sigmastate.exceptions.SerializerException import sigmastate.lang.{DeserializationSigmaBuilder, StdSigmaBuilder} import sigmastate.serialization._ -import sigmastate.util.safeNewArray +import sigma.util.safeNewArray import sigmastate.utils.{SigmaByteReader, SigmaByteWriter} import java.util.Objects From 9d4d53cae1c82b30260a18aa115bc13cd40f6fd5 Mon Sep 17 00:00:00 2001 From: Alexander Slesarenko Date: Tue, 22 Aug 2023 18:10:58 +0200 Subject: [PATCH 06/37] minimize-modules: replaced special.collection -> sigma.collection and special.sigma -> sigma --- .../kiama/util/Collections.scala | 2 +- .../kiama/util/Collections.scala | 2 +- .../CoreLibReflection.scala | 44 ++---------------- .../scala/{special => }/sigma/SigmaDsl.scala | 6 +-- .../main/scala/{special => sigma}/Types.scala | 9 ++-- .../collection/CollType.scala | 2 +- .../{special => sigma}/collection/Colls.scala | 2 +- .../collection/CollsOverArrays.scala | 2 +- .../collection/Extensions.scala | 2 +- .../collection/package.scala | 2 +- .../scala/{special => }/sigma/package.scala | 1 - .../scala/{special => sigma}/TypesTests.scala | 8 ++-- .../collections/CollGens.scala | 4 +- .../collections/CollsTests.scala | 14 +++--- .../src/main/scala/sigmastate/Platform.scala | 8 ++-- .../scala/sigmastate/crypto/Platform.scala | 4 +- .../src/main/scala/sigmastate/Platform.scala | 8 ++-- .../scala/sigmastate/crypto/Platform.scala | 4 +- .../scala/org/ergoplatform/ErgoAddress.scala | 2 +- .../main/scala/org/ergoplatform/ErgoBox.scala | 2 +- .../org/ergoplatform/ErgoBoxCandidate.scala | 4 +- .../org/ergoplatform/ErgoLikeContext.scala | 11 +++-- .../org/ergoplatform/dsl/AvlTreeHelpers.scala | 4 +- .../org/ergoplatform/settings/ErgoAlgos.scala | 2 +- .../main/scala/sigmastate/AvlTreeData.scala | 2 +- .../scala/sigmastate/DataValueComparer.scala | 4 +- .../sigmastate/InterpreterReflection.scala | 10 ++--- .../src/main/scala/sigmastate/Values.scala | 4 +- .../sigmastate/basics/DLogProtocol.scala | 2 +- .../basics/DiffieHellmanTupleProtocol.scala | 2 +- .../basics/SigmaProtocolFunctions.scala | 3 +- .../scala/sigmastate/eval/BigIntegerOps.scala | 4 +- .../sigmastate/eval/CostingDataContext.scala | 8 ++-- .../scala/sigmastate/eval/Evaluation.scala | 8 ++-- .../scala/sigmastate/eval/Extensions.scala | 4 +- .../main/scala/sigmastate/eval/package.scala | 6 +-- .../interpreter/ErgoTreeEvaluator.scala | 8 ++-- .../sigmastate/interpreter/Interpreter.scala | 2 +- .../interpreter/InterpreterContext.scala | 7 ++- .../interpreter/ProverInterpreter.scala | 2 +- .../scala/sigmastate/lang/SigmaBuilder.scala | 4 +- .../serialization/DataSerializer.scala | 4 +- .../src/main/scala/sigmastate/trees.scala | 6 +-- .../src/main/scala/sigmastate/types.scala | 6 +-- .../scala/sigmastate/utils/Extensions.scala | 2 +- .../main/scala/sigmastate/utils/Helpers.scala | 4 +- .../scala/sigmastate/utxo/transformers.scala | 8 ++-- .../SigmaProtocolSpecification.scala | 2 +- .../scala/sigmastate/eval/BasicOpsTests.scala | 2 +- .../helpers/ErgoLikeContextTesting.scala | 4 +- .../sigmastate/helpers/TestingHelpers.scala | 4 +- .../sigmastate/lang/SigmaBuilderTest.scala | 2 +- .../ConstantSerializerSpecification.scala | 2 +- .../DataSerializerSpecification.scala | 2 +- .../generators/ObjectGenerators.scala | 6 +-- .../special/sigma/ContractsTestkit.scala | 4 +- .../special/sigma/SigmaTestingData.scala | 6 +-- .../scala/sigmastate/lang/LangTests.scala | 4 +- .../scala/sigmastate/ErgoTreeBenchmarks.scala | 2 +- .../sigmastate/ReflectionGenerator.scala | 4 +- .../sigmastate/helpers/SigmaPPrintSpec.scala | 4 +- .../special/collections/BasicBenchmarks.scala | 2 +- .../special/collections/BenchmarkGens.scala | 4 +- .../special/collections/BufferBenchmark.scala | 2 +- .../special/collections/CollBenchmark.scala | 6 +-- .../special/collections/MapBenchmark.scala | 2 +- .../special/collections/SymBenchmark.scala | 2 +- .../org/ergoplatform/dsl/ContractSpec.scala | 2 +- .../org/ergoplatform/dsl/ContractSyntax.scala | 2 +- .../ergoplatform/dsl/ErgoContractSpec.scala | 2 +- .../main/scala/scalan/GraphIRReflection.scala | 45 +++++++++++++++++-- sc/shared/src/main/scala/scalan/Library.scala | 2 +- .../scala/sigmastate/eval/GraphBuilding.scala | 4 +- .../scala/sigmastate/eval/SigmaLibrary.scala | 4 +- .../scala/special/collection/CollsUnit.scala | 4 +- .../special/collection/impl/CollsImpl.scala | 12 +++-- .../scala/special/sigma/SigmaDslUnit.scala | 2 +- .../special/sigma/impl/SigmaDslImpl.scala | 24 +++++----- .../sigma/wrappers/WrappersModule.scala | 2 +- .../scala/special/wrappers/WrappersSpec.scala | 0 .../ErgoAddressSpecification.scala | 2 +- .../ErgoLikeTransactionSpec.scala | 4 +- .../ergoplatform/dsl/TestContractSpec.scala | 2 +- .../src/test/scala/scalan/TestContexts.scala | 2 +- .../sigmastate/ErgoTreeSpecification.scala | 4 +- .../ScriptVersionSwitchSpecification.scala | 2 +- .../SoftForkabilitySpecification.scala | 2 +- .../scala/sigmastate/TypesSpecification.scala | 2 +- .../sigmastate/eval/ErgoScriptTestkit.scala | 2 +- .../helpers/CompilerTestingCommons.scala | 4 +- .../sigmastate/helpers/SigmaPPrint.scala | 4 +- .../utxo/AVLTreeScriptsSpecification.scala | 4 +- .../utxo/ContextEnrichingSpecification.scala | 2 +- .../UsingContextPropertiesSpecification.scala | 2 +- .../utxo/examples/AssetsAtomicExchange.scala | 4 +- .../AssetsAtomicExchangeErgoTests.scala | 2 +- .../utxo/examples/AssetsPartialFilling.scala | 4 +- .../utxo/examples/CrowdFunding.scala | 2 +- .../examples/DummyExamplesSpecification.scala | 4 +- .../ExecuteFromExamplesSpecification.scala | 2 +- ...racleDataInputsExamplesSpecification.scala | 4 +- .../OracleExamplesSpecification.scala | 2 +- .../OracleTokenExamplesSpecification.scala | 4 +- .../RevenueSharingExamplesSpecification.scala | 2 +- .../collections/CollsStagingTests.scala | 6 +-- .../DataValueComparerSpecification.scala | 4 +- .../test/scala/special/sigma/LoopTests.scala | 2 +- .../special/sigma/SigmaDslSpecification.scala | 24 +++++----- .../special/sigma/SigmaDslStaginTests.scala | 25 +++++------ .../scala/special/sigma/SigmaDslTesting.scala | 6 +-- .../org/ergoplatform/sdk/js/AvlTree.scala | 2 +- .../ergoplatform/sdk/js/GroupElement.scala | 2 +- .../org/ergoplatform/sdk/js/Header.scala | 2 +- .../scala/org/ergoplatform/sdk/js/Isos.scala | 13 +++--- .../org/ergoplatform/sdk/js/PreHeader.scala | 2 +- .../org/ergoplatform/sdk/js/SigmaProp.scala | 2 +- .../scala/org/ergoplatform/sdk/js/Type.scala | 20 ++++----- .../scala/org/ergoplatform/sdk/js/Value.scala | 30 ++++++------- .../org/ergoplatform/sdk/js/IsosSpec.scala | 5 +-- .../org/ergoplatform/sdk/js/ValueSpec.scala | 2 +- .../ergoplatform/sdk/BlockchainContext.scala | 4 +- .../ergoplatform/sdk/DataJsonEncoder.scala | 4 +- .../org/ergoplatform/sdk/Extensions.scala | 4 +- .../org/ergoplatform/sdk/JavaHelpers.scala | 22 ++++----- .../org/ergoplatform/sdk/JsonCodecs.scala | 10 ++--- .../org/ergoplatform/sdk/ProverBuilder.scala | 2 +- .../org/ergoplatform/sdk/SigmaProver.scala | 2 +- .../sdk/UnsignedTransactionBuilder.scala | 6 +-- .../org/ergoplatform/sdk/utils/Zero.scala | 6 +-- .../context/BlockchainStateContext.scala | 6 +-- .../sdk/ContractTemplateSpecification.scala | 2 +- .../sdk/DataJsonEncoderSpecification.scala | 2 +- .../org/ergoplatform/sdk/ExtensionsSpec.scala | 4 +- .../sdk/JsonSerializationSpec.scala | 6 +-- .../sdk/multisig/SigningSpec.scala | 2 +- 135 files changed, 359 insertions(+), 368 deletions(-) rename common/shared/src/main/scala-2.11/{sigmastate => sigma}/kiama/util/Collections.scala (97%) rename common/shared/src/main/scala-2.12/{sigmastate => sigma}/kiama/util/Collections.scala (97%) rename common/shared/src/main/scala/{special => sigma}/CoreLibReflection.scala (90%) rename common/shared/src/main/scala/{special => }/sigma/SigmaDsl.scala (99%) rename common/shared/src/main/scala/{special => sigma}/Types.scala (96%) rename common/shared/src/main/scala/{special => sigma}/collection/CollType.scala (96%) rename common/shared/src/main/scala/{special => sigma}/collection/Colls.scala (99%) rename common/shared/src/main/scala/{special => sigma}/collection/CollsOverArrays.scala (99%) rename common/shared/src/main/scala/{special => sigma}/collection/Extensions.scala (98%) rename common/shared/src/main/scala/{special => sigma}/collection/package.scala (97%) rename common/shared/src/main/scala/{special => }/sigma/package.scala (98%) rename common/shared/src/test/scala/{special => sigma}/TypesTests.scala (77%) rename common/shared/src/test/scala/{special => sigma}/collections/CollGens.scala (98%) rename common/shared/src/test/scala/{special => sigma}/collections/CollsTests.scala (97%) rename {common => sc}/shared/src/main/scala/special/wrappers/WrappersSpec.scala (100%) diff --git a/common/shared/src/main/scala-2.11/sigmastate/kiama/util/Collections.scala b/common/shared/src/main/scala-2.11/sigma/kiama/util/Collections.scala similarity index 97% rename from common/shared/src/main/scala-2.11/sigmastate/kiama/util/Collections.scala rename to common/shared/src/main/scala-2.11/sigma/kiama/util/Collections.scala index 347a996452..476ea45dbd 100644 --- a/common/shared/src/main/scala-2.11/sigmastate/kiama/util/Collections.scala +++ b/common/shared/src/main/scala-2.11/sigma/kiama/util/Collections.scala @@ -8,7 +8,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -package sigmastate.kiama +package sigma.kiama package util object Collections { diff --git a/common/shared/src/main/scala-2.12/sigmastate/kiama/util/Collections.scala b/common/shared/src/main/scala-2.12/sigma/kiama/util/Collections.scala similarity index 97% rename from common/shared/src/main/scala-2.12/sigmastate/kiama/util/Collections.scala rename to common/shared/src/main/scala-2.12/sigma/kiama/util/Collections.scala index 347a996452..476ea45dbd 100644 --- a/common/shared/src/main/scala-2.12/sigmastate/kiama/util/Collections.scala +++ b/common/shared/src/main/scala-2.12/sigma/kiama/util/Collections.scala @@ -8,7 +8,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -package sigmastate.kiama +package sigma.kiama package util object Collections { diff --git a/common/shared/src/main/scala/special/CoreLibReflection.scala b/common/shared/src/main/scala/sigma/CoreLibReflection.scala similarity index 90% rename from common/shared/src/main/scala/special/CoreLibReflection.scala rename to common/shared/src/main/scala/sigma/CoreLibReflection.scala index 53c8d34ddf..66f179ae57 100644 --- a/common/shared/src/main/scala/special/CoreLibReflection.scala +++ b/common/shared/src/main/scala/sigma/CoreLibReflection.scala @@ -1,11 +1,10 @@ -package special +package sigma import scalan.RType import scalan.reflection.CommonReflection.registerClassEntry import scalan.reflection._ -import special.collection.{CollBuilder, Coll} -import special.sigma._ -import special.wrappers.{OptionWrapSpec, RTypeWrapSpec} +import sigma._ +import sigma.collection._ /** Registrations of reflection metadata for core-lib module. * For each class of this module that needs reflection metadata, @@ -34,7 +33,7 @@ object CoreLibReflection { ) } - { val clazz = classOf[special.sigma.BigInt] + { val clazz = classOf[sigma.BigInt] val paramTypes = Array[Class[_]](clazz) registerClassEntry(clazz, methods = Map( @@ -83,32 +82,6 @@ object CoreLibReflection { ) } - { val clazz = classOf[OptionWrapSpec] - registerClassEntry(clazz, - methods = Map( - mkMethod(clazz, "getOrElse", Array[Class[_]](classOf[Option[_]], classOf[Function0[_]])) { (obj, args) => - val opt = args(0).asInstanceOf[Option[Any]] - val defaultFunc = args(1).asInstanceOf[Function0[Any]] - obj.asInstanceOf[OptionWrapSpec].getOrElse(opt, defaultFunc()) - }, - mkMethod(clazz, "isDefined", Array[Class[_]](classOf[Option[_]])) { (obj, args) => - obj.asInstanceOf[OptionWrapSpec].isDefined(args(0).asInstanceOf[Option[_]]) - }, - mkMethod(clazz, "filter", Array[Class[_]](classOf[Option[_]], classOf[Function1[_,_]])) { (obj, args) => - obj.asInstanceOf[OptionWrapSpec].filter( - args(0).asInstanceOf[Option[Any]], args(1).asInstanceOf[Any => Boolean]) - }, - mkMethod(clazz, "map", Array[Class[_]](classOf[Option[_]], classOf[Function1[_,_]])) { (obj, args) => - obj.asInstanceOf[OptionWrapSpec].map( - args(0).asInstanceOf[Option[Any]], args(1).asInstanceOf[Any => Any]) - }, - mkMethod(clazz, "get", Array[Class[_]](classOf[Option[_]])) { (obj, args) => - obj.asInstanceOf[OptionWrapSpec].get(args(0).asInstanceOf[Option[_]]) - } - ) - ) - } - { val clazz = classOf[Coll[_]] registerClassEntry(clazz, methods = Map( @@ -431,13 +404,4 @@ object CoreLibReflection { ) } - { val clazz = classOf[RTypeWrapSpec] - registerClassEntry(clazz, - methods = Map( - mkMethod(clazz, "name", Array[Class[_]](classOf[RType[_]])) { (obj, args) => - obj.asInstanceOf[RTypeWrapSpec].name(args(0).asInstanceOf[RType[_]]) - } - ) - ) - } } diff --git a/common/shared/src/main/scala/special/sigma/SigmaDsl.scala b/common/shared/src/main/scala/sigma/SigmaDsl.scala similarity index 99% rename from common/shared/src/main/scala/special/sigma/SigmaDsl.scala rename to common/shared/src/main/scala/sigma/SigmaDsl.scala index 325aaa444a..7bcaa20fd7 100644 --- a/common/shared/src/main/scala/special/sigma/SigmaDsl.scala +++ b/common/shared/src/main/scala/sigma/SigmaDsl.scala @@ -1,8 +1,8 @@ -package special.sigma +package sigma import java.math.BigInteger -import special.collection._ +import sigma.collection._ import scalan._ import scorex.crypto.authds.{ADDigest, ADValue} import scorex.crypto.authds.avltree.batch.Operation @@ -694,7 +694,7 @@ trait Context { * @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 `sigmastate.eval.InvalidType` exception when the type of the variable value is * different from cT. */ def getVar[T](id: Byte)(implicit cT: RType[T]): Option[T] diff --git a/common/shared/src/main/scala/special/Types.scala b/common/shared/src/main/scala/sigma/Types.scala similarity index 96% rename from common/shared/src/main/scala/special/Types.scala rename to common/shared/src/main/scala/sigma/Types.scala index 5b37d57d4e..0ce8785989 100644 --- a/common/shared/src/main/scala/special/Types.scala +++ b/common/shared/src/main/scala/sigma/Types.scala @@ -1,10 +1,11 @@ -package special +package sigma -import scalan.util.CollectionUtil import scalan.RType -import scala.reflect.ClassTag -import special.collection.Coll import scalan.RType.SomeType +import scalan.util.CollectionUtil +import sigma.collection.Coll + +import scala.reflect.ClassTag object Types { /** Generic representation of tuples values. */ diff --git a/common/shared/src/main/scala/special/collection/CollType.scala b/common/shared/src/main/scala/sigma/collection/CollType.scala similarity index 96% rename from common/shared/src/main/scala/special/collection/CollType.scala rename to common/shared/src/main/scala/sigma/collection/CollType.scala index 1061742705..81a8b2fb16 100644 --- a/common/shared/src/main/scala/special/collection/CollType.scala +++ b/common/shared/src/main/scala/sigma/collection/CollType.scala @@ -1,4 +1,4 @@ -package special.collection +package sigma.collection import scalan.RType diff --git a/common/shared/src/main/scala/special/collection/Colls.scala b/common/shared/src/main/scala/sigma/collection/Colls.scala similarity index 99% rename from common/shared/src/main/scala/special/collection/Colls.scala rename to common/shared/src/main/scala/sigma/collection/Colls.scala index 027297de18..c1c00ed67a 100644 --- a/common/shared/src/main/scala/special/collection/Colls.scala +++ b/common/shared/src/main/scala/sigma/collection/Colls.scala @@ -1,4 +1,4 @@ -package special.collection +package sigma.collection import scalan._ diff --git a/common/shared/src/main/scala/special/collection/CollsOverArrays.scala b/common/shared/src/main/scala/sigma/collection/CollsOverArrays.scala similarity index 99% rename from common/shared/src/main/scala/special/collection/CollsOverArrays.scala rename to common/shared/src/main/scala/sigma/collection/CollsOverArrays.scala index fc6f0e3767..1593bac573 100644 --- a/common/shared/src/main/scala/special/collection/CollsOverArrays.scala +++ b/common/shared/src/main/scala/sigma/collection/CollsOverArrays.scala @@ -1,4 +1,4 @@ -package special.collection +package sigma.collection import java.util import scalan._ // required diff --git a/common/shared/src/main/scala/special/collection/Extensions.scala b/common/shared/src/main/scala/sigma/collection/Extensions.scala similarity index 98% rename from common/shared/src/main/scala/special/collection/Extensions.scala rename to common/shared/src/main/scala/sigma/collection/Extensions.scala index 4256d91336..e08adca1b6 100644 --- a/common/shared/src/main/scala/special/collection/Extensions.scala +++ b/common/shared/src/main/scala/sigma/collection/Extensions.scala @@ -1,4 +1,4 @@ -package special.collection +package sigma.collection import debox.cfor import scorex.util.encode.Base16 diff --git a/common/shared/src/main/scala/special/collection/package.scala b/common/shared/src/main/scala/sigma/collection/package.scala similarity index 97% rename from common/shared/src/main/scala/special/collection/package.scala rename to common/shared/src/main/scala/sigma/collection/package.scala index a683abd7a0..1e89a7fbf5 100644 --- a/common/shared/src/main/scala/special/collection/package.scala +++ b/common/shared/src/main/scala/sigma/collection/package.scala @@ -1,4 +1,4 @@ -package special +package sigma import scalan.RType diff --git a/common/shared/src/main/scala/special/sigma/package.scala b/common/shared/src/main/scala/sigma/package.scala similarity index 98% rename from common/shared/src/main/scala/special/sigma/package.scala rename to common/shared/src/main/scala/sigma/package.scala index a81b27a45b..4eaee24aff 100644 --- a/common/shared/src/main/scala/special/sigma/package.scala +++ b/common/shared/src/main/scala/sigma/package.scala @@ -1,4 +1,3 @@ -package special import java.math.BigInteger import scalan.RType diff --git a/common/shared/src/test/scala/special/TypesTests.scala b/common/shared/src/test/scala/sigma/TypesTests.scala similarity index 77% rename from common/shared/src/test/scala/special/TypesTests.scala rename to common/shared/src/test/scala/sigma/TypesTests.scala index b0c6ce5808..3601db8659 100644 --- a/common/shared/src/test/scala/special/TypesTests.scala +++ b/common/shared/src/test/scala/sigma/TypesTests.scala @@ -1,8 +1,8 @@ -package special +package sigma +import scalan.RType._ import scalan.{BaseTests, RType} -import RType._ -import Types._ +import sigma.Types._ class TypesTests extends BaseTests { @@ -10,7 +10,7 @@ class TypesTests extends BaseTests { def test[A](t: RType[A], n: String) = { t.name shouldBe n } - test(tupleRType(Array(IntType, LongType, RType[(Byte, special.sigma.BigInt)], RType[Option[Boolean]])), + test(tupleRType(Array(IntType, LongType, RType[(Byte, sigma.BigInt)], RType[Option[Boolean]])), "(Int, Long, (Byte, BigInt), Option[Boolean])") } diff --git a/common/shared/src/test/scala/special/collections/CollGens.scala b/common/shared/src/test/scala/sigma/collections/CollGens.scala similarity index 98% rename from common/shared/src/test/scala/special/collections/CollGens.scala rename to common/shared/src/test/scala/sigma/collections/CollGens.scala index 858ce9f3f4..c8fdb3094f 100644 --- a/common/shared/src/test/scala/special/collections/CollGens.scala +++ b/common/shared/src/test/scala/sigma/collections/CollGens.scala @@ -1,10 +1,10 @@ -package special.collections +package sigma.collections import org.scalacheck.util.Buildable import org.scalacheck.{Arbitrary, Gen} import scalan._ import scalan.RType -import special.collection.{Coll, CollBuilder, CollOverArrayBuilder, PairColl} +import sigma.collection.{Coll, CollBuilder, CollOverArrayBuilder, PairColl} import spire.scalacompat.BuilderCompat import scala.collection.mutable import scala.collection.mutable.ArrayBuffer diff --git a/common/shared/src/test/scala/special/collections/CollsTests.scala b/common/shared/src/test/scala/sigma/collections/CollsTests.scala similarity index 97% rename from common/shared/src/test/scala/special/collections/CollsTests.scala rename to common/shared/src/test/scala/sigma/collections/CollsTests.scala index 2c7484193b..a4d2fb3af4 100644 --- a/common/shared/src/test/scala/special/collections/CollsTests.scala +++ b/common/shared/src/test/scala/sigma/collections/CollsTests.scala @@ -1,4 +1,4 @@ -package special.collections +package sigma.collections import org.scalacheck.Gen import org.scalatest.exceptions.TestFailedException @@ -7,13 +7,13 @@ import org.scalatest.propspec.AnyPropSpec import org.scalatestplus.scalacheck.ScalaCheckPropertyChecks import scalan._ import sigma.{VersionContext, VersionTestingProperty} -import special.collection.{Coll, CollOverArray, PairOfCols} +import sigma.collection.{Coll, CollOverArray, PairOfCols} import scala.language.{existentials} class CollsTests extends AnyPropSpec with ScalaCheckPropertyChecks with Matchers with CollGens with VersionTestingProperty { testSuite => import Gen._ - import special.collection.Extensions._ + import sigma.collection.Extensions._ def squared[A](f: A => A): ((A, A)) => (A, A) = (p: (A, A)) => (f(p._1), f(p._2)) @@ -491,8 +491,8 @@ class CollsTests extends AnyPropSpec with ScalaCheckPropertyChecks with Matchers /* TODO: simplify the above code * match-case removal gives the following compilation error: type mismatch; - found : special.collection.PairColl[_$1(in value res),_$2(in value res)] where type _$2(in value res), type _$1(in value res) - required: special.collection.Coll[(_$1(in method getSuperGen), _$2(in method getSuperGen))] + found : sigma.collection.PairColl[_$1(in value res),_$2(in value res)] where type _$2(in value res), type _$1(in value res) + required: sigma.collection.Coll[(_$1(in method getSuperGen), _$2(in method getSuperGen))] val res = col1.unionSet(col1) */ } @@ -511,8 +511,8 @@ class CollsTests extends AnyPropSpec with ScalaCheckPropertyChecks with Matchers /* TODO: simplify the above code * match-case removal gives the following compilation error: type mismatch; - found : special.collection.PairColl[_$1(in value res),_$2(in value res)] where type _$2(in value res), type _$1(in value res) - required: special.collection.Coll[(_$1(in method getSuperGen), _$2(in method getSuperGen))] + found : sigma.collection.PairColl[_$1(in value res),_$2(in value res)] where type _$2(in value res), type _$1(in value res) + required: sigma.collection.Coll[(_$1(in method getSuperGen), _$2(in method getSuperGen))] val res = col.diff(col) */ builder.replicate(2, 10).diff(builder.replicate(1, 10)).toArray shouldBe Array(10) diff --git a/interpreter/js/src/main/scala/sigmastate/Platform.scala b/interpreter/js/src/main/scala/sigmastate/Platform.scala index de3f0a3b7f..4defdc896b 100644 --- a/interpreter/js/src/main/scala/sigmastate/Platform.scala +++ b/interpreter/js/src/main/scala/sigmastate/Platform.scala @@ -6,8 +6,8 @@ import sigma.VersionContext import sigmastate.Values.{Constant, FalseLeaf, SigmaBoolean, TrueLeaf} import sigmastate.eval.{Evaluation, SigmaDsl} import sigmastate.lang.SigmaBuilder -import special.collection.Coll -import special.sigma.{AnyValue, AvlTree, GroupElement, SigmaProp} +import sigma.collection.Coll +import sigma.{AnyValue, AvlTree, GroupElement, SigmaProp} import java.math.BigInteger @@ -32,7 +32,7 @@ object Platform { case v: Int => Nullable(mkConstant[SInt.type](v, SInt)) case v: Long => Nullable(mkConstant[SLong.type](v, SLong)) case v: BigInteger => Nullable(mkConstant[SBigInt.type](SigmaDsl.BigInt(v), SBigInt)) - case n: special.sigma.BigInt => Nullable(mkConstant[SBigInt.type](n, SBigInt)) + case n: sigma.BigInt => Nullable(mkConstant[SBigInt.type](n, SBigInt)) case ge: GroupElement => Nullable(mkConstant[SGroupElement.type](ge, SGroupElement)) case b: Boolean => Nullable(if (b) TrueLeaf else FalseLeaf) case v: String => Nullable(mkConstant[SString.type](v, SString)) @@ -47,7 +47,7 @@ object Platform { // this case is added in v5.0 and it can be useful when the box value comes from a // register or a context variable is passed to SubstConstants. - case b: special.sigma.Box => + case b: sigma.Box => if (VersionContext.current.isJitActivated) Nullable(mkConstant[SBox.type](b, SBox)) else diff --git a/interpreter/js/src/main/scala/sigmastate/crypto/Platform.scala b/interpreter/js/src/main/scala/sigmastate/crypto/Platform.scala index ba5460e517..61d4ed9cfb 100644 --- a/interpreter/js/src/main/scala/sigmastate/crypto/Platform.scala +++ b/interpreter/js/src/main/scala/sigmastate/crypto/Platform.scala @@ -3,8 +3,8 @@ package sigmastate.crypto import scalan.RType import scorex.util.encode.Base16 import sigmastate._ -import special.collection.Coll -import special.sigma._ +import sigma.collection.Coll +import sigma._ import java.math.BigInteger import scala.scalajs.js diff --git a/interpreter/jvm/src/main/scala/sigmastate/Platform.scala b/interpreter/jvm/src/main/scala/sigmastate/Platform.scala index b29941b6d4..e4b1e86ad1 100644 --- a/interpreter/jvm/src/main/scala/sigmastate/Platform.scala +++ b/interpreter/jvm/src/main/scala/sigmastate/Platform.scala @@ -6,8 +6,8 @@ import sigma.VersionContext import sigmastate.Values.{Constant, FalseLeaf, SigmaBoolean, TrueLeaf} import sigmastate.eval.{Evaluation, SigmaDsl} import sigmastate.lang.SigmaBuilder -import special.collection.Coll -import special.sigma.{AvlTree, GroupElement, SigmaProp} +import sigma.collection.Coll +import sigma.{AvlTree, GroupElement, SigmaProp} import java.math.BigInteger @@ -32,7 +32,7 @@ object Platform { case v: Int => Nullable(mkConstant[SInt.type](v, SInt)) case v: Long => Nullable(mkConstant[SLong.type](v, SLong)) case v: BigInteger => Nullable(mkConstant[SBigInt.type](SigmaDsl.BigInt(v), SBigInt)) - case n: special.sigma.BigInt => Nullable(mkConstant[SBigInt.type](n, SBigInt)) + case n: sigma.BigInt => Nullable(mkConstant[SBigInt.type](n, SBigInt)) case ge: GroupElement => Nullable(mkConstant[SGroupElement.type](ge, SGroupElement)) case b: Boolean => Nullable(if (b) TrueLeaf else FalseLeaf) case v: String => Nullable(mkConstant[SString.type](v, SString)) @@ -47,7 +47,7 @@ object Platform { // this case is added in v5.0 and it can be useful when the box value comes from a // register or a context variable is passed to SubstConstants. - case b: special.sigma.Box => + case b: sigma.Box => if (VersionContext.current.isJitActivated) Nullable(mkConstant[SBox.type](b, SBox)) else diff --git a/interpreter/jvm/src/main/scala/sigmastate/crypto/Platform.scala b/interpreter/jvm/src/main/scala/sigmastate/crypto/Platform.scala index 3b74ba4714..c79cf8c59c 100644 --- a/interpreter/jvm/src/main/scala/sigmastate/crypto/Platform.scala +++ b/interpreter/jvm/src/main/scala/sigmastate/crypto/Platform.scala @@ -10,8 +10,8 @@ import scalan.RType import java.math.BigInteger import sigmastate._ import sigmastate.basics.BcDlogGroup -import special.collection.Coll -import special.sigma._ +import sigma.collection.Coll +import sigma._ import java.text.Normalizer.Form.NFKD import java.text.Normalizer diff --git a/interpreter/shared/src/main/scala/org/ergoplatform/ErgoAddress.scala b/interpreter/shared/src/main/scala/org/ergoplatform/ErgoAddress.scala index 6d6371494b..a821b4ef9b 100644 --- a/interpreter/shared/src/main/scala/org/ergoplatform/ErgoAddress.scala +++ b/interpreter/shared/src/main/scala/org/ergoplatform/ErgoAddress.scala @@ -10,7 +10,7 @@ import sigmastate.basics.DLogProtocol.{ProveDlogProp, ProveDlog} import sigmastate.exceptions.SigmaException import sigmastate.serialization._ import sigmastate.utxo.{DeserializeContext, Slice} -import special.collection.Coll +import sigma.collection.Coll import scala.util.Try diff --git a/interpreter/shared/src/main/scala/org/ergoplatform/ErgoBox.scala b/interpreter/shared/src/main/scala/org/ergoplatform/ErgoBox.scala index 9d373fb36a..b5ad85458c 100644 --- a/interpreter/shared/src/main/scala/org/ergoplatform/ErgoBox.scala +++ b/interpreter/shared/src/main/scala/org/ergoplatform/ErgoBox.scala @@ -15,7 +15,7 @@ import sigmastate.eval._ import sigmastate.serialization.SigmaSerializer import sigmastate.utils.{Helpers, SigmaByteReader, SigmaByteWriter} import sigmastate.utxo.ExtractCreationInfo -import special.collection._ +import sigma.collection._ /** * Box (aka coin, or an unspent output) is a basic concept of a UTXO-based cryptocurrency. In Bitcoin, such an object diff --git a/interpreter/shared/src/main/scala/org/ergoplatform/ErgoBoxCandidate.scala b/interpreter/shared/src/main/scala/org/ergoplatform/ErgoBoxCandidate.scala index 7948823cda..e08d540187 100644 --- a/interpreter/shared/src/main/scala/org/ergoplatform/ErgoBoxCandidate.scala +++ b/interpreter/shared/src/main/scala/org/ergoplatform/ErgoBoxCandidate.scala @@ -9,13 +9,13 @@ import sigmastate._ import sigmastate.SType.AnyOps import sigmastate.serialization.{SigmaSerializer, ValueSerializer} import sigmastate.utils.{SigmaByteReader, SigmaByteWriter} -import special.collection.Coll +import sigma.collection.Coll import sigmastate.eval._ import sigmastate.eval.Extensions._ import sigmastate.serialization.ErgoTreeSerializer.DefaultSerializer import sigma.util.safeNewArray import debox.cfor -import special.collection.Extensions.CollOps +import sigma.collection.Extensions.CollOps import scala.collection.{immutable, mutable} import scala.runtime.ScalaRunTime diff --git a/interpreter/shared/src/main/scala/org/ergoplatform/ErgoLikeContext.scala b/interpreter/shared/src/main/scala/org/ergoplatform/ErgoLikeContext.scala index 3b356fd4ec..5ae468be8f 100644 --- a/interpreter/shared/src/main/scala/org/ergoplatform/ErgoLikeContext.scala +++ b/interpreter/shared/src/main/scala/org/ergoplatform/ErgoLikeContext.scala @@ -11,9 +11,8 @@ import sigmastate.interpreter.{ContextExtension, ErgoTreeEvaluator, Interpreter, import sigmastate.exceptions.InterpreterException import sigmastate.serialization.OpCodes import sigmastate.serialization.OpCodes.OpCode -import special.collection.Coll -import special.sigma -import special.sigma.{AnyValue, Header, PreHeader} +import sigma.collection.Coll +import sigma.{AnyValue, Header, PreHeader} import debox.cfor /** Represents a script evaluation context to be passed to a prover and a verifier to execute and @@ -112,7 +111,7 @@ class ErgoLikeContext(val lastBlockUtxoRoot: AvlTreeData, /** Current version of the ErgoTree executed by the interpreter. * This property is used to implement version dependent operations and passed to - * interpreter via [[special.sigma.Context]]. + * interpreter via [[sigma.Context]]. * The value cannot be assigned on [[ErgoLikeContext]] construction and must be * attached using [[withErgoTreeVersion()]] method. * When the value is None, the [[InterpreterException]] is thrown by the interpreter. @@ -327,7 +326,7 @@ case object Self extends NotReadyValueBox with FixedCostValueCompanion { } } -/** When interpreted evaluates to the singleton instance of [[special.sigma.Context]]. +/** When interpreted evaluates to the singleton instance of [[sigma.Context]]. * Corresponds to `CONTEXT` variable in ErgoScript which can be used like `CONTEXT.headers`. */ case object Context extends NotReadyValue[SContext.type] with ValueCompanion { @@ -345,7 +344,7 @@ case object Context extends NotReadyValue[SContext.type] with ValueCompanion { } } -/** When interpreted evaluates to the singleton instance of [[special.sigma.SigmaDslBuilder]]. +/** When interpreted evaluates to the singleton instance of [[sigma.SigmaDslBuilder]]. * Corresponds to `Global` variable in ErgoScript which can be used like `Global.groupGenerator`. */ case object Global extends NotReadyValue[SGlobal.type] with FixedCostValueCompanion { diff --git a/interpreter/shared/src/main/scala/org/ergoplatform/dsl/AvlTreeHelpers.scala b/interpreter/shared/src/main/scala/org/ergoplatform/dsl/AvlTreeHelpers.scala index 31eadc836c..b649c8e381 100644 --- a/interpreter/shared/src/main/scala/org/ergoplatform/dsl/AvlTreeHelpers.scala +++ b/interpreter/shared/src/main/scala/org/ergoplatform/dsl/AvlTreeHelpers.scala @@ -1,11 +1,11 @@ package org.ergoplatform.dsl -import special.collection.Coll +import sigma.collection.Coll import sigmastate.eval.{CAvlTree, CostingSigmaDslBuilder} import scorex.crypto.authds.{ADKey, ADValue} import scorex.crypto.hash.{Digest32, Blake2b256} import sigmastate.{AvlTreeData, AvlTreeFlags} -import special.sigma.AvlTree +import sigma.AvlTree import scorex.crypto.authds.avltree.batch.{BatchAVLProver, Insert} import CostingSigmaDslBuilder.Colls diff --git a/interpreter/shared/src/main/scala/org/ergoplatform/settings/ErgoAlgos.scala b/interpreter/shared/src/main/scala/org/ergoplatform/settings/ErgoAlgos.scala index 624e713654..25505d8602 100644 --- a/interpreter/shared/src/main/scala/org/ergoplatform/settings/ErgoAlgos.scala +++ b/interpreter/shared/src/main/scala/org/ergoplatform/settings/ErgoAlgos.scala @@ -2,7 +2,7 @@ package org.ergoplatform.settings import scorex.crypto.hash.Blake2b256 import scorex.util._ -import special.collection.Coll +import sigma.collection.Coll import scala.util.Try diff --git a/interpreter/shared/src/main/scala/sigmastate/AvlTreeData.scala b/interpreter/shared/src/main/scala/sigmastate/AvlTreeData.scala index 6533aa857c..64e3ceba2d 100644 --- a/interpreter/shared/src/main/scala/sigmastate/AvlTreeData.scala +++ b/interpreter/shared/src/main/scala/sigmastate/AvlTreeData.scala @@ -4,7 +4,7 @@ import sigmastate.basics.CryptoConstants import sigmastate.eval.Colls import sigmastate.serialization.SigmaSerializer import sigmastate.utils.{SigmaByteReader, SigmaByteWriter} -import special.collection.Coll +import sigma.collection.Coll case class AvlTreeFlags(insertAllowed: Boolean, updateAllowed: Boolean, removeAllowed: Boolean) { diff --git a/interpreter/shared/src/main/scala/sigmastate/DataValueComparer.scala b/interpreter/shared/src/main/scala/sigmastate/DataValueComparer.scala index eab9c461b8..75b604f5a0 100644 --- a/interpreter/shared/src/main/scala/sigmastate/DataValueComparer.scala +++ b/interpreter/shared/src/main/scala/sigmastate/DataValueComparer.scala @@ -9,8 +9,8 @@ import sigmastate.basics.ProveDHTuple import sigmastate.eval.SigmaDsl import sigmastate.basics.CryptoConstants.EcPointType import sigmastate.interpreter.{ErgoTreeEvaluator, NamedDesc, OperationCostInfo} -import special.sigma.{AvlTree, AvlTreeRType, BigInt, BigIntRType, Box, BoxRType, GroupElement, GroupElementRType, Header, HeaderRType, PreHeader, PreHeaderRType, SigmaProp} -import special.collection.{Coll, CollOverArray, PairOfCols} +import sigma.{AvlTree, AvlTreeRType, BigInt, BigIntRType, Box, BoxRType, GroupElement, GroupElementRType, Header, HeaderRType, PreHeader, PreHeaderRType, SigmaProp} +import sigma.collection.{Coll, CollOverArray, PairOfCols} /** Implementation of data equality for two arbitrary ErgoTree data types. * @see [[DataValueComparer.equalDataValues]] diff --git a/interpreter/shared/src/main/scala/sigmastate/InterpreterReflection.scala b/interpreter/shared/src/main/scala/sigmastate/InterpreterReflection.scala index cce29d51da..6e05af97ab 100644 --- a/interpreter/shared/src/main/scala/sigmastate/InterpreterReflection.scala +++ b/interpreter/shared/src/main/scala/sigmastate/InterpreterReflection.scala @@ -2,20 +2,18 @@ package sigmastate import org.ergoplatform.ErgoBox.RegisterId import scalan.reflection.CommonReflection.registerClassEntry -import scalan.reflection.{SRConstructor, mkConstructor, mkMethod, SRMethod} +import scalan.reflection.{mkConstructor, mkMethod} +import sigma.collection.Coll +import sigma.{AvlTree, CoreLibReflection, SigmaDslBuilder} import sigmastate.SAvlTree.KeyValueColl -import sigmastate.SCollection.{SIntArray, SByteArray, SBooleanArray} +import sigmastate.SCollection.{SBooleanArray, SByteArray, SIntArray} import sigmastate.Values._ import sigmastate.basics.VerifierMessage.Challenge import sigmastate.crypto.GF2_192_Poly import sigmastate.interpreter.ErgoTreeEvaluator import sigmastate.lang.Terms._ -import sigmastate.lang.{CheckingSigmaBuilder, Terms} import sigmastate.serialization.OpCodes.OpCode import sigmastate.utxo._ -import special.CoreLibReflection -import special.collection.Coll -import special.sigma.{SigmaDslBuilder, AvlTree} /** Reflection metadata for `interpreter` module. * For each class of this module that needs reflection metadata, diff --git a/interpreter/shared/src/main/scala/sigmastate/Values.scala b/interpreter/shared/src/main/scala/sigmastate/Values.scala index d93b5add75..2eb5a4ecad 100644 --- a/interpreter/shared/src/main/scala/sigmastate/Values.scala +++ b/interpreter/shared/src/main/scala/sigmastate/Values.scala @@ -32,10 +32,10 @@ import sigmastate.lang.CheckingSigmaBuilder._ import sigmastate.serialization.ErgoTreeSerializer.DefaultSerializer import sigmastate.serialization.transformers.ProveDHTupleSerializer import sigmastate.utils.{SigmaByteReader, SigmaByteWriter} -import special.sigma.{AvlTree, Header, PreHeader, _} +import sigma.{AvlTree, Header, PreHeader, _} import sigmastate.lang.SourceContext import sigma.util.safeNewArray -import special.collection.Coll +import sigma.collection.Coll import scala.collection.compat.immutable.ArraySeq import scala.collection.mutable diff --git a/interpreter/shared/src/main/scala/sigmastate/basics/DLogProtocol.scala b/interpreter/shared/src/main/scala/sigmastate/basics/DLogProtocol.scala index 9b801d7ad1..96bfb0dd9d 100644 --- a/interpreter/shared/src/main/scala/sigmastate/basics/DLogProtocol.scala +++ b/interpreter/shared/src/main/scala/sigmastate/basics/DLogProtocol.scala @@ -12,7 +12,7 @@ import sigmastate.basics.VerifierMessage.Challenge import CryptoConstants.{EcPointType, dlogGroup} import sigmastate.serialization.{OpCodes, GroupElementSerializer} import sigmastate.serialization.OpCodes.OpCode -import special.sigma.SigmaProp +import sigma.SigmaProp object DLogProtocol { diff --git a/interpreter/shared/src/main/scala/sigmastate/basics/DiffieHellmanTupleProtocol.scala b/interpreter/shared/src/main/scala/sigmastate/basics/DiffieHellmanTupleProtocol.scala index e39508bf4f..762772c528 100644 --- a/interpreter/shared/src/main/scala/sigmastate/basics/DiffieHellmanTupleProtocol.scala +++ b/interpreter/shared/src/main/scala/sigmastate/basics/DiffieHellmanTupleProtocol.scala @@ -10,7 +10,7 @@ import sigmastate.eval.SigmaDsl import CryptoConstants.EcPointType import sigmastate.serialization.{OpCodes, GroupElementSerializer} import sigmastate.serialization.OpCodes.OpCode -import special.sigma.SigmaProp +import sigma.SigmaProp trait DiffieHellmanTupleProtocol extends SigmaProtocol[DiffieHellmanTupleProtocol] { diff --git a/interpreter/shared/src/main/scala/sigmastate/basics/SigmaProtocolFunctions.scala b/interpreter/shared/src/main/scala/sigmastate/basics/SigmaProtocolFunctions.scala index 2350c3f1d2..9c9d15b0d2 100644 --- a/interpreter/shared/src/main/scala/sigmastate/basics/SigmaProtocolFunctions.scala +++ b/interpreter/shared/src/main/scala/sigmastate/basics/SigmaProtocolFunctions.scala @@ -2,9 +2,8 @@ package sigmastate.basics import sigmastate.SigmaLeaf import sigmastate.basics.CryptoConstants.dlogGroup -import sigmastate.basics.DLogProtocol.{DLogProverInput, ProveDlog} import sigmastate.basics.VerifierMessage.Challenge -import special.collection.Coll +import sigma.collection.Coll import supertagged.TaggedType import java.math.BigInteger diff --git a/interpreter/shared/src/main/scala/sigmastate/eval/BigIntegerOps.scala b/interpreter/shared/src/main/scala/sigmastate/eval/BigIntegerOps.scala index 90ce2bd63b..a3e44b8ebe 100644 --- a/interpreter/shared/src/main/scala/sigmastate/eval/BigIntegerOps.scala +++ b/interpreter/shared/src/main/scala/sigmastate/eval/BigIntegerOps.scala @@ -5,7 +5,7 @@ import java.math.BigInteger import scalan.{ExactOrderingImpl, ExactIntegral} import scala.math.{Integral, Ordering} -import special.sigma._ +import sigma._ import sigmastate.eval.Extensions._ object OrderingOps { @@ -60,7 +60,7 @@ object NumericOps { /** The instance of Integral for BigInt. * - * Note: ExactIntegral was not defined for [[special.sigma.BigInt]] in v4.x. + * Note: ExactIntegral was not defined for [[sigma.BigInt]] in v4.x. * This is because arithmetic BigInt operations were handled in a special way * (see `case op: ArithOp[t] if op.tpe == SBigInt =>` in RuntimeCosting.scala). * As result [[scalan.primitives.UnBinOps.ApplyBinOp]] nodes were not created for diff --git a/interpreter/shared/src/main/scala/sigmastate/eval/CostingDataContext.scala b/interpreter/shared/src/main/scala/sigmastate/eval/CostingDataContext.scala index a79995313a..262808700c 100644 --- a/interpreter/shared/src/main/scala/sigmastate/eval/CostingDataContext.scala +++ b/interpreter/shared/src/main/scala/sigmastate/eval/CostingDataContext.scala @@ -23,8 +23,8 @@ import sigmastate.eval.Extensions._ import sigmastate.interpreter.Interpreter import sigmastate.serialization.ErgoTreeSerializer.DefaultSerializer import sigmastate.serialization.{GroupElementSerializer, SigmaSerializer} -import special.collection._ -import special.sigma._ +import sigma.collection._ +import sigma._ import java.math.BigInteger import java.util.Arrays @@ -150,7 +150,7 @@ case class CSigmaProp(sigmaTree: SigmaBoolean) extends SigmaProp with WrapperOf[ override def toString: String = s"SigmaProp(${wrappedValue.showToString})" } -/** Implementation of the [[special.sigma.AvlTreeVerifier]] trait based on +/** Implementation of the [[sigma.AvlTreeVerifier]] trait based on * [[scorex.crypto.authds.avltree.batch.BatchAVLVerifier]]. * * @see BatchAVLVerifier, AvlTreeVerifier @@ -534,7 +534,7 @@ class CostingSigmaDslBuilder extends SigmaDslBuilder { dsl => /** Wraps the given [[ErgoBox]] into SigmaDsl value of type [[Box]]. * @param ebox the value to be wrapped - * @see [[sigmastate.SBox]], [[special.sigma.Box]] + * @see [[sigmastate.SBox]], [[sigma.Box]] */ def Box(ebox: ErgoBox): Box = CostingBox(ebox) diff --git a/interpreter/shared/src/main/scala/sigmastate/eval/Evaluation.scala b/interpreter/shared/src/main/scala/sigmastate/eval/Evaluation.scala index fa8b50a6c9..ae10009145 100644 --- a/interpreter/shared/src/main/scala/sigmastate/eval/Evaluation.scala +++ b/interpreter/shared/src/main/scala/sigmastate/eval/Evaluation.scala @@ -6,7 +6,7 @@ import scalan.RType._ import sigmastate.SType._ import sigmastate.Values.SigmaBoolean import sigmastate._ -import special.Types._ +import sigma.Types._ import debox.cfor import sigmastate.exceptions.CostLimitException import java.math.BigInteger @@ -17,8 +17,8 @@ import scala.util.Try /** Helper methods used as part of ErgoTree evaluation. */ object Evaluation { - import special.collection._ - import special.sigma._ + import sigma.collection._ + import sigma._ def msgCostLimitError(cost: Long, limit: Long) = s"Estimated execution cost $cost exceeds the limit $limit" @@ -145,7 +145,7 @@ object Evaluation { case _: Unit => UnitType case _: BigInteger => BigIntegerRType - case _: special.sigma.BigInt => BigIntRType + case _: sigma.BigInt => BigIntRType case _: GroupElement => GroupElementRType diff --git a/interpreter/shared/src/main/scala/sigmastate/eval/Extensions.scala b/interpreter/shared/src/main/scala/sigmastate/eval/Extensions.scala index b4efc58348..d92f48f37e 100644 --- a/interpreter/shared/src/main/scala/sigmastate/eval/Extensions.scala +++ b/interpreter/shared/src/main/scala/sigmastate/eval/Extensions.scala @@ -11,8 +11,8 @@ import sigmastate.crypto.{CryptoFacade, Ecp} import sigmastate.lang.{CheckingSigmaBuilder, TransformingSigmaBuilder} import sigmastate.utils.Helpers import sigmastate.{Platform, SCollection, SCollectionType, SType} -import special.collection.Coll -import special.sigma._ +import sigma.collection.Coll +import sigma._ import java.math.BigInteger diff --git a/interpreter/shared/src/main/scala/sigmastate/eval/package.scala b/interpreter/shared/src/main/scala/sigmastate/eval/package.scala index cb4ebb9c05..995d770183 100644 --- a/interpreter/shared/src/main/scala/sigmastate/eval/package.scala +++ b/interpreter/shared/src/main/scala/sigmastate/eval/package.scala @@ -7,8 +7,8 @@ import scalan.RType import scorex.crypto.hash.Digest32 import sigmastate.Values.SigmaBoolean import sigmastate.basics.CryptoConstants.EcPointType -import special.collection.{Coll, CollBuilder} -import special.sigma._ +import sigma.collection.{Coll, CollBuilder} +import sigma._ import supertagged.TaggedType import scala.language.implicitConversions @@ -43,7 +43,7 @@ package object eval { /** Implicit conversions between Dsl type and the type wrapped by the corresponding type Dsl type. * Here BigInt is Dsl type and BigInteger is wrapped type. - * @see `special.sigma.CBigInt` + * @see `sigma.CBigInt` */ implicit def bigIntegerToBigInt(bi: BigInteger): BigInt = SigmaDsl.BigInt(bi) implicit def bigIntToBigInteger(bi: BigInt): BigInteger = SigmaDsl.toBigInteger(bi) diff --git a/interpreter/shared/src/main/scala/sigmastate/interpreter/ErgoTreeEvaluator.scala b/interpreter/shared/src/main/scala/sigmastate/interpreter/ErgoTreeEvaluator.scala index 15b9328d00..b5f1af9dd4 100644 --- a/interpreter/shared/src/main/scala/sigmastate/interpreter/ErgoTreeEvaluator.scala +++ b/interpreter/shared/src/main/scala/sigmastate/interpreter/ErgoTreeEvaluator.scala @@ -6,7 +6,7 @@ import sigmastate.Values._ import sigmastate.eval.Profiler import sigmastate.interpreter.ErgoTreeEvaluator.DataEnv import sigmastate.interpreter.Interpreter.ReductionResult -import special.sigma.{Context, SigmaProp} +import sigma.{Context, SigmaProp} import scalan.util.Extensions._ import sigmastate.interpreter.EvalSettings._ import supertagged.TaggedType @@ -103,8 +103,8 @@ case class JitEvalResult[A](value: A, cost: JitCost) * transaction. No additional transformation is performed. * ErgoTree is interpreted directly and all the intermediate data is stored in the * runtime types. - * The runtime types are such types as [[special.collection.Coll]], - * [[special.sigma.SigmaProp]], [[special.sigma.AvlTree]], [[BigInt]], etc. + * The runtime types are such types as [[sigma.collection.Coll]], + * [[sigma.SigmaProp]], [[sigma.AvlTree]], [[BigInt]], etc. * It also use immutable Map to keep current [[DataEnv]] of computed [[ValDef]]s, as * result only addition is used from the map, and deletion is essentially a garbage * collection. @@ -500,7 +500,7 @@ object ErgoTreeEvaluator { /** Evaluate the given expression in the given Ergo context using the given settings. * The given Value is evaluated as-is and is not changed during evaluation. * - * @param sigmaContext [[special.sigma.Context]] instance used for script execution + * @param sigmaContext [[sigma.Context]] instance used for script execution * @param costAccumulator [[CostAccumulator]] instance used for accumulating costs * @param constants collection of segregated constants which can be refered by * [[ConstantPlaceholder]]s in `exp` diff --git a/interpreter/shared/src/main/scala/sigmastate/interpreter/Interpreter.scala b/interpreter/shared/src/main/scala/sigmastate/interpreter/Interpreter.scala index 59d96ba91a..45db609448 100644 --- a/interpreter/shared/src/main/scala/sigmastate/interpreter/Interpreter.scala +++ b/interpreter/shared/src/main/scala/sigmastate/interpreter/Interpreter.scala @@ -171,7 +171,7 @@ trait Interpreter { val (resProp, cost) = { val ctx = context.asInstanceOf[ErgoLikeContext] ErgoTreeEvaluator.eval(ctx, ErgoTree.EmptyConstants, exp, evalSettings) match { - case (p: special.sigma.SigmaProp, c) => (p, c) + case (p: sigma.SigmaProp, c) => (p, c) case (res, _) => sys.error(s"Invalid result type of $res: expected SigmaProp when evaluating $exp") } diff --git a/interpreter/shared/src/main/scala/sigmastate/interpreter/InterpreterContext.scala b/interpreter/shared/src/main/scala/sigmastate/interpreter/InterpreterContext.scala index 937aa37fda..017af3ff9b 100644 --- a/interpreter/shared/src/main/scala/sigmastate/interpreter/InterpreterContext.scala +++ b/interpreter/shared/src/main/scala/sigmastate/interpreter/InterpreterContext.scala @@ -6,8 +6,7 @@ import sigmastate.Values.EvaluatedValue import sigmastate.interpreter.ContextExtension.VarBinding import sigmastate.serialization.SigmaSerializer import sigmastate.utils.{SigmaByteReader, SigmaByteWriter} -import special.sigma -import special.sigma.AnyValue +import sigma.AnyValue import scala.collection.mutable @@ -109,8 +108,8 @@ trait InterpreterContext { /** Creates a new instance with given validation settings. */ def withValidationSettings(newVs: SigmaValidationSettings): InterpreterContext - /** Creates `special.sigma.Context` instance based on this context. The created instance - * contains all data represented using types form [[special.sigma]] package. + /** Creates `sigma.Context` instance based on this context. The created instance + * contains all data represented using types form [[sigma]] package. * These types are used internally by ErgoTree interpreter. * Thus, this method performs transformation from Ergo to internal Sigma representation * of all context data. diff --git a/interpreter/shared/src/main/scala/sigmastate/interpreter/ProverInterpreter.scala b/interpreter/shared/src/main/scala/sigmastate/interpreter/ProverInterpreter.scala index a0e45359f3..41f0ab37db 100644 --- a/interpreter/shared/src/main/scala/sigmastate/interpreter/ProverInterpreter.scala +++ b/interpreter/shared/src/main/scala/sigmastate/interpreter/ProverInterpreter.scala @@ -15,7 +15,7 @@ import sigmastate.crypto.{GF2_192, GF2_192_Poly} import sigmastate.eval.Extensions.ArrayOps import sigmastate.exceptions.InterpreterException import sigmastate.utils.Helpers -import special.collection.Coll +import sigma.collection.Coll import java.math.BigInteger import scala.util.Try diff --git a/interpreter/shared/src/main/scala/sigmastate/lang/SigmaBuilder.scala b/interpreter/shared/src/main/scala/sigmastate/lang/SigmaBuilder.scala index 7161fa0c40..e3b5d460fc 100644 --- a/interpreter/shared/src/main/scala/sigmastate/lang/SigmaBuilder.scala +++ b/interpreter/shared/src/main/scala/sigmastate/lang/SigmaBuilder.scala @@ -15,8 +15,8 @@ import sigmastate.lang.Terms.{STypeSubst, _} import sigmastate.serialization.OpCodes import sigmastate.serialization.OpCodes.OpCode import sigmastate.utxo._ -import special.collection.Coll -import special.sigma.AnyValue +import sigma.collection.Coll +import sigma.AnyValue import scala.util.DynamicVariable diff --git a/interpreter/shared/src/main/scala/sigmastate/serialization/DataSerializer.scala b/interpreter/shared/src/main/scala/sigmastate/serialization/DataSerializer.scala index d659dbf81b..d53075acd5 100644 --- a/interpreter/shared/src/main/scala/sigmastate/serialization/DataSerializer.scala +++ b/interpreter/shared/src/main/scala/sigmastate/serialization/DataSerializer.scala @@ -10,8 +10,8 @@ import sigmastate.Values.SigmaBoolean import sigmastate.utils.{SigmaByteReader, SigmaByteWriter} import sigmastate._ import sigmastate.eval.{Evaluation, _} -import special.collection._ -import special.sigma._ +import sigma.collection._ +import sigma._ import debox.cfor import sigmastate.exceptions.SerializerException import scala.collection.mutable diff --git a/interpreter/shared/src/main/scala/sigmastate/trees.scala b/interpreter/shared/src/main/scala/sigmastate/trees.scala index bbefdf78b9..91cbb8eef5 100644 --- a/interpreter/shared/src/main/scala/sigmastate/trees.scala +++ b/interpreter/shared/src/main/scala/sigmastate/trees.scala @@ -22,8 +22,8 @@ import sigmastate.interpreter.ErgoTreeEvaluator.DataEnv import sigmastate.serialization.OpCodes._ import sigmastate.serialization._ import sigmastate.utxo.{SimpleTransformerCompanion, Transformer} -import special.collection.Coll -import special.sigma.{GroupElement, SigmaProp} +import sigma.collection.Coll +import sigma.{GroupElement, SigmaProp} import scala.collection.mutable import scala.collection.mutable.ArrayBuffer @@ -1177,7 +1177,7 @@ case class Exponentiate(override val left: Value[SGroupElement.type], protected final override def eval(env: DataEnv)(implicit E: ErgoTreeEvaluator): Any = { val leftV = left.evalTo[GroupElement](env) - val rightV = right.evalTo[special.sigma.BigInt](env) + val rightV = right.evalTo[sigma.BigInt](env) addCost(Exponentiate.costKind) leftV.exp(rightV) } diff --git a/interpreter/shared/src/main/scala/sigmastate/types.scala b/interpreter/shared/src/main/scala/sigmastate/types.scala index e4fd826304..63b9e75fe9 100644 --- a/interpreter/shared/src/main/scala/sigmastate/types.scala +++ b/interpreter/shared/src/main/scala/sigmastate/types.scala @@ -19,8 +19,8 @@ import sigmastate.lang.{SigmaBuilder, Terms} import sigmastate.SCollection._ import sigmastate.basics.CryptoConstants.{hashLength, EcPointType} import sigmastate.serialization.OpCodes -import special.collection.Coll -import special.sigma._ +import sigma.collection.Coll +import sigma._ import scala.language.implicitConversions import scala.reflect.{classTag, ClassTag} @@ -2563,7 +2563,7 @@ case object SPreHeader extends SProduct with SPredefType with SMonoType { /** This type is introduced to unify handling of global and non-global (i.e. methods) operations. * It unifies implementation of global operation with implementation of methods and avoids code * duplication (following DRY principle https://en.wikipedia.org/wiki/Don%27t_repeat_yourself). - * The WrappedType is `special.sigma.SigmaDslBuilder`, which is an interface implemented by + * The WrappedType is `sigma.SigmaDslBuilder`, which is an interface implemented by * the singleton sigmastate.eval.CostingSigmaDslBuilder * * The Constant(...) tree node of this type are not allowed, as well as using it in register and diff --git a/interpreter/shared/src/main/scala/sigmastate/utils/Extensions.scala b/interpreter/shared/src/main/scala/sigmastate/utils/Extensions.scala index 5cdb9f70fc..1235893611 100644 --- a/interpreter/shared/src/main/scala/sigmastate/utils/Extensions.scala +++ b/interpreter/shared/src/main/scala/sigmastate/utils/Extensions.scala @@ -4,7 +4,7 @@ import org.ergoplatform.ErgoBox.TokenId import scorex.util.{ModifierId, idToBytes} import scorex.utils.{Ints, Longs, Shorts} import sigmastate.eval.{Digest32Coll, SigmaDsl} -import special.collection.Coll +import sigma.collection.Coll object Extensions { implicit class ByteOpsForSigma(val b: Byte) extends AnyVal { diff --git a/interpreter/shared/src/main/scala/sigmastate/utils/Helpers.scala b/interpreter/shared/src/main/scala/sigmastate/utils/Helpers.scala index 0f9d4aae16..4eb870b412 100644 --- a/interpreter/shared/src/main/scala/sigmastate/utils/Helpers.scala +++ b/interpreter/shared/src/main/scala/sigmastate/utils/Helpers.scala @@ -8,8 +8,8 @@ import scorex.utils.Ints import sigma.Environment import sigmastate.eval.{CAnyValue, Colls, SigmaDsl} import sigmastate.basics.CryptoConstants.EcPointType -import special.collection.Coll -import special.sigma.GroupElement +import sigma.collection.Coll +import sigma.GroupElement import java.util import java.util.concurrent.locks.Lock diff --git a/interpreter/shared/src/main/scala/sigmastate/utxo/transformers.scala b/interpreter/shared/src/main/scala/sigmastate/utxo/transformers.scala index 2fc36c753c..8cd0abe075 100644 --- a/interpreter/shared/src/main/scala/sigmastate/utxo/transformers.scala +++ b/interpreter/shared/src/main/scala/sigmastate/utxo/transformers.scala @@ -13,8 +13,8 @@ import sigmastate.eval.{Evaluation, SigmaDsl} import sigmastate.exceptions.InterpreterException import sigmastate.interpreter.ErgoTreeEvaluator import sigmastate.interpreter.ErgoTreeEvaluator.{DataEnv, error} -import special.collection.Coll -import special.sigma.{Box, SigmaProp} +import sigma.collection.Coll +import sigma.{Box, SigmaProp} // TODO refactor: remove this trait as it doesn't have semantic meaning @@ -390,7 +390,7 @@ case class ExtractAmount(input: Value[SBox.type]) extends Extract[SLong.type] wi object ExtractAmount extends SimpleTransformerCompanion with FixedCostValueCompanion { val OpType = SFunc(SBox, SLong) override def opCode: OpCode = OpCodes.ExtractAmountCode - /** Cost of: 1) access `value` property of a [[special.sigma.Box]] */ + /** Cost of: 1) access `value` property of a [[sigma.Box]] */ override val costKind = FixedCost(JitCost(8)) override def argInfos: Seq[ArgInfo] = ExtractAmountInfo.argInfos } @@ -563,7 +563,7 @@ object DeserializeRegister extends ValueCompanion { baseCost = JitCost(1), perChunkCost = JitCost(10), chunkSize = 128) } -/** See [[special.sigma.Context.getVar()]] for detailed description. */ +/** See [[sigma.Context.getVar()]] for detailed description. */ case class GetVar[V <: SType](varId: Byte, override val tpe: SOption[V]) extends NotReadyValue[SOption[V]] { override def companion = GetVar override val opType = SFunc(SContext.ContextFuncDom, tpe) diff --git a/interpreter/shared/src/test/scala/sigmastate/SigmaProtocolSpecification.scala b/interpreter/shared/src/test/scala/sigmastate/SigmaProtocolSpecification.scala index 669cb09da5..107890221b 100644 --- a/interpreter/shared/src/test/scala/sigmastate/SigmaProtocolSpecification.scala +++ b/interpreter/shared/src/test/scala/sigmastate/SigmaProtocolSpecification.scala @@ -2,7 +2,7 @@ package sigmastate import sigmastate.basics.VerifierMessage.Challenge import sigmastate.crypto.{GF2_192, GF2_192_Poly} -import special.sigma.SigmaTestingData +import sigma.SigmaTestingData class SigmaProtocolSpecification extends SigmaTestingData { diff --git a/interpreter/shared/src/test/scala/sigmastate/eval/BasicOpsTests.scala b/interpreter/shared/src/test/scala/sigmastate/eval/BasicOpsTests.scala index d4f05a4050..40f4e7f3d8 100644 --- a/interpreter/shared/src/test/scala/sigmastate/eval/BasicOpsTests.scala +++ b/interpreter/shared/src/test/scala/sigmastate/eval/BasicOpsTests.scala @@ -6,7 +6,7 @@ import org.scalatest.matchers.should.Matchers import java.math.BigInteger import sigmastate.TrivialProp import sigmastate.basics.SecP256K1Group -import special.sigma.{ContractsTestkit, SigmaDslBuilder, SigmaProp} +import sigma.{ContractsTestkit, SigmaDslBuilder, SigmaProp} import scala.language.implicitConversions diff --git a/interpreter/shared/src/test/scala/sigmastate/helpers/ErgoLikeContextTesting.scala b/interpreter/shared/src/test/scala/sigmastate/helpers/ErgoLikeContextTesting.scala index 702d890147..a24dcd548c 100644 --- a/interpreter/shared/src/test/scala/sigmastate/helpers/ErgoLikeContextTesting.scala +++ b/interpreter/shared/src/test/scala/sigmastate/helpers/ErgoLikeContextTesting.scala @@ -9,8 +9,8 @@ import sigmastate.eval._ import sigmastate.interpreter.ContextExtension import sigmastate.interpreter.ErgoTreeEvaluator.DefaultEvalSettings import sigmastate.serialization.{GroupElementSerializer, SigmaSerializer} -import special.collection.Coll -import special.sigma.{Box, Header, PreHeader} +import sigma.collection.Coll +import sigma.{Box, Header, PreHeader} object ErgoLikeContextTesting { /* NO HF PROOF: diff --git a/interpreter/shared/src/test/scala/sigmastate/helpers/TestingHelpers.scala b/interpreter/shared/src/test/scala/sigmastate/helpers/TestingHelpers.scala index fa1b9f163c..e664a251e6 100644 --- a/interpreter/shared/src/test/scala/sigmastate/helpers/TestingHelpers.scala +++ b/interpreter/shared/src/test/scala/sigmastate/helpers/TestingHelpers.scala @@ -8,8 +8,8 @@ import sigmastate.AvlTreeData import sigmastate.Values.ErgoTree import sigmastate.eval.{CostingSigmaDslBuilder, _} import sigmastate.interpreter.ContextExtension -import special.collection.{Coll, CollOverArray, PairOfCols} -import special.sigma.{Header, PreHeader} +import sigma.collection.{Coll, CollOverArray, PairOfCols} +import sigma.{Header, PreHeader} import scala.collection.compat.immutable.ArraySeq diff --git a/interpreter/shared/src/test/scala/sigmastate/lang/SigmaBuilderTest.scala b/interpreter/shared/src/test/scala/sigmastate/lang/SigmaBuilderTest.scala index 393e69454b..0eccc3ce41 100644 --- a/interpreter/shared/src/test/scala/sigmastate/lang/SigmaBuilderTest.scala +++ b/interpreter/shared/src/test/scala/sigmastate/lang/SigmaBuilderTest.scala @@ -11,7 +11,7 @@ import sigmastate.eval.Extensions.ArrayOps import sigmastate.eval.{CAnyValue, CAvlTree, CostingBox, SigmaDsl} import sigmastate.exceptions.ConstraintFailed import sigmastate.serialization.OpCodes -import special.sigma.SigmaTestingData +import sigma.SigmaTestingData import java.math.BigInteger diff --git a/interpreter/shared/src/test/scala/sigmastate/serialization/ConstantSerializerSpecification.scala b/interpreter/shared/src/test/scala/sigmastate/serialization/ConstantSerializerSpecification.scala index 42df295d53..4e71522d3d 100644 --- a/interpreter/shared/src/test/scala/sigmastate/serialization/ConstantSerializerSpecification.scala +++ b/interpreter/shared/src/test/scala/sigmastate/serialization/ConstantSerializerSpecification.scala @@ -12,7 +12,7 @@ import sigmastate.eval._ import sigmastate.eval.Extensions._ import sigmastate.Values._ import sigmastate.eval.Evaluation -import special.sigma.AvlTree +import sigma.AvlTree import SType.AnyOps import scorex.util.encode.Base16 import sigmastate.exceptions.SerializerException diff --git a/interpreter/shared/src/test/scala/sigmastate/serialization/DataSerializerSpecification.scala b/interpreter/shared/src/test/scala/sigmastate/serialization/DataSerializerSpecification.scala index d50f943d7a..dcac288b6b 100644 --- a/interpreter/shared/src/test/scala/sigmastate/serialization/DataSerializerSpecification.scala +++ b/interpreter/shared/src/test/scala/sigmastate/serialization/DataSerializerSpecification.scala @@ -11,7 +11,7 @@ import sigmastate.eval.Evaluation import sigmastate.eval._ import sigmastate.eval.Extensions._ import sigmastate.basics.CryptoConstants.EcPointType -import special.sigma.AvlTree +import sigma.AvlTree import SType.AnyOps import sigmastate.exceptions.SerializerException import sigmastate.interpreter.{CostAccumulator, ErgoTreeEvaluator} diff --git a/interpreter/shared/src/test/scala/sigmastate/serialization/generators/ObjectGenerators.scala b/interpreter/shared/src/test/scala/sigmastate/serialization/generators/ObjectGenerators.scala index d566e416ba..9128d3dc10 100644 --- a/interpreter/shared/src/test/scala/sigmastate/serialization/generators/ObjectGenerators.scala +++ b/interpreter/shared/src/test/scala/sigmastate/serialization/generators/ObjectGenerators.scala @@ -22,8 +22,8 @@ import sigmastate.interpreter.{ContextExtension, ProverResult} import sigmastate.lang.TransformingSigmaBuilder._ import sigmastate._ import sigmastate.utxo._ -import special.collection.Coll -import special.sigma._ +import sigma.collection.Coll +import sigma._ import java.math.BigInteger import scala.collection.compat.immutable.ArraySeq @@ -238,7 +238,7 @@ trait ObjectGenerators extends TypeGenerators val unsignedShortGen: Gen[Short] = Gen.chooseNum(0, Short.MaxValue).map(_.toShort) lazy val contextExtensionGen: Gen[ContextExtension] = for { - values: collection.Seq[(Byte, EvaluatedValue[SType])] <- Gen.sequence(contextExtensionValuesGen(0, 5))(Buildable.buildableSeq) + values: scala.collection.Seq[(Byte, EvaluatedValue[SType])] <- Gen.sequence(contextExtensionValuesGen(0, 5))(Buildable.buildableSeq) } yield ContextExtension(mutable.LinkedHashMap[Byte, EvaluatedValue[SType]](values.sortBy(_._1).toSeq:_*)) lazy val serializedProverResultGen: Gen[ProverResult] = for { diff --git a/interpreter/shared/src/test/scala/special/sigma/ContractsTestkit.scala b/interpreter/shared/src/test/scala/special/sigma/ContractsTestkit.scala index a544361d98..a7f0b1624a 100644 --- a/interpreter/shared/src/test/scala/special/sigma/ContractsTestkit.scala +++ b/interpreter/shared/src/test/scala/special/sigma/ContractsTestkit.scala @@ -1,6 +1,6 @@ -package special.sigma +package sigma -import special.collection.{Coll, CollOverArrayBuilder} +import sigma.collection.{Coll, CollOverArrayBuilder} import scalan.RType import sigmastate.Values.ErgoTree import sigmastate.{AvlTreeData, Values} diff --git a/interpreter/shared/src/test/scala/special/sigma/SigmaTestingData.scala b/interpreter/shared/src/test/scala/special/sigma/SigmaTestingData.scala index d2b2fa819e..2ce39b0077 100644 --- a/interpreter/shared/src/test/scala/special/sigma/SigmaTestingData.scala +++ b/interpreter/shared/src/test/scala/special/sigma/SigmaTestingData.scala @@ -1,4 +1,4 @@ -package special.sigma +package sigma import org.ergoplatform.ErgoBox import org.ergoplatform.settings.ErgoAlgos @@ -22,13 +22,13 @@ import sigmastate.serialization.ErgoTreeSerializer import sigmastate.serialization.generators.ObjectGenerators import sigmastate.utils.Helpers import sigmastate._ -import special.collection.Coll +import sigma.collection.Coll import java.math.BigInteger import scala.reflect.ClassTag trait SigmaTestingData extends TestingCommons with ObjectGenerators { - /** Creates a [[special.collection.Coll]] with the given `items`. */ + /** Creates a [[sigma.collection.Coll]] with the given `items`. */ def Coll[T](items: T*)(implicit cT: RType[T]): Coll[T] = CostingSigmaDslBuilder.Colls.fromItems(items: _*) diff --git a/parsers/shared/src/test/scala/sigmastate/lang/LangTests.scala b/parsers/shared/src/test/scala/sigmastate/lang/LangTests.scala index 9fc7198543..0c79b8f05e 100644 --- a/parsers/shared/src/test/scala/sigmastate/lang/LangTests.scala +++ b/parsers/shared/src/test/scala/sigmastate/lang/LangTests.scala @@ -10,10 +10,10 @@ import sigmastate.basics.DLogProtocol.ProveDlog import sigmastate.SCollection.SByteArray import sigmastate.basics.{ProveDHTuple, CryptoConstants} import sigmastate.interpreter.Interpreter.ScriptEnv -import special.sigma._ +import sigma._ import sigmastate.eval._ import sigmastate.helpers.NegativeTesting -import special.collection.Coll +import sigma.collection.Coll trait LangTests extends Matchers with NegativeTesting { diff --git a/sc/jvm/src/test/scala/sigmastate/ErgoTreeBenchmarks.scala b/sc/jvm/src/test/scala/sigmastate/ErgoTreeBenchmarks.scala index da86cbe297..8c3789891b 100644 --- a/sc/jvm/src/test/scala/sigmastate/ErgoTreeBenchmarks.scala +++ b/sc/jvm/src/test/scala/sigmastate/ErgoTreeBenchmarks.scala @@ -2,9 +2,9 @@ package sigmastate import debox.cfor import org.scalameter.api.Bench +import sigma.collections.BenchmarkGens import sigmastate.Values.{IntConstant, SValue} import sigmastate.serialization.OpCodes.PlusCode -import special.collections.BenchmarkGens object ErgoTreeBenchmarks extends Bench.LocalTime with BenchmarkGens { suite: Bench[Double] => diff --git a/sc/jvm/src/test/scala/sigmastate/ReflectionGenerator.scala b/sc/jvm/src/test/scala/sigmastate/ReflectionGenerator.scala index 2d71462966..ed2f863102 100644 --- a/sc/jvm/src/test/scala/sigmastate/ReflectionGenerator.scala +++ b/sc/jvm/src/test/scala/sigmastate/ReflectionGenerator.scala @@ -32,8 +32,8 @@ object ReflectionGenerator { val knownPackages = Array( "scalan.primitives.", - "special.collection.", - "special.sigma.", + "sigma.collection.", + "sigma.", "special.wrappers.", "sigmastate.Values.", "sigmastate.lang.Terms.", diff --git a/sc/jvm/src/test/scala/sigmastate/helpers/SigmaPPrintSpec.scala b/sc/jvm/src/test/scala/sigmastate/helpers/SigmaPPrintSpec.scala index 59e08c918f..5abbf7c9c3 100644 --- a/sc/jvm/src/test/scala/sigmastate/helpers/SigmaPPrintSpec.scala +++ b/sc/jvm/src/test/scala/sigmastate/helpers/SigmaPPrintSpec.scala @@ -12,8 +12,8 @@ import sigmastate.lang.Terms.MethodCall import sigmastate.serialization.OpCodes import sigmastate.utils.Helpers import sigmastate.utxo.SelectField -import special.collection.CollType -import special.sigma.SigmaDslTesting +import sigma.collection.CollType +import sigma.SigmaDslTesting import java.math.BigInteger import scala.collection.mutable.ArrayBuffer diff --git a/sc/jvm/src/test/scala/special/collections/BasicBenchmarks.scala b/sc/jvm/src/test/scala/special/collections/BasicBenchmarks.scala index 31ecd890b1..144f731bad 100644 --- a/sc/jvm/src/test/scala/special/collections/BasicBenchmarks.scala +++ b/sc/jvm/src/test/scala/special/collections/BasicBenchmarks.scala @@ -1,4 +1,4 @@ -package special.collections +package sigma.collections import org.scalameter.api._ import debox.cfor diff --git a/sc/jvm/src/test/scala/special/collections/BenchmarkGens.scala b/sc/jvm/src/test/scala/special/collections/BenchmarkGens.scala index 7047207a55..a44e40fe38 100644 --- a/sc/jvm/src/test/scala/special/collections/BenchmarkGens.scala +++ b/sc/jvm/src/test/scala/special/collections/BenchmarkGens.scala @@ -1,7 +1,7 @@ -package special.collections +package sigma.collections import org.scalameter.KeyValue -import org.scalameter.api.{Gen, Bench, _} +import org.scalameter.api.{Bench, Gen, _} trait BenchmarkGens extends CollGens { suite: Bench[Double] => def maxSize = 100000 diff --git a/sc/jvm/src/test/scala/special/collections/BufferBenchmark.scala b/sc/jvm/src/test/scala/special/collections/BufferBenchmark.scala index c2327c7a98..e4dd00e9be 100644 --- a/sc/jvm/src/test/scala/special/collections/BufferBenchmark.scala +++ b/sc/jvm/src/test/scala/special/collections/BufferBenchmark.scala @@ -1,4 +1,4 @@ -package special.collections +package sigma.collections import debox.Buffer import debox.cfor diff --git a/sc/jvm/src/test/scala/special/collections/CollBenchmark.scala b/sc/jvm/src/test/scala/special/collections/CollBenchmark.scala index c123778137..aa72f7dc49 100644 --- a/sc/jvm/src/test/scala/special/collections/CollBenchmark.scala +++ b/sc/jvm/src/test/scala/special/collections/CollBenchmark.scala @@ -1,10 +1,10 @@ -package special.collections +package sigma.collections import org.scalameter.{execution, Executor} import org.scalameter.api._ import org.scalameter.picklers.Implicits._ -import special.collection.Coll -import special.collection.Extensions._ +import sigma.collection.Coll +import sigma.collection.Extensions._ import debox.cfor diff --git a/sc/jvm/src/test/scala/special/collections/MapBenchmark.scala b/sc/jvm/src/test/scala/special/collections/MapBenchmark.scala index 3a5c78c8e1..06b2e781c6 100644 --- a/sc/jvm/src/test/scala/special/collections/MapBenchmark.scala +++ b/sc/jvm/src/test/scala/special/collections/MapBenchmark.scala @@ -1,4 +1,4 @@ -package special.collections +package sigma.collections import org.scalameter.api.Bench import scalan.{AVHashMap, Nullable} diff --git a/sc/jvm/src/test/scala/special/collections/SymBenchmark.scala b/sc/jvm/src/test/scala/special/collections/SymBenchmark.scala index 354177afbc..4710f9fe7e 100644 --- a/sc/jvm/src/test/scala/special/collections/SymBenchmark.scala +++ b/sc/jvm/src/test/scala/special/collections/SymBenchmark.scala @@ -1,4 +1,4 @@ -package special.collections +package sigma.collections import debox.{Set => DSet, Map => DMap} import scalan.TestLibrary diff --git a/sc/shared/src/main/scala/org/ergoplatform/dsl/ContractSpec.scala b/sc/shared/src/main/scala/org/ergoplatform/dsl/ContractSpec.scala index bba4d81b3e..013c540f73 100644 --- a/sc/shared/src/main/scala/org/ergoplatform/dsl/ContractSpec.scala +++ b/sc/shared/src/main/scala/org/ergoplatform/dsl/ContractSpec.scala @@ -4,7 +4,7 @@ import org.ergoplatform.ErgoBox.{BoxId, NonMandatoryRegisterId, TokenId} import sigmastate.interpreter.{CostedProverResult, ProverResult} import scalan.RType import org.ergoplatform.{ErgoLikeContext, ErgoBox} -import special.sigma.{SigmaDslBuilder, AnyValue, SigmaProp} +import sigma.{SigmaDslBuilder, AnyValue, SigmaProp} import sigmastate.Values.ErgoTree import sigmastate.eval.{IRContext, CostingSigmaDslBuilder} diff --git a/sc/shared/src/main/scala/org/ergoplatform/dsl/ContractSyntax.scala b/sc/shared/src/main/scala/org/ergoplatform/dsl/ContractSyntax.scala index d792663669..acc1ded565 100644 --- a/sc/shared/src/main/scala/org/ergoplatform/dsl/ContractSyntax.scala +++ b/sc/shared/src/main/scala/org/ergoplatform/dsl/ContractSyntax.scala @@ -7,7 +7,7 @@ import sigmastate.SType.AnyOps import org.ergoplatform.dsl.ContractSyntax.{ErgoScript, Proposition} import sigmastate.eval.{CostingSigmaDslBuilder, Evaluation} import sigmastate.interpreter.Interpreter.ScriptEnv -import special.sigma.{SigmaProp, SigmaContract, Context, SigmaDslBuilder} +import sigma.{SigmaProp, SigmaContract, Context, SigmaDslBuilder} import scala.language.implicitConversions /** Defines methods to be used in contract implementations based on [[SigmaContract]]. */ diff --git a/sc/shared/src/main/scala/org/ergoplatform/dsl/ErgoContractSpec.scala b/sc/shared/src/main/scala/org/ergoplatform/dsl/ErgoContractSpec.scala index abc025acf9..1592c1d30b 100644 --- a/sc/shared/src/main/scala/org/ergoplatform/dsl/ErgoContractSpec.scala +++ b/sc/shared/src/main/scala/org/ergoplatform/dsl/ErgoContractSpec.scala @@ -1,6 +1,6 @@ package org.ergoplatform.dsl -import special.collection.Coll +import sigma.collection.Coll import sigmastate.interpreter.CostedProverResult import sigmastate.eval.IRContext import org.ergoplatform.dsl.ContractSyntax.{ErgoScript, Proposition, Token} diff --git a/sc/shared/src/main/scala/scalan/GraphIRReflection.scala b/sc/shared/src/main/scala/scalan/GraphIRReflection.scala index e271d5d176..89ce1ab852 100644 --- a/sc/shared/src/main/scala/scalan/GraphIRReflection.scala +++ b/sc/shared/src/main/scala/scalan/GraphIRReflection.scala @@ -3,10 +3,11 @@ package scalan import scalan.primitives.Thunks import scalan.reflection.CommonReflection.registerClassEntry import scalan.reflection.{CommonReflection, mkConstructor, mkMethod} +import sigma.CoreLibReflection import sigmastate.eval.SigmaLibrary -import special.CoreLibReflection -import special.collection.Colls -import special.sigma.SigmaDsl +import sigma.collection.Colls +import sigma.SigmaDsl +import special.wrappers.{OptionWrapSpec, RTypeWrapSpec} import wrappers.scalan.WRTypes /** Registrations of reflection metadata for graph-ir module (see README.md). @@ -68,7 +69,7 @@ object GraphIRReflection { ) ) - { val clazz = classOf[special.sigma.SigmaDsl#SigmaProp] + { val clazz = classOf[sigma.SigmaDsl#SigmaProp] val ctx = null.asInstanceOf[SigmaDsl] // ok! type level only registerClassEntry(clazz, methods = Map( @@ -564,4 +565,40 @@ object GraphIRReflection { ) ) } + { + val clazz = classOf[OptionWrapSpec] + registerClassEntry(clazz, + methods = Map( + mkMethod(clazz, "getOrElse", Array[Class[_]](classOf[Option[_]], classOf[Function0[_]])) { (obj, args) => + val opt = args(0).asInstanceOf[Option[Any]] + val defaultFunc = args(1).asInstanceOf[Function0[Any]] + obj.asInstanceOf[OptionWrapSpec].getOrElse(opt, defaultFunc()) + }, + mkMethod(clazz, "isDefined", Array[Class[_]](classOf[Option[_]])) { (obj, args) => + obj.asInstanceOf[OptionWrapSpec].isDefined(args(0).asInstanceOf[Option[_]]) + }, + mkMethod(clazz, "filter", Array[Class[_]](classOf[Option[_]], classOf[Function1[_, _]])) { (obj, args) => + obj.asInstanceOf[OptionWrapSpec].filter( + args(0).asInstanceOf[Option[Any]], args(1).asInstanceOf[Any => Boolean]) + }, + mkMethod(clazz, "map", Array[Class[_]](classOf[Option[_]], classOf[Function1[_, _]])) { (obj, args) => + obj.asInstanceOf[OptionWrapSpec].map( + args(0).asInstanceOf[Option[Any]], args(1).asInstanceOf[Any => Any]) + }, + mkMethod(clazz, "get", Array[Class[_]](classOf[Option[_]])) { (obj, args) => + obj.asInstanceOf[OptionWrapSpec].get(args(0).asInstanceOf[Option[_]]) + } + ) + ) + } + { + val clazz = classOf[RTypeWrapSpec] + registerClassEntry(clazz, + methods = Map( + mkMethod(clazz, "name", Array[Class[_]](classOf[RType[_]])) { (obj, args) => + obj.asInstanceOf[RTypeWrapSpec].name(args(0).asInstanceOf[RType[_]]) + } + ) + ) + } } diff --git a/sc/shared/src/main/scala/scalan/Library.scala b/sc/shared/src/main/scala/scalan/Library.scala index ac8c5564a6..566c53e4dc 100644 --- a/sc/shared/src/main/scala/scalan/Library.scala +++ b/sc/shared/src/main/scala/scalan/Library.scala @@ -1,7 +1,7 @@ package scalan import scala.language.implicitConversions -import special.collection._ +import sigma.collection._ import special.wrappers.WrappersModule import scalan.util.MemoizedFunc import scalan.ExactIntegral._ diff --git a/sc/shared/src/main/scala/sigmastate/eval/GraphBuilding.scala b/sc/shared/src/main/scala/sigmastate/eval/GraphBuilding.scala index 347468da89..ea8f3bdd74 100644 --- a/sc/shared/src/main/scala/sigmastate/eval/GraphBuilding.scala +++ b/sc/shared/src/main/scala/sigmastate/eval/GraphBuilding.scala @@ -393,7 +393,7 @@ trait GraphBuilding extends SigmaLibrary { IR: IRContext => import sigmastate._ - protected implicit def groupElementToECPoint(g: special.sigma.GroupElement): EcPointType = CostingSigmaDslBuilder.toECPoint(g).asInstanceOf[EcPointType] + protected implicit def groupElementToECPoint(g: sigma.GroupElement): EcPointType = CostingSigmaDslBuilder.toECPoint(g).asInstanceOf[EcPointType] def error(msg: String) = throw new GraphBuildingException(msg, None) def error(msg: String, srcCtx: Option[SourceContext]) = throw new GraphBuildingException(msg, srcCtx) @@ -471,7 +471,7 @@ trait GraphBuilding extends SigmaLibrary { IR: IRContext => case box: SBox => val boxV = liftConst(box) boxV - case tree: special.sigma.AvlTree => + case tree: sigma.AvlTree => val treeV = liftConst(tree) treeV case s: String => diff --git a/sc/shared/src/main/scala/sigmastate/eval/SigmaLibrary.scala b/sc/shared/src/main/scala/sigmastate/eval/SigmaLibrary.scala index bc1e17d228..be17179cbf 100644 --- a/sc/shared/src/main/scala/sigmastate/eval/SigmaLibrary.scala +++ b/sc/shared/src/main/scala/sigmastate/eval/SigmaLibrary.scala @@ -1,11 +1,11 @@ package sigmastate.eval import scalan.Library -import special.sigma.SigmaDslModule +import sigma.SigmaDslModule /** Main trait which represents sigma operations in graph IR cake. */ trait SigmaLibrary extends Library - with special.sigma.wrappers.WrappersModule + with sigma.wrappers.WrappersModule with SigmaDslModule { import WRType._ diff --git a/sc/shared/src/main/scala/special/collection/CollsUnit.scala b/sc/shared/src/main/scala/special/collection/CollsUnit.scala index 217341830d..f3342e7594 100644 --- a/sc/shared/src/main/scala/special/collection/CollsUnit.scala +++ b/sc/shared/src/main/scala/special/collection/CollsUnit.scala @@ -1,10 +1,10 @@ -package special.collection { +package sigma.collection { import scalan._ /** Staged version of collection interfaces which is used in graph-based IR to represent * methods of Coll and CollBuilder. * Each method of Coll and CollBuilder in Colls corresponds to a method of the original - * non-staged class [[special.collection.Coll]] and [[special.collection.CollBuilder]]. + * non-staged class [[sigma.collection.Coll]] and [[sigma.collection.CollBuilder]]. * The semantics of each method is the same as in the original class, please look there * for details. */ diff --git a/sc/shared/src/main/scala/special/collection/impl/CollsImpl.scala b/sc/shared/src/main/scala/special/collection/impl/CollsImpl.scala index 0437f6c97f..e4cb3b0077 100644 --- a/sc/shared/src/main/scala/special/collection/impl/CollsImpl.scala +++ b/sc/shared/src/main/scala/special/collection/impl/CollsImpl.scala @@ -1,4 +1,4 @@ -package special.collection +package sigma.collection import scala.language.{existentials,implicitConversions} import scalan._ @@ -20,8 +20,7 @@ import WOption._ class CollCls extends EntityObject("Coll") { // entityConst: single const for each entity import Liftables._ - import scala.reflect.{ClassTag, classTag} - type SColl[A] = special.collection.Coll[A] + type SColl[A] = sigma.collection.Coll[A] case class CollConst[SA, A]( constValue: SColl[SA], lA: Liftable[SA, A] @@ -496,8 +495,7 @@ object Coll extends CollCls object CollBuilder extends EntityObject("CollBuilder") { // entityConst: single const for each entity import Liftables._ - import scala.reflect.{ClassTag, classTag} - type SCollBuilder = special.collection.CollBuilder + type SCollBuilder = sigma.collection.CollBuilder case class CollBuilderConst( constValue: SCollBuilder ) extends LiftedConst[SCollBuilder, CollBuilder] with CollBuilder @@ -639,9 +637,9 @@ object CollBuilder extends EntityObject("CollBuilder") { } -object CollsModule extends scalan.ModuleInfo("special.collection", "Colls") { +object CollsModule extends scalan.ModuleInfo("sigma.collection", "Colls") { val reflection = GraphIRReflection } } -trait CollsModule extends special.collection.impl.CollsDefs {self: Library =>} +trait CollsModule extends sigma.collection.impl.CollsDefs {self: Library =>} diff --git a/sc/shared/src/main/scala/special/sigma/SigmaDslUnit.scala b/sc/shared/src/main/scala/special/sigma/SigmaDslUnit.scala index 0ac9882574..48548226a5 100644 --- a/sc/shared/src/main/scala/special/sigma/SigmaDslUnit.scala +++ b/sc/shared/src/main/scala/special/sigma/SigmaDslUnit.scala @@ -1,4 +1,4 @@ -package special.sigma { +package sigma { import scalan._ import sigmastate.eval.SigmaLibrary diff --git a/sc/shared/src/main/scala/special/sigma/impl/SigmaDslImpl.scala b/sc/shared/src/main/scala/special/sigma/impl/SigmaDslImpl.scala index c56beb83cb..e36b2eaf3e 100644 --- a/sc/shared/src/main/scala/special/sigma/impl/SigmaDslImpl.scala +++ b/sc/shared/src/main/scala/special/sigma/impl/SigmaDslImpl.scala @@ -1,4 +1,4 @@ -package special.sigma +package sigma import scala.language.{existentials, implicitConversions} import scalan._ @@ -34,7 +34,7 @@ object BigInt extends EntityObject("BigInt") { // entityConst: single const for each entity import Liftables._ import scala.reflect.{ClassTag, classTag} - type SBigInt = special.sigma.BigInt + type SBigInt = sigma.BigInt case class BigIntConst( constValue: SBigInt ) extends LiftedConst[SBigInt, BigInt] with BigInt @@ -269,7 +269,7 @@ object GroupElement extends EntityObject("GroupElement") { // entityConst: single const for each entity import Liftables._ import scala.reflect.{ClassTag, classTag} - type SGroupElement = special.sigma.GroupElement + type SGroupElement = sigma.GroupElement case class GroupElementConst( constValue: SGroupElement ) extends LiftedConst[SGroupElement, GroupElement] with GroupElement @@ -409,7 +409,7 @@ object SigmaProp extends EntityObject("SigmaProp") { // entityConst: single const for each entity import Liftables._ import scala.reflect.{ClassTag, classTag} - type SSigmaProp = special.sigma.SigmaProp + type SSigmaProp = sigma.SigmaProp case class SigmaPropConst( constValue: SSigmaProp ) extends LiftedConst[SSigmaProp, SigmaProp] with SigmaProp @@ -573,7 +573,7 @@ object Box extends EntityObject("Box") { // entityConst: single const for each entity import Liftables._ import scala.reflect.{ClassTag, classTag} - type SBox = special.sigma.Box + type SBox = sigma.Box case class BoxConst( constValue: SBox ) extends LiftedConst[SBox, Box] with Box @@ -819,7 +819,7 @@ object AvlTree extends EntityObject("AvlTree") { // entityConst: single const for each entity import Liftables._ import scala.reflect.{ClassTag, classTag} - type SAvlTree = special.sigma.AvlTree + type SAvlTree = sigma.AvlTree case class AvlTreeConst( constValue: SAvlTree ) extends LiftedConst[SAvlTree, AvlTree] with AvlTree @@ -1092,7 +1092,7 @@ object PreHeader extends EntityObject("PreHeader") { // entityConst: single const for each entity import Liftables._ import scala.reflect.{ClassTag, classTag} - type SPreHeader = special.sigma.PreHeader + type SPreHeader = sigma.PreHeader case class PreHeaderConst( constValue: SPreHeader ) extends LiftedConst[SPreHeader, PreHeader] with PreHeader @@ -1253,7 +1253,7 @@ object Header extends EntityObject("Header") { // entityConst: single const for each entity import Liftables._ import scala.reflect.{ClassTag, classTag} - type SHeader = special.sigma.Header + type SHeader = sigma.Header case class HeaderConst( constValue: SHeader ) extends LiftedConst[SHeader, Header] with Header @@ -1526,7 +1526,7 @@ object Context extends EntityObject("Context") { // entityConst: single const for each entity import Liftables._ import scala.reflect.{ClassTag, classTag} - type SContext = special.sigma.Context + type SContext = sigma.Context case class ContextConst( constValue: SContext ) extends LiftedConst[SContext, Context] with Context @@ -1795,7 +1795,7 @@ object SigmaDslBuilder extends EntityObject("SigmaDslBuilder") { // entityConst: single const for each entity import Liftables._ import scala.reflect.{ClassTag, classTag} - type SSigmaDslBuilder = special.sigma.SigmaDslBuilder + type SSigmaDslBuilder = sigma.SigmaDslBuilder case class SigmaDslBuilderConst( constValue: SSigmaDslBuilder ) extends LiftedConst[SSigmaDslBuilder, SigmaDslBuilder] with SigmaDslBuilder @@ -2339,9 +2339,9 @@ object SigmaDslBuilder extends EntityObject("SigmaDslBuilder") { registerEntityObject("SigmaDslBuilder", SigmaDslBuilder) } -object SigmaDslModule extends scalan.ModuleInfo("special.sigma", "SigmaDsl") { +object SigmaDslModule extends scalan.ModuleInfo("sigma", "SigmaDsl") { val reflection = GraphIRReflection } } -trait SigmaDslModule extends special.sigma.impl.SigmaDslDefs {self: SigmaLibrary =>} +trait SigmaDslModule extends sigma.impl.SigmaDslDefs {self: SigmaLibrary =>} diff --git a/sc/shared/src/main/scala/special/sigma/wrappers/WrappersModule.scala b/sc/shared/src/main/scala/special/sigma/wrappers/WrappersModule.scala index 84fc0abdd3..6696788621 100644 --- a/sc/shared/src/main/scala/special/sigma/wrappers/WrappersModule.scala +++ b/sc/shared/src/main/scala/special/sigma/wrappers/WrappersModule.scala @@ -1,4 +1,4 @@ -package special.sigma.wrappers +package sigma.wrappers trait WrappersModule extends special.wrappers.WrappersModule diff --git a/common/shared/src/main/scala/special/wrappers/WrappersSpec.scala b/sc/shared/src/main/scala/special/wrappers/WrappersSpec.scala similarity index 100% rename from common/shared/src/main/scala/special/wrappers/WrappersSpec.scala rename to sc/shared/src/main/scala/special/wrappers/WrappersSpec.scala diff --git a/sc/shared/src/test/scala/org/ergoplatform/ErgoAddressSpecification.scala b/sc/shared/src/test/scala/org/ergoplatform/ErgoAddressSpecification.scala index 22359c1606..e6610e1c7b 100644 --- a/sc/shared/src/test/scala/org/ergoplatform/ErgoAddressSpecification.scala +++ b/sc/shared/src/test/scala/org/ergoplatform/ErgoAddressSpecification.scala @@ -21,7 +21,7 @@ import sigmastate.serialization.ErgoTreeSerializer.DefaultSerializer import sigmastate.serialization.{GroupElementSerializer, ValueSerializer} import sigmastate.utils.Helpers._ import sigmastate.{CompilerCrossVersionProps, SType, SigmaAnd} -import special.sigma.SigmaDslTesting +import sigma.SigmaDslTesting import java.math.BigInteger diff --git a/sc/shared/src/test/scala/org/ergoplatform/ErgoLikeTransactionSpec.scala b/sc/shared/src/test/scala/org/ergoplatform/ErgoLikeTransactionSpec.scala index 25c01af43d..1d644afcb5 100644 --- a/sc/shared/src/test/scala/org/ergoplatform/ErgoLikeTransactionSpec.scala +++ b/sc/shared/src/test/scala/org/ergoplatform/ErgoLikeTransactionSpec.scala @@ -14,8 +14,8 @@ import sigmastate.eval.Extensions._ import sigmastate.SType._ import sigmastate.helpers.TestingHelpers.copyTransaction import sigmastate.utils.Helpers -import special.sigma.SigmaDslTesting -import special.collection.Extensions._ +import sigma.SigmaDslTesting +import sigma.collection.Extensions._ class ErgoLikeTransactionSpec extends SigmaDslTesting { diff --git a/sc/shared/src/test/scala/org/ergoplatform/dsl/TestContractSpec.scala b/sc/shared/src/test/scala/org/ergoplatform/dsl/TestContractSpec.scala index 996db0e184..54e773ea35 100644 --- a/sc/shared/src/test/scala/org/ergoplatform/dsl/TestContractSpec.scala +++ b/sc/shared/src/test/scala/org/ergoplatform/dsl/TestContractSpec.scala @@ -18,7 +18,7 @@ import sigmastate.eval.{CSigmaProp, Evaluation, IRContext, CAnyValue} import sigmastate.helpers.{ContextEnrichingTestProvingInterpreter, ErgoLikeContextTesting, ErgoLikeTestInterpreter, CompilerTestingCommons} import sigmastate.helpers.TestingHelpers._ import sigmastate.lang.Terms.ValueOps -import special.sigma.{AnyValue, SigmaProp} +import sigma.{AnyValue, SigmaProp} case class TestContractSpec(testSuite: CompilerTestingCommons)(implicit val IR: IRContext) extends ContractSpec { diff --git a/sc/shared/src/test/scala/scalan/TestContexts.scala b/sc/shared/src/test/scala/scalan/TestContexts.scala index 2b01269672..78147e5da4 100644 --- a/sc/shared/src/test/scala/scalan/TestContexts.scala +++ b/sc/shared/src/test/scala/scalan/TestContexts.scala @@ -1,7 +1,7 @@ package scalan import scalan.reflection.RMethod -import special.CoreLibReflection +import sigma.CoreLibReflection trait TestContexts extends TestUtils { diff --git a/sc/shared/src/test/scala/sigmastate/ErgoTreeSpecification.scala b/sc/shared/src/test/scala/sigmastate/ErgoTreeSpecification.scala index 8025060afc..8a939fbb20 100644 --- a/sc/shared/src/test/scala/sigmastate/ErgoTreeSpecification.scala +++ b/sc/shared/src/test/scala/sigmastate/ErgoTreeSpecification.scala @@ -19,8 +19,8 @@ import sigmastate.lang.Terms._ import sigmastate.serialization.ErgoTreeSerializer.DefaultSerializer import sigmastate.utils.Helpers.TryOps import sigmastate.utxo._ -import special.collection._ -import special.sigma.{ContractsTestkit, SigmaDslTesting} +import sigma.collection._ +import sigma.{ContractsTestkit, SigmaDslTesting} /** Regression tests with ErgoTree related test vectors. diff --git a/sc/shared/src/test/scala/sigmastate/ScriptVersionSwitchSpecification.scala b/sc/shared/src/test/scala/sigmastate/ScriptVersionSwitchSpecification.scala index 11bf2602e5..ad5af68649 100644 --- a/sc/shared/src/test/scala/sigmastate/ScriptVersionSwitchSpecification.scala +++ b/sc/shared/src/test/scala/sigmastate/ScriptVersionSwitchSpecification.scala @@ -15,7 +15,7 @@ import sigmastate.interpreter.EvalSettings.EvaluationMode import sigmastate.interpreter.{CostedProverResult, ErgoTreeEvaluator, EvalSettings, Interpreter, ProverResult} import sigmastate.lang.Terms.ValueOps import sigmastate.utils.Helpers._ -import special.sigma.{Box, SigmaDslTesting} +import sigma.{Box, SigmaDslTesting} /** Specification to verify that the interpreter behaves according to docs/aot-jit-switch.md. * diff --git a/sc/shared/src/test/scala/sigmastate/SoftForkabilitySpecification.scala b/sc/shared/src/test/scala/sigmastate/SoftForkabilitySpecification.scala index e671f503b0..c576e24096 100644 --- a/sc/shared/src/test/scala/sigmastate/SoftForkabilitySpecification.scala +++ b/sc/shared/src/test/scala/sigmastate/SoftForkabilitySpecification.scala @@ -20,7 +20,7 @@ import sigmastate.serialization.SigmaSerializer.startReader import sigmastate.serialization._ import sigmastate.utils.Helpers._ import sigmastate.utxo.DeserializeContext -import special.sigma.SigmaTestingData +import sigma.SigmaTestingData class SoftForkabilitySpecification extends SigmaTestingData with CompilerTestingCommons diff --git a/sc/shared/src/test/scala/sigmastate/TypesSpecification.scala b/sc/shared/src/test/scala/sigmastate/TypesSpecification.scala index d9432bbc96..3d5edf22f2 100644 --- a/sc/shared/src/test/scala/sigmastate/TypesSpecification.scala +++ b/sc/shared/src/test/scala/sigmastate/TypesSpecification.scala @@ -3,7 +3,7 @@ package sigmastate import sigma.Environment import sigmastate.SType.isValueOfType import sigmastate.eval.{CSigmaProp, CostingSigmaDslBuilder} -import special.sigma.SigmaTestingData +import sigma.SigmaTestingData class TypesSpecification extends SigmaTestingData { diff --git a/sc/shared/src/test/scala/sigmastate/eval/ErgoScriptTestkit.scala b/sc/shared/src/test/scala/sigmastate/eval/ErgoScriptTestkit.scala index b1902877e8..5d949d65fc 100644 --- a/sc/shared/src/test/scala/sigmastate/eval/ErgoScriptTestkit.scala +++ b/sc/shared/src/test/scala/sigmastate/eval/ErgoScriptTestkit.scala @@ -14,7 +14,7 @@ import sigmastate.lang.Terms.ValueOps import sigmastate.lang.{CompilerResult, CompilerSettings, LangTests, SigmaCompiler} import sigmastate.serialization.ErgoTreeSerializer.DefaultSerializer import sigmastate.{AvlTreeData, CompilerTestsBase, SType} -import special.sigma.{ContractsTestkit, Context => DContext} +import sigma.{ContractsTestkit, Context => DContext} import scala.annotation.unused import scala.util.Success diff --git a/sc/shared/src/test/scala/sigmastate/helpers/CompilerTestingCommons.scala b/sc/shared/src/test/scala/sigmastate/helpers/CompilerTestingCommons.scala index b2b497e423..ab4df0c3f2 100644 --- a/sc/shared/src/test/scala/sigmastate/helpers/CompilerTestingCommons.scala +++ b/sc/shared/src/test/scala/sigmastate/helpers/CompilerTestingCommons.scala @@ -55,10 +55,10 @@ trait CompilerTestingCommons extends TestingCommons // (ctx.HEIGHT method call compiled to Height IR node) // ------- // We add ctx as it's own variable with id = 1 - val ctxVar = Extensions.toAnyValue[special.sigma.Context](ctx)(special.sigma.ContextRType) + val ctxVar = Extensions.toAnyValue[sigma.Context](ctx)(sigma.ContextRType) val newVars = if (ctx.vars.length < 2) { val vars = ctx.vars.toArray - val buf = new Array[special.sigma.AnyValue](2) + val buf = new Array[sigma.AnyValue](2) Array.copy(vars, 0, buf, 0, vars.length) buf(1) = ctxVar CostingSigmaDslBuilder.Colls.fromArray(buf) diff --git a/sc/shared/src/test/scala/sigmastate/helpers/SigmaPPrint.scala b/sc/shared/src/test/scala/sigmastate/helpers/SigmaPPrint.scala index 38ae6c6740..a1b1c97c86 100644 --- a/sc/shared/src/test/scala/sigmastate/helpers/SigmaPPrint.scala +++ b/sc/shared/src/test/scala/sigmastate/helpers/SigmaPPrint.scala @@ -17,8 +17,8 @@ import sigmastate.lang.Terms.MethodCall import sigmastate.serialization.GroupElementSerializer import sigmastate.utxo.SelectField import sigmastate.interpreter.{CompanionDesc, ErgoTreeEvaluator, FixedCostItem, MethodDesc} -import special.collection.{Coll, CollType} -import special.sigma.GroupElement +import sigma.collection.{Coll, CollType} +import sigma.GroupElement import scala.collection.compat.immutable.ArraySeq import scala.collection.mutable diff --git a/sc/shared/src/test/scala/sigmastate/utxo/AVLTreeScriptsSpecification.scala b/sc/shared/src/test/scala/sigmastate/utxo/AVLTreeScriptsSpecification.scala index 9fd017eeae..520f625a94 100644 --- a/sc/shared/src/test/scala/sigmastate/utxo/AVLTreeScriptsSpecification.scala +++ b/sc/shared/src/test/scala/sigmastate/utxo/AVLTreeScriptsSpecification.scala @@ -17,8 +17,8 @@ import sigmastate.helpers.TestingHelpers._ import sigmastate.interpreter.Interpreter.ScriptNameProp import sigmastate.interpreter.ProverResult import sigmastate.lang.Terms._ -import special.collection.Coll -import special.sigma.{AvlTree, Context} +import sigma.collection.Coll +import sigma.{AvlTree, Context} class AVLTreeScriptsSpecification extends CompilerTestingCommons diff --git a/sc/shared/src/test/scala/sigmastate/utxo/ContextEnrichingSpecification.scala b/sc/shared/src/test/scala/sigmastate/utxo/ContextEnrichingSpecification.scala index c76606ed96..3e9d7394bd 100644 --- a/sc/shared/src/test/scala/sigmastate/utxo/ContextEnrichingSpecification.scala +++ b/sc/shared/src/test/scala/sigmastate/utxo/ContextEnrichingSpecification.scala @@ -6,7 +6,7 @@ import sigmastate.Values._ import sigmastate._ import sigmastate.lang.Terms._ import sigmastate.helpers.{ContextEnrichingTestProvingInterpreter, ErgoLikeContextTesting, ErgoLikeTestInterpreter, CompilerTestingCommons} -import special.collection.Coll +import sigma.collection.Coll class ContextEnrichingSpecification extends CompilerTestingCommons diff --git a/sc/shared/src/test/scala/sigmastate/utxo/UsingContextPropertiesSpecification.scala b/sc/shared/src/test/scala/sigmastate/utxo/UsingContextPropertiesSpecification.scala index dea73e67b4..e83d9a8569 100644 --- a/sc/shared/src/test/scala/sigmastate/utxo/UsingContextPropertiesSpecification.scala +++ b/sc/shared/src/test/scala/sigmastate/utxo/UsingContextPropertiesSpecification.scala @@ -3,7 +3,7 @@ package sigmastate.utxo import sigmastate.{TrivialProp, CompilerCrossVersionProps} import sigmastate.eval.{IRContext, CSigmaProp} import sigmastate.eval.Extensions._ -import special.sigma.Context +import sigma.Context import sigmastate.helpers.CompilerTestingCommons import org.ergoplatform.dsl.{SigmaContractSyntax, ContractSpec, TestContractSpec} import org.ergoplatform.ErgoBox diff --git a/sc/shared/src/test/scala/sigmastate/utxo/examples/AssetsAtomicExchange.scala b/sc/shared/src/test/scala/sigmastate/utxo/examples/AssetsAtomicExchange.scala index c27dd1356d..e1780c3b04 100644 --- a/sc/shared/src/test/scala/sigmastate/utxo/examples/AssetsAtomicExchange.scala +++ b/sc/shared/src/test/scala/sigmastate/utxo/examples/AssetsAtomicExchange.scala @@ -1,9 +1,9 @@ package sigmastate.utxo.examples import org.ergoplatform.dsl.ContractSyntax.Token -import special.sigma.Context +import sigma.Context import org.ergoplatform.ErgoBox.{R4, TokenId} -import special.collection.Coll +import sigma.collection.Coll import org.ergoplatform.dsl.{SigmaContractSyntax, ContractSpec, StdContracts} /** Contract specification for assets atomic exchange transactions. diff --git a/sc/shared/src/test/scala/sigmastate/utxo/examples/AssetsAtomicExchangeErgoTests.scala b/sc/shared/src/test/scala/sigmastate/utxo/examples/AssetsAtomicExchangeErgoTests.scala index 9a84f6cf1d..b5883ec7d6 100644 --- a/sc/shared/src/test/scala/sigmastate/utxo/examples/AssetsAtomicExchangeErgoTests.scala +++ b/sc/shared/src/test/scala/sigmastate/utxo/examples/AssetsAtomicExchangeErgoTests.scala @@ -3,7 +3,7 @@ package sigmastate.utxo.examples import sigmastate.helpers.CompilerTestingCommons import org.ergoplatform.dsl.ContractSyntax.Token import org.ergoplatform.dsl.ErgoContractSpec -import special.collection.Coll +import sigma.collection.Coll import scorex.crypto.hash.Blake2b256 import sigmastate.eval.Digest32Coll diff --git a/sc/shared/src/test/scala/sigmastate/utxo/examples/AssetsPartialFilling.scala b/sc/shared/src/test/scala/sigmastate/utxo/examples/AssetsPartialFilling.scala index ad5126d626..c7c3b88458 100644 --- a/sc/shared/src/test/scala/sigmastate/utxo/examples/AssetsPartialFilling.scala +++ b/sc/shared/src/test/scala/sigmastate/utxo/examples/AssetsPartialFilling.scala @@ -2,8 +2,8 @@ package sigmastate.utxo.examples import org.ergoplatform.ErgoBox.TokenId import org.ergoplatform.dsl.ContractSyntax.Token -import special.sigma.Context -import special.collection.Coll +import sigma.Context +import sigma.collection.Coll import org.ergoplatform.dsl.{SigmaContractSyntax, ContractSpec, StdContracts} /** diff --git a/sc/shared/src/test/scala/sigmastate/utxo/examples/CrowdFunding.scala b/sc/shared/src/test/scala/sigmastate/utxo/examples/CrowdFunding.scala index ebbf021fb8..d73c0721df 100644 --- a/sc/shared/src/test/scala/sigmastate/utxo/examples/CrowdFunding.scala +++ b/sc/shared/src/test/scala/sigmastate/utxo/examples/CrowdFunding.scala @@ -1,6 +1,6 @@ package sigmastate.utxo.examples -import special.sigma.{Context, Box} +import sigma.{Context, Box} import org.ergoplatform.dsl.{SigmaContractSyntax, ContractSpec, StdContracts} /** @param backer The party, who wants to fund some amount of Ergs to the project. diff --git a/sc/shared/src/test/scala/sigmastate/utxo/examples/DummyExamplesSpecification.scala b/sc/shared/src/test/scala/sigmastate/utxo/examples/DummyExamplesSpecification.scala index 9206a6502c..c24b629b7d 100644 --- a/sc/shared/src/test/scala/sigmastate/utxo/examples/DummyExamplesSpecification.scala +++ b/sc/shared/src/test/scala/sigmastate/utxo/examples/DummyExamplesSpecification.scala @@ -4,8 +4,8 @@ import org.ergoplatform.ErgoBox import org.ergoplatform.dsl.{ContractSpec, SigmaContractSyntax, StdContracts, TestContractSpec} import scorex.crypto.hash import sigmastate.helpers.CompilerTestingCommons -import special.collection.Coll -import special.sigma.{Box, Context} +import sigma.collection.Coll +import sigma.{Box, Context} import sigmastate.eval.Extensions class DummyExamplesSpecification extends CompilerTestingCommons { suite => diff --git a/sc/shared/src/test/scala/sigmastate/utxo/examples/ExecuteFromExamplesSpecification.scala b/sc/shared/src/test/scala/sigmastate/utxo/examples/ExecuteFromExamplesSpecification.scala index 34fbc5e356..5ea4ef7a05 100644 --- a/sc/shared/src/test/scala/sigmastate/utxo/examples/ExecuteFromExamplesSpecification.scala +++ b/sc/shared/src/test/scala/sigmastate/utxo/examples/ExecuteFromExamplesSpecification.scala @@ -3,7 +3,7 @@ package sigmastate.utxo.examples import org.ergoplatform._ import org.ergoplatform.dsl.{ContractSpec, SigmaContractSyntax, StdContracts, TestContractSpec} import sigmastate.helpers.CompilerTestingCommons -import special.sigma.Context +import sigma.Context import sigmastate.eval.Extensions._ class ExecuteFromExamplesSpecification extends CompilerTestingCommons { suite => diff --git a/sc/shared/src/test/scala/sigmastate/utxo/examples/OracleDataInputsExamplesSpecification.scala b/sc/shared/src/test/scala/sigmastate/utxo/examples/OracleDataInputsExamplesSpecification.scala index 002d1836c9..0be9e3d02c 100644 --- a/sc/shared/src/test/scala/sigmastate/utxo/examples/OracleDataInputsExamplesSpecification.scala +++ b/sc/shared/src/test/scala/sigmastate/utxo/examples/OracleDataInputsExamplesSpecification.scala @@ -6,8 +6,8 @@ import org.ergoplatform.dsl.{ContractSpec, SigmaContractSyntax, StdContracts, Te import scorex.crypto.hash.Blake2b256 import sigmastate.eval.Digest32Coll import sigmastate.helpers.CompilerTestingCommons -import special.collection.Coll -import special.sigma.Context +import sigma.collection.Coll +import sigma.Context class OracleDataInputsExamplesSpecification extends CompilerTestingCommons { suite => implicit lazy val IR: TestingIRContext = new TestingIRContext diff --git a/sc/shared/src/test/scala/sigmastate/utxo/examples/OracleExamplesSpecification.scala b/sc/shared/src/test/scala/sigmastate/utxo/examples/OracleExamplesSpecification.scala index 384f0d4b63..c477638d6f 100644 --- a/sc/shared/src/test/scala/sigmastate/utxo/examples/OracleExamplesSpecification.scala +++ b/sc/shared/src/test/scala/sigmastate/utxo/examples/OracleExamplesSpecification.scala @@ -19,7 +19,7 @@ import sigmastate.crypto.{BigIntegers, CryptoFacade} import sigmastate.eval.Extensions.ArrayOps import sigmastate.interpreter.Interpreter.{ScriptNameProp, emptyEnv} import sigmastate.utxo._ -import special.sigma.Context +import sigma.Context import sigmastate.utils.Helpers._ class OracleExamplesSpecification extends CompilerTestingCommons diff --git a/sc/shared/src/test/scala/sigmastate/utxo/examples/OracleTokenExamplesSpecification.scala b/sc/shared/src/test/scala/sigmastate/utxo/examples/OracleTokenExamplesSpecification.scala index 7087854598..a9e254cc37 100644 --- a/sc/shared/src/test/scala/sigmastate/utxo/examples/OracleTokenExamplesSpecification.scala +++ b/sc/shared/src/test/scala/sigmastate/utxo/examples/OracleTokenExamplesSpecification.scala @@ -6,8 +6,8 @@ import org.ergoplatform.dsl.{ContractSpec, SigmaContractSyntax, StdContracts, Te import scorex.crypto.hash.Blake2b256 import sigmastate.eval.Digest32Coll import sigmastate.helpers.CompilerTestingCommons -import special.collection.Coll -import special.sigma.Context +import sigma.collection.Coll +import sigma.Context class OracleTokenExamplesSpecification extends CompilerTestingCommons { suite => implicit lazy val IR: TestingIRContext = new TestingIRContext diff --git a/sc/shared/src/test/scala/sigmastate/utxo/examples/RevenueSharingExamplesSpecification.scala b/sc/shared/src/test/scala/sigmastate/utxo/examples/RevenueSharingExamplesSpecification.scala index 90cf1871a6..41d3b59039 100644 --- a/sc/shared/src/test/scala/sigmastate/utxo/examples/RevenueSharingExamplesSpecification.scala +++ b/sc/shared/src/test/scala/sigmastate/utxo/examples/RevenueSharingExamplesSpecification.scala @@ -3,7 +3,7 @@ package sigmastate.utxo.examples import org.ergoplatform.dsl.{SigmaContractSyntax, ContractSpec, TestContractSpec, StdContracts} import sigmastate.eval.Extensions import sigmastate.helpers.CompilerTestingCommons -import special.sigma.Context +import sigma.Context class RevenueSharingExamplesSpecification extends CompilerTestingCommons { suite => implicit lazy val IR = new TestingIRContext diff --git a/sc/shared/src/test/scala/special/collections/CollsStagingTests.scala b/sc/shared/src/test/scala/special/collections/CollsStagingTests.scala index 7abe786b04..8df061299d 100644 --- a/sc/shared/src/test/scala/special/collections/CollsStagingTests.scala +++ b/sc/shared/src/test/scala/special/collections/CollsStagingTests.scala @@ -1,4 +1,4 @@ -package special.collections +package sigma.collections import scala.language.reflectiveCalls import special.wrappers.WrappersTests @@ -47,7 +47,7 @@ class CollsStagingTests extends WrappersTests { import EnvRep._ import Liftables._ - val Cols: SCollBuilder = new special.collection.CollOverArrayBuilder + val Cols: SCollBuilder = new sigma.collection.CollOverArrayBuilder val arr = Array(1, 2, 3) val col = Cols.fromArray(arr) @@ -63,7 +63,7 @@ class CollsStagingTests extends WrappersTests { import Coll._ import CollBuilder._ - val Cols: SCollBuilder = new special.collection.CollOverArrayBuilder + val Cols: SCollBuilder = new sigma.collection.CollOverArrayBuilder val colData = Cols.replicate(10, 10) val colSym = colBuilder.replicate(10, 10) val resSym = colSym.append(colSym) diff --git a/sc/shared/src/test/scala/special/sigma/DataValueComparerSpecification.scala b/sc/shared/src/test/scala/special/sigma/DataValueComparerSpecification.scala index eaca756182..9cf9562e50 100644 --- a/sc/shared/src/test/scala/special/sigma/DataValueComparerSpecification.scala +++ b/sc/shared/src/test/scala/special/sigma/DataValueComparerSpecification.scala @@ -1,4 +1,4 @@ -package special.sigma +package sigma import org.scalatest.BeforeAndAfterAll import scalan.RType @@ -8,7 +8,7 @@ import sigmastate.Values.ErgoTree import sigmastate.eval.{CSigmaProp, Profiler, SigmaDsl} import sigmastate.helpers.SigmaPPrint import sigmastate.interpreter.{CostAccumulator, ErgoTreeEvaluator, EvalSettings, TracedCost} -import special.collection.Coll +import sigma.collection.Coll import scala.util.{Success, Try} diff --git a/sc/shared/src/test/scala/special/sigma/LoopTests.scala b/sc/shared/src/test/scala/special/sigma/LoopTests.scala index 37ff177c8e..ae1b2438f0 100644 --- a/sc/shared/src/test/scala/special/sigma/LoopTests.scala +++ b/sc/shared/src/test/scala/special/sigma/LoopTests.scala @@ -1,4 +1,4 @@ -package special.sigma +package sigma import sigmastate.helpers.CompilerTestingCommons diff --git a/sc/shared/src/test/scala/special/sigma/SigmaDslSpecification.scala b/sc/shared/src/test/scala/special/sigma/SigmaDslSpecification.scala index 812092d668..afb3868cdf 100644 --- a/sc/shared/src/test/scala/special/sigma/SigmaDslSpecification.scala +++ b/sc/shared/src/test/scala/special/sigma/SigmaDslSpecification.scala @@ -1,4 +1,4 @@ -package special.sigma +package sigma import java.math.BigInteger import org.ergoplatform._ @@ -20,8 +20,8 @@ import sigmastate.eval.Extensions._ import sigmastate.eval._ import sigmastate.lang.Terms.{MethodCall, PropertyCall} import sigmastate.utxo._ -import special.collection._ -import special.collection.Extensions._ +import sigma.collection._ +import sigma.collection.Extensions._ import sigmastate.serialization.OpCodes.OpCode import sigmastate.utils.Helpers import sigmastate.utils.Helpers._ @@ -6891,7 +6891,7 @@ class SigmaDslSpecification extends SigmaDslTesting )), preGeneratedSamples = Some(samples)) } else { - def error = new java.lang.NoSuchMethodException("sigmastate.SCollection$.forall_eval(sigmastate.lang.Terms$MethodCall,special.collection.Coll,scala.Function1,sigmastate.interpreter.ErgoTreeEvaluator))") + def error = new java.lang.NoSuchMethodException("sigmastate.SCollection$.forall_eval(sigmastate.lang.Terms$MethodCall,sigma.collection.Coll,scala.Function1,sigmastate.interpreter.ErgoTreeEvaluator))") verifyCases( Seq((Coll[Box](), Expected(error))), existingFeature[Coll[Box], Boolean]({ (x: Coll[Box]) => throw error }, @@ -6967,7 +6967,7 @@ class SigmaDslSpecification extends SigmaDslTesting )), preGeneratedSamples = Some(samples)) } else { - def error = new java.lang.NoSuchMethodException("sigmastate.SCollection$.exist_eval(sigmastate.lang.Terms$MethodCall,special.collection.Coll,scala.Function1,sigmastate.interpreter.ErgoTreeEvaluator))") + def error = new java.lang.NoSuchMethodException("sigmastate.SCollection$.exist_eval(sigmastate.lang.Terms$MethodCall,sigma.collection.Coll,scala.Function1,sigmastate.interpreter.ErgoTreeEvaluator))") verifyCases( Seq((Coll[Box](), Expected(error))), existingFeature[Coll[Box], Boolean]({ (x: Coll[Box]) => throw error }, @@ -7072,7 +7072,7 @@ class SigmaDslSpecification extends SigmaDslTesting ) ))) } else { - def error = new java.lang.NoSuchMethodException("sigmastate.SCollection$.exist_eval(sigmastate.lang.Terms$MethodCall,special.collection.Coll,scala.Function1,sigmastate.interpreter.ErgoTreeEvaluator))") + def error = new java.lang.NoSuchMethodException("sigmastate.SCollection$.exist_eval(sigmastate.lang.Terms$MethodCall,sigma.collection.Coll,scala.Function1,sigmastate.interpreter.ErgoTreeEvaluator))") verifyCases( Seq( (Coll[BigInt](), Expected(error)) ), existingFeature[Coll[BigInt], Boolean]( @@ -7187,7 +7187,7 @@ class SigmaDslSpecification extends SigmaDslTesting ) ))) } else { - def error = new java.lang.NoSuchMethodException("sigmastate.SCollection$.exist_eval(sigmastate.lang.Terms$MethodCall,special.collection.Coll,scala.Function1,sigmastate.interpreter.ErgoTreeEvaluator))") + def error = new java.lang.NoSuchMethodException("sigmastate.SCollection$.exist_eval(sigmastate.lang.Terms$MethodCall,sigma.collection.Coll,scala.Function1,sigmastate.interpreter.ErgoTreeEvaluator))") verifyCases( Seq( (Coll[BigInt](), Expected(error)) ), existingFeature[Coll[BigInt], Boolean]( @@ -7795,7 +7795,7 @@ class SigmaDslSpecification extends SigmaDslTesting ) ))) } else { - def error = new java.lang.NoSuchMethodException("sigmastate.SCollection$.fold_eval(sigmastate.lang.Terms$MethodCall,special.collection.Coll,java.lang.Object,scala.Function1,sigmastate.interpreter.ErgoTreeEvaluator))") + def error = new java.lang.NoSuchMethodException("sigmastate.SCollection$.fold_eval(sigmastate.lang.Terms$MethodCall,sigma.collection.Coll,java.lang.Object,scala.Function1,sigmastate.interpreter.ErgoTreeEvaluator))") verifyCases( Seq( ((Coll[Byte](), 0), Expected(error)) ), existingFeature[(Coll[Byte], Int), Int]( @@ -8073,7 +8073,7 @@ class SigmaDslSpecification extends SigmaDslTesting ) ) )) } else { - def error = new java.lang.NoSuchMethodException("sigmastate.SCollection$.fold_eval(sigmastate.lang.Terms$MethodCall,special.collection.Coll,int,int,sigmastate.interpreter.ErgoTreeEvaluator))") + def error = new java.lang.NoSuchMethodException("sigmastate.SCollection$.fold_eval(sigmastate.lang.Terms$MethodCall,sigma.collection.Coll,int,int,sigmastate.interpreter.ErgoTreeEvaluator))") verifyCases( Seq( ((Coll[Byte](), 0), Expected(error)) ), existingFeature( @@ -8739,7 +8739,7 @@ class SigmaDslSpecification extends SigmaDslTesting )), preGeneratedSamples = Some(samples)) } else { - def error = new java.lang.NoSuchMethodException("sigmastate.SCollection$.slice_eval(sigmastate.lang.Terms$MethodCall,special.collection.Coll,int,int,sigmastate.interpreter.ErgoTreeEvaluator))") + def error = new java.lang.NoSuchMethodException("sigmastate.SCollection$.slice_eval(sigmastate.lang.Terms$MethodCall,sigma.collection.Coll,int,int,sigmastate.interpreter.ErgoTreeEvaluator))") verifyCases( Seq( (Coll[Int](), (-1, 0)) -> Expected(error) ), existingFeature({ (x: (Coll[Int], (Int, Int))) => throw error; x._1.slice(x._2._1, x._2._2) }, @@ -8818,7 +8818,7 @@ class SigmaDslSpecification extends SigmaDslTesting ) ))) } else { - def error = new java.lang.NoSuchMethodException("sigmastate.SCollection$.append_eval(sigmastate.lang.Terms$MethodCall,special.collection.Coll,special.collection.Coll,sigmastate.interpreter.ErgoTreeEvaluator))") + def error = new java.lang.NoSuchMethodException("sigmastate.SCollection$.append_eval(sigmastate.lang.Terms$MethodCall,sigma.collection.Coll,sigma.collection.Coll,sigmastate.interpreter.ErgoTreeEvaluator))") verifyCases( Seq( (Coll[Int](), Coll[Int]()) -> Expected(error) ), existingFeature( @@ -9948,7 +9948,7 @@ class SigmaDslSpecification extends SigmaDslTesting preGeneratedSamples = Some(Seq.empty) ) } else { - def error = new java.lang.NoSuchMethodException("sigmastate.SCollection$.fold_eval(sigmastate.lang.Terms$MethodCall,special.collection.Coll,java.lang.Object,scala.Function1,sigmastate.interpreter.ErgoTreeEvaluator))") + def error = new java.lang.NoSuchMethodException("sigmastate.SCollection$.fold_eval(sigmastate.lang.Terms$MethodCall,sigma.collection.Coll,java.lang.Object,scala.Function1,sigmastate.interpreter.ErgoTreeEvaluator))") verifyCases( Seq( (keys, initial) -> Expected(error) ), existingFeature[(Coll[Coll[Byte]], Coll[Byte]), Coll[Byte]]( diff --git a/sc/shared/src/test/scala/special/sigma/SigmaDslStaginTests.scala b/sc/shared/src/test/scala/special/sigma/SigmaDslStaginTests.scala index 97ee39d07a..1c67410585 100644 --- a/sc/shared/src/test/scala/special/sigma/SigmaDslStaginTests.scala +++ b/sc/shared/src/test/scala/special/sigma/SigmaDslStaginTests.scala @@ -1,14 +1,13 @@ -package special.sigma +package sigma -import org.scalatest.{BeforeAndAfterAll} -import special.collection._ - -import scala.language.reflectiveCalls +import org.scalatest.BeforeAndAfterAll import scalan.{BaseCtxTests, BaseLiftableTests} -import sigma.VersionContext -import sigmastate.{eval, TrivialProp} +import sigma.collection._ import sigmastate.eval.Extensions._ import sigmastate.eval._ +import sigmastate.{TrivialProp, eval} + +import scala.language.reflectiveCalls class SigmaDslStaginTests extends BaseCtxTests with ErgoScriptTestkit with BaseLiftableTests with BeforeAndAfterAll { class Ctx extends TestContext with IRContext with LiftableTestKit { @@ -17,13 +16,13 @@ class SigmaDslStaginTests extends BaseCtxTests with ErgoScriptTestkit with BaseL test("invokeUnlifted") { val cake = new Ctx import cake._ - import Liftables._ - import Context._ - import Coll._ import Box._ - import SigmaProp._ - import SigmaDslBuilder._ + import Coll._ + import Context._ import EnvRep._ + import Liftables._ + import SigmaDslBuilder._ + import SigmaProp._ val dsl: SSigmaDslBuilder = eval.SigmaDsl type RSigmaDslBuilder = cake.SigmaDslBuilder @@ -47,7 +46,7 @@ class SigmaDslStaginTests extends BaseCtxTests with ErgoScriptTestkit with BaseL cake.check(boxA1, { env: EnvRep[RBox] => for { obj <- env } yield obj.value }, boxA1.value) cake.check(boxA1, { env: EnvRep[RBox] => for { obj <- env } yield obj.creationInfo }, boxA1.creationInfo) - cake.check(boxA1, { env: EnvRep[RBox] => for { obj <- env; arg <- lifted(1) } yield obj.getReg[Coll[Byte]](arg) }, boxA1.getReg[special.collection.Coll[Byte]](1)) + cake.check(boxA1, { env: EnvRep[RBox] => for { obj <- env; arg <- lifted(1) } yield obj.getReg[Coll[Byte]](arg) }, boxA1.getReg[sigma.collection.Coll[Byte]](1)) } diff --git a/sc/shared/src/test/scala/special/sigma/SigmaDslTesting.scala b/sc/shared/src/test/scala/special/sigma/SigmaDslTesting.scala index 0f1e84f5b7..66b0ec6558 100644 --- a/sc/shared/src/test/scala/special/sigma/SigmaDslTesting.scala +++ b/sc/shared/src/test/scala/special/sigma/SigmaDslTesting.scala @@ -1,4 +1,4 @@ -package special.sigma +package sigma import debox.cfor import org.ergoplatform._ @@ -36,7 +36,7 @@ import sigmastate.serialization.generators.ObjectGenerators import sigmastate.utils.Helpers._ import sigmastate.utxo.{DeserializeContext, DeserializeRegister, GetVar, OptionGet} import sigmastate.{SOption, SSigmaProp, SType, SigmaLeaf, eval} -import special.collection.{Coll, CollType} +import sigma.collection.{Coll, CollType} import java.util import scala.collection.mutable @@ -352,7 +352,7 @@ class SigmaDslTesting extends AnyPropSpec ) // We add ctx as it's own variable with id = 1 - val ctxVar = eval.Extensions.toAnyValue[special.sigma.Context](ctx)(special.sigma.ContextRType) + val ctxVar = eval.Extensions.toAnyValue[sigma.Context](ctx)(sigma.ContextRType) val carolVar = eval.Extensions.toAnyValue[Coll[Byte]](pkCarolBytes.toColl)(RType[Coll[Byte]]) val newCtx = ctx .withUpdatedVars(1 -> ctxVar, 2 -> carolVar) diff --git a/sdk/js/src/main/scala/org/ergoplatform/sdk/js/AvlTree.scala b/sdk/js/src/main/scala/org/ergoplatform/sdk/js/AvlTree.scala index 19edc35f40..f1cf64377c 100644 --- a/sdk/js/src/main/scala/org/ergoplatform/sdk/js/AvlTree.scala +++ b/sdk/js/src/main/scala/org/ergoplatform/sdk/js/AvlTree.scala @@ -4,7 +4,7 @@ import scala.scalajs.js import scala.scalajs.js.UndefOr import scala.scalajs.js.annotation.JSExportTopLevel -/** Equivalent of [[special.sigma.AvlTree]] available from JS. */ +/** Equivalent of [[sigma.AvlTree]] available from JS. */ @JSExportTopLevel("AvlTree") class AvlTree( val digest: String, diff --git a/sdk/js/src/main/scala/org/ergoplatform/sdk/js/GroupElement.scala b/sdk/js/src/main/scala/org/ergoplatform/sdk/js/GroupElement.scala index cc20e704bb..857592d4a2 100644 --- a/sdk/js/src/main/scala/org/ergoplatform/sdk/js/GroupElement.scala +++ b/sdk/js/src/main/scala/org/ergoplatform/sdk/js/GroupElement.scala @@ -6,7 +6,7 @@ import sigmastate.eval.Extensions.ArrayByteOps import scala.scalajs.js import scala.scalajs.js.annotation.JSExportTopLevel -/** Equivalent of [[special.sigma.GroupElement]] available from JS. */ +/** Equivalent of [[sigma.GroupElement]] available from JS. */ @JSExportTopLevel("GroupElement") class GroupElement(val point: Ecp) extends js.Object { /** Returns the point encoded as hex string (ASN.1 encoding). diff --git a/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Header.scala b/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Header.scala index fecd4ef67c..43ea9ecb29 100644 --- a/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Header.scala +++ b/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Header.scala @@ -3,7 +3,7 @@ package org.ergoplatform.sdk.js import scala.scalajs.js import scala.scalajs.js.annotation.JSExportTopLevel -/** Equivalent of [[special.sigma.Header]] available from JS. */ +/** Equivalent of [[sigma.Header]] available from JS. */ @JSExportTopLevel("Header") class Header( val id: String, diff --git a/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Isos.scala b/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Isos.scala index 4ee64c9b96..f97edd0ab9 100644 --- a/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Isos.scala +++ b/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Isos.scala @@ -21,10 +21,9 @@ import sigmastate.fleetSdkCommon.{distEsmTypesBoxesMod => boxesMod, distEsmTypes import sigmastate.interpreter.{ContextExtension, ProverResult} import sigmastate.serialization.{ErgoTreeSerializer, ValueSerializer} import sigmastate.{AvlTreeData, AvlTreeFlags, SType} -import special.collection.Coll -import special.collection.Extensions.CollBytesOps -import special.sigma -import special.sigma.GroupElement +import sigma.collection.Coll +import sigma.collection.Extensions.CollBytesOps +import sigma.GroupElement import java.math.BigInteger import scala.collection.immutable.ListMap @@ -111,7 +110,7 @@ object Isos { } } - implicit val isoHeader: Iso[Header, special.sigma.Header] = new Iso[Header, special.sigma.Header] { + implicit val isoHeader: Iso[Header, sigma.Header] = new Iso[Header, sigma.Header] { override def to(a: Header): sigma.Header = { CHeader( id = isoStringToColl.to(a.id), @@ -153,7 +152,7 @@ object Isos { } } - implicit val isoPreHeader: Iso[PreHeader, special.sigma.PreHeader] = new Iso[PreHeader, special.sigma.PreHeader] { + implicit val isoPreHeader: Iso[PreHeader, sigma.PreHeader] = new Iso[PreHeader, sigma.PreHeader] { override def to(a: PreHeader): sigma.PreHeader = { CPreHeader( version = a.version, @@ -255,7 +254,7 @@ object Isos { override def from(x: DataInput): inputsMod.DataInput = inputsMod.DataInput(x.boxId.convertTo[boxesMod.BoxId]) } - implicit val isoBigInt: Iso[js.BigInt, special.sigma.BigInt] = new Iso[js.BigInt, special.sigma.BigInt] { + implicit val isoBigInt: Iso[js.BigInt, sigma.BigInt] = new Iso[js.BigInt, sigma.BigInt] { override def to(x: js.BigInt): sigma.BigInt = { CBigInt(new BigInteger(x.toString(10))) } diff --git a/sdk/js/src/main/scala/org/ergoplatform/sdk/js/PreHeader.scala b/sdk/js/src/main/scala/org/ergoplatform/sdk/js/PreHeader.scala index 7e38032446..a3b7eeb7f3 100644 --- a/sdk/js/src/main/scala/org/ergoplatform/sdk/js/PreHeader.scala +++ b/sdk/js/src/main/scala/org/ergoplatform/sdk/js/PreHeader.scala @@ -3,7 +3,7 @@ package org.ergoplatform.sdk.js import scala.scalajs.js import scala.scalajs.js.annotation.JSExportTopLevel -/** Equivalent of [[special.sigma.PreHeader]] available from JS. */ +/** Equivalent of [[sigma.PreHeader]] available from JS. */ @JSExportTopLevel("PreHeader") class PreHeader( val version: Byte, diff --git a/sdk/js/src/main/scala/org/ergoplatform/sdk/js/SigmaProp.scala b/sdk/js/src/main/scala/org/ergoplatform/sdk/js/SigmaProp.scala index bc2da23561..c44a6a19db 100644 --- a/sdk/js/src/main/scala/org/ergoplatform/sdk/js/SigmaProp.scala +++ b/sdk/js/src/main/scala/org/ergoplatform/sdk/js/SigmaProp.scala @@ -6,7 +6,7 @@ import sigmastate.basics.DLogProtocol.ProveDlog import scala.scalajs.js import scala.scalajs.js.annotation.JSExportTopLevel -/** Equivalent of [[special.sigma.SigmaProp]] available from JS. */ +/** Equivalent of [[sigma.SigmaProp]] available from JS. */ @JSExportTopLevel("SigmaProp") class SigmaProp(val sigmaBoolean: SigmaBoolean) extends js.Object { } diff --git a/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Type.scala b/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Type.scala index ba4c7128b9..9565ce5b73 100644 --- a/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Type.scala +++ b/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Type.scala @@ -32,33 +32,33 @@ object Type extends js.Object { val Long = new Type(RType.LongType) /** Descriptor of ErgoScript type BigInt. */ - val BigInt = new Type(special.sigma.BigIntRType) + val BigInt = new Type(sigma.BigIntRType) /** Descriptor of ErgoScript type GroupElement. */ - val GroupElement = new Type(special.sigma.GroupElementRType) + val GroupElement = new Type(sigma.GroupElementRType) /** Descriptor of ErgoScript type SigmaProp. */ - val SigmaProp = new Type(special.sigma.SigmaPropRType) + val SigmaProp = new Type(sigma.SigmaPropRType) /** Descriptor of ErgoScript type Box. */ - val Box = new Type(special.sigma.BoxRType) + val Box = new Type(sigma.BoxRType) /** Descriptor of ErgoScript type AvlTree. */ - val AvlTree = new Type(special.sigma.AvlTreeRType) + val AvlTree = new Type(sigma.AvlTreeRType) /** Descriptor of ErgoScript type Context. */ - val Context = new Type(special.sigma.ContextRType) + val Context = new Type(sigma.ContextRType) /** Descriptor of ErgoScript type Header. */ - val Header = new Type(special.sigma.HeaderRType) + val Header = new Type(sigma.HeaderRType) /** Descriptor of ErgoScript type PreHeader. */ - val PreHeader = new Type(special.sigma.PreHeaderRType) + val PreHeader = new Type(sigma.PreHeaderRType) /** Descriptor of ErgoScript type Global. * @see SigmaDslBuilder, SGlobal */ - val SigmaDslBuilder = new Type(special.sigma.SigmaDslBuilderRType) + val SigmaDslBuilder = new Type(sigma.SigmaDslBuilderRType) /** Constructs a new descriptor of ErgoScript pair type (l, r). * @param l first component of the pair @@ -73,6 +73,6 @@ object Type extends js.Object { * @param elemType type descriptor of collection elements */ def collType(elemType: Type): Type = { - new Type(special.collection.collRType(elemType.rtype)) + new Type(sigma.collection.collRType(elemType.rtype)) } } \ No newline at end of file diff --git a/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Value.scala b/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Value.scala index 0c30216dbc..39fc89c058 100644 --- a/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Value.scala +++ b/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Value.scala @@ -13,7 +13,7 @@ import sigmastate.fleetSdkCommon.distEsmTypesCommonMod import sigmastate.fleetSdkCommon.distEsmTypesRegistersMod.NonMandatoryRegisters import sigmastate.lang.DeserializationSigmaBuilder import sigmastate.serialization.{ConstantSerializer, DataSerializer, SigmaSerializer} -import special.collection.{Coll, CollType} +import sigma.collection.{Coll, CollType} import java.math.BigInteger import scala.scalajs.js @@ -85,19 +85,19 @@ object Value extends js.Object { case RType.BooleanType => data case RType.ByteType | RType.ShortType | RType.IntType => data case RType.LongType => java.lang.Long.parseLong(data.asInstanceOf[js.BigInt].toString(10)) - case special.sigma.BigIntRType => + case sigma.BigIntRType => val v = data.asInstanceOf[js.BigInt] SigmaDsl.BigInt(new BigInteger(v.toString(16), 16)) - case special.sigma.GroupElementRType => + case sigma.GroupElementRType => val ge = data.asInstanceOf[GroupElement] SigmaDsl.GroupElement(ge.point) - case special.sigma.SigmaPropRType => + case sigma.SigmaPropRType => val p = data.asInstanceOf[SigmaProp] SigmaDsl.SigmaProp(p.sigmaBoolean) - case special.sigma.AvlTreeRType => + case sigma.AvlTreeRType => val t = data.asInstanceOf[AvlTree] Isos.isoAvlTree.to(t) - case special.sigma.BoxRType => + case sigma.BoxRType => val t = data.asInstanceOf[Box[distEsmTypesCommonMod.Amount, NonMandatoryRegisters]] SigmaDsl.Box(Isos.isoBox.to(t)) case ct: CollType[a] => @@ -125,17 +125,17 @@ object Value extends js.Object { case RType.BooleanType => value case RType.ByteType | RType.ShortType | RType.IntType => value case RType.LongType => js.BigInt(value.asInstanceOf[Long].toString) - case special.sigma.BigIntRType => - val hex = SigmaDsl.toBigInteger(value.asInstanceOf[special.sigma.BigInt]).toString(10) + case sigma.BigIntRType => + val hex = SigmaDsl.toBigInteger(value.asInstanceOf[sigma.BigInt]).toString(10) js.BigInt(hex) - case special.sigma.GroupElementRType => + case sigma.GroupElementRType => val point = value.asInstanceOf[CGroupElement].wrappedValue.asInstanceOf[Platform.Ecp] new GroupElement(point) - case special.sigma.SigmaPropRType => + case sigma.SigmaPropRType => new SigmaProp(value.asInstanceOf[CSigmaProp].wrappedValue) - case special.sigma.AvlTreeRType => + case sigma.AvlTreeRType => Isos.isoAvlTree.from(value.asInstanceOf[CAvlTree]) - case special.sigma.BoxRType => + case sigma.BoxRType => Isos.isoBox.from(value.asInstanceOf[CostingBox].wrappedValue) case ct: CollType[a] => val arr = value.asInstanceOf[Coll[a]].toArray @@ -162,11 +162,11 @@ object Value extends js.Object { if (n < MinLong || n > MaxLong) throw new ArithmeticException(s"value $n is out of long range") n - case special.sigma.BigIntRType => + case sigma.BigIntRType => data.asInstanceOf[js.BigInt] - case special.sigma.GroupElementRType => + case sigma.GroupElementRType => data.asInstanceOf[GroupElement] - case special.sigma.SigmaPropRType => + case sigma.SigmaPropRType => data.asInstanceOf[SigmaProp] case PairType(l, r) => data match { case arr: js.Array[Any @unchecked] => diff --git a/sdk/js/src/test/scala/org/ergoplatform/sdk/js/IsosSpec.scala b/sdk/js/src/test/scala/org/ergoplatform/sdk/js/IsosSpec.scala index 47eedf2706..250d34b5cd 100644 --- a/sdk/js/src/test/scala/org/ergoplatform/sdk/js/IsosSpec.scala +++ b/sdk/js/src/test/scala/org/ergoplatform/sdk/js/IsosSpec.scala @@ -13,9 +13,8 @@ import sigmastate.Values.Constant import sigmastate.eval.Colls import sigmastate.interpreter.{ContextExtension, ProverResult} import sigmastate.serialization.generators.ObjectGenerators -import special.collection.Coll -import special.sigma -import special.sigma.GroupElement +import sigma.collection.Coll +import sigma.GroupElement import scala.scalajs.js diff --git a/sdk/js/src/test/scala/org/ergoplatform/sdk/js/ValueSpec.scala b/sdk/js/src/test/scala/org/ergoplatform/sdk/js/ValueSpec.scala index 54ace98db5..85bba2b1c8 100644 --- a/sdk/js/src/test/scala/org/ergoplatform/sdk/js/ValueSpec.scala +++ b/sdk/js/src/test/scala/org/ergoplatform/sdk/js/ValueSpec.scala @@ -13,7 +13,7 @@ import sigmastate.eval.CSigmaProp import sigmastate.lang.DeserializationSigmaBuilder import sigmastate.serialization.ConstantSerializer import sigmastate.utils.Helpers -import special.sigma.SigmaTestingData +import sigma.SigmaTestingData import java.math.BigInteger diff --git a/sdk/shared/src/main/scala/org/ergoplatform/sdk/BlockchainContext.scala b/sdk/shared/src/main/scala/org/ergoplatform/sdk/BlockchainContext.scala index d5b6edaf69..317fda331c 100644 --- a/sdk/shared/src/main/scala/org/ergoplatform/sdk/BlockchainContext.scala +++ b/sdk/shared/src/main/scala/org/ergoplatform/sdk/BlockchainContext.scala @@ -1,8 +1,8 @@ package org.ergoplatform.sdk import org.ergoplatform.sdk.wallet.protocol.context.BlockchainStateContext -import special.collection.Coll -import special.sigma.Header +import sigma.collection.Coll +import sigma.Header /** Represents a specific context of blockchain for execution * of transaction building scenario. diff --git a/sdk/shared/src/main/scala/org/ergoplatform/sdk/DataJsonEncoder.scala b/sdk/shared/src/main/scala/org/ergoplatform/sdk/DataJsonEncoder.scala index d36bd947a3..fd49f1b3d9 100644 --- a/sdk/shared/src/main/scala/org/ergoplatform/sdk/DataJsonEncoder.scala +++ b/sdk/shared/src/main/scala/org/ergoplatform/sdk/DataJsonEncoder.scala @@ -12,8 +12,8 @@ import sigmastate.Values.{Constant, EvaluatedValue} import sigmastate._ import sigmastate.lang.SigmaParser import sigmastate.eval._ -import special.collection.Coll -import special.sigma._ +import sigma.collection.Coll +import sigma._ import debox.cfor import sigmastate.exceptions.SerializerException import scala.collection.compat.immutable.ArraySeq diff --git a/sdk/shared/src/main/scala/org/ergoplatform/sdk/Extensions.scala b/sdk/shared/src/main/scala/org/ergoplatform/sdk/Extensions.scala index 426090b125..6744bf746e 100644 --- a/sdk/shared/src/main/scala/org/ergoplatform/sdk/Extensions.scala +++ b/sdk/shared/src/main/scala/org/ergoplatform/sdk/Extensions.scala @@ -4,8 +4,8 @@ import debox.cfor import scalan.RType import scalan.rtypeToClassTag // actually used import sigmastate.eval.CPreHeader -import special.collection.{Coll, CollBuilder, PairColl} -import special.sigma.{Header, PreHeader} +import sigma.collection.{Coll, CollBuilder, PairColl} +import sigma.{Header, PreHeader} import scala.collection.compat.BuildFrom import scala.collection.{GenIterable, immutable} diff --git a/sdk/shared/src/main/scala/org/ergoplatform/sdk/JavaHelpers.scala b/sdk/shared/src/main/scala/org/ergoplatform/sdk/JavaHelpers.scala index 52c653e9db..5e516256c3 100644 --- a/sdk/shared/src/main/scala/org/ergoplatform/sdk/JavaHelpers.scala +++ b/sdk/shared/src/main/scala/org/ergoplatform/sdk/JavaHelpers.scala @@ -1,7 +1,7 @@ package org.ergoplatform.sdk import scalan.RType -import special.collection.Coll +import sigma.collection.Coll import scala.collection.{JavaConverters, mutable} import org.ergoplatform._ @@ -12,7 +12,7 @@ import sigmastate.serialization.{ErgoTreeSerializer, GroupElementSerializer, Sig import scorex.crypto.authds.ADKey import org.ergoplatform.settings.ErgoAlgos import sigmastate.eval.{CPreHeader, Colls, CostingSigmaDslBuilder, Digest32Coll, Evaluation} -import special.sigma.{AnyValue, AvlTree, GroupElement, Header} +import sigma.{AnyValue, AvlTree, GroupElement, Header} import sigmastate.utils.Helpers._ // don't remove, required for Scala 2.11 import java.util @@ -249,8 +249,8 @@ object JavaHelpers { implicit val JLongRType: RType[JLong] = RType.LongType.asInstanceOf[RType[JLong]] implicit val JBooleanRType: RType[JBoolean] = RType.BooleanType.asInstanceOf[RType[JBoolean]] - val HeaderRType: RType[Header] = special.sigma.HeaderRType - val PreHeaderRType: RType[special.sigma.PreHeader] = special.sigma.PreHeaderRType + val HeaderRType: RType[Header] = sigma.HeaderRType + val PreHeaderRType: RType[sigma.PreHeader] = sigma.PreHeaderRType def Algos: ErgoAlgos = org.ergoplatform.settings.ErgoAlgos @@ -359,17 +359,17 @@ object JavaHelpers { DataInput(ADKey @@ boxIdBytes) } - def collRType[T](tItem: RType[T]): RType[Coll[T]] = special.collection.collRType(tItem) + def collRType[T](tItem: RType[T]): RType[Coll[T]] = sigma.collection.collRType(tItem) - def BigIntRType: RType[special.sigma.BigInt] = special.sigma.BigIntRType + def BigIntRType: RType[sigma.BigInt] = sigma.BigIntRType - def GroupElementRType: RType[special.sigma.GroupElement] = special.sigma.GroupElementRType + def GroupElementRType: RType[sigma.GroupElement] = sigma.GroupElementRType - def SigmaPropRType: RType[special.sigma.SigmaProp] = special.sigma.SigmaPropRType + def SigmaPropRType: RType[sigma.SigmaProp] = sigma.SigmaPropRType - def AvlTreeRType: RType[special.sigma.AvlTree] = special.sigma.AvlTreeRType + def AvlTreeRType: RType[sigma.AvlTree] = sigma.AvlTreeRType - def BoxRType: RType[special.sigma.Box] = special.sigma.BoxRType + def BoxRType: RType[sigma.Box] = sigma.BoxRType def SigmaDsl: CostingSigmaDslBuilder = sigmastate.eval.SigmaDsl @@ -409,7 +409,7 @@ object JavaHelpers { * @return a mapping from asset id to to balance and total assets number */ def extractAssets(boxes: IndexedSeq[ErgoBoxCandidate]): (Map[Digest32Coll, Long], Int) = { - import special.collection.Extensions.CollOps + import sigma.collection.Extensions.CollOps val map = mutable.Map[Digest32Coll, Long]() val assetsNum = boxes.foldLeft(0) { case (acc, box) => require(box.additionalTokens.length <= SigmaConstants.MaxTokens.value, "too many assets in one box") diff --git a/sdk/shared/src/main/scala/org/ergoplatform/sdk/JsonCodecs.scala b/sdk/shared/src/main/scala/org/ergoplatform/sdk/JsonCodecs.scala index 52e1565ca3..604a8ac081 100644 --- a/sdk/shared/src/main/scala/org/ergoplatform/sdk/JsonCodecs.scala +++ b/sdk/shared/src/main/scala/org/ergoplatform/sdk/JsonCodecs.scala @@ -16,8 +16,8 @@ import sigmastate.eval.{CPreHeader, WrapperOf, _} import sigmastate.exceptions.SigmaException import sigmastate.interpreter.{ContextExtension, ProverResult} import sigmastate.{AvlTreeData, AvlTreeFlags, SType} -import special.collection.Coll -import special.sigma.{AnyValue, Header, PreHeader} +import sigma.collection.Coll +import sigma.{AnyValue, Header, PreHeader} import scala.util.Try import sigmastate.utils.Helpers._ // required for Scala 2.11 @@ -62,11 +62,11 @@ trait JsonCodecs { fromTry(Try.apply(DataJsonEncoder.decodeAnyValue(cursor.value))) }) - implicit val sigmaBigIntEncoder: Encoder[special.sigma.BigInt] = Encoder.instance({ bigInt => + implicit val sigmaBigIntEncoder: Encoder[sigma.BigInt] = Encoder.instance({ bigInt => JsonNumber.fromDecimalStringUnsafe(bigInt.asInstanceOf[WrapperOf[BigInteger]].wrappedValue.toString).asJson }) - implicit val sigmaBigIntDecoder: Decoder[special.sigma.BigInt] = Decoder.instance({ implicit cursor => + implicit val sigmaBigIntDecoder: Decoder[sigma.BigInt] = Decoder.instance({ implicit cursor => for { jsonNumber <- cursor.as[JsonNumber] bigInt <- fromOption(jsonNumber.toBigInt) @@ -153,7 +153,7 @@ trait JsonCodecs { minerPk <- cursor.downField("minerPk").as[Coll[Byte]] powOnetimePk <- cursor.downField("powOnetimePk").as[Coll[Byte]] powNonce <- cursor.downField("powNonce").as[Coll[Byte]] - powDistance <- cursor.downField("powDistance").as[special.sigma.BigInt] + powDistance <- cursor.downField("powDistance").as[sigma.BigInt] votes <- cursor.downField("votes").as[Coll[Byte]] } yield new CHeader(id, version, parentId, adProofsRoot, stateRoot, transactionsRoot, timestamp, nBits, height, extensionRoot, SigmaDsl.decodePoint(minerPk), SigmaDsl.decodePoint(powOnetimePk), powNonce, powDistance, votes) diff --git a/sdk/shared/src/main/scala/org/ergoplatform/sdk/ProverBuilder.scala b/sdk/shared/src/main/scala/org/ergoplatform/sdk/ProverBuilder.scala index 0704cbe8d6..5525dbcc4d 100644 --- a/sdk/shared/src/main/scala/org/ergoplatform/sdk/ProverBuilder.scala +++ b/sdk/shared/src/main/scala/org/ergoplatform/sdk/ProverBuilder.scala @@ -4,7 +4,7 @@ import org.ergoplatform.ErgoAddressEncoder.{MainnetNetworkPrefix, NetworkPrefix} import org.ergoplatform.sdk.wallet.secrets.ExtendedSecretKey import sigmastate.basics.DLogProtocol.DLogProverInput import sigmastate.basics.{DLogProtocol, DiffieHellmanTupleProverInput} -import special.sigma.GroupElement +import sigma.GroupElement import java.math.BigInteger import scala.collection.mutable.ArrayBuffer diff --git a/sdk/shared/src/main/scala/org/ergoplatform/sdk/SigmaProver.scala b/sdk/shared/src/main/scala/org/ergoplatform/sdk/SigmaProver.scala index 8090627083..aa281f5b10 100644 --- a/sdk/shared/src/main/scala/org/ergoplatform/sdk/SigmaProver.scala +++ b/sdk/shared/src/main/scala/org/ergoplatform/sdk/SigmaProver.scala @@ -6,7 +6,7 @@ import org.ergoplatform.sdk.wallet.protocol.context.BlockchainStateContext import sigmastate.eval.{CostingSigmaDslBuilder, SigmaDsl} import sigmastate.interpreter.HintsBag import sigmastate.utils.Helpers.TryOps -import special.sigma.{BigInt, SigmaProp} +import sigma.{BigInt, SigmaProp} /** Represents a prover for signing Ergo transactions and messages. * diff --git a/sdk/shared/src/main/scala/org/ergoplatform/sdk/UnsignedTransactionBuilder.scala b/sdk/shared/src/main/scala/org/ergoplatform/sdk/UnsignedTransactionBuilder.scala index e48f26fd6f..6030bf2aa9 100644 --- a/sdk/shared/src/main/scala/org/ergoplatform/sdk/UnsignedTransactionBuilder.scala +++ b/sdk/shared/src/main/scala/org/ergoplatform/sdk/UnsignedTransactionBuilder.scala @@ -9,9 +9,9 @@ import org.ergoplatform.sdk.wallet.{AssetUtils, TokensMap} import scorex.util.{ModifierId, bytesToId} import sigmastate.eval.Extensions.ArrayOps import sigmastate.utils.Extensions.ModifierIdOps -import special.collection.Coll -import special.collection.Extensions.CollBytesOps -import special.sigma.PreHeader +import sigma.collection.Coll +import sigma.collection.Extensions.CollBytesOps +import sigma.PreHeader import scala.collection.mutable.ArrayBuffer import scala.util.Try diff --git a/sdk/shared/src/main/scala/org/ergoplatform/sdk/utils/Zero.scala b/sdk/shared/src/main/scala/org/ergoplatform/sdk/utils/Zero.scala index 2115d774a0..e2b57100cc 100644 --- a/sdk/shared/src/main/scala/org/ergoplatform/sdk/utils/Zero.scala +++ b/sdk/shared/src/main/scala/org/ergoplatform/sdk/utils/Zero.scala @@ -10,9 +10,9 @@ import sigmastate.Values.ErgoTree import sigmastate.basics.CryptoConstants import sigmastate.eval._ import sigmastate.{AvlTreeData, AvlTreeFlags, TrivialProp} -import special.Types.TupleType -import special.collection.{Coll, CollType} -import special.sigma.{AvlTree, AvlTreeRType, BigInt, BigIntRType, Box, BoxRType, GroupElement, GroupElementRType, SigmaProp, SigmaPropRType} +import sigma.Types.TupleType +import sigma.collection.{Coll, CollType} +import sigma.{AvlTree, AvlTreeRType, BigInt, BigIntRType, Box, BoxRType, GroupElement, GroupElementRType, SigmaProp, SigmaPropRType} import java.math.BigInteger import scala.language.implicitConversions diff --git a/sdk/shared/src/main/scala/org/ergoplatform/sdk/wallet/protocol/context/BlockchainStateContext.scala b/sdk/shared/src/main/scala/org/ergoplatform/sdk/wallet/protocol/context/BlockchainStateContext.scala index 5c8d97df4f..41ba7ee8d1 100644 --- a/sdk/shared/src/main/scala/org/ergoplatform/sdk/wallet/protocol/context/BlockchainStateContext.scala +++ b/sdk/shared/src/main/scala/org/ergoplatform/sdk/wallet/protocol/context/BlockchainStateContext.scala @@ -1,6 +1,6 @@ package org.ergoplatform.sdk.wallet.protocol.context -import special.collection.Coll +import sigma.collection.Coll /** Blockchain context used in tx signing. * @@ -9,7 +9,7 @@ import special.collection.Coll * @param sigmaPreHeader returns pre-header (header without certain fields) of the current block */ case class BlockchainStateContext( - sigmaLastHeaders: Coll[special.sigma.Header], + sigmaLastHeaders: Coll[sigma.Header], previousStateDigest: Coll[Byte], - sigmaPreHeader: special.sigma.PreHeader + sigmaPreHeader: sigma.PreHeader ) diff --git a/sdk/shared/src/test/scala/org/ergoplatform/sdk/ContractTemplateSpecification.scala b/sdk/shared/src/test/scala/org/ergoplatform/sdk/ContractTemplateSpecification.scala index c660f44e02..268012ac3c 100644 --- a/sdk/shared/src/test/scala/org/ergoplatform/sdk/ContractTemplateSpecification.scala +++ b/sdk/shared/src/test/scala/org/ergoplatform/sdk/ContractTemplateSpecification.scala @@ -8,7 +8,7 @@ import sigmastate._ import sigmastate.eval.CBigInt import sigmastate.helpers.NegativeTesting import sigmastate.serialization.{SerializationSpecification, SigmaSerializer} -import special.sigma.ContractsTestkit +import sigma.ContractsTestkit import java.math.BigInteger diff --git a/sdk/shared/src/test/scala/org/ergoplatform/sdk/DataJsonEncoderSpecification.scala b/sdk/shared/src/test/scala/org/ergoplatform/sdk/DataJsonEncoderSpecification.scala index cdcd0906c0..d89ac0f6c5 100644 --- a/sdk/shared/src/test/scala/org/ergoplatform/sdk/DataJsonEncoderSpecification.scala +++ b/sdk/shared/src/test/scala/org/ergoplatform/sdk/DataJsonEncoderSpecification.scala @@ -13,7 +13,7 @@ import sigmastate.eval.Extensions._ import sigmastate.eval.{Evaluation, _} import sigmastate.basics.CryptoConstants.EcPointType import sigmastate.exceptions.SerializerException -import special.sigma.{Box, AvlTree} +import sigma.{Box, AvlTree} import sigmastate.serialization.SerializationSpecification class DataJsonEncoderSpecification extends SerializationSpecification { diff --git a/sdk/shared/src/test/scala/org/ergoplatform/sdk/ExtensionsSpec.scala b/sdk/shared/src/test/scala/org/ergoplatform/sdk/ExtensionsSpec.scala index 72c75ace73..97fe775e73 100644 --- a/sdk/shared/src/test/scala/org/ergoplatform/sdk/ExtensionsSpec.scala +++ b/sdk/shared/src/test/scala/org/ergoplatform/sdk/ExtensionsSpec.scala @@ -3,10 +3,10 @@ package org.ergoplatform.sdk import org.scalatest.matchers.should.Matchers import org.scalatest.propspec.AnyPropSpec import org.scalatestplus.scalacheck.ScalaCheckPropertyChecks -import special.collection.Coll -import special.collections.CollGens +import sigma.collection.Coll import org.ergoplatform.sdk.Extensions.{CollBuilderOps, CollOps, GenIterableOps, PairCollOps} import scalan.RType +import sigma.collections.CollGens import sigmastate.eval.CostingSigmaDslBuilder class ExtensionsSpec extends AnyPropSpec with ScalaCheckPropertyChecks with Matchers with CollGens { diff --git a/sdk/shared/src/test/scala/org/ergoplatform/sdk/JsonSerializationSpec.scala b/sdk/shared/src/test/scala/org/ergoplatform/sdk/JsonSerializationSpec.scala index e85757985e..a764b6e7de 100644 --- a/sdk/shared/src/test/scala/org/ergoplatform/sdk/JsonSerializationSpec.scala +++ b/sdk/shared/src/test/scala/org/ergoplatform/sdk/JsonSerializationSpec.scala @@ -17,8 +17,8 @@ import sigmastate.eval.Digest32Coll import sigmastate.interpreter.{ContextExtension, ProverResult} import sigmastate.serialization.SerializationSpecification import sigmastate.utils.Helpers.DecoderResultOps // required for Scala 2.11 (extension method toTry) -import special.collection.Coll -import special.sigma.{Header, PreHeader} +import sigma.collection.Coll +import sigma.{Header, PreHeader} import org.ergoplatform.{DataInput, ErgoBox, ErgoBoxCandidate, ErgoLikeContext, ErgoLikeTransaction, ErgoLikeTransactionTemplate, Input, UnsignedErgoLikeTransaction, UnsignedInput} import scala.collection.mutable @@ -35,7 +35,7 @@ class JsonSerializationSpec extends SerializationSpecification with JsonCodecs { } property("sigma.BigInt should be encoded into JSON and decoded back correctly") { - forAll { v: special.sigma.BigInt => jsonRoundTrip(v) } + forAll { v: sigma.BigInt => jsonRoundTrip(v) } } property("byte array should be encoded into JSON and decoded back correctly") { diff --git a/sdk/shared/src/test/scala/org/ergoplatform/sdk/multisig/SigningSpec.scala b/sdk/shared/src/test/scala/org/ergoplatform/sdk/multisig/SigningSpec.scala index bde2e04fcf..e45fd0d8dd 100644 --- a/sdk/shared/src/test/scala/org/ergoplatform/sdk/multisig/SigningSpec.scala +++ b/sdk/shared/src/test/scala/org/ergoplatform/sdk/multisig/SigningSpec.scala @@ -11,7 +11,7 @@ import org.scalatestplus.scalacheck.ScalaCheckPropertyChecks import scalan.util.CollectionUtil.AnyOps import sigmastate.TestsBase import sigmastate.Values.{Constant, ErgoTree} -import special.sigma.SigmaTestingData +import sigma.SigmaTestingData class SigningSpec extends AnyPropSpec with ScalaCheckPropertyChecks with Matchers with TestsBase From 3fce4d720dce436ac79f90d6029bc98cf17134e4 Mon Sep 17 00:00:00 2001 From: Alexander Slesarenko Date: Tue, 22 Aug 2023 18:36:50 +0200 Subject: [PATCH 07/37] minimize-modules: collections moved to sigma package --- .../sigma/{collection => }/CollType.scala | 2 +- .../scala/sigma/{collection => }/Colls.scala | 2 +- .../{collection => }/CollsOverArrays.scala | 4 ++-- .../main/scala/sigma/CoreLibReflection.scala | 2 -- .../sigma/{collection => }/Extensions.scala | 2 +- .../src/main/scala/sigma/SigmaDsl.scala | 1 - .../shared/src/main/scala/sigma/Types.scala | 1 - .../main/scala/sigma/collection/package.scala | 23 ------------------- .../shared/src/main/scala/sigma/package.scala | 11 +++++++++ .../CollGens.scala | 3 +-- .../CollsTests.scala | 14 +++++------ .../src/main/scala/sigmastate/Platform.scala | 2 +- .../scala/sigmastate/crypto/Platform.scala | 2 +- .../src/main/scala/sigmastate/Platform.scala | 2 +- .../scala/sigmastate/crypto/Platform.scala | 2 +- .../scala/org/ergoplatform/ErgoAddress.scala | 2 +- .../main/scala/org/ergoplatform/ErgoBox.scala | 2 +- .../org/ergoplatform/ErgoBoxCandidate.scala | 4 ++-- .../org/ergoplatform/ErgoLikeContext.scala | 2 +- .../org/ergoplatform/dsl/AvlTreeHelpers.scala | 2 +- .../org/ergoplatform/settings/ErgoAlgos.scala | 2 +- .../main/scala/sigmastate/AvlTreeData.scala | 2 +- .../scala/sigmastate/DataValueComparer.scala | 2 +- .../sigmastate/InterpreterReflection.scala | 2 +- .../src/main/scala/sigmastate/Values.scala | 2 +- .../basics/SigmaProtocolFunctions.scala | 2 +- .../sigmastate/eval/CostingDataContext.scala | 1 - .../scala/sigmastate/eval/Evaluation.scala | 2 +- .../scala/sigmastate/eval/Extensions.scala | 2 +- .../main/scala/sigmastate/eval/package.scala | 2 +- .../interpreter/ErgoTreeEvaluator.scala | 2 +- .../interpreter/ProverInterpreter.scala | 2 +- .../scala/sigmastate/lang/SigmaBuilder.scala | 2 +- .../serialization/DataSerializer.scala | 1 - .../src/main/scala/sigmastate/trees.scala | 2 +- .../src/main/scala/sigmastate/types.scala | 2 +- .../scala/sigmastate/utils/Extensions.scala | 2 +- .../main/scala/sigmastate/utils/Helpers.scala | 2 +- .../scala/sigmastate/utxo/transformers.scala | 2 +- .../helpers/ErgoLikeContextTesting.scala | 2 +- .../sigmastate/helpers/TestingHelpers.scala | 2 +- .../generators/ObjectGenerators.scala | 2 +- .../special/sigma/ContractsTestkit.scala | 1 - .../special/sigma/SigmaTestingData.scala | 4 ++-- .../scala/sigmastate/lang/LangTests.scala | 2 +- .../scala/sigmastate/ErgoTreeBenchmarks.scala | 2 +- .../sigmastate/ReflectionGenerator.scala | 2 +- .../sigmastate/helpers/SigmaPPrintSpec.scala | 2 +- .../special/collections/BasicBenchmarks.scala | 2 +- .../special/collections/BenchmarkGens.scala | 2 +- .../special/collections/BufferBenchmark.scala | 2 +- .../special/collections/CollBenchmark.scala | 4 +--- .../special/collections/MapBenchmark.scala | 2 +- .../special/collections/SymBenchmark.scala | 2 +- .../ergoplatform/dsl/ErgoContractSpec.scala | 2 +- .../main/scala/scalan/GraphIRReflection.scala | 2 +- sc/shared/src/main/scala/scalan/Library.scala | 2 +- .../scala/special/collection/CollsUnit.scala | 4 ++-- .../special/collection/impl/CollsImpl.scala | 10 ++++---- .../ErgoLikeTransactionSpec.scala | 2 +- .../sigmastate/ErgoTreeSpecification.scala | 2 +- .../sigmastate/helpers/SigmaPPrint.scala | 3 +-- .../utxo/AVLTreeScriptsSpecification.scala | 2 +- .../utxo/ContextEnrichingSpecification.scala | 2 +- .../utxo/examples/AssetsAtomicExchange.scala | 2 +- .../AssetsAtomicExchangeErgoTests.scala | 2 +- .../utxo/examples/AssetsPartialFilling.scala | 2 +- .../examples/DummyExamplesSpecification.scala | 3 +-- ...racleDataInputsExamplesSpecification.scala | 2 +- .../OracleTokenExamplesSpecification.scala | 2 +- .../collections/CollsStagingTests.scala | 6 ++--- .../DataValueComparerSpecification.scala | 2 +- .../special/sigma/SigmaDslSpecification.scala | 22 +++++++++--------- .../special/sigma/SigmaDslStaginTests.scala | 3 +-- .../scala/special/sigma/SigmaDslTesting.scala | 2 +- .../scala/org/ergoplatform/sdk/js/Isos.scala | 4 ++-- .../scala/org/ergoplatform/sdk/js/Type.scala | 2 +- .../scala/org/ergoplatform/sdk/js/Value.scala | 2 +- .../org/ergoplatform/sdk/js/IsosSpec.scala | 2 +- .../ergoplatform/sdk/BlockchainContext.scala | 2 +- .../ergoplatform/sdk/DataJsonEncoder.scala | 1 - .../org/ergoplatform/sdk/Extensions.scala | 2 +- .../org/ergoplatform/sdk/JavaHelpers.scala | 6 ++--- .../org/ergoplatform/sdk/JsonCodecs.scala | 2 +- .../sdk/UnsignedTransactionBuilder.scala | 4 ++-- .../org/ergoplatform/sdk/utils/Zero.scala | 2 +- .../context/BlockchainStateContext.scala | 2 +- .../org/ergoplatform/sdk/ExtensionsSpec.scala | 4 ++-- .../sdk/JsonSerializationSpec.scala | 2 +- 89 files changed, 121 insertions(+), 149 deletions(-) rename common/shared/src/main/scala/sigma/{collection => }/CollType.scala (96%) rename common/shared/src/main/scala/sigma/{collection => }/Colls.scala (99%) rename common/shared/src/main/scala/sigma/{collection => }/CollsOverArrays.scala (99%) rename common/shared/src/main/scala/sigma/{collection => }/Extensions.scala (98%) delete mode 100644 common/shared/src/main/scala/sigma/collection/package.scala rename common/shared/src/test/scala/sigma/{collections => collection}/CollGens.scala (98%) rename common/shared/src/test/scala/sigma/{collections => collection}/CollsTests.scala (97%) diff --git a/common/shared/src/main/scala/sigma/collection/CollType.scala b/common/shared/src/main/scala/sigma/CollType.scala similarity index 96% rename from common/shared/src/main/scala/sigma/collection/CollType.scala rename to common/shared/src/main/scala/sigma/CollType.scala index 81a8b2fb16..c2ff828edf 100644 --- a/common/shared/src/main/scala/sigma/collection/CollType.scala +++ b/common/shared/src/main/scala/sigma/CollType.scala @@ -1,4 +1,4 @@ -package sigma.collection +package sigma import scalan.RType diff --git a/common/shared/src/main/scala/sigma/collection/Colls.scala b/common/shared/src/main/scala/sigma/Colls.scala similarity index 99% rename from common/shared/src/main/scala/sigma/collection/Colls.scala rename to common/shared/src/main/scala/sigma/Colls.scala index c1c00ed67a..022f5843ec 100644 --- a/common/shared/src/main/scala/sigma/collection/Colls.scala +++ b/common/shared/src/main/scala/sigma/Colls.scala @@ -1,4 +1,4 @@ -package sigma.collection +package sigma import scalan._ diff --git a/common/shared/src/main/scala/sigma/collection/CollsOverArrays.scala b/common/shared/src/main/scala/sigma/CollsOverArrays.scala similarity index 99% rename from common/shared/src/main/scala/sigma/collection/CollsOverArrays.scala rename to common/shared/src/main/scala/sigma/CollsOverArrays.scala index 1593bac573..9a756f3370 100644 --- a/common/shared/src/main/scala/sigma/collection/CollsOverArrays.scala +++ b/common/shared/src/main/scala/sigma/CollsOverArrays.scala @@ -1,4 +1,4 @@ -package sigma.collection +package sigma import java.util import scalan._ // required @@ -139,7 +139,7 @@ class CollOverArray[@specialized A](val toArray: Array[A], val builder: CollBuil override def equals(obj: scala.Any): Boolean = (this eq obj.asInstanceOf[AnyRef]) || (obj match { case obj: CollOverArray[_] if obj.tItem == this.tItem => - util.Objects.deepEquals(obj.toArray, toArray) + java.util.Objects.deepEquals(obj.toArray, toArray) case _ => false }) diff --git a/common/shared/src/main/scala/sigma/CoreLibReflection.scala b/common/shared/src/main/scala/sigma/CoreLibReflection.scala index 66f179ae57..55c0e20f9a 100644 --- a/common/shared/src/main/scala/sigma/CoreLibReflection.scala +++ b/common/shared/src/main/scala/sigma/CoreLibReflection.scala @@ -3,8 +3,6 @@ package sigma import scalan.RType import scalan.reflection.CommonReflection.registerClassEntry import scalan.reflection._ -import sigma._ -import sigma.collection._ /** Registrations of reflection metadata for core-lib module. * For each class of this module that needs reflection metadata, diff --git a/common/shared/src/main/scala/sigma/collection/Extensions.scala b/common/shared/src/main/scala/sigma/Extensions.scala similarity index 98% rename from common/shared/src/main/scala/sigma/collection/Extensions.scala rename to common/shared/src/main/scala/sigma/Extensions.scala index e08adca1b6..08087eced0 100644 --- a/common/shared/src/main/scala/sigma/collection/Extensions.scala +++ b/common/shared/src/main/scala/sigma/Extensions.scala @@ -1,4 +1,4 @@ -package sigma.collection +package sigma import debox.cfor import scorex.util.encode.Base16 diff --git a/common/shared/src/main/scala/sigma/SigmaDsl.scala b/common/shared/src/main/scala/sigma/SigmaDsl.scala index 7bcaa20fd7..894ca6ca50 100644 --- a/common/shared/src/main/scala/sigma/SigmaDsl.scala +++ b/common/shared/src/main/scala/sigma/SigmaDsl.scala @@ -2,7 +2,6 @@ package sigma import java.math.BigInteger -import sigma.collection._ import scalan._ import scorex.crypto.authds.{ADDigest, ADValue} import scorex.crypto.authds.avltree.batch.Operation diff --git a/common/shared/src/main/scala/sigma/Types.scala b/common/shared/src/main/scala/sigma/Types.scala index 0ce8785989..5f10d5bda0 100644 --- a/common/shared/src/main/scala/sigma/Types.scala +++ b/common/shared/src/main/scala/sigma/Types.scala @@ -3,7 +3,6 @@ package sigma import scalan.RType import scalan.RType.SomeType import scalan.util.CollectionUtil -import sigma.collection.Coll import scala.reflect.ClassTag diff --git a/common/shared/src/main/scala/sigma/collection/package.scala b/common/shared/src/main/scala/sigma/collection/package.scala deleted file mode 100644 index 1e89a7fbf5..0000000000 --- a/common/shared/src/main/scala/sigma/collection/package.scala +++ /dev/null @@ -1,23 +0,0 @@ -package sigma - -import scalan.RType - -import scala.language.implicitConversions -import scala.reflect.classTag - -package object collection { - /** Forces reflection data initialization */ - val reflection = CoreLibReflection - - /** Implicit resolution of `Coll[A]` type descriptor, given a descriptor of `A`. */ - implicit def collRType[A](implicit tA: RType[A]): RType[Coll[A]] = CollType[A](tA) - - implicit val collBuilderRType: RType[CollBuilder] = RType.fromClassTag(classTag[CollBuilder]) - - private def sameLengthErrorMsg[A, B](xs: Coll[A], ys: Coll[B]) = - s"Collections should have same length but was ${xs.length} and ${ys.length}:\n xs=$xs;\n ys=$ys" - - def requireSameLength[A, B](xs: Coll[A], ys: Coll[B]) = { - require(xs.length == ys.length, sameLengthErrorMsg(xs, ys)) - } -} diff --git a/common/shared/src/main/scala/sigma/package.scala b/common/shared/src/main/scala/sigma/package.scala index 4eaee24aff..c09ec6eea6 100644 --- a/common/shared/src/main/scala/sigma/package.scala +++ b/common/shared/src/main/scala/sigma/package.scala @@ -30,4 +30,15 @@ package object sigma { implicit val BigIntegerRType: RType[BigInteger] = GeneralType(classTag[BigInteger]) + /** Implicit resolution of `Coll[A]` type descriptor, given a descriptor of `A`. */ + implicit def collRType[A](implicit tA: RType[A]): RType[Coll[A]] = CollType[A](tA) + + implicit val collBuilderRType: RType[CollBuilder] = RType.fromClassTag(classTag[CollBuilder]) + + private def sameLengthErrorMsg[A, B](xs: Coll[A], ys: Coll[B]) = + s"Collections should have same length but was ${xs.length} and ${ys.length}:\n xs=$xs;\n ys=$ys" + + def requireSameLength[A, B](xs: Coll[A], ys: Coll[B]) = { + require(xs.length == ys.length, sameLengthErrorMsg(xs, ys)) + } } \ No newline at end of file diff --git a/common/shared/src/test/scala/sigma/collections/CollGens.scala b/common/shared/src/test/scala/sigma/collection/CollGens.scala similarity index 98% rename from common/shared/src/test/scala/sigma/collections/CollGens.scala rename to common/shared/src/test/scala/sigma/collection/CollGens.scala index c8fdb3094f..4c136eb252 100644 --- a/common/shared/src/test/scala/sigma/collections/CollGens.scala +++ b/common/shared/src/test/scala/sigma/collection/CollGens.scala @@ -1,10 +1,9 @@ -package sigma.collections +package sigma import org.scalacheck.util.Buildable import org.scalacheck.{Arbitrary, Gen} import scalan._ import scalan.RType -import sigma.collection.{Coll, CollBuilder, CollOverArrayBuilder, PairColl} import spire.scalacompat.BuilderCompat import scala.collection.mutable import scala.collection.mutable.ArrayBuffer diff --git a/common/shared/src/test/scala/sigma/collections/CollsTests.scala b/common/shared/src/test/scala/sigma/collection/CollsTests.scala similarity index 97% rename from common/shared/src/test/scala/sigma/collections/CollsTests.scala rename to common/shared/src/test/scala/sigma/collection/CollsTests.scala index a4d2fb3af4..16461d8d8c 100644 --- a/common/shared/src/test/scala/sigma/collections/CollsTests.scala +++ b/common/shared/src/test/scala/sigma/collection/CollsTests.scala @@ -1,4 +1,4 @@ -package sigma.collections +package sigma import org.scalacheck.Gen import org.scalatest.exceptions.TestFailedException @@ -6,14 +6,12 @@ import org.scalatest.matchers.should.Matchers import org.scalatest.propspec.AnyPropSpec import org.scalatestplus.scalacheck.ScalaCheckPropertyChecks import scalan._ -import sigma.{VersionContext, VersionTestingProperty} -import sigma.collection.{Coll, CollOverArray, PairOfCols} import scala.language.{existentials} class CollsTests extends AnyPropSpec with ScalaCheckPropertyChecks with Matchers with CollGens with VersionTestingProperty { testSuite => import Gen._ - import sigma.collection.Extensions._ + import sigma.Extensions._ def squared[A](f: A => A): ((A, A)) => (A, A) = (p: (A, A)) => (f(p._1), f(p._2)) @@ -491,8 +489,8 @@ class CollsTests extends AnyPropSpec with ScalaCheckPropertyChecks with Matchers /* TODO: simplify the above code * match-case removal gives the following compilation error: type mismatch; - found : sigma.collection.PairColl[_$1(in value res),_$2(in value res)] where type _$2(in value res), type _$1(in value res) - required: sigma.collection.Coll[(_$1(in method getSuperGen), _$2(in method getSuperGen))] + found : sigma.PairColl[_$1(in value res),_$2(in value res)] where type _$2(in value res), type _$1(in value res) + required: sigma.Coll[(_$1(in method getSuperGen), _$2(in method getSuperGen))] val res = col1.unionSet(col1) */ } @@ -511,8 +509,8 @@ class CollsTests extends AnyPropSpec with ScalaCheckPropertyChecks with Matchers /* TODO: simplify the above code * match-case removal gives the following compilation error: type mismatch; - found : sigma.collection.PairColl[_$1(in value res),_$2(in value res)] where type _$2(in value res), type _$1(in value res) - required: sigma.collection.Coll[(_$1(in method getSuperGen), _$2(in method getSuperGen))] + found : sigma.PairColl[_$1(in value res),_$2(in value res)] where type _$2(in value res), type _$1(in value res) + required: sigma.Coll[(_$1(in method getSuperGen), _$2(in method getSuperGen))] val res = col.diff(col) */ builder.replicate(2, 10).diff(builder.replicate(1, 10)).toArray shouldBe Array(10) diff --git a/interpreter/js/src/main/scala/sigmastate/Platform.scala b/interpreter/js/src/main/scala/sigmastate/Platform.scala index 4defdc896b..eeca7b7853 100644 --- a/interpreter/js/src/main/scala/sigmastate/Platform.scala +++ b/interpreter/js/src/main/scala/sigmastate/Platform.scala @@ -6,7 +6,7 @@ import sigma.VersionContext import sigmastate.Values.{Constant, FalseLeaf, SigmaBoolean, TrueLeaf} import sigmastate.eval.{Evaluation, SigmaDsl} import sigmastate.lang.SigmaBuilder -import sigma.collection.Coll +import sigma.Coll import sigma.{AnyValue, AvlTree, GroupElement, SigmaProp} import java.math.BigInteger diff --git a/interpreter/js/src/main/scala/sigmastate/crypto/Platform.scala b/interpreter/js/src/main/scala/sigmastate/crypto/Platform.scala index 61d4ed9cfb..2f448d89a4 100644 --- a/interpreter/js/src/main/scala/sigmastate/crypto/Platform.scala +++ b/interpreter/js/src/main/scala/sigmastate/crypto/Platform.scala @@ -3,7 +3,7 @@ package sigmastate.crypto import scalan.RType import scorex.util.encode.Base16 import sigmastate._ -import sigma.collection.Coll +import sigma.Coll import sigma._ import java.math.BigInteger diff --git a/interpreter/jvm/src/main/scala/sigmastate/Platform.scala b/interpreter/jvm/src/main/scala/sigmastate/Platform.scala index e4b1e86ad1..fa14798449 100644 --- a/interpreter/jvm/src/main/scala/sigmastate/Platform.scala +++ b/interpreter/jvm/src/main/scala/sigmastate/Platform.scala @@ -6,7 +6,7 @@ import sigma.VersionContext import sigmastate.Values.{Constant, FalseLeaf, SigmaBoolean, TrueLeaf} import sigmastate.eval.{Evaluation, SigmaDsl} import sigmastate.lang.SigmaBuilder -import sigma.collection.Coll +import sigma.Coll import sigma.{AvlTree, GroupElement, SigmaProp} import java.math.BigInteger diff --git a/interpreter/jvm/src/main/scala/sigmastate/crypto/Platform.scala b/interpreter/jvm/src/main/scala/sigmastate/crypto/Platform.scala index c79cf8c59c..fe7c0afa72 100644 --- a/interpreter/jvm/src/main/scala/sigmastate/crypto/Platform.scala +++ b/interpreter/jvm/src/main/scala/sigmastate/crypto/Platform.scala @@ -10,7 +10,7 @@ import scalan.RType import java.math.BigInteger import sigmastate._ import sigmastate.basics.BcDlogGroup -import sigma.collection.Coll +import sigma.Coll import sigma._ import java.text.Normalizer.Form.NFKD diff --git a/interpreter/shared/src/main/scala/org/ergoplatform/ErgoAddress.scala b/interpreter/shared/src/main/scala/org/ergoplatform/ErgoAddress.scala index a821b4ef9b..bb97286e16 100644 --- a/interpreter/shared/src/main/scala/org/ergoplatform/ErgoAddress.scala +++ b/interpreter/shared/src/main/scala/org/ergoplatform/ErgoAddress.scala @@ -10,7 +10,7 @@ import sigmastate.basics.DLogProtocol.{ProveDlogProp, ProveDlog} import sigmastate.exceptions.SigmaException import sigmastate.serialization._ import sigmastate.utxo.{DeserializeContext, Slice} -import sigma.collection.Coll +import sigma.Coll import scala.util.Try diff --git a/interpreter/shared/src/main/scala/org/ergoplatform/ErgoBox.scala b/interpreter/shared/src/main/scala/org/ergoplatform/ErgoBox.scala index b5ad85458c..a3abf97920 100644 --- a/interpreter/shared/src/main/scala/org/ergoplatform/ErgoBox.scala +++ b/interpreter/shared/src/main/scala/org/ergoplatform/ErgoBox.scala @@ -15,7 +15,7 @@ import sigmastate.eval._ import sigmastate.serialization.SigmaSerializer import sigmastate.utils.{Helpers, SigmaByteReader, SigmaByteWriter} import sigmastate.utxo.ExtractCreationInfo -import sigma.collection._ +import sigma._ /** * Box (aka coin, or an unspent output) is a basic concept of a UTXO-based cryptocurrency. In Bitcoin, such an object diff --git a/interpreter/shared/src/main/scala/org/ergoplatform/ErgoBoxCandidate.scala b/interpreter/shared/src/main/scala/org/ergoplatform/ErgoBoxCandidate.scala index e08d540187..e10f7907e1 100644 --- a/interpreter/shared/src/main/scala/org/ergoplatform/ErgoBoxCandidate.scala +++ b/interpreter/shared/src/main/scala/org/ergoplatform/ErgoBoxCandidate.scala @@ -9,13 +9,13 @@ import sigmastate._ import sigmastate.SType.AnyOps import sigmastate.serialization.{SigmaSerializer, ValueSerializer} import sigmastate.utils.{SigmaByteReader, SigmaByteWriter} -import sigma.collection.Coll +import sigma.Coll import sigmastate.eval._ import sigmastate.eval.Extensions._ import sigmastate.serialization.ErgoTreeSerializer.DefaultSerializer import sigma.util.safeNewArray import debox.cfor -import sigma.collection.Extensions.CollOps +import sigma.Extensions.CollOps import scala.collection.{immutable, mutable} import scala.runtime.ScalaRunTime diff --git a/interpreter/shared/src/main/scala/org/ergoplatform/ErgoLikeContext.scala b/interpreter/shared/src/main/scala/org/ergoplatform/ErgoLikeContext.scala index 5ae468be8f..05b5bde4e2 100644 --- a/interpreter/shared/src/main/scala/org/ergoplatform/ErgoLikeContext.scala +++ b/interpreter/shared/src/main/scala/org/ergoplatform/ErgoLikeContext.scala @@ -11,7 +11,7 @@ import sigmastate.interpreter.{ContextExtension, ErgoTreeEvaluator, Interpreter, import sigmastate.exceptions.InterpreterException import sigmastate.serialization.OpCodes import sigmastate.serialization.OpCodes.OpCode -import sigma.collection.Coll +import sigma.Coll import sigma.{AnyValue, Header, PreHeader} import debox.cfor diff --git a/interpreter/shared/src/main/scala/org/ergoplatform/dsl/AvlTreeHelpers.scala b/interpreter/shared/src/main/scala/org/ergoplatform/dsl/AvlTreeHelpers.scala index b649c8e381..627b0a3f54 100644 --- a/interpreter/shared/src/main/scala/org/ergoplatform/dsl/AvlTreeHelpers.scala +++ b/interpreter/shared/src/main/scala/org/ergoplatform/dsl/AvlTreeHelpers.scala @@ -1,6 +1,6 @@ package org.ergoplatform.dsl -import sigma.collection.Coll +import sigma.Coll import sigmastate.eval.{CAvlTree, CostingSigmaDslBuilder} import scorex.crypto.authds.{ADKey, ADValue} import scorex.crypto.hash.{Digest32, Blake2b256} diff --git a/interpreter/shared/src/main/scala/org/ergoplatform/settings/ErgoAlgos.scala b/interpreter/shared/src/main/scala/org/ergoplatform/settings/ErgoAlgos.scala index 25505d8602..e6b3141f9c 100644 --- a/interpreter/shared/src/main/scala/org/ergoplatform/settings/ErgoAlgos.scala +++ b/interpreter/shared/src/main/scala/org/ergoplatform/settings/ErgoAlgos.scala @@ -2,7 +2,7 @@ package org.ergoplatform.settings import scorex.crypto.hash.Blake2b256 import scorex.util._ -import sigma.collection.Coll +import sigma.Coll import scala.util.Try diff --git a/interpreter/shared/src/main/scala/sigmastate/AvlTreeData.scala b/interpreter/shared/src/main/scala/sigmastate/AvlTreeData.scala index 64e3ceba2d..23188cfa49 100644 --- a/interpreter/shared/src/main/scala/sigmastate/AvlTreeData.scala +++ b/interpreter/shared/src/main/scala/sigmastate/AvlTreeData.scala @@ -4,7 +4,7 @@ import sigmastate.basics.CryptoConstants import sigmastate.eval.Colls import sigmastate.serialization.SigmaSerializer import sigmastate.utils.{SigmaByteReader, SigmaByteWriter} -import sigma.collection.Coll +import sigma.Coll case class AvlTreeFlags(insertAllowed: Boolean, updateAllowed: Boolean, removeAllowed: Boolean) { diff --git a/interpreter/shared/src/main/scala/sigmastate/DataValueComparer.scala b/interpreter/shared/src/main/scala/sigmastate/DataValueComparer.scala index 75b604f5a0..c07eaff70f 100644 --- a/interpreter/shared/src/main/scala/sigmastate/DataValueComparer.scala +++ b/interpreter/shared/src/main/scala/sigmastate/DataValueComparer.scala @@ -10,7 +10,7 @@ import sigmastate.eval.SigmaDsl import sigmastate.basics.CryptoConstants.EcPointType import sigmastate.interpreter.{ErgoTreeEvaluator, NamedDesc, OperationCostInfo} import sigma.{AvlTree, AvlTreeRType, BigInt, BigIntRType, Box, BoxRType, GroupElement, GroupElementRType, Header, HeaderRType, PreHeader, PreHeaderRType, SigmaProp} -import sigma.collection.{Coll, CollOverArray, PairOfCols} +import sigma.{Coll, CollOverArray, PairOfCols} /** Implementation of data equality for two arbitrary ErgoTree data types. * @see [[DataValueComparer.equalDataValues]] diff --git a/interpreter/shared/src/main/scala/sigmastate/InterpreterReflection.scala b/interpreter/shared/src/main/scala/sigmastate/InterpreterReflection.scala index 6e05af97ab..7c2f26d423 100644 --- a/interpreter/shared/src/main/scala/sigmastate/InterpreterReflection.scala +++ b/interpreter/shared/src/main/scala/sigmastate/InterpreterReflection.scala @@ -3,7 +3,7 @@ package sigmastate import org.ergoplatform.ErgoBox.RegisterId import scalan.reflection.CommonReflection.registerClassEntry import scalan.reflection.{mkConstructor, mkMethod} -import sigma.collection.Coll +import sigma.Coll import sigma.{AvlTree, CoreLibReflection, SigmaDslBuilder} import sigmastate.SAvlTree.KeyValueColl import sigmastate.SCollection.{SBooleanArray, SByteArray, SIntArray} diff --git a/interpreter/shared/src/main/scala/sigmastate/Values.scala b/interpreter/shared/src/main/scala/sigmastate/Values.scala index 2eb5a4ecad..a9f5779b7d 100644 --- a/interpreter/shared/src/main/scala/sigmastate/Values.scala +++ b/interpreter/shared/src/main/scala/sigmastate/Values.scala @@ -35,7 +35,7 @@ import sigmastate.utils.{SigmaByteReader, SigmaByteWriter} import sigma.{AvlTree, Header, PreHeader, _} import sigmastate.lang.SourceContext import sigma.util.safeNewArray -import sigma.collection.Coll +import sigma.Coll import scala.collection.compat.immutable.ArraySeq import scala.collection.mutable diff --git a/interpreter/shared/src/main/scala/sigmastate/basics/SigmaProtocolFunctions.scala b/interpreter/shared/src/main/scala/sigmastate/basics/SigmaProtocolFunctions.scala index 9c9d15b0d2..6b99616753 100644 --- a/interpreter/shared/src/main/scala/sigmastate/basics/SigmaProtocolFunctions.scala +++ b/interpreter/shared/src/main/scala/sigmastate/basics/SigmaProtocolFunctions.scala @@ -3,7 +3,7 @@ package sigmastate.basics import sigmastate.SigmaLeaf import sigmastate.basics.CryptoConstants.dlogGroup import sigmastate.basics.VerifierMessage.Challenge -import sigma.collection.Coll +import sigma.Coll import supertagged.TaggedType import java.math.BigInteger diff --git a/interpreter/shared/src/main/scala/sigmastate/eval/CostingDataContext.scala b/interpreter/shared/src/main/scala/sigmastate/eval/CostingDataContext.scala index 262808700c..2123f14ce4 100644 --- a/interpreter/shared/src/main/scala/sigmastate/eval/CostingDataContext.scala +++ b/interpreter/shared/src/main/scala/sigmastate/eval/CostingDataContext.scala @@ -23,7 +23,6 @@ import sigmastate.eval.Extensions._ import sigmastate.interpreter.Interpreter import sigmastate.serialization.ErgoTreeSerializer.DefaultSerializer import sigmastate.serialization.{GroupElementSerializer, SigmaSerializer} -import sigma.collection._ import sigma._ import java.math.BigInteger diff --git a/interpreter/shared/src/main/scala/sigmastate/eval/Evaluation.scala b/interpreter/shared/src/main/scala/sigmastate/eval/Evaluation.scala index ae10009145..ddb7b205ac 100644 --- a/interpreter/shared/src/main/scala/sigmastate/eval/Evaluation.scala +++ b/interpreter/shared/src/main/scala/sigmastate/eval/Evaluation.scala @@ -17,7 +17,7 @@ import scala.util.Try /** Helper methods used as part of ErgoTree evaluation. */ object Evaluation { - import sigma.collection._ + import sigma._ import sigma._ def msgCostLimitError(cost: Long, limit: Long) = s"Estimated execution cost $cost exceeds the limit $limit" diff --git a/interpreter/shared/src/main/scala/sigmastate/eval/Extensions.scala b/interpreter/shared/src/main/scala/sigmastate/eval/Extensions.scala index d92f48f37e..8c1eedb9f0 100644 --- a/interpreter/shared/src/main/scala/sigmastate/eval/Extensions.scala +++ b/interpreter/shared/src/main/scala/sigmastate/eval/Extensions.scala @@ -11,7 +11,7 @@ import sigmastate.crypto.{CryptoFacade, Ecp} import sigmastate.lang.{CheckingSigmaBuilder, TransformingSigmaBuilder} import sigmastate.utils.Helpers import sigmastate.{Platform, SCollection, SCollectionType, SType} -import sigma.collection.Coll +import sigma.Coll import sigma._ import java.math.BigInteger diff --git a/interpreter/shared/src/main/scala/sigmastate/eval/package.scala b/interpreter/shared/src/main/scala/sigmastate/eval/package.scala index 995d770183..7add87d048 100644 --- a/interpreter/shared/src/main/scala/sigmastate/eval/package.scala +++ b/interpreter/shared/src/main/scala/sigmastate/eval/package.scala @@ -7,7 +7,7 @@ import scalan.RType import scorex.crypto.hash.Digest32 import sigmastate.Values.SigmaBoolean import sigmastate.basics.CryptoConstants.EcPointType -import sigma.collection.{Coll, CollBuilder} +import sigma.{Coll, CollBuilder} import sigma._ import supertagged.TaggedType diff --git a/interpreter/shared/src/main/scala/sigmastate/interpreter/ErgoTreeEvaluator.scala b/interpreter/shared/src/main/scala/sigmastate/interpreter/ErgoTreeEvaluator.scala index b5f1af9dd4..62e9c5a34b 100644 --- a/interpreter/shared/src/main/scala/sigmastate/interpreter/ErgoTreeEvaluator.scala +++ b/interpreter/shared/src/main/scala/sigmastate/interpreter/ErgoTreeEvaluator.scala @@ -103,7 +103,7 @@ case class JitEvalResult[A](value: A, cost: JitCost) * transaction. No additional transformation is performed. * ErgoTree is interpreted directly and all the intermediate data is stored in the * runtime types. - * The runtime types are such types as [[sigma.collection.Coll]], + * The runtime types are such types as [[sigma.Coll]], * [[sigma.SigmaProp]], [[sigma.AvlTree]], [[BigInt]], etc. * It also use immutable Map to keep current [[DataEnv]] of computed [[ValDef]]s, as * result only addition is used from the map, and deletion is essentially a garbage diff --git a/interpreter/shared/src/main/scala/sigmastate/interpreter/ProverInterpreter.scala b/interpreter/shared/src/main/scala/sigmastate/interpreter/ProverInterpreter.scala index 41f0ab37db..d3cf8b7558 100644 --- a/interpreter/shared/src/main/scala/sigmastate/interpreter/ProverInterpreter.scala +++ b/interpreter/shared/src/main/scala/sigmastate/interpreter/ProverInterpreter.scala @@ -15,7 +15,7 @@ import sigmastate.crypto.{GF2_192, GF2_192_Poly} import sigmastate.eval.Extensions.ArrayOps import sigmastate.exceptions.InterpreterException import sigmastate.utils.Helpers -import sigma.collection.Coll +import sigma.Coll import java.math.BigInteger import scala.util.Try diff --git a/interpreter/shared/src/main/scala/sigmastate/lang/SigmaBuilder.scala b/interpreter/shared/src/main/scala/sigmastate/lang/SigmaBuilder.scala index e3b5d460fc..147cbafa84 100644 --- a/interpreter/shared/src/main/scala/sigmastate/lang/SigmaBuilder.scala +++ b/interpreter/shared/src/main/scala/sigmastate/lang/SigmaBuilder.scala @@ -15,7 +15,7 @@ import sigmastate.lang.Terms.{STypeSubst, _} import sigmastate.serialization.OpCodes import sigmastate.serialization.OpCodes.OpCode import sigmastate.utxo._ -import sigma.collection.Coll +import sigma.Coll import sigma.AnyValue import scala.util.DynamicVariable diff --git a/interpreter/shared/src/main/scala/sigmastate/serialization/DataSerializer.scala b/interpreter/shared/src/main/scala/sigmastate/serialization/DataSerializer.scala index d53075acd5..a3c86c85e7 100644 --- a/interpreter/shared/src/main/scala/sigmastate/serialization/DataSerializer.scala +++ b/interpreter/shared/src/main/scala/sigmastate/serialization/DataSerializer.scala @@ -10,7 +10,6 @@ import sigmastate.Values.SigmaBoolean import sigmastate.utils.{SigmaByteReader, SigmaByteWriter} import sigmastate._ import sigmastate.eval.{Evaluation, _} -import sigma.collection._ import sigma._ import debox.cfor import sigmastate.exceptions.SerializerException diff --git a/interpreter/shared/src/main/scala/sigmastate/trees.scala b/interpreter/shared/src/main/scala/sigmastate/trees.scala index 91cbb8eef5..006bfa8454 100644 --- a/interpreter/shared/src/main/scala/sigmastate/trees.scala +++ b/interpreter/shared/src/main/scala/sigmastate/trees.scala @@ -22,7 +22,7 @@ import sigmastate.interpreter.ErgoTreeEvaluator.DataEnv import sigmastate.serialization.OpCodes._ import sigmastate.serialization._ import sigmastate.utxo.{SimpleTransformerCompanion, Transformer} -import sigma.collection.Coll +import sigma.Coll import sigma.{GroupElement, SigmaProp} import scala.collection.mutable diff --git a/interpreter/shared/src/main/scala/sigmastate/types.scala b/interpreter/shared/src/main/scala/sigmastate/types.scala index 63b9e75fe9..c4a8a89181 100644 --- a/interpreter/shared/src/main/scala/sigmastate/types.scala +++ b/interpreter/shared/src/main/scala/sigmastate/types.scala @@ -19,7 +19,7 @@ import sigmastate.lang.{SigmaBuilder, Terms} import sigmastate.SCollection._ import sigmastate.basics.CryptoConstants.{hashLength, EcPointType} import sigmastate.serialization.OpCodes -import sigma.collection.Coll +import sigma.Coll import sigma._ import scala.language.implicitConversions diff --git a/interpreter/shared/src/main/scala/sigmastate/utils/Extensions.scala b/interpreter/shared/src/main/scala/sigmastate/utils/Extensions.scala index 1235893611..f7ce8b46c4 100644 --- a/interpreter/shared/src/main/scala/sigmastate/utils/Extensions.scala +++ b/interpreter/shared/src/main/scala/sigmastate/utils/Extensions.scala @@ -4,7 +4,7 @@ import org.ergoplatform.ErgoBox.TokenId import scorex.util.{ModifierId, idToBytes} import scorex.utils.{Ints, Longs, Shorts} import sigmastate.eval.{Digest32Coll, SigmaDsl} -import sigma.collection.Coll +import sigma.Coll object Extensions { implicit class ByteOpsForSigma(val b: Byte) extends AnyVal { diff --git a/interpreter/shared/src/main/scala/sigmastate/utils/Helpers.scala b/interpreter/shared/src/main/scala/sigmastate/utils/Helpers.scala index 4eb870b412..07f9f8dd30 100644 --- a/interpreter/shared/src/main/scala/sigmastate/utils/Helpers.scala +++ b/interpreter/shared/src/main/scala/sigmastate/utils/Helpers.scala @@ -8,7 +8,7 @@ import scorex.utils.Ints import sigma.Environment import sigmastate.eval.{CAnyValue, Colls, SigmaDsl} import sigmastate.basics.CryptoConstants.EcPointType -import sigma.collection.Coll +import sigma.Coll import sigma.GroupElement import java.util diff --git a/interpreter/shared/src/main/scala/sigmastate/utxo/transformers.scala b/interpreter/shared/src/main/scala/sigmastate/utxo/transformers.scala index 8cd0abe075..87d4bc52bc 100644 --- a/interpreter/shared/src/main/scala/sigmastate/utxo/transformers.scala +++ b/interpreter/shared/src/main/scala/sigmastate/utxo/transformers.scala @@ -13,7 +13,7 @@ import sigmastate.eval.{Evaluation, SigmaDsl} import sigmastate.exceptions.InterpreterException import sigmastate.interpreter.ErgoTreeEvaluator import sigmastate.interpreter.ErgoTreeEvaluator.{DataEnv, error} -import sigma.collection.Coll +import sigma.Coll import sigma.{Box, SigmaProp} // TODO refactor: remove this trait as it doesn't have semantic meaning diff --git a/interpreter/shared/src/test/scala/sigmastate/helpers/ErgoLikeContextTesting.scala b/interpreter/shared/src/test/scala/sigmastate/helpers/ErgoLikeContextTesting.scala index a24dcd548c..02086879e5 100644 --- a/interpreter/shared/src/test/scala/sigmastate/helpers/ErgoLikeContextTesting.scala +++ b/interpreter/shared/src/test/scala/sigmastate/helpers/ErgoLikeContextTesting.scala @@ -9,7 +9,7 @@ import sigmastate.eval._ import sigmastate.interpreter.ContextExtension import sigmastate.interpreter.ErgoTreeEvaluator.DefaultEvalSettings import sigmastate.serialization.{GroupElementSerializer, SigmaSerializer} -import sigma.collection.Coll +import sigma.Coll import sigma.{Box, Header, PreHeader} object ErgoLikeContextTesting { diff --git a/interpreter/shared/src/test/scala/sigmastate/helpers/TestingHelpers.scala b/interpreter/shared/src/test/scala/sigmastate/helpers/TestingHelpers.scala index e664a251e6..afecd8d3b6 100644 --- a/interpreter/shared/src/test/scala/sigmastate/helpers/TestingHelpers.scala +++ b/interpreter/shared/src/test/scala/sigmastate/helpers/TestingHelpers.scala @@ -8,7 +8,7 @@ import sigmastate.AvlTreeData import sigmastate.Values.ErgoTree import sigmastate.eval.{CostingSigmaDslBuilder, _} import sigmastate.interpreter.ContextExtension -import sigma.collection.{Coll, CollOverArray, PairOfCols} +import sigma.{Coll, CollOverArray, PairOfCols} import sigma.{Header, PreHeader} import scala.collection.compat.immutable.ArraySeq diff --git a/interpreter/shared/src/test/scala/sigmastate/serialization/generators/ObjectGenerators.scala b/interpreter/shared/src/test/scala/sigmastate/serialization/generators/ObjectGenerators.scala index 9128d3dc10..bf8c4ef06f 100644 --- a/interpreter/shared/src/test/scala/sigmastate/serialization/generators/ObjectGenerators.scala +++ b/interpreter/shared/src/test/scala/sigmastate/serialization/generators/ObjectGenerators.scala @@ -22,7 +22,7 @@ import sigmastate.interpreter.{ContextExtension, ProverResult} import sigmastate.lang.TransformingSigmaBuilder._ import sigmastate._ import sigmastate.utxo._ -import sigma.collection.Coll +import sigma.Coll import sigma._ import java.math.BigInteger diff --git a/interpreter/shared/src/test/scala/special/sigma/ContractsTestkit.scala b/interpreter/shared/src/test/scala/special/sigma/ContractsTestkit.scala index a7f0b1624a..44c853df35 100644 --- a/interpreter/shared/src/test/scala/special/sigma/ContractsTestkit.scala +++ b/interpreter/shared/src/test/scala/special/sigma/ContractsTestkit.scala @@ -1,6 +1,5 @@ package sigma -import sigma.collection.{Coll, CollOverArrayBuilder} import scalan.RType import sigmastate.Values.ErgoTree import sigmastate.{AvlTreeData, Values} diff --git a/interpreter/shared/src/test/scala/special/sigma/SigmaTestingData.scala b/interpreter/shared/src/test/scala/special/sigma/SigmaTestingData.scala index 2ce39b0077..93f7223bc9 100644 --- a/interpreter/shared/src/test/scala/special/sigma/SigmaTestingData.scala +++ b/interpreter/shared/src/test/scala/special/sigma/SigmaTestingData.scala @@ -22,13 +22,13 @@ import sigmastate.serialization.ErgoTreeSerializer import sigmastate.serialization.generators.ObjectGenerators import sigmastate.utils.Helpers import sigmastate._ -import sigma.collection.Coll +import sigma.Coll import java.math.BigInteger import scala.reflect.ClassTag trait SigmaTestingData extends TestingCommons with ObjectGenerators { - /** Creates a [[sigma.collection.Coll]] with the given `items`. */ + /** Creates a [[sigma.Coll]] with the given `items`. */ def Coll[T](items: T*)(implicit cT: RType[T]): Coll[T] = CostingSigmaDslBuilder.Colls.fromItems(items: _*) diff --git a/parsers/shared/src/test/scala/sigmastate/lang/LangTests.scala b/parsers/shared/src/test/scala/sigmastate/lang/LangTests.scala index 0c79b8f05e..2b2fa70ce8 100644 --- a/parsers/shared/src/test/scala/sigmastate/lang/LangTests.scala +++ b/parsers/shared/src/test/scala/sigmastate/lang/LangTests.scala @@ -13,7 +13,7 @@ import sigmastate.interpreter.Interpreter.ScriptEnv import sigma._ import sigmastate.eval._ import sigmastate.helpers.NegativeTesting -import sigma.collection.Coll +import sigma.Coll trait LangTests extends Matchers with NegativeTesting { diff --git a/sc/jvm/src/test/scala/sigmastate/ErgoTreeBenchmarks.scala b/sc/jvm/src/test/scala/sigmastate/ErgoTreeBenchmarks.scala index 8c3789891b..f5741dcb42 100644 --- a/sc/jvm/src/test/scala/sigmastate/ErgoTreeBenchmarks.scala +++ b/sc/jvm/src/test/scala/sigmastate/ErgoTreeBenchmarks.scala @@ -2,7 +2,7 @@ package sigmastate import debox.cfor import org.scalameter.api.Bench -import sigma.collections.BenchmarkGens +import sigma.BenchmarkGens import sigmastate.Values.{IntConstant, SValue} import sigmastate.serialization.OpCodes.PlusCode diff --git a/sc/jvm/src/test/scala/sigmastate/ReflectionGenerator.scala b/sc/jvm/src/test/scala/sigmastate/ReflectionGenerator.scala index ed2f863102..df19d7a45c 100644 --- a/sc/jvm/src/test/scala/sigmastate/ReflectionGenerator.scala +++ b/sc/jvm/src/test/scala/sigmastate/ReflectionGenerator.scala @@ -32,7 +32,7 @@ object ReflectionGenerator { val knownPackages = Array( "scalan.primitives.", - "sigma.collection.", + "sigma.", "sigma.", "special.wrappers.", "sigmastate.Values.", diff --git a/sc/jvm/src/test/scala/sigmastate/helpers/SigmaPPrintSpec.scala b/sc/jvm/src/test/scala/sigmastate/helpers/SigmaPPrintSpec.scala index 5abbf7c9c3..ff7a37c5a7 100644 --- a/sc/jvm/src/test/scala/sigmastate/helpers/SigmaPPrintSpec.scala +++ b/sc/jvm/src/test/scala/sigmastate/helpers/SigmaPPrintSpec.scala @@ -12,7 +12,7 @@ import sigmastate.lang.Terms.MethodCall import sigmastate.serialization.OpCodes import sigmastate.utils.Helpers import sigmastate.utxo.SelectField -import sigma.collection.CollType +import sigma.CollType import sigma.SigmaDslTesting import java.math.BigInteger diff --git a/sc/jvm/src/test/scala/special/collections/BasicBenchmarks.scala b/sc/jvm/src/test/scala/special/collections/BasicBenchmarks.scala index 144f731bad..dcb7ff54b3 100644 --- a/sc/jvm/src/test/scala/special/collections/BasicBenchmarks.scala +++ b/sc/jvm/src/test/scala/special/collections/BasicBenchmarks.scala @@ -1,4 +1,4 @@ -package sigma.collections +package sigma import org.scalameter.api._ import debox.cfor diff --git a/sc/jvm/src/test/scala/special/collections/BenchmarkGens.scala b/sc/jvm/src/test/scala/special/collections/BenchmarkGens.scala index a44e40fe38..3421d42343 100644 --- a/sc/jvm/src/test/scala/special/collections/BenchmarkGens.scala +++ b/sc/jvm/src/test/scala/special/collections/BenchmarkGens.scala @@ -1,4 +1,4 @@ -package sigma.collections +package sigma import org.scalameter.KeyValue import org.scalameter.api.{Bench, Gen, _} diff --git a/sc/jvm/src/test/scala/special/collections/BufferBenchmark.scala b/sc/jvm/src/test/scala/special/collections/BufferBenchmark.scala index e4dd00e9be..0654b12690 100644 --- a/sc/jvm/src/test/scala/special/collections/BufferBenchmark.scala +++ b/sc/jvm/src/test/scala/special/collections/BufferBenchmark.scala @@ -1,4 +1,4 @@ -package sigma.collections +package sigma import debox.Buffer import debox.cfor diff --git a/sc/jvm/src/test/scala/special/collections/CollBenchmark.scala b/sc/jvm/src/test/scala/special/collections/CollBenchmark.scala index aa72f7dc49..cb2614871b 100644 --- a/sc/jvm/src/test/scala/special/collections/CollBenchmark.scala +++ b/sc/jvm/src/test/scala/special/collections/CollBenchmark.scala @@ -1,10 +1,8 @@ -package sigma.collections +package sigma import org.scalameter.{execution, Executor} import org.scalameter.api._ import org.scalameter.picklers.Implicits._ -import sigma.collection.Coll -import sigma.collection.Extensions._ import debox.cfor diff --git a/sc/jvm/src/test/scala/special/collections/MapBenchmark.scala b/sc/jvm/src/test/scala/special/collections/MapBenchmark.scala index 06b2e781c6..ca36b41179 100644 --- a/sc/jvm/src/test/scala/special/collections/MapBenchmark.scala +++ b/sc/jvm/src/test/scala/special/collections/MapBenchmark.scala @@ -1,4 +1,4 @@ -package sigma.collections +package sigma import org.scalameter.api.Bench import scalan.{AVHashMap, Nullable} diff --git a/sc/jvm/src/test/scala/special/collections/SymBenchmark.scala b/sc/jvm/src/test/scala/special/collections/SymBenchmark.scala index 4710f9fe7e..ff46aafa2b 100644 --- a/sc/jvm/src/test/scala/special/collections/SymBenchmark.scala +++ b/sc/jvm/src/test/scala/special/collections/SymBenchmark.scala @@ -1,4 +1,4 @@ -package sigma.collections +package sigma import debox.{Set => DSet, Map => DMap} import scalan.TestLibrary diff --git a/sc/shared/src/main/scala/org/ergoplatform/dsl/ErgoContractSpec.scala b/sc/shared/src/main/scala/org/ergoplatform/dsl/ErgoContractSpec.scala index 1592c1d30b..c1b0b40381 100644 --- a/sc/shared/src/main/scala/org/ergoplatform/dsl/ErgoContractSpec.scala +++ b/sc/shared/src/main/scala/org/ergoplatform/dsl/ErgoContractSpec.scala @@ -1,6 +1,6 @@ package org.ergoplatform.dsl -import sigma.collection.Coll +import sigma.Coll import sigmastate.interpreter.CostedProverResult import sigmastate.eval.IRContext import org.ergoplatform.dsl.ContractSyntax.{ErgoScript, Proposition, Token} diff --git a/sc/shared/src/main/scala/scalan/GraphIRReflection.scala b/sc/shared/src/main/scala/scalan/GraphIRReflection.scala index 89ce1ab852..6abcfb2fa3 100644 --- a/sc/shared/src/main/scala/scalan/GraphIRReflection.scala +++ b/sc/shared/src/main/scala/scalan/GraphIRReflection.scala @@ -5,7 +5,7 @@ import scalan.reflection.CommonReflection.registerClassEntry import scalan.reflection.{CommonReflection, mkConstructor, mkMethod} import sigma.CoreLibReflection import sigmastate.eval.SigmaLibrary -import sigma.collection.Colls +import sigma.Colls import sigma.SigmaDsl import special.wrappers.{OptionWrapSpec, RTypeWrapSpec} import wrappers.scalan.WRTypes diff --git a/sc/shared/src/main/scala/scalan/Library.scala b/sc/shared/src/main/scala/scalan/Library.scala index 566c53e4dc..797d510b7b 100644 --- a/sc/shared/src/main/scala/scalan/Library.scala +++ b/sc/shared/src/main/scala/scalan/Library.scala @@ -1,7 +1,7 @@ package scalan import scala.language.implicitConversions -import sigma.collection._ +import sigma._ import special.wrappers.WrappersModule import scalan.util.MemoizedFunc import scalan.ExactIntegral._ diff --git a/sc/shared/src/main/scala/special/collection/CollsUnit.scala b/sc/shared/src/main/scala/special/collection/CollsUnit.scala index f3342e7594..02e62aeb4d 100644 --- a/sc/shared/src/main/scala/special/collection/CollsUnit.scala +++ b/sc/shared/src/main/scala/special/collection/CollsUnit.scala @@ -1,10 +1,10 @@ -package sigma.collection { +package sigma { import scalan._ /** Staged version of collection interfaces which is used in graph-based IR to represent * methods of Coll and CollBuilder. * Each method of Coll and CollBuilder in Colls corresponds to a method of the original - * non-staged class [[sigma.collection.Coll]] and [[sigma.collection.CollBuilder]]. + * non-staged class [[sigma.Coll]] and [[sigma.CollBuilder]]. * The semantics of each method is the same as in the original class, please look there * for details. */ diff --git a/sc/shared/src/main/scala/special/collection/impl/CollsImpl.scala b/sc/shared/src/main/scala/special/collection/impl/CollsImpl.scala index e4cb3b0077..67c19d672f 100644 --- a/sc/shared/src/main/scala/special/collection/impl/CollsImpl.scala +++ b/sc/shared/src/main/scala/special/collection/impl/CollsImpl.scala @@ -1,4 +1,4 @@ -package sigma.collection +package sigma import scala.language.{existentials,implicitConversions} import scalan._ @@ -20,7 +20,7 @@ import WOption._ class CollCls extends EntityObject("Coll") { // entityConst: single const for each entity import Liftables._ - type SColl[A] = sigma.collection.Coll[A] + type SColl[A] = sigma.Coll[A] case class CollConst[SA, A]( constValue: SColl[SA], lA: Liftable[SA, A] @@ -495,7 +495,7 @@ object Coll extends CollCls object CollBuilder extends EntityObject("CollBuilder") { // entityConst: single const for each entity import Liftables._ - type SCollBuilder = sigma.collection.CollBuilder + type SCollBuilder = sigma.CollBuilder case class CollBuilderConst( constValue: SCollBuilder ) extends LiftedConst[SCollBuilder, CollBuilder] with CollBuilder @@ -637,9 +637,9 @@ object CollBuilder extends EntityObject("CollBuilder") { } -object CollsModule extends scalan.ModuleInfo("sigma.collection", "Colls") { +object CollsModule extends scalan.ModuleInfo("sigma", "Colls") { val reflection = GraphIRReflection } } -trait CollsModule extends sigma.collection.impl.CollsDefs {self: Library =>} +trait CollsModule extends sigma.impl.CollsDefs {self: Library =>} diff --git a/sc/shared/src/test/scala/org/ergoplatform/ErgoLikeTransactionSpec.scala b/sc/shared/src/test/scala/org/ergoplatform/ErgoLikeTransactionSpec.scala index 1d644afcb5..c07dc58d3a 100644 --- a/sc/shared/src/test/scala/org/ergoplatform/ErgoLikeTransactionSpec.scala +++ b/sc/shared/src/test/scala/org/ergoplatform/ErgoLikeTransactionSpec.scala @@ -15,7 +15,7 @@ import sigmastate.SType._ import sigmastate.helpers.TestingHelpers.copyTransaction import sigmastate.utils.Helpers import sigma.SigmaDslTesting -import sigma.collection.Extensions._ +import sigma.Extensions._ class ErgoLikeTransactionSpec extends SigmaDslTesting { diff --git a/sc/shared/src/test/scala/sigmastate/ErgoTreeSpecification.scala b/sc/shared/src/test/scala/sigmastate/ErgoTreeSpecification.scala index 8a939fbb20..e752eaf9ea 100644 --- a/sc/shared/src/test/scala/sigmastate/ErgoTreeSpecification.scala +++ b/sc/shared/src/test/scala/sigmastate/ErgoTreeSpecification.scala @@ -19,7 +19,7 @@ import sigmastate.lang.Terms._ import sigmastate.serialization.ErgoTreeSerializer.DefaultSerializer import sigmastate.utils.Helpers.TryOps import sigmastate.utxo._ -import sigma.collection._ +import sigma._ import sigma.{ContractsTestkit, SigmaDslTesting} diff --git a/sc/shared/src/test/scala/sigmastate/helpers/SigmaPPrint.scala b/sc/shared/src/test/scala/sigmastate/helpers/SigmaPPrint.scala index a1b1c97c86..1bfd11dea5 100644 --- a/sc/shared/src/test/scala/sigmastate/helpers/SigmaPPrint.scala +++ b/sc/shared/src/test/scala/sigmastate/helpers/SigmaPPrint.scala @@ -17,8 +17,7 @@ import sigmastate.lang.Terms.MethodCall import sigmastate.serialization.GroupElementSerializer import sigmastate.utxo.SelectField import sigmastate.interpreter.{CompanionDesc, ErgoTreeEvaluator, FixedCostItem, MethodDesc} -import sigma.collection.{Coll, CollType} -import sigma.GroupElement +import sigma.{Coll, CollType, GroupElement} import scala.collection.compat.immutable.ArraySeq import scala.collection.mutable diff --git a/sc/shared/src/test/scala/sigmastate/utxo/AVLTreeScriptsSpecification.scala b/sc/shared/src/test/scala/sigmastate/utxo/AVLTreeScriptsSpecification.scala index 520f625a94..5133692685 100644 --- a/sc/shared/src/test/scala/sigmastate/utxo/AVLTreeScriptsSpecification.scala +++ b/sc/shared/src/test/scala/sigmastate/utxo/AVLTreeScriptsSpecification.scala @@ -17,7 +17,7 @@ import sigmastate.helpers.TestingHelpers._ import sigmastate.interpreter.Interpreter.ScriptNameProp import sigmastate.interpreter.ProverResult import sigmastate.lang.Terms._ -import sigma.collection.Coll +import sigma.Coll import sigma.{AvlTree, Context} diff --git a/sc/shared/src/test/scala/sigmastate/utxo/ContextEnrichingSpecification.scala b/sc/shared/src/test/scala/sigmastate/utxo/ContextEnrichingSpecification.scala index 3e9d7394bd..6c84a5f54f 100644 --- a/sc/shared/src/test/scala/sigmastate/utxo/ContextEnrichingSpecification.scala +++ b/sc/shared/src/test/scala/sigmastate/utxo/ContextEnrichingSpecification.scala @@ -6,7 +6,7 @@ import sigmastate.Values._ import sigmastate._ import sigmastate.lang.Terms._ import sigmastate.helpers.{ContextEnrichingTestProvingInterpreter, ErgoLikeContextTesting, ErgoLikeTestInterpreter, CompilerTestingCommons} -import sigma.collection.Coll +import sigma.Coll class ContextEnrichingSpecification extends CompilerTestingCommons diff --git a/sc/shared/src/test/scala/sigmastate/utxo/examples/AssetsAtomicExchange.scala b/sc/shared/src/test/scala/sigmastate/utxo/examples/AssetsAtomicExchange.scala index e1780c3b04..c58d7511d1 100644 --- a/sc/shared/src/test/scala/sigmastate/utxo/examples/AssetsAtomicExchange.scala +++ b/sc/shared/src/test/scala/sigmastate/utxo/examples/AssetsAtomicExchange.scala @@ -3,7 +3,7 @@ package sigmastate.utxo.examples import org.ergoplatform.dsl.ContractSyntax.Token import sigma.Context import org.ergoplatform.ErgoBox.{R4, TokenId} -import sigma.collection.Coll +import sigma.Coll import org.ergoplatform.dsl.{SigmaContractSyntax, ContractSpec, StdContracts} /** Contract specification for assets atomic exchange transactions. diff --git a/sc/shared/src/test/scala/sigmastate/utxo/examples/AssetsAtomicExchangeErgoTests.scala b/sc/shared/src/test/scala/sigmastate/utxo/examples/AssetsAtomicExchangeErgoTests.scala index b5883ec7d6..5eb852265d 100644 --- a/sc/shared/src/test/scala/sigmastate/utxo/examples/AssetsAtomicExchangeErgoTests.scala +++ b/sc/shared/src/test/scala/sigmastate/utxo/examples/AssetsAtomicExchangeErgoTests.scala @@ -3,7 +3,7 @@ package sigmastate.utxo.examples import sigmastate.helpers.CompilerTestingCommons import org.ergoplatform.dsl.ContractSyntax.Token import org.ergoplatform.dsl.ErgoContractSpec -import sigma.collection.Coll +import sigma.Coll import scorex.crypto.hash.Blake2b256 import sigmastate.eval.Digest32Coll diff --git a/sc/shared/src/test/scala/sigmastate/utxo/examples/AssetsPartialFilling.scala b/sc/shared/src/test/scala/sigmastate/utxo/examples/AssetsPartialFilling.scala index c7c3b88458..969439fe59 100644 --- a/sc/shared/src/test/scala/sigmastate/utxo/examples/AssetsPartialFilling.scala +++ b/sc/shared/src/test/scala/sigmastate/utxo/examples/AssetsPartialFilling.scala @@ -3,7 +3,7 @@ package sigmastate.utxo.examples import org.ergoplatform.ErgoBox.TokenId import org.ergoplatform.dsl.ContractSyntax.Token import sigma.Context -import sigma.collection.Coll +import sigma.Coll import org.ergoplatform.dsl.{SigmaContractSyntax, ContractSpec, StdContracts} /** diff --git a/sc/shared/src/test/scala/sigmastate/utxo/examples/DummyExamplesSpecification.scala b/sc/shared/src/test/scala/sigmastate/utxo/examples/DummyExamplesSpecification.scala index c24b629b7d..754e3baa73 100644 --- a/sc/shared/src/test/scala/sigmastate/utxo/examples/DummyExamplesSpecification.scala +++ b/sc/shared/src/test/scala/sigmastate/utxo/examples/DummyExamplesSpecification.scala @@ -4,8 +4,7 @@ import org.ergoplatform.ErgoBox import org.ergoplatform.dsl.{ContractSpec, SigmaContractSyntax, StdContracts, TestContractSpec} import scorex.crypto.hash import sigmastate.helpers.CompilerTestingCommons -import sigma.collection.Coll -import sigma.{Box, Context} +import sigma.{Box, Context, Coll} import sigmastate.eval.Extensions class DummyExamplesSpecification extends CompilerTestingCommons { suite => diff --git a/sc/shared/src/test/scala/sigmastate/utxo/examples/OracleDataInputsExamplesSpecification.scala b/sc/shared/src/test/scala/sigmastate/utxo/examples/OracleDataInputsExamplesSpecification.scala index 0be9e3d02c..564385fd96 100644 --- a/sc/shared/src/test/scala/sigmastate/utxo/examples/OracleDataInputsExamplesSpecification.scala +++ b/sc/shared/src/test/scala/sigmastate/utxo/examples/OracleDataInputsExamplesSpecification.scala @@ -6,7 +6,7 @@ import org.ergoplatform.dsl.{ContractSpec, SigmaContractSyntax, StdContracts, Te import scorex.crypto.hash.Blake2b256 import sigmastate.eval.Digest32Coll import sigmastate.helpers.CompilerTestingCommons -import sigma.collection.Coll +import sigma.Coll import sigma.Context class OracleDataInputsExamplesSpecification extends CompilerTestingCommons { suite => diff --git a/sc/shared/src/test/scala/sigmastate/utxo/examples/OracleTokenExamplesSpecification.scala b/sc/shared/src/test/scala/sigmastate/utxo/examples/OracleTokenExamplesSpecification.scala index a9e254cc37..5a30cd6689 100644 --- a/sc/shared/src/test/scala/sigmastate/utxo/examples/OracleTokenExamplesSpecification.scala +++ b/sc/shared/src/test/scala/sigmastate/utxo/examples/OracleTokenExamplesSpecification.scala @@ -6,7 +6,7 @@ import org.ergoplatform.dsl.{ContractSpec, SigmaContractSyntax, StdContracts, Te import scorex.crypto.hash.Blake2b256 import sigmastate.eval.Digest32Coll import sigmastate.helpers.CompilerTestingCommons -import sigma.collection.Coll +import sigma.Coll import sigma.Context class OracleTokenExamplesSpecification extends CompilerTestingCommons { suite => diff --git a/sc/shared/src/test/scala/special/collections/CollsStagingTests.scala b/sc/shared/src/test/scala/special/collections/CollsStagingTests.scala index 8df061299d..545ab7d916 100644 --- a/sc/shared/src/test/scala/special/collections/CollsStagingTests.scala +++ b/sc/shared/src/test/scala/special/collections/CollsStagingTests.scala @@ -1,4 +1,4 @@ -package sigma.collections +package sigma import scala.language.reflectiveCalls import special.wrappers.WrappersTests @@ -47,7 +47,7 @@ class CollsStagingTests extends WrappersTests { import EnvRep._ import Liftables._ - val Cols: SCollBuilder = new sigma.collection.CollOverArrayBuilder + val Cols: SCollBuilder = new sigma.CollOverArrayBuilder val arr = Array(1, 2, 3) val col = Cols.fromArray(arr) @@ -63,7 +63,7 @@ class CollsStagingTests extends WrappersTests { import Coll._ import CollBuilder._ - val Cols: SCollBuilder = new sigma.collection.CollOverArrayBuilder + val Cols: SCollBuilder = new sigma.CollOverArrayBuilder val colData = Cols.replicate(10, 10) val colSym = colBuilder.replicate(10, 10) val resSym = colSym.append(colSym) diff --git a/sc/shared/src/test/scala/special/sigma/DataValueComparerSpecification.scala b/sc/shared/src/test/scala/special/sigma/DataValueComparerSpecification.scala index 9cf9562e50..3a4b639306 100644 --- a/sc/shared/src/test/scala/special/sigma/DataValueComparerSpecification.scala +++ b/sc/shared/src/test/scala/special/sigma/DataValueComparerSpecification.scala @@ -8,7 +8,7 @@ import sigmastate.Values.ErgoTree import sigmastate.eval.{CSigmaProp, Profiler, SigmaDsl} import sigmastate.helpers.SigmaPPrint import sigmastate.interpreter.{CostAccumulator, ErgoTreeEvaluator, EvalSettings, TracedCost} -import sigma.collection.Coll +import sigma.Coll import scala.util.{Success, Try} diff --git a/sc/shared/src/test/scala/special/sigma/SigmaDslSpecification.scala b/sc/shared/src/test/scala/special/sigma/SigmaDslSpecification.scala index afb3868cdf..591f2ca47b 100644 --- a/sc/shared/src/test/scala/special/sigma/SigmaDslSpecification.scala +++ b/sc/shared/src/test/scala/special/sigma/SigmaDslSpecification.scala @@ -20,8 +20,8 @@ import sigmastate.eval.Extensions._ import sigmastate.eval._ import sigmastate.lang.Terms.{MethodCall, PropertyCall} import sigmastate.utxo._ -import sigma.collection._ -import sigma.collection.Extensions._ +import sigma._ +import sigma.Extensions._ import sigmastate.serialization.OpCodes.OpCode import sigmastate.utils.Helpers import sigmastate.utils.Helpers._ @@ -6891,7 +6891,7 @@ class SigmaDslSpecification extends SigmaDslTesting )), preGeneratedSamples = Some(samples)) } else { - def error = new java.lang.NoSuchMethodException("sigmastate.SCollection$.forall_eval(sigmastate.lang.Terms$MethodCall,sigma.collection.Coll,scala.Function1,sigmastate.interpreter.ErgoTreeEvaluator))") + def error = new java.lang.NoSuchMethodException("sigmastate.SCollection$.forall_eval(sigmastate.lang.Terms$MethodCall,sigma.Coll,scala.Function1,sigmastate.interpreter.ErgoTreeEvaluator))") verifyCases( Seq((Coll[Box](), Expected(error))), existingFeature[Coll[Box], Boolean]({ (x: Coll[Box]) => throw error }, @@ -6967,7 +6967,7 @@ class SigmaDslSpecification extends SigmaDslTesting )), preGeneratedSamples = Some(samples)) } else { - def error = new java.lang.NoSuchMethodException("sigmastate.SCollection$.exist_eval(sigmastate.lang.Terms$MethodCall,sigma.collection.Coll,scala.Function1,sigmastate.interpreter.ErgoTreeEvaluator))") + def error = new java.lang.NoSuchMethodException("sigmastate.SCollection$.exist_eval(sigmastate.lang.Terms$MethodCall,sigma.Coll,scala.Function1,sigmastate.interpreter.ErgoTreeEvaluator))") verifyCases( Seq((Coll[Box](), Expected(error))), existingFeature[Coll[Box], Boolean]({ (x: Coll[Box]) => throw error }, @@ -7072,7 +7072,7 @@ class SigmaDslSpecification extends SigmaDslTesting ) ))) } else { - def error = new java.lang.NoSuchMethodException("sigmastate.SCollection$.exist_eval(sigmastate.lang.Terms$MethodCall,sigma.collection.Coll,scala.Function1,sigmastate.interpreter.ErgoTreeEvaluator))") + def error = new java.lang.NoSuchMethodException("sigmastate.SCollection$.exist_eval(sigmastate.lang.Terms$MethodCall,sigma.Coll,scala.Function1,sigmastate.interpreter.ErgoTreeEvaluator))") verifyCases( Seq( (Coll[BigInt](), Expected(error)) ), existingFeature[Coll[BigInt], Boolean]( @@ -7187,7 +7187,7 @@ class SigmaDslSpecification extends SigmaDslTesting ) ))) } else { - def error = new java.lang.NoSuchMethodException("sigmastate.SCollection$.exist_eval(sigmastate.lang.Terms$MethodCall,sigma.collection.Coll,scala.Function1,sigmastate.interpreter.ErgoTreeEvaluator))") + def error = new java.lang.NoSuchMethodException("sigmastate.SCollection$.exist_eval(sigmastate.lang.Terms$MethodCall,sigma.Coll,scala.Function1,sigmastate.interpreter.ErgoTreeEvaluator))") verifyCases( Seq( (Coll[BigInt](), Expected(error)) ), existingFeature[Coll[BigInt], Boolean]( @@ -7795,7 +7795,7 @@ class SigmaDslSpecification extends SigmaDslTesting ) ))) } else { - def error = new java.lang.NoSuchMethodException("sigmastate.SCollection$.fold_eval(sigmastate.lang.Terms$MethodCall,sigma.collection.Coll,java.lang.Object,scala.Function1,sigmastate.interpreter.ErgoTreeEvaluator))") + def error = new java.lang.NoSuchMethodException("sigmastate.SCollection$.fold_eval(sigmastate.lang.Terms$MethodCall,sigma.Coll,java.lang.Object,scala.Function1,sigmastate.interpreter.ErgoTreeEvaluator))") verifyCases( Seq( ((Coll[Byte](), 0), Expected(error)) ), existingFeature[(Coll[Byte], Int), Int]( @@ -8073,7 +8073,7 @@ class SigmaDslSpecification extends SigmaDslTesting ) ) )) } else { - def error = new java.lang.NoSuchMethodException("sigmastate.SCollection$.fold_eval(sigmastate.lang.Terms$MethodCall,sigma.collection.Coll,int,int,sigmastate.interpreter.ErgoTreeEvaluator))") + def error = new java.lang.NoSuchMethodException("sigmastate.SCollection$.fold_eval(sigmastate.lang.Terms$MethodCall,sigma.Coll,int,int,sigmastate.interpreter.ErgoTreeEvaluator))") verifyCases( Seq( ((Coll[Byte](), 0), Expected(error)) ), existingFeature( @@ -8739,7 +8739,7 @@ class SigmaDslSpecification extends SigmaDslTesting )), preGeneratedSamples = Some(samples)) } else { - def error = new java.lang.NoSuchMethodException("sigmastate.SCollection$.slice_eval(sigmastate.lang.Terms$MethodCall,sigma.collection.Coll,int,int,sigmastate.interpreter.ErgoTreeEvaluator))") + def error = new java.lang.NoSuchMethodException("sigmastate.SCollection$.slice_eval(sigmastate.lang.Terms$MethodCall,sigma.Coll,int,int,sigmastate.interpreter.ErgoTreeEvaluator))") verifyCases( Seq( (Coll[Int](), (-1, 0)) -> Expected(error) ), existingFeature({ (x: (Coll[Int], (Int, Int))) => throw error; x._1.slice(x._2._1, x._2._2) }, @@ -8818,7 +8818,7 @@ class SigmaDslSpecification extends SigmaDslTesting ) ))) } else { - def error = new java.lang.NoSuchMethodException("sigmastate.SCollection$.append_eval(sigmastate.lang.Terms$MethodCall,sigma.collection.Coll,sigma.collection.Coll,sigmastate.interpreter.ErgoTreeEvaluator))") + def error = new java.lang.NoSuchMethodException("sigmastate.SCollection$.append_eval(sigmastate.lang.Terms$MethodCall,sigma.Coll,sigma.Coll,sigmastate.interpreter.ErgoTreeEvaluator))") verifyCases( Seq( (Coll[Int](), Coll[Int]()) -> Expected(error) ), existingFeature( @@ -9948,7 +9948,7 @@ class SigmaDslSpecification extends SigmaDslTesting preGeneratedSamples = Some(Seq.empty) ) } else { - def error = new java.lang.NoSuchMethodException("sigmastate.SCollection$.fold_eval(sigmastate.lang.Terms$MethodCall,sigma.collection.Coll,java.lang.Object,scala.Function1,sigmastate.interpreter.ErgoTreeEvaluator))") + def error = new java.lang.NoSuchMethodException("sigmastate.SCollection$.fold_eval(sigmastate.lang.Terms$MethodCall,sigma.Coll,java.lang.Object,scala.Function1,sigmastate.interpreter.ErgoTreeEvaluator))") verifyCases( Seq( (keys, initial) -> Expected(error) ), existingFeature[(Coll[Coll[Byte]], Coll[Byte]), Coll[Byte]]( diff --git a/sc/shared/src/test/scala/special/sigma/SigmaDslStaginTests.scala b/sc/shared/src/test/scala/special/sigma/SigmaDslStaginTests.scala index 1c67410585..ea29c47745 100644 --- a/sc/shared/src/test/scala/special/sigma/SigmaDslStaginTests.scala +++ b/sc/shared/src/test/scala/special/sigma/SigmaDslStaginTests.scala @@ -2,7 +2,6 @@ package sigma import org.scalatest.BeforeAndAfterAll import scalan.{BaseCtxTests, BaseLiftableTests} -import sigma.collection._ import sigmastate.eval.Extensions._ import sigmastate.eval._ import sigmastate.{TrivialProp, eval} @@ -46,7 +45,7 @@ class SigmaDslStaginTests extends BaseCtxTests with ErgoScriptTestkit with BaseL cake.check(boxA1, { env: EnvRep[RBox] => for { obj <- env } yield obj.value }, boxA1.value) cake.check(boxA1, { env: EnvRep[RBox] => for { obj <- env } yield obj.creationInfo }, boxA1.creationInfo) - cake.check(boxA1, { env: EnvRep[RBox] => for { obj <- env; arg <- lifted(1) } yield obj.getReg[Coll[Byte]](arg) }, boxA1.getReg[sigma.collection.Coll[Byte]](1)) + cake.check(boxA1, { env: EnvRep[RBox] => for { obj <- env; arg <- lifted(1) } yield obj.getReg[Coll[Byte]](arg) }, boxA1.getReg[sigma.Coll[Byte]](1)) } diff --git a/sc/shared/src/test/scala/special/sigma/SigmaDslTesting.scala b/sc/shared/src/test/scala/special/sigma/SigmaDslTesting.scala index 66b0ec6558..16818c25ea 100644 --- a/sc/shared/src/test/scala/special/sigma/SigmaDslTesting.scala +++ b/sc/shared/src/test/scala/special/sigma/SigmaDslTesting.scala @@ -36,7 +36,7 @@ import sigmastate.serialization.generators.ObjectGenerators import sigmastate.utils.Helpers._ import sigmastate.utxo.{DeserializeContext, DeserializeRegister, GetVar, OptionGet} import sigmastate.{SOption, SSigmaProp, SType, SigmaLeaf, eval} -import sigma.collection.{Coll, CollType} +import sigma.{Coll, CollType} import java.util import scala.collection.mutable diff --git a/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Isos.scala b/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Isos.scala index f97edd0ab9..ff5e31d812 100644 --- a/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Isos.scala +++ b/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Isos.scala @@ -21,8 +21,8 @@ import sigmastate.fleetSdkCommon.{distEsmTypesBoxesMod => boxesMod, distEsmTypes import sigmastate.interpreter.{ContextExtension, ProverResult} import sigmastate.serialization.{ErgoTreeSerializer, ValueSerializer} import sigmastate.{AvlTreeData, AvlTreeFlags, SType} -import sigma.collection.Coll -import sigma.collection.Extensions.CollBytesOps +import sigma.Coll +import sigma.Extensions.CollBytesOps import sigma.GroupElement import java.math.BigInteger diff --git a/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Type.scala b/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Type.scala index 9565ce5b73..13ecc6cec5 100644 --- a/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Type.scala +++ b/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Type.scala @@ -73,6 +73,6 @@ object Type extends js.Object { * @param elemType type descriptor of collection elements */ def collType(elemType: Type): Type = { - new Type(sigma.collection.collRType(elemType.rtype)) + new Type(sigma.collRType(elemType.rtype)) } } \ No newline at end of file diff --git a/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Value.scala b/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Value.scala index 39fc89c058..4802c90c81 100644 --- a/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Value.scala +++ b/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Value.scala @@ -13,7 +13,7 @@ import sigmastate.fleetSdkCommon.distEsmTypesCommonMod import sigmastate.fleetSdkCommon.distEsmTypesRegistersMod.NonMandatoryRegisters import sigmastate.lang.DeserializationSigmaBuilder import sigmastate.serialization.{ConstantSerializer, DataSerializer, SigmaSerializer} -import sigma.collection.{Coll, CollType} +import sigma.{Coll, CollType} import java.math.BigInteger import scala.scalajs.js diff --git a/sdk/js/src/test/scala/org/ergoplatform/sdk/js/IsosSpec.scala b/sdk/js/src/test/scala/org/ergoplatform/sdk/js/IsosSpec.scala index 250d34b5cd..aaa7159758 100644 --- a/sdk/js/src/test/scala/org/ergoplatform/sdk/js/IsosSpec.scala +++ b/sdk/js/src/test/scala/org/ergoplatform/sdk/js/IsosSpec.scala @@ -13,7 +13,7 @@ import sigmastate.Values.Constant import sigmastate.eval.Colls import sigmastate.interpreter.{ContextExtension, ProverResult} import sigmastate.serialization.generators.ObjectGenerators -import sigma.collection.Coll +import sigma.Coll import sigma.GroupElement import scala.scalajs.js diff --git a/sdk/shared/src/main/scala/org/ergoplatform/sdk/BlockchainContext.scala b/sdk/shared/src/main/scala/org/ergoplatform/sdk/BlockchainContext.scala index 317fda331c..1d87f197e8 100644 --- a/sdk/shared/src/main/scala/org/ergoplatform/sdk/BlockchainContext.scala +++ b/sdk/shared/src/main/scala/org/ergoplatform/sdk/BlockchainContext.scala @@ -1,7 +1,7 @@ package org.ergoplatform.sdk import org.ergoplatform.sdk.wallet.protocol.context.BlockchainStateContext -import sigma.collection.Coll +import sigma.Coll import sigma.Header /** Represents a specific context of blockchain for execution diff --git a/sdk/shared/src/main/scala/org/ergoplatform/sdk/DataJsonEncoder.scala b/sdk/shared/src/main/scala/org/ergoplatform/sdk/DataJsonEncoder.scala index fd49f1b3d9..822351072f 100644 --- a/sdk/shared/src/main/scala/org/ergoplatform/sdk/DataJsonEncoder.scala +++ b/sdk/shared/src/main/scala/org/ergoplatform/sdk/DataJsonEncoder.scala @@ -12,7 +12,6 @@ import sigmastate.Values.{Constant, EvaluatedValue} import sigmastate._ import sigmastate.lang.SigmaParser import sigmastate.eval._ -import sigma.collection.Coll import sigma._ import debox.cfor import sigmastate.exceptions.SerializerException diff --git a/sdk/shared/src/main/scala/org/ergoplatform/sdk/Extensions.scala b/sdk/shared/src/main/scala/org/ergoplatform/sdk/Extensions.scala index 6744bf746e..5618f3e8f2 100644 --- a/sdk/shared/src/main/scala/org/ergoplatform/sdk/Extensions.scala +++ b/sdk/shared/src/main/scala/org/ergoplatform/sdk/Extensions.scala @@ -4,7 +4,7 @@ import debox.cfor import scalan.RType import scalan.rtypeToClassTag // actually used import sigmastate.eval.CPreHeader -import sigma.collection.{Coll, CollBuilder, PairColl} +import sigma.{Coll, CollBuilder, PairColl} import sigma.{Header, PreHeader} import scala.collection.compat.BuildFrom diff --git a/sdk/shared/src/main/scala/org/ergoplatform/sdk/JavaHelpers.scala b/sdk/shared/src/main/scala/org/ergoplatform/sdk/JavaHelpers.scala index 5e516256c3..884e987376 100644 --- a/sdk/shared/src/main/scala/org/ergoplatform/sdk/JavaHelpers.scala +++ b/sdk/shared/src/main/scala/org/ergoplatform/sdk/JavaHelpers.scala @@ -1,7 +1,7 @@ package org.ergoplatform.sdk import scalan.RType -import sigma.collection.Coll +import sigma.Coll import scala.collection.{JavaConverters, mutable} import org.ergoplatform._ @@ -359,7 +359,7 @@ object JavaHelpers { DataInput(ADKey @@ boxIdBytes) } - def collRType[T](tItem: RType[T]): RType[Coll[T]] = sigma.collection.collRType(tItem) + def collRType[T](tItem: RType[T]): RType[Coll[T]] = sigma.collRType(tItem) def BigIntRType: RType[sigma.BigInt] = sigma.BigIntRType @@ -409,7 +409,7 @@ object JavaHelpers { * @return a mapping from asset id to to balance and total assets number */ def extractAssets(boxes: IndexedSeq[ErgoBoxCandidate]): (Map[Digest32Coll, Long], Int) = { - import sigma.collection.Extensions.CollOps + import sigma.Extensions.CollOps val map = mutable.Map[Digest32Coll, Long]() val assetsNum = boxes.foldLeft(0) { case (acc, box) => require(box.additionalTokens.length <= SigmaConstants.MaxTokens.value, "too many assets in one box") diff --git a/sdk/shared/src/main/scala/org/ergoplatform/sdk/JsonCodecs.scala b/sdk/shared/src/main/scala/org/ergoplatform/sdk/JsonCodecs.scala index 604a8ac081..905983d7a2 100644 --- a/sdk/shared/src/main/scala/org/ergoplatform/sdk/JsonCodecs.scala +++ b/sdk/shared/src/main/scala/org/ergoplatform/sdk/JsonCodecs.scala @@ -16,7 +16,7 @@ import sigmastate.eval.{CPreHeader, WrapperOf, _} import sigmastate.exceptions.SigmaException import sigmastate.interpreter.{ContextExtension, ProverResult} import sigmastate.{AvlTreeData, AvlTreeFlags, SType} -import sigma.collection.Coll +import sigma.Coll import sigma.{AnyValue, Header, PreHeader} import scala.util.Try diff --git a/sdk/shared/src/main/scala/org/ergoplatform/sdk/UnsignedTransactionBuilder.scala b/sdk/shared/src/main/scala/org/ergoplatform/sdk/UnsignedTransactionBuilder.scala index 6030bf2aa9..dab4a73efd 100644 --- a/sdk/shared/src/main/scala/org/ergoplatform/sdk/UnsignedTransactionBuilder.scala +++ b/sdk/shared/src/main/scala/org/ergoplatform/sdk/UnsignedTransactionBuilder.scala @@ -9,8 +9,8 @@ import org.ergoplatform.sdk.wallet.{AssetUtils, TokensMap} import scorex.util.{ModifierId, bytesToId} import sigmastate.eval.Extensions.ArrayOps import sigmastate.utils.Extensions.ModifierIdOps -import sigma.collection.Coll -import sigma.collection.Extensions.CollBytesOps +import sigma.Coll +import sigma.Extensions.CollBytesOps import sigma.PreHeader import scala.collection.mutable.ArrayBuffer diff --git a/sdk/shared/src/main/scala/org/ergoplatform/sdk/utils/Zero.scala b/sdk/shared/src/main/scala/org/ergoplatform/sdk/utils/Zero.scala index e2b57100cc..eab06627f3 100644 --- a/sdk/shared/src/main/scala/org/ergoplatform/sdk/utils/Zero.scala +++ b/sdk/shared/src/main/scala/org/ergoplatform/sdk/utils/Zero.scala @@ -11,7 +11,7 @@ import sigmastate.basics.CryptoConstants import sigmastate.eval._ import sigmastate.{AvlTreeData, AvlTreeFlags, TrivialProp} import sigma.Types.TupleType -import sigma.collection.{Coll, CollType} +import sigma.{Coll, CollType} import sigma.{AvlTree, AvlTreeRType, BigInt, BigIntRType, Box, BoxRType, GroupElement, GroupElementRType, SigmaProp, SigmaPropRType} import java.math.BigInteger diff --git a/sdk/shared/src/main/scala/org/ergoplatform/sdk/wallet/protocol/context/BlockchainStateContext.scala b/sdk/shared/src/main/scala/org/ergoplatform/sdk/wallet/protocol/context/BlockchainStateContext.scala index 41ba7ee8d1..172c24fc0f 100644 --- a/sdk/shared/src/main/scala/org/ergoplatform/sdk/wallet/protocol/context/BlockchainStateContext.scala +++ b/sdk/shared/src/main/scala/org/ergoplatform/sdk/wallet/protocol/context/BlockchainStateContext.scala @@ -1,6 +1,6 @@ package org.ergoplatform.sdk.wallet.protocol.context -import sigma.collection.Coll +import sigma.Coll /** Blockchain context used in tx signing. * diff --git a/sdk/shared/src/test/scala/org/ergoplatform/sdk/ExtensionsSpec.scala b/sdk/shared/src/test/scala/org/ergoplatform/sdk/ExtensionsSpec.scala index 97fe775e73..427f83d049 100644 --- a/sdk/shared/src/test/scala/org/ergoplatform/sdk/ExtensionsSpec.scala +++ b/sdk/shared/src/test/scala/org/ergoplatform/sdk/ExtensionsSpec.scala @@ -3,10 +3,10 @@ package org.ergoplatform.sdk import org.scalatest.matchers.should.Matchers import org.scalatest.propspec.AnyPropSpec import org.scalatestplus.scalacheck.ScalaCheckPropertyChecks -import sigma.collection.Coll +import sigma.Coll import org.ergoplatform.sdk.Extensions.{CollBuilderOps, CollOps, GenIterableOps, PairCollOps} import scalan.RType -import sigma.collections.CollGens +import sigma.CollGens import sigmastate.eval.CostingSigmaDslBuilder class ExtensionsSpec extends AnyPropSpec with ScalaCheckPropertyChecks with Matchers with CollGens { diff --git a/sdk/shared/src/test/scala/org/ergoplatform/sdk/JsonSerializationSpec.scala b/sdk/shared/src/test/scala/org/ergoplatform/sdk/JsonSerializationSpec.scala index a764b6e7de..353134a076 100644 --- a/sdk/shared/src/test/scala/org/ergoplatform/sdk/JsonSerializationSpec.scala +++ b/sdk/shared/src/test/scala/org/ergoplatform/sdk/JsonSerializationSpec.scala @@ -17,7 +17,7 @@ import sigmastate.eval.Digest32Coll import sigmastate.interpreter.{ContextExtension, ProverResult} import sigmastate.serialization.SerializationSpecification import sigmastate.utils.Helpers.DecoderResultOps // required for Scala 2.11 (extension method toTry) -import sigma.collection.Coll +import sigma.Coll import sigma.{Header, PreHeader} import org.ergoplatform.{DataInput, ErgoBox, ErgoBoxCandidate, ErgoLikeContext, ErgoLikeTransaction, ErgoLikeTransactionTemplate, Input, UnsignedErgoLikeTransaction, UnsignedInput} From 8ed3f81e695af5d3a8e3ad41ecf3c8ed1ac41947 Mon Sep 17 00:00:00 2001 From: Alexander Slesarenko Date: Tue, 22 Aug 2023 18:45:10 +0200 Subject: [PATCH 08/37] minimize-modules: use fully qualified java.util. --- .../scala/scalan/util/CollectionUtil.scala | 20 +++++++++---------- .../main/scala/sigma/CollsOverArrays.scala | 4 +--- .../org/ergoplatform/ErgoBoxCandidate.scala | 2 +- .../main/scala/org/ergoplatform/Input.scala | 4 ++-- .../ergoplatform/validation/RuleStatus.scala | 4 ++-- .../scala/sigmastate/crypto/GF2_192.scala | 2 +- .../sigmastate/crypto/GF2_192_Poly.scala | 4 ++-- .../sigmastate/interpreter/Interpreter.scala | 2 +- .../sigmastate/interpreter/ProverResult.scala | 4 ++-- .../serialization/ErgoTreeSerializer.scala | 2 +- .../main/scala/sigmastate/utils/Helpers.scala | 20 +++++++++---------- .../scala/special/sigma/SigmaDslTesting.scala | 2 +- .../scala/org/ergoplatform/sdk/ErgoId.scala | 4 ++-- .../org/ergoplatform/sdk/SecretString.scala | 4 ++-- .../org/ergoplatform/sdk/Transactions.scala | 2 +- .../wallet/secrets/ExtendedPublicKey.scala | 8 ++++---- .../wallet/secrets/ExtendedSecretKey.scala | 10 +++++----- 17 files changed, 47 insertions(+), 51 deletions(-) diff --git a/common/shared/src/main/scala/scalan/util/CollectionUtil.scala b/common/shared/src/main/scala/scalan/util/CollectionUtil.scala index 0ee4030e2c..2eefc8b956 100644 --- a/common/shared/src/main/scala/scalan/util/CollectionUtil.scala +++ b/common/shared/src/main/scala/scalan/util/CollectionUtil.scala @@ -1,7 +1,5 @@ package scalan.util -import java.util - import scala.collection.{Seq, mutable, GenIterable} import scala.collection.mutable.{HashMap, ArrayBuffer} import scala.reflect.ClassTag @@ -52,15 +50,15 @@ object CollectionUtil { * @param arr the input array for which the deep hash code is to be calculated */ def deepHashCode[T](arr: Array[T]): Int = arr match { - case arr: Array[AnyRef] => util.Arrays.deepHashCode(arr) - case arr: Array[Byte] => util.Arrays.hashCode(arr) - case arr: Array[Short] => util.Arrays.hashCode(arr) - case arr: Array[Int] => util.Arrays.hashCode(arr) - case arr: Array[Long] => util.Arrays.hashCode(arr) - case arr: Array[Char] => util.Arrays.hashCode(arr) - case arr: Array[Float] => util.Arrays.hashCode(arr) - case arr: Array[Double] => util.Arrays.hashCode(arr) - case arr: Array[Boolean] => util.Arrays.hashCode(arr) + case arr: Array[AnyRef] => java.util.Arrays.deepHashCode(arr) + case arr: Array[Byte] => java.util.Arrays.hashCode(arr) + case arr: Array[Short] => java.util.Arrays.hashCode(arr) + case arr: Array[Int] => java.util.Arrays.hashCode(arr) + case arr: Array[Long] => java.util.Arrays.hashCode(arr) + case arr: Array[Char] => java.util.Arrays.hashCode(arr) + case arr: Array[Float] => java.util.Arrays.hashCode(arr) + case arr: Array[Double] => java.util.Arrays.hashCode(arr) + case arr: Array[Boolean] => java.util.Arrays.hashCode(arr) } /** Group the given sequence of pairs by first values as keys. diff --git a/common/shared/src/main/scala/sigma/CollsOverArrays.scala b/common/shared/src/main/scala/sigma/CollsOverArrays.scala index 9a756f3370..9e8b0f810d 100644 --- a/common/shared/src/main/scala/sigma/CollsOverArrays.scala +++ b/common/shared/src/main/scala/sigma/CollsOverArrays.scala @@ -1,6 +1,5 @@ package sigma -import java.util import scalan._ // required import scalan.util.CollectionUtil import scalan.RType @@ -8,7 +7,6 @@ import debox.Buffer import scalan.RType._ import sigma.util.{MaxArrayLength, safeConcatArrays_v5} import debox.cfor -import sigma.VersionContext class CollOverArray[@specialized A](val toArray: Array[A], val builder: CollBuilder) (implicit tA: RType[A]) extends Coll[A] { @@ -398,7 +396,7 @@ class PairOfCols[@specialized L, @specialized R](val ls: Coll[L], val rs: Coll[R } override def unionSet(that: Coll[(L, R)]): Coll[(L, R)] = { - val set = new util.HashSet[(L,R)](32) + val set = new java.util.HashSet[(L,R)](32) implicit val ctL = ls.tItem.classTag implicit val ctR = rs.tItem.classTag val resL = Buffer.empty[L] diff --git a/interpreter/shared/src/main/scala/org/ergoplatform/ErgoBoxCandidate.scala b/interpreter/shared/src/main/scala/org/ergoplatform/ErgoBoxCandidate.scala index e10f7907e1..13ae47b2e2 100644 --- a/interpreter/shared/src/main/scala/org/ergoplatform/ErgoBoxCandidate.scala +++ b/interpreter/shared/src/main/scala/org/ergoplatform/ErgoBoxCandidate.scala @@ -85,7 +85,7 @@ class ErgoBoxCandidate(val value: Long, override def equals(arg: Any): Boolean = { arg match { - case x: ErgoBoxCandidate => util.Arrays.equals(bytesWithNoRef, x.bytesWithNoRef) + case x: ErgoBoxCandidate => java.util.Arrays.equals(bytesWithNoRef, x.bytesWithNoRef) case _ => false } } diff --git a/interpreter/shared/src/main/scala/org/ergoplatform/Input.scala b/interpreter/shared/src/main/scala/org/ergoplatform/Input.scala index d8bd8c6d1d..e0b4830797 100644 --- a/interpreter/shared/src/main/scala/org/ergoplatform/Input.scala +++ b/interpreter/shared/src/main/scala/org/ergoplatform/Input.scala @@ -18,7 +18,7 @@ case class DataInput(boxId: BoxId) { override def toString: String = s"DataInput(${ErgoAlgos.encode(boxId)})" override def equals(obj: Any): Boolean = obj match { - case x: DataInput => util.Arrays.equals(boxId, x.boxId) + case x: DataInput => java.util.Arrays.equals(boxId, x.boxId) case _ => false } @@ -39,7 +39,7 @@ class UnsignedInput(val boxId: BoxId, val extension: ContextExtension) { // todo check whether it is correct to compare inputs (Input use the same equals) by boxId only? override def equals(obj: Any): Boolean = obj match { - case x: UnsignedInput => util.Arrays.equals(boxId, x.boxId) + case x: UnsignedInput => java.util.Arrays.equals(boxId, x.boxId) case _ => false } diff --git a/interpreter/shared/src/main/scala/org/ergoplatform/validation/RuleStatus.scala b/interpreter/shared/src/main/scala/org/ergoplatform/validation/RuleStatus.scala index f40a916701..789016abfb 100644 --- a/interpreter/shared/src/main/scala/org/ergoplatform/validation/RuleStatus.scala +++ b/interpreter/shared/src/main/scala/org/ergoplatform/validation/RuleStatus.scala @@ -45,11 +45,11 @@ case class ReplacedRule(newRuleId: Short) extends RuleStatus { case class ChangedRule(newValue: Array[Byte]) extends RuleStatus { val statusCode: Byte = RuleStatus.ChangedRuleCode - override def hashCode(): Int = util.Arrays.hashCode(newValue) + override def hashCode(): Int = java.util.Arrays.hashCode(newValue) override def canEqual(that: Any): Boolean = that.isInstanceOf[ChangedRule] override def equals(obj: Any): Boolean = (this eq obj.asInstanceOf[AnyRef]) || (obj match { - case that: ChangedRule => util.Arrays.equals(newValue, that.newValue) + case that: ChangedRule => java.util.Arrays.equals(newValue, that.newValue) }) } diff --git a/interpreter/shared/src/main/scala/sigmastate/crypto/GF2_192.scala b/interpreter/shared/src/main/scala/sigmastate/crypto/GF2_192.scala index 36e8343e2b..bb0ad60a84 100644 --- a/interpreter/shared/src/main/scala/sigmastate/crypto/GF2_192.scala +++ b/interpreter/shared/src/main/scala/sigmastate/crypto/GF2_192.scala @@ -113,7 +113,7 @@ class GF2_192 extends AnyRef { } } - override def hashCode = util.Arrays.hashCode(word) + override def hashCode = java.util.Arrays.hashCode(word) /** * diff --git a/interpreter/shared/src/main/scala/sigmastate/crypto/GF2_192_Poly.scala b/interpreter/shared/src/main/scala/sigmastate/crypto/GF2_192_Poly.scala index 344305a157..a9212fe565 100644 --- a/interpreter/shared/src/main/scala/sigmastate/crypto/GF2_192_Poly.scala +++ b/interpreter/shared/src/main/scala/sigmastate/crypto/GF2_192_Poly.scala @@ -164,14 +164,14 @@ class GF2_192_Poly { def coeff0Bytes: Array[Byte] = c(0).toByteArray override def hashCode: Int = { - 31 * util.Arrays.deepHashCode(c.asInstanceOf[Array[AnyRef]]) + deg + 31 * java.util.Arrays.deepHashCode(c.asInstanceOf[Array[AnyRef]]) + deg } override def equals(obj: Any): Boolean = { if (this eq obj.asInstanceOf[AnyRef]) return true obj match { case that: GF2_192_Poly => - util.Arrays.deepEquals(c.asInstanceOf[Array[AnyRef]], that.c.asInstanceOf[Array[AnyRef]]) && + java.util.Arrays.deepEquals(c.asInstanceOf[Array[AnyRef]], that.c.asInstanceOf[Array[AnyRef]]) && deg == that.deg case _ => false } diff --git a/interpreter/shared/src/main/scala/sigmastate/interpreter/Interpreter.scala b/interpreter/shared/src/main/scala/sigmastate/interpreter/Interpreter.scala index 45db609448..6a0142a119 100644 --- a/interpreter/shared/src/main/scala/sigmastate/interpreter/Interpreter.scala +++ b/interpreter/shared/src/main/scala/sigmastate/interpreter/Interpreter.scala @@ -385,7 +385,7 @@ trait Interpreter { * (and, if applicable, the associated data). Reject otherwise. */ val expectedChallenge = CryptoFunctions.hashFn(bytes) - util.Arrays.equals(newRoot.challenge.toArray, expectedChallenge) + java.util.Arrays.equals(newRoot.challenge.toArray, expectedChallenge) } /** diff --git a/interpreter/shared/src/main/scala/sigmastate/interpreter/ProverResult.scala b/interpreter/shared/src/main/scala/sigmastate/interpreter/ProverResult.scala index a6824a1570..45d6159d8c 100644 --- a/interpreter/shared/src/main/scala/sigmastate/interpreter/ProverResult.scala +++ b/interpreter/shared/src/main/scala/sigmastate/interpreter/ProverResult.scala @@ -13,12 +13,12 @@ import sigmastate.utils.{SigmaByteReader, SigmaByteWriter} * @param extension - user-defined variables to be put into context */ class ProverResult(val proof: Array[Byte], val extension: ContextExtension) { - override def hashCode(): Int = util.Arrays.hashCode(proof) * 31 + extension.hashCode() + override def hashCode(): Int = java.util.Arrays.hashCode(proof) * 31 + extension.hashCode() override def equals(obj: scala.Any): Boolean = (this eq obj.asInstanceOf[AnyRef]) || (obj match { case obj: ProverResult => - util.Arrays.equals(proof, obj.proof) && extension == obj.extension + java.util.Arrays.equals(proof, obj.proof) && extension == obj.extension case _ => false }) diff --git a/interpreter/shared/src/main/scala/sigmastate/serialization/ErgoTreeSerializer.scala b/interpreter/shared/src/main/scala/sigmastate/serialization/ErgoTreeSerializer.scala index 735b5f0595..f8c5221945 100644 --- a/interpreter/shared/src/main/scala/sigmastate/serialization/ErgoTreeSerializer.scala +++ b/interpreter/shared/src/main/scala/sigmastate/serialization/ErgoTreeSerializer.scala @@ -275,7 +275,7 @@ class ErgoTreeSerializer { // allocate array of back references: forall i: positionsBackref(i) is index in `positions` val positionsBackref = safeNewArray[Int](positionsRange) // mark all positions are not assigned - util.Arrays.fill(positionsBackref, -1) + java.util.Arrays.fill(positionsBackref, -1) cfor(0)(_ < positions.length, _ + 1) { iPos => val pos = positions(iPos) diff --git a/interpreter/shared/src/main/scala/sigmastate/utils/Helpers.scala b/interpreter/shared/src/main/scala/sigmastate/utils/Helpers.scala index 07f9f8dd30..f1c72a0475 100644 --- a/interpreter/shared/src/main/scala/sigmastate/utils/Helpers.scala +++ b/interpreter/shared/src/main/scala/sigmastate/utils/Helpers.scala @@ -80,15 +80,15 @@ object Helpers { } def deepHashCode[T](arr: Array[T]): Int = arr match { - case arr: Array[AnyRef] => util.Arrays.deepHashCode(arr) - case arr: Array[Byte] => util.Arrays.hashCode(arr) - case arr: Array[Short] => util.Arrays.hashCode(arr) - case arr: Array[Int] => util.Arrays.hashCode(arr) - case arr: Array[Long] => util.Arrays.hashCode(arr) - case arr: Array[Char] => util.Arrays.hashCode(arr) - case arr: Array[Float] => util.Arrays.hashCode(arr) - case arr: Array[Double] => util.Arrays.hashCode(arr) - case arr: Array[Boolean] => util.Arrays.hashCode(arr) + case arr: Array[AnyRef] => java.util.Arrays.deepHashCode(arr) + case arr: Array[Byte] => java.util.Arrays.hashCode(arr) + case arr: Array[Short] => java.util.Arrays.hashCode(arr) + case arr: Array[Int] => java.util.Arrays.hashCode(arr) + case arr: Array[Long] => java.util.Arrays.hashCode(arr) + case arr: Array[Char] => java.util.Arrays.hashCode(arr) + case arr: Array[Float] => java.util.Arrays.hashCode(arr) + case arr: Array[Double] => java.util.Arrays.hashCode(arr) + case arr: Array[Boolean] => java.util.Arrays.hashCode(arr) } /** Optimized hashCode for array of bytes when it represents some hash thus it have @@ -97,7 +97,7 @@ object Helpers { */ @inline final def safeIdHashCode(id: Array[Byte]): Int = if (id != null && id.length >= 4) Ints.fromBytes(id(0), id(1), id(2), id(3)) - else util.Arrays.hashCode(id) + else java.util.Arrays.hashCode(id) implicit class TryOps[+A](val source: Try[A]) extends AnyVal { def fold[B](onError: Throwable => B, onSuccess: A => B) = source match { diff --git a/sc/shared/src/test/scala/special/sigma/SigmaDslTesting.scala b/sc/shared/src/test/scala/special/sigma/SigmaDslTesting.scala index 16818c25ea..81ec1ced50 100644 --- a/sc/shared/src/test/scala/special/sigma/SigmaDslTesting.scala +++ b/sc/shared/src/test/scala/special/sigma/SigmaDslTesting.scala @@ -275,7 +275,7 @@ class SigmaDslTesting extends AnyPropSpec val txOutputCandidates = ctx.outputs.toArray.map(SigmaDsl.toErgoBox) val tx = new ErgoLikeTransaction( txInputs, txDataInputs, txOutputCandidates.toIndexedSeq) - val selfIndex = boxesToSpend.indexWhere(b => util.Arrays.equals(b.id, ctx.selfBox.id.toArray)) + val selfIndex = boxesToSpend.indexWhere(b => java.util.Arrays.equals(b.id, ctx.selfBox.id.toArray)) val extension = ContextExtension( values = ctx.vars.toArray.zipWithIndex.collect { diff --git a/sdk/shared/src/main/scala/org/ergoplatform/sdk/ErgoId.scala b/sdk/shared/src/main/scala/org/ergoplatform/sdk/ErgoId.scala index 088b16fe77..7d56b05295 100644 --- a/sdk/shared/src/main/scala/org/ergoplatform/sdk/ErgoId.scala +++ b/sdk/shared/src/main/scala/org/ergoplatform/sdk/ErgoId.scala @@ -19,14 +19,14 @@ class ErgoId(val _idBytes: Array[Byte]) { override def hashCode = if (_idBytes != null && _idBytes.length >= 4) Ints.fromByteArray(_idBytes) - else util.Arrays.hashCode(_idBytes) + else java.util.Arrays.hashCode(_idBytes) override def equals(obj: Any): Boolean = { if (obj == null) return false if (this eq obj.asInstanceOf[AnyRef]) return true obj match { case that: ErgoId => - util.Arrays.equals(this._idBytes, that._idBytes) + java.util.Arrays.equals(this._idBytes, that._idBytes) case _ => false } } diff --git a/sdk/shared/src/main/scala/org/ergoplatform/sdk/SecretString.scala b/sdk/shared/src/main/scala/org/ergoplatform/sdk/SecretString.scala index 4cf8e8b2c3..83ff2e0a10 100644 --- a/sdk/shared/src/main/scala/org/ergoplatform/sdk/SecretString.scala +++ b/sdk/shared/src/main/scala/org/ergoplatform/sdk/SecretString.scala @@ -67,13 +67,13 @@ final class SecretString private[sdk](val _data: Array[Char]) { * Erases secret characters stored in this instance so that they are no longer reside in memory. */ def erase(): Unit = { - util.Arrays.fill(_data, ' ') + java.util.Arrays.fill(_data, ' ') _erased = true } override def hashCode(): Int = { checkErased() - util.Arrays.hashCode(_data) + java.util.Arrays.hashCode(_data) } /** this is adapted version of java.lang.String */ diff --git a/sdk/shared/src/main/scala/org/ergoplatform/sdk/Transactions.scala b/sdk/shared/src/main/scala/org/ergoplatform/sdk/Transactions.scala index 275814a983..8848e73c42 100644 --- a/sdk/shared/src/main/scala/org/ergoplatform/sdk/Transactions.scala +++ b/sdk/shared/src/main/scala/org/ergoplatform/sdk/Transactions.scala @@ -36,7 +36,7 @@ case class UnreducedTransaction( private def checkSameIds( xsName: String, xs: Seq[Array[Byte]], ysName: String, ys: Seq[Array[Byte]], msg: => String) = { - require(xs.zip(ys).forall { case (id1, id2) => util.Arrays.equals(id1, id2) }, { + require(xs.zip(ys).forall { case (id1, id2) => java.util.Arrays.equals(id1, id2) }, { val xsOnly = xs.diff(ys) val ysOnly = ys.diff(xs) s"""$msg: diff --git a/sdk/shared/src/main/scala/org/ergoplatform/sdk/wallet/secrets/ExtendedPublicKey.scala b/sdk/shared/src/main/scala/org/ergoplatform/sdk/wallet/secrets/ExtendedPublicKey.scala index cdc7458b75..10536b20b0 100644 --- a/sdk/shared/src/main/scala/org/ergoplatform/sdk/wallet/secrets/ExtendedPublicKey.scala +++ b/sdk/shared/src/main/scala/org/ergoplatform/sdk/wallet/secrets/ExtendedPublicKey.scala @@ -29,15 +29,15 @@ final class ExtendedPublicKey(/*private[secrets] */val keyBytes: Array[Byte], override def equals(obj: Any): Boolean = (this eq obj.asInstanceOf[AnyRef]) || (obj match { case that: ExtendedPublicKey => - util.Arrays.equals(that.keyBytes, this.keyBytes) && - util.Arrays.equals(that.chainCode, this.chainCode) && + java.util.Arrays.equals(that.keyBytes, this.keyBytes) && + java.util.Arrays.equals(that.chainCode, this.chainCode) && that.path == this.path case _ => false }) override def hashCode(): Int = { - var h = util.Arrays.hashCode(keyBytes) - h = 31 * h + util.Arrays.hashCode(chainCode) + var h = java.util.Arrays.hashCode(keyBytes) + h = 31 * h + java.util.Arrays.hashCode(chainCode) h = 31 * h + path.hashCode() h } diff --git a/sdk/shared/src/main/scala/org/ergoplatform/sdk/wallet/secrets/ExtendedSecretKey.scala b/sdk/shared/src/main/scala/org/ergoplatform/sdk/wallet/secrets/ExtendedSecretKey.scala index 2842658e66..96802217df 100644 --- a/sdk/shared/src/main/scala/org/ergoplatform/sdk/wallet/secrets/ExtendedSecretKey.scala +++ b/sdk/shared/src/main/scala/org/ergoplatform/sdk/wallet/secrets/ExtendedSecretKey.scala @@ -34,19 +34,19 @@ final class ExtendedSecretKey(/*private[secrets]*/ val keyBytes: Array[Byte], def isErased: Boolean = keyBytes.forall(_ == 0x00) - def zeroSecret(): Unit = util.Arrays.fill(keyBytes, 0: Byte) + def zeroSecret(): Unit = java.util.Arrays.fill(keyBytes, 0: Byte) override def equals(obj: Any): Boolean = (this eq obj.asInstanceOf[AnyRef]) || (obj match { case that: ExtendedSecretKey => - util.Arrays.equals(that.keyBytes, this.keyBytes) && - util.Arrays.equals(that.chainCode, this.chainCode) && + java.util.Arrays.equals(that.keyBytes, this.keyBytes) && + java.util.Arrays.equals(that.chainCode, this.chainCode) && that.path == this.path case _ => false }) override def hashCode(): Int = { - var h = util.Arrays.hashCode(keyBytes) - h = 31 * h + util.Arrays.hashCode(chainCode) + var h = java.util.Arrays.hashCode(keyBytes) + h = 31 * h + java.util.Arrays.hashCode(chainCode) h = 31 * h + path.hashCode() h } From 55f1c1b2c248884ef3d013debe09880e2aa2df02 Mon Sep 17 00:00:00 2001 From: Alexander Slesarenko Date: Tue, 22 Aug 2023 21:50:17 +0200 Subject: [PATCH 09/37] minimize-modules: TupleType moved to separate file --- .../src/main/scala/sigma/TupleType.scala | 24 +++++++++++++ .../shared/src/main/scala/sigma/Types.scala | 34 ------------------- .../shared/src/main/scala/sigma/package.scala | 12 ++++++- .../src/test/scala/sigma/TypesTests.scala | 1 - .../scala/sigmastate/eval/Evaluation.scala | 1 - .../src/main/scala/scalan/TypeDescs.scala | 6 ++-- .../scala/special/wrappers}/WrapSpec.scala | 2 +- .../scala/special/wrappers/WrappersSpec.scala | 2 +- .../org/ergoplatform/sdk/utils/Zero.scala | 4 +-- 9 files changed, 42 insertions(+), 44 deletions(-) create mode 100644 common/shared/src/main/scala/sigma/TupleType.scala delete mode 100644 common/shared/src/main/scala/sigma/Types.scala rename {common/shared/src/main/scala/scalan => sc/shared/src/main/scala/special/wrappers}/WrapSpec.scala (82%) diff --git a/common/shared/src/main/scala/sigma/TupleType.scala b/common/shared/src/main/scala/sigma/TupleType.scala new file mode 100644 index 0000000000..0703e725f7 --- /dev/null +++ b/common/shared/src/main/scala/sigma/TupleType.scala @@ -0,0 +1,24 @@ +package sigma + +import scalan.RType +import scalan.RType.SomeType +import scalan.util.CollectionUtil + +import scala.reflect.ClassTag + +/** Descriptor (in RType family) of tuple types. + * + * @param items types of tuple items + */ +case class TupleType(items: Array[SomeType]) extends RType[TupleData] { + override val classTag: ClassTag[TupleData] = scala.reflect.classTag[TupleData] + + override def name: String = items.map(_.name).mkString("(", ", ", ")") + + override def hashCode(): Int = CollectionUtil.deepHashCode(items) + + override def equals(obj: Any): Boolean = (this eq obj.asInstanceOf[AnyRef]) || (obj match { + case that: TupleType => java.util.Arrays.equals(items.asInstanceOf[Array[AnyRef]], that.items.asInstanceOf[Array[AnyRef]]) + case _ => false + }) +} diff --git a/common/shared/src/main/scala/sigma/Types.scala b/common/shared/src/main/scala/sigma/Types.scala deleted file mode 100644 index 5f10d5bda0..0000000000 --- a/common/shared/src/main/scala/sigma/Types.scala +++ /dev/null @@ -1,34 +0,0 @@ -package sigma - -import scalan.RType -import scalan.RType.SomeType -import scalan.util.CollectionUtil - -import scala.reflect.ClassTag - -object Types { - /** Generic representation of tuples values. */ - type TupleData = Coll[Any] - - /** Returns an RType object representing a tuple type with the given SomeType array types. - * @param types An array of SomeType representing the types of each item in the tuple. - * @return An RType object for the tuple type. - */ - def tupleRType(types: Array[SomeType]): RType[TupleData] = TupleType(types) - - /** Descriptor (in RType family) of tuple types. - * @param items types of tuple items - */ - case class TupleType(items: Array[SomeType]) extends RType[TupleData] { - override val classTag: ClassTag[TupleData] = scala.reflect.classTag[TupleData] - - override def name: String = items.map(_.name).mkString("(", ", ", ")") - - override def hashCode(): Int = CollectionUtil.deepHashCode(items) - - override def equals(obj: Any): Boolean = (this eq obj.asInstanceOf[AnyRef]) || (obj match { - case that: TupleType => java.util.Arrays.equals(items.asInstanceOf[Array[AnyRef]], that.items.asInstanceOf[Array[AnyRef]]) - case _ => false - }) - } -} diff --git a/common/shared/src/main/scala/sigma/package.scala b/common/shared/src/main/scala/sigma/package.scala index c09ec6eea6..840a4edf72 100644 --- a/common/shared/src/main/scala/sigma/package.scala +++ b/common/shared/src/main/scala/sigma/package.scala @@ -1,7 +1,7 @@ import java.math.BigInteger import scalan.RType -import scalan.RType.GeneralType +import scalan.RType.{GeneralType, SomeType} import scala.reflect.classTag @@ -41,4 +41,14 @@ package object sigma { def requireSameLength[A, B](xs: Coll[A], ys: Coll[B]) = { require(xs.length == ys.length, sameLengthErrorMsg(xs, ys)) } + + /** Generic representation of tuples values. */ + type TupleData = Coll[Any] + + /** Returns an RType object representing a tuple type with the given SomeType array types. + * + * @param types An array of SomeType representing the types of each item in the tuple. + * @return An RType object for the tuple type. + */ + def tupleRType(types: Array[SomeType]): RType[TupleData] = TupleType(types) } \ No newline at end of file diff --git a/common/shared/src/test/scala/sigma/TypesTests.scala b/common/shared/src/test/scala/sigma/TypesTests.scala index 3601db8659..4301d6e22f 100644 --- a/common/shared/src/test/scala/sigma/TypesTests.scala +++ b/common/shared/src/test/scala/sigma/TypesTests.scala @@ -2,7 +2,6 @@ package sigma import scalan.RType._ import scalan.{BaseTests, RType} -import sigma.Types._ class TypesTests extends BaseTests { diff --git a/interpreter/shared/src/main/scala/sigmastate/eval/Evaluation.scala b/interpreter/shared/src/main/scala/sigmastate/eval/Evaluation.scala index ddb7b205ac..c47be16605 100644 --- a/interpreter/shared/src/main/scala/sigmastate/eval/Evaluation.scala +++ b/interpreter/shared/src/main/scala/sigmastate/eval/Evaluation.scala @@ -6,7 +6,6 @@ import scalan.RType._ import sigmastate.SType._ import sigmastate.Values.SigmaBoolean import sigmastate._ -import sigma.Types._ import debox.cfor import sigmastate.exceptions.CostLimitException import java.math.BigInteger diff --git a/sc/shared/src/main/scala/scalan/TypeDescs.scala b/sc/shared/src/main/scala/scalan/TypeDescs.scala index 57fc2a1a52..f0a190a113 100644 --- a/sc/shared/src/main/scala/scalan/TypeDescs.scala +++ b/sc/shared/src/main/scala/scalan/TypeDescs.scala @@ -1,13 +1,15 @@ package scalan -import scala.language.{implicitConversions} +import scala.language.implicitConversions import scala.annotation.implicitNotFound import scala.collection.immutable.ListMap import scalan.util._ import scalan.RType._ + import scala.collection.mutable import debox.cfor -import scalan.reflection.{RClass, RMethod, RConstructor} +import scalan.reflection.{RClass, RConstructor, RMethod} +import special.wrappers.WrapSpec abstract class TypeDescs extends Base { self: Scalan => diff --git a/common/shared/src/main/scala/scalan/WrapSpec.scala b/sc/shared/src/main/scala/special/wrappers/WrapSpec.scala similarity index 82% rename from common/shared/src/main/scala/scalan/WrapSpec.scala rename to sc/shared/src/main/scala/special/wrappers/WrapSpec.scala index 5eda48bc88..dd07f1144c 100644 --- a/common/shared/src/main/scala/scalan/WrapSpec.scala +++ b/sc/shared/src/main/scala/special/wrappers/WrapSpec.scala @@ -1,4 +1,4 @@ -package scalan +package special.wrappers /** Base type for all wrapper specification classes. * @see OptionWrapSpec as an example */ diff --git a/sc/shared/src/main/scala/special/wrappers/WrappersSpec.scala b/sc/shared/src/main/scala/special/wrappers/WrappersSpec.scala index e539d299d4..9393ca110b 100644 --- a/sc/shared/src/main/scala/special/wrappers/WrappersSpec.scala +++ b/sc/shared/src/main/scala/special/wrappers/WrappersSpec.scala @@ -1,6 +1,6 @@ package special.wrappers -import scalan.{WrapSpec, RType} +import scalan.RType /** Base class for wrappers of such types as WOption, WRType etc. * Used in graph IR to implement method invocation. diff --git a/sdk/shared/src/main/scala/org/ergoplatform/sdk/utils/Zero.scala b/sdk/shared/src/main/scala/org/ergoplatform/sdk/utils/Zero.scala index eab06627f3..6e1a782e5c 100644 --- a/sdk/shared/src/main/scala/org/ergoplatform/sdk/utils/Zero.scala +++ b/sdk/shared/src/main/scala/org/ergoplatform/sdk/utils/Zero.scala @@ -10,9 +10,7 @@ import sigmastate.Values.ErgoTree import sigmastate.basics.CryptoConstants import sigmastate.eval._ import sigmastate.{AvlTreeData, AvlTreeFlags, TrivialProp} -import sigma.Types.TupleType -import sigma.{Coll, CollType} -import sigma.{AvlTree, AvlTreeRType, BigInt, BigIntRType, Box, BoxRType, GroupElement, GroupElementRType, SigmaProp, SigmaPropRType} +import sigma._ import java.math.BigInteger import scala.language.implicitConversions From 7f11c9ae6ab5a2c3180fc9392d39306b6cf48969 Mon Sep 17 00:00:00 2001 From: Alexander Slesarenko Date: Tue, 22 Aug 2023 22:02:49 +0200 Subject: [PATCH 10/37] minimize-modules: reflection moved to sigma --- .../src/main/scala/scalan/reflection/Platform.scala | 2 +- .../src/main/scala/scalan/reflection/JavaImpl.scala | 2 +- .../src/main/scala/scalan/reflection/Platform.scala | 2 +- .../src/main/scala/sigma/CoreLibReflection.scala | 4 ++-- common/shared/src/main/scala/sigma/Environment.scala | 2 +- .../main/scala/sigma/kiama/rewriting/Rewriter.scala | 2 +- common/shared/src/main/scala/sigma/package.scala | 2 +- .../reflection/CommonReflection.scala | 2 +- .../scala/{scalan => sigma}/reflection/RClass.scala | 2 +- .../{scalan => sigma}/reflection/StaticImpl.scala | 2 +- .../scala/{scalan => sigma}/reflection/package.scala | 2 +- .../main/scala/sigmastate/InterpreterReflection.scala | 4 ++-- .../shared/src/main/scala/sigmastate/types.scala | 2 +- .../InterpreterReflectionGeneratorTests.scala | 4 ++-- .../test/scala/sigmastate/ReflectionGenerator.scala | 6 +++--- sc/shared/src/main/scala/scalan/Base.scala | 11 +++++------ sc/shared/src/main/scala/scalan/Entities.scala | 2 +- .../src/main/scala/scalan/GraphIRReflection.scala | 4 ++-- sc/shared/src/main/scala/scalan/MethodCalls.scala | 6 +++--- sc/shared/src/main/scala/scalan/TypeDescs.scala | 6 +++--- .../src/main/scala/scalan/primitives/Thunks.scala | 2 +- .../src/main/scala/scalan/staged/Transforming.scala | 4 ++-- .../scala/special/collection/impl/CollsImpl.scala | 2 +- .../main/scala/special/sigma/impl/SigmaDslImpl.scala | 2 +- .../main/scala/wrappers/scala/impl/WOptionsImpl.scala | 2 +- .../main/scala/wrappers/scalan/impl/WRTypesImpl.scala | 2 +- .../wrappers/special/impl/WSpecialPredefsImpl.scala | 2 +- sc/shared/src/test/scala/scalan/TestContexts.scala | 2 +- .../test/scala/scalan/util/ScalaNameUtilSuite.scala | 4 ++-- 29 files changed, 45 insertions(+), 46 deletions(-) rename common/shared/src/main/scala/{scalan => sigma}/reflection/CommonReflection.scala (99%) rename common/shared/src/main/scala/{scalan => sigma}/reflection/RClass.scala (99%) rename common/shared/src/main/scala/{scalan => sigma}/reflection/StaticImpl.scala (99%) rename common/shared/src/main/scala/{scalan => sigma}/reflection/package.scala (99%) diff --git a/common/js/src/main/scala/scalan/reflection/Platform.scala b/common/js/src/main/scala/scalan/reflection/Platform.scala index 6970bf999d..af98382329 100644 --- a/common/js/src/main/scala/scalan/reflection/Platform.scala +++ b/common/js/src/main/scala/scalan/reflection/Platform.scala @@ -1,4 +1,4 @@ -package scalan.reflection +package sigma.reflection import sigma.RuntimePlatform import scala.collection.mutable diff --git a/common/jvm/src/main/scala/scalan/reflection/JavaImpl.scala b/common/jvm/src/main/scala/scalan/reflection/JavaImpl.scala index 75c46ae352..fcebc8f928 100644 --- a/common/jvm/src/main/scala/scalan/reflection/JavaImpl.scala +++ b/common/jvm/src/main/scala/scalan/reflection/JavaImpl.scala @@ -1,4 +1,4 @@ -package scalan.reflection +package sigma.reflection import debox.cfor diff --git a/common/jvm/src/main/scala/scalan/reflection/Platform.scala b/common/jvm/src/main/scala/scalan/reflection/Platform.scala index 8c59a0096e..6e5aac1b8e 100644 --- a/common/jvm/src/main/scala/scalan/reflection/Platform.scala +++ b/common/jvm/src/main/scala/scalan/reflection/Platform.scala @@ -1,4 +1,4 @@ -package scalan.reflection +package sigma.reflection import sigma.RuntimePlatform import scala.collection.concurrent.TrieMap diff --git a/common/shared/src/main/scala/sigma/CoreLibReflection.scala b/common/shared/src/main/scala/sigma/CoreLibReflection.scala index 55c0e20f9a..ae50557abc 100644 --- a/common/shared/src/main/scala/sigma/CoreLibReflection.scala +++ b/common/shared/src/main/scala/sigma/CoreLibReflection.scala @@ -1,8 +1,8 @@ package sigma import scalan.RType -import scalan.reflection.CommonReflection.registerClassEntry -import scalan.reflection._ +import sigma.reflection.CommonReflection.registerClassEntry +import sigma.reflection._ /** Registrations of reflection metadata for core-lib module. * For each class of this module that needs reflection metadata, diff --git a/common/shared/src/main/scala/sigma/Environment.scala b/common/shared/src/main/scala/sigma/Environment.scala index 7665b251a5..959e02c1fb 100644 --- a/common/shared/src/main/scala/sigma/Environment.scala +++ b/common/shared/src/main/scala/sigma/Environment.scala @@ -17,6 +17,6 @@ object Environment { implicit val current: Environment = new Environment { override def isJVM: Boolean = runtimePlatform == RuntimePlatform.JVM override def isJS: Boolean = runtimePlatform == RuntimePlatform.JS - override def runtimePlatform: RuntimePlatform = scalan.reflection.Platform.runtimePlatform + override def runtimePlatform: RuntimePlatform = sigma.reflection.Platform.runtimePlatform } } \ No newline at end of file diff --git a/common/shared/src/main/scala/sigma/kiama/rewriting/Rewriter.scala b/common/shared/src/main/scala/sigma/kiama/rewriting/Rewriter.scala index ee53218307..92deb2d140 100644 --- a/common/shared/src/main/scala/sigma/kiama/rewriting/Rewriter.scala +++ b/common/shared/src/main/scala/sigma/kiama/rewriting/Rewriter.scala @@ -11,7 +11,7 @@ package sigma.kiama package rewriting -import scalan.reflection.{Platform, RClass, RConstructor} +import sigma.reflection.{Platform, RClass, RConstructor} //import sigma.kiama.==> /** diff --git a/common/shared/src/main/scala/sigma/package.scala b/common/shared/src/main/scala/sigma/package.scala index 840a4edf72..f6ec47bb70 100644 --- a/common/shared/src/main/scala/sigma/package.scala +++ b/common/shared/src/main/scala/sigma/package.scala @@ -10,7 +10,7 @@ import scala.reflect.classTag */ package object sigma { /** Forces reflection data initialization */ - val reflection = CoreLibReflection + val coreLibReflection = CoreLibReflection implicit val BigIntRType: RType[BigInt] = GeneralType(classTag[BigInt]) implicit val GroupElementRType: RType[GroupElement] = GeneralType(classTag[GroupElement]) diff --git a/common/shared/src/main/scala/scalan/reflection/CommonReflection.scala b/common/shared/src/main/scala/sigma/reflection/CommonReflection.scala similarity index 99% rename from common/shared/src/main/scala/scalan/reflection/CommonReflection.scala rename to common/shared/src/main/scala/sigma/reflection/CommonReflection.scala index b839d668be..9bf15b0e1b 100644 --- a/common/shared/src/main/scala/scalan/reflection/CommonReflection.scala +++ b/common/shared/src/main/scala/sigma/reflection/CommonReflection.scala @@ -1,4 +1,4 @@ -package scalan.reflection +package sigma.reflection import scala.collection.compat.immutable.ArraySeq import scala.collection.mutable diff --git a/common/shared/src/main/scala/scalan/reflection/RClass.scala b/common/shared/src/main/scala/sigma/reflection/RClass.scala similarity index 99% rename from common/shared/src/main/scala/scalan/reflection/RClass.scala rename to common/shared/src/main/scala/sigma/reflection/RClass.scala index 32e8aeb2e3..6c843253aa 100644 --- a/common/shared/src/main/scala/scalan/reflection/RClass.scala +++ b/common/shared/src/main/scala/sigma/reflection/RClass.scala @@ -1,4 +1,4 @@ -package scalan.reflection +package sigma.reflection /** A representation of a field of a class, providing reflective access to the field's type. */ abstract class RField { diff --git a/common/shared/src/main/scala/scalan/reflection/StaticImpl.scala b/common/shared/src/main/scala/sigma/reflection/StaticImpl.scala similarity index 99% rename from common/shared/src/main/scala/scalan/reflection/StaticImpl.scala rename to common/shared/src/main/scala/sigma/reflection/StaticImpl.scala index ff6a39348e..e95eea1f59 100644 --- a/common/shared/src/main/scala/scalan/reflection/StaticImpl.scala +++ b/common/shared/src/main/scala/sigma/reflection/StaticImpl.scala @@ -1,4 +1,4 @@ -package scalan.reflection +package sigma.reflection /** * Represents a field in an Sigma Reflection metadata. diff --git a/common/shared/src/main/scala/scalan/reflection/package.scala b/common/shared/src/main/scala/sigma/reflection/package.scala similarity index 99% rename from common/shared/src/main/scala/scalan/reflection/package.scala rename to common/shared/src/main/scala/sigma/reflection/package.scala index 96a9556628..6b98056968 100644 --- a/common/shared/src/main/scala/scalan/reflection/package.scala +++ b/common/shared/src/main/scala/sigma/reflection/package.scala @@ -1,4 +1,4 @@ -package scalan +package sigma import scala.collection.mutable diff --git a/interpreter/shared/src/main/scala/sigmastate/InterpreterReflection.scala b/interpreter/shared/src/main/scala/sigmastate/InterpreterReflection.scala index 7c2f26d423..cdde62557f 100644 --- a/interpreter/shared/src/main/scala/sigmastate/InterpreterReflection.scala +++ b/interpreter/shared/src/main/scala/sigmastate/InterpreterReflection.scala @@ -1,8 +1,8 @@ package sigmastate import org.ergoplatform.ErgoBox.RegisterId -import scalan.reflection.CommonReflection.registerClassEntry -import scalan.reflection.{mkConstructor, mkMethod} +import sigma.reflection.CommonReflection.registerClassEntry +import sigma.reflection.{mkConstructor, mkMethod} import sigma.Coll import sigma.{AvlTree, CoreLibReflection, SigmaDslBuilder} import sigmastate.SAvlTree.KeyValueColl diff --git a/interpreter/shared/src/main/scala/sigmastate/types.scala b/interpreter/shared/src/main/scala/sigmastate/types.scala index c4a8a89181..98b4dcb3a0 100644 --- a/interpreter/shared/src/main/scala/sigmastate/types.scala +++ b/interpreter/shared/src/main/scala/sigmastate/types.scala @@ -32,7 +32,7 @@ import sigmastate.eval.Evaluation.stypeToRType import sigmastate.eval._ import sigmastate.exceptions.MethodNotFound import debox.cfor -import scalan.reflection.{CommonReflection, RClass, RMethod} +import sigma.reflection.{CommonReflection, RClass, RMethod} import scala.collection.mutable import scala.util.{Success, Failure} diff --git a/sc/jvm/src/test/scala/sigmastate/InterpreterReflectionGeneratorTests.scala b/sc/jvm/src/test/scala/sigmastate/InterpreterReflectionGeneratorTests.scala index 45d8888e14..965e33c460 100644 --- a/sc/jvm/src/test/scala/sigmastate/InterpreterReflectionGeneratorTests.scala +++ b/sc/jvm/src/test/scala/sigmastate/InterpreterReflectionGeneratorTests.scala @@ -3,8 +3,8 @@ package sigmastate import org.scalatest.matchers.should.Matchers import org.scalatest.propspec.AnyPropSpec import scalan.TypeDescs -import scalan.reflection.CommonReflection.registerClassEntry -import scalan.reflection.SRConstructor +import sigma.reflection.CommonReflection.registerClassEntry +import sigma.reflection.SRConstructor object ObjA { class A diff --git a/sc/jvm/src/test/scala/sigmastate/ReflectionGenerator.scala b/sc/jvm/src/test/scala/sigmastate/ReflectionGenerator.scala index df19d7a45c..9a3750be47 100644 --- a/sc/jvm/src/test/scala/sigmastate/ReflectionGenerator.scala +++ b/sc/jvm/src/test/scala/sigmastate/ReflectionGenerator.scala @@ -1,6 +1,6 @@ package sigmastate -import scalan.reflection._ +import sigma.reflection._ import scalan.{Base, TypeDescs} import scala.annotation.unused @@ -177,13 +177,13 @@ object ReflectionGenerator { } private def collectEmptyClasses = { - scalan.reflection.Platform.unknownClasses.toSeq.filter(e => + sigma.reflection.Platform.unknownClasses.toSeq.filter(e => isEmpty(e._2) && // don't contain constructors, fields or methods !CommonReflection.classes.contains(e._1)) // not already registered } private def collectNonEmptyClasses = { - scalan.reflection.Platform.unknownClasses.toSeq.filter(e => + sigma.reflection.Platform.unknownClasses.toSeq.filter(e => !isEmpty(e._2) && !CommonReflection.classes.contains(e._1)) } diff --git a/sc/shared/src/main/scala/scalan/Base.scala b/sc/shared/src/main/scala/scalan/Base.scala index 22e01da17f..708ed746fb 100644 --- a/sc/shared/src/main/scala/scalan/Base.scala +++ b/sc/shared/src/main/scala/scalan/Base.scala @@ -1,17 +1,16 @@ package scalan -import java.util.Arrays +import debox.{cfor, Buffer => DBuffer} import scalan.OverloadHack.Overloaded1 +import scalan.util.StringUtil +import sigma.reflection.RConstructor -import scala.language.implicitConversions +import java.util.Arrays import scala.annotation.implicitNotFound import scala.annotation.unchecked.uncheckedVariance -import scalan.util.StringUtil -import debox.{cfor, Buffer => DBuffer} -import scalan.reflection.{RClass, RConstructor} - import scala.collection.compat.immutable.ArraySeq import scala.collection.mutable +import scala.language.implicitConversions /** * The Base trait houses common AST nodes. It also manages a list of encountered definitions which diff --git a/sc/shared/src/main/scala/scalan/Entities.scala b/sc/shared/src/main/scala/scalan/Entities.scala index db830be224..1a74349cc7 100644 --- a/sc/shared/src/main/scala/scalan/Entities.scala +++ b/sc/shared/src/main/scala/scalan/Entities.scala @@ -13,7 +13,7 @@ trait Entities extends TypeDescs { self: Scalan => def parent: Option[Elem[_]] = None /** Name of the entity type without `Elem` suffix. */ def entityName: String = { - val n = scalan.reflection.Platform.safeSimpleName(this.getClass).stripSuffix("Elem") + val n = sigma.reflection.Platform.safeSimpleName(this.getClass).stripSuffix("Elem") n } def convert(x: Ref[Def[_]]): Ref[A] = !!!("should not be called") diff --git a/sc/shared/src/main/scala/scalan/GraphIRReflection.scala b/sc/shared/src/main/scala/scalan/GraphIRReflection.scala index 6abcfb2fa3..fcc9ab905b 100644 --- a/sc/shared/src/main/scala/scalan/GraphIRReflection.scala +++ b/sc/shared/src/main/scala/scalan/GraphIRReflection.scala @@ -1,8 +1,8 @@ package scalan import scalan.primitives.Thunks -import scalan.reflection.CommonReflection.registerClassEntry -import scalan.reflection.{CommonReflection, mkConstructor, mkMethod} +import sigma.reflection.CommonReflection.registerClassEntry +import sigma.reflection.{CommonReflection, mkConstructor, mkMethod} import sigma.CoreLibReflection import sigmastate.eval.SigmaLibrary import sigma.Colls diff --git a/sc/shared/src/main/scala/scalan/MethodCalls.scala b/sc/shared/src/main/scala/scalan/MethodCalls.scala index d300d0765a..6c89502330 100644 --- a/sc/shared/src/main/scala/scalan/MethodCalls.scala +++ b/sc/shared/src/main/scala/scalan/MethodCalls.scala @@ -4,7 +4,7 @@ import scala.annotation.{tailrec, unused} import scala.reflect.ClassTag import debox.{Buffer => DBuffer} import debox.cfor -import scalan.reflection.RMethod +import sigma.reflection.RMethod trait MethodCalls extends Base { self: Scalan => @@ -12,7 +12,7 @@ trait MethodCalls extends Base { self: Scalan => /** Graph node to represent invocation of the method of some class. * @param receiver node ref representing instance on which the method is called - * @param method method which is called (descriptor from `scalan.reflection`) + * @param method method which is called (descriptor from `sigma.reflection`) * @param args node refs representing arguments passed to the method * @param neverInvoke it true this method cannot be performed, even if the * receiver node allow this @@ -43,7 +43,7 @@ trait MethodCalls extends Base { self: Scalan => /** Try invoke `method` on the node instance refered by `receiver`. * Each MC node contains enough information to perform invocation using - * `scalan.reflection.RMethod.invoke` method. However, this is not possible + * `sigma.reflection.RMethod.invoke` method. However, this is not possible * if the node pointed to by `receiver` don't implement this method, * for example when receiver is Lambda variable pointing to Variable node * instance (in which case this MC was created by adapter) diff --git a/sc/shared/src/main/scala/scalan/TypeDescs.scala b/sc/shared/src/main/scala/scalan/TypeDescs.scala index f0a190a113..83849beb81 100644 --- a/sc/shared/src/main/scala/scalan/TypeDescs.scala +++ b/sc/shared/src/main/scala/scalan/TypeDescs.scala @@ -8,7 +8,7 @@ import scalan.RType._ import scala.collection.mutable import debox.cfor -import scalan.reflection.{RClass, RConstructor, RMethod} +import sigma.reflection.{RClass, RConstructor, RMethod} import special.wrappers.WrapSpec abstract class TypeDescs extends Base { self: Scalan => @@ -95,7 +95,7 @@ abstract class TypeDescs extends Base { self: Scalan => lazy val name: String = getName(_.name) // <> to delimit because: [] is used inside name; {} looks bad with structs. - override def toString = s"${scalan.reflection.Platform.safeSimpleName(getClass)}<$name>" + override def toString = s"${sigma.reflection.Platform.safeSimpleName(getClass)}<$name>" } /** Type descriptor of staged types, which correspond to source (unstaged) RTypes @@ -121,7 +121,7 @@ abstract class TypeDescs extends Base { self: Scalan => be.sourceType.name case e => val cl = e.getClass - val name = scalan.reflection.Platform.safeSimpleName(cl).stripSuffix("Elem") + val name = sigma.reflection.Platform.safeSimpleName(cl).stripSuffix("Elem") name } if (typeArgs.isEmpty) diff --git a/sc/shared/src/main/scala/scalan/primitives/Thunks.scala b/sc/shared/src/main/scala/scalan/primitives/Thunks.scala index 030b9b5736..1eb598655a 100644 --- a/sc/shared/src/main/scala/scalan/primitives/Thunks.scala +++ b/sc/shared/src/main/scala/scalan/primitives/Thunks.scala @@ -4,7 +4,7 @@ import scala.language.{existentials, implicitConversions} import scalan._ import debox.{Buffer => DBuffer, Set => DSet} import debox.cfor -import scalan.reflection.RClass +import sigma.reflection.RClass import scalan.util.{Covariant, GraphUtil} diff --git a/sc/shared/src/main/scala/scalan/staged/Transforming.scala b/sc/shared/src/main/scala/scalan/staged/Transforming.scala index 9dd714d049..b44f815464 100644 --- a/sc/shared/src/main/scala/scalan/staged/Transforming.scala +++ b/sc/shared/src/main/scala/scalan/staged/Transforming.scala @@ -2,10 +2,10 @@ package scalan.staged import java.util import scala.language.existentials -import scalan.{AVHashMap, DelayInvokeException, Lazy, Nullable, Scalan} +import scalan.{Lazy, Nullable, Scalan} import debox.{Buffer => DBuffer} import debox.cfor -import scalan.reflection.RMethod +import sigma.reflection.RMethod trait Transforming { self: Scalan => diff --git a/sc/shared/src/main/scala/special/collection/impl/CollsImpl.scala b/sc/shared/src/main/scala/special/collection/impl/CollsImpl.scala index 67c19d672f..33bf96a626 100644 --- a/sc/shared/src/main/scala/special/collection/impl/CollsImpl.scala +++ b/sc/shared/src/main/scala/special/collection/impl/CollsImpl.scala @@ -5,7 +5,7 @@ import scalan._ import scala.collection.compat.immutable.ArraySeq package impl { - import scalan.reflection.{RClass, RMethod} + import sigma.reflection.{RClass, RMethod} // Abs ----------------------------------- trait CollsDefs extends scalan.Scalan with Colls { diff --git a/sc/shared/src/main/scala/special/sigma/impl/SigmaDslImpl.scala b/sc/shared/src/main/scala/special/sigma/impl/SigmaDslImpl.scala index e36b2eaf3e..f99ee23a68 100644 --- a/sc/shared/src/main/scala/special/sigma/impl/SigmaDslImpl.scala +++ b/sc/shared/src/main/scala/special/sigma/impl/SigmaDslImpl.scala @@ -7,7 +7,7 @@ import sigmastate.eval.SigmaLibrary import scala.collection.compat.immutable.ArraySeq package impl { - import scalan.reflection.{RClass, RMethod} + import sigma.reflection.{RClass, RMethod} import sigmastate.eval.SigmaLibrary // Abs ----------------------------------- diff --git a/sc/shared/src/main/scala/wrappers/scala/impl/WOptionsImpl.scala b/sc/shared/src/main/scala/wrappers/scala/impl/WOptionsImpl.scala index e5e7f333e6..36abe24f96 100644 --- a/sc/shared/src/main/scala/wrappers/scala/impl/WOptionsImpl.scala +++ b/sc/shared/src/main/scala/wrappers/scala/impl/WOptionsImpl.scala @@ -7,7 +7,7 @@ import special.wrappers.OptionWrapSpec import scala.collection.compat.immutable.ArraySeq package impl { - import scalan.reflection.{RClass, RMethod} + import sigma.reflection.{RClass, RMethod} // Abs ----------------------------------- trait WOptionsDefs extends scalan.Scalan with WOptions { diff --git a/sc/shared/src/main/scala/wrappers/scalan/impl/WRTypesImpl.scala b/sc/shared/src/main/scala/wrappers/scalan/impl/WRTypesImpl.scala index 66bbf9ed81..820eaf9c47 100644 --- a/sc/shared/src/main/scala/wrappers/scalan/impl/WRTypesImpl.scala +++ b/sc/shared/src/main/scala/wrappers/scalan/impl/WRTypesImpl.scala @@ -8,7 +8,7 @@ import scala.collection.compat.immutable.ArraySeq package impl { import scalan.GraphIRReflection - import scalan.reflection.{RClass, RMethod} + import sigma.reflection.{RClass, RMethod} // Abs ----------------------------------- trait WRTypesDefs extends scalan.Scalan with WRTypes { diff --git a/sc/shared/src/main/scala/wrappers/special/impl/WSpecialPredefsImpl.scala b/sc/shared/src/main/scala/wrappers/special/impl/WSpecialPredefsImpl.scala index 72b673553f..b13b170634 100644 --- a/sc/shared/src/main/scala/wrappers/special/impl/WSpecialPredefsImpl.scala +++ b/sc/shared/src/main/scala/wrappers/special/impl/WSpecialPredefsImpl.scala @@ -5,7 +5,7 @@ import scalan._ import special.wrappers.WrappersModule package impl { - import scalan.reflection.RClass + import sigma.reflection.RClass // Abs ----------------------------------- trait WSpecialPredefsDefs extends scalan.Scalan with WSpecialPredefs { diff --git a/sc/shared/src/test/scala/scalan/TestContexts.scala b/sc/shared/src/test/scala/scalan/TestContexts.scala index 78147e5da4..70e32d04ff 100644 --- a/sc/shared/src/test/scala/scalan/TestContexts.scala +++ b/sc/shared/src/test/scala/scalan/TestContexts.scala @@ -1,6 +1,6 @@ package scalan -import scalan.reflection.RMethod +import sigma.reflection.RMethod import sigma.CoreLibReflection trait TestContexts extends TestUtils { diff --git a/sc/shared/src/test/scala/scalan/util/ScalaNameUtilSuite.scala b/sc/shared/src/test/scala/scalan/util/ScalaNameUtilSuite.scala index 5c597a216c..3cec84bbe6 100644 --- a/sc/shared/src/test/scala/scalan/util/ScalaNameUtilSuite.scala +++ b/sc/shared/src/test/scala/scalan/util/ScalaNameUtilSuite.scala @@ -1,8 +1,8 @@ package scalan.util import scalan.BaseTests -import scalan.reflection.CommonReflection.registerClassEntry -import scalan.reflection.{RClass, mkMethod} +import sigma.reflection.CommonReflection.registerClassEntry +import sigma.reflection.{RClass, mkMethod} class ScalaNameUtilSuite extends BaseTests { def +\() = ??? From a756e436096e935432866fd8c889fb52f2e1c730 Mon Sep 17 00:00:00 2001 From: Alexander Slesarenko Date: Wed, 23 Aug 2023 01:35:00 +0200 Subject: [PATCH 11/37] minimize-modules: util moved to sigma --- .../{scalan => sigma}/util/FileUtil.scala | 6 ++--- .../util/FileUtilTests.scala | 2 +- .../{scalan => sigma}/util/ProcessUtil.scala | 2 +- .../src/main/scala/scalan/ExactIntegral.scala | 2 +- .../main/scala/sigma/CollsOverArrays.scala | 2 +- .../src/main/scala/sigma/TupleType.scala | 2 +- .../util/CollectionUtil.scala | 2 +- .../{scalan => sigma}/util/Extensions.scala | 2 +- .../{scalan => sigma}/util/GraphUtil.scala | 2 +- .../{scalan => sigma}/util/MemoizedFunc.scala | 2 +- .../{scalan => sigma}/util/StringUtil.scala | 2 +- .../sigma/{util.scala => util/package.scala} | 7 +++--- .../src/test/scala/scalan/TestUtils.scala | 6 ++--- .../scala/scalan/util/BenchmarkUtil.scala | 2 +- .../scalan/util/CollectionUtilTests.scala | 4 ++-- .../scala/scalan/util/GraphUtilTests.scala | 2 +- .../scala/scalan/util/PrintExtensions.scala | 2 +- .../scala/scalan/util/StringUtilTests.scala | 2 +- .../StronglyConnectedComponentsTests.scala | 2 +- .../org/ergoplatform/SigmaConstants.scala | 2 +- .../SigmaValidationSettingsSerializer.scala | 2 +- .../validation/ValidationRules.scala | 2 +- .../src/main/scala/sigmastate/Values.scala | 4 ++-- .../sigmastate/eval/CostingDataContext.scala | 2 +- .../main/scala/sigmastate/eval/Profiler.scala | 2 +- .../interpreter/ErgoTreeEvaluator.scala | 4 ++-- .../interpreter/ProverInterpreter.scala | 2 +- .../serialization/ValueSerializer.scala | 4 ++-- .../trees/Relation2Serializer.scala | 2 +- .../src/main/scala/sigmastate/types.scala | 24 ++++++++----------- .../sigmastate/utxo/ComplexityTableStat.scala | 2 +- sc/jvm/src/test/scala/scalan/Platform.scala | 2 +- .../scalan/compilation/GraphVizExport.scala | 3 ++- .../sigmastate/utils/GenPredefFuncsApp.scala | 4 ++-- .../sigmastate/utils/GenPredefTypesApp.scala | 2 +- .../sigmastate/utils/GenSerializers.scala | 6 ++--- sc/shared/src/main/scala/scalan/Base.scala | 2 +- sc/shared/src/main/scala/scalan/Library.scala | 3 +-- .../src/main/scala/scalan/MethodCalls.scala | 2 +- .../src/main/scala/scalan/TypeDescs.scala | 3 ++- .../scalan/{util => core}/Variance.scala | 2 +- .../src/main/scala/scalan/meta/SSymName.scala | 2 +- .../scala/scalan/primitives/Functions.scala | 5 ++-- .../main/scala/scalan/primitives/Thunks.scala | 4 ++-- .../scala/scalan/staged/ProgramGraphs.scala | 4 ++-- .../scala/sigmastate/eval/GraphBuilding.scala | 5 ++-- .../scala/sigmastate/lang/SigmaTyper.scala | 2 +- .../special/collection/impl/CollsImpl.scala | 2 +- .../wrappers/scala/impl/WOptionsImpl.scala | 2 +- .../wrappers/scalan/impl/WRTypesImpl.scala | 2 +- .../org/ergoplatform/ErgoTreePredefSpec.scala | 12 +++++----- .../src/test/scala/scalan/LibraryTests.scala | 2 +- .../scalan/{util => core}/ScalaNameUtil.scala | 4 ++-- .../{util => core}/ScalaNameUtilSuite.scala | 2 +- .../TestingInterpreterSpecification.scala | 6 ++--- .../sigmastate/eval/EvaluationTest.scala | 2 +- .../sigmastate/eval/MeasureIRContext.scala | 2 +- .../helpers/CompilerTestingCommons.scala | 2 +- .../DeserializationResilience.scala | 2 +- .../sigmastate/utils/GenInfoObjects.scala | 2 +- .../test/scala/sigmastate/utils/SpecGen.scala | 13 +++++----- .../utxo/BasicOpsSpecification.scala | 2 +- .../utxo/SerializationRoundTripSpec.scala | 2 +- .../DataValueComparerSpecification.scala | 2 +- .../special/sigma/SigmaDslSpecification.scala | 4 ++-- .../scala/special/sigma/SigmaDslTesting.scala | 9 ++++--- .../sdk/AppkitProvingInterpreter.scala | 4 ++-- .../org/ergoplatform/sdk/JavaHelpers.scala | 2 +- .../sdk/ReducingInterpreter.scala | 3 +-- .../sdk/multisig/SigningSpec.scala | 2 +- 70 files changed, 118 insertions(+), 123 deletions(-) rename common/jvm/src/test/scala/{scalan => sigma}/util/FileUtil.scala (98%) rename common/jvm/src/test/scala/{scalan => sigma}/util/FileUtilTests.scala (98%) rename common/jvm/src/test/scala/{scalan => sigma}/util/ProcessUtil.scala (99%) rename common/shared/src/main/scala/{scalan => sigma}/util/CollectionUtil.scala (99%) rename common/shared/src/main/scala/{scalan => sigma}/util/Extensions.scala (99%) rename common/shared/src/main/scala/{scalan => sigma}/util/GraphUtil.scala (99%) rename common/shared/src/main/scala/{scalan => sigma}/util/MemoizedFunc.scala (97%) rename common/shared/src/main/scala/{scalan => sigma}/util/StringUtil.scala (98%) rename common/shared/src/main/scala/sigma/{util.scala => util/package.scala} (91%) rename sc/shared/src/main/scala/scalan/{util => core}/Variance.scala (89%) rename sc/shared/src/test/scala/scalan/{util => core}/ScalaNameUtil.scala (90%) rename sc/shared/src/test/scala/scalan/{util => core}/ScalaNameUtilSuite.scala (98%) diff --git a/common/jvm/src/test/scala/scalan/util/FileUtil.scala b/common/jvm/src/test/scala/sigma/util/FileUtil.scala similarity index 98% rename from common/jvm/src/test/scala/scalan/util/FileUtil.scala rename to common/jvm/src/test/scala/sigma/util/FileUtil.scala index c4a8d15595..cac749c6a3 100644 --- a/common/jvm/src/test/scala/scalan/util/FileUtil.scala +++ b/common/jvm/src/test/scala/sigma/util/FileUtil.scala @@ -1,7 +1,7 @@ -package scalan.util +package sigma.util -import scalan.util.CollectionUtil.AnyOps -import scalan.util.StringUtil.cleanFileName +import sigma.util.CollectionUtil.AnyOps +import sigma.util.StringUtil.cleanFileName import java.io._ import java.net.{JarURLConnection, URL} diff --git a/common/jvm/src/test/scala/scalan/util/FileUtilTests.scala b/common/jvm/src/test/scala/sigma/util/FileUtilTests.scala similarity index 98% rename from common/jvm/src/test/scala/scalan/util/FileUtilTests.scala rename to common/jvm/src/test/scala/sigma/util/FileUtilTests.scala index 2edb4289ce..419a18a0ce 100644 --- a/common/jvm/src/test/scala/scalan/util/FileUtilTests.scala +++ b/common/jvm/src/test/scala/sigma/util/FileUtilTests.scala @@ -1,4 +1,4 @@ -package scalan.util +package sigma.util import scalan.BaseNestedTests diff --git a/common/jvm/src/test/scala/scalan/util/ProcessUtil.scala b/common/jvm/src/test/scala/sigma/util/ProcessUtil.scala similarity index 99% rename from common/jvm/src/test/scala/scalan/util/ProcessUtil.scala rename to common/jvm/src/test/scala/sigma/util/ProcessUtil.scala index f30d1fc2e0..7afa9bb616 100644 --- a/common/jvm/src/test/scala/scalan/util/ProcessUtil.scala +++ b/common/jvm/src/test/scala/sigma/util/ProcessUtil.scala @@ -1,4 +1,4 @@ -package scalan.util +package sigma.util import java.io.File import scala.collection.mutable diff --git a/common/shared/src/main/scala/scalan/ExactIntegral.scala b/common/shared/src/main/scala/scalan/ExactIntegral.scala index 57e6e55dd3..48dba05f9b 100644 --- a/common/shared/src/main/scala/scalan/ExactIntegral.scala +++ b/common/shared/src/main/scala/scalan/ExactIntegral.scala @@ -1,6 +1,6 @@ package scalan -import scalan.util.Extensions._ +import sigma.util.Extensions.{ByteOps, ShortOps} /** Type-class which defines the operations on Integral types (Byte, Short, Int, Long, BigInt) * with overflow checks. diff --git a/common/shared/src/main/scala/sigma/CollsOverArrays.scala b/common/shared/src/main/scala/sigma/CollsOverArrays.scala index 9e8b0f810d..c93fbebb0f 100644 --- a/common/shared/src/main/scala/sigma/CollsOverArrays.scala +++ b/common/shared/src/main/scala/sigma/CollsOverArrays.scala @@ -1,7 +1,7 @@ package sigma import scalan._ // required -import scalan.util.CollectionUtil +import sigma.util.CollectionUtil import scalan.RType import debox.Buffer import scalan.RType._ diff --git a/common/shared/src/main/scala/sigma/TupleType.scala b/common/shared/src/main/scala/sigma/TupleType.scala index 0703e725f7..a6261d29d4 100644 --- a/common/shared/src/main/scala/sigma/TupleType.scala +++ b/common/shared/src/main/scala/sigma/TupleType.scala @@ -2,7 +2,7 @@ package sigma import scalan.RType import scalan.RType.SomeType -import scalan.util.CollectionUtil +import sigma.util.CollectionUtil import scala.reflect.ClassTag diff --git a/common/shared/src/main/scala/scalan/util/CollectionUtil.scala b/common/shared/src/main/scala/sigma/util/CollectionUtil.scala similarity index 99% rename from common/shared/src/main/scala/scalan/util/CollectionUtil.scala rename to common/shared/src/main/scala/sigma/util/CollectionUtil.scala index 2eefc8b956..d6bcd69767 100644 --- a/common/shared/src/main/scala/scalan/util/CollectionUtil.scala +++ b/common/shared/src/main/scala/sigma/util/CollectionUtil.scala @@ -1,4 +1,4 @@ -package scalan.util +package sigma.util import scala.collection.{Seq, mutable, GenIterable} import scala.collection.mutable.{HashMap, ArrayBuffer} diff --git a/common/shared/src/main/scala/scalan/util/Extensions.scala b/common/shared/src/main/scala/sigma/util/Extensions.scala similarity index 99% rename from common/shared/src/main/scala/scalan/util/Extensions.scala rename to common/shared/src/main/scala/sigma/util/Extensions.scala index 457a60a72e..1d38173e1f 100644 --- a/common/shared/src/main/scala/scalan/util/Extensions.scala +++ b/common/shared/src/main/scala/sigma/util/Extensions.scala @@ -1,4 +1,4 @@ -package scalan.util +package sigma.util import java.math.BigInteger import java.nio.ByteBuffer diff --git a/common/shared/src/main/scala/scalan/util/GraphUtil.scala b/common/shared/src/main/scala/sigma/util/GraphUtil.scala similarity index 99% rename from common/shared/src/main/scala/scalan/util/GraphUtil.scala rename to common/shared/src/main/scala/sigma/util/GraphUtil.scala index 88df8d94b4..b8cb9a0edb 100644 --- a/common/shared/src/main/scala/scalan/util/GraphUtil.scala +++ b/common/shared/src/main/scala/sigma/util/GraphUtil.scala @@ -1,4 +1,4 @@ -package scalan.util +package sigma.util import scalan.DFunc import debox.{Set => DSet, Buffer => DBuffer} diff --git a/common/shared/src/main/scala/scalan/util/MemoizedFunc.scala b/common/shared/src/main/scala/sigma/util/MemoizedFunc.scala similarity index 97% rename from common/shared/src/main/scala/scalan/util/MemoizedFunc.scala rename to common/shared/src/main/scala/sigma/util/MemoizedFunc.scala index 48df94788a..5960cc5366 100644 --- a/common/shared/src/main/scala/scalan/util/MemoizedFunc.scala +++ b/common/shared/src/main/scala/sigma/util/MemoizedFunc.scala @@ -1,4 +1,4 @@ -package scalan.util +package sigma.util import scalan.AVHashMap diff --git a/common/shared/src/main/scala/scalan/util/StringUtil.scala b/common/shared/src/main/scala/sigma/util/StringUtil.scala similarity index 98% rename from common/shared/src/main/scala/scalan/util/StringUtil.scala rename to common/shared/src/main/scala/sigma/util/StringUtil.scala index 9dcf42daab..5bef3e1612 100644 --- a/common/shared/src/main/scala/scalan/util/StringUtil.scala +++ b/common/shared/src/main/scala/sigma/util/StringUtil.scala @@ -1,4 +1,4 @@ -package scalan.util +package sigma.util import debox.cfor diff --git a/common/shared/src/main/scala/sigma/util.scala b/common/shared/src/main/scala/sigma/util/package.scala similarity index 91% rename from common/shared/src/main/scala/sigma/util.scala rename to common/shared/src/main/scala/sigma/util/package.scala index 85c5ef0b2e..87b3b6a805 100644 --- a/common/shared/src/main/scala/sigma/util.scala +++ b/common/shared/src/main/scala/sigma/util/package.scala @@ -1,10 +1,8 @@ package sigma -import scalan.util.CollectionUtil - import scala.reflect.ClassTag -object util { +package object util { /** Maximum length of an allocatable array. */ val MaxArrayLength: Int = 100000 @@ -24,7 +22,8 @@ object util { /** Concatenate two arrays checking length limit of the resulting array. * Should be used in implementation of Coll operations of v5.0 and above. */ - final def safeConcatArrays_v5[A](arr1: Array[A], arr2: Array[A])(implicit tA: ClassTag[A]): Array[A] = { + final def safeConcatArrays_v5[A](arr1: Array[A], arr2: Array[A]) + (implicit tA: ClassTag[A]): Array[A] = { checkLength[A](arr1.length + arr2.length) CollectionUtil.concatArrays_v5(arr1, arr2) } diff --git a/common/shared/src/test/scala/scalan/TestUtils.scala b/common/shared/src/test/scala/scalan/TestUtils.scala index a7471b3a62..683c9c29cf 100644 --- a/common/shared/src/test/scala/scalan/TestUtils.scala +++ b/common/shared/src/test/scala/scalan/TestUtils.scala @@ -1,10 +1,10 @@ package scalan -import scalan.util.StringUtil import org.scalactic.TripleEquals import org.scalatest.matchers.should.Matchers -import org.scalatest.{TestSuite, Inside} -import scalan.util.StringUtil.{cleanFileName, StringUtilExtensions} +import org.scalatest.{Inside, TestSuite} +import sigma.util.StringUtil +import sigma.util.StringUtil.{StringUtilExtensions, cleanFileName} /** * Created by slesarenko on 11/10/2017. diff --git a/common/shared/src/test/scala/scalan/util/BenchmarkUtil.scala b/common/shared/src/test/scala/scalan/util/BenchmarkUtil.scala index a06a7d859d..ce79d045c4 100644 --- a/common/shared/src/test/scala/scalan/util/BenchmarkUtil.scala +++ b/common/shared/src/test/scala/scalan/util/BenchmarkUtil.scala @@ -1,4 +1,4 @@ -package scalan.util +package sigma.util import debox.cfor diff --git a/common/shared/src/test/scala/scalan/util/CollectionUtilTests.scala b/common/shared/src/test/scala/scalan/util/CollectionUtilTests.scala index 2b394755aa..281cc7b17e 100644 --- a/common/shared/src/test/scala/scalan/util/CollectionUtilTests.scala +++ b/common/shared/src/test/scala/scalan/util/CollectionUtilTests.scala @@ -1,4 +1,4 @@ -package scalan.util +package sigma.util import scalan.BaseTests @@ -6,7 +6,7 @@ import scala.collection.{Seq, mutable} import scala.reflect.ClassTag class CollectionUtilTests extends BaseTests { - import scalan.util.CollectionUtil._ + import sigma.util.CollectionUtil._ test("updateMany") { val xs: Seq[Byte] = Array[Byte](1,2,3) diff --git a/common/shared/src/test/scala/scalan/util/GraphUtilTests.scala b/common/shared/src/test/scala/scalan/util/GraphUtilTests.scala index 213d8bc688..e38d28375b 100644 --- a/common/shared/src/test/scala/scalan/util/GraphUtilTests.scala +++ b/common/shared/src/test/scala/scalan/util/GraphUtilTests.scala @@ -1,4 +1,4 @@ -package scalan.util +package sigma.util import scalan.{BaseNestedTests, DFunc} import debox.{Set => DSet, Buffer => DBuffer} diff --git a/common/shared/src/test/scala/scalan/util/PrintExtensions.scala b/common/shared/src/test/scala/scalan/util/PrintExtensions.scala index d3b87441dd..2adc563c32 100644 --- a/common/shared/src/test/scala/scalan/util/PrintExtensions.scala +++ b/common/shared/src/test/scala/scalan/util/PrintExtensions.scala @@ -1,4 +1,4 @@ -package scalan.util +package sigma.util /** Helper methods for pretty printing of collections and optional values. */ object PrintExtensions { diff --git a/common/shared/src/test/scala/scalan/util/StringUtilTests.scala b/common/shared/src/test/scala/scalan/util/StringUtilTests.scala index 4a2fc3b14f..ef90c371f9 100644 --- a/common/shared/src/test/scala/scalan/util/StringUtilTests.scala +++ b/common/shared/src/test/scala/scalan/util/StringUtilTests.scala @@ -1,4 +1,4 @@ -package scalan.util +package sigma.util import scalan.BaseNestedTests diff --git a/common/shared/src/test/scala/scalan/util/StronglyConnectedComponentsTests.scala b/common/shared/src/test/scala/scalan/util/StronglyConnectedComponentsTests.scala index 2019515885..aae397996f 100644 --- a/common/shared/src/test/scala/scalan/util/StronglyConnectedComponentsTests.scala +++ b/common/shared/src/test/scala/scalan/util/StronglyConnectedComponentsTests.scala @@ -1,4 +1,4 @@ -package scalan.util +package sigma.util import scalan.BaseTests diff --git a/interpreter/shared/src/main/scala/org/ergoplatform/SigmaConstants.scala b/interpreter/shared/src/main/scala/org/ergoplatform/SigmaConstants.scala index be745d8d7d..4f4bacc298 100644 --- a/interpreter/shared/src/main/scala/org/ergoplatform/SigmaConstants.scala +++ b/interpreter/shared/src/main/scala/org/ergoplatform/SigmaConstants.scala @@ -1,6 +1,6 @@ package org.ergoplatform -import scalan.util.CollectionUtil.TraversableOps // used in Scala 2.11 +import sigma.util.CollectionUtil.TraversableOps // used in Scala 2.11 import sigmastate.basics.CryptoConstants /** Descriptor of a constant which represents some size value. diff --git a/interpreter/shared/src/main/scala/org/ergoplatform/validation/SigmaValidationSettingsSerializer.scala b/interpreter/shared/src/main/scala/org/ergoplatform/validation/SigmaValidationSettingsSerializer.scala index 1b53b7dbf1..a3b89f294b 100644 --- a/interpreter/shared/src/main/scala/org/ergoplatform/validation/SigmaValidationSettingsSerializer.scala +++ b/interpreter/shared/src/main/scala/org/ergoplatform/validation/SigmaValidationSettingsSerializer.scala @@ -2,7 +2,7 @@ package org.ergoplatform.validation import sigmastate.serialization.SigmaSerializer import sigmastate.utils.{SigmaByteReader, SigmaByteWriter} -import scalan.util.Extensions.{IntOps, LongOps} +import sigma.util.Extensions.IntOps import sigmastate.exceptions.SerializerException // TODO v5.x: remove unused class and related json encoders diff --git a/interpreter/shared/src/main/scala/org/ergoplatform/validation/ValidationRules.scala b/interpreter/shared/src/main/scala/org/ergoplatform/validation/ValidationRules.scala index 2573d3f592..442faed890 100644 --- a/interpreter/shared/src/main/scala/org/ergoplatform/validation/ValidationRules.scala +++ b/interpreter/shared/src/main/scala/org/ergoplatform/validation/ValidationRules.scala @@ -1,6 +1,6 @@ package org.ergoplatform.validation -import scalan.util.Extensions.toUByte +import sigma.util.Extensions.toUByte import sigmastate.Values.{ErgoTree, SValue} import sigmastate._ import sigmastate.exceptions.{InterpreterException, InvalidOpCode, ReaderPositionLimitExceeded, SerializerException, SigmaException} diff --git a/interpreter/shared/src/main/scala/sigmastate/Values.scala b/interpreter/shared/src/main/scala/sigmastate/Values.scala index a9f5779b7d..158f24b375 100644 --- a/interpreter/shared/src/main/scala/sigmastate/Values.scala +++ b/interpreter/shared/src/main/scala/sigmastate/Values.scala @@ -6,7 +6,7 @@ import sigma.kiama.rewriting.Rewriter.{count, everywherebu, strategy} import org.ergoplatform.settings.ErgoAlgos import org.ergoplatform.validation.ValidationException import scalan.{Nullable, RType} -import scalan.util.CollectionUtil._ +import sigma.util.CollectionUtil._ import sigmastate.SCollection.{SByteArray, SIntArray} import sigmastate.basics.CryptoConstants.EcPointType import sigmastate.interpreter.{CompanionDesc, ErgoTreeEvaluator, Interpreter, NamedDesc} @@ -20,7 +20,7 @@ import sigmastate.lang.Terms._ import sigmastate.utxo._ import sigmastate.eval._ import sigmastate.eval.Extensions._ -import scalan.util.Extensions.ByteOps +import sigma.util.Extensions.ByteOps import sigmastate.interpreter.ErgoTreeEvaluator._ import debox.cfor import scorex.util.encode.Base16 diff --git a/interpreter/shared/src/main/scala/sigmastate/eval/CostingDataContext.scala b/interpreter/shared/src/main/scala/sigmastate/eval/CostingDataContext.scala index 2123f14ce4..f40e469164 100644 --- a/interpreter/shared/src/main/scala/sigmastate/eval/CostingDataContext.scala +++ b/interpreter/shared/src/main/scala/sigmastate/eval/CostingDataContext.scala @@ -5,7 +5,7 @@ import org.ergoplatform.validation.{SigmaValidationSettings, ValidationRules} import org.ergoplatform.{ErgoBox, SigmaConstants} import scalan.OverloadHack.Overloaded1 import scalan.RType -import scalan.util.Extensions.BigIntegerOps +import sigma.util.Extensions.BigIntegerOps import scorex.crypto.authds.avltree.batch._ import scorex.crypto.authds.{ADDigest, ADKey, ADValue, SerializedAdProof} import scorex.crypto.hash.{Blake2b256, Digest32, Sha256} diff --git a/interpreter/shared/src/main/scala/sigmastate/eval/Profiler.scala b/interpreter/shared/src/main/scala/sigmastate/eval/Profiler.scala index 74e187b809..80266c9063 100644 --- a/interpreter/shared/src/main/scala/sigmastate/eval/Profiler.scala +++ b/interpreter/shared/src/main/scala/sigmastate/eval/Profiler.scala @@ -5,7 +5,7 @@ import sigmastate.Values.SValue import sigmastate.serialization.{OpCodes, ValueSerializer} import sigmastate.serialization.OpCodes.OpCode import sigmastate.serialization.ValueSerializer.getSerializer -import scalan.util.Extensions.ByteOps +import sigma.util.Extensions.ByteOps import debox.{Buffer => DBuffer, Map => DMap} import debox.sp import sigmastate.eval.Extensions.DBufferOps diff --git a/interpreter/shared/src/main/scala/sigmastate/interpreter/ErgoTreeEvaluator.scala b/interpreter/shared/src/main/scala/sigmastate/interpreter/ErgoTreeEvaluator.scala index 62e9c5a34b..e1bcd3119c 100644 --- a/interpreter/shared/src/main/scala/sigmastate/interpreter/ErgoTreeEvaluator.scala +++ b/interpreter/shared/src/main/scala/sigmastate/interpreter/ErgoTreeEvaluator.scala @@ -1,13 +1,13 @@ package sigmastate.interpreter import org.ergoplatform.ErgoLikeContext -import sigmastate.{PerItemCost, TypeBasedCost, FixedCost, SType, JitCost} +import sigmastate.{FixedCost, JitCost, PerItemCost, SType, TypeBasedCost} import sigmastate.Values._ import sigmastate.eval.Profiler import sigmastate.interpreter.ErgoTreeEvaluator.DataEnv import sigmastate.interpreter.Interpreter.ReductionResult import sigma.{Context, SigmaProp} -import scalan.util.Extensions._ +import sigma.util.Extensions._ import sigmastate.interpreter.EvalSettings._ import supertagged.TaggedType import debox.{Buffer => DBuffer} diff --git a/interpreter/shared/src/main/scala/sigmastate/interpreter/ProverInterpreter.scala b/interpreter/shared/src/main/scala/sigmastate/interpreter/ProverInterpreter.scala index d3cf8b7558..a67ea6f236 100644 --- a/interpreter/shared/src/main/scala/sigmastate/interpreter/ProverInterpreter.scala +++ b/interpreter/shared/src/main/scala/sigmastate/interpreter/ProverInterpreter.scala @@ -1,7 +1,7 @@ package sigmastate.interpreter import sigma.kiama.rewriting.Rewriter.{everywherebu, everywheretd, rule} -import scalan.util.CollectionUtil._ +import sigma.util.CollectionUtil._ import sigma.VersionContext import sigma.kiama.rewriting.Strategy import sigmastate.TrivialProp.{FalseProp, TrueProp} diff --git a/interpreter/shared/src/main/scala/sigmastate/serialization/ValueSerializer.scala b/interpreter/shared/src/main/scala/sigmastate/serialization/ValueSerializer.scala index 2ef308f928..c9dc9902ef 100644 --- a/interpreter/shared/src/main/scala/sigmastate/serialization/ValueSerializer.scala +++ b/interpreter/shared/src/main/scala/sigmastate/serialization/ValueSerializer.scala @@ -2,14 +2,14 @@ package sigmastate.serialization import org.ergoplatform.validation.ValidationRules.CheckValidOpCode import org.ergoplatform._ +import sigma.util.Extensions.toUByte import sigmastate.SCollection.SByteArray import sigmastate.Values._ import sigmastate._ import sigmastate.lang.DeserializationSigmaBuilder import sigmastate.serialization.OpCodes._ import sigmastate.serialization.transformers._ -import sigmastate.serialization.trees.{Relation2Serializer, QuadrupleSerializer} -import scalan.util.Extensions._ +import sigmastate.serialization.trees.{QuadrupleSerializer, Relation2Serializer} import sigmastate.utils.SigmaByteWriter.DataInfo import sigmastate.utils._ import sigmastate.utxo.ComplexityTable._ diff --git a/interpreter/shared/src/main/scala/sigmastate/serialization/trees/Relation2Serializer.scala b/interpreter/shared/src/main/scala/sigmastate/serialization/trees/Relation2Serializer.scala index 23f6fcb6d4..655fa8f2d2 100644 --- a/interpreter/shared/src/main/scala/sigmastate/serialization/trees/Relation2Serializer.scala +++ b/interpreter/shared/src/main/scala/sigmastate/serialization/trees/Relation2Serializer.scala @@ -6,7 +6,7 @@ import sigmastate.serialization.OpCodes._ import sigmastate.serialization.ValueSerializer import sigmastate.utils.{SigmaByteReader, SigmaByteWriter} import sigmastate.serialization.ValueSerializer._ -import scalan.util.Extensions._ +import sigma.util.Extensions._ case class Relation2Serializer[S1 <: SType, S2 <: SType, R <: Value[SBoolean.type]] (override val opDesc: RelationCompanion, diff --git a/interpreter/shared/src/main/scala/sigmastate/types.scala b/interpreter/shared/src/main/scala/sigmastate/types.scala index 98b4dcb3a0..c8f70a4b34 100644 --- a/interpreter/shared/src/main/scala/sigmastate/types.scala +++ b/interpreter/shared/src/main/scala/sigmastate/types.scala @@ -3,39 +3,35 @@ package sigmastate import java.math.BigInteger import org.ergoplatform._ import org.ergoplatform.validation._ -import scalan.{RType, Nullable} +import scalan.{Nullable, RType} import scalan.RType.GeneralType -import sigmastate.SType.{TypeCode, AnyOps} +import sigmastate.SType.TypeCode import sigmastate.interpreter._ import sigmastate.utils.Overloading.Overload1 -import sigmastate.utils.SparseArrayContainer -import scalan.util.Extensions._ -import scorex.crypto.authds.{ADValue, ADKey} -import scorex.crypto.authds.avltree.batch.{Lookup, Remove, Insert, Update} -import scorex.crypto.hash.Blake2b256 +import scorex.crypto.authds.{ADKey, ADValue} +import scorex.crypto.authds.avltree.batch.{Insert, Lookup, Remove, Update} import sigmastate.Values._ import sigmastate.lang.Terms._ import sigmastate.lang.{SigmaBuilder, Terms} import sigmastate.SCollection._ -import sigmastate.basics.CryptoConstants.{hashLength, EcPointType} +import sigmastate.basics.CryptoConstants.EcPointType import sigmastate.serialization.OpCodes import sigma.Coll import sigma._ import scala.language.implicitConversions -import scala.reflect.{classTag, ClassTag} +import scala.reflect.{ClassTag, classTag} import scala.collection.compat.immutable.ArraySeq -import sigmastate.SMethod.{InvokeDescBuilder, MethodCostFunc, givenCost, javaMethodOf, MethodCallIrBuilder} +import sigmastate.SMethod.{InvokeDescBuilder, MethodCallIrBuilder, MethodCostFunc, javaMethodOf} import sigmastate.utxo._ import sigmastate.lang.Terms.STypeSubst import sigmastate.eval.Evaluation.stypeToRType import sigmastate.eval._ -import sigmastate.exceptions.MethodNotFound import debox.cfor -import sigma.reflection.{CommonReflection, RClass, RMethod} +import sigma.reflection.{RClass, RMethod} +import sigma.util.Extensions.{IntOps, LongOps, ShortOps} -import scala.collection.mutable -import scala.util.{Success, Failure} +import scala.util.{Failure, Success} /** Base type for all AST nodes of sigma lang. */ trait SigmaNode extends Product diff --git a/interpreter/shared/src/main/scala/sigmastate/utxo/ComplexityTableStat.scala b/interpreter/shared/src/main/scala/sigmastate/utxo/ComplexityTableStat.scala index c9f68138d9..e595fa2b6a 100644 --- a/interpreter/shared/src/main/scala/sigmastate/utxo/ComplexityTableStat.scala +++ b/interpreter/shared/src/main/scala/sigmastate/utxo/ComplexityTableStat.scala @@ -2,7 +2,7 @@ package sigmastate.utxo import sigmastate.serialization.ValueSerializer.getSerializer import sigmastate.serialization.OpCodes.OpCode -import scalan.util.Extensions.ByteOps +import sigma.util.Extensions.ByteOps import sigmastate.SMethod import sigmastate.serialization.OpCodes diff --git a/sc/jvm/src/test/scala/scalan/Platform.scala b/sc/jvm/src/test/scala/scalan/Platform.scala index fe49a80368..43041a92c6 100644 --- a/sc/jvm/src/test/scala/scalan/Platform.scala +++ b/sc/jvm/src/test/scala/scalan/Platform.scala @@ -1,7 +1,7 @@ package scalan import scalan.compilation.GraphVizExport -import scalan.util.FileUtil +import sigma.util.FileUtil import org.scalatest.Assertions object Platform { diff --git a/sc/jvm/src/test/scala/scalan/compilation/GraphVizExport.scala b/sc/jvm/src/test/scala/scalan/compilation/GraphVizExport.scala index 11cc2de629..06cbdd64a5 100644 --- a/sc/jvm/src/test/scala/scalan/compilation/GraphVizExport.scala +++ b/sc/jvm/src/test/scala/scalan/compilation/GraphVizExport.scala @@ -3,7 +3,8 @@ package scalan.compilation import java.awt.Desktop import java.io.{File, PrintWriter} import scalan.Scalan -import scalan.util.{StringUtil, ScalaNameUtil, FileUtil, ProcessUtil} +import scalan.core.ScalaNameUtil +import sigma.util.{FileUtil, ProcessUtil, StringUtil} import scala.collection.immutable.StringOps diff --git a/sc/jvm/src/test/scala/sigmastate/utils/GenPredefFuncsApp.scala b/sc/jvm/src/test/scala/sigmastate/utils/GenPredefFuncsApp.scala index 3fffe59784..796b036a08 100644 --- a/sc/jvm/src/test/scala/sigmastate/utils/GenPredefFuncsApp.scala +++ b/sc/jvm/src/test/scala/sigmastate/utils/GenPredefFuncsApp.scala @@ -1,7 +1,7 @@ package sigmastate.utils -import scalan.util.FileUtil -import scalan.util.PrintExtensions._ +import sigma.util.FileUtil +import sigma.util.PrintExtensions.IterableExtensions object GenPredefFuncsApp extends SpecGen { diff --git a/sc/jvm/src/test/scala/sigmastate/utils/GenPredefTypesApp.scala b/sc/jvm/src/test/scala/sigmastate/utils/GenPredefTypesApp.scala index b889abff2b..bf11f8bf51 100644 --- a/sc/jvm/src/test/scala/sigmastate/utils/GenPredefTypesApp.scala +++ b/sc/jvm/src/test/scala/sigmastate/utils/GenPredefTypesApp.scala @@ -1,6 +1,6 @@ package sigmastate.utils -import scalan.util.FileUtil +import sigma.util.FileUtil object GenPredefTypesApp extends SpecGen { import SpecGenUtils._ diff --git a/sc/jvm/src/test/scala/sigmastate/utils/GenSerializers.scala b/sc/jvm/src/test/scala/sigmastate/utils/GenSerializers.scala index 470baf27e8..75e39111ab 100644 --- a/sc/jvm/src/test/scala/sigmastate/utils/GenSerializers.scala +++ b/sc/jvm/src/test/scala/sigmastate/utils/GenSerializers.scala @@ -1,8 +1,8 @@ package sigmastate.utils -import scalan.util.Extensions.ByteOps -import scalan.util.FileUtil -import scalan.util.PrintExtensions._ +import sigma.util.Extensions.ByteOps +import sigma.util.FileUtil +import sigma.util.PrintExtensions._ import sigmastate.lang.Terms.{MethodCall, PropertyCall} import sigmastate.serialization.ValueSerializer._ diff --git a/sc/shared/src/main/scala/scalan/Base.scala b/sc/shared/src/main/scala/scalan/Base.scala index 708ed746fb..6d9eafa0bc 100644 --- a/sc/shared/src/main/scala/scalan/Base.scala +++ b/sc/shared/src/main/scala/scalan/Base.scala @@ -2,7 +2,7 @@ package scalan import debox.{cfor, Buffer => DBuffer} import scalan.OverloadHack.Overloaded1 -import scalan.util.StringUtil +import sigma.util.StringUtil import sigma.reflection.RConstructor import java.util.Arrays diff --git a/sc/shared/src/main/scala/scalan/Library.scala b/sc/shared/src/main/scala/scalan/Library.scala index 797d510b7b..5a6b9dbcd0 100644 --- a/sc/shared/src/main/scala/scalan/Library.scala +++ b/sc/shared/src/main/scala/scalan/Library.scala @@ -3,8 +3,7 @@ package scalan import scala.language.implicitConversions import sigma._ import special.wrappers.WrappersModule -import scalan.util.MemoizedFunc -import scalan.ExactIntegral._ +import sigma.util.MemoizedFunc trait Library extends Scalan with WrappersModule diff --git a/sc/shared/src/main/scala/scalan/MethodCalls.scala b/sc/shared/src/main/scala/scalan/MethodCalls.scala index 6c89502330..af3c3201ef 100644 --- a/sc/shared/src/main/scala/scalan/MethodCalls.scala +++ b/sc/shared/src/main/scala/scalan/MethodCalls.scala @@ -5,6 +5,7 @@ import scala.reflect.ClassTag import debox.{Buffer => DBuffer} import debox.cfor import sigma.reflection.RMethod +import sigma.util.CollectionUtil.TraversableOps trait MethodCalls extends Base { self: Scalan => @@ -62,7 +63,6 @@ trait MethodCalls extends Base { self: Scalan => ) } - import scalan.util.CollectionUtil.TraversableOps override def equals(other: Any): Boolean = (this eq other.asInstanceOf[AnyRef]) || { other match { case other: MethodCall => diff --git a/sc/shared/src/main/scala/scalan/TypeDescs.scala b/sc/shared/src/main/scala/scalan/TypeDescs.scala index 83849beb81..089f9f374e 100644 --- a/sc/shared/src/main/scala/scalan/TypeDescs.scala +++ b/sc/shared/src/main/scala/scalan/TypeDescs.scala @@ -3,12 +3,13 @@ package scalan import scala.language.implicitConversions import scala.annotation.implicitNotFound import scala.collection.immutable.ListMap -import scalan.util._ import scalan.RType._ import scala.collection.mutable import debox.cfor +import scalan.core.{Contravariant, Covariant, Variance} import sigma.reflection.{RClass, RConstructor, RMethod} +import sigma.util.CollectionUtil import special.wrappers.WrapSpec abstract class TypeDescs extends Base { self: Scalan => diff --git a/sc/shared/src/main/scala/scalan/util/Variance.scala b/sc/shared/src/main/scala/scalan/core/Variance.scala similarity index 89% rename from sc/shared/src/main/scala/scalan/util/Variance.scala rename to sc/shared/src/main/scala/scalan/core/Variance.scala index 2e0ea84841..279a8118d6 100644 --- a/sc/shared/src/main/scala/scalan/util/Variance.scala +++ b/sc/shared/src/main/scala/scalan/core/Variance.scala @@ -1,4 +1,4 @@ -package scalan.util +package scalan.core sealed trait Variance extends Product with Serializable case object Invariant extends Variance diff --git a/sc/shared/src/main/scala/scalan/meta/SSymName.scala b/sc/shared/src/main/scala/scalan/meta/SSymName.scala index 7574f8d8e2..ea9b1546ba 100644 --- a/sc/shared/src/main/scala/scalan/meta/SSymName.scala +++ b/sc/shared/src/main/scala/scalan/meta/SSymName.scala @@ -1,6 +1,6 @@ package scalan.meta -import scalan.util.StringUtil._ +import sigma.util.StringUtil.StringUtilExtensions case class ImportItem(packageName: String, importedNames: List[String]) diff --git a/sc/shared/src/main/scala/scalan/primitives/Functions.scala b/sc/shared/src/main/scala/scalan/primitives/Functions.scala index 76ec2c6d4a..830c7b3bd7 100644 --- a/sc/shared/src/main/scala/scalan/primitives/Functions.scala +++ b/sc/shared/src/main/scala/scalan/primitives/Functions.scala @@ -1,14 +1,13 @@ package scalan.primitives import java.util - import scalan.staged.ProgramGraphs -import scalan.util.GraphUtil -import scalan.{Nullable, emptyDBufferOfInt, Base, Lazy, Scalan} +import scalan.{Base, Lazy, Nullable, Scalan, emptyDBufferOfInt} import debox.{Buffer => DBuffer} import scala.language.implicitConversions import debox.cfor +import sigma.util.GraphUtil trait Functions extends Base with ProgramGraphs { self: Scalan => diff --git a/sc/shared/src/main/scala/scalan/primitives/Thunks.scala b/sc/shared/src/main/scala/scalan/primitives/Thunks.scala index 1eb598655a..ea1117215d 100644 --- a/sc/shared/src/main/scala/scalan/primitives/Thunks.scala +++ b/sc/shared/src/main/scala/scalan/primitives/Thunks.scala @@ -4,9 +4,9 @@ import scala.language.{existentials, implicitConversions} import scalan._ import debox.{Buffer => DBuffer, Set => DSet} import debox.cfor +import scalan.core.Covariant import sigma.reflection.RClass - -import scalan.util.{Covariant, GraphUtil} +import sigma.util.GraphUtil import scala.collection.Seq diff --git a/sc/shared/src/main/scala/scalan/staged/ProgramGraphs.scala b/sc/shared/src/main/scala/scalan/staged/ProgramGraphs.scala index 28b79b3530..5a5a05a459 100644 --- a/sc/shared/src/main/scala/scalan/staged/ProgramGraphs.scala +++ b/sc/shared/src/main/scala/scalan/staged/ProgramGraphs.scala @@ -1,8 +1,8 @@ package scalan.staged -import scalan.{DFunc, Scalan, Nullable} +import scalan.{DFunc, Nullable, Scalan} import debox.{Buffer => DBuffer} -import scalan.util.GraphUtil +import sigma.util.GraphUtil import debox.cfor import scala.collection.compat.immutable.ArraySeq diff --git a/sc/shared/src/main/scala/sigmastate/eval/GraphBuilding.scala b/sc/shared/src/main/scala/sigmastate/eval/GraphBuilding.scala index ea8f3bdd74..a316265fca 100644 --- a/sc/shared/src/main/scala/sigmastate/eval/GraphBuilding.scala +++ b/sc/shared/src/main/scala/sigmastate/eval/GraphBuilding.scala @@ -3,7 +3,7 @@ package sigmastate.eval import org.ergoplatform._ import scalan.ExactIntegral.{ByteIsExactIntegral, IntIsExactIntegral, LongIsExactIntegral, ShortIsExactIntegral} import scalan.ExactOrdering.{ByteIsExactOrdering, IntIsExactOrdering, LongIsExactOrdering, ShortIsExactOrdering} -import scalan.util.Extensions.ByteOps +import sigma.util.Extensions.ByteOps import scalan.{ExactIntegral, ExactNumeric, ExactOrdering, Lazy, MutableLazy, Nullable} import sigmastate.Values.Value.Typed import sigmastate.Values._ @@ -14,7 +14,8 @@ import sigmastate.serialization.OpCodes import sigmastate.utxo._ import sigmastate._ import sigmastate.basics.CryptoConstants.EcPointType -import sigmastate.exceptions.{SigmaException, GraphBuildingException} +import sigmastate.exceptions.{GraphBuildingException, SigmaException} + import scala.collection.mutable.ArrayBuffer /** Perform translation of typed expression given by [[Value]] to a graph in IRContext. diff --git a/sc/shared/src/main/scala/sigmastate/lang/SigmaTyper.scala b/sc/shared/src/main/scala/sigmastate/lang/SigmaTyper.scala index ccc0784abe..7cc5b3db08 100644 --- a/sc/shared/src/main/scala/sigmastate/lang/SigmaTyper.scala +++ b/sc/shared/src/main/scala/sigmastate/lang/SigmaTyper.scala @@ -6,7 +6,7 @@ import sigmastate.Values._ import sigmastate._ import SCollection.SBooleanArray import scalan.Nullable -import scalan.util.Extensions.Ensuring +import sigma.util.Extensions.Ensuring import sigmastate.lang.Terms._ import sigmastate.exceptions._ import sigmastate.lang.SigmaPredef._ diff --git a/sc/shared/src/main/scala/special/collection/impl/CollsImpl.scala b/sc/shared/src/main/scala/special/collection/impl/CollsImpl.scala index 33bf96a626..95acc6e74e 100644 --- a/sc/shared/src/main/scala/special/collection/impl/CollsImpl.scala +++ b/sc/shared/src/main/scala/special/collection/impl/CollsImpl.scala @@ -347,7 +347,7 @@ class CollCls extends EntityObject("Coll") { )) } - override def buildTypeArgs = super.buildTypeArgs ++ TypeArgs("A" -> (eA -> scalan.util.Invariant)) + override def buildTypeArgs = super.buildTypeArgs ++ TypeArgs("A" -> (eA -> scalan.core.Invariant)) } implicit final def collElement[A](implicit eA: Elem[A]): Elem[Coll[A]] = diff --git a/sc/shared/src/main/scala/wrappers/scala/impl/WOptionsImpl.scala b/sc/shared/src/main/scala/wrappers/scala/impl/WOptionsImpl.scala index 36abe24f96..6809984a34 100644 --- a/sc/shared/src/main/scala/wrappers/scala/impl/WOptionsImpl.scala +++ b/sc/shared/src/main/scala/wrappers/scala/impl/WOptionsImpl.scala @@ -168,7 +168,7 @@ class WOptionCls extends EntityObject("WOption") { )) } - override def buildTypeArgs = super.buildTypeArgs ++ TypeArgs("A" -> (eA -> scalan.util.Invariant)) + override def buildTypeArgs = super.buildTypeArgs ++ TypeArgs("A" -> (eA -> scalan.core.Invariant)) } implicit final def wOptionElement[A](implicit eA: Elem[A]): Elem[WOption[A]] = diff --git a/sc/shared/src/main/scala/wrappers/scalan/impl/WRTypesImpl.scala b/sc/shared/src/main/scala/wrappers/scalan/impl/WRTypesImpl.scala index 820eaf9c47..e4737589c2 100644 --- a/sc/shared/src/main/scala/wrappers/scalan/impl/WRTypesImpl.scala +++ b/sc/shared/src/main/scala/wrappers/scalan/impl/WRTypesImpl.scala @@ -99,7 +99,7 @@ class WRTypeCls extends EntityObject("WRType") { Elem.declaredWrapperMethods(_RTypeWrapSpec, RClass(classOf[WRType[A]]), Set("name")) } - override def buildTypeArgs = super.buildTypeArgs ++ TypeArgs("A" -> (eA -> scalan.util.Invariant)) + override def buildTypeArgs = super.buildTypeArgs ++ TypeArgs("A" -> (eA -> scalan.core.Invariant)) } implicit final def wRTypeElement[A](implicit eA: Elem[A]): Elem[WRType[A]] = diff --git a/sc/shared/src/test/scala/org/ergoplatform/ErgoTreePredefSpec.scala b/sc/shared/src/test/scala/org/ergoplatform/ErgoTreePredefSpec.scala index 89247a968a..6ee6e95cbe 100644 --- a/sc/shared/src/test/scala/org/ergoplatform/ErgoTreePredefSpec.scala +++ b/sc/shared/src/test/scala/org/ergoplatform/ErgoTreePredefSpec.scala @@ -7,17 +7,17 @@ import org.ergoplatform.settings.MonetarySettings import org.scalacheck.Gen import scorex.crypto.hash.Blake2b256 import scorex.util.Random -import sigmastate.Values.{SigmaPropConstant, CollectionConstant, ByteArrayConstant, IntConstant, ErgoTree} +import sigma.util.BenchmarkUtil.measure +import sigmastate.Values.{ByteArrayConstant, CollectionConstant, ErgoTree, IntConstant, SigmaPropConstant} import sigmastate._ -import sigmastate.basics.DLogProtocol.{ProveDlog, DLogProverInput} -import sigmastate.helpers.{ErgoLikeContextTesting, ErgoLikeTestInterpreter, CompilerTestingCommons, ContextEnrichingTestProvingInterpreter} +import sigmastate.basics.DLogProtocol.{DLogProverInput, ProveDlog} +import sigmastate.helpers.{CompilerTestingCommons, ContextEnrichingTestProvingInterpreter, ErgoLikeContextTesting, ErgoLikeTestInterpreter} import sigmastate.helpers.TestingHelpers._ import sigmastate.interpreter.Interpreter.{ScriptNameProp, emptyEnv} -import sigmastate.interpreter.{ProverResult, ContextExtension} +import sigmastate.interpreter.{ContextExtension, ProverResult} import sigmastate.lang.Terms.ValueOps import sigmastate.serialization.ValueSerializer -import sigmastate.utxo.{ExtractCreationInfo, ByIndex, SelectField} -import scalan.util.BenchmarkUtil._ +import sigmastate.utxo.{ByIndex, ExtractCreationInfo, SelectField} import sigmastate.eval.{Colls, Digest32Coll} import sigmastate.utils.Helpers._ diff --git a/sc/shared/src/test/scala/scalan/LibraryTests.scala b/sc/shared/src/test/scala/scalan/LibraryTests.scala index 299a1961cc..e082e9154d 100644 --- a/sc/shared/src/test/scala/scalan/LibraryTests.scala +++ b/sc/shared/src/test/scala/scalan/LibraryTests.scala @@ -1,6 +1,6 @@ package scalan -import scalan.util.BenchmarkUtil._ +import sigma.util.BenchmarkUtil.{measure, measureTime} class Benchmark[T <: Scalan](createContext: => T) { val printDebugInfo: Boolean = false diff --git a/sc/shared/src/test/scala/scalan/util/ScalaNameUtil.scala b/sc/shared/src/test/scala/scalan/core/ScalaNameUtil.scala similarity index 90% rename from sc/shared/src/test/scala/scalan/util/ScalaNameUtil.scala rename to sc/shared/src/test/scala/scalan/core/ScalaNameUtil.scala index 0f54e958c7..ac018b62a5 100644 --- a/sc/shared/src/test/scala/scalan/util/ScalaNameUtil.scala +++ b/sc/shared/src/test/scala/scalan/core/ScalaNameUtil.scala @@ -1,7 +1,7 @@ -package scalan.util +package scalan.core object ScalaNameUtil { - val opChars = Set('+', '-', '*', '/', ':', '>', '<', '=', '!', '@', '#', '%', + val opChars: Set[Char] = Set('+', '-', '*', '/', ':', '>', '<', '=', '!', '@', '#', '%', '&', '~', '?', '|', '\\', '^') def cleanNestedClassName(className: String): String = diff --git a/sc/shared/src/test/scala/scalan/util/ScalaNameUtilSuite.scala b/sc/shared/src/test/scala/scalan/core/ScalaNameUtilSuite.scala similarity index 98% rename from sc/shared/src/test/scala/scalan/util/ScalaNameUtilSuite.scala rename to sc/shared/src/test/scala/scalan/core/ScalaNameUtilSuite.scala index 3cec84bbe6..0d4e2ecbdf 100644 --- a/sc/shared/src/test/scala/scalan/util/ScalaNameUtilSuite.scala +++ b/sc/shared/src/test/scala/scalan/core/ScalaNameUtilSuite.scala @@ -1,4 +1,4 @@ -package scalan.util +package scalan.core import scalan.BaseTests import sigma.reflection.CommonReflection.registerClassEntry diff --git a/sc/shared/src/test/scala/sigmastate/TestingInterpreterSpecification.scala b/sc/shared/src/test/scala/sigmastate/TestingInterpreterSpecification.scala index 51e6fd9556..0bfe986284 100644 --- a/sc/shared/src/test/scala/sigmastate/TestingInterpreterSpecification.scala +++ b/sc/shared/src/test/scala/sigmastate/TestingInterpreterSpecification.scala @@ -1,17 +1,17 @@ package sigmastate -import sigmastate.basics.DLogProtocol.{ProveDlog, DLogProverInput} +import sigmastate.basics.DLogProtocol.{DLogProverInput, ProveDlog} import scorex.crypto.hash.Blake2b256 import sigmastate.Values._ import sigmastate.interpreter._ -import scalan.util.Extensions._ import Interpreter._ import sigmastate.lang.Terms._ import org.ergoplatform._ import org.scalatest.BeforeAndAfterAll import scorex.util.encode.Base58 +import sigma.util.Extensions.IntOps import sigmastate.basics.CryptoConstants -import sigmastate.helpers.{ErgoLikeTestInterpreter, CompilerTestingCommons, ErgoLikeContextTesting, ErgoLikeTestProvingInterpreter} +import sigmastate.helpers.{CompilerTestingCommons, ErgoLikeContextTesting, ErgoLikeTestInterpreter, ErgoLikeTestProvingInterpreter} import sigmastate.helpers.TestingHelpers._ import sigmastate.serialization.ValueSerializer import sigmastate.utils.Helpers._ diff --git a/sc/shared/src/test/scala/sigmastate/eval/EvaluationTest.scala b/sc/shared/src/test/scala/sigmastate/eval/EvaluationTest.scala index 4ef470d172..7ff3e039c5 100644 --- a/sc/shared/src/test/scala/sigmastate/eval/EvaluationTest.scala +++ b/sc/shared/src/test/scala/sigmastate/eval/EvaluationTest.scala @@ -7,7 +7,7 @@ import sigmastate.helpers.TestingHelpers._ import sigmastate.interpreter.Interpreter._ import scalan.BaseCtxTests import sigmastate.lang.LangTests -import scalan.util.BenchmarkUtil._ +import sigma.util.BenchmarkUtil._ import sigmastate._ import sigmastate.basics.DLogProtocol.{DLogProverInput, ProveDlog} import sigmastate.serialization.ErgoTreeSerializer.DefaultSerializer diff --git a/sc/shared/src/test/scala/sigmastate/eval/MeasureIRContext.scala b/sc/shared/src/test/scala/sigmastate/eval/MeasureIRContext.scala index 267fee8eff..9f88588cc9 100644 --- a/sc/shared/src/test/scala/sigmastate/eval/MeasureIRContext.scala +++ b/sc/shared/src/test/scala/sigmastate/eval/MeasureIRContext.scala @@ -1,7 +1,7 @@ package sigmastate.eval import scalan.{BaseCtxTests, Benchmark} -import scalan.util.BenchmarkUtil.measure +import sigma.util.BenchmarkUtil.measure object MeasureIRContext extends App { var ctx: RuntimeIRContext = null diff --git a/sc/shared/src/test/scala/sigmastate/helpers/CompilerTestingCommons.scala b/sc/shared/src/test/scala/sigmastate/helpers/CompilerTestingCommons.scala index ab4df0c3f2..1a750f3a19 100644 --- a/sc/shared/src/test/scala/sigmastate/helpers/CompilerTestingCommons.scala +++ b/sc/shared/src/test/scala/sigmastate/helpers/CompilerTestingCommons.scala @@ -6,7 +6,7 @@ import org.ergoplatform.validation.{ValidationException, ValidationSpecification import org.scalacheck.Arbitrary.arbByte import org.scalacheck.Gen import org.scalatest.Assertion -import scalan.util.BenchmarkUtil +import sigma.util.BenchmarkUtil import scalan.{RType, TestContexts, TestUtils} import sigmastate.Values.{Constant, ErgoTree, SValue, SigmaBoolean, SigmaPropValue} import sigmastate.eval._ diff --git a/sc/shared/src/test/scala/sigmastate/serialization/DeserializationResilience.scala b/sc/shared/src/test/scala/sigmastate/serialization/DeserializationResilience.scala index 24bdbb8ca4..d7ae2af6b4 100644 --- a/sc/shared/src/test/scala/sigmastate/serialization/DeserializationResilience.scala +++ b/sc/shared/src/test/scala/sigmastate/serialization/DeserializationResilience.scala @@ -4,7 +4,7 @@ import org.ergoplatform.validation.ValidationException import org.ergoplatform.validation.ValidationRules.CheckPositionLimit import org.ergoplatform.{ErgoBoxCandidate, Outputs} import org.scalacheck.Gen -import scalan.util.BenchmarkUtil +import sigma.util.BenchmarkUtil import scorex.crypto.authds.avltree.batch.{BatchAVLProver, Insert} import scorex.crypto.authds.{ADKey, ADValue} import scorex.crypto.hash.{Blake2b256, Digest32} diff --git a/sc/shared/src/test/scala/sigmastate/utils/GenInfoObjects.scala b/sc/shared/src/test/scala/sigmastate/utils/GenInfoObjects.scala index 41579fae61..9ebdce9f31 100644 --- a/sc/shared/src/test/scala/sigmastate/utils/GenInfoObjects.scala +++ b/sc/shared/src/test/scala/sigmastate/utils/GenInfoObjects.scala @@ -1,7 +1,7 @@ package sigmastate.utils import sigmastate.SMethod -import scalan.util.PrintExtensions._ +import sigma.util.PrintExtensions._ import scala.util.Try import Helpers._ // required for Scala 2.11 diff --git a/sc/shared/src/test/scala/sigmastate/utils/SpecGen.scala b/sc/shared/src/test/scala/sigmastate/utils/SpecGen.scala index cd2106e5c0..7eccb1dd00 100644 --- a/sc/shared/src/test/scala/sigmastate/utils/SpecGen.scala +++ b/sc/shared/src/test/scala/sigmastate/utils/SpecGen.scala @@ -1,17 +1,18 @@ package sigmastate.utils +import sigma.util.PrintExtensions.IterableExtensions import sigmastate._ import sigmastate.eval.Evaluation._ -import scalan.util.Extensions.ByteOps -import scalan.util.CollectionUtil -import scalan.util.PrintExtensions._ +import sigma.util.Extensions.ByteOps +import sigma.util.CollectionUtil +import sigma.util.PrintExtensions._ import sigmastate.Values._ -import sigmastate.lang.SigmaPredef.{PredefinedFuncRegistry, PredefinedFunc} +import sigmastate.lang.SigmaPredef.{PredefinedFunc, PredefinedFuncRegistry} import sigmastate.lang.StdSigmaBuilder import sigmastate.lang.Terms.{MethodCall, PropertyCall} import sigmastate.serialization.OpCodes.OpCode -import sigmastate.serialization.{ValueSerializer, OpCodes} -import sigmastate.utxo.{SigmaPropIsProven, SelectField} +import sigmastate.serialization.{OpCodes, ValueSerializer} +import sigmastate.utxo.{SelectField, SigmaPropIsProven} object SpecGenUtils { val types = SType.allPredefTypes.diff(Seq(SString)) diff --git a/sc/shared/src/test/scala/sigmastate/utxo/BasicOpsSpecification.scala b/sc/shared/src/test/scala/sigmastate/utxo/BasicOpsSpecification.scala index 9372a59e5e..efdae595ff 100644 --- a/sc/shared/src/test/scala/sigmastate/utxo/BasicOpsSpecification.scala +++ b/sc/shared/src/test/scala/sigmastate/utxo/BasicOpsSpecification.scala @@ -19,7 +19,7 @@ import sigmastate.interpreter.ContextExtension.VarBinding import sigmastate.interpreter.ErgoTreeEvaluator.DefaultEvalSettings import sigmastate.interpreter.EvalSettings import sigmastate.utils.Helpers._ -import scalan.util.StringUtil._ +import sigma.util.StringUtil._ class BasicOpsSpecification extends CompilerTestingCommons with CompilerCrossVersionProps { diff --git a/sc/shared/src/test/scala/sigmastate/utxo/SerializationRoundTripSpec.scala b/sc/shared/src/test/scala/sigmastate/utxo/SerializationRoundTripSpec.scala index 519a938160..660e772c03 100644 --- a/sc/shared/src/test/scala/sigmastate/utxo/SerializationRoundTripSpec.scala +++ b/sc/shared/src/test/scala/sigmastate/utxo/SerializationRoundTripSpec.scala @@ -1,7 +1,7 @@ package sigmastate.utxo import org.ergoplatform._ -import scalan.util.BenchmarkUtil +import sigma.util.BenchmarkUtil import sigmastate.helpers.CompilerTestingCommons import sigmastate.interpreter.{ContextExtension, ProverResult} import sigmastate.serialization.generators.ObjectGenerators diff --git a/sc/shared/src/test/scala/special/sigma/DataValueComparerSpecification.scala b/sc/shared/src/test/scala/special/sigma/DataValueComparerSpecification.scala index 3a4b639306..697823e50f 100644 --- a/sc/shared/src/test/scala/special/sigma/DataValueComparerSpecification.scala +++ b/sc/shared/src/test/scala/special/sigma/DataValueComparerSpecification.scala @@ -2,7 +2,7 @@ package sigma import org.scalatest.BeforeAndAfterAll import scalan.RType -import scalan.util.BenchmarkUtil +import sigma.util.BenchmarkUtil import sigmastate.{DataValueComparer, JitCost, TrivialProp} import sigmastate.Values.ErgoTree import sigmastate.eval.{CSigmaProp, Profiler, SigmaDsl} diff --git a/sc/shared/src/test/scala/special/sigma/SigmaDslSpecification.scala b/sc/shared/src/test/scala/special/sigma/SigmaDslSpecification.scala index 591f2ca47b..523d0af2af 100644 --- a/sc/shared/src/test/scala/special/sigma/SigmaDslSpecification.scala +++ b/sc/shared/src/test/scala/special/sigma/SigmaDslSpecification.scala @@ -6,9 +6,9 @@ import org.ergoplatform.settings.ErgoAlgos import org.scalacheck.{Arbitrary, Gen} import scalan.{ExactIntegral, ExactNumeric, ExactOrdering, RType} import scorex.crypto.authds.avltree.batch._ -import scorex.crypto.authds.{ADDigest, ADKey, ADValue} +import scorex.crypto.authds.{ADKey, ADValue} import scorex.crypto.hash.{Blake2b256, Digest32} -import scalan.util.Extensions._ +import sigma.util.Extensions._ import sigmastate.utils.Extensions._ import sigmastate.SCollection._ import sigmastate.Values.IntConstant diff --git a/sc/shared/src/test/scala/special/sigma/SigmaDslTesting.scala b/sc/shared/src/test/scala/special/sigma/SigmaDslTesting.scala index 81ec1ced50..1b0da1058d 100644 --- a/sc/shared/src/test/scala/special/sigma/SigmaDslTesting.scala +++ b/sc/shared/src/test/scala/special/sigma/SigmaDslTesting.scala @@ -15,11 +15,10 @@ import org.scalatestplus.scalacheck.ScalaCheckPropertyChecks import scalan.Platform.threadSleepOrNoOp import scalan.RType import scalan.RType._ -import scalan.util.BenchmarkUtil -import scalan.util.CollectionUtil._ -import scalan.util.Extensions._ -import scalan.util.StringUtil.StringUtilExtensions -import sigma.VersionContext +import sigma.util.BenchmarkUtil +import sigma.util.CollectionUtil._ +import sigma.util.Extensions._ +import sigma.util.StringUtil.StringUtilExtensions import sigmastate.SType.AnyOps import sigmastate.Values.{ByteArrayConstant, Constant, ConstantNode, ErgoTree, IntConstant, SValue} import sigmastate.basics.DLogProtocol.{DLogProverInput, ProveDlog} diff --git a/sdk/shared/src/main/scala/org/ergoplatform/sdk/AppkitProvingInterpreter.scala b/sdk/shared/src/main/scala/org/ergoplatform/sdk/AppkitProvingInterpreter.scala index f745103cab..6c16ad1e2e 100644 --- a/sdk/shared/src/main/scala/org/ergoplatform/sdk/AppkitProvingInterpreter.scala +++ b/sdk/shared/src/main/scala/org/ergoplatform/sdk/AppkitProvingInterpreter.scala @@ -8,7 +8,7 @@ import org.ergoplatform.sdk.utils.ArithUtils import org.ergoplatform.sdk.wallet.protocol.context.{BlockchainStateContext, TransactionContext} import org.ergoplatform.sdk.wallet.secrets.ExtendedSecretKey import org.ergoplatform.validation.ValidationRules -import scalan.util.Extensions.LongOps +import sigma.util.Extensions.LongOps import sigma.VersionContext import sigmastate.Values.SigmaBoolean import sigmastate.basics.DLogProtocol.{DLogProverInput, ProveDlog} @@ -17,7 +17,7 @@ import sigmastate.interpreter.Interpreter.{ReductionResult, estimateCryptoVerify import sigmastate.interpreter._ import sigmastate.serialization.SigmaSerializer import sigmastate.utils.{SigmaByteReader, SigmaByteWriter} -import sigmastate.{AvlTreeData} +import sigmastate.AvlTreeData import java.util import java.util.{Objects, List => JList} diff --git a/sdk/shared/src/main/scala/org/ergoplatform/sdk/JavaHelpers.scala b/sdk/shared/src/main/scala/org/ergoplatform/sdk/JavaHelpers.scala index 884e987376..7a76539ac8 100644 --- a/sdk/shared/src/main/scala/org/ergoplatform/sdk/JavaHelpers.scala +++ b/sdk/shared/src/main/scala/org/ergoplatform/sdk/JavaHelpers.scala @@ -27,7 +27,7 @@ import org.ergoplatform.sdk.Extensions.{CollBuilderOps, PairCollOps} import org.ergoplatform.sdk.wallet.{Constants, TokensMap} import org.ergoplatform.sdk.wallet.secrets.{DerivationPath, ExtendedSecretKey} import scalan.ExactIntegral.LongIsExactIntegral -import scalan.util.StringUtil.StringUtilExtensions +import sigma.util.StringUtil.StringUtilExtensions import sigmastate.basics.CryptoConstants.EcPointType import sigmastate.basics.{DiffieHellmanTupleProverInput, ProveDHTuple} import sigmastate.crypto.CryptoFacade diff --git a/sdk/shared/src/main/scala/org/ergoplatform/sdk/ReducingInterpreter.scala b/sdk/shared/src/main/scala/org/ergoplatform/sdk/ReducingInterpreter.scala index f06c37fd39..1e73c49640 100644 --- a/sdk/shared/src/main/scala/org/ergoplatform/sdk/ReducingInterpreter.scala +++ b/sdk/shared/src/main/scala/org/ergoplatform/sdk/ReducingInterpreter.scala @@ -6,8 +6,7 @@ import org.ergoplatform.sdk.utils.ArithUtils import org.ergoplatform.sdk.wallet.protocol.context.{BlockchainStateContext, TransactionContext} import org.ergoplatform.validation.ValidationRules import org.ergoplatform.{ErgoLikeContext, ErgoLikeInterpreter} -import scalan.util.Extensions.LongOps -import scorex.crypto.authds.ADDigest +import sigma.util.Extensions.LongOps import sigmastate.AvlTreeData import sigmastate.Values.ErgoTree import sigmastate.eval.Evaluation.addCostChecked diff --git a/sdk/shared/src/test/scala/org/ergoplatform/sdk/multisig/SigningSpec.scala b/sdk/shared/src/test/scala/org/ergoplatform/sdk/multisig/SigningSpec.scala index e45fd0d8dd..1d0866d440 100644 --- a/sdk/shared/src/test/scala/org/ergoplatform/sdk/multisig/SigningSpec.scala +++ b/sdk/shared/src/test/scala/org/ergoplatform/sdk/multisig/SigningSpec.scala @@ -8,7 +8,7 @@ import org.ergoplatform.sdk.{BlockchainContext, BlockchainParameters, ExtendedIn import org.scalatest.matchers.should.Matchers import org.scalatest.propspec.AnyPropSpec import org.scalatestplus.scalacheck.ScalaCheckPropertyChecks -import scalan.util.CollectionUtil.AnyOps +import sigma.util.CollectionUtil.AnyOps import sigmastate.TestsBase import sigmastate.Values.{Constant, ErgoTree} import sigma.SigmaTestingData From 3bbc1e46885c87bb2ad979120bfba625be311e03 Mon Sep 17 00:00:00 2001 From: Alexander Slesarenko Date: Wed, 23 Aug 2023 02:21:19 +0200 Subject: [PATCH 12/37] minimize-modules: move from scalan to sigma.core --- .../scala/{scalan => sigma}/reflection/Platform.scala | 0 .../scala/{scalan => sigma}/reflection/JavaImpl.scala | 0 .../scala/{scalan => sigma}/reflection/Platform.scala | 0 common/jvm/src/test/scala/sigma/util/FileUtilTests.scala | 2 +- common/shared/src/main/scala/sigma/CollType.scala | 2 +- common/shared/src/main/scala/sigma/Colls.scala | 2 +- common/shared/src/main/scala/sigma/CollsOverArrays.scala | 6 +++--- .../shared/src/main/scala/sigma/CoreLibReflection.scala | 2 +- common/shared/src/main/scala/sigma/SigmaDsl.scala | 2 +- common/shared/src/main/scala/sigma/TupleType.scala | 4 ++-- .../src/main/scala/{scalan => sigma/core}/AnyVals.scala | 2 +- .../src/main/scala/{scalan => sigma/core}/DFunc.scala | 2 +- .../main/scala/{scalan => sigma/core}/ExactIntegral.scala | 2 +- .../main/scala/{scalan => sigma/core}/ExactNumeric.scala | 4 ++-- .../main/scala/{scalan => sigma/core}/ExactOrdering.scala | 2 +- .../src/main/scala/{scalan => sigma/core}/Lazy.scala | 2 +- .../main/scala/{scalan => sigma/core}/OverloadHack.scala | 2 +- .../src/main/scala/{scalan => sigma/core}/RType.scala | 2 +- .../src/main/scala/{scalan => sigma/core}/package.scala | 4 +++- common/shared/src/main/scala/sigma/package.scala | 4 ++-- common/shared/src/main/scala/sigma/util/GraphUtil.scala | 2 +- .../shared/src/main/scala/sigma/util/MemoizedFunc.scala | 2 +- .../src/test/scala/{scalan => sigma}/BaseTests.scala | 2 +- .../src/test/scala/{scalan => sigma}/TestUtils.scala | 2 +- common/shared/src/test/scala/sigma/TypesTests.scala | 4 ++-- .../shared/src/test/scala/sigma/collection/CollGens.scala | 4 ++-- .../src/test/scala/sigma/collection/CollsTests.scala | 2 +- .../test/scala/{scalan => sigma}/util/BenchmarkUtil.scala | 0 .../{scalan => sigma}/util/CollectionUtilTests.scala | 2 +- .../scala/{scalan => sigma}/util/GraphUtilTests.scala | 3 ++- .../scala/{scalan => sigma}/util/PrintExtensions.scala | 0 .../scala/{scalan => sigma}/util/StringUtilTests.scala | 2 +- .../util/StronglyConnectedComponentsTests.scala | 2 +- interpreter/js/src/main/scala/sigmastate/Platform.scala | 2 +- .../js/src/main/scala/sigmastate/crypto/Platform.scala | 2 +- interpreter/jvm/src/main/scala/sigmastate/Platform.scala | 2 +- .../jvm/src/main/scala/sigmastate/crypto/Platform.scala | 2 +- .../src/main/scala/sigmastate/DataValueComparer.scala | 4 ++-- interpreter/shared/src/main/scala/sigmastate/Values.scala | 2 +- .../src/main/scala/sigmastate/eval/BigIntegerOps.scala | 2 +- .../main/scala/sigmastate/eval/CostingDataContext.scala | 4 ++-- .../src/main/scala/sigmastate/eval/Evaluation.scala | 4 ++-- .../src/main/scala/sigmastate/eval/Extensions.scala | 2 +- .../shared/src/main/scala/sigmastate/eval/package.scala | 2 +- .../src/main/scala/sigmastate/lang/SigmaBuilder.scala | 2 +- .../src/main/scala/sigmastate/lang/SigmaPredef.scala | 2 +- .../shared/src/main/scala/sigmastate/lang/Terms.scala | 2 +- .../scala/sigmastate/serialization/DataSerializer.scala | 2 +- interpreter/shared/src/main/scala/sigmastate/trees.scala | 8 ++++---- interpreter/shared/src/main/scala/sigmastate/types.scala | 4 ++-- .../shared/src/main/scala/sigmastate/utils/Helpers.scala | 2 +- .../src/main/scala/sigmastate/utxo/transformers.scala | 2 +- .../src/test/scala/sigmastate/lang/SigmaBuilderTest.scala | 2 +- .../serialization/ConstantSerializerSpecification.scala | 2 +- .../serialization/DataSerializerSpecification.scala | 2 +- .../serialization/generators/ObjectGenerators.scala | 2 +- .../src/test/scala/special/sigma/ContractsTestkit.scala | 4 ++-- .../src/test/scala/special/sigma/SigmaTestingData.scala | 2 +- .../src/main/scala/sigmastate/lang/SigmaParser.scala | 2 +- .../src/main/scala/sigmastate/lang/syntax/Basic.scala | 2 +- .../src/test/scala/sigmastate/ReflectionGenerator.scala | 3 +-- .../test/scala/sigmastate/helpers/SigmaPPrintSpec.scala | 2 +- .../src/test/scala/special/collections/MapBenchmark.scala | 2 +- .../main/scala/org/ergoplatform/dsl/ContractSpec.scala | 2 +- .../main/scala/org/ergoplatform/dsl/ContractSyntax.scala | 2 +- sc/shared/src/main/scala/scalan/Base.scala | 3 ++- sc/shared/src/main/scala/scalan/DefRewriting.scala | 2 ++ sc/shared/src/main/scala/scalan/GraphIRReflection.scala | 1 + sc/shared/src/main/scala/scalan/Library.scala | 1 + sc/shared/src/main/scala/scalan/TypeDescs.scala | 5 +++-- .../src/main/scala/scalan/primitives/Functions.scala | 3 ++- .../src/main/scala/scalan/primitives/NumericOps.scala | 3 ++- .../src/main/scala/scalan/primitives/OrderingOps.scala | 4 +++- sc/shared/src/main/scala/scalan/primitives/Thunks.scala | 3 ++- sc/shared/src/main/scala/scalan/primitives/Tuples.scala | 3 ++- sc/shared/src/main/scala/scalan/staged/AstGraphs.scala | 5 +++-- .../src/main/scala/scalan/staged/ProgramGraphs.scala | 4 ++-- sc/shared/src/main/scala/scalan/staged/Transforming.scala | 3 ++- .../src/main/scala/sigmastate/eval/GraphBuilding.scala | 7 ++++--- .../src/main/scala/sigmastate/lang/SigmaBinder.scala | 2 +- sc/shared/src/main/scala/sigmastate/lang/SigmaTyper.scala | 2 +- .../main/scala/special/collection/impl/CollsImpl.scala | 1 + .../src/main/scala/special/sigma/impl/SigmaDslImpl.scala | 1 + .../src/main/scala/special/wrappers/WrappersSpec.scala | 2 +- .../src/main/scala/wrappers/scala/impl/WOptionsImpl.scala | 1 + sc/shared/src/main/scala/wrappers/scalan/WRTypes.scala | 2 +- .../src/main/scala/wrappers/scalan/impl/WRTypesImpl.scala | 2 +- .../scala/wrappers/special/impl/WSpecialPredefsImpl.scala | 1 + .../scala/org/ergoplatform/dsl/TestContractSpec.scala | 2 +- sc/shared/src/test/scala/scalan/TestContexts.scala | 2 +- .../src/test/scala/scalan/core/ScalaNameUtilSuite.scala | 2 +- .../src/test/scala/sigmastate/ErgoTreeSpecification.scala | 4 ++-- .../scala/sigmastate/helpers/CompilerTestingCommons.scala | 4 +++- .../src/test/scala/sigmastate/helpers/SigmaPPrint.scala | 4 ++-- .../scala/sigmastate/utxo/BasicOpsSpecification.scala | 2 +- .../special/sigma/DataValueComparerSpecification.scala | 2 +- .../test/scala/special/sigma/SigmaDslSpecification.scala | 4 ++-- .../src/test/scala/special/sigma/SigmaDslTesting.scala | 4 ++-- .../src/test/scala/special/wrappers/WRTypeTests.scala | 2 +- .../test/scala/special/wrappers/WSpecialPredefTests.scala | 2 +- sdk/js/src/main/scala/org/ergoplatform/sdk/js/Isos.scala | 2 +- sdk/js/src/main/scala/org/ergoplatform/sdk/js/Type.scala | 2 +- sdk/js/src/main/scala/org/ergoplatform/sdk/js/Value.scala | 4 ++-- .../main/scala/org/ergoplatform/sdk/DataJsonEncoder.scala | 2 +- .../src/main/scala/org/ergoplatform/sdk/Extensions.scala | 4 ++-- .../src/main/scala/org/ergoplatform/sdk/JavaHelpers.scala | 4 ++-- .../main/scala/org/ergoplatform/sdk/OutBoxBuilder.scala | 2 +- .../src/main/scala/org/ergoplatform/sdk/Utils.scala | 2 +- .../src/main/scala/org/ergoplatform/sdk/utils/Zero.scala | 4 ++-- .../ergoplatform/sdk/DataJsonEncoderSpecification.scala | 2 +- .../test/scala/org/ergoplatform/sdk/ExtensionsSpec.scala | 2 +- 111 files changed, 151 insertions(+), 128 deletions(-) rename common/js/src/main/scala/{scalan => sigma}/reflection/Platform.scala (100%) rename common/jvm/src/main/scala/{scalan => sigma}/reflection/JavaImpl.scala (100%) rename common/jvm/src/main/scala/{scalan => sigma}/reflection/Platform.scala (100%) rename common/shared/src/main/scala/{scalan => sigma/core}/AnyVals.scala (99%) rename common/shared/src/main/scala/{scalan => sigma/core}/DFunc.scala (89%) rename common/shared/src/main/scala/{scalan => sigma/core}/ExactIntegral.scala (99%) rename common/shared/src/main/scala/{scalan => sigma/core}/ExactNumeric.scala (96%) rename common/shared/src/main/scala/{scalan => sigma/core}/ExactOrdering.scala (98%) rename common/shared/src/main/scala/{scalan => sigma/core}/Lazy.scala (96%) rename common/shared/src/main/scala/{scalan => sigma/core}/OverloadHack.scala (97%) rename common/shared/src/main/scala/{scalan => sigma/core}/RType.scala (99%) rename common/shared/src/main/scala/{scalan => sigma/core}/package.scala (96%) rename common/shared/src/test/scala/{scalan => sigma}/BaseTests.scala (98%) rename common/shared/src/test/scala/{scalan => sigma}/TestUtils.scala (98%) rename common/shared/src/test/scala/{scalan => sigma}/util/BenchmarkUtil.scala (100%) rename common/shared/src/test/scala/{scalan => sigma}/util/CollectionUtilTests.scala (99%) rename common/shared/src/test/scala/{scalan => sigma}/util/GraphUtilTests.scala (96%) rename common/shared/src/test/scala/{scalan => sigma}/util/PrintExtensions.scala (100%) rename common/shared/src/test/scala/{scalan => sigma}/util/StringUtilTests.scala (87%) rename common/shared/src/test/scala/{scalan => sigma}/util/StronglyConnectedComponentsTests.scala (77%) diff --git a/common/js/src/main/scala/scalan/reflection/Platform.scala b/common/js/src/main/scala/sigma/reflection/Platform.scala similarity index 100% rename from common/js/src/main/scala/scalan/reflection/Platform.scala rename to common/js/src/main/scala/sigma/reflection/Platform.scala diff --git a/common/jvm/src/main/scala/scalan/reflection/JavaImpl.scala b/common/jvm/src/main/scala/sigma/reflection/JavaImpl.scala similarity index 100% rename from common/jvm/src/main/scala/scalan/reflection/JavaImpl.scala rename to common/jvm/src/main/scala/sigma/reflection/JavaImpl.scala diff --git a/common/jvm/src/main/scala/scalan/reflection/Platform.scala b/common/jvm/src/main/scala/sigma/reflection/Platform.scala similarity index 100% rename from common/jvm/src/main/scala/scalan/reflection/Platform.scala rename to common/jvm/src/main/scala/sigma/reflection/Platform.scala diff --git a/common/jvm/src/test/scala/sigma/util/FileUtilTests.scala b/common/jvm/src/test/scala/sigma/util/FileUtilTests.scala index 419a18a0ce..9b6eddb0a7 100644 --- a/common/jvm/src/test/scala/sigma/util/FileUtilTests.scala +++ b/common/jvm/src/test/scala/sigma/util/FileUtilTests.scala @@ -1,6 +1,6 @@ package sigma.util -import scalan.BaseNestedTests +import sigma.BaseNestedTests class FileUtilTests extends BaseNestedTests { import FileUtil._ diff --git a/common/shared/src/main/scala/sigma/CollType.scala b/common/shared/src/main/scala/sigma/CollType.scala index c2ff828edf..7af67852fe 100644 --- a/common/shared/src/main/scala/sigma/CollType.scala +++ b/common/shared/src/main/scala/sigma/CollType.scala @@ -1,6 +1,6 @@ package sigma -import scalan.RType +import sigma.core.RType import scala.language.implicitConversions import scala.reflect.ClassTag diff --git a/common/shared/src/main/scala/sigma/Colls.scala b/common/shared/src/main/scala/sigma/Colls.scala index 022f5843ec..874e116d3f 100644 --- a/common/shared/src/main/scala/sigma/Colls.scala +++ b/common/shared/src/main/scala/sigma/Colls.scala @@ -1,6 +1,6 @@ package sigma -import scalan._ +import sigma.core.RType /** Indexed (zero-based) collection of elements of type `A`. * NOTE: declaring it `abstract class` makes some performance benefits, but doesn't work diff --git a/common/shared/src/main/scala/sigma/CollsOverArrays.scala b/common/shared/src/main/scala/sigma/CollsOverArrays.scala index c93fbebb0f..cbc8bc7bdf 100644 --- a/common/shared/src/main/scala/sigma/CollsOverArrays.scala +++ b/common/shared/src/main/scala/sigma/CollsOverArrays.scala @@ -1,10 +1,10 @@ package sigma -import scalan._ // required +import sigma.core._ import sigma.util.CollectionUtil -import scalan.RType +import sigma.core.RType import debox.Buffer -import scalan.RType._ +import sigma.core.RType._ import sigma.util.{MaxArrayLength, safeConcatArrays_v5} import debox.cfor diff --git a/common/shared/src/main/scala/sigma/CoreLibReflection.scala b/common/shared/src/main/scala/sigma/CoreLibReflection.scala index ae50557abc..989b3dd66f 100644 --- a/common/shared/src/main/scala/sigma/CoreLibReflection.scala +++ b/common/shared/src/main/scala/sigma/CoreLibReflection.scala @@ -1,6 +1,6 @@ package sigma -import scalan.RType +import sigma.core.RType import sigma.reflection.CommonReflection.registerClassEntry import sigma.reflection._ diff --git a/common/shared/src/main/scala/sigma/SigmaDsl.scala b/common/shared/src/main/scala/sigma/SigmaDsl.scala index 894ca6ca50..91d49cc7cd 100644 --- a/common/shared/src/main/scala/sigma/SigmaDsl.scala +++ b/common/shared/src/main/scala/sigma/SigmaDsl.scala @@ -2,7 +2,7 @@ package sigma import java.math.BigInteger -import scalan._ +import sigma.core._ import scorex.crypto.authds.{ADDigest, ADValue} import scorex.crypto.authds.avltree.batch.Operation diff --git a/common/shared/src/main/scala/sigma/TupleType.scala b/common/shared/src/main/scala/sigma/TupleType.scala index a6261d29d4..abe91608cb 100644 --- a/common/shared/src/main/scala/sigma/TupleType.scala +++ b/common/shared/src/main/scala/sigma/TupleType.scala @@ -1,7 +1,7 @@ package sigma -import scalan.RType -import scalan.RType.SomeType +import sigma.core.RType +import sigma.core.RType.SomeType import sigma.util.CollectionUtil import scala.reflect.ClassTag diff --git a/common/shared/src/main/scala/scalan/AnyVals.scala b/common/shared/src/main/scala/sigma/core/AnyVals.scala similarity index 99% rename from common/shared/src/main/scala/scalan/AnyVals.scala rename to common/shared/src/main/scala/sigma/core/AnyVals.scala index ca0887401e..763048ce9c 100644 --- a/common/shared/src/main/scala/scalan/AnyVals.scala +++ b/common/shared/src/main/scala/sigma/core/AnyVals.scala @@ -1,4 +1,4 @@ -package scalan +package sigma.core import java.util.HashMap diff --git a/common/shared/src/main/scala/scalan/DFunc.scala b/common/shared/src/main/scala/sigma/core/DFunc.scala similarity index 89% rename from common/shared/src/main/scala/scalan/DFunc.scala rename to common/shared/src/main/scala/sigma/core/DFunc.scala index 23f4766fa8..29ab5cf1b5 100644 --- a/common/shared/src/main/scala/scalan/DFunc.scala +++ b/common/shared/src/main/scala/sigma/core/DFunc.scala @@ -1,4 +1,4 @@ -package scalan +package sigma.core /** Function interface which support specialization and thus unboxed invocations. */ abstract class DFunc[@specialized(Int) A, B] { diff --git a/common/shared/src/main/scala/scalan/ExactIntegral.scala b/common/shared/src/main/scala/sigma/core/ExactIntegral.scala similarity index 99% rename from common/shared/src/main/scala/scalan/ExactIntegral.scala rename to common/shared/src/main/scala/sigma/core/ExactIntegral.scala index 48dba05f9b..e8092789fd 100644 --- a/common/shared/src/main/scala/scalan/ExactIntegral.scala +++ b/common/shared/src/main/scala/sigma/core/ExactIntegral.scala @@ -1,4 +1,4 @@ -package scalan +package sigma.core import sigma.util.Extensions.{ByteOps, ShortOps} diff --git a/common/shared/src/main/scala/scalan/ExactNumeric.scala b/common/shared/src/main/scala/sigma/core/ExactNumeric.scala similarity index 96% rename from common/shared/src/main/scala/scalan/ExactNumeric.scala rename to common/shared/src/main/scala/sigma/core/ExactNumeric.scala index 5967785de5..75a33d11a1 100644 --- a/common/shared/src/main/scala/scalan/ExactNumeric.scala +++ b/common/shared/src/main/scala/sigma/core/ExactNumeric.scala @@ -1,6 +1,6 @@ -package scalan +package sigma.core -import scalan.ExactIntegral._ +import sigma.core.ExactIntegral._ /** Numeric operations with overflow checks. * Raise exception when overflow is detected. diff --git a/common/shared/src/main/scala/scalan/ExactOrdering.scala b/common/shared/src/main/scala/sigma/core/ExactOrdering.scala similarity index 98% rename from common/shared/src/main/scala/scalan/ExactOrdering.scala rename to common/shared/src/main/scala/sigma/core/ExactOrdering.scala index a727233588..95264cb979 100644 --- a/common/shared/src/main/scala/scalan/ExactOrdering.scala +++ b/common/shared/src/main/scala/sigma/core/ExactOrdering.scala @@ -1,4 +1,4 @@ -package scalan +package sigma.core import scala.math.Numeric.{ByteIsIntegral, LongIsIntegral, ShortIsIntegral, IntIsIntegral} diff --git a/common/shared/src/main/scala/scalan/Lazy.scala b/common/shared/src/main/scala/sigma/core/Lazy.scala similarity index 96% rename from common/shared/src/main/scala/scalan/Lazy.scala rename to common/shared/src/main/scala/sigma/core/Lazy.scala index bb0495fb5a..2e4c8efdca 100644 --- a/common/shared/src/main/scala/scalan/Lazy.scala +++ b/common/shared/src/main/scala/sigma/core/Lazy.scala @@ -1,4 +1,4 @@ -package scalan +package sigma.core /** Non-thread safe (but efficient on single thread) immutable lazy value. * The `block` is executed only once. */ diff --git a/common/shared/src/main/scala/scalan/OverloadHack.scala b/common/shared/src/main/scala/sigma/core/OverloadHack.scala similarity index 97% rename from common/shared/src/main/scala/scalan/OverloadHack.scala rename to common/shared/src/main/scala/sigma/core/OverloadHack.scala index 81d92e6f0f..88663fd32d 100644 --- a/common/shared/src/main/scala/scalan/OverloadHack.scala +++ b/common/shared/src/main/scala/sigma/core/OverloadHack.scala @@ -1,4 +1,4 @@ -package scalan +package sigma.core /** Scala specific trick to appease erasure of methods argument types. * Example usage: diff --git a/common/shared/src/main/scala/scalan/RType.scala b/common/shared/src/main/scala/sigma/core/RType.scala similarity index 99% rename from common/shared/src/main/scala/scalan/RType.scala rename to common/shared/src/main/scala/sigma/core/RType.scala index 98ecb1ec4c..2fbdb43454 100644 --- a/common/shared/src/main/scala/scalan/RType.scala +++ b/common/shared/src/main/scala/sigma/core/RType.scala @@ -1,4 +1,4 @@ -package scalan +package sigma.core import scala.reflect.ClassTag import scala.annotation.{implicitNotFound, unused} diff --git a/common/shared/src/main/scala/scalan/package.scala b/common/shared/src/main/scala/sigma/core/package.scala similarity index 96% rename from common/shared/src/main/scala/scalan/package.scala rename to common/shared/src/main/scala/sigma/core/package.scala index 1a25931fd6..4ad876fc2c 100644 --- a/common/shared/src/main/scala/scalan/package.scala +++ b/common/shared/src/main/scala/sigma/core/package.scala @@ -1,7 +1,9 @@ +package sigma + import scala.reflect.ClassTag -package object scalan { +package object core { /** Allows implicit resolution to find appropriate instance of ClassTag in * the scope where RType is implicitly available. */ diff --git a/common/shared/src/main/scala/sigma/package.scala b/common/shared/src/main/scala/sigma/package.scala index f6ec47bb70..df7b301f85 100644 --- a/common/shared/src/main/scala/sigma/package.scala +++ b/common/shared/src/main/scala/sigma/package.scala @@ -1,7 +1,7 @@ import java.math.BigInteger -import scalan.RType -import scalan.RType.{GeneralType, SomeType} +import sigma.core.RType +import sigma.core.RType.{GeneralType, SomeType} import scala.reflect.classTag diff --git a/common/shared/src/main/scala/sigma/util/GraphUtil.scala b/common/shared/src/main/scala/sigma/util/GraphUtil.scala index b8cb9a0edb..dafbda3244 100644 --- a/common/shared/src/main/scala/sigma/util/GraphUtil.scala +++ b/common/shared/src/main/scala/sigma/util/GraphUtil.scala @@ -1,6 +1,6 @@ package sigma.util -import scalan.DFunc +import sigma.core.DFunc import debox.{Set => DSet, Buffer => DBuffer} import debox.cfor import scala.reflect.ClassTag diff --git a/common/shared/src/main/scala/sigma/util/MemoizedFunc.scala b/common/shared/src/main/scala/sigma/util/MemoizedFunc.scala index 5960cc5366..0ae516ea02 100644 --- a/common/shared/src/main/scala/sigma/util/MemoizedFunc.scala +++ b/common/shared/src/main/scala/sigma/util/MemoizedFunc.scala @@ -1,6 +1,6 @@ package sigma.util -import scalan.AVHashMap +import sigma.core.AVHashMap /** Transforms a given function into memoized equivalent function. * Memoization is implemented by computing function f only once for each diff --git a/common/shared/src/test/scala/scalan/BaseTests.scala b/common/shared/src/test/scala/sigma/BaseTests.scala similarity index 98% rename from common/shared/src/test/scala/scalan/BaseTests.scala rename to common/shared/src/test/scala/sigma/BaseTests.scala index e015ff948e..9ea0fcaf56 100644 --- a/common/shared/src/test/scala/scalan/BaseTests.scala +++ b/common/shared/src/test/scala/sigma/BaseTests.scala @@ -1,4 +1,4 @@ -package scalan +package sigma import org.scalatest.flatspec.AnyFlatSpec import org.scalatest.funspec.AnyFunSpec diff --git a/common/shared/src/test/scala/scalan/TestUtils.scala b/common/shared/src/test/scala/sigma/TestUtils.scala similarity index 98% rename from common/shared/src/test/scala/scalan/TestUtils.scala rename to common/shared/src/test/scala/sigma/TestUtils.scala index 683c9c29cf..082f1d10ac 100644 --- a/common/shared/src/test/scala/scalan/TestUtils.scala +++ b/common/shared/src/test/scala/sigma/TestUtils.scala @@ -1,4 +1,4 @@ -package scalan +package sigma import org.scalactic.TripleEquals import org.scalatest.matchers.should.Matchers diff --git a/common/shared/src/test/scala/sigma/TypesTests.scala b/common/shared/src/test/scala/sigma/TypesTests.scala index 4301d6e22f..f0fd6ac95d 100644 --- a/common/shared/src/test/scala/sigma/TypesTests.scala +++ b/common/shared/src/test/scala/sigma/TypesTests.scala @@ -1,7 +1,7 @@ package sigma -import scalan.RType._ -import scalan.{BaseTests, RType} +import sigma.core.RType._ +import sigma.core.RType class TypesTests extends BaseTests { diff --git a/common/shared/src/test/scala/sigma/collection/CollGens.scala b/common/shared/src/test/scala/sigma/collection/CollGens.scala index 4c136eb252..7726bd0909 100644 --- a/common/shared/src/test/scala/sigma/collection/CollGens.scala +++ b/common/shared/src/test/scala/sigma/collection/CollGens.scala @@ -2,8 +2,8 @@ package sigma import org.scalacheck.util.Buildable import org.scalacheck.{Arbitrary, Gen} -import scalan._ -import scalan.RType +import sigma.core._ +import sigma.core.RType import spire.scalacompat.BuilderCompat import scala.collection.mutable import scala.collection.mutable.ArrayBuffer diff --git a/common/shared/src/test/scala/sigma/collection/CollsTests.scala b/common/shared/src/test/scala/sigma/collection/CollsTests.scala index 16461d8d8c..bd8b9cb005 100644 --- a/common/shared/src/test/scala/sigma/collection/CollsTests.scala +++ b/common/shared/src/test/scala/sigma/collection/CollsTests.scala @@ -5,7 +5,7 @@ import org.scalatest.exceptions.TestFailedException import org.scalatest.matchers.should.Matchers import org.scalatest.propspec.AnyPropSpec import org.scalatestplus.scalacheck.ScalaCheckPropertyChecks -import scalan._ +import sigma.core._ import scala.language.{existentials} diff --git a/common/shared/src/test/scala/scalan/util/BenchmarkUtil.scala b/common/shared/src/test/scala/sigma/util/BenchmarkUtil.scala similarity index 100% rename from common/shared/src/test/scala/scalan/util/BenchmarkUtil.scala rename to common/shared/src/test/scala/sigma/util/BenchmarkUtil.scala diff --git a/common/shared/src/test/scala/scalan/util/CollectionUtilTests.scala b/common/shared/src/test/scala/sigma/util/CollectionUtilTests.scala similarity index 99% rename from common/shared/src/test/scala/scalan/util/CollectionUtilTests.scala rename to common/shared/src/test/scala/sigma/util/CollectionUtilTests.scala index 281cc7b17e..24b03f9d88 100644 --- a/common/shared/src/test/scala/scalan/util/CollectionUtilTests.scala +++ b/common/shared/src/test/scala/sigma/util/CollectionUtilTests.scala @@ -1,6 +1,6 @@ package sigma.util -import scalan.BaseTests +import sigma.BaseTests import scala.collection.{Seq, mutable} import scala.reflect.ClassTag diff --git a/common/shared/src/test/scala/scalan/util/GraphUtilTests.scala b/common/shared/src/test/scala/sigma/util/GraphUtilTests.scala similarity index 96% rename from common/shared/src/test/scala/scalan/util/GraphUtilTests.scala rename to common/shared/src/test/scala/sigma/util/GraphUtilTests.scala index e38d28375b..29e710cbeb 100644 --- a/common/shared/src/test/scala/scalan/util/GraphUtilTests.scala +++ b/common/shared/src/test/scala/sigma/util/GraphUtilTests.scala @@ -1,7 +1,8 @@ package sigma.util -import scalan.{BaseNestedTests, DFunc} +import sigma.{BaseNestedTests} import debox.{Set => DSet, Buffer => DBuffer} +import sigma.core.DFunc class GraphUtilTests extends BaseNestedTests { import GraphUtil._ diff --git a/common/shared/src/test/scala/scalan/util/PrintExtensions.scala b/common/shared/src/test/scala/sigma/util/PrintExtensions.scala similarity index 100% rename from common/shared/src/test/scala/scalan/util/PrintExtensions.scala rename to common/shared/src/test/scala/sigma/util/PrintExtensions.scala diff --git a/common/shared/src/test/scala/scalan/util/StringUtilTests.scala b/common/shared/src/test/scala/sigma/util/StringUtilTests.scala similarity index 87% rename from common/shared/src/test/scala/scalan/util/StringUtilTests.scala rename to common/shared/src/test/scala/sigma/util/StringUtilTests.scala index ef90c371f9..12ddf792a8 100644 --- a/common/shared/src/test/scala/scalan/util/StringUtilTests.scala +++ b/common/shared/src/test/scala/sigma/util/StringUtilTests.scala @@ -1,6 +1,6 @@ package sigma.util -import scalan.BaseNestedTests +import sigma.BaseNestedTests class StringUtilTests extends BaseNestedTests { import StringUtil._ diff --git a/common/shared/src/test/scala/scalan/util/StronglyConnectedComponentsTests.scala b/common/shared/src/test/scala/sigma/util/StronglyConnectedComponentsTests.scala similarity index 77% rename from common/shared/src/test/scala/scalan/util/StronglyConnectedComponentsTests.scala rename to common/shared/src/test/scala/sigma/util/StronglyConnectedComponentsTests.scala index aae397996f..f6076d4fed 100644 --- a/common/shared/src/test/scala/scalan/util/StronglyConnectedComponentsTests.scala +++ b/common/shared/src/test/scala/sigma/util/StronglyConnectedComponentsTests.scala @@ -1,6 +1,6 @@ package sigma.util -import scalan.BaseTests +import sigma.BaseTests class StronglyConnectedComponentsTests extends BaseTests { diff --git a/interpreter/js/src/main/scala/sigmastate/Platform.scala b/interpreter/js/src/main/scala/sigmastate/Platform.scala index eeca7b7853..2f9f0c6b6d 100644 --- a/interpreter/js/src/main/scala/sigmastate/Platform.scala +++ b/interpreter/js/src/main/scala/sigmastate/Platform.scala @@ -1,7 +1,7 @@ package sigmastate import org.ergoplatform.ErgoBox -import scalan.Nullable +import sigma.core.Nullable import sigma.VersionContext import sigmastate.Values.{Constant, FalseLeaf, SigmaBoolean, TrueLeaf} import sigmastate.eval.{Evaluation, SigmaDsl} diff --git a/interpreter/js/src/main/scala/sigmastate/crypto/Platform.scala b/interpreter/js/src/main/scala/sigmastate/crypto/Platform.scala index 2f448d89a4..435792e39f 100644 --- a/interpreter/js/src/main/scala/sigmastate/crypto/Platform.scala +++ b/interpreter/js/src/main/scala/sigmastate/crypto/Platform.scala @@ -1,6 +1,6 @@ package sigmastate.crypto -import scalan.RType +import sigma.core.RType import scorex.util.encode.Base16 import sigmastate._ import sigma.Coll diff --git a/interpreter/jvm/src/main/scala/sigmastate/Platform.scala b/interpreter/jvm/src/main/scala/sigmastate/Platform.scala index fa14798449..bf146df289 100644 --- a/interpreter/jvm/src/main/scala/sigmastate/Platform.scala +++ b/interpreter/jvm/src/main/scala/sigmastate/Platform.scala @@ -1,7 +1,7 @@ package sigmastate import org.ergoplatform.ErgoBox -import scalan.Nullable +import sigma.core.Nullable import sigma.VersionContext import sigmastate.Values.{Constant, FalseLeaf, SigmaBoolean, TrueLeaf} import sigmastate.eval.{Evaluation, SigmaDsl} diff --git a/interpreter/jvm/src/main/scala/sigmastate/crypto/Platform.scala b/interpreter/jvm/src/main/scala/sigmastate/crypto/Platform.scala index fe7c0afa72..388dfb8df9 100644 --- a/interpreter/jvm/src/main/scala/sigmastate/crypto/Platform.scala +++ b/interpreter/jvm/src/main/scala/sigmastate/crypto/Platform.scala @@ -5,7 +5,7 @@ import org.bouncycastle.crypto.ec.CustomNamedCurves import org.bouncycastle.crypto.generators.PKCS5S2ParametersGenerator import org.bouncycastle.crypto.params.KeyParameter import org.bouncycastle.math.ec.{ECCurve, ECFieldElement, ECPoint} -import scalan.RType +import sigma.core.RType import java.math.BigInteger import sigmastate._ diff --git a/interpreter/shared/src/main/scala/sigmastate/DataValueComparer.scala b/interpreter/shared/src/main/scala/sigmastate/DataValueComparer.scala index c07eaff70f..05c104d494 100644 --- a/interpreter/shared/src/main/scala/sigmastate/DataValueComparer.scala +++ b/interpreter/shared/src/main/scala/sigmastate/DataValueComparer.scala @@ -1,8 +1,8 @@ package sigmastate -import scalan.{AVHashMap, Nullable, RType} +import sigma.core.{AVHashMap, Nullable, RType} import debox.{cfor, sp} -import scalan.RType._ +import sigma.core.RType._ import sigmastate.Values.SigmaBoolean import sigmastate.basics.DLogProtocol.ProveDlog import sigmastate.basics.ProveDHTuple diff --git a/interpreter/shared/src/main/scala/sigmastate/Values.scala b/interpreter/shared/src/main/scala/sigmastate/Values.scala index 158f24b375..2eec9a27bb 100644 --- a/interpreter/shared/src/main/scala/sigmastate/Values.scala +++ b/interpreter/shared/src/main/scala/sigmastate/Values.scala @@ -5,7 +5,7 @@ import java.util.{Arrays, Objects} import sigma.kiama.rewriting.Rewriter.{count, everywherebu, strategy} import org.ergoplatform.settings.ErgoAlgos import org.ergoplatform.validation.ValidationException -import scalan.{Nullable, RType} +import sigma.core.{Nullable, RType} import sigma.util.CollectionUtil._ import sigmastate.SCollection.{SByteArray, SIntArray} import sigmastate.basics.CryptoConstants.EcPointType diff --git a/interpreter/shared/src/main/scala/sigmastate/eval/BigIntegerOps.scala b/interpreter/shared/src/main/scala/sigmastate/eval/BigIntegerOps.scala index a3e44b8ebe..b92134be41 100644 --- a/interpreter/shared/src/main/scala/sigmastate/eval/BigIntegerOps.scala +++ b/interpreter/shared/src/main/scala/sigmastate/eval/BigIntegerOps.scala @@ -2,7 +2,7 @@ package sigmastate.eval import java.math.BigInteger -import scalan.{ExactOrderingImpl, ExactIntegral} +import sigma.core.{ExactOrderingImpl, ExactIntegral} import scala.math.{Integral, Ordering} import sigma._ diff --git a/interpreter/shared/src/main/scala/sigmastate/eval/CostingDataContext.scala b/interpreter/shared/src/main/scala/sigmastate/eval/CostingDataContext.scala index f40e469164..3e02ac8bd8 100644 --- a/interpreter/shared/src/main/scala/sigmastate/eval/CostingDataContext.scala +++ b/interpreter/shared/src/main/scala/sigmastate/eval/CostingDataContext.scala @@ -3,8 +3,8 @@ package sigmastate.eval import debox.cfor import org.ergoplatform.validation.{SigmaValidationSettings, ValidationRules} import org.ergoplatform.{ErgoBox, SigmaConstants} -import scalan.OverloadHack.Overloaded1 -import scalan.RType +import sigma.core.OverloadHack.Overloaded1 +import sigma.core.RType import sigma.util.Extensions.BigIntegerOps import scorex.crypto.authds.avltree.batch._ import scorex.crypto.authds.{ADDigest, ADKey, ADValue, SerializedAdProof} diff --git a/interpreter/shared/src/main/scala/sigmastate/eval/Evaluation.scala b/interpreter/shared/src/main/scala/sigmastate/eval/Evaluation.scala index c47be16605..27188d1410 100644 --- a/interpreter/shared/src/main/scala/sigmastate/eval/Evaluation.scala +++ b/interpreter/shared/src/main/scala/sigmastate/eval/Evaluation.scala @@ -1,8 +1,8 @@ package sigmastate.eval import org.ergoplatform._ -import scalan.RType -import scalan.RType._ +import sigma.core.RType +import sigma.core.RType._ import sigmastate.SType._ import sigmastate.Values.SigmaBoolean import sigmastate._ diff --git a/interpreter/shared/src/main/scala/sigmastate/eval/Extensions.scala b/interpreter/shared/src/main/scala/sigmastate/eval/Extensions.scala index 8c1eedb9f0..2b89c5ca70 100644 --- a/interpreter/shared/src/main/scala/sigmastate/eval/Extensions.scala +++ b/interpreter/shared/src/main/scala/sigmastate/eval/Extensions.scala @@ -3,7 +3,7 @@ package sigmastate.eval import debox.{cfor, Buffer => DBuffer} import org.ergoplatform.ErgoBox import org.ergoplatform.ErgoBox.TokenId -import scalan.{Nullable, RType} +import sigma.core.{Nullable, RType} import scorex.util.encode.Base16 import sigmastate.SType.AnyOps import sigmastate.Values.{Constant, ConstantNode} diff --git a/interpreter/shared/src/main/scala/sigmastate/eval/package.scala b/interpreter/shared/src/main/scala/sigmastate/eval/package.scala index 7add87d048..90913b1cc4 100644 --- a/interpreter/shared/src/main/scala/sigmastate/eval/package.scala +++ b/interpreter/shared/src/main/scala/sigmastate/eval/package.scala @@ -3,7 +3,7 @@ package sigmastate import java.math.BigInteger import org.ergoplatform.ErgoBox -import scalan.RType +import sigma.core.RType import scorex.crypto.hash.Digest32 import sigmastate.Values.SigmaBoolean import sigmastate.basics.CryptoConstants.EcPointType diff --git a/interpreter/shared/src/main/scala/sigmastate/lang/SigmaBuilder.scala b/interpreter/shared/src/main/scala/sigmastate/lang/SigmaBuilder.scala index 147cbafa84..93d526dfae 100644 --- a/interpreter/shared/src/main/scala/sigmastate/lang/SigmaBuilder.scala +++ b/interpreter/shared/src/main/scala/sigmastate/lang/SigmaBuilder.scala @@ -2,7 +2,7 @@ package sigmastate.lang import debox.cfor import org.ergoplatform.ErgoBox.RegisterId -import scalan.Nullable +import sigma.core.Nullable import sigma.Environment import sigmastate.SCollection.{SByteArray, SIntArray} import sigmastate.SOption.SIntOption diff --git a/interpreter/shared/src/main/scala/sigmastate/lang/SigmaPredef.scala b/interpreter/shared/src/main/scala/sigmastate/lang/SigmaPredef.scala index 7c958918e5..747046fb1a 100644 --- a/interpreter/shared/src/main/scala/sigmastate/lang/SigmaPredef.scala +++ b/interpreter/shared/src/main/scala/sigmastate/lang/SigmaPredef.scala @@ -2,7 +2,7 @@ package sigmastate.lang import org.ergoplatform.ErgoAddressEncoder.NetworkPrefix import org.ergoplatform.{ErgoAddressEncoder, P2PKAddress} -import scalan.Nullable +import sigma.core.Nullable import scorex.util.encode.{Base64, Base58, Base16} import sigmastate.SCollection.{SIntArray, SByteArray} import sigmastate.SOption._ diff --git a/interpreter/shared/src/main/scala/sigmastate/lang/Terms.scala b/interpreter/shared/src/main/scala/sigmastate/lang/Terms.scala index 02057217a2..9743edbb19 100644 --- a/interpreter/shared/src/main/scala/sigmastate/lang/Terms.scala +++ b/interpreter/shared/src/main/scala/sigmastate/lang/Terms.scala @@ -1,7 +1,7 @@ package sigmastate.lang import sigma.kiama.rewriting.Rewriter._ -import scalan.Nullable +import sigma.core.Nullable import sigmastate.SCollection.{SIntArray, SByteArray} import sigmastate.Values._ import sigmastate.utils.Overloading.Overload1 diff --git a/interpreter/shared/src/main/scala/sigmastate/serialization/DataSerializer.scala b/interpreter/shared/src/main/scala/sigmastate/serialization/DataSerializer.scala index a3c86c85e7..b6e6c2ea57 100644 --- a/interpreter/shared/src/main/scala/sigmastate/serialization/DataSerializer.scala +++ b/interpreter/shared/src/main/scala/sigmastate/serialization/DataSerializer.scala @@ -5,7 +5,7 @@ import java.nio.charset.StandardCharsets import org.ergoplatform.ErgoBox import org.ergoplatform.validation.ValidationRules.CheckSerializableTypeCode -import scalan.RType +import sigma.core.RType import sigmastate.Values.SigmaBoolean import sigmastate.utils.{SigmaByteReader, SigmaByteWriter} import sigmastate._ diff --git a/interpreter/shared/src/main/scala/sigmastate/trees.scala b/interpreter/shared/src/main/scala/sigmastate/trees.scala index 006bfa8454..4bbb4e3f65 100644 --- a/interpreter/shared/src/main/scala/sigmastate/trees.scala +++ b/interpreter/shared/src/main/scala/sigmastate/trees.scala @@ -3,10 +3,10 @@ package sigmastate import debox.{cfor, Map => DMap} import org.ergoplatform.SigmaConstants import org.ergoplatform.validation.SigmaValidationSettings -import scalan.ExactIntegral._ -import scalan.ExactOrdering._ -import scalan.OverloadHack.Overloaded1 -import scalan.{ExactIntegral, ExactOrdering} +import sigma.core.ExactIntegral._ +import sigma.core.ExactOrdering._ +import sigma.core.OverloadHack.Overloaded1 +import sigma.core.{ExactIntegral, ExactOrdering} import scorex.crypto.hash.{Blake2b256, CryptographicHash32, Sha256} import sigma.VersionContext import sigmastate.ArithOp.OperationImpl diff --git a/interpreter/shared/src/main/scala/sigmastate/types.scala b/interpreter/shared/src/main/scala/sigmastate/types.scala index c8f70a4b34..6ad160d66b 100644 --- a/interpreter/shared/src/main/scala/sigmastate/types.scala +++ b/interpreter/shared/src/main/scala/sigmastate/types.scala @@ -3,8 +3,8 @@ package sigmastate import java.math.BigInteger import org.ergoplatform._ import org.ergoplatform.validation._ -import scalan.{Nullable, RType} -import scalan.RType.GeneralType +import sigma.core.{Nullable, RType} +import sigma.core.RType.GeneralType import sigmastate.SType.TypeCode import sigmastate.interpreter._ import sigmastate.utils.Overloading.Overload1 diff --git a/interpreter/shared/src/main/scala/sigmastate/utils/Helpers.scala b/interpreter/shared/src/main/scala/sigmastate/utils/Helpers.scala index f1c72a0475..2e4c88d6dd 100644 --- a/interpreter/shared/src/main/scala/sigmastate/utils/Helpers.scala +++ b/interpreter/shared/src/main/scala/sigmastate/utils/Helpers.scala @@ -3,7 +3,7 @@ package sigmastate.utils import debox.cfor import io.circe.Decoder import org.ergoplatform.settings.ErgoAlgos -import scalan.{OverloadHack, RType} +import sigma.core.{OverloadHack, RType} import scorex.utils.Ints import sigma.Environment import sigmastate.eval.{CAnyValue, Colls, SigmaDsl} diff --git a/interpreter/shared/src/main/scala/sigmastate/utxo/transformers.scala b/interpreter/shared/src/main/scala/sigmastate/utxo/transformers.scala index 87d4bc52bc..a8e4b2d233 100644 --- a/interpreter/shared/src/main/scala/sigmastate/utxo/transformers.scala +++ b/interpreter/shared/src/main/scala/sigmastate/utxo/transformers.scala @@ -7,7 +7,7 @@ import sigmastate._ import sigmastate.serialization.OpCodes.OpCode import sigmastate.serialization.OpCodes import org.ergoplatform.ErgoBox.RegisterId -import scalan.RType +import sigma.core.RType import sigmastate.Operations._ import sigmastate.eval.{Evaluation, SigmaDsl} import sigmastate.exceptions.InterpreterException diff --git a/interpreter/shared/src/test/scala/sigmastate/lang/SigmaBuilderTest.scala b/interpreter/shared/src/test/scala/sigmastate/lang/SigmaBuilderTest.scala index 0eccc3ce41..779b7f33eb 100644 --- a/interpreter/shared/src/test/scala/sigmastate/lang/SigmaBuilderTest.scala +++ b/interpreter/shared/src/test/scala/sigmastate/lang/SigmaBuilderTest.scala @@ -3,7 +3,7 @@ package sigmastate.lang import org.scalatest.matchers.should.Matchers import org.scalatest.propspec.AnyPropSpec import org.scalatestplus.scalacheck.ScalaCheckPropertyChecks -import scalan.{Nullable, RType} +import sigma.core.{Nullable, RType} import sigma.{Environment, VersionContext} import sigmastate.Values._ import sigmastate._ diff --git a/interpreter/shared/src/test/scala/sigmastate/serialization/ConstantSerializerSpecification.scala b/interpreter/shared/src/test/scala/sigmastate/serialization/ConstantSerializerSpecification.scala index 4e71522d3d..0893267378 100644 --- a/interpreter/shared/src/test/scala/sigmastate/serialization/ConstantSerializerSpecification.scala +++ b/interpreter/shared/src/test/scala/sigmastate/serialization/ConstantSerializerSpecification.scala @@ -3,7 +3,7 @@ package sigmastate.serialization import java.math.BigInteger import org.ergoplatform._ import org.scalacheck.Arbitrary._ -import scalan.RType +import sigma.core.RType import sigmastate.SCollection.SByteArray import sigmastate.Values.{BigIntConstant, ByteArrayConstant, Constant, FalseLeaf, GroupGenerator, LongConstant, SValue, TrueLeaf} import sigmastate.basics.CryptoConstants.EcPointType diff --git a/interpreter/shared/src/test/scala/sigmastate/serialization/DataSerializerSpecification.scala b/interpreter/shared/src/test/scala/sigmastate/serialization/DataSerializerSpecification.scala index dcac288b6b..0aeaed9e09 100644 --- a/interpreter/shared/src/test/scala/sigmastate/serialization/DataSerializerSpecification.scala +++ b/interpreter/shared/src/test/scala/sigmastate/serialization/DataSerializerSpecification.scala @@ -3,7 +3,7 @@ package sigmastate.serialization import java.math.BigInteger import org.ergoplatform.ErgoBox import org.scalacheck.Arbitrary._ -import scalan.RType +import sigma.core.RType import sigmastate.SCollection.SByteArray import sigmastate.Values.{ErgoTree, SigmaBoolean} import sigmastate._ diff --git a/interpreter/shared/src/test/scala/sigmastate/serialization/generators/ObjectGenerators.scala b/interpreter/shared/src/test/scala/sigmastate/serialization/generators/ObjectGenerators.scala index bf8c4ef06f..4dc3625d91 100644 --- a/interpreter/shared/src/test/scala/sigmastate/serialization/generators/ObjectGenerators.scala +++ b/interpreter/shared/src/test/scala/sigmastate/serialization/generators/ObjectGenerators.scala @@ -8,7 +8,7 @@ import org.scalacheck.Arbitrary._ import org.scalacheck.Gen.{choose, frequency} import org.scalacheck.util.Buildable import org.scalacheck.{Arbitrary, Gen} -import scalan.RType +import sigma.core.RType import scorex.crypto.authds.{ADDigest, ADKey} import scorex.util.encode.{Base58, Base64} import scorex.util.{ModifierId, bytesToId} diff --git a/interpreter/shared/src/test/scala/special/sigma/ContractsTestkit.scala b/interpreter/shared/src/test/scala/special/sigma/ContractsTestkit.scala index 44c853df35..928632dd29 100644 --- a/interpreter/shared/src/test/scala/special/sigma/ContractsTestkit.scala +++ b/interpreter/shared/src/test/scala/special/sigma/ContractsTestkit.scala @@ -1,12 +1,12 @@ package sigma -import scalan.RType +import sigma.core.RType import sigmastate.Values.ErgoTree import sigmastate.{AvlTreeData, Values} import sigmastate.eval._ import sigmastate.eval.Extensions._ import sigmastate.helpers.TestingHelpers._ -import scalan._ +import sigma.core._ import scala.annotation.nowarn // imports implicit ClassTag diff --git a/interpreter/shared/src/test/scala/special/sigma/SigmaTestingData.scala b/interpreter/shared/src/test/scala/special/sigma/SigmaTestingData.scala index 93f7223bc9..a65e5d6927 100644 --- a/interpreter/shared/src/test/scala/special/sigma/SigmaTestingData.scala +++ b/interpreter/shared/src/test/scala/special/sigma/SigmaTestingData.scala @@ -6,7 +6,7 @@ import org.scalacheck.Arbitrary.arbitrary import org.scalacheck.Gen.containerOfN import org.scalacheck.util.Buildable import org.scalacheck.{Arbitrary, Gen} -import scalan.RType +import sigma.core.RType import scorex.crypto.authds.{ADKey, ADValue} import scorex.crypto.hash.{Blake2b256, Digest32} import scorex.util.ModifierId diff --git a/parsers/shared/src/main/scala/sigmastate/lang/SigmaParser.scala b/parsers/shared/src/main/scala/sigmastate/lang/SigmaParser.scala index 0ef4651cf5..a218f24347 100644 --- a/parsers/shared/src/main/scala/sigmastate/lang/SigmaParser.scala +++ b/parsers/shared/src/main/scala/sigmastate/lang/SigmaParser.scala @@ -3,7 +3,7 @@ package sigmastate.lang import fastparse.internal.Logger import sigmastate._ import Values._ -import scalan.Nullable +import sigma.core.Nullable import sigmastate.lang.Terms._ import sigmastate.lang.syntax.Basic._ import sigmastate.lang.syntax.{Core, Exprs} diff --git a/parsers/shared/src/main/scala/sigmastate/lang/syntax/Basic.scala b/parsers/shared/src/main/scala/sigmastate/lang/syntax/Basic.scala index e9e91c8197..cae64d2c80 100644 --- a/parsers/shared/src/main/scala/sigmastate/lang/syntax/Basic.scala +++ b/parsers/shared/src/main/scala/sigmastate/lang/syntax/Basic.scala @@ -3,7 +3,7 @@ package sigmastate.lang.syntax import fastparse._ import NoWhitespace._ import fastparse.CharPredicates._ -import scalan.Nullable +import sigma.core.Nullable import sigmastate.lang.SourceContext import sigmastate.exceptions.CompilerException diff --git a/sc/jvm/src/test/scala/sigmastate/ReflectionGenerator.scala b/sc/jvm/src/test/scala/sigmastate/ReflectionGenerator.scala index 9a3750be47..76a39a026f 100644 --- a/sc/jvm/src/test/scala/sigmastate/ReflectionGenerator.scala +++ b/sc/jvm/src/test/scala/sigmastate/ReflectionGenerator.scala @@ -1,8 +1,7 @@ package sigmastate -import sigma.reflection._ import scalan.{Base, TypeDescs} - +import sigma.reflection._ import scala.annotation.unused import scala.collection.mutable diff --git a/sc/jvm/src/test/scala/sigmastate/helpers/SigmaPPrintSpec.scala b/sc/jvm/src/test/scala/sigmastate/helpers/SigmaPPrintSpec.scala index ff7a37c5a7..e5247b839c 100644 --- a/sc/jvm/src/test/scala/sigmastate/helpers/SigmaPPrintSpec.scala +++ b/sc/jvm/src/test/scala/sigmastate/helpers/SigmaPPrintSpec.scala @@ -2,7 +2,7 @@ package sigmastate.helpers import org.ergoplatform.settings.ErgoAlgos import org.ergoplatform.{ErgoBox, Outputs} -import scalan.RType +import sigma.core.RType import scorex.util.ModifierId import sigmastate.Values._ import sigmastate._ diff --git a/sc/jvm/src/test/scala/special/collections/MapBenchmark.scala b/sc/jvm/src/test/scala/special/collections/MapBenchmark.scala index ca36b41179..2bbe149ccc 100644 --- a/sc/jvm/src/test/scala/special/collections/MapBenchmark.scala +++ b/sc/jvm/src/test/scala/special/collections/MapBenchmark.scala @@ -1,7 +1,7 @@ package sigma import org.scalameter.api.Bench -import scalan.{AVHashMap, Nullable} +import sigma.core.{AVHashMap, Nullable} import debox.cfor trait MapBenchmarkCases extends BenchmarkGens { suite: Bench[Double] => diff --git a/sc/shared/src/main/scala/org/ergoplatform/dsl/ContractSpec.scala b/sc/shared/src/main/scala/org/ergoplatform/dsl/ContractSpec.scala index 013c540f73..95be10d40c 100644 --- a/sc/shared/src/main/scala/org/ergoplatform/dsl/ContractSpec.scala +++ b/sc/shared/src/main/scala/org/ergoplatform/dsl/ContractSpec.scala @@ -2,7 +2,7 @@ package org.ergoplatform.dsl import org.ergoplatform.ErgoBox.{BoxId, NonMandatoryRegisterId, TokenId} import sigmastate.interpreter.{CostedProverResult, ProverResult} -import scalan.RType +import sigma.core.RType import org.ergoplatform.{ErgoLikeContext, ErgoBox} import sigma.{SigmaDslBuilder, AnyValue, SigmaProp} import sigmastate.Values.ErgoTree diff --git a/sc/shared/src/main/scala/org/ergoplatform/dsl/ContractSyntax.scala b/sc/shared/src/main/scala/org/ergoplatform/dsl/ContractSyntax.scala index acc1ded565..135799520c 100644 --- a/sc/shared/src/main/scala/org/ergoplatform/dsl/ContractSyntax.scala +++ b/sc/shared/src/main/scala/org/ergoplatform/dsl/ContractSyntax.scala @@ -1,7 +1,7 @@ package org.ergoplatform.dsl import org.ergoplatform.ErgoBox.TokenId -import scalan.RType +import sigma.core.RType import sigmastate.SType import sigmastate.SType.AnyOps import org.ergoplatform.dsl.ContractSyntax.{ErgoScript, Proposition} diff --git a/sc/shared/src/main/scala/scalan/Base.scala b/sc/shared/src/main/scala/scalan/Base.scala index 6d9eafa0bc..e5705aa508 100644 --- a/sc/shared/src/main/scala/scalan/Base.scala +++ b/sc/shared/src/main/scala/scalan/Base.scala @@ -1,7 +1,8 @@ package scalan import debox.{cfor, Buffer => DBuffer} -import scalan.OverloadHack.Overloaded1 +import sigma.core.{AVHashMap, Nullable, RType} +import sigma.core.OverloadHack.Overloaded1 import sigma.util.StringUtil import sigma.reflection.RConstructor diff --git a/sc/shared/src/main/scala/scalan/DefRewriting.scala b/sc/shared/src/main/scala/scalan/DefRewriting.scala index f915239d46..94c5dda699 100644 --- a/sc/shared/src/main/scala/scalan/DefRewriting.scala +++ b/sc/shared/src/main/scala/scalan/DefRewriting.scala @@ -1,5 +1,7 @@ package scalan +import sigma.core.ExactNumeric + trait DefRewriting { scalan: Scalan => /** Rewrites given node to another equivalent node and returns its reference. diff --git a/sc/shared/src/main/scala/scalan/GraphIRReflection.scala b/sc/shared/src/main/scala/scalan/GraphIRReflection.scala index fcc9ab905b..711629b318 100644 --- a/sc/shared/src/main/scala/scalan/GraphIRReflection.scala +++ b/sc/shared/src/main/scala/scalan/GraphIRReflection.scala @@ -7,6 +7,7 @@ import sigma.CoreLibReflection import sigmastate.eval.SigmaLibrary import sigma.Colls import sigma.SigmaDsl +import sigma.core.RType import special.wrappers.{OptionWrapSpec, RTypeWrapSpec} import wrappers.scalan.WRTypes diff --git a/sc/shared/src/main/scala/scalan/Library.scala b/sc/shared/src/main/scala/scalan/Library.scala index 5a6b9dbcd0..e3b3bc592a 100644 --- a/sc/shared/src/main/scala/scalan/Library.scala +++ b/sc/shared/src/main/scala/scalan/Library.scala @@ -2,6 +2,7 @@ package scalan import scala.language.implicitConversions import sigma._ +import sigma.core.{Nullable, RType} import special.wrappers.WrappersModule import sigma.util.MemoizedFunc diff --git a/sc/shared/src/main/scala/scalan/TypeDescs.scala b/sc/shared/src/main/scala/scalan/TypeDescs.scala index 089f9f374e..a84533c445 100644 --- a/sc/shared/src/main/scala/scalan/TypeDescs.scala +++ b/sc/shared/src/main/scala/scalan/TypeDescs.scala @@ -3,11 +3,12 @@ package scalan import scala.language.implicitConversions import scala.annotation.implicitNotFound import scala.collection.immutable.ListMap -import scalan.RType._ +import sigma.core.RType._ import scala.collection.mutable import debox.cfor import scalan.core.{Contravariant, Covariant, Variance} +import sigma.core.{AVHashMap, Lazy, Nullable, RType} import sigma.reflection.{RClass, RConstructor, RMethod} import sigma.util.CollectionUtil import special.wrappers.WrapSpec @@ -69,7 +70,7 @@ abstract class TypeDescs extends Base { self: Scalan => // TODO optimize performance hot spot (45% of invokeUnlifted time), reduce allocation of Some final def getSourceValues(dataEnv: DataEnv, forWrapper: Boolean, stagedValues: AnyRef*): Seq[AnyRef] = { - import OverloadHack._ + import sigma.core.OverloadHack._ val limit = stagedValues.length val res = mutable.ArrayBuilder.make[AnyRef] res.sizeHint(limit) diff --git a/sc/shared/src/main/scala/scalan/primitives/Functions.scala b/sc/shared/src/main/scala/scalan/primitives/Functions.scala index 830c7b3bd7..011a96df98 100644 --- a/sc/shared/src/main/scala/scalan/primitives/Functions.scala +++ b/sc/shared/src/main/scala/scalan/primitives/Functions.scala @@ -2,11 +2,12 @@ package scalan.primitives import java.util import scalan.staged.ProgramGraphs -import scalan.{Base, Lazy, Nullable, Scalan, emptyDBufferOfInt} +import scalan.{Base, Scalan} import debox.{Buffer => DBuffer} import scala.language.implicitConversions import debox.cfor +import sigma.core.{Lazy, Nullable, emptyDBufferOfInt} import sigma.util.GraphUtil trait Functions extends Base with ProgramGraphs { self: Scalan => diff --git a/sc/shared/src/main/scala/scalan/primitives/NumericOps.scala b/sc/shared/src/main/scala/scalan/primitives/NumericOps.scala index 39c93b49ae..018e5dae4e 100644 --- a/sc/shared/src/main/scala/scalan/primitives/NumericOps.scala +++ b/sc/shared/src/main/scala/scalan/primitives/NumericOps.scala @@ -1,6 +1,7 @@ package scalan.primitives -import scalan.{ExactNumeric, Base, Scalan, ExactIntegral} +import scalan.{Base, Scalan} +import sigma.core.{ExactIntegral, ExactNumeric} /** Slice in Scala cake with definitions of numeric operations. */ trait NumericOps extends Base { self: Scalan => diff --git a/sc/shared/src/main/scala/scalan/primitives/OrderingOps.scala b/sc/shared/src/main/scala/scalan/primitives/OrderingOps.scala index 479c502795..1f1a4a1ac1 100644 --- a/sc/shared/src/main/scala/scalan/primitives/OrderingOps.scala +++ b/sc/shared/src/main/scala/scalan/primitives/OrderingOps.scala @@ -1,6 +1,8 @@ package scalan.primitives -import scalan.{Base, Scalan, ExactOrdering} +import scalan.{Base, Scalan} +import sigma.core.ExactOrdering + import scala.language.implicitConversions /** Slice in Scala cake with definitions of comparison operations. */ diff --git a/sc/shared/src/main/scala/scalan/primitives/Thunks.scala b/sc/shared/src/main/scala/scalan/primitives/Thunks.scala index ea1117215d..88dcd0d0ca 100644 --- a/sc/shared/src/main/scala/scalan/primitives/Thunks.scala +++ b/sc/shared/src/main/scala/scalan/primitives/Thunks.scala @@ -5,6 +5,7 @@ import scalan._ import debox.{Buffer => DBuffer, Set => DSet} import debox.cfor import scalan.core.Covariant +import sigma.core.{AVHashMap, DFunc, Lazy, Nullable, RType} import sigma.reflection.RClass import sigma.util.GraphUtil @@ -81,7 +82,7 @@ trait Thunks extends Functions { self: Scalan => /** Implementation of Liftable type class for `Thunk[T]` given liftable for `T`. */ case class LiftableThunk[ST, T](lT: Liftable[ST, T]) extends Liftable[SThunk[ST], Thunk[T]] { - import RType._ + import sigma.core.RType._ override def eW: Elem[Thunk[T]] = thunkElement(lT.eW) override def sourceType: RType[SThunk[ST]] = { implicit val tST = lT.sourceType diff --git a/sc/shared/src/main/scala/scalan/primitives/Tuples.scala b/sc/shared/src/main/scala/scalan/primitives/Tuples.scala index 1fa5fbe5ad..4e47e28e6b 100644 --- a/sc/shared/src/main/scala/scalan/primitives/Tuples.scala +++ b/sc/shared/src/main/scala/scalan/primitives/Tuples.scala @@ -4,8 +4,9 @@ */ package scalan.primitives +import scalan.{Base, Scalan} import scala.language.implicitConversions -import scalan.{Base, Scalan, AVHashMap} +import sigma.core.{AVHashMap} trait Tuples extends Base { self: Scalan => object Pair { diff --git a/sc/shared/src/main/scala/scalan/staged/AstGraphs.scala b/sc/shared/src/main/scala/scalan/staged/AstGraphs.scala index bec0c36eed..090fedeaae 100644 --- a/sc/shared/src/main/scala/scalan/staged/AstGraphs.scala +++ b/sc/shared/src/main/scala/scalan/staged/AstGraphs.scala @@ -1,9 +1,10 @@ package scalan.staged import scala.collection._ -import scalan.{Base, Scalan, emptyDBufferOfInt} +import scalan.Scalan import debox.cfor -import debox.{Set => DSet, Buffer => DBuffer, Map => DMap} +import debox.{Buffer => DBuffer, Map => DMap, Set => DSet} +import sigma.core.emptyDBufferOfInt trait AstGraphs extends Transforming { self: Scalan => diff --git a/sc/shared/src/main/scala/scalan/staged/ProgramGraphs.scala b/sc/shared/src/main/scala/scalan/staged/ProgramGraphs.scala index 5a5a05a459..b0654e7fa9 100644 --- a/sc/shared/src/main/scala/scalan/staged/ProgramGraphs.scala +++ b/sc/shared/src/main/scala/scalan/staged/ProgramGraphs.scala @@ -1,10 +1,10 @@ package scalan.staged -import scalan.{DFunc, Nullable, Scalan} +import scalan.Scalan import debox.{Buffer => DBuffer} import sigma.util.GraphUtil import debox.cfor - +import sigma.core.{DFunc, Nullable} import scala.collection.compat.immutable.ArraySeq trait ProgramGraphs extends AstGraphs { self: Scalan => diff --git a/sc/shared/src/main/scala/scalan/staged/Transforming.scala b/sc/shared/src/main/scala/scalan/staged/Transforming.scala index b44f815464..d1f458b19b 100644 --- a/sc/shared/src/main/scala/scalan/staged/Transforming.scala +++ b/sc/shared/src/main/scala/scalan/staged/Transforming.scala @@ -2,9 +2,10 @@ package scalan.staged import java.util import scala.language.existentials -import scalan.{Lazy, Nullable, Scalan} +import scalan.Scalan import debox.{Buffer => DBuffer} import debox.cfor +import sigma.core.{Lazy, Nullable} import sigma.reflection.RMethod trait Transforming { self: Scalan => diff --git a/sc/shared/src/main/scala/sigmastate/eval/GraphBuilding.scala b/sc/shared/src/main/scala/sigmastate/eval/GraphBuilding.scala index a316265fca..fc7efb75dd 100644 --- a/sc/shared/src/main/scala/sigmastate/eval/GraphBuilding.scala +++ b/sc/shared/src/main/scala/sigmastate/eval/GraphBuilding.scala @@ -1,10 +1,11 @@ package sigmastate.eval import org.ergoplatform._ -import scalan.ExactIntegral.{ByteIsExactIntegral, IntIsExactIntegral, LongIsExactIntegral, ShortIsExactIntegral} -import scalan.ExactOrdering.{ByteIsExactOrdering, IntIsExactOrdering, LongIsExactOrdering, ShortIsExactOrdering} +import scalan.MutableLazy +import sigma.core.ExactIntegral.{ByteIsExactIntegral, IntIsExactIntegral, LongIsExactIntegral, ShortIsExactIntegral} +import sigma.core.ExactOrdering.{ByteIsExactOrdering, IntIsExactOrdering, LongIsExactOrdering, ShortIsExactOrdering} import sigma.util.Extensions.ByteOps -import scalan.{ExactIntegral, ExactNumeric, ExactOrdering, Lazy, MutableLazy, Nullable} +import sigma.core.{ExactIntegral, ExactNumeric, ExactOrdering, Lazy, Nullable} import sigmastate.Values.Value.Typed import sigmastate.Values._ import sigmastate.interpreter.Interpreter.ScriptEnv diff --git a/sc/shared/src/main/scala/sigmastate/lang/SigmaBinder.scala b/sc/shared/src/main/scala/sigmastate/lang/SigmaBinder.scala index 0bbad9d54a..4f006e7223 100644 --- a/sc/shared/src/main/scala/sigmastate/lang/SigmaBinder.scala +++ b/sc/shared/src/main/scala/sigmastate/lang/SigmaBinder.scala @@ -2,7 +2,7 @@ package sigmastate.lang import org.ergoplatform.ErgoAddressEncoder.NetworkPrefix import org.ergoplatform._ -import scalan.Nullable +import sigma.core.Nullable import sigma.kiama.rewriting.CallbackRewriter import sigmastate.Values._ import sigmastate._ diff --git a/sc/shared/src/main/scala/sigmastate/lang/SigmaTyper.scala b/sc/shared/src/main/scala/sigmastate/lang/SigmaTyper.scala index 7cc5b3db08..62e8fd75a1 100644 --- a/sc/shared/src/main/scala/sigmastate/lang/SigmaTyper.scala +++ b/sc/shared/src/main/scala/sigmastate/lang/SigmaTyper.scala @@ -5,7 +5,7 @@ import sigmastate.SCollection._ import sigmastate.Values._ import sigmastate._ import SCollection.SBooleanArray -import scalan.Nullable +import sigma.core.Nullable import sigma.util.Extensions.Ensuring import sigmastate.lang.Terms._ import sigmastate.exceptions._ diff --git a/sc/shared/src/main/scala/special/collection/impl/CollsImpl.scala b/sc/shared/src/main/scala/special/collection/impl/CollsImpl.scala index 95acc6e74e..0525101ee8 100644 --- a/sc/shared/src/main/scala/special/collection/impl/CollsImpl.scala +++ b/sc/shared/src/main/scala/special/collection/impl/CollsImpl.scala @@ -5,6 +5,7 @@ import scalan._ import scala.collection.compat.immutable.ArraySeq package impl { + import sigma.core.{Nullable, RType} import sigma.reflection.{RClass, RMethod} // Abs ----------------------------------- diff --git a/sc/shared/src/main/scala/special/sigma/impl/SigmaDslImpl.scala b/sc/shared/src/main/scala/special/sigma/impl/SigmaDslImpl.scala index f99ee23a68..1505efbb00 100644 --- a/sc/shared/src/main/scala/special/sigma/impl/SigmaDslImpl.scala +++ b/sc/shared/src/main/scala/special/sigma/impl/SigmaDslImpl.scala @@ -7,6 +7,7 @@ import sigmastate.eval.SigmaLibrary import scala.collection.compat.immutable.ArraySeq package impl { + import sigma.core.{Nullable, RType} import sigma.reflection.{RClass, RMethod} import sigmastate.eval.SigmaLibrary diff --git a/sc/shared/src/main/scala/special/wrappers/WrappersSpec.scala b/sc/shared/src/main/scala/special/wrappers/WrappersSpec.scala index 9393ca110b..8c25fe1eb5 100644 --- a/sc/shared/src/main/scala/special/wrappers/WrappersSpec.scala +++ b/sc/shared/src/main/scala/special/wrappers/WrappersSpec.scala @@ -1,6 +1,6 @@ package special.wrappers -import scalan.RType +import sigma.core.RType /** Base class for wrappers of such types as WOption, WRType etc. * Used in graph IR to implement method invocation. diff --git a/sc/shared/src/main/scala/wrappers/scala/impl/WOptionsImpl.scala b/sc/shared/src/main/scala/wrappers/scala/impl/WOptionsImpl.scala index 6809984a34..fe8dd78f7e 100644 --- a/sc/shared/src/main/scala/wrappers/scala/impl/WOptionsImpl.scala +++ b/sc/shared/src/main/scala/wrappers/scala/impl/WOptionsImpl.scala @@ -7,6 +7,7 @@ import special.wrappers.OptionWrapSpec import scala.collection.compat.immutable.ArraySeq package impl { + import sigma.core.{Nullable, RType} import sigma.reflection.{RClass, RMethod} // Abs ----------------------------------- diff --git a/sc/shared/src/main/scala/wrappers/scalan/WRTypes.scala b/sc/shared/src/main/scala/wrappers/scalan/WRTypes.scala index 07795cdada..a9f0335ae9 100644 --- a/sc/shared/src/main/scala/wrappers/scalan/WRTypes.scala +++ b/sc/shared/src/main/scala/wrappers/scalan/WRTypes.scala @@ -3,7 +3,7 @@ package wrappers.scalan { import impl._ - import scalan.RType + import sigma.core.RType import special.wrappers.WrappersModule diff --git a/sc/shared/src/main/scala/wrappers/scalan/impl/WRTypesImpl.scala b/sc/shared/src/main/scala/wrappers/scalan/impl/WRTypesImpl.scala index e4737589c2..5fa2ec3e8a 100644 --- a/sc/shared/src/main/scala/wrappers/scalan/impl/WRTypesImpl.scala +++ b/sc/shared/src/main/scala/wrappers/scalan/impl/WRTypesImpl.scala @@ -1,7 +1,7 @@ package wrappers.scalan import scala.language.{existentials,implicitConversions} -import scalan.RType +import sigma.core.RType import special.wrappers.WrappersModule import special.wrappers.RTypeWrapSpec import scala.collection.compat.immutable.ArraySeq diff --git a/sc/shared/src/main/scala/wrappers/special/impl/WSpecialPredefsImpl.scala b/sc/shared/src/main/scala/wrappers/special/impl/WSpecialPredefsImpl.scala index b13b170634..0efa5348da 100644 --- a/sc/shared/src/main/scala/wrappers/special/impl/WSpecialPredefsImpl.scala +++ b/sc/shared/src/main/scala/wrappers/special/impl/WSpecialPredefsImpl.scala @@ -5,6 +5,7 @@ import scalan._ import special.wrappers.WrappersModule package impl { + import sigma.core.Nullable import sigma.reflection.RClass // Abs ----------------------------------- diff --git a/sc/shared/src/test/scala/org/ergoplatform/dsl/TestContractSpec.scala b/sc/shared/src/test/scala/org/ergoplatform/dsl/TestContractSpec.scala index 54e773ea35..8d260ccee0 100644 --- a/sc/shared/src/test/scala/org/ergoplatform/dsl/TestContractSpec.scala +++ b/sc/shared/src/test/scala/org/ergoplatform/dsl/TestContractSpec.scala @@ -7,7 +7,7 @@ import sigmastate.interpreter.{CostedProverResult, ProverResult} import scala.collection.mutable.ArrayBuffer import org.ergoplatform.ErgoBox.{NonMandatoryRegisterId, TokenId} -import scalan.Nullable +import sigma.core.Nullable import scala.util.Try import org.ergoplatform.{ErgoBox, ErgoLikeContext} diff --git a/sc/shared/src/test/scala/scalan/TestContexts.scala b/sc/shared/src/test/scala/scalan/TestContexts.scala index 70e32d04ff..9811473d3a 100644 --- a/sc/shared/src/test/scala/scalan/TestContexts.scala +++ b/sc/shared/src/test/scala/scalan/TestContexts.scala @@ -1,7 +1,7 @@ package scalan import sigma.reflection.RMethod -import sigma.CoreLibReflection +import sigma.{BaseNestedTests, BaseShouldTests, BaseTests, CoreLibReflection, TestUtils} trait TestContexts extends TestUtils { diff --git a/sc/shared/src/test/scala/scalan/core/ScalaNameUtilSuite.scala b/sc/shared/src/test/scala/scalan/core/ScalaNameUtilSuite.scala index 0d4e2ecbdf..443735d0e6 100644 --- a/sc/shared/src/test/scala/scalan/core/ScalaNameUtilSuite.scala +++ b/sc/shared/src/test/scala/scalan/core/ScalaNameUtilSuite.scala @@ -1,6 +1,6 @@ package scalan.core -import scalan.BaseTests +import sigma.BaseTests import sigma.reflection.CommonReflection.registerClassEntry import sigma.reflection.{RClass, mkMethod} diff --git a/sc/shared/src/test/scala/sigmastate/ErgoTreeSpecification.scala b/sc/shared/src/test/scala/sigmastate/ErgoTreeSpecification.scala index e752eaf9ea..9e8f5d7fb3 100644 --- a/sc/shared/src/test/scala/sigmastate/ErgoTreeSpecification.scala +++ b/sc/shared/src/test/scala/sigmastate/ErgoTreeSpecification.scala @@ -3,8 +3,8 @@ package sigmastate import org.ergoplatform.settings.ErgoAlgos import org.ergoplatform.validation.{ValidationException, ValidationRules} import org.ergoplatform.{ErgoAddressEncoder, ErgoBox, ErgoLikeContext, Self} -import scalan.RType.asType -import scalan.{Nullable, RType} +import sigma.core.RType.asType +import sigma.core.{Nullable, RType} import sigma.VersionContext import sigmastate.SCollection.{SByteArray, checkValidFlatmap} import sigmastate.Values._ diff --git a/sc/shared/src/test/scala/sigmastate/helpers/CompilerTestingCommons.scala b/sc/shared/src/test/scala/sigmastate/helpers/CompilerTestingCommons.scala index 1a750f3a19..2af556d8ab 100644 --- a/sc/shared/src/test/scala/sigmastate/helpers/CompilerTestingCommons.scala +++ b/sc/shared/src/test/scala/sigmastate/helpers/CompilerTestingCommons.scala @@ -7,7 +7,9 @@ import org.scalacheck.Arbitrary.arbByte import org.scalacheck.Gen import org.scalatest.Assertion import sigma.util.BenchmarkUtil -import scalan.{RType, TestContexts, TestUtils} +import scalan.TestContexts +import sigma.TestUtils +import sigma.core.RType import sigmastate.Values.{Constant, ErgoTree, SValue, SigmaBoolean, SigmaPropValue} import sigmastate.eval._ import sigmastate.helpers.TestingHelpers._ diff --git a/sc/shared/src/test/scala/sigmastate/helpers/SigmaPPrint.scala b/sc/shared/src/test/scala/sigmastate/helpers/SigmaPPrint.scala index 1bfd11dea5..36c9c8a456 100644 --- a/sc/shared/src/test/scala/sigmastate/helpers/SigmaPPrint.scala +++ b/sc/shared/src/test/scala/sigmastate/helpers/SigmaPPrint.scala @@ -5,8 +5,8 @@ import org.ergoplatform.ErgoBox import org.ergoplatform.ErgoBox.RegisterId import org.ergoplatform.settings.ErgoAlgos import pprint.{PPrinter, Tree} -import scalan.RType -import scalan.RType.PrimitiveType +import sigma.core.RType +import sigma.core.RType.PrimitiveType import sigmastate.SCollection._ import sigmastate.Values.{ConstantNode, ErgoTree, FuncValue, ValueCompanion} import sigmastate._ diff --git a/sc/shared/src/test/scala/sigmastate/utxo/BasicOpsSpecification.scala b/sc/shared/src/test/scala/sigmastate/utxo/BasicOpsSpecification.scala index efdae595ff..ffb1fc3a18 100644 --- a/sc/shared/src/test/scala/sigmastate/utxo/BasicOpsSpecification.scala +++ b/sc/shared/src/test/scala/sigmastate/utxo/BasicOpsSpecification.scala @@ -3,7 +3,7 @@ package sigmastate.utxo import java.math.BigInteger import org.ergoplatform.ErgoBox.{AdditionalRegisters, R6, R8} import org.ergoplatform._ -import scalan.RType +import sigma.core.RType import sigmastate.SCollection.SByteArray import sigmastate.Values._ import sigmastate._ diff --git a/sc/shared/src/test/scala/special/sigma/DataValueComparerSpecification.scala b/sc/shared/src/test/scala/special/sigma/DataValueComparerSpecification.scala index 697823e50f..8749d6e52a 100644 --- a/sc/shared/src/test/scala/special/sigma/DataValueComparerSpecification.scala +++ b/sc/shared/src/test/scala/special/sigma/DataValueComparerSpecification.scala @@ -1,7 +1,7 @@ package sigma import org.scalatest.BeforeAndAfterAll -import scalan.RType +import sigma.core.RType import sigma.util.BenchmarkUtil import sigmastate.{DataValueComparer, JitCost, TrivialProp} import sigmastate.Values.ErgoTree diff --git a/sc/shared/src/test/scala/special/sigma/SigmaDslSpecification.scala b/sc/shared/src/test/scala/special/sigma/SigmaDslSpecification.scala index 523d0af2af..eb238964c0 100644 --- a/sc/shared/src/test/scala/special/sigma/SigmaDslSpecification.scala +++ b/sc/shared/src/test/scala/special/sigma/SigmaDslSpecification.scala @@ -4,7 +4,7 @@ import java.math.BigInteger import org.ergoplatform._ import org.ergoplatform.settings.ErgoAlgos import org.scalacheck.{Arbitrary, Gen} -import scalan.{ExactIntegral, ExactNumeric, ExactOrdering, RType} +import sigma.core.{ExactIntegral, ExactNumeric, ExactOrdering, RType} import scorex.crypto.authds.avltree.batch._ import scorex.crypto.authds.{ADKey, ADValue} import scorex.crypto.hash.{Blake2b256, Digest32} @@ -33,7 +33,7 @@ import org.ergoplatform.ErgoBox.AdditionalRegisters import org.scalacheck.Arbitrary._ import org.scalacheck.Gen.frequency import org.scalatest.{BeforeAndAfterAll, Tag} -import scalan.RType._ +import sigma.core.RType._ import scorex.util.ModifierId import sigmastate.basics.ProveDHTuple import sigmastate.interpreter._ diff --git a/sc/shared/src/test/scala/special/sigma/SigmaDslTesting.scala b/sc/shared/src/test/scala/special/sigma/SigmaDslTesting.scala index 1b0da1058d..68d74fdca1 100644 --- a/sc/shared/src/test/scala/special/sigma/SigmaDslTesting.scala +++ b/sc/shared/src/test/scala/special/sigma/SigmaDslTesting.scala @@ -13,8 +13,8 @@ import org.scalatest.matchers.should.Matchers import org.scalatest.propspec.AnyPropSpec import org.scalatestplus.scalacheck.ScalaCheckPropertyChecks import scalan.Platform.threadSleepOrNoOp -import scalan.RType -import scalan.RType._ +import sigma.core.RType +import sigma.core.RType._ import sigma.util.BenchmarkUtil import sigma.util.CollectionUtil._ import sigma.util.Extensions._ diff --git a/sc/shared/src/test/scala/special/wrappers/WRTypeTests.scala b/sc/shared/src/test/scala/special/wrappers/WRTypeTests.scala index 0378e7fbc3..400a4355f6 100644 --- a/sc/shared/src/test/scala/special/wrappers/WRTypeTests.scala +++ b/sc/shared/src/test/scala/special/wrappers/WRTypeTests.scala @@ -1,6 +1,6 @@ package special.wrappers -import scalan.RType +import sigma.core.RType import scala.language.reflectiveCalls diff --git a/sc/shared/src/test/scala/special/wrappers/WSpecialPredefTests.scala b/sc/shared/src/test/scala/special/wrappers/WSpecialPredefTests.scala index 2321d32577..f3e07be7d9 100644 --- a/sc/shared/src/test/scala/special/wrappers/WSpecialPredefTests.scala +++ b/sc/shared/src/test/scala/special/wrappers/WSpecialPredefTests.scala @@ -2,7 +2,7 @@ package special.wrappers import scala.language.reflectiveCalls -import scalan.RType +import sigma.core.RType class WSpecialPredefTests extends WrappersTests { diff --git a/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Isos.scala b/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Isos.scala index ff5e31d812..dedaa1fcd0 100644 --- a/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Isos.scala +++ b/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Isos.scala @@ -5,7 +5,7 @@ import org.ergoplatform.sdk.JavaHelpers.UniversalConverter import org.ergoplatform.sdk.{ExtendedInputBox, Iso} import org.ergoplatform.sdk.wallet.protocol.context import org.ergoplatform._ -import scalan.RType +import sigma.core.RType import scorex.crypto.authds.ADKey import scorex.util.ModifierId import scorex.util.encode.Base16 diff --git a/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Type.scala b/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Type.scala index 13ecc6cec5..846407737b 100644 --- a/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Type.scala +++ b/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Type.scala @@ -1,6 +1,6 @@ package org.ergoplatform.sdk.js -import scalan.RType +import sigma.core.RType import scala.scalajs.js import scala.scalajs.js.annotation.JSExportTopLevel diff --git a/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Value.scala b/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Value.scala index 4802c90c81..720f2d5799 100644 --- a/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Value.scala +++ b/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Value.scala @@ -1,8 +1,8 @@ package org.ergoplatform.sdk.js import org.ergoplatform.sdk.js.Value.toRuntimeData -import scalan.RType -import scalan.RType.PairType +import sigma.core.RType +import sigma.core.RType.PairType import scorex.util.Extensions.{IntOps, LongOps} import scorex.util.encode.Base16 import sigmastate.SType diff --git a/sdk/shared/src/main/scala/org/ergoplatform/sdk/DataJsonEncoder.scala b/sdk/shared/src/main/scala/org/ergoplatform/sdk/DataJsonEncoder.scala index 822351072f..71e460cd42 100644 --- a/sdk/shared/src/main/scala/org/ergoplatform/sdk/DataJsonEncoder.scala +++ b/sdk/shared/src/main/scala/org/ergoplatform/sdk/DataJsonEncoder.scala @@ -6,7 +6,7 @@ import io.circe.syntax._ import org.ergoplatform.ErgoBox import org.ergoplatform.ErgoBox.{NonMandatoryRegisterId, Token} import org.ergoplatform.settings.ErgoAlgos -import scalan.RType +import sigma.core.RType import scorex.util._ import sigmastate.Values.{Constant, EvaluatedValue} import sigmastate._ diff --git a/sdk/shared/src/main/scala/org/ergoplatform/sdk/Extensions.scala b/sdk/shared/src/main/scala/org/ergoplatform/sdk/Extensions.scala index 5618f3e8f2..883133c0cd 100644 --- a/sdk/shared/src/main/scala/org/ergoplatform/sdk/Extensions.scala +++ b/sdk/shared/src/main/scala/org/ergoplatform/sdk/Extensions.scala @@ -1,8 +1,8 @@ package org.ergoplatform.sdk import debox.cfor -import scalan.RType -import scalan.rtypeToClassTag // actually used +import sigma.core.RType +import sigma.core.rtypeToClassTag // actually used import sigmastate.eval.CPreHeader import sigma.{Coll, CollBuilder, PairColl} import sigma.{Header, PreHeader} diff --git a/sdk/shared/src/main/scala/org/ergoplatform/sdk/JavaHelpers.scala b/sdk/shared/src/main/scala/org/ergoplatform/sdk/JavaHelpers.scala index 7a76539ac8..e0d41818ac 100644 --- a/sdk/shared/src/main/scala/org/ergoplatform/sdk/JavaHelpers.scala +++ b/sdk/shared/src/main/scala/org/ergoplatform/sdk/JavaHelpers.scala @@ -1,6 +1,6 @@ package org.ergoplatform.sdk -import scalan.RType +import sigma.core.RType import sigma.Coll import scala.collection.{JavaConverters, mutable} @@ -26,7 +26,7 @@ import org.ergoplatform.sdk.JavaHelpers.{TokenColl, TokenIdRType} import org.ergoplatform.sdk.Extensions.{CollBuilderOps, PairCollOps} import org.ergoplatform.sdk.wallet.{Constants, TokensMap} import org.ergoplatform.sdk.wallet.secrets.{DerivationPath, ExtendedSecretKey} -import scalan.ExactIntegral.LongIsExactIntegral +import sigma.core.ExactIntegral.LongIsExactIntegral import sigma.util.StringUtil.StringUtilExtensions import sigmastate.basics.CryptoConstants.EcPointType import sigmastate.basics.{DiffieHellmanTupleProverInput, ProveDHTuple} diff --git a/sdk/shared/src/main/scala/org/ergoplatform/sdk/OutBoxBuilder.scala b/sdk/shared/src/main/scala/org/ergoplatform/sdk/OutBoxBuilder.scala index 5c2f531588..0a5bd8c1d0 100644 --- a/sdk/shared/src/main/scala/org/ergoplatform/sdk/OutBoxBuilder.scala +++ b/sdk/shared/src/main/scala/org/ergoplatform/sdk/OutBoxBuilder.scala @@ -3,7 +3,7 @@ package org.ergoplatform.sdk import org.ergoplatform.ErgoBox.TokenId import org.ergoplatform.sdk.JavaHelpers.collRType import org.ergoplatform.{ErgoBox, ErgoBoxCandidate, SigmaConstants} -import scalan.RType +import sigma.core.RType import sigmastate.SType import sigmastate.Values.{Constant, ErgoTree, EvaluatedValue} import sigmastate.eval.Colls diff --git a/sdk/shared/src/main/scala/org/ergoplatform/sdk/Utils.scala b/sdk/shared/src/main/scala/org/ergoplatform/sdk/Utils.scala index f706a09f96..4c5e8a9df5 100644 --- a/sdk/shared/src/main/scala/org/ergoplatform/sdk/Utils.scala +++ b/sdk/shared/src/main/scala/org/ergoplatform/sdk/Utils.scala @@ -1,6 +1,6 @@ package org.ergoplatform.sdk -import scalan.ExactIntegral +import sigma.core.ExactIntegral import scala.collection.mutable import scala.reflect.ClassTag diff --git a/sdk/shared/src/main/scala/org/ergoplatform/sdk/utils/Zero.scala b/sdk/shared/src/main/scala/org/ergoplatform/sdk/utils/Zero.scala index 6e1a782e5c..efaad43446 100644 --- a/sdk/shared/src/main/scala/org/ergoplatform/sdk/utils/Zero.scala +++ b/sdk/shared/src/main/scala/org/ergoplatform/sdk/utils/Zero.scala @@ -1,8 +1,8 @@ package org.ergoplatform.sdk.utils import org.ergoplatform.ErgoBox -import scalan.RType -import scalan.RType._ +import sigma.core.RType +import sigma.core.RType._ import scorex.crypto.authds.avltree.batch.BatchAVLProver import scorex.crypto.hash.{Blake2b256, Digest32} import scorex.util.ModifierId diff --git a/sdk/shared/src/test/scala/org/ergoplatform/sdk/DataJsonEncoderSpecification.scala b/sdk/shared/src/test/scala/org/ergoplatform/sdk/DataJsonEncoderSpecification.scala index d89ac0f6c5..bc6e9faaf8 100644 --- a/sdk/shared/src/test/scala/org/ergoplatform/sdk/DataJsonEncoderSpecification.scala +++ b/sdk/shared/src/test/scala/org/ergoplatform/sdk/DataJsonEncoderSpecification.scala @@ -4,7 +4,7 @@ package org.ergoplatform.sdk import java.math.BigInteger import org.scalacheck.Arbitrary._ -import scalan.RType +import sigma.core.RType import sigmastate.SCollection.SByteArray import sigmastate.SType.AnyOps import sigmastate.Values.SigmaBoolean diff --git a/sdk/shared/src/test/scala/org/ergoplatform/sdk/ExtensionsSpec.scala b/sdk/shared/src/test/scala/org/ergoplatform/sdk/ExtensionsSpec.scala index 427f83d049..70fa40910e 100644 --- a/sdk/shared/src/test/scala/org/ergoplatform/sdk/ExtensionsSpec.scala +++ b/sdk/shared/src/test/scala/org/ergoplatform/sdk/ExtensionsSpec.scala @@ -5,7 +5,7 @@ import org.scalatest.propspec.AnyPropSpec import org.scalatestplus.scalacheck.ScalaCheckPropertyChecks import sigma.Coll import org.ergoplatform.sdk.Extensions.{CollBuilderOps, CollOps, GenIterableOps, PairCollOps} -import scalan.RType +import sigma.core.RType import sigma.CollGens import sigmastate.eval.CostingSigmaDslBuilder From 6e7ab0f69a30d6b1667023c32b82c2d9387ca83f Mon Sep 17 00:00:00 2001 From: Alexander Slesarenko Date: Wed, 23 Aug 2023 02:28:06 +0200 Subject: [PATCH 13/37] minimize-modules: fix packages --- common/shared/src/test/scala/sigma/collection/CollGens.scala | 4 +++- .../shared/src/test/scala/sigma/collection/CollsTests.scala | 5 +++-- .../src/test/scala/special/collections/BenchmarkGens.scala | 1 + .../src/test/scala/org/ergoplatform/sdk/ExtensionsSpec.scala | 2 +- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/common/shared/src/test/scala/sigma/collection/CollGens.scala b/common/shared/src/test/scala/sigma/collection/CollGens.scala index 7726bd0909..126bdf79b8 100644 --- a/common/shared/src/test/scala/sigma/collection/CollGens.scala +++ b/common/shared/src/test/scala/sigma/collection/CollGens.scala @@ -1,10 +1,12 @@ -package sigma +package sigma.collection import org.scalacheck.util.Buildable import org.scalacheck.{Arbitrary, Gen} +import sigma.{Coll, CollBuilder, CollOverArrayBuilder, PairColl} import sigma.core._ import sigma.core.RType import spire.scalacompat.BuilderCompat + import scala.collection.mutable import scala.collection.mutable.ArrayBuffer diff --git a/common/shared/src/test/scala/sigma/collection/CollsTests.scala b/common/shared/src/test/scala/sigma/collection/CollsTests.scala index bd8b9cb005..67d9dbc537 100644 --- a/common/shared/src/test/scala/sigma/collection/CollsTests.scala +++ b/common/shared/src/test/scala/sigma/collection/CollsTests.scala @@ -1,13 +1,14 @@ -package sigma +package sigma.collection import org.scalacheck.Gen import org.scalatest.exceptions.TestFailedException import org.scalatest.matchers.should.Matchers import org.scalatest.propspec.AnyPropSpec import org.scalatestplus.scalacheck.ScalaCheckPropertyChecks +import sigma.{Coll, CollOverArray, PairOfCols, VersionContext, VersionTestingProperty} import sigma.core._ -import scala.language.{existentials} +import scala.language.existentials class CollsTests extends AnyPropSpec with ScalaCheckPropertyChecks with Matchers with CollGens with VersionTestingProperty { testSuite => import Gen._ diff --git a/sc/jvm/src/test/scala/special/collections/BenchmarkGens.scala b/sc/jvm/src/test/scala/special/collections/BenchmarkGens.scala index 3421d42343..74684194be 100644 --- a/sc/jvm/src/test/scala/special/collections/BenchmarkGens.scala +++ b/sc/jvm/src/test/scala/special/collections/BenchmarkGens.scala @@ -2,6 +2,7 @@ package sigma import org.scalameter.KeyValue import org.scalameter.api.{Bench, Gen, _} +import sigma.collection.CollGens trait BenchmarkGens extends CollGens { suite: Bench[Double] => def maxSize = 100000 diff --git a/sdk/shared/src/test/scala/org/ergoplatform/sdk/ExtensionsSpec.scala b/sdk/shared/src/test/scala/org/ergoplatform/sdk/ExtensionsSpec.scala index 70fa40910e..c84918d128 100644 --- a/sdk/shared/src/test/scala/org/ergoplatform/sdk/ExtensionsSpec.scala +++ b/sdk/shared/src/test/scala/org/ergoplatform/sdk/ExtensionsSpec.scala @@ -5,8 +5,8 @@ import org.scalatest.propspec.AnyPropSpec import org.scalatestplus.scalacheck.ScalaCheckPropertyChecks import sigma.Coll import org.ergoplatform.sdk.Extensions.{CollBuilderOps, CollOps, GenIterableOps, PairCollOps} +import sigma.collection.CollGens import sigma.core.RType -import sigma.CollGens import sigmastate.eval.CostingSigmaDslBuilder class ExtensionsSpec extends AnyPropSpec with ScalaCheckPropertyChecks with Matchers with CollGens { From b4e344e624720f6be3b5deaac7736bf46d4db2be Mon Sep 17 00:00:00 2001 From: Alexander Slesarenko Date: Thu, 24 Aug 2023 12:20:39 +0200 Subject: [PATCH 14/37] minimize-modules: move from sigmastate.basics -> crypto --- .../src/main/scala/sigma/core/package.scala | 7 --- .../shared/src/main/scala/sigma/package.scala | 7 ++- .../scala/sigma/collection/CollGens.scala | 3 +- .../scala/sigma/collection/CollsTests.scala | 2 +- .../scala/sigmastate/crypto/Platform.scala | 1 - .../scala/org/ergoplatform/ErgoAddress.scala | 2 +- .../org/ergoplatform/ErgoTreePredef.scala | 4 +- .../org/ergoplatform/SigmaConstants.scala | 2 +- .../main/scala/sigmastate/AvlTreeData.scala | 2 +- .../scala/sigmastate/DataValueComparer.scala | 6 +- .../sigmastate/InterpreterReflection.scala | 2 +- .../main/scala/sigmastate/SigSerializer.scala | 6 +- .../main/scala/sigmastate/UncheckedTree.scala | 7 +-- .../main/scala/sigmastate/UnprovenTree.scala | 6 +- .../src/main/scala/sigmastate/Values.scala | 6 +- .../{basics => crypto}/BcDlogGroup.scala | 2 +- .../{basics => crypto}/CryptoConstants.scala | 3 +- .../{basics => crypto}/CryptoFunctions.scala | 2 +- .../{basics => crypto}/DLogProtocol.scala | 5 +- .../DiffieHellmanTupleProtocol.scala | 7 +-- .../{basics => crypto}/DlogGroup.scala | 3 +- .../SigmaProtocolFunctions.scala | 6 +- .../sigmastate/eval/CostingDataContext.scala | 6 +- .../main/scala/sigmastate/eval/package.scala | 2 +- .../scala/sigmastate/interpreter/Hint.scala | 4 +- .../sigmastate/interpreter/Interpreter.scala | 6 +- .../interpreter/ProverInterpreter.scala | 6 +- .../sigmastate/interpreter/ProverUtils.scala | 5 +- .../GroupElementSerializer.scala | 2 +- .../serialization/ProveDlogSerializer.scala | 4 +- .../transformers/ProveDHTupleSerializer.scala | 4 +- .../src/main/scala/sigmastate/trees.scala | 2 +- .../src/main/scala/sigmastate/types.scala | 2 +- .../main/scala/sigmastate/utils/Helpers.scala | 2 +- .../SigmaProtocolSpecification.scala | 2 +- .../crypto/GroupLawsSpecification.scala | 2 +- .../crypto/SigningSpecification.scala | 4 +- .../scala/sigmastate/eval/BasicOpsTests.scala | 2 +- ...ntextEnrichingTestProvingInterpreter.scala | 4 +- .../helpers/ErgoLikeContextTesting.scala | 2 +- .../ErgoLikeTestProvingInterpreter.scala | 4 +- .../sigmastate/helpers/TestingCommons.scala | 2 +- .../ConstantSerializerSpecification.scala | 2 +- .../DataSerializerSpecification.scala | 2 +- .../GroupElementSerializerSpecification.scala | 2 +- .../PDHTSerializerSpecification.scala | 2 +- .../ProveDlogSerializerSpec.scala | 2 +- .../SigSerializerSpecification.scala | 6 +- .../generators/ObjectGenerators.scala | 6 +- .../sigmastate/utxo/ProverSpecification.scala | 4 +- .../special/sigma/SigmaTestingData.scala | 6 +- .../lang/exceptions/Exceptions.scala | 55 ------------------- .../scala/sigmastate/lang/LangTests.scala | 4 +- .../scala/sigmastate/eval/GraphBuilding.scala | 2 +- .../scala/sigmastate/eval/TreeBuilding.scala | 4 +- .../ErgoAddressSpecification.scala | 6 +- .../org/ergoplatform/ErgoTreePredefSpec.scala | 2 +- .../TestingInterpreterSpecification.scala | 4 +- .../sigmastate/eval/EvaluationTest.scala | 2 +- .../sigmastate/helpers/SigmaPPrint.scala | 2 +- .../sigmastate/lang/SigmaTyperTest.scala | 4 +- .../DeserializationResilience.scala | 2 +- .../utxo/BasicOpsSpecification.scala | 2 +- .../ErgoLikeInterpreterSpecification.scala | 6 +- .../utxo/ThresholdSpecification.scala | 2 +- .../examples/CoopExampleSpecification.scala | 2 +- .../DHTupleExampleSpecification.scala | 4 +- .../sigmastate/utxo/examples/IcoExample.scala | 2 +- .../examples/MixExampleSpecification.scala | 4 +- .../OracleExamplesSpecification.scala | 2 +- .../RPSGameExampleSpecification.scala | 2 +- .../XorGameExampleSpecification.scala | 2 +- .../special/sigma/SigmaDslSpecification.scala | 4 +- .../scala/special/sigma/SigmaDslTesting.scala | 4 +- .../org/ergoplatform/sdk/js/SigmaProp.scala | 2 +- .../org/ergoplatform/sdk/js/ValueSpec.scala | 4 +- .../sdk/AppkitProvingInterpreter.scala | 4 +- .../org/ergoplatform/sdk/Extensions.scala | 2 +- .../org/ergoplatform/sdk/JavaHelpers.scala | 6 +- .../org/ergoplatform/sdk/ProverBuilder.scala | 4 +- .../org/ergoplatform/sdk/utils/Zero.scala | 2 +- .../wallet/secrets/ExtendedPublicKey.scala | 5 +- .../wallet/secrets/ExtendedSecretKey.scala | 8 +-- .../sdk/wallet/secrets/SecretKey.scala | 4 +- .../sdk/DataJsonEncoderSpecification.scala | 2 +- .../sdk/JsonSerializationSpec.scala | 4 +- .../sdk/wallet/utils/Generators.scala | 2 +- 87 files changed, 148 insertions(+), 214 deletions(-) rename interpreter/shared/src/main/scala/sigmastate/{basics => crypto}/BcDlogGroup.scala (99%) rename interpreter/shared/src/main/scala/sigmastate/{basics => crypto}/CryptoConstants.scala (97%) rename interpreter/shared/src/main/scala/sigmastate/{basics => crypto}/CryptoFunctions.scala (95%) rename interpreter/shared/src/main/scala/sigmastate/{basics => crypto}/DLogProtocol.scala (97%) rename interpreter/shared/src/main/scala/sigmastate/{basics => crypto}/DiffieHellmanTupleProtocol.scala (97%) rename interpreter/shared/src/main/scala/sigmastate/{basics => crypto}/DlogGroup.scala (98%) rename interpreter/shared/src/main/scala/sigmastate/{basics => crypto}/SigmaProtocolFunctions.scala (95%) delete mode 100644 interpreter/src/main/scala/sigmastate/lang/exceptions/Exceptions.scala diff --git a/common/shared/src/main/scala/sigma/core/package.scala b/common/shared/src/main/scala/sigma/core/package.scala index 4ad876fc2c..5bf1562a68 100644 --- a/common/shared/src/main/scala/sigma/core/package.scala +++ b/common/shared/src/main/scala/sigma/core/package.scala @@ -1,14 +1,7 @@ package sigma - -import scala.reflect.ClassTag - package object core { - /** Allows implicit resolution to find appropriate instance of ClassTag in - * the scope where RType is implicitly available. */ - implicit def rtypeToClassTag[A](implicit t: RType[A]): ClassTag[A] = t.classTag - /** Immutable empty array of integers, should be used instead of allocating new empty arrays. */ val EmptyArrayOfInt = Array.empty[Int] diff --git a/common/shared/src/main/scala/sigma/package.scala b/common/shared/src/main/scala/sigma/package.scala index df7b301f85..44368a0ade 100644 --- a/common/shared/src/main/scala/sigma/package.scala +++ b/common/shared/src/main/scala/sigma/package.scala @@ -3,7 +3,7 @@ import java.math.BigInteger import sigma.core.RType import sigma.core.RType.{GeneralType, SomeType} -import scala.reflect.classTag +import scala.reflect.{ClassTag, classTag} /** The following implicit values are used as type descriptors of all the predefined Sigma types. * @see [[RType]] class @@ -33,6 +33,11 @@ package object sigma { /** Implicit resolution of `Coll[A]` type descriptor, given a descriptor of `A`. */ implicit def collRType[A](implicit tA: RType[A]): RType[Coll[A]] = CollType[A](tA) + /** Allows implicit resolution to find appropriate instance of ClassTag in + * the scope where RType is implicitly available. + */ + implicit def rtypeToClassTag[A](implicit t: RType[A]): ClassTag[A] = t.classTag + implicit val collBuilderRType: RType[CollBuilder] = RType.fromClassTag(classTag[CollBuilder]) private def sameLengthErrorMsg[A, B](xs: Coll[A], ys: Coll[B]) = diff --git a/common/shared/src/test/scala/sigma/collection/CollGens.scala b/common/shared/src/test/scala/sigma/collection/CollGens.scala index 126bdf79b8..a203124c14 100644 --- a/common/shared/src/test/scala/sigma/collection/CollGens.scala +++ b/common/shared/src/test/scala/sigma/collection/CollGens.scala @@ -1,9 +1,10 @@ package sigma.collection +import scala.language.implicitConversions import org.scalacheck.util.Buildable import org.scalacheck.{Arbitrary, Gen} import sigma.{Coll, CollBuilder, CollOverArrayBuilder, PairColl} -import sigma.core._ +import sigma._ import sigma.core.RType import spire.scalacompat.BuilderCompat diff --git a/common/shared/src/test/scala/sigma/collection/CollsTests.scala b/common/shared/src/test/scala/sigma/collection/CollsTests.scala index 67d9dbc537..1f24d1959c 100644 --- a/common/shared/src/test/scala/sigma/collection/CollsTests.scala +++ b/common/shared/src/test/scala/sigma/collection/CollsTests.scala @@ -5,7 +5,7 @@ import org.scalatest.exceptions.TestFailedException import org.scalatest.matchers.should.Matchers import org.scalatest.propspec.AnyPropSpec import org.scalatestplus.scalacheck.ScalaCheckPropertyChecks -import sigma.{Coll, CollOverArray, PairOfCols, VersionContext, VersionTestingProperty} +import sigma._ import sigma.core._ import scala.language.existentials diff --git a/interpreter/jvm/src/main/scala/sigmastate/crypto/Platform.scala b/interpreter/jvm/src/main/scala/sigmastate/crypto/Platform.scala index 388dfb8df9..1c6d822f3a 100644 --- a/interpreter/jvm/src/main/scala/sigmastate/crypto/Platform.scala +++ b/interpreter/jvm/src/main/scala/sigmastate/crypto/Platform.scala @@ -9,7 +9,6 @@ import sigma.core.RType import java.math.BigInteger import sigmastate._ -import sigmastate.basics.BcDlogGroup import sigma.Coll import sigma._ diff --git a/interpreter/shared/src/main/scala/org/ergoplatform/ErgoAddress.scala b/interpreter/shared/src/main/scala/org/ergoplatform/ErgoAddress.scala index bb97286e16..483a0c1dde 100644 --- a/interpreter/shared/src/main/scala/org/ergoplatform/ErgoAddress.scala +++ b/interpreter/shared/src/main/scala/org/ergoplatform/ErgoAddress.scala @@ -6,7 +6,7 @@ import scorex.crypto.hash.{Digest32, Blake2b256} import scorex.util.encode.Base58 import sigmastate.Values._ import sigmastate._ -import sigmastate.basics.DLogProtocol.{ProveDlogProp, ProveDlog} +import sigmastate.crypto.DLogProtocol.{ProveDlogProp, ProveDlog} import sigmastate.exceptions.SigmaException import sigmastate.serialization._ import sigmastate.utxo.{DeserializeContext, Slice} diff --git a/interpreter/shared/src/main/scala/org/ergoplatform/ErgoTreePredef.scala b/interpreter/shared/src/main/scala/org/ergoplatform/ErgoTreePredef.scala index d8fbf16b8f..8f01a46864 100644 --- a/interpreter/shared/src/main/scala/org/ergoplatform/ErgoTreePredef.scala +++ b/interpreter/shared/src/main/scala/org/ergoplatform/ErgoTreePredef.scala @@ -1,8 +1,8 @@ package org.ergoplatform import org.ergoplatform.settings.MonetarySettings -import sigmastate.basics.DLogProtocol.ProveDlog -import sigmastate.basics.CryptoConstants +import sigmastate.crypto.DLogProtocol.ProveDlog +import sigmastate.crypto.CryptoConstants import sigmastate.serialization.ErgoTreeSerializer.DefaultSerializer import sigmastate.SCollection.SByteArray import sigmastate.Values.{LongConstant, SigmaPropConstant, IntArrayConstant, TrueSigmaProp, Value, FalseSigmaProp, SigmaPropValue, IntConstant, ErgoTree} diff --git a/interpreter/shared/src/main/scala/org/ergoplatform/SigmaConstants.scala b/interpreter/shared/src/main/scala/org/ergoplatform/SigmaConstants.scala index 4f4bacc298..74dc98ade9 100644 --- a/interpreter/shared/src/main/scala/org/ergoplatform/SigmaConstants.scala +++ b/interpreter/shared/src/main/scala/org/ergoplatform/SigmaConstants.scala @@ -1,7 +1,7 @@ package org.ergoplatform import sigma.util.CollectionUtil.TraversableOps // used in Scala 2.11 -import sigmastate.basics.CryptoConstants +import sigmastate.crypto.CryptoConstants /** Descriptor of a constant which represents some size value. * @tparam T type of the constant value diff --git a/interpreter/shared/src/main/scala/sigmastate/AvlTreeData.scala b/interpreter/shared/src/main/scala/sigmastate/AvlTreeData.scala index 23188cfa49..042df327b5 100644 --- a/interpreter/shared/src/main/scala/sigmastate/AvlTreeData.scala +++ b/interpreter/shared/src/main/scala/sigmastate/AvlTreeData.scala @@ -1,6 +1,6 @@ package sigmastate -import sigmastate.basics.CryptoConstants +import sigmastate.crypto.CryptoConstants import sigmastate.eval.Colls import sigmastate.serialization.SigmaSerializer import sigmastate.utils.{SigmaByteReader, SigmaByteWriter} diff --git a/interpreter/shared/src/main/scala/sigmastate/DataValueComparer.scala b/interpreter/shared/src/main/scala/sigmastate/DataValueComparer.scala index 05c104d494..194e545310 100644 --- a/interpreter/shared/src/main/scala/sigmastate/DataValueComparer.scala +++ b/interpreter/shared/src/main/scala/sigmastate/DataValueComparer.scala @@ -4,10 +4,10 @@ import sigma.core.{AVHashMap, Nullable, RType} import debox.{cfor, sp} import sigma.core.RType._ import sigmastate.Values.SigmaBoolean -import sigmastate.basics.DLogProtocol.ProveDlog -import sigmastate.basics.ProveDHTuple +import sigmastate.crypto.DLogProtocol.ProveDlog +import sigmastate.crypto.ProveDHTuple import sigmastate.eval.SigmaDsl -import sigmastate.basics.CryptoConstants.EcPointType +import sigmastate.crypto.CryptoConstants.EcPointType import sigmastate.interpreter.{ErgoTreeEvaluator, NamedDesc, OperationCostInfo} import sigma.{AvlTree, AvlTreeRType, BigInt, BigIntRType, Box, BoxRType, GroupElement, GroupElementRType, Header, HeaderRType, PreHeader, PreHeaderRType, SigmaProp} import sigma.{Coll, CollOverArray, PairOfCols} diff --git a/interpreter/shared/src/main/scala/sigmastate/InterpreterReflection.scala b/interpreter/shared/src/main/scala/sigmastate/InterpreterReflection.scala index cdde62557f..4f89b9a465 100644 --- a/interpreter/shared/src/main/scala/sigmastate/InterpreterReflection.scala +++ b/interpreter/shared/src/main/scala/sigmastate/InterpreterReflection.scala @@ -8,7 +8,7 @@ import sigma.{AvlTree, CoreLibReflection, SigmaDslBuilder} import sigmastate.SAvlTree.KeyValueColl import sigmastate.SCollection.{SBooleanArray, SByteArray, SIntArray} import sigmastate.Values._ -import sigmastate.basics.VerifierMessage.Challenge +import sigmastate.crypto.VerifierMessage.Challenge import sigmastate.crypto.GF2_192_Poly import sigmastate.interpreter.ErgoTreeEvaluator import sigmastate.lang.Terms._ diff --git a/interpreter/shared/src/main/scala/sigmastate/SigSerializer.scala b/interpreter/shared/src/main/scala/sigmastate/SigSerializer.scala index d71424aa01..20341cbcc6 100644 --- a/interpreter/shared/src/main/scala/sigmastate/SigSerializer.scala +++ b/interpreter/shared/src/main/scala/sigmastate/SigSerializer.scala @@ -3,9 +3,9 @@ package sigmastate import sigmastate.crypto.{BigIntegers, GF2_192_Poly} import scorex.util.encode.Base16 import sigmastate.Values.SigmaBoolean -import sigmastate.basics.DLogProtocol.{ProveDlog, SecondDLogProverMessage} -import sigmastate.basics.VerifierMessage.Challenge -import sigmastate.basics.{CryptoConstants, ProveDHTuple, SecondDHTupleProverMessage} +import sigmastate.crypto.DLogProtocol.{ProveDlog, SecondDLogProverMessage} +import sigmastate.crypto.VerifierMessage.Challenge +import sigmastate.crypto.{CryptoConstants, ProveDHTuple, SecondDHTupleProverMessage} import sigmastate.interpreter.ErgoTreeEvaluator.{fixedCostOp, perItemCostOp} import sigmastate.interpreter.{ErgoTreeEvaluator, NamedDesc, OperationCostInfo} import sigmastate.serialization.SigmaSerializer diff --git a/interpreter/shared/src/main/scala/sigmastate/UncheckedTree.scala b/interpreter/shared/src/main/scala/sigmastate/UncheckedTree.scala index 4b4b28fa0d..a8b9bf4faf 100644 --- a/interpreter/shared/src/main/scala/sigmastate/UncheckedTree.scala +++ b/interpreter/shared/src/main/scala/sigmastate/UncheckedTree.scala @@ -1,9 +1,8 @@ package sigmastate -import sigmastate.basics.DLogProtocol.{FirstDLogProverMessage, ProveDlog, SecondDLogProverMessage} -import sigmastate.basics.VerifierMessage.Challenge -import sigmastate.Values.SigmaBoolean -import sigmastate.basics.{FirstDHTupleProverMessage, ProveDHTuple, SecondDHTupleProverMessage} +import sigmastate.crypto.DLogProtocol.{FirstDLogProverMessage, ProveDlog, SecondDLogProverMessage} +import sigmastate.crypto.VerifierMessage.Challenge +import sigmastate.crypto.{FirstDHTupleProverMessage, ProveDHTuple, SecondDHTupleProverMessage} import sigmastate.crypto.GF2_192_Poly sealed trait UncheckedTree extends ProofTree diff --git a/interpreter/shared/src/main/scala/sigmastate/UnprovenTree.scala b/interpreter/shared/src/main/scala/sigmastate/UnprovenTree.scala index a01c937a1f..4e45c230f2 100644 --- a/interpreter/shared/src/main/scala/sigmastate/UnprovenTree.scala +++ b/interpreter/shared/src/main/scala/sigmastate/UnprovenTree.scala @@ -2,9 +2,9 @@ package sigmastate import java.math.BigInteger import sigmastate.Values.{ErgoTree, SigmaBoolean, SigmaPropConstant} -import sigmastate.basics.DLogProtocol.{FirstDLogProverMessage, ProveDlog} -import sigmastate.basics.VerifierMessage.Challenge -import sigmastate.basics.{FirstDHTupleProverMessage, FirstProverMessage, ProveDHTuple} +import sigmastate.crypto.DLogProtocol.{FirstDLogProverMessage, ProveDlog} +import sigmastate.crypto.VerifierMessage.Challenge +import sigmastate.crypto.{FirstDHTupleProverMessage, FirstProverMessage, ProveDHTuple} import sigmastate.interpreter.{ErgoTreeEvaluator, NamedDesc, OperationCostInfo} import sigmastate.interpreter.ErgoTreeEvaluator.fixedCostOp import sigmastate.serialization.ErgoTreeSerializer.DefaultSerializer diff --git a/interpreter/shared/src/main/scala/sigmastate/Values.scala b/interpreter/shared/src/main/scala/sigmastate/Values.scala index 2eec9a27bb..366581d5e5 100644 --- a/interpreter/shared/src/main/scala/sigmastate/Values.scala +++ b/interpreter/shared/src/main/scala/sigmastate/Values.scala @@ -8,14 +8,14 @@ import org.ergoplatform.validation.ValidationException import sigma.core.{Nullable, RType} import sigma.util.CollectionUtil._ import sigmastate.SCollection.{SByteArray, SIntArray} -import sigmastate.basics.CryptoConstants.EcPointType +import sigmastate.crypto.CryptoConstants.EcPointType import sigmastate.interpreter.{CompanionDesc, ErgoTreeEvaluator, Interpreter, NamedDesc} import sigmastate.serialization._ import sigmastate.serialization.OpCodes._ import sigmastate.TrivialProp.{FalseProp, TrueProp} import sigmastate.Values.ErgoTree.substConstants -import sigmastate.basics.DLogProtocol.ProveDlog -import sigmastate.basics.{CryptoConstants, ProveDHTuple} +import sigmastate.crypto.DLogProtocol.ProveDlog +import sigmastate.crypto.{CryptoConstants, ProveDHTuple} import sigmastate.lang.Terms._ import sigmastate.utxo._ import sigmastate.eval._ diff --git a/interpreter/shared/src/main/scala/sigmastate/basics/BcDlogGroup.scala b/interpreter/shared/src/main/scala/sigmastate/crypto/BcDlogGroup.scala similarity index 99% rename from interpreter/shared/src/main/scala/sigmastate/basics/BcDlogGroup.scala rename to interpreter/shared/src/main/scala/sigmastate/crypto/BcDlogGroup.scala index f4b9b4c8f3..030b333032 100644 --- a/interpreter/shared/src/main/scala/sigmastate/basics/BcDlogGroup.scala +++ b/interpreter/shared/src/main/scala/sigmastate/crypto/BcDlogGroup.scala @@ -1,4 +1,4 @@ -package sigmastate.basics +package sigmastate.crypto import java.math.BigInteger import sigmastate.crypto.BigIntegers diff --git a/interpreter/shared/src/main/scala/sigmastate/basics/CryptoConstants.scala b/interpreter/shared/src/main/scala/sigmastate/crypto/CryptoConstants.scala similarity index 97% rename from interpreter/shared/src/main/scala/sigmastate/basics/CryptoConstants.scala rename to interpreter/shared/src/main/scala/sigmastate/crypto/CryptoConstants.scala index b82892291c..59525bec7e 100644 --- a/interpreter/shared/src/main/scala/sigmastate/basics/CryptoConstants.scala +++ b/interpreter/shared/src/main/scala/sigmastate/crypto/CryptoConstants.scala @@ -1,7 +1,6 @@ -package sigmastate.basics +package sigmastate.crypto import java.math.BigInteger -import sigmastate.crypto.Ecp /** Constants used in crypto operations implementation. */ object CryptoConstants { diff --git a/interpreter/shared/src/main/scala/sigmastate/basics/CryptoFunctions.scala b/interpreter/shared/src/main/scala/sigmastate/crypto/CryptoFunctions.scala similarity index 95% rename from interpreter/shared/src/main/scala/sigmastate/basics/CryptoFunctions.scala rename to interpreter/shared/src/main/scala/sigmastate/crypto/CryptoFunctions.scala index 58eaa70598..ff8d395d44 100644 --- a/interpreter/shared/src/main/scala/sigmastate/basics/CryptoFunctions.scala +++ b/interpreter/shared/src/main/scala/sigmastate/crypto/CryptoFunctions.scala @@ -1,4 +1,4 @@ -package sigmastate.basics +package sigmastate.crypto import scorex.crypto.hash.Blake2b256 diff --git a/interpreter/shared/src/main/scala/sigmastate/basics/DLogProtocol.scala b/interpreter/shared/src/main/scala/sigmastate/crypto/DLogProtocol.scala similarity index 97% rename from interpreter/shared/src/main/scala/sigmastate/basics/DLogProtocol.scala rename to interpreter/shared/src/main/scala/sigmastate/crypto/DLogProtocol.scala index 96bfb0dd9d..a078da2ceb 100644 --- a/interpreter/shared/src/main/scala/sigmastate/basics/DLogProtocol.scala +++ b/interpreter/shared/src/main/scala/sigmastate/crypto/DLogProtocol.scala @@ -1,14 +1,13 @@ -package sigmastate.basics +package sigmastate.crypto import java.math.BigInteger -import sigmastate.crypto.BigIntegers import sigmastate.Values._ import Value.PropositionCode import scorex.util.encode.Base16 import sigmastate._ import sigmastate.eval._ -import sigmastate.basics.VerifierMessage.Challenge +import sigmastate.crypto.VerifierMessage.Challenge import CryptoConstants.{EcPointType, dlogGroup} import sigmastate.serialization.{OpCodes, GroupElementSerializer} import sigmastate.serialization.OpCodes.OpCode diff --git a/interpreter/shared/src/main/scala/sigmastate/basics/DiffieHellmanTupleProtocol.scala b/interpreter/shared/src/main/scala/sigmastate/crypto/DiffieHellmanTupleProtocol.scala similarity index 97% rename from interpreter/shared/src/main/scala/sigmastate/basics/DiffieHellmanTupleProtocol.scala rename to interpreter/shared/src/main/scala/sigmastate/crypto/DiffieHellmanTupleProtocol.scala index 762772c528..a30e187105 100644 --- a/interpreter/shared/src/main/scala/sigmastate/basics/DiffieHellmanTupleProtocol.scala +++ b/interpreter/shared/src/main/scala/sigmastate/crypto/DiffieHellmanTupleProtocol.scala @@ -1,11 +1,10 @@ -package sigmastate.basics +package sigmastate.crypto import java.math.BigInteger -import sigmastate.crypto.BigIntegers import sigmastate.Values.Value.PropositionCode import sigmastate._ -import sigmastate.basics.VerifierMessage.Challenge +import sigmastate.crypto.VerifierMessage.Challenge import sigmastate.eval.SigmaDsl import CryptoConstants.EcPointType import sigmastate.serialization.{OpCodes, GroupElementSerializer} @@ -44,7 +43,7 @@ object DiffieHellmanTupleProverInput { /** First message of Diffie Hellman tuple sigma protocol. * @param a commitment to secret randomness `a = g^r`, where `g` is default generator of the group * @param b commitment to secret randomness `b = h^r`, where `h` is another random generator of the group - * @see createRandomGenerator in [[sigmastate.basics.CryptoConstants.dlogGroup]] + * @see createRandomGenerator in [[sigmastate.crypto.CryptoConstants.dlogGroup]] */ case class FirstDHTupleProverMessage(a: EcPointType, b: EcPointType) extends FirstProverMessage { diff --git a/interpreter/shared/src/main/scala/sigmastate/basics/DlogGroup.scala b/interpreter/shared/src/main/scala/sigmastate/crypto/DlogGroup.scala similarity index 98% rename from interpreter/shared/src/main/scala/sigmastate/basics/DlogGroup.scala rename to interpreter/shared/src/main/scala/sigmastate/crypto/DlogGroup.scala index 07e989d119..80ab2e372d 100644 --- a/interpreter/shared/src/main/scala/sigmastate/basics/DlogGroup.scala +++ b/interpreter/shared/src/main/scala/sigmastate/crypto/DlogGroup.scala @@ -1,7 +1,6 @@ -package sigmastate.basics +package sigmastate.crypto import java.math.BigInteger -import sigmastate.crypto.{Ecp, CryptoFacade, SecureRandom} /** This is the general interface for the discrete logarithm prime-order group. * Every class in the DlogGroup family implements this interface. diff --git a/interpreter/shared/src/main/scala/sigmastate/basics/SigmaProtocolFunctions.scala b/interpreter/shared/src/main/scala/sigmastate/crypto/SigmaProtocolFunctions.scala similarity index 95% rename from interpreter/shared/src/main/scala/sigmastate/basics/SigmaProtocolFunctions.scala rename to interpreter/shared/src/main/scala/sigmastate/crypto/SigmaProtocolFunctions.scala index 6b99616753..176edb201c 100644 --- a/interpreter/shared/src/main/scala/sigmastate/basics/SigmaProtocolFunctions.scala +++ b/interpreter/shared/src/main/scala/sigmastate/crypto/SigmaProtocolFunctions.scala @@ -1,8 +1,8 @@ -package sigmastate.basics +package sigmastate.crypto import sigmastate.SigmaLeaf -import sigmastate.basics.CryptoConstants.dlogGroup -import sigmastate.basics.VerifierMessage.Challenge +import sigmastate.crypto.CryptoConstants.dlogGroup +import sigmastate.crypto.VerifierMessage.Challenge import sigma.Coll import supertagged.TaggedType diff --git a/interpreter/shared/src/main/scala/sigmastate/eval/CostingDataContext.scala b/interpreter/shared/src/main/scala/sigmastate/eval/CostingDataContext.scala index 3e02ac8bd8..2f5a09c6ef 100644 --- a/interpreter/shared/src/main/scala/sigmastate/eval/CostingDataContext.scala +++ b/interpreter/shared/src/main/scala/sigmastate/eval/CostingDataContext.scala @@ -15,9 +15,9 @@ import sigmastate.SCollection.SByteArray import sigmastate.Values.ErgoTree.EmptyConstants import sigmastate.Values.{ConstantNode, ErgoTree, EvaluatedValue, SValue, SigmaBoolean} import sigmastate._ -import sigmastate.basics.CryptoConstants.EcPointType -import sigmastate.basics.DLogProtocol.ProveDlog -import sigmastate.basics.{CryptoConstants, ProveDHTuple} +import sigmastate.crypto.CryptoConstants.EcPointType +import sigmastate.crypto.DLogProtocol.ProveDlog +import sigmastate.crypto.{CryptoConstants, ProveDHTuple} import sigmastate.crypto.{CryptoFacade, Ecp} import sigmastate.eval.Extensions._ import sigmastate.interpreter.Interpreter diff --git a/interpreter/shared/src/main/scala/sigmastate/eval/package.scala b/interpreter/shared/src/main/scala/sigmastate/eval/package.scala index 90913b1cc4..cee9117304 100644 --- a/interpreter/shared/src/main/scala/sigmastate/eval/package.scala +++ b/interpreter/shared/src/main/scala/sigmastate/eval/package.scala @@ -6,7 +6,7 @@ import org.ergoplatform.ErgoBox import sigma.core.RType import scorex.crypto.hash.Digest32 import sigmastate.Values.SigmaBoolean -import sigmastate.basics.CryptoConstants.EcPointType +import sigmastate.crypto.CryptoConstants.EcPointType import sigma.{Coll, CollBuilder} import sigma._ import supertagged.TaggedType diff --git a/interpreter/shared/src/main/scala/sigmastate/interpreter/Hint.scala b/interpreter/shared/src/main/scala/sigmastate/interpreter/Hint.scala index ab2530f653..2e894502f4 100644 --- a/interpreter/shared/src/main/scala/sigmastate/interpreter/Hint.scala +++ b/interpreter/shared/src/main/scala/sigmastate/interpreter/Hint.scala @@ -3,8 +3,8 @@ package sigmastate.interpreter import java.math.BigInteger import sigmastate.{NodePosition, SigmaLeaf, UncheckedTree} import sigmastate.Values.SigmaBoolean -import sigmastate.basics.FirstProverMessage -import sigmastate.basics.VerifierMessage.Challenge +import sigmastate.crypto.FirstProverMessage +import sigmastate.crypto.VerifierMessage.Challenge /** * A hint for a prover which helps the prover to prove a statement. For example, if the statement is "pk1 && pk2", diff --git a/interpreter/shared/src/main/scala/sigmastate/interpreter/Interpreter.scala b/interpreter/shared/src/main/scala/sigmastate/interpreter/Interpreter.scala index 6a0142a119..cb519e12ae 100644 --- a/interpreter/shared/src/main/scala/sigmastate/interpreter/Interpreter.scala +++ b/interpreter/shared/src/main/scala/sigmastate/interpreter/Interpreter.scala @@ -5,11 +5,11 @@ import sigma.kiama.rewriting.Rewriter.{everywherebu, rule, strategy} import org.ergoplatform.ErgoLikeContext import org.ergoplatform.validation.SigmaValidationSettings import org.ergoplatform.validation.ValidationRules._ -import sigmastate.basics.DLogProtocol.ProveDlog +import sigmastate.crypto.DLogProtocol.ProveDlog import sigmastate.SCollection.SByteArray import sigmastate.Values._ -import sigmastate.basics.DLogProtocol.{DLogInteractiveProver, FirstDLogProverMessage, ProveDlog} -import sigmastate.basics._ +import sigmastate.crypto.DLogProtocol.{DLogInteractiveProver, FirstDLogProverMessage, ProveDlog} +import sigmastate.crypto._ import sigmastate.interpreter.Interpreter._ import sigmastate.serialization.{SigmaSerializer, ValueSerializer} import sigmastate.utxo.DeserializeContext diff --git a/interpreter/shared/src/main/scala/sigmastate/interpreter/ProverInterpreter.scala b/interpreter/shared/src/main/scala/sigmastate/interpreter/ProverInterpreter.scala index a67ea6f236..2953e8ed0c 100644 --- a/interpreter/shared/src/main/scala/sigmastate/interpreter/ProverInterpreter.scala +++ b/interpreter/shared/src/main/scala/sigmastate/interpreter/ProverInterpreter.scala @@ -8,9 +8,9 @@ import sigmastate.TrivialProp.{FalseProp, TrueProp} import sigmastate.Values._ import sigma.VersionContext.MaxSupportedScriptVersion import sigmastate._ -import sigmastate.basics.DLogProtocol._ -import sigmastate.basics.VerifierMessage.Challenge -import sigmastate.basics._ +import sigmastate.crypto.DLogProtocol._ +import sigmastate.crypto.VerifierMessage.Challenge +import sigmastate.crypto._ import sigmastate.crypto.{GF2_192, GF2_192_Poly} import sigmastate.eval.Extensions.ArrayOps import sigmastate.exceptions.InterpreterException diff --git a/interpreter/shared/src/main/scala/sigmastate/interpreter/ProverUtils.scala b/interpreter/shared/src/main/scala/sigmastate/interpreter/ProverUtils.scala index e2b0fe8f5a..0e66cb55c5 100644 --- a/interpreter/shared/src/main/scala/sigmastate/interpreter/ProverUtils.scala +++ b/interpreter/shared/src/main/scala/sigmastate/interpreter/ProverUtils.scala @@ -2,9 +2,8 @@ package sigmastate.interpreter import sigmastate._ import sigmastate.Values.{ErgoTree, SigmaBoolean} -import sigmastate.basics.DLogProtocol.{DLogInteractiveProver, ProveDlog} -import sigmastate.basics.{DiffieHellmanTupleInteractiveProver, ProveDHTuple} -import sigmastate.basics.VerifierMessage.Challenge +import sigmastate.crypto.DLogProtocol.{DLogInteractiveProver, ProveDlog} +import sigmastate.crypto.{DiffieHellmanTupleInteractiveProver, ProveDHTuple} trait ProverUtils extends Interpreter { diff --git a/interpreter/shared/src/main/scala/sigmastate/serialization/GroupElementSerializer.scala b/interpreter/shared/src/main/scala/sigmastate/serialization/GroupElementSerializer.scala index 0a68a5d95a..e54c41e426 100644 --- a/interpreter/shared/src/main/scala/sigmastate/serialization/GroupElementSerializer.scala +++ b/interpreter/shared/src/main/scala/sigmastate/serialization/GroupElementSerializer.scala @@ -1,6 +1,6 @@ package sigmastate.serialization -import sigmastate.basics.CryptoConstants +import sigmastate.crypto.CryptoConstants import sigmastate.crypto.CryptoFacade import CryptoConstants.EcPointType import sigma.util.safeNewArray diff --git a/interpreter/shared/src/main/scala/sigmastate/serialization/ProveDlogSerializer.scala b/interpreter/shared/src/main/scala/sigmastate/serialization/ProveDlogSerializer.scala index edf7b175f4..89400938fe 100644 --- a/interpreter/shared/src/main/scala/sigmastate/serialization/ProveDlogSerializer.scala +++ b/interpreter/shared/src/main/scala/sigmastate/serialization/ProveDlogSerializer.scala @@ -1,9 +1,9 @@ package sigmastate.serialization -import sigmastate.basics.DLogProtocol.ProveDlog +import sigmastate.crypto.DLogProtocol.ProveDlog import sigmastate.{SGroupElement, CreateProveDlog} import sigmastate.Values.{Value, SValue, SigmaPropValue} -import sigmastate.basics.CryptoConstants.EcPointType +import sigmastate.crypto.CryptoConstants.EcPointType import sigmastate.lang.Terms._ import sigmastate.utils.SigmaByteWriter.DataInfo import sigmastate.utils.{SigmaByteReader, SigmaByteWriter} diff --git a/interpreter/shared/src/main/scala/sigmastate/serialization/transformers/ProveDHTupleSerializer.scala b/interpreter/shared/src/main/scala/sigmastate/serialization/transformers/ProveDHTupleSerializer.scala index b25d13d8de..39406a35c0 100644 --- a/interpreter/shared/src/main/scala/sigmastate/serialization/transformers/ProveDHTupleSerializer.scala +++ b/interpreter/shared/src/main/scala/sigmastate/serialization/transformers/ProveDHTupleSerializer.scala @@ -2,8 +2,8 @@ package sigmastate.serialization.transformers import sigmastate.{SGroupElement, CreateProveDHTuple} import sigmastate.Values.{Value, SigmaPropValue} -import sigmastate.basics.ProveDHTuple -import sigmastate.basics.CryptoConstants.EcPointType +import sigmastate.crypto.ProveDHTuple +import sigmastate.crypto.CryptoConstants.EcPointType import sigmastate.lang.Terms._ import sigmastate.utils.{SigmaByteReader, SigmaByteWriter} import sigmastate.serialization._ diff --git a/interpreter/shared/src/main/scala/sigmastate/trees.scala b/interpreter/shared/src/main/scala/sigmastate/trees.scala index 4bbb4e3f65..690be2ebe3 100644 --- a/interpreter/shared/src/main/scala/sigmastate/trees.scala +++ b/interpreter/shared/src/main/scala/sigmastate/trees.scala @@ -37,7 +37,7 @@ trait SigmaConjecture extends SigmaBoolean { /** * Basic trait for leafs of crypto-trees, such as - * [[sigmastate.basics.DLogProtocol.ProveDlog]] and [[sigmastate.basics.ProveDHTuple]] + * [[sigmastate.crypto.DLogProtocol.ProveDlog]] and [[sigmastate.crypto.ProveDHTuple]] * instances. * It plays the same role as [[SigmaConjecture]]. It used in prover to distinguish leafs from * other nodes and have logic common to leaves regardless of the concrete leaf type. diff --git a/interpreter/shared/src/main/scala/sigmastate/types.scala b/interpreter/shared/src/main/scala/sigmastate/types.scala index 6ad160d66b..716fb738dc 100644 --- a/interpreter/shared/src/main/scala/sigmastate/types.scala +++ b/interpreter/shared/src/main/scala/sigmastate/types.scala @@ -14,7 +14,7 @@ import sigmastate.Values._ import sigmastate.lang.Terms._ import sigmastate.lang.{SigmaBuilder, Terms} import sigmastate.SCollection._ -import sigmastate.basics.CryptoConstants.EcPointType +import sigmastate.crypto.CryptoConstants.EcPointType import sigmastate.serialization.OpCodes import sigma.Coll import sigma._ diff --git a/interpreter/shared/src/main/scala/sigmastate/utils/Helpers.scala b/interpreter/shared/src/main/scala/sigmastate/utils/Helpers.scala index 2e4c88d6dd..b689c59f66 100644 --- a/interpreter/shared/src/main/scala/sigmastate/utils/Helpers.scala +++ b/interpreter/shared/src/main/scala/sigmastate/utils/Helpers.scala @@ -7,7 +7,7 @@ import sigma.core.{OverloadHack, RType} import scorex.utils.Ints import sigma.Environment import sigmastate.eval.{CAnyValue, Colls, SigmaDsl} -import sigmastate.basics.CryptoConstants.EcPointType +import sigmastate.crypto.CryptoConstants.EcPointType import sigma.Coll import sigma.GroupElement diff --git a/interpreter/shared/src/test/scala/sigmastate/SigmaProtocolSpecification.scala b/interpreter/shared/src/test/scala/sigmastate/SigmaProtocolSpecification.scala index 107890221b..5e059e3355 100644 --- a/interpreter/shared/src/test/scala/sigmastate/SigmaProtocolSpecification.scala +++ b/interpreter/shared/src/test/scala/sigmastate/SigmaProtocolSpecification.scala @@ -1,6 +1,6 @@ package sigmastate -import sigmastate.basics.VerifierMessage.Challenge +import sigmastate.crypto.VerifierMessage.Challenge import sigmastate.crypto.{GF2_192, GF2_192_Poly} import sigma.SigmaTestingData diff --git a/interpreter/shared/src/test/scala/sigmastate/crypto/GroupLawsSpecification.scala b/interpreter/shared/src/test/scala/sigmastate/crypto/GroupLawsSpecification.scala index 45863a18a6..d177a26e4c 100644 --- a/interpreter/shared/src/test/scala/sigmastate/crypto/GroupLawsSpecification.scala +++ b/interpreter/shared/src/test/scala/sigmastate/crypto/GroupLawsSpecification.scala @@ -2,7 +2,7 @@ package sigmastate.crypto import java.math.BigInteger import org.scalacheck.Gen -import sigmastate.basics.CryptoConstants +import sigmastate.crypto.CryptoConstants import CryptoConstants.EcPointType import org.scalatest.propspec.AnyPropSpec import org.scalatestplus.scalacheck.ScalaCheckPropertyChecks diff --git a/interpreter/shared/src/test/scala/sigmastate/crypto/SigningSpecification.scala b/interpreter/shared/src/test/scala/sigmastate/crypto/SigningSpecification.scala index 4ac2f7c8da..724a0171dc 100644 --- a/interpreter/shared/src/test/scala/sigmastate/crypto/SigningSpecification.scala +++ b/interpreter/shared/src/test/scala/sigmastate/crypto/SigningSpecification.scala @@ -4,11 +4,11 @@ import org.scalacheck.Gen import scorex.util.encode.Base16 import sigmastate.{AtLeast, COR, CAND} import sigmastate.Values.SigmaBoolean -import sigmastate.basics.DLogProtocol.DLogProverInput +import sigmastate.crypto.DLogProtocol.DLogProverInput import sigmastate.helpers.{ErgoLikeTestInterpreter, ErgoLikeTestProvingInterpreter, TestingCommons} import sigmastate.interpreter.{HintsBag, ContextExtension, ProverResult} import sigmastate.serialization.transformers.ProveDHTupleSerializer -import sigmastate.basics.ProveDHTuple +import sigmastate.crypto.ProveDHTuple class SigningSpecification extends TestingCommons { diff --git a/interpreter/shared/src/test/scala/sigmastate/eval/BasicOpsTests.scala b/interpreter/shared/src/test/scala/sigmastate/eval/BasicOpsTests.scala index 40f4e7f3d8..07b8fdcddb 100644 --- a/interpreter/shared/src/test/scala/sigmastate/eval/BasicOpsTests.scala +++ b/interpreter/shared/src/test/scala/sigmastate/eval/BasicOpsTests.scala @@ -5,7 +5,7 @@ import org.scalatest.matchers.should.Matchers import java.math.BigInteger import sigmastate.TrivialProp -import sigmastate.basics.SecP256K1Group +import sigmastate.crypto.SecP256K1Group import sigma.{ContractsTestkit, SigmaDslBuilder, SigmaProp} import scala.language.implicitConversions diff --git a/interpreter/shared/src/test/scala/sigmastate/helpers/ContextEnrichingTestProvingInterpreter.scala b/interpreter/shared/src/test/scala/sigmastate/helpers/ContextEnrichingTestProvingInterpreter.scala index e9f77b65c6..641142f43c 100644 --- a/interpreter/shared/src/test/scala/sigmastate/helpers/ContextEnrichingTestProvingInterpreter.scala +++ b/interpreter/shared/src/test/scala/sigmastate/helpers/ContextEnrichingTestProvingInterpreter.scala @@ -3,8 +3,8 @@ package sigmastate.helpers import scorex.utils.Random import sigmastate.SType import sigmastate.Values._ -import sigmastate.basics.DLogProtocol.DLogProverInput -import sigmastate.basics.DiffieHellmanTupleProverInput +import sigmastate.crypto.DLogProtocol.DLogProverInput +import sigmastate.crypto.DiffieHellmanTupleProverInput class ContextEnrichingTestProvingInterpreter extends ErgoLikeTestProvingInterpreter with ContextEnrichingProverInterpreter { diff --git a/interpreter/shared/src/test/scala/sigmastate/helpers/ErgoLikeContextTesting.scala b/interpreter/shared/src/test/scala/sigmastate/helpers/ErgoLikeContextTesting.scala index 02086879e5..a98915c55d 100644 --- a/interpreter/shared/src/test/scala/sigmastate/helpers/ErgoLikeContextTesting.scala +++ b/interpreter/shared/src/test/scala/sigmastate/helpers/ErgoLikeContextTesting.scala @@ -4,7 +4,7 @@ import org.ergoplatform.ErgoLikeContext.Height import org.ergoplatform._ import org.ergoplatform.validation.{SigmaValidationSettings, ValidationRules} import sigmastate.AvlTreeData -import sigmastate.basics.CryptoConstants +import sigmastate.crypto.CryptoConstants import sigmastate.eval._ import sigmastate.interpreter.ContextExtension import sigmastate.interpreter.ErgoTreeEvaluator.DefaultEvalSettings diff --git a/interpreter/shared/src/test/scala/sigmastate/helpers/ErgoLikeTestProvingInterpreter.scala b/interpreter/shared/src/test/scala/sigmastate/helpers/ErgoLikeTestProvingInterpreter.scala index 2a3609a3fc..5500d7aa66 100644 --- a/interpreter/shared/src/test/scala/sigmastate/helpers/ErgoLikeTestProvingInterpreter.scala +++ b/interpreter/shared/src/test/scala/sigmastate/helpers/ErgoLikeTestProvingInterpreter.scala @@ -1,8 +1,8 @@ package sigmastate.helpers import sigmastate.UnprovenConjecture -import sigmastate.basics.DLogProtocol.DLogProverInput -import sigmastate.basics.{DiffieHellmanTupleProverInput, SigmaProtocolPrivateInput} +import sigmastate.crypto.DLogProtocol.DLogProverInput +import sigmastate.crypto.{DiffieHellmanTupleProverInput, SigmaProtocolPrivateInput} import sigmastate.interpreter.ProverInterpreter class ErgoLikeTestProvingInterpreter diff --git a/interpreter/shared/src/test/scala/sigmastate/helpers/TestingCommons.scala b/interpreter/shared/src/test/scala/sigmastate/helpers/TestingCommons.scala index 9c61e52aed..19a8efe608 100644 --- a/interpreter/shared/src/test/scala/sigmastate/helpers/TestingCommons.scala +++ b/interpreter/shared/src/test/scala/sigmastate/helpers/TestingCommons.scala @@ -9,7 +9,7 @@ import sigmastate.eval.SigmaDsl import scorex.crypto.hash.Blake2b256 import org.ergoplatform.{ErgoBox, ErgoLikeContext} import org.scalatest.matchers.should.Matchers -import sigmastate.basics.CryptoConstants.EcPointType +import sigmastate.crypto.CryptoConstants.EcPointType trait TestingCommons extends AnyPropSpec with ScalaCheckPropertyChecks diff --git a/interpreter/shared/src/test/scala/sigmastate/serialization/ConstantSerializerSpecification.scala b/interpreter/shared/src/test/scala/sigmastate/serialization/ConstantSerializerSpecification.scala index 0893267378..573c6ea261 100644 --- a/interpreter/shared/src/test/scala/sigmastate/serialization/ConstantSerializerSpecification.scala +++ b/interpreter/shared/src/test/scala/sigmastate/serialization/ConstantSerializerSpecification.scala @@ -6,7 +6,7 @@ import org.scalacheck.Arbitrary._ import sigma.core.RType import sigmastate.SCollection.SByteArray import sigmastate.Values.{BigIntConstant, ByteArrayConstant, Constant, FalseLeaf, GroupGenerator, LongConstant, SValue, TrueLeaf} -import sigmastate.basics.CryptoConstants.EcPointType +import sigmastate.crypto.CryptoConstants.EcPointType import sigmastate._ import sigmastate.eval._ import sigmastate.eval.Extensions._ diff --git a/interpreter/shared/src/test/scala/sigmastate/serialization/DataSerializerSpecification.scala b/interpreter/shared/src/test/scala/sigmastate/serialization/DataSerializerSpecification.scala index 0aeaed9e09..d10b9396ff 100644 --- a/interpreter/shared/src/test/scala/sigmastate/serialization/DataSerializerSpecification.scala +++ b/interpreter/shared/src/test/scala/sigmastate/serialization/DataSerializerSpecification.scala @@ -10,7 +10,7 @@ import sigmastate._ import sigmastate.eval.Evaluation import sigmastate.eval._ import sigmastate.eval.Extensions._ -import sigmastate.basics.CryptoConstants.EcPointType +import sigmastate.crypto.CryptoConstants.EcPointType import sigma.AvlTree import SType.AnyOps import sigmastate.exceptions.SerializerException diff --git a/interpreter/shared/src/test/scala/sigmastate/serialization/GroupElementSerializerSpecification.scala b/interpreter/shared/src/test/scala/sigmastate/serialization/GroupElementSerializerSpecification.scala index a0a5c8c2c1..04c4a8e128 100644 --- a/interpreter/shared/src/test/scala/sigmastate/serialization/GroupElementSerializerSpecification.scala +++ b/interpreter/shared/src/test/scala/sigmastate/serialization/GroupElementSerializerSpecification.scala @@ -1,6 +1,6 @@ package sigmastate.serialization -import sigmastate.basics.CryptoConstants +import sigmastate.crypto.CryptoConstants import sigmastate.crypto.CryptoFacade import sigmastate.eval._ diff --git a/interpreter/shared/src/test/scala/sigmastate/serialization/PDHTSerializerSpecification.scala b/interpreter/shared/src/test/scala/sigmastate/serialization/PDHTSerializerSpecification.scala index 4df5ab5b61..dbca6fb190 100644 --- a/interpreter/shared/src/test/scala/sigmastate/serialization/PDHTSerializerSpecification.scala +++ b/interpreter/shared/src/test/scala/sigmastate/serialization/PDHTSerializerSpecification.scala @@ -1,6 +1,6 @@ package sigmastate.serialization -import sigmastate.basics.ProveDHTuple +import sigmastate.crypto.ProveDHTuple class PDHTSerializerSpecification extends SerializationSpecification { diff --git a/interpreter/shared/src/test/scala/sigmastate/serialization/ProveDlogSerializerSpec.scala b/interpreter/shared/src/test/scala/sigmastate/serialization/ProveDlogSerializerSpec.scala index 1705fc325e..df791f248a 100644 --- a/interpreter/shared/src/test/scala/sigmastate/serialization/ProveDlogSerializerSpec.scala +++ b/interpreter/shared/src/test/scala/sigmastate/serialization/ProveDlogSerializerSpec.scala @@ -1,6 +1,6 @@ package sigmastate.serialization -import sigmastate.basics.DLogProtocol.ProveDlog +import sigmastate.crypto.DLogProtocol.ProveDlog class ProveDlogSerializerSpec extends SerializationSpecification { diff --git a/interpreter/shared/src/test/scala/sigmastate/serialization/SigSerializerSpecification.scala b/interpreter/shared/src/test/scala/sigmastate/serialization/SigSerializerSpecification.scala index a66c56f2f2..52aaa89070 100644 --- a/interpreter/shared/src/test/scala/sigmastate/serialization/SigSerializerSpecification.scala +++ b/interpreter/shared/src/test/scala/sigmastate/serialization/SigSerializerSpecification.scala @@ -6,9 +6,9 @@ import org.scalacheck.{Arbitrary, Gen} import org.scalatest.Assertion import sigmastate.Values.SigmaBoolean import sigmastate._ -import sigmastate.basics.DLogProtocol.{ProveDlog, SecondDLogProverMessage} -import sigmastate.basics.VerifierMessage.Challenge -import sigmastate.basics.{ProveDHTuple, SecondDHTupleProverMessage} +import sigmastate.crypto.DLogProtocol.{ProveDlog, SecondDLogProverMessage} +import sigmastate.crypto.VerifierMessage.Challenge +import sigmastate.crypto.{ProveDHTuple, SecondDHTupleProverMessage} import sigmastate.crypto.GF2_192_Poly import sigmastate.eval.Extensions.ArrayOps import sigmastate.helpers.{ContextEnrichingTestProvingInterpreter, ErgoLikeContextTesting, ErgoLikeTransactionTesting, TestingCommons} diff --git a/interpreter/shared/src/test/scala/sigmastate/serialization/generators/ObjectGenerators.scala b/interpreter/shared/src/test/scala/sigmastate/serialization/generators/ObjectGenerators.scala index 4dc3625d91..f8f8ccf614 100644 --- a/interpreter/shared/src/test/scala/sigmastate/serialization/generators/ObjectGenerators.scala +++ b/interpreter/shared/src/test/scala/sigmastate/serialization/generators/ObjectGenerators.scala @@ -13,11 +13,11 @@ import scorex.crypto.authds.{ADDigest, ADKey} import scorex.util.encode.{Base58, Base64} import scorex.util.{ModifierId, bytesToId} import sigmastate.Values._ -import sigmastate.basics.DLogProtocol.ProveDlog -import sigmastate.basics.{CryptoConstants, ProveDHTuple} +import sigmastate.crypto.DLogProtocol.ProveDlog +import sigmastate.crypto.{CryptoConstants, ProveDHTuple} import sigmastate.eval.Extensions._ import sigmastate.eval.{CostingBox, SigmaDsl, _} -import sigmastate.basics.CryptoConstants.{EcPointType, dlogGroup} +import sigmastate.crypto.CryptoConstants.{EcPointType, dlogGroup} import sigmastate.interpreter.{ContextExtension, ProverResult} import sigmastate.lang.TransformingSigmaBuilder._ import sigmastate._ diff --git a/interpreter/shared/src/test/scala/sigmastate/utxo/ProverSpecification.scala b/interpreter/shared/src/test/scala/sigmastate/utxo/ProverSpecification.scala index 360754db6f..1334ee520f 100644 --- a/interpreter/shared/src/test/scala/sigmastate/utxo/ProverSpecification.scala +++ b/interpreter/shared/src/test/scala/sigmastate/utxo/ProverSpecification.scala @@ -4,8 +4,8 @@ import org.ergoplatform.ErgoLikeInterpreter import scorex.crypto.hash.Blake2b256 import sigmastate.Values.SigmaBoolean import sigmastate._ -import sigmastate.basics.DLogProtocol.FirstDLogProverMessage -import sigmastate.basics.{FirstDHTupleProverMessage, SecP256K1Group} +import sigmastate.crypto.DLogProtocol.FirstDLogProverMessage +import sigmastate.crypto.{FirstDHTupleProverMessage, SecP256K1Group} import sigmastate.exceptions.InterpreterException import sigmastate.helpers.{ErgoLikeTestProvingInterpreter, TestingCommons} import sigmastate.interpreter.{HintsBag, ProverInterpreter} diff --git a/interpreter/shared/src/test/scala/special/sigma/SigmaTestingData.scala b/interpreter/shared/src/test/scala/special/sigma/SigmaTestingData.scala index a65e5d6927..c4c207d44c 100644 --- a/interpreter/shared/src/test/scala/special/sigma/SigmaTestingData.scala +++ b/interpreter/shared/src/test/scala/special/sigma/SigmaTestingData.scala @@ -11,9 +11,9 @@ import scorex.crypto.authds.{ADKey, ADValue} import scorex.crypto.hash.{Blake2b256, Digest32} import scorex.util.ModifierId import sigmastate.Values.{ByteArrayConstant, ConcreteCollection, ConstantPlaceholder, ErgoTree, FalseLeaf, IntConstant, LongConstant, SigmaPropConstant, TrueLeaf} -import sigmastate.basics.CryptoConstants.EcPointType -import sigmastate.basics.DLogProtocol.ProveDlog -import sigmastate.basics.ProveDHTuple +import sigmastate.crypto.CryptoConstants.EcPointType +import sigmastate.crypto.DLogProtocol.ProveDlog +import sigmastate.crypto.ProveDHTuple import sigmastate.eval.{Colls, _} import sigmastate.eval.Extensions._ import sigmastate.eval.{CAvlTree, CBigInt, CHeader, CPreHeader, CSigmaProp, CostingBox, CostingSigmaDslBuilder, SigmaDsl} diff --git a/interpreter/src/main/scala/sigmastate/lang/exceptions/Exceptions.scala b/interpreter/src/main/scala/sigmastate/lang/exceptions/Exceptions.scala deleted file mode 100644 index 285baf6c26..0000000000 --- a/interpreter/src/main/scala/sigmastate/lang/exceptions/Exceptions.scala +++ /dev/null @@ -1,55 +0,0 @@ -package sigmastate.lang.exceptions - -import sigmastate.JitCost -import sigmastate.lang.SourceContext - -/** Base class of all exceptions thrown from various Sigma components. */ -class SigmaException(val message: String, val source: Option[SourceContext] = None, val cause: Option[Throwable] = None) - extends Exception(message, cause.orNull) { - - override def getMessage: String = source.map { srcCtx => - val lineNumberStrPrefix = s"line ${srcCtx.line}: " - "\n" + lineNumberStrPrefix + - s"${srcCtx.sourceLine}\n${" " * (lineNumberStrPrefix.length + srcCtx.column - 1)}^\n" + message - }.getOrElse(message) -} - -/** Exception thrown by the [[sigmastate.lang.SigmaBinder]]. */ -class BinderException(message: String, source: Option[SourceContext] = None) - extends SigmaException(message, source) - -/** Exception thrown by the [[sigmastate.lang.SigmaTyper]]. */ -class TyperException(message: String, source: Option[SourceContext] = None) - extends SigmaException(message, source) - -/** Exception thrown by the [[sigmastate.lang.SigmaSpecializer]]. */ -class SpecializerException(message: String, source: Option[SourceContext] = None) - extends SigmaException(message, source) - -/** Exception thrown by the [[sigmastate.serialization.SigmaSerializer]]. */ -case class SerializerException( - override val message: String, - override val source: Option[SourceContext] = None, - override val cause: Option[Throwable] = None) - extends SigmaException(message, source, cause) - -/** Exception thrown by the [[sigmastate.lang.SigmaBuilder]]. */ -class BuilderException(message: String, source: Option[SourceContext] = None) - extends SigmaException(message, source) - -/** Exception thrown by interpreter during cost estimation. */ -class CosterException(message: String, source: Option[SourceContext], cause: Option[Throwable] = None) - extends SigmaException(message, source, cause) - -/** Exception thrown by [[sigmastate.interpreter.Interpreter]]. */ -class InterpreterException(message: String, source: Option[SourceContext] = None, cause: Option[Throwable] = None) - extends SigmaException(message, source, cause) - -/** Exception thrown by [[sigmastate.interpreter.Interpreter]] when cost limit is exceeded. */ -class CostLimitException(val estimatedCost: Long, message: String, cause: Option[Throwable] = None) - extends SigmaException(message, None, cause) - -object CostLimitException { - /** Formats the error message with the given parameters. */ - def msgCostLimitError(cost: JitCost, limit: JitCost) = s"Estimated execution cost $cost exceeds the limit $limit" -} diff --git a/parsers/shared/src/test/scala/sigmastate/lang/LangTests.scala b/parsers/shared/src/test/scala/sigmastate/lang/LangTests.scala index 2b2fa70ce8..a1da3d0766 100644 --- a/parsers/shared/src/test/scala/sigmastate/lang/LangTests.scala +++ b/parsers/shared/src/test/scala/sigmastate/lang/LangTests.scala @@ -6,9 +6,9 @@ import sigmastate.Values.{ConcreteCollection, LongConstant, SValue, SigmaBoolean import sigmastate._ import java.math.BigInteger -import sigmastate.basics.DLogProtocol.ProveDlog +import sigmastate.crypto.DLogProtocol.ProveDlog import sigmastate.SCollection.SByteArray -import sigmastate.basics.{ProveDHTuple, CryptoConstants} +import sigmastate.crypto.{ProveDHTuple, CryptoConstants} import sigmastate.interpreter.Interpreter.ScriptEnv import sigma._ import sigmastate.eval._ diff --git a/sc/shared/src/main/scala/sigmastate/eval/GraphBuilding.scala b/sc/shared/src/main/scala/sigmastate/eval/GraphBuilding.scala index fc7efb75dd..e560655812 100644 --- a/sc/shared/src/main/scala/sigmastate/eval/GraphBuilding.scala +++ b/sc/shared/src/main/scala/sigmastate/eval/GraphBuilding.scala @@ -14,7 +14,7 @@ import sigmastate.lang.Terms.{Ident, Select, Val, ValueOps} import sigmastate.serialization.OpCodes import sigmastate.utxo._ import sigmastate._ -import sigmastate.basics.CryptoConstants.EcPointType +import sigmastate.crypto.CryptoConstants.EcPointType import sigmastate.exceptions.{GraphBuildingException, SigmaException} import scala.collection.mutable.ArrayBuffer diff --git a/sc/shared/src/main/scala/sigmastate/eval/TreeBuilding.scala b/sc/shared/src/main/scala/sigmastate/eval/TreeBuilding.scala index d0245f5799..13fc8c7bd1 100644 --- a/sc/shared/src/main/scala/sigmastate/eval/TreeBuilding.scala +++ b/sc/shared/src/main/scala/sigmastate/eval/TreeBuilding.scala @@ -10,8 +10,8 @@ import sigmastate.serialization.ConstantStore import scala.collection.mutable.ArrayBuffer import SType._ -import sigmastate.basics.DLogProtocol.ProveDlog -import sigmastate.basics.ProveDHTuple +import sigmastate.crypto.DLogProtocol.ProveDlog +import sigmastate.crypto.ProveDHTuple import sigmastate.lang.Terms /** Implementation of IR-graph to ErgoTree expression translation. diff --git a/sc/shared/src/test/scala/org/ergoplatform/ErgoAddressSpecification.scala b/sc/shared/src/test/scala/org/ergoplatform/ErgoAddressSpecification.scala index e6610e1c7b..b4153ff4f2 100644 --- a/sc/shared/src/test/scala/org/ergoplatform/ErgoAddressSpecification.scala +++ b/sc/shared/src/test/scala/org/ergoplatform/ErgoAddressSpecification.scala @@ -6,13 +6,13 @@ import org.scalatest.{Assertion, TryValues} import scorex.crypto.hash.Blake2b256 import scorex.util.encode.Base58 import sigmastate.Values.{ByteArrayConstant, Constant, ErgoTree, IntConstant, UnparsedErgoTree} -import sigmastate.basics.DLogProtocol -import sigmastate.basics.DLogProtocol.{DLogProverInput, ProveDlog} +import sigmastate.crypto.DLogProtocol +import sigmastate.crypto.DLogProtocol.{DLogProverInput, ProveDlog} import sigmastate.eval.InvalidType import sigmastate.helpers.TestingHelpers._ import sigmastate.helpers._ import sigmastate.interpreter.ContextExtension.VarBinding -import sigmastate.basics.CryptoConstants.dlogGroup +import sigmastate.crypto.CryptoConstants.dlogGroup import sigmastate.exceptions.CostLimitException import sigmastate.interpreter.Interpreter.{ScriptEnv, ScriptNameProp} import sigmastate.interpreter.{ContextExtension, CostedProverResult} diff --git a/sc/shared/src/test/scala/org/ergoplatform/ErgoTreePredefSpec.scala b/sc/shared/src/test/scala/org/ergoplatform/ErgoTreePredefSpec.scala index 6ee6e95cbe..eb22fdc92e 100644 --- a/sc/shared/src/test/scala/org/ergoplatform/ErgoTreePredefSpec.scala +++ b/sc/shared/src/test/scala/org/ergoplatform/ErgoTreePredefSpec.scala @@ -10,7 +10,7 @@ import scorex.util.Random import sigma.util.BenchmarkUtil.measure import sigmastate.Values.{ByteArrayConstant, CollectionConstant, ErgoTree, IntConstant, SigmaPropConstant} import sigmastate._ -import sigmastate.basics.DLogProtocol.{DLogProverInput, ProveDlog} +import sigmastate.crypto.DLogProtocol.{DLogProverInput, ProveDlog} import sigmastate.helpers.{CompilerTestingCommons, ContextEnrichingTestProvingInterpreter, ErgoLikeContextTesting, ErgoLikeTestInterpreter} import sigmastate.helpers.TestingHelpers._ import sigmastate.interpreter.Interpreter.{ScriptNameProp, emptyEnv} diff --git a/sc/shared/src/test/scala/sigmastate/TestingInterpreterSpecification.scala b/sc/shared/src/test/scala/sigmastate/TestingInterpreterSpecification.scala index 0bfe986284..2398a48535 100644 --- a/sc/shared/src/test/scala/sigmastate/TestingInterpreterSpecification.scala +++ b/sc/shared/src/test/scala/sigmastate/TestingInterpreterSpecification.scala @@ -1,6 +1,6 @@ package sigmastate -import sigmastate.basics.DLogProtocol.{DLogProverInput, ProveDlog} +import sigmastate.crypto.DLogProtocol.{DLogProverInput, ProveDlog} import scorex.crypto.hash.Blake2b256 import sigmastate.Values._ import sigmastate.interpreter._ @@ -10,7 +10,7 @@ import org.ergoplatform._ import org.scalatest.BeforeAndAfterAll import scorex.util.encode.Base58 import sigma.util.Extensions.IntOps -import sigmastate.basics.CryptoConstants +import sigmastate.crypto.CryptoConstants import sigmastate.helpers.{CompilerTestingCommons, ErgoLikeContextTesting, ErgoLikeTestInterpreter, ErgoLikeTestProvingInterpreter} import sigmastate.helpers.TestingHelpers._ import sigmastate.serialization.ValueSerializer diff --git a/sc/shared/src/test/scala/sigmastate/eval/EvaluationTest.scala b/sc/shared/src/test/scala/sigmastate/eval/EvaluationTest.scala index 7ff3e039c5..9aefb272b6 100644 --- a/sc/shared/src/test/scala/sigmastate/eval/EvaluationTest.scala +++ b/sc/shared/src/test/scala/sigmastate/eval/EvaluationTest.scala @@ -9,7 +9,7 @@ import scalan.BaseCtxTests import sigmastate.lang.LangTests import sigma.util.BenchmarkUtil._ import sigmastate._ -import sigmastate.basics.DLogProtocol.{DLogProverInput, ProveDlog} +import sigmastate.crypto.DLogProtocol.{DLogProverInput, ProveDlog} import sigmastate.serialization.ErgoTreeSerializer.DefaultSerializer class EvaluationTest extends BaseCtxTests diff --git a/sc/shared/src/test/scala/sigmastate/helpers/SigmaPPrint.scala b/sc/shared/src/test/scala/sigmastate/helpers/SigmaPPrint.scala index 36c9c8a456..4ee22342d1 100644 --- a/sc/shared/src/test/scala/sigmastate/helpers/SigmaPPrint.scala +++ b/sc/shared/src/test/scala/sigmastate/helpers/SigmaPPrint.scala @@ -11,7 +11,7 @@ import sigmastate.SCollection._ import sigmastate.Values.{ConstantNode, ErgoTree, FuncValue, ValueCompanion} import sigmastate._ import sigmastate.crypto.GF2_192_Poly -import sigmastate.basics.CryptoConstants.EcPointType +import sigmastate.crypto.CryptoConstants.EcPointType import sigmastate.lang.Terms import sigmastate.lang.Terms.MethodCall import sigmastate.serialization.GroupElementSerializer diff --git a/sc/shared/src/test/scala/sigmastate/lang/SigmaTyperTest.scala b/sc/shared/src/test/scala/sigmastate/lang/SigmaTyperTest.scala index 85476c3c6d..35c21b5c82 100644 --- a/sc/shared/src/test/scala/sigmastate/lang/SigmaTyperTest.scala +++ b/sc/shared/src/test/scala/sigmastate/lang/SigmaTyperTest.scala @@ -8,8 +8,8 @@ import org.scalatestplus.scalacheck.ScalaCheckPropertyChecks import sigmastate.SCollection._ import sigmastate.Values._ import sigmastate._ -import sigmastate.basics.CryptoConstants -import sigmastate.basics.DLogProtocol.{DLogProverInput, ProveDlog} +import sigmastate.crypto.CryptoConstants +import sigmastate.crypto.DLogProtocol.{DLogProverInput, ProveDlog} import sigmastate.eval.Colls import sigmastate.exceptions.TyperException import sigmastate.interpreter.Interpreter.ScriptEnv diff --git a/sc/shared/src/test/scala/sigmastate/serialization/DeserializationResilience.scala b/sc/shared/src/test/scala/sigmastate/serialization/DeserializationResilience.scala index d7ae2af6b4..817b42ffdf 100644 --- a/sc/shared/src/test/scala/sigmastate/serialization/DeserializationResilience.scala +++ b/sc/shared/src/test/scala/sigmastate/serialization/DeserializationResilience.scala @@ -12,7 +12,7 @@ import scorex.util.serialization.{Reader, VLQByteBufferReader} import sigma.Environment import sigmastate.Values.{BlockValue, GetVarInt, IntConstant, SValue, SigmaBoolean, SigmaPropValue, Tuple, ValDef, ValUse} import sigmastate._ -import sigmastate.basics.CryptoConstants +import sigmastate.crypto.CryptoConstants import sigmastate.eval.Extensions._ import sigmastate.eval._ import sigmastate.exceptions.{DeserializeCallDepthExceeded, InvalidTypePrefix, ReaderPositionLimitExceeded, SerializerException} diff --git a/sc/shared/src/test/scala/sigmastate/utxo/BasicOpsSpecification.scala b/sc/shared/src/test/scala/sigmastate/utxo/BasicOpsSpecification.scala index ffb1fc3a18..2d8d62380e 100644 --- a/sc/shared/src/test/scala/sigmastate/utxo/BasicOpsSpecification.scala +++ b/sc/shared/src/test/scala/sigmastate/utxo/BasicOpsSpecification.scala @@ -13,7 +13,7 @@ import sigmastate.helpers.TestingHelpers._ import sigmastate.interpreter.Interpreter._ import sigmastate.lang.Terms._ import SType.AnyOps -import sigmastate.basics.CryptoConstants +import sigmastate.crypto.CryptoConstants import sigmastate.eval.{CAnyValue, InvalidType} import sigmastate.interpreter.ContextExtension.VarBinding import sigmastate.interpreter.ErgoTreeEvaluator.DefaultEvalSettings diff --git a/sc/shared/src/test/scala/sigmastate/utxo/ErgoLikeInterpreterSpecification.scala b/sc/shared/src/test/scala/sigmastate/utxo/ErgoLikeInterpreterSpecification.scala index 7f2cc3ac33..58bbb522c6 100644 --- a/sc/shared/src/test/scala/sigmastate/utxo/ErgoLikeInterpreterSpecification.scala +++ b/sc/shared/src/test/scala/sigmastate/utxo/ErgoLikeInterpreterSpecification.scala @@ -12,8 +12,8 @@ import sigmastate._ import sigmastate.eval._ import sigmastate.eval.Extensions._ import sigmastate.interpreter.Interpreter._ -import sigmastate.basics.DLogProtocol.ProveDlog -import sigmastate.basics.ProveDHTuple +import sigmastate.crypto.DLogProtocol.ProveDlog +import sigmastate.crypto.ProveDHTuple import sigmastate.helpers._ import sigmastate.helpers.TestingHelpers._ import sigmastate.interpreter.ContextExtension.VarBinding @@ -742,7 +742,7 @@ class ErgoLikeInterpreterSpecification extends CompilerTestingCommons } property("non-const ProveDHT") { - import sigmastate.basics.CryptoConstants.dlogGroup + import sigmastate.crypto.CryptoConstants.dlogGroup compile(Map("gA" -> dlogGroup.generator.toGroupElement), "proveDHTuple(gA, OUTPUTS(0).R4[GroupElement].get, gA, gA)" ).asInstanceOf[BlockValue].result shouldBe a [CreateProveDHTuple] diff --git a/sc/shared/src/test/scala/sigmastate/utxo/ThresholdSpecification.scala b/sc/shared/src/test/scala/sigmastate/utxo/ThresholdSpecification.scala index ce442ecb50..31536a76fd 100644 --- a/sc/shared/src/test/scala/sigmastate/utxo/ThresholdSpecification.scala +++ b/sc/shared/src/test/scala/sigmastate/utxo/ThresholdSpecification.scala @@ -1,6 +1,6 @@ package sigmastate.utxo -import sigmastate.basics.DLogProtocol.{DLogProverInput, ProveDlog} +import sigmastate.crypto.DLogProtocol.{DLogProverInput, ProveDlog} import sigmastate.Values.{ConcreteCollection, FalseLeaf, IntConstant, SigmaPropConstant, SigmaPropValue, TrueLeaf} import sigmastate._ import sigmastate.helpers.{ContextEnrichingTestProvingInterpreter, ErgoLikeContextTesting, ErgoLikeTestInterpreter, ErgoLikeTransactionTesting, CompilerTestingCommons} diff --git a/sc/shared/src/test/scala/sigmastate/utxo/examples/CoopExampleSpecification.scala b/sc/shared/src/test/scala/sigmastate/utxo/examples/CoopExampleSpecification.scala index 3a2bf8b0c3..44b69db572 100644 --- a/sc/shared/src/test/scala/sigmastate/utxo/examples/CoopExampleSpecification.scala +++ b/sc/shared/src/test/scala/sigmastate/utxo/examples/CoopExampleSpecification.scala @@ -3,7 +3,7 @@ package sigmastate.utxo.examples import org.ergoplatform.{ErgoLikeContext, ErgoLikeTransaction, ErgoBox} import org.scalatest.Assertion import org.scalatest.TryValues._ -import sigmastate.basics.DLogProtocol.{ProveDlog, DLogProverInput} +import sigmastate.crypto.DLogProtocol.{ProveDlog, DLogProverInput} import scorex.crypto.hash.Blake2b256 import sigmastate.Values.{ByteArrayConstant, ErgoTree, BooleanConstant} import sigmastate.helpers.{ContextEnrichingTestProvingInterpreter, ErgoLikeContextTesting, CompilerTestingCommons, ErgoLikeTestInterpreter} diff --git a/sc/shared/src/test/scala/sigmastate/utxo/examples/DHTupleExampleSpecification.scala b/sc/shared/src/test/scala/sigmastate/utxo/examples/DHTupleExampleSpecification.scala index e4984a25c1..92f6e6c4cb 100644 --- a/sc/shared/src/test/scala/sigmastate/utxo/examples/DHTupleExampleSpecification.scala +++ b/sc/shared/src/test/scala/sigmastate/utxo/examples/DHTupleExampleSpecification.scala @@ -6,8 +6,8 @@ import java.math.BigInteger import org.ergoplatform.ErgoBox.{R4, R5} import sigmastate.{AvlTreeData, CompilerCrossVersionProps} import sigmastate.Values.GroupElementConstant -import sigmastate.basics.DLogProtocol.ProveDlog -import sigmastate.basics.{DiffieHellmanTupleProverInput, ProveDHTuple, CryptoConstants} +import sigmastate.crypto.DLogProtocol.ProveDlog +import sigmastate.crypto.{DiffieHellmanTupleProverInput, ProveDHTuple, CryptoConstants} import sigmastate.helpers.{ContextEnrichingTestProvingInterpreter, ErgoLikeContextTesting, CompilerTestingCommons, ErgoLikeTestInterpreter} import sigmastate.helpers.TestingHelpers._ import sigmastate.interpreter.Interpreter._ diff --git a/sc/shared/src/test/scala/sigmastate/utxo/examples/IcoExample.scala b/sc/shared/src/test/scala/sigmastate/utxo/examples/IcoExample.scala index 251b9d1329..bab97e59e8 100644 --- a/sc/shared/src/test/scala/sigmastate/utxo/examples/IcoExample.scala +++ b/sc/shared/src/test/scala/sigmastate/utxo/examples/IcoExample.scala @@ -10,7 +10,7 @@ import scorex.crypto.authds.{ADKey, ADValue} import scorex.crypto.hash.{Blake2b256, Digest32} import sigmastate.Values._ import sigmastate._ -import sigmastate.basics.CryptoConstants +import sigmastate.crypto.CryptoConstants import sigmastate.eval.Extensions.ArrayOps import sigmastate.eval._ import sigmastate.helpers.TestingHelpers._ diff --git a/sc/shared/src/test/scala/sigmastate/utxo/examples/MixExampleSpecification.scala b/sc/shared/src/test/scala/sigmastate/utxo/examples/MixExampleSpecification.scala index c0e9ca1d73..6bbf410dc1 100644 --- a/sc/shared/src/test/scala/sigmastate/utxo/examples/MixExampleSpecification.scala +++ b/sc/shared/src/test/scala/sigmastate/utxo/examples/MixExampleSpecification.scala @@ -6,8 +6,8 @@ import org.ergoplatform.ErgoBox.{R4, R5} import scorex.crypto.hash.Blake2b256 import sigmastate.{AvlTreeData, CompilerCrossVersionProps} import sigmastate.Values.GroupElementConstant -import sigmastate.basics.DLogProtocol.ProveDlog -import sigmastate.basics.{DiffieHellmanTupleProverInput, ProveDHTuple, CryptoConstants} +import sigmastate.crypto.DLogProtocol.ProveDlog +import sigmastate.crypto.{DiffieHellmanTupleProverInput, ProveDHTuple, CryptoConstants} import sigmastate.helpers.{ContextEnrichingTestProvingInterpreter, ErgoLikeContextTesting, CompilerTestingCommons, ErgoLikeTestInterpreter} import sigmastate.helpers.TestingHelpers._ import sigmastate.interpreter.Interpreter._ diff --git a/sc/shared/src/test/scala/sigmastate/utxo/examples/OracleExamplesSpecification.scala b/sc/shared/src/test/scala/sigmastate/utxo/examples/OracleExamplesSpecification.scala index c477638d6f..8566ce437e 100644 --- a/sc/shared/src/test/scala/sigmastate/utxo/examples/OracleExamplesSpecification.scala +++ b/sc/shared/src/test/scala/sigmastate/utxo/examples/OracleExamplesSpecification.scala @@ -14,7 +14,7 @@ import sigmastate.helpers.{CompilerTestingCommons, ContextEnrichingTestProvingIn import sigmastate.helpers.TestingHelpers._ import org.ergoplatform._ import org.ergoplatform.dsl.{ContractSpec, SigmaContractSyntax, StdContracts, TestContractSpec} -import sigmastate.basics.CryptoConstants +import sigmastate.crypto.CryptoConstants import sigmastate.crypto.{BigIntegers, CryptoFacade} import sigmastate.eval.Extensions.ArrayOps import sigmastate.interpreter.Interpreter.{ScriptNameProp, emptyEnv} diff --git a/sc/shared/src/test/scala/sigmastate/utxo/examples/RPSGameExampleSpecification.scala b/sc/shared/src/test/scala/sigmastate/utxo/examples/RPSGameExampleSpecification.scala index c65e63c95c..1f00dbfc3c 100644 --- a/sc/shared/src/test/scala/sigmastate/utxo/examples/RPSGameExampleSpecification.scala +++ b/sc/shared/src/test/scala/sigmastate/utxo/examples/RPSGameExampleSpecification.scala @@ -6,7 +6,7 @@ import scorex.crypto.hash.Blake2b256 import scorex.utils.Random import sigmastate.Values.{ByteArrayConstant, ByteConstant, IntConstant, SigmaPropConstant} import sigmastate._ -import sigmastate.basics.DLogProtocol.ProveDlog +import sigmastate.crypto.DLogProtocol.ProveDlog import sigmastate.helpers.{ContextEnrichingTestProvingInterpreter, ErgoLikeContextTesting, ErgoLikeTestInterpreter, CompilerTestingCommons} import sigmastate.helpers.TestingHelpers._ import sigmastate.interpreter.Interpreter._ diff --git a/sc/shared/src/test/scala/sigmastate/utxo/examples/XorGameExampleSpecification.scala b/sc/shared/src/test/scala/sigmastate/utxo/examples/XorGameExampleSpecification.scala index c462e0396f..436115e9c2 100644 --- a/sc/shared/src/test/scala/sigmastate/utxo/examples/XorGameExampleSpecification.scala +++ b/sc/shared/src/test/scala/sigmastate/utxo/examples/XorGameExampleSpecification.scala @@ -6,7 +6,7 @@ import scorex.crypto.hash.Blake2b256 import scorex.utils.Random import sigmastate.Values.{ByteArrayConstant, ByteConstant, IntConstant, SigmaPropConstant} import sigmastate._ -import sigmastate.basics.DLogProtocol.ProveDlog +import sigmastate.crypto.DLogProtocol.ProveDlog import sigmastate.helpers.{ContextEnrichingTestProvingInterpreter, ErgoLikeContextTesting, ErgoLikeTestInterpreter, CompilerTestingCommons} import sigmastate.helpers.TestingHelpers._ import sigmastate.interpreter.Interpreter._ diff --git a/sc/shared/src/test/scala/special/sigma/SigmaDslSpecification.scala b/sc/shared/src/test/scala/special/sigma/SigmaDslSpecification.scala index eb238964c0..b024607c3f 100644 --- a/sc/shared/src/test/scala/special/sigma/SigmaDslSpecification.scala +++ b/sc/shared/src/test/scala/special/sigma/SigmaDslSpecification.scala @@ -13,7 +13,7 @@ import sigmastate.utils.Extensions._ import sigmastate.SCollection._ import sigmastate.Values.IntConstant import sigmastate._ -import sigmastate.basics.DLogProtocol._ +import sigmastate.crypto.DLogProtocol._ import sigmastate.Values._ import sigmastate.lang.Terms.Apply import sigmastate.eval.Extensions._ @@ -35,7 +35,7 @@ import org.scalacheck.Gen.frequency import org.scalatest.{BeforeAndAfterAll, Tag} import sigma.core.RType._ import scorex.util.ModifierId -import sigmastate.basics.ProveDHTuple +import sigmastate.crypto.ProveDHTuple import sigmastate.interpreter._ import org.scalactic.source.Position import sigma.VersionContext diff --git a/sc/shared/src/test/scala/special/sigma/SigmaDslTesting.scala b/sc/shared/src/test/scala/special/sigma/SigmaDslTesting.scala index 68d74fdca1..f268f77c1e 100644 --- a/sc/shared/src/test/scala/special/sigma/SigmaDslTesting.scala +++ b/sc/shared/src/test/scala/special/sigma/SigmaDslTesting.scala @@ -21,8 +21,8 @@ import sigma.util.Extensions._ import sigma.util.StringUtil.StringUtilExtensions import sigmastate.SType.AnyOps import sigmastate.Values.{ByteArrayConstant, Constant, ConstantNode, ErgoTree, IntConstant, SValue} -import sigmastate.basics.DLogProtocol.{DLogProverInput, ProveDlog} -import sigmastate.basics.SigmaProtocolPrivateInput +import sigmastate.crypto.DLogProtocol.{DLogProverInput, ProveDlog} +import sigmastate.crypto.SigmaProtocolPrivateInput import sigmastate.eval.Extensions._ import sigmastate.eval.{CompiletimeIRContext, CostingBox, CostingDataContext, Evaluation, IRContext, SigmaDsl} import sigmastate.helpers.TestingHelpers._ diff --git a/sdk/js/src/main/scala/org/ergoplatform/sdk/js/SigmaProp.scala b/sdk/js/src/main/scala/org/ergoplatform/sdk/js/SigmaProp.scala index c44a6a19db..2dc665d918 100644 --- a/sdk/js/src/main/scala/org/ergoplatform/sdk/js/SigmaProp.scala +++ b/sdk/js/src/main/scala/org/ergoplatform/sdk/js/SigmaProp.scala @@ -1,7 +1,7 @@ package org.ergoplatform.sdk.js import sigmastate.Values.SigmaBoolean -import sigmastate.basics.DLogProtocol.ProveDlog +import sigmastate.crypto.DLogProtocol.ProveDlog import scala.scalajs.js import scala.scalajs.js.annotation.JSExportTopLevel diff --git a/sdk/js/src/test/scala/org/ergoplatform/sdk/js/ValueSpec.scala b/sdk/js/src/test/scala/org/ergoplatform/sdk/js/ValueSpec.scala index 85bba2b1c8..be0997fcc6 100644 --- a/sdk/js/src/test/scala/org/ergoplatform/sdk/js/ValueSpec.scala +++ b/sdk/js/src/test/scala/org/ergoplatform/sdk/js/ValueSpec.scala @@ -6,8 +6,8 @@ import org.scalatestplus.scalacheck.ScalaCheckPropertyChecks import scorex.util.encode.Base16 import sigmastate.SType import sigmastate.Values.{AvlTreeConstant, BigIntConstant, BooleanConstant, BoxConstant, ByteConstant, Constant, GroupElementConstant, IntConstant, LongConstant, ShortConstant, SigmaPropConstant, UnitConstant} -import sigmastate.basics.CryptoConstants.dlogGroup -import sigmastate.basics.DLogProtocol.ProveDlog +import sigmastate.crypto.CryptoConstants.dlogGroup +import sigmastate.crypto.DLogProtocol.ProveDlog import sigmastate.crypto.CryptoFacade import sigmastate.eval.CSigmaProp import sigmastate.lang.DeserializationSigmaBuilder diff --git a/sdk/shared/src/main/scala/org/ergoplatform/sdk/AppkitProvingInterpreter.scala b/sdk/shared/src/main/scala/org/ergoplatform/sdk/AppkitProvingInterpreter.scala index 6c16ad1e2e..b3b470c604 100644 --- a/sdk/shared/src/main/scala/org/ergoplatform/sdk/AppkitProvingInterpreter.scala +++ b/sdk/shared/src/main/scala/org/ergoplatform/sdk/AppkitProvingInterpreter.scala @@ -11,8 +11,8 @@ import org.ergoplatform.validation.ValidationRules import sigma.util.Extensions.LongOps import sigma.VersionContext import sigmastate.Values.SigmaBoolean -import sigmastate.basics.DLogProtocol.{DLogProverInput, ProveDlog} -import sigmastate.basics.{DiffieHellmanTupleProverInput, SigmaProtocolPrivateInput} +import sigmastate.crypto.DLogProtocol.{DLogProverInput, ProveDlog} +import sigmastate.crypto.{DiffieHellmanTupleProverInput, SigmaProtocolPrivateInput} import sigmastate.interpreter.Interpreter.{ReductionResult, estimateCryptoVerifyCost} import sigmastate.interpreter._ import sigmastate.serialization.SigmaSerializer diff --git a/sdk/shared/src/main/scala/org/ergoplatform/sdk/Extensions.scala b/sdk/shared/src/main/scala/org/ergoplatform/sdk/Extensions.scala index 883133c0cd..98e78188cd 100644 --- a/sdk/shared/src/main/scala/org/ergoplatform/sdk/Extensions.scala +++ b/sdk/shared/src/main/scala/org/ergoplatform/sdk/Extensions.scala @@ -2,7 +2,7 @@ package org.ergoplatform.sdk import debox.cfor import sigma.core.RType -import sigma.core.rtypeToClassTag // actually used +import sigma.rtypeToClassTag // actually used import sigmastate.eval.CPreHeader import sigma.{Coll, CollBuilder, PairColl} import sigma.{Header, PreHeader} diff --git a/sdk/shared/src/main/scala/org/ergoplatform/sdk/JavaHelpers.scala b/sdk/shared/src/main/scala/org/ergoplatform/sdk/JavaHelpers.scala index e0d41818ac..769455e252 100644 --- a/sdk/shared/src/main/scala/org/ergoplatform/sdk/JavaHelpers.scala +++ b/sdk/shared/src/main/scala/org/ergoplatform/sdk/JavaHelpers.scala @@ -20,7 +20,7 @@ import java.lang.{Boolean => JBoolean, Byte => JByte, Integer => JInt, Long => J import java.util.{List => JList, Map => JMap} import org.ergoplatform.ErgoAddressEncoder.NetworkPrefix import scorex.util.encode.Base16 -import sigmastate.basics.DLogProtocol.ProveDlog +import sigmastate.crypto.DLogProtocol.ProveDlog import scorex.util.{ModifierId, bytesToId, idToBytes} import org.ergoplatform.sdk.JavaHelpers.{TokenColl, TokenIdRType} import org.ergoplatform.sdk.Extensions.{CollBuilderOps, PairCollOps} @@ -28,8 +28,8 @@ import org.ergoplatform.sdk.wallet.{Constants, TokensMap} import org.ergoplatform.sdk.wallet.secrets.{DerivationPath, ExtendedSecretKey} import sigma.core.ExactIntegral.LongIsExactIntegral import sigma.util.StringUtil.StringUtilExtensions -import sigmastate.basics.CryptoConstants.EcPointType -import sigmastate.basics.{DiffieHellmanTupleProverInput, ProveDHTuple} +import sigmastate.crypto.CryptoConstants.EcPointType +import sigmastate.crypto.{DiffieHellmanTupleProverInput, ProveDHTuple} import sigmastate.crypto.CryptoFacade import java.math.BigInteger diff --git a/sdk/shared/src/main/scala/org/ergoplatform/sdk/ProverBuilder.scala b/sdk/shared/src/main/scala/org/ergoplatform/sdk/ProverBuilder.scala index 5525dbcc4d..7422d04ed5 100644 --- a/sdk/shared/src/main/scala/org/ergoplatform/sdk/ProverBuilder.scala +++ b/sdk/shared/src/main/scala/org/ergoplatform/sdk/ProverBuilder.scala @@ -2,8 +2,8 @@ package org.ergoplatform.sdk import org.ergoplatform.ErgoAddressEncoder.{MainnetNetworkPrefix, NetworkPrefix} import org.ergoplatform.sdk.wallet.secrets.ExtendedSecretKey -import sigmastate.basics.DLogProtocol.DLogProverInput -import sigmastate.basics.{DLogProtocol, DiffieHellmanTupleProverInput} +import sigmastate.crypto.DLogProtocol.DLogProverInput +import sigmastate.crypto.{DLogProtocol, DiffieHellmanTupleProverInput} import sigma.GroupElement import java.math.BigInteger diff --git a/sdk/shared/src/main/scala/org/ergoplatform/sdk/utils/Zero.scala b/sdk/shared/src/main/scala/org/ergoplatform/sdk/utils/Zero.scala index efaad43446..4733e62710 100644 --- a/sdk/shared/src/main/scala/org/ergoplatform/sdk/utils/Zero.scala +++ b/sdk/shared/src/main/scala/org/ergoplatform/sdk/utils/Zero.scala @@ -7,7 +7,7 @@ import scorex.crypto.authds.avltree.batch.BatchAVLProver import scorex.crypto.hash.{Blake2b256, Digest32} import scorex.util.ModifierId import sigmastate.Values.ErgoTree -import sigmastate.basics.CryptoConstants +import sigmastate.crypto.CryptoConstants import sigmastate.eval._ import sigmastate.{AvlTreeData, AvlTreeFlags, TrivialProp} import sigma._ diff --git a/sdk/shared/src/main/scala/org/ergoplatform/sdk/wallet/secrets/ExtendedPublicKey.scala b/sdk/shared/src/main/scala/org/ergoplatform/sdk/wallet/secrets/ExtendedPublicKey.scala index 10536b20b0..2ad287972e 100644 --- a/sdk/shared/src/main/scala/org/ergoplatform/sdk/wallet/secrets/ExtendedPublicKey.scala +++ b/sdk/shared/src/main/scala/org/ergoplatform/sdk/wallet/secrets/ExtendedPublicKey.scala @@ -1,8 +1,7 @@ package org.ergoplatform.sdk.wallet.secrets -import java.util -import sigmastate.basics.DLogProtocol.{DLogProverInput, ProveDlog} -import sigmastate.basics.CryptoConstants +import sigmastate.crypto.DLogProtocol.{DLogProverInput, ProveDlog} +import sigmastate.crypto.CryptoConstants import sigmastate.crypto.CryptoFacade import sigmastate.crypto.BigIntegers import sigmastate.serialization.SigmaSerializer diff --git a/sdk/shared/src/main/scala/org/ergoplatform/sdk/wallet/secrets/ExtendedSecretKey.scala b/sdk/shared/src/main/scala/org/ergoplatform/sdk/wallet/secrets/ExtendedSecretKey.scala index 96802217df..4b87e31e13 100644 --- a/sdk/shared/src/main/scala/org/ergoplatform/sdk/wallet/secrets/ExtendedSecretKey.scala +++ b/sdk/shared/src/main/scala/org/ergoplatform/sdk/wallet/secrets/ExtendedSecretKey.scala @@ -1,12 +1,10 @@ package org.ergoplatform.sdk.wallet.secrets -import org.ergoplatform.sdk.wallet.Constants import java.math.BigInteger -import java.util import sigmastate.crypto.BigIntegers -import sigmastate.basics.DLogProtocol -import sigmastate.basics.DLogProtocol.DLogProverInput -import sigmastate.basics.CryptoConstants +import sigmastate.crypto.DLogProtocol +import sigmastate.crypto.DLogProtocol.DLogProverInput +import sigmastate.crypto.CryptoConstants import sigmastate.crypto.CryptoFacade import sigmastate.serialization.SigmaSerializer import sigmastate.utils.{SigmaByteReader, SigmaByteWriter} diff --git a/sdk/shared/src/main/scala/org/ergoplatform/sdk/wallet/secrets/SecretKey.scala b/sdk/shared/src/main/scala/org/ergoplatform/sdk/wallet/secrets/SecretKey.scala index 73ce7d39ea..7fb8cc7481 100644 --- a/sdk/shared/src/main/scala/org/ergoplatform/sdk/wallet/secrets/SecretKey.scala +++ b/sdk/shared/src/main/scala/org/ergoplatform/sdk/wallet/secrets/SecretKey.scala @@ -1,7 +1,7 @@ package org.ergoplatform.sdk.wallet.secrets -import sigmastate.basics.DLogProtocol.DLogProverInput -import sigmastate.basics.{DiffieHellmanTupleProverInput, SigmaProtocolPrivateInput} +import sigmastate.crypto.DLogProtocol.DLogProverInput +import sigmastate.crypto.{DiffieHellmanTupleProverInput, SigmaProtocolPrivateInput} /** * Basic trait for secret data, encapsulating a corresponding private inputs for a Sigma protocol. diff --git a/sdk/shared/src/test/scala/org/ergoplatform/sdk/DataJsonEncoderSpecification.scala b/sdk/shared/src/test/scala/org/ergoplatform/sdk/DataJsonEncoderSpecification.scala index bc6e9faaf8..019db458c0 100644 --- a/sdk/shared/src/test/scala/org/ergoplatform/sdk/DataJsonEncoderSpecification.scala +++ b/sdk/shared/src/test/scala/org/ergoplatform/sdk/DataJsonEncoderSpecification.scala @@ -11,7 +11,7 @@ import sigmastate.Values.SigmaBoolean import sigmastate._ import sigmastate.eval.Extensions._ import sigmastate.eval.{Evaluation, _} -import sigmastate.basics.CryptoConstants.EcPointType +import sigmastate.crypto.CryptoConstants.EcPointType import sigmastate.exceptions.SerializerException import sigma.{Box, AvlTree} import sigmastate.serialization.SerializationSpecification diff --git a/sdk/shared/src/test/scala/org/ergoplatform/sdk/JsonSerializationSpec.scala b/sdk/shared/src/test/scala/org/ergoplatform/sdk/JsonSerializationSpec.scala index 353134a076..70615d6796 100644 --- a/sdk/shared/src/test/scala/org/ergoplatform/sdk/JsonSerializationSpec.scala +++ b/sdk/shared/src/test/scala/org/ergoplatform/sdk/JsonSerializationSpec.scala @@ -11,8 +11,8 @@ import scorex.util.ModifierId import scorex.util.encode.Base16 import sigmastate.{AvlTreeData, SType} import sigmastate.Values.{ByteArrayConstant, ByteConstant, ErgoTree, EvaluatedValue, IntConstant, LongArrayConstant, SigmaPropConstant} -import sigmastate.basics.CryptoConstants -import sigmastate.basics.DLogProtocol.ProveDlog +import sigmastate.crypto.CryptoConstants +import sigmastate.crypto.DLogProtocol.ProveDlog import sigmastate.eval.Digest32Coll import sigmastate.interpreter.{ContextExtension, ProverResult} import sigmastate.serialization.SerializationSpecification diff --git a/sdk/shared/src/test/scala/org/ergoplatform/sdk/wallet/utils/Generators.scala b/sdk/shared/src/test/scala/org/ergoplatform/sdk/wallet/utils/Generators.scala index e4cc09c4a2..80164f5f23 100644 --- a/sdk/shared/src/test/scala/org/ergoplatform/sdk/wallet/utils/Generators.scala +++ b/sdk/shared/src/test/scala/org/ergoplatform/sdk/wallet/utils/Generators.scala @@ -9,7 +9,7 @@ import org.scalacheck.Arbitrary.arbByte import org.scalacheck.{Arbitrary, Gen} import scorex.crypto.authds.ADKey import sigmastate.Values.{ByteArrayConstant, CollectionConstant, ErgoTree, EvaluatedValue, FalseLeaf, TrueLeaf} -import sigmastate.basics.DLogProtocol.ProveDlog +import sigmastate.crypto.DLogProtocol.ProveDlog import sigmastate.{SByte, SType} import scorex.util._ import org.ergoplatform.{ErgoBox, ErgoBoxCandidate, ErgoTreePredef, UnsignedErgoLikeTransaction, UnsignedInput} From dec171b059e58df7d6c1c84c6acb04f57caf6fa8 Mon Sep 17 00:00:00 2001 From: Alexander Slesarenko Date: Thu, 24 Aug 2023 19:27:36 +0200 Subject: [PATCH 15/37] minimize-modules: move ExactIntegral, ExactOrdering --- .../main/scala/sigma/core/ExactIntegral.scala | 62 ------------------- .../main/scala/sigma/core/ExactNumeric.scala | 46 -------------- .../main/scala/sigma/core/ExactOrdering.scala | 27 -------- .../src/main/scala/sigma/core/package.scala | 19 ++++++ .../shared/src/main/scala/sigma/package.scala | 30 ++++----- .../scala/sigmastate/crypto/Platform.scala | 1 - .../scala/sigmastate/eval/BigIntegerOps.scala | 7 --- .../scala/sigmastate/eval/Evaluation.scala | 14 +---- .../src/main/scala/sigmastate/types.scala | 3 +- .../CollsStagingTests.scala | 0 .../DataValueComparerSpecification.scala | 0 .../scala/{special => }/sigma/LoopTests.scala | 0 .../sigma/SigmaDslSpecification.scala | 2 +- .../sigma/SigmaDslStaginTests.scala | 0 .../{special => }/sigma/SigmaDslTesting.scala | 0 15 files changed, 38 insertions(+), 173 deletions(-) delete mode 100644 common/shared/src/main/scala/sigma/core/ExactIntegral.scala delete mode 100644 common/shared/src/main/scala/sigma/core/ExactNumeric.scala delete mode 100644 common/shared/src/main/scala/sigma/core/ExactOrdering.scala rename sc/shared/src/test/scala/{special/collections => sigma}/CollsStagingTests.scala (100%) rename sc/shared/src/test/scala/{special => }/sigma/DataValueComparerSpecification.scala (100%) rename sc/shared/src/test/scala/{special => }/sigma/LoopTests.scala (100%) rename sc/shared/src/test/scala/{special => }/sigma/SigmaDslSpecification.scala (99%) rename sc/shared/src/test/scala/{special => }/sigma/SigmaDslStaginTests.scala (100%) rename sc/shared/src/test/scala/{special => }/sigma/SigmaDslTesting.scala (100%) diff --git a/common/shared/src/main/scala/sigma/core/ExactIntegral.scala b/common/shared/src/main/scala/sigma/core/ExactIntegral.scala deleted file mode 100644 index e8092789fd..0000000000 --- a/common/shared/src/main/scala/sigma/core/ExactIntegral.scala +++ /dev/null @@ -1,62 +0,0 @@ -package sigma.core - -import sigma.util.Extensions.{ByteOps, ShortOps} - -/** Type-class which defines the operations on Integral types (Byte, Short, Int, Long, BigInt) - * with overflow checks. - * - * An exception is raised when an overflow is detected. - * Each concrete instance of this type-class overrides three methods `plus`, `minus`, - * `times`. - * - * By default all the methods are implemented by delegating to the corresponding Integral - * instance from the standard Scala library. - * - * This trait is used in core IR to avoid implicitly using standard scala implementations. - */ -trait ExactIntegral[T] extends ExactNumeric[T] { - protected val n: scala.math.Integral[T] - - /** Integer division operation `x / y`. */ - def quot(x: T, y: T): T = n.quot(x, y) - - /** Operation which returns remainder from dividing x by y. - * The exact rules are defined in the concrete instance of the type T. - * A default implementation delegates to Integral[T].rem method for the corresponding - * type T. - * The default implementation can be overridden for any concrete type T. - */ - def divisionRemainder(x: T, y: T): T = n.rem(x, y) -} - -/** ExactIntegral instances for all types. */ -object ExactIntegral { - - implicit object ByteIsExactIntegral extends ExactIntegral[Byte] { - val n = scala.math.Numeric.ByteIsIntegral - override def plus(x: Byte, y: Byte): Byte = x.addExact(y) - override def minus(x: Byte, y: Byte): Byte = x.subtractExact(y) - override def times(x: Byte, y: Byte): Byte = x.multiplyExact(y) - } - - implicit object ShortIsExactIntegral extends ExactIntegral[Short] { - val n = scala.math.Numeric.ShortIsIntegral - override def plus(x: Short, y: Short): Short = x.addExact(y) - override def minus(x: Short, y: Short): Short = x.subtractExact(y) - override def times(x: Short, y: Short): Short = x.multiplyExact(y) - } - - implicit object IntIsExactIntegral extends ExactIntegral[Int] { - val n = scala.math.Numeric.IntIsIntegral - override def plus(x: Int, y: Int): Int = java7.compat.Math.addExact(x, y) - override def minus(x: Int, y: Int): Int = java7.compat.Math.subtractExact(x, y) - override def times(x: Int, y: Int): Int = java7.compat.Math.multiplyExact(x, y) - } - - implicit object LongIsExactIntegral extends ExactIntegral[Long] { - val n = scala.math.Numeric.LongIsIntegral - override def plus(x: Long, y: Long): Long = java7.compat.Math.addExact(x, y) - override def minus(x: Long, y: Long): Long = java7.compat.Math.subtractExact(x, y) - override def times(x: Long, y: Long): Long = java7.compat.Math.multiplyExact(x, y) - } -} diff --git a/common/shared/src/main/scala/sigma/core/ExactNumeric.scala b/common/shared/src/main/scala/sigma/core/ExactNumeric.scala deleted file mode 100644 index 75a33d11a1..0000000000 --- a/common/shared/src/main/scala/sigma/core/ExactNumeric.scala +++ /dev/null @@ -1,46 +0,0 @@ -package sigma.core - -import sigma.core.ExactIntegral._ - -/** Numeric operations with overflow checks. - * Raise exception when overflow is detected. - * Each instance of this typeclass overrides three methods `plus`, `minus`, `times`. - * All other methods are implemented by delegating to the corresponding Numeric instance from - * standard Scala library. - * This trait is used in core IR to avoid implicitly using standard scala implementations - */ -trait ExactNumeric[T] { - protected val n: Numeric[T] - - /** Addition operation `x + y`. */ - def plus(x: T, y: T): T - - /** Subtraction operation `x - y`. */ - def minus(x: T, y: T): T - - /** Multiplication operation `x * y`. */ - def times(x: T, y: T): T - - /** Returns negative value `-x`. */ - def negate(x: T): T = n.negate(x) - - /** Returns a value of type T, which corresponds to the given integer value `x`. */ - def fromInt(x: Int): T = n.fromInt(x) - - def toInt(x: T): Int = n.toInt(x) - def toLong(x: T): Long = n.toLong(x) - - /** A value of type T which corresponds to integer 0. */ - lazy val zero: T = fromInt(0) - - /** A value of type T which corresponds to integer 1. */ - lazy val one: T = fromInt(1) -} - -object ExactNumeric { - /** ExactNumeric instances are the same as ExactIntegral. - * This values are implicitly used wherever ExactNumeric is needed (see usages). - */ - implicit def IntIsExactNumeric: ExactNumeric[Int] = IntIsExactIntegral - implicit def LongIsExactNumeric: ExactNumeric[Long] = LongIsExactIntegral -} diff --git a/common/shared/src/main/scala/sigma/core/ExactOrdering.scala b/common/shared/src/main/scala/sigma/core/ExactOrdering.scala deleted file mode 100644 index 95264cb979..0000000000 --- a/common/shared/src/main/scala/sigma/core/ExactOrdering.scala +++ /dev/null @@ -1,27 +0,0 @@ -package sigma.core - -import scala.math.Numeric.{ByteIsIntegral, LongIsIntegral, ShortIsIntegral, IntIsIntegral} - -/** Ordering operations to be used with other Exact traits. - * All methods are implemented by delegating to the corresponding Ordering instance from - * standard Scala library. - * This trait is used in core IR to avoid implicitly using standard scala implementations. - */ -trait ExactOrdering[T] extends Ordering[T] { - val n: Ordering[T] - override def compare(x: T, y: T): Int = n.compare(x, y) -} - -class ExactOrderingImpl[T](val n: Ordering[T]) extends ExactOrdering[T] - -/** ExactOrdering instances for all types. */ -object ExactOrdering { - - implicit object ByteIsExactOrdering extends ExactOrderingImpl[Byte](ByteIsIntegral) - - implicit object ShortIsExactOrdering extends ExactOrderingImpl[Short](ShortIsIntegral) - - implicit object IntIsExactOrdering extends ExactOrderingImpl[Int](IntIsIntegral) - - implicit object LongIsExactOrdering extends ExactOrderingImpl[Long](LongIsIntegral) -} diff --git a/common/shared/src/main/scala/sigma/core/package.scala b/common/shared/src/main/scala/sigma/core/package.scala index 5bf1562a68..e1b214c2b6 100644 --- a/common/shared/src/main/scala/sigma/core/package.scala +++ b/common/shared/src/main/scala/sigma/core/package.scala @@ -1,6 +1,25 @@ package sigma +import scala.reflect.classTag + +/** Contains cores definitions which serves as a basis for [[sigma]] package implementations. */ package object core { + /** Shadow the implicit from sigma package so it doesn't interfere with the resolution + * of ClassTags below. + */ + private def rtypeToClassTag = ??? + + val BigIntClassTag = classTag[BigInt] + val GroupElementClassTag = classTag[GroupElement] + val SigmaPropClassTag = classTag[SigmaProp] + val AvlTreeClassTag = classTag[AvlTree] + val BoxClassTag = classTag[Box] + val ContextClassTag = classTag[Context] + val HeaderClassTag = classTag[Header] + val PreHeaderClassTag = classTag[PreHeader] + val AnyValueClassTag = classTag[AnyValue] + val SigmaDslBuilderClassTag = classTag[SigmaDslBuilder] + val CollBuilderClassTag = classTag[CollBuilder] /** Immutable empty array of integers, should be used instead of allocating new empty arrays. */ val EmptyArrayOfInt = Array.empty[Int] diff --git a/common/shared/src/main/scala/sigma/package.scala b/common/shared/src/main/scala/sigma/package.scala index 44368a0ade..b0c8ce9022 100644 --- a/common/shared/src/main/scala/sigma/package.scala +++ b/common/shared/src/main/scala/sigma/package.scala @@ -1,9 +1,8 @@ -import java.math.BigInteger -import sigma.core.RType +import sigma.core._ import sigma.core.RType.{GeneralType, SomeType} -import scala.reflect.{ClassTag, classTag} +import scala.reflect.ClassTag /** The following implicit values are used as type descriptors of all the predefined Sigma types. * @see [[RType]] class @@ -12,23 +11,20 @@ package object sigma { /** Forces reflection data initialization */ val coreLibReflection = CoreLibReflection - implicit val BigIntRType: RType[BigInt] = GeneralType(classTag[BigInt]) - implicit val GroupElementRType: RType[GroupElement] = GeneralType(classTag[GroupElement]) - implicit val SigmaPropRType: RType[SigmaProp] = GeneralType(classTag[SigmaProp]) - implicit val AvlTreeRType: RType[AvlTree] = GeneralType(classTag[AvlTree]) + implicit val BigIntRType: RType[BigInt] = GeneralType(BigIntClassTag) + implicit val GroupElementRType: RType[GroupElement] = GeneralType(GroupElementClassTag) + implicit val SigmaPropRType: RType[SigmaProp] = GeneralType(SigmaPropClassTag) + implicit val AvlTreeRType: RType[AvlTree] = GeneralType(AvlTreeClassTag) - implicit val BoxRType: RType[Box] = GeneralType(classTag[Box]) - implicit val ContextRType: RType[Context] = GeneralType(classTag[Context]) + implicit val BoxRType: RType[Box] = GeneralType(BoxClassTag) + implicit val ContextRType: RType[Context] = GeneralType(ContextClassTag) - implicit val HeaderRType: RType[Header] = GeneralType(classTag[Header]) - implicit val PreHeaderRType: RType[PreHeader] = GeneralType(classTag[PreHeader]) + implicit val HeaderRType: RType[Header] = GeneralType(HeaderClassTag) + implicit val PreHeaderRType: RType[PreHeader] = GeneralType(PreHeaderClassTag) - implicit val AnyValueRType: RType[AnyValue] = RType.fromClassTag(classTag[AnyValue]) + implicit val AnyValueRType: RType[AnyValue] = RType.fromClassTag(AnyValueClassTag) - implicit val SigmaContractRType: RType[SigmaContract] = RType.fromClassTag(classTag[SigmaContract]) - implicit val SigmaDslBuilderRType: RType[SigmaDslBuilder] = RType.fromClassTag(classTag[SigmaDslBuilder]) - - implicit val BigIntegerRType: RType[BigInteger] = GeneralType(classTag[BigInteger]) + implicit val SigmaDslBuilderRType: RType[SigmaDslBuilder] = RType.fromClassTag(SigmaDslBuilderClassTag) /** Implicit resolution of `Coll[A]` type descriptor, given a descriptor of `A`. */ implicit def collRType[A](implicit tA: RType[A]): RType[Coll[A]] = CollType[A](tA) @@ -38,7 +34,7 @@ package object sigma { */ implicit def rtypeToClassTag[A](implicit t: RType[A]): ClassTag[A] = t.classTag - implicit val collBuilderRType: RType[CollBuilder] = RType.fromClassTag(classTag[CollBuilder]) + implicit val collBuilderRType: RType[CollBuilder] = RType.fromClassTag(CollBuilderClassTag) private def sameLengthErrorMsg[A, B](xs: Coll[A], ys: Coll[B]) = s"Collections should have same length but was ${xs.length} and ${ys.length}:\n xs=$xs;\n ys=$ys" diff --git a/interpreter/js/src/main/scala/sigmastate/crypto/Platform.scala b/interpreter/js/src/main/scala/sigmastate/crypto/Platform.scala index 435792e39f..538b14348b 100644 --- a/interpreter/js/src/main/scala/sigmastate/crypto/Platform.scala +++ b/interpreter/js/src/main/scala/sigmastate/crypto/Platform.scala @@ -10,7 +10,6 @@ import java.math.BigInteger import scala.scalajs.js import scala.scalajs.js.UnicodeNormalizationForm import scala.scalajs.js.typedarray.Uint8Array -import scala.util.Random /** JVM specific implementation of crypto methods (NOT yet implemented). */ object Platform { diff --git a/interpreter/shared/src/main/scala/sigmastate/eval/BigIntegerOps.scala b/interpreter/shared/src/main/scala/sigmastate/eval/BigIntegerOps.scala index b92134be41..e249b38864 100644 --- a/interpreter/shared/src/main/scala/sigmastate/eval/BigIntegerOps.scala +++ b/interpreter/shared/src/main/scala/sigmastate/eval/BigIntegerOps.scala @@ -1,7 +1,5 @@ package sigmastate.eval -import java.math.BigInteger - import sigma.core.{ExactOrderingImpl, ExactIntegral} import scala.math.{Integral, Ordering} @@ -11,11 +9,6 @@ import sigmastate.eval.Extensions._ object OrderingOps { def apply[T](implicit ord: Ordering[T]) = ord - trait BigIntegerOrdering extends Ordering[BigInteger] { - def compare(x: BigInteger, y: BigInteger) = x.compareTo(y) - } - implicit object BigIntegerOrdering extends BigIntegerOrdering - trait BigIntOrdering extends Ordering[BigInt] { def compare(x: BigInt, y: BigInt) = x.compareTo(y) } diff --git a/interpreter/shared/src/main/scala/sigmastate/eval/Evaluation.scala b/interpreter/shared/src/main/scala/sigmastate/eval/Evaluation.scala index 27188d1410..e7ad1f4113 100644 --- a/interpreter/shared/src/main/scala/sigmastate/eval/Evaluation.scala +++ b/interpreter/shared/src/main/scala/sigmastate/eval/Evaluation.scala @@ -98,12 +98,8 @@ object Evaluation { case StringType => SString case AnyType => SAny case UnitType => SUnit - - case BigIntegerRType => SBigInt case BigIntRType => SBigInt - case GroupElementRType => SGroupElement - case AvlTreeRType => SAvlTree case ot: OptionType[_] => sigmastate.SOption(rtypeToSType(ot.tA)) case BoxRType => SBox @@ -142,19 +138,15 @@ object Evaluation { case _: Long => LongType case _: String => StringType case _: Unit => UnitType - - case _: BigInteger => BigIntegerRType case _: sigma.BigInt => BigIntRType - case _: GroupElement => GroupElementRType - - case _: ErgoBox => ErgoBoxRType + case _: ErgoBox => ErgoBoxRType // TODO remove this RType case _: Box => BoxRType - case _: AvlTreeData => AvlTreeDataRType + case _: AvlTreeData => AvlTreeDataRType // TODO remove this RType case _: AvlTree => AvlTreeRType - case _: SigmaBoolean => SigmaBooleanRType + case _: SigmaBoolean => SigmaBooleanRType // TODO remove this RType case _: SigmaProp => SigmaPropRType case _: Context => ContextRType case _ => diff --git a/interpreter/shared/src/main/scala/sigmastate/types.scala b/interpreter/shared/src/main/scala/sigmastate/types.scala index 716fb738dc..0ca0cc50c1 100644 --- a/interpreter/shared/src/main/scala/sigmastate/types.scala +++ b/interpreter/shared/src/main/scala/sigmastate/types.scala @@ -115,6 +115,7 @@ object SType { implicit def typeCollection[V <: SType](implicit tV: V): SCollection[V] = SCollection[V](tV) /** RType descriptors for predefined types used in AOTC-based interpreter. */ + def rtypeToClassTag = ??? implicit val SigmaBooleanRType: RType[SigmaBoolean] = RType.fromClassTag(classTag[SigmaBoolean]) implicit val ErgoBoxRType: RType[ErgoBox] = RType.fromClassTag(classTag[ErgoBox]) implicit val ErgoBoxCandidateRType: RType[ErgoBoxCandidate] = RType.fromClassTag(classTag[ErgoBoxCandidate]) @@ -269,7 +270,7 @@ object SType { case SShort => reflect.classTag[Short] case SInt => reflect.classTag[Int] case SLong => reflect.classTag[Long] - case SBigInt => reflect.classTag[BigInteger] + case SBigInt => reflect.classTag[BigInt] case SAvlTree => reflect.classTag[AvlTree] case SGroupElement => reflect.classTag[EcPointType] case SSigmaProp => reflect.classTag[SigmaBoolean] diff --git a/sc/shared/src/test/scala/special/collections/CollsStagingTests.scala b/sc/shared/src/test/scala/sigma/CollsStagingTests.scala similarity index 100% rename from sc/shared/src/test/scala/special/collections/CollsStagingTests.scala rename to sc/shared/src/test/scala/sigma/CollsStagingTests.scala diff --git a/sc/shared/src/test/scala/special/sigma/DataValueComparerSpecification.scala b/sc/shared/src/test/scala/sigma/DataValueComparerSpecification.scala similarity index 100% rename from sc/shared/src/test/scala/special/sigma/DataValueComparerSpecification.scala rename to sc/shared/src/test/scala/sigma/DataValueComparerSpecification.scala diff --git a/sc/shared/src/test/scala/special/sigma/LoopTests.scala b/sc/shared/src/test/scala/sigma/LoopTests.scala similarity index 100% rename from sc/shared/src/test/scala/special/sigma/LoopTests.scala rename to sc/shared/src/test/scala/sigma/LoopTests.scala diff --git a/sc/shared/src/test/scala/special/sigma/SigmaDslSpecification.scala b/sc/shared/src/test/scala/sigma/SigmaDslSpecification.scala similarity index 99% rename from sc/shared/src/test/scala/special/sigma/SigmaDslSpecification.scala rename to sc/shared/src/test/scala/sigma/SigmaDslSpecification.scala index b024607c3f..343ad5396b 100644 --- a/sc/shared/src/test/scala/special/sigma/SigmaDslSpecification.scala +++ b/sc/shared/src/test/scala/sigma/SigmaDslSpecification.scala @@ -1,4 +1,4 @@ -package sigma +package special.sigma import java.math.BigInteger import org.ergoplatform._ diff --git a/sc/shared/src/test/scala/special/sigma/SigmaDslStaginTests.scala b/sc/shared/src/test/scala/sigma/SigmaDslStaginTests.scala similarity index 100% rename from sc/shared/src/test/scala/special/sigma/SigmaDslStaginTests.scala rename to sc/shared/src/test/scala/sigma/SigmaDslStaginTests.scala diff --git a/sc/shared/src/test/scala/special/sigma/SigmaDslTesting.scala b/sc/shared/src/test/scala/sigma/SigmaDslTesting.scala similarity index 100% rename from sc/shared/src/test/scala/special/sigma/SigmaDslTesting.scala rename to sc/shared/src/test/scala/sigma/SigmaDslTesting.scala From f1d0fc70c30d790af057c93255c040f92643b848 Mon Sep 17 00:00:00 2001 From: Alexander Slesarenko Date: Thu, 24 Aug 2023 19:33:21 +0200 Subject: [PATCH 16/37] minimize-modules: CollType moved --- .../scala/sigma/{ => core}/CollType.scala | 4 +- .../scala/sigmastate/eval/Evaluation.scala | 4 +- .../scala/sigmastate/eval/ExactIntegral.scala | 62 +++++++++++++++++++ .../scala/sigmastate/eval/ExactNumeric.scala | 46 ++++++++++++++ .../scala/sigmastate/eval/ExactOrdering.scala | 27 ++++++++ .../sigmastate/helpers/SigmaPPrintSpec.scala | 3 +- .../test/scala/sigma/SigmaDslTesting.scala | 4 +- .../sigmastate/helpers/SigmaPPrint.scala | 10 +-- .../scala/org/ergoplatform/sdk/js/Value.scala | 4 +- .../org/ergoplatform/sdk/utils/Zero.scala | 2 +- 10 files changed, 149 insertions(+), 17 deletions(-) rename common/shared/src/main/scala/sigma/{ => core}/CollType.scala (94%) create mode 100644 interpreter/shared/src/main/scala/sigmastate/eval/ExactIntegral.scala create mode 100644 interpreter/shared/src/main/scala/sigmastate/eval/ExactNumeric.scala create mode 100644 interpreter/shared/src/main/scala/sigmastate/eval/ExactOrdering.scala diff --git a/common/shared/src/main/scala/sigma/CollType.scala b/common/shared/src/main/scala/sigma/core/CollType.scala similarity index 94% rename from common/shared/src/main/scala/sigma/CollType.scala rename to common/shared/src/main/scala/sigma/core/CollType.scala index 7af67852fe..dc526abd69 100644 --- a/common/shared/src/main/scala/sigma/CollType.scala +++ b/common/shared/src/main/scala/sigma/core/CollType.scala @@ -1,6 +1,6 @@ -package sigma +package sigma.core -import sigma.core.RType +import sigma.Coll import scala.language.implicitConversions import scala.reflect.ClassTag diff --git a/interpreter/shared/src/main/scala/sigmastate/eval/Evaluation.scala b/interpreter/shared/src/main/scala/sigmastate/eval/Evaluation.scala index e7ad1f4113..daf520a0f1 100644 --- a/interpreter/shared/src/main/scala/sigmastate/eval/Evaluation.scala +++ b/interpreter/shared/src/main/scala/sigmastate/eval/Evaluation.scala @@ -1,14 +1,14 @@ package sigmastate.eval import org.ergoplatform._ -import sigma.core.RType +import sigma.core.{CollType, RType} import sigma.core.RType._ import sigmastate.SType._ import sigmastate.Values.SigmaBoolean import sigmastate._ import debox.cfor import sigmastate.exceptions.CostLimitException -import java.math.BigInteger + import scala.reflect.ClassTag import scala.util.Try diff --git a/interpreter/shared/src/main/scala/sigmastate/eval/ExactIntegral.scala b/interpreter/shared/src/main/scala/sigmastate/eval/ExactIntegral.scala new file mode 100644 index 0000000000..e8092789fd --- /dev/null +++ b/interpreter/shared/src/main/scala/sigmastate/eval/ExactIntegral.scala @@ -0,0 +1,62 @@ +package sigma.core + +import sigma.util.Extensions.{ByteOps, ShortOps} + +/** Type-class which defines the operations on Integral types (Byte, Short, Int, Long, BigInt) + * with overflow checks. + * + * An exception is raised when an overflow is detected. + * Each concrete instance of this type-class overrides three methods `plus`, `minus`, + * `times`. + * + * By default all the methods are implemented by delegating to the corresponding Integral + * instance from the standard Scala library. + * + * This trait is used in core IR to avoid implicitly using standard scala implementations. + */ +trait ExactIntegral[T] extends ExactNumeric[T] { + protected val n: scala.math.Integral[T] + + /** Integer division operation `x / y`. */ + def quot(x: T, y: T): T = n.quot(x, y) + + /** Operation which returns remainder from dividing x by y. + * The exact rules are defined in the concrete instance of the type T. + * A default implementation delegates to Integral[T].rem method for the corresponding + * type T. + * The default implementation can be overridden for any concrete type T. + */ + def divisionRemainder(x: T, y: T): T = n.rem(x, y) +} + +/** ExactIntegral instances for all types. */ +object ExactIntegral { + + implicit object ByteIsExactIntegral extends ExactIntegral[Byte] { + val n = scala.math.Numeric.ByteIsIntegral + override def plus(x: Byte, y: Byte): Byte = x.addExact(y) + override def minus(x: Byte, y: Byte): Byte = x.subtractExact(y) + override def times(x: Byte, y: Byte): Byte = x.multiplyExact(y) + } + + implicit object ShortIsExactIntegral extends ExactIntegral[Short] { + val n = scala.math.Numeric.ShortIsIntegral + override def plus(x: Short, y: Short): Short = x.addExact(y) + override def minus(x: Short, y: Short): Short = x.subtractExact(y) + override def times(x: Short, y: Short): Short = x.multiplyExact(y) + } + + implicit object IntIsExactIntegral extends ExactIntegral[Int] { + val n = scala.math.Numeric.IntIsIntegral + override def plus(x: Int, y: Int): Int = java7.compat.Math.addExact(x, y) + override def minus(x: Int, y: Int): Int = java7.compat.Math.subtractExact(x, y) + override def times(x: Int, y: Int): Int = java7.compat.Math.multiplyExact(x, y) + } + + implicit object LongIsExactIntegral extends ExactIntegral[Long] { + val n = scala.math.Numeric.LongIsIntegral + override def plus(x: Long, y: Long): Long = java7.compat.Math.addExact(x, y) + override def minus(x: Long, y: Long): Long = java7.compat.Math.subtractExact(x, y) + override def times(x: Long, y: Long): Long = java7.compat.Math.multiplyExact(x, y) + } +} diff --git a/interpreter/shared/src/main/scala/sigmastate/eval/ExactNumeric.scala b/interpreter/shared/src/main/scala/sigmastate/eval/ExactNumeric.scala new file mode 100644 index 0000000000..75a33d11a1 --- /dev/null +++ b/interpreter/shared/src/main/scala/sigmastate/eval/ExactNumeric.scala @@ -0,0 +1,46 @@ +package sigma.core + +import sigma.core.ExactIntegral._ + +/** Numeric operations with overflow checks. + * Raise exception when overflow is detected. + * Each instance of this typeclass overrides three methods `plus`, `minus`, `times`. + * All other methods are implemented by delegating to the corresponding Numeric instance from + * standard Scala library. + * This trait is used in core IR to avoid implicitly using standard scala implementations + */ +trait ExactNumeric[T] { + protected val n: Numeric[T] + + /** Addition operation `x + y`. */ + def plus(x: T, y: T): T + + /** Subtraction operation `x - y`. */ + def minus(x: T, y: T): T + + /** Multiplication operation `x * y`. */ + def times(x: T, y: T): T + + /** Returns negative value `-x`. */ + def negate(x: T): T = n.negate(x) + + /** Returns a value of type T, which corresponds to the given integer value `x`. */ + def fromInt(x: Int): T = n.fromInt(x) + + def toInt(x: T): Int = n.toInt(x) + def toLong(x: T): Long = n.toLong(x) + + /** A value of type T which corresponds to integer 0. */ + lazy val zero: T = fromInt(0) + + /** A value of type T which corresponds to integer 1. */ + lazy val one: T = fromInt(1) +} + +object ExactNumeric { + /** ExactNumeric instances are the same as ExactIntegral. + * This values are implicitly used wherever ExactNumeric is needed (see usages). + */ + implicit def IntIsExactNumeric: ExactNumeric[Int] = IntIsExactIntegral + implicit def LongIsExactNumeric: ExactNumeric[Long] = LongIsExactIntegral +} diff --git a/interpreter/shared/src/main/scala/sigmastate/eval/ExactOrdering.scala b/interpreter/shared/src/main/scala/sigmastate/eval/ExactOrdering.scala new file mode 100644 index 0000000000..95264cb979 --- /dev/null +++ b/interpreter/shared/src/main/scala/sigmastate/eval/ExactOrdering.scala @@ -0,0 +1,27 @@ +package sigma.core + +import scala.math.Numeric.{ByteIsIntegral, LongIsIntegral, ShortIsIntegral, IntIsIntegral} + +/** Ordering operations to be used with other Exact traits. + * All methods are implemented by delegating to the corresponding Ordering instance from + * standard Scala library. + * This trait is used in core IR to avoid implicitly using standard scala implementations. + */ +trait ExactOrdering[T] extends Ordering[T] { + val n: Ordering[T] + override def compare(x: T, y: T): Int = n.compare(x, y) +} + +class ExactOrderingImpl[T](val n: Ordering[T]) extends ExactOrdering[T] + +/** ExactOrdering instances for all types. */ +object ExactOrdering { + + implicit object ByteIsExactOrdering extends ExactOrderingImpl[Byte](ByteIsIntegral) + + implicit object ShortIsExactOrdering extends ExactOrderingImpl[Short](ShortIsIntegral) + + implicit object IntIsExactOrdering extends ExactOrderingImpl[Int](IntIsIntegral) + + implicit object LongIsExactOrdering extends ExactOrderingImpl[Long](LongIsIntegral) +} diff --git a/sc/jvm/src/test/scala/sigmastate/helpers/SigmaPPrintSpec.scala b/sc/jvm/src/test/scala/sigmastate/helpers/SigmaPPrintSpec.scala index e5247b839c..2b39d8d2af 100644 --- a/sc/jvm/src/test/scala/sigmastate/helpers/SigmaPPrintSpec.scala +++ b/sc/jvm/src/test/scala/sigmastate/helpers/SigmaPPrintSpec.scala @@ -2,7 +2,7 @@ package sigmastate.helpers import org.ergoplatform.settings.ErgoAlgos import org.ergoplatform.{ErgoBox, Outputs} -import sigma.core.RType +import sigma.core.{CollType, RType} import scorex.util.ModifierId import sigmastate.Values._ import sigmastate._ @@ -12,7 +12,6 @@ import sigmastate.lang.Terms.MethodCall import sigmastate.serialization.OpCodes import sigmastate.utils.Helpers import sigmastate.utxo.SelectField -import sigma.CollType import sigma.SigmaDslTesting import java.math.BigInteger diff --git a/sc/shared/src/test/scala/sigma/SigmaDslTesting.scala b/sc/shared/src/test/scala/sigma/SigmaDslTesting.scala index f268f77c1e..1da3968468 100644 --- a/sc/shared/src/test/scala/sigma/SigmaDslTesting.scala +++ b/sc/shared/src/test/scala/sigma/SigmaDslTesting.scala @@ -13,7 +13,7 @@ import org.scalatest.matchers.should.Matchers import org.scalatest.propspec.AnyPropSpec import org.scalatestplus.scalacheck.ScalaCheckPropertyChecks import scalan.Platform.threadSleepOrNoOp -import sigma.core.RType +import sigma.core.{CollType, RType} import sigma.core.RType._ import sigma.util.BenchmarkUtil import sigma.util.CollectionUtil._ @@ -35,9 +35,7 @@ import sigmastate.serialization.generators.ObjectGenerators import sigmastate.utils.Helpers._ import sigmastate.utxo.{DeserializeContext, DeserializeRegister, GetVar, OptionGet} import sigmastate.{SOption, SSigmaProp, SType, SigmaLeaf, eval} -import sigma.{Coll, CollType} -import java.util import scala.collection.mutable import scala.reflect.ClassTag import scala.util.{Failure, Success, Try} diff --git a/sc/shared/src/test/scala/sigmastate/helpers/SigmaPPrint.scala b/sc/shared/src/test/scala/sigmastate/helpers/SigmaPPrint.scala index 4ee22342d1..1193fc7db8 100644 --- a/sc/shared/src/test/scala/sigmastate/helpers/SigmaPPrint.scala +++ b/sc/shared/src/test/scala/sigmastate/helpers/SigmaPPrint.scala @@ -1,24 +1,24 @@ package sigmastate.helpers -import java.math.BigInteger import org.ergoplatform.ErgoBox import org.ergoplatform.ErgoBox.RegisterId import org.ergoplatform.settings.ErgoAlgos import pprint.{PPrinter, Tree} -import sigma.core.RType import sigma.core.RType.PrimitiveType +import sigma.core.{CollType, RType} +import sigma.{Coll, GroupElement} import sigmastate.SCollection._ import sigmastate.Values.{ConstantNode, ErgoTree, FuncValue, ValueCompanion} import sigmastate._ -import sigmastate.crypto.GF2_192_Poly import sigmastate.crypto.CryptoConstants.EcPointType +import sigmastate.crypto.GF2_192_Poly +import sigmastate.interpreter.{CompanionDesc, FixedCostItem, MethodDesc} import sigmastate.lang.Terms import sigmastate.lang.Terms.MethodCall import sigmastate.serialization.GroupElementSerializer import sigmastate.utxo.SelectField -import sigmastate.interpreter.{CompanionDesc, ErgoTreeEvaluator, FixedCostItem, MethodDesc} -import sigma.{Coll, CollType, GroupElement} +import java.math.BigInteger import scala.collection.compat.immutable.ArraySeq import scala.collection.mutable import scala.collection.mutable.ArrayBuffer diff --git a/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Value.scala b/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Value.scala index 720f2d5799..852bd867a8 100644 --- a/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Value.scala +++ b/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Value.scala @@ -1,7 +1,7 @@ package org.ergoplatform.sdk.js import org.ergoplatform.sdk.js.Value.toRuntimeData -import sigma.core.RType +import sigma.core.{CollType, RType} import sigma.core.RType.PairType import scorex.util.Extensions.{IntOps, LongOps} import scorex.util.encode.Base16 @@ -13,7 +13,7 @@ import sigmastate.fleetSdkCommon.distEsmTypesCommonMod import sigmastate.fleetSdkCommon.distEsmTypesRegistersMod.NonMandatoryRegisters import sigmastate.lang.DeserializationSigmaBuilder import sigmastate.serialization.{ConstantSerializer, DataSerializer, SigmaSerializer} -import sigma.{Coll, CollType} +import sigma.Coll import java.math.BigInteger import scala.scalajs.js diff --git a/sdk/shared/src/main/scala/org/ergoplatform/sdk/utils/Zero.scala b/sdk/shared/src/main/scala/org/ergoplatform/sdk/utils/Zero.scala index 4733e62710..fd3bb455d6 100644 --- a/sdk/shared/src/main/scala/org/ergoplatform/sdk/utils/Zero.scala +++ b/sdk/shared/src/main/scala/org/ergoplatform/sdk/utils/Zero.scala @@ -1,7 +1,7 @@ package org.ergoplatform.sdk.utils import org.ergoplatform.ErgoBox -import sigma.core.RType +import sigma.core.{CollType, RType} import sigma.core.RType._ import scorex.crypto.authds.avltree.batch.BatchAVLProver import scorex.crypto.hash.{Blake2b256, Digest32} From 87682bb7996f5dc481595618bf08d9c85d5540b9 Mon Sep 17 00:00:00 2001 From: Alexander Slesarenko Date: Thu, 24 Aug 2023 22:07:39 +0200 Subject: [PATCH 17/37] minimize-modules: RType descriptors moved to `sigma` package --- .../main/scala/sigma/CollsOverArrays.scala | 5 ++-- .../src/main/scala/sigma/core/RType.scala | 21 +++++----------- .../scala/sigma/{ => core}/TupleType.scala | 4 ++-- .../src/main/scala/sigma/core/package.scala | 3 ++- .../shared/src/main/scala/sigma/package.scala | 16 ++++++++++++- .../scala/sigmastate/crypto/Platform.scala | 2 +- .../scala/sigmastate/crypto/Platform.scala | 3 +-- .../scala/sigmastate/DataValueComparer.scala | 4 +--- .../src/main/scala/sigmastate/Values.scala | 2 +- .../scala/sigmastate/eval/Evaluation.scala | 4 ++-- .../main/scala/sigmastate/eval/package.scala | 2 +- .../serialization/DataSerializer.scala | 4 ++-- .../ConstantSerializerSpecification.scala | 4 ++-- .../DataSerializerSpecification.scala | 6 ++--- .../scalan/compilation/GraphVizExport.scala | 5 ++-- .../sigmastate/helpers/SigmaPPrintSpec.scala | 4 ++-- .../special/collections/BenchmarkGens.scala | 7 ------ .../src/main/scala/scalan/TypeDescs.scala | 14 +++++------ .../main/scala/scalan/primitives/Equal.scala | 6 +++-- .../scala/sigma/SigmaDslSpecification.scala | 4 ++-- .../sigmastate/helpers/SigmaPPrint.scala | 2 +- .../sigmastate/lang/SigmaCompilerTest.scala | 12 ++++++---- .../sigmastate/lang/SigmaTyperTest.scala | 2 +- .../utxo/BasicOpsSpecification.scala | 2 +- .../scala/special/wrappers/WRTypeTests.scala | 2 +- .../scala/org/ergoplatform/sdk/js/Type.scala | 8 +++---- .../scala/org/ergoplatform/sdk/js/Value.scala | 24 +++++++++---------- .../ergoplatform/sdk/ContractTemplate.scala | 7 +++--- .../ergoplatform/sdk/DataJsonEncoder.scala | 2 +- .../org/ergoplatform/sdk/JavaHelpers.scala | 12 +++++----- .../org/ergoplatform/sdk/OutBoxBuilder.scala | 2 +- .../org/ergoplatform/sdk/utils/Zero.scala | 2 +- .../sdk/DataJsonEncoderSpecification.scala | 19 ++++++++------- 33 files changed, 109 insertions(+), 107 deletions(-) rename common/shared/src/main/scala/sigma/{ => core}/TupleType.scala (94%) diff --git a/common/shared/src/main/scala/sigma/CollsOverArrays.scala b/common/shared/src/main/scala/sigma/CollsOverArrays.scala index cbc8bc7bdf..7d57c8a4fb 100644 --- a/common/shared/src/main/scala/sigma/CollsOverArrays.scala +++ b/common/shared/src/main/scala/sigma/CollsOverArrays.scala @@ -1,6 +1,5 @@ package sigma -import sigma.core._ import sigma.util.CollectionUtil import sigma.core.RType import debox.Buffer @@ -245,8 +244,8 @@ class PairOfCols[@specialized L, @specialized R](val ls: Coll[L], val rs: Coll[R }) override def hashCode() = ls.hashCode() * 41 + rs.hashCode() - @inline implicit def tL = ls.tItem - @inline implicit def tR = rs.tItem + @inline implicit def tL: RType[L] = ls.tItem + @inline implicit def tR: RType[R] = rs.tItem override lazy val tItem: RType[(L, R)] = { RType.pairRType(tL, tR) diff --git a/common/shared/src/main/scala/sigma/core/RType.scala b/common/shared/src/main/scala/sigma/core/RType.scala index 2fbdb43454..ead1968c09 100644 --- a/common/shared/src/main/scala/sigma/core/RType.scala +++ b/common/shared/src/main/scala/sigma/core/RType.scala @@ -30,12 +30,12 @@ object RType { @inline def asType[T](t: RType[_]): RType[T] = t.asInstanceOf[RType[T]] def fromClassTag[A](ctA: ClassTag[A]): RType[A] = (ctA match { - case ClassTag.Boolean => BooleanType - case ClassTag.Byte => ByteType - case ClassTag.Short => ShortType - case ClassTag.Int => IntType - case ClassTag.Long => LongType - case ClassTag.Unit => UnitType + case ClassTag.Boolean => sigma.BooleanType + case ClassTag.Byte => sigma.ByteType + case ClassTag.Short => sigma.ShortType + case ClassTag.Int => sigma.IntType + case ClassTag.Long => sigma.LongType + case ClassTag.Unit => sigma.UnitType case _ => GeneralType[A](ctA) }).asInstanceOf[RType[A]] @@ -62,15 +62,6 @@ object RType { override def name: String = classTag.toString() } - val AnyType : RType[Any] = GeneralType[Any] (ClassTag.Any) - - implicit val BooleanType : RType[Boolean] = PrimitiveType[Boolean] (ClassTag.Boolean, Array.emptyBooleanArray) - implicit val ByteType : RType[Byte] = PrimitiveType[Byte] (ClassTag.Byte, Array.emptyByteArray) - implicit val ShortType : RType[Short] = PrimitiveType[Short] (ClassTag.Short, Array.emptyShortArray) - implicit val IntType : RType[Int] = PrimitiveType[Int] (ClassTag.Int, Array.emptyIntArray) - implicit val LongType : RType[Long] = PrimitiveType[Long] (ClassTag.Long, Array.emptyLongArray) - implicit val UnitType : RType[Unit] = PrimitiveType[Unit] (ClassTag.Unit, Array[Unit]()(ClassTag.Unit)) - implicit case object StringType extends RType[String] { override def classTag: ClassTag[String] = ClassTag[String](classOf[String]) override def name: String = "String" diff --git a/common/shared/src/main/scala/sigma/TupleType.scala b/common/shared/src/main/scala/sigma/core/TupleType.scala similarity index 94% rename from common/shared/src/main/scala/sigma/TupleType.scala rename to common/shared/src/main/scala/sigma/core/TupleType.scala index abe91608cb..ad16ec59d5 100644 --- a/common/shared/src/main/scala/sigma/TupleType.scala +++ b/common/shared/src/main/scala/sigma/core/TupleType.scala @@ -1,6 +1,6 @@ -package sigma +package sigma.core -import sigma.core.RType +import sigma.TupleData import sigma.core.RType.SomeType import sigma.util.CollectionUtil diff --git a/common/shared/src/main/scala/sigma/core/package.scala b/common/shared/src/main/scala/sigma/core/package.scala index e1b214c2b6..81091f0387 100644 --- a/common/shared/src/main/scala/sigma/core/package.scala +++ b/common/shared/src/main/scala/sigma/core/package.scala @@ -1,5 +1,6 @@ package sigma +import scala.annotation.nowarn import scala.reflect.classTag /** Contains cores definitions which serves as a basis for [[sigma]] package implementations. */ @@ -7,7 +8,7 @@ package object core { /** Shadow the implicit from sigma package so it doesn't interfere with the resolution * of ClassTags below. */ - private def rtypeToClassTag = ??? + @nowarn private def rtypeToClassTag = ??? val BigIntClassTag = classTag[BigInt] val GroupElementClassTag = classTag[GroupElement] diff --git a/common/shared/src/main/scala/sigma/package.scala b/common/shared/src/main/scala/sigma/package.scala index b0c8ce9022..0c0bab03c1 100644 --- a/common/shared/src/main/scala/sigma/package.scala +++ b/common/shared/src/main/scala/sigma/package.scala @@ -1,6 +1,6 @@ import sigma.core._ -import sigma.core.RType.{GeneralType, SomeType} +import sigma.core.RType.{GeneralType, PrimitiveType, SomeType} import scala.reflect.ClassTag @@ -11,6 +11,20 @@ package object sigma { /** Forces reflection data initialization */ val coreLibReflection = CoreLibReflection + val AnyType: RType[Any] = GeneralType[Any](ClassTag.Any) + + implicit val BooleanType: RType[Boolean] = PrimitiveType[Boolean](ClassTag.Boolean, Array.emptyBooleanArray) + + implicit val ByteType : RType[Byte] = PrimitiveType[Byte](ClassTag.Byte, Array.emptyByteArray) + + implicit val ShortType : RType[Short] = PrimitiveType[Short](ClassTag.Short, Array.emptyShortArray) + + implicit val IntType : RType[Int] = PrimitiveType[Int](ClassTag.Int, Array.emptyIntArray) + + implicit val LongType : RType[Long] = PrimitiveType[Long](ClassTag.Long, Array.emptyLongArray) + + implicit val UnitType : RType[Unit] = PrimitiveType[Unit](ClassTag.Unit, Array[Unit]()(ClassTag.Unit)) + implicit val BigIntRType: RType[BigInt] = GeneralType(BigIntClassTag) implicit val GroupElementRType: RType[GroupElement] = GeneralType(GroupElementClassTag) implicit val SigmaPropRType: RType[SigmaProp] = GeneralType(SigmaPropClassTag) diff --git a/interpreter/js/src/main/scala/sigmastate/crypto/Platform.scala b/interpreter/js/src/main/scala/sigmastate/crypto/Platform.scala index 538b14348b..3786e233ea 100644 --- a/interpreter/js/src/main/scala/sigmastate/crypto/Platform.scala +++ b/interpreter/js/src/main/scala/sigmastate/crypto/Platform.scala @@ -244,7 +244,7 @@ object Platform { */ def isCorrectType[T <: SType](value: Any, tpe: T): Boolean = value match { case c: Coll[_] => tpe match { - case STuple(items) => c.tItem == RType.AnyType && c.length == items.length + case STuple(items) => c.tItem == sigma.AnyType && c.length == items.length case tpeColl: SCollection[_] => true case _ => sys.error(s"Collection value $c has unexpected type $tpe") } diff --git a/interpreter/jvm/src/main/scala/sigmastate/crypto/Platform.scala b/interpreter/jvm/src/main/scala/sigmastate/crypto/Platform.scala index 1c6d822f3a..1c5c63b197 100644 --- a/interpreter/jvm/src/main/scala/sigmastate/crypto/Platform.scala +++ b/interpreter/jvm/src/main/scala/sigmastate/crypto/Platform.scala @@ -5,7 +5,6 @@ import org.bouncycastle.crypto.ec.CustomNamedCurves import org.bouncycastle.crypto.generators.PKCS5S2ParametersGenerator import org.bouncycastle.crypto.params.KeyParameter import org.bouncycastle.math.ec.{ECCurve, ECFieldElement, ECPoint} -import sigma.core.RType import java.math.BigInteger import sigmastate._ @@ -174,7 +173,7 @@ object Platform { */ def isCorrectType[T <: SType](value: Any, tpe: T): Boolean = value match { case c: Coll[_] => tpe match { - case STuple(items) => c.tItem == RType.AnyType && c.length == items.length + case STuple(items) => c.tItem == sigma.AnyType && c.length == items.length case _: SCollection[_] => true case _ => sys.error(s"Collection value $c has unexpected type $tpe") } diff --git a/interpreter/shared/src/main/scala/sigmastate/DataValueComparer.scala b/interpreter/shared/src/main/scala/sigmastate/DataValueComparer.scala index 194e545310..f625ccd23c 100644 --- a/interpreter/shared/src/main/scala/sigmastate/DataValueComparer.scala +++ b/interpreter/shared/src/main/scala/sigmastate/DataValueComparer.scala @@ -2,15 +2,13 @@ package sigmastate import sigma.core.{AVHashMap, Nullable, RType} import debox.{cfor, sp} -import sigma.core.RType._ import sigmastate.Values.SigmaBoolean import sigmastate.crypto.DLogProtocol.ProveDlog import sigmastate.crypto.ProveDHTuple import sigmastate.eval.SigmaDsl import sigmastate.crypto.CryptoConstants.EcPointType import sigmastate.interpreter.{ErgoTreeEvaluator, NamedDesc, OperationCostInfo} -import sigma.{AvlTree, AvlTreeRType, BigInt, BigIntRType, Box, BoxRType, GroupElement, GroupElementRType, Header, HeaderRType, PreHeader, PreHeaderRType, SigmaProp} -import sigma.{Coll, CollOverArray, PairOfCols} +import sigma._ /** Implementation of data equality for two arbitrary ErgoTree data types. * @see [[DataValueComparer.equalDataValues]] diff --git a/interpreter/shared/src/main/scala/sigmastate/Values.scala b/interpreter/shared/src/main/scala/sigmastate/Values.scala index 366581d5e5..bc15b54df0 100644 --- a/interpreter/shared/src/main/scala/sigmastate/Values.scala +++ b/interpreter/shared/src/main/scala/sigmastate/Values.scala @@ -848,7 +848,7 @@ object Values { override lazy val value = { val xs = items.cast[EvaluatedValue[SAny.type]].map(_.value) - Colls.fromArray(xs.toArray(SAny.classTag.asInstanceOf[ClassTag[SAny.WrappedType]]))(RType.AnyType) + Colls.fromArray(xs.toArray(SAny.classTag.asInstanceOf[ClassTag[SAny.WrappedType]]))(sigma.AnyType) } protected final override def eval(env: DataEnv)(implicit E: ErgoTreeEvaluator): Any = { diff --git a/interpreter/shared/src/main/scala/sigmastate/eval/Evaluation.scala b/interpreter/shared/src/main/scala/sigmastate/eval/Evaluation.scala index daf520a0f1..0dd9f9cf0b 100644 --- a/interpreter/shared/src/main/scala/sigmastate/eval/Evaluation.scala +++ b/interpreter/shared/src/main/scala/sigmastate/eval/Evaluation.scala @@ -1,7 +1,7 @@ package sigmastate.eval import org.ergoplatform._ -import sigma.core.{CollType, RType} +import sigma.core.{CollType, RType, TupleType} import sigma.core.RType._ import sigmastate.SType._ import sigmastate.Values.SigmaBoolean @@ -156,7 +156,7 @@ object Evaluation { /** Convert SigmaDsl representation of tuple to ErgoTree serializable representation. */ def fromDslTuple(value: Any, tupleTpe: STuple): Coll[Any] = value match { case t: Tuple2[_,_] => TupleColl(t._1, t._2) - case a: Coll[Any]@unchecked if a.tItem == RType.AnyType => a + case a: Coll[Any]@unchecked if a.tItem == sigma.AnyType => a case _ => sys.error(s"Cannot execute fromDslTuple($value, $tupleTpe)") } diff --git a/interpreter/shared/src/main/scala/sigmastate/eval/package.scala b/interpreter/shared/src/main/scala/sigmastate/eval/package.scala index cee9117304..21a8240cf4 100644 --- a/interpreter/shared/src/main/scala/sigmastate/eval/package.scala +++ b/interpreter/shared/src/main/scala/sigmastate/eval/package.scala @@ -31,7 +31,7 @@ package object eval { * Such long tuples are represented as Coll[Any]. * This representaion of tuples is different from representation of pairs (x, y), * where Tuple2 type is used instead of Coll. */ - def TupleColl(items: Any*): Coll[Any] = Colls.fromItems(items:_*)(RType.AnyType) + def TupleColl(items: Any*): Coll[Any] = Colls.fromItems(items:_*)(sigma.AnyType) trait BaseDigestColl extends TaggedType[Coll[Byte]] diff --git a/interpreter/shared/src/main/scala/sigmastate/serialization/DataSerializer.scala b/interpreter/shared/src/main/scala/sigmastate/serialization/DataSerializer.scala index b6e6c2ea57..30660093ea 100644 --- a/interpreter/shared/src/main/scala/sigmastate/serialization/DataSerializer.scala +++ b/interpreter/shared/src/main/scala/sigmastate/serialization/DataSerializer.scala @@ -126,7 +126,7 @@ object DataSerializer { val arr = tuple.items.map { t => deserialize(t, r) }.toArray[Any] - val coll = Colls.fromArray(arr)(RType.AnyType) + val coll = Colls.fromArray(arr)(sigma.AnyType) Evaluation.toDslTuple(coll, tuple) case t => CheckSerializableTypeCode(t.typeCode) @@ -147,7 +147,7 @@ object DataSerializer { case tTup: STuple if tTup.items.length == 2 => Evaluation.stypeToRType(tpeElem) case _: STuple => - collRType(RType.AnyType) + collRType(sigma.AnyType) case _ => Evaluation.stypeToRType(tpeElem) }).asInstanceOf[RType[T#WrappedType]] diff --git a/interpreter/shared/src/test/scala/sigmastate/serialization/ConstantSerializerSpecification.scala b/interpreter/shared/src/test/scala/sigmastate/serialization/ConstantSerializerSpecification.scala index 573c6ea261..92813e44cf 100644 --- a/interpreter/shared/src/test/scala/sigmastate/serialization/ConstantSerializerSpecification.scala +++ b/interpreter/shared/src/test/scala/sigmastate/serialization/ConstantSerializerSpecification.scala @@ -27,7 +27,7 @@ class ConstantSerializerSpecification extends TableSerializationSpecification { implicit val tT = Evaluation.stypeToRType(tpe) implicit val tag = tT.classTag forAll { xs: Array[T#WrappedType] => - implicit val tAny = RType.AnyType + implicit val tAny = sigma.AnyType roundTripTest(Constant[SCollection[T]](xs.toColl, SCollection(tpe))) roundTripTest(Constant[SType](xs.toColl.map(x => (x, x)).asWrappedType, SCollection(STuple(tpe, tpe)))) // pairs are special case val triples = xs.toColl.map(x => TupleColl(x, x, x)).asWrappedType @@ -49,7 +49,7 @@ class ConstantSerializerSpecification extends TableSerializationSpecification { implicit val wWrapped = wrappedTypeGen(tpe) implicit val tT = Evaluation.stypeToRType(tpe) @nowarn implicit val tag = tT.classTag - implicit val tAny: RType[Any] = RType.AnyType + implicit val tAny: RType[Any] = sigma.AnyType forAll { in: (T#WrappedType, T#WrappedType) => val (x,y) = (in._1, in._2) roundTripTest(Constant[SType]((x, y).asWrappedType, STuple(tpe, tpe))) diff --git a/interpreter/shared/src/test/scala/sigmastate/serialization/DataSerializerSpecification.scala b/interpreter/shared/src/test/scala/sigmastate/serialization/DataSerializerSpecification.scala index d10b9396ff..1dee51c26f 100644 --- a/interpreter/shared/src/test/scala/sigmastate/serialization/DataSerializerSpecification.scala +++ b/interpreter/shared/src/test/scala/sigmastate/serialization/DataSerializerSpecification.scala @@ -51,7 +51,7 @@ class DataSerializerSpecification extends SerializationSpecification { implicit val wWrapped = wrappedTypeGen(tpe) implicit val tT = Evaluation.stypeToRType(tpe) implicit val tagT = tT.classTag - implicit val tAny = RType.AnyType + implicit val tAny = sigma.AnyType forAll { xs: Array[T#WrappedType] => roundtrip[SCollection[T]](xs.toColl, SCollection(tpe)) roundtrip[SType](xs.toColl.map(x => (x, x)).asWrappedType, SCollection(STuple(tpe, tpe))) @@ -78,7 +78,7 @@ class DataSerializerSpecification extends SerializationSpecification { def testTuples[T <: SType](tpe: T) = { implicit val wWrapped = wrappedTypeGen(tpe) @nowarn implicit val tag = tpe.classTag[T#WrappedType] - implicit val tAny: RType[Any] = RType.AnyType + implicit val tAny: RType[Any] = sigma.AnyType forAll { in: (T#WrappedType, T#WrappedType) => val (x,y) = (in._1, in._2) roundtrip[SType]((x, y).asWrappedType, STuple(tpe, tpe)) @@ -107,7 +107,7 @@ class DataSerializerSpecification extends SerializationSpecification { property("Should check limits and fail") { val len = 0xFFFF + 1 - val tup = SigmaDsl.Colls.replicate(len, 1.asInstanceOf[Any])(RType.AnyType) + val tup = SigmaDsl.Colls.replicate(len, 1.asInstanceOf[Any])(sigma.AnyType) assertExceptionThrown({ val w = SigmaSerializer.startWriter() DataSerializer.serialize(tup.asWrappedType, STuple(Array.fill(len)(SInt)), w) diff --git a/sc/jvm/src/test/scala/scalan/compilation/GraphVizExport.scala b/sc/jvm/src/test/scala/scalan/compilation/GraphVizExport.scala index 06cbdd64a5..8568e6c1db 100644 --- a/sc/jvm/src/test/scala/scalan/compilation/GraphVizExport.scala +++ b/sc/jvm/src/test/scala/scalan/compilation/GraphVizExport.scala @@ -6,6 +6,7 @@ import scalan.Scalan import scalan.core.ScalaNameUtil import sigma.util.{FileUtil, ProcessUtil, StringUtil} +import scala.annotation.unused import scala.collection.immutable.StringOps // TODO implement this outside of the cake @@ -21,7 +22,7 @@ class GraphVizExport[Ctx <: Scalan](val scalan: Ctx) { // TODO it would be better to have nodeColor(elem: Elem[_], optDef: Option[Def[_]]) to // avoid looking up definition, but this leads to ClassFormatError (likely Scala bug) - protected def nodeColor(td: TypeDesc, d: Def[_])(implicit config: GraphVizConfig): String = d match { + protected def nodeColor(td: TypeDesc, d: Def[_])(implicit @unused config: GraphVizConfig): String = d match { case _ => nodeColor(td) } @@ -137,7 +138,7 @@ class GraphVizExport[Ctx <: Scalan](val scalan: Ctx) { case _ => x.toString } - private def emitDepEdges(sym: Sym, rhs: Def[_])(implicit stream: PrintWriter, config: GraphVizConfig) = { + private def emitDepEdges(sym: Sym, rhs: Def[_])(implicit stream: PrintWriter, @unused config: GraphVizConfig) = { val (deps, lambdaVars) = rhs match { case l: Lambda[_, _] => lambdaDeps(l) case _ => (rhs.deps.toList, Nil) diff --git a/sc/jvm/src/test/scala/sigmastate/helpers/SigmaPPrintSpec.scala b/sc/jvm/src/test/scala/sigmastate/helpers/SigmaPPrintSpec.scala index 2b39d8d2af..38feb207b6 100644 --- a/sc/jvm/src/test/scala/sigmastate/helpers/SigmaPPrintSpec.scala +++ b/sc/jvm/src/test/scala/sigmastate/helpers/SigmaPPrintSpec.scala @@ -42,8 +42,8 @@ class SigmaPPrintSpec extends SigmaDslTesting { test(SCollectionType(SBoolean), "SBooleanArray") test(STuple(Vector(SBoolean, SInt)), "SPair(SBoolean, SInt)") - test(RType.BooleanType, "RType.BooleanType") - test(CollType(RType.ByteType), "CollType(RType.ByteType)") + test(sigma.BooleanType, "RType.BooleanType") + test(CollType(sigma.ByteType), "CollType(RType.ByteType)") // exception handlers test(new ArithmeticException("msg"), "new ArithmeticException(\"msg\")") diff --git a/sc/jvm/src/test/scala/special/collections/BenchmarkGens.scala b/sc/jvm/src/test/scala/special/collections/BenchmarkGens.scala index 74684194be..3819772202 100644 --- a/sc/jvm/src/test/scala/special/collections/BenchmarkGens.scala +++ b/sc/jvm/src/test/scala/special/collections/BenchmarkGens.scala @@ -14,11 +14,4 @@ trait BenchmarkGens extends CollGens { suite: Bench[Double] => val arrays = ranges.map { case (r, i) => (r.toArray, i) } val colls = arrays.map { case (arr, i) => (builder.fromArray(arr), i) } - - private val config = Seq[KeyValue]( - exec.minWarmupRuns -> 5, - exec.maxWarmupRuns -> 10, - exec.benchRuns -> 30, - exec.requireGC -> true - ) } diff --git a/sc/shared/src/main/scala/scalan/TypeDescs.scala b/sc/shared/src/main/scala/scalan/TypeDescs.scala index a84533c445..6449861d11 100644 --- a/sc/shared/src/main/scala/scalan/TypeDescs.scala +++ b/sc/shared/src/main/scala/scalan/TypeDescs.scala @@ -361,17 +361,17 @@ abstract class TypeDescs extends Base { self: Scalan => } /** Type descriptor for `Any`, cannot be used implicitly. */ - val AnyElement: Elem[Any] = new BaseElemLiftable[Any](null, AnyType) + val AnyElement: Elem[Any] = new BaseElemLiftable[Any](null, sigma.AnyType) /** Predefined Lazy value saved here to be used in hotspot code. */ val LazyAnyElement = Lazy(AnyElement) - implicit val BooleanElement: Elem[Boolean] = new BaseElemLiftable(false, BooleanType) - implicit val ByteElement: Elem[Byte] = new BaseElemLiftable(0.toByte, ByteType) - implicit val ShortElement: Elem[Short] = new BaseElemLiftable(0.toShort, ShortType) - implicit val IntElement: Elem[Int] = new BaseElemLiftable(0, IntType) - implicit val LongElement: Elem[Long] = new BaseElemLiftable(0L, LongType) - implicit val UnitElement: Elem[Unit] = new BaseElemLiftable((), UnitType) + implicit val BooleanElement: Elem[Boolean] = new BaseElemLiftable(false, sigma.BooleanType) + implicit val ByteElement: Elem[Byte] = new BaseElemLiftable(0.toByte, sigma.ByteType) + implicit val ShortElement: Elem[Short] = new BaseElemLiftable(0.toShort, sigma.ShortType) + implicit val IntElement: Elem[Int] = new BaseElemLiftable(0, sigma.IntType) + implicit val LongElement: Elem[Long] = new BaseElemLiftable(0L, sigma.LongType) + implicit val UnitElement: Elem[Unit] = new BaseElemLiftable((), sigma.UnitType) implicit val StringElement: Elem[String] = new BaseElemLiftable("", StringType) /** Implicitly defines element type for pairs. */ diff --git a/sc/shared/src/main/scala/scalan/primitives/Equal.scala b/sc/shared/src/main/scala/scalan/primitives/Equal.scala index e2a35acf15..4d64e94383 100644 --- a/sc/shared/src/main/scala/scalan/primitives/Equal.scala +++ b/sc/shared/src/main/scala/scalan/primitives/Equal.scala @@ -2,6 +2,8 @@ package scalan.primitives import scalan.{Base, Scalan} +import scala.annotation.unused + trait Equal extends Base { self: Scalan => /** Binary operation representing structural equality between arguments. */ case class Equals[A: Elem]() extends BinOp[A, Boolean]("==") { @@ -13,11 +15,11 @@ trait Equal extends Base { self: Scalan => override def applySeq(x: A, y: A): Boolean = !equalValues[A](x, y) } - protected def equalValues[A](x: Any, y: Any)(implicit eA: Elem[A]) = x == y + protected def equalValues[A](x: Any, y: Any)(implicit @unused eA: Elem[A]) = x == y /** Extension methods to construct ApplyBinOp nodes */ implicit class EqualOps[A](x: Ref[A]) { - implicit private val eA = x.elem + implicit private val eA: Elem[A] = x.elem /** Apply Equals binary operation and return Ref to ApplyBinOp node. */ def ===(y: Ref[A]): Ref[Boolean] = Equals[A].apply(x, y) diff --git a/sc/shared/src/test/scala/sigma/SigmaDslSpecification.scala b/sc/shared/src/test/scala/sigma/SigmaDslSpecification.scala index 343ad5396b..6a90429e20 100644 --- a/sc/shared/src/test/scala/sigma/SigmaDslSpecification.scala +++ b/sc/shared/src/test/scala/sigma/SigmaDslSpecification.scala @@ -9716,10 +9716,10 @@ class SigmaDslSpecification extends SigmaDslTesting }, changedFeature( { (x: (Coll[Byte], Int)) => - SigmaDsl.substConstants(x._1, Coll[Int](x._2), Coll[Any](SigmaDsl.sigmaProp(false))(RType.AnyType)) + SigmaDsl.substConstants(x._1, Coll[Int](x._2), Coll[Any](SigmaDsl.sigmaProp(false))(sigma.AnyType)) }, { (x: (Coll[Byte], Int)) => - SigmaDsl.substConstants(x._1, Coll[Int](x._2), Coll[Any](SigmaDsl.sigmaProp(false))(RType.AnyType)) + SigmaDsl.substConstants(x._1, Coll[Int](x._2), Coll[Any](SigmaDsl.sigmaProp(false))(sigma.AnyType)) }, "{ (x: (Coll[Byte], Int)) => substConstants[Any](x._1, Coll[Int](x._2), Coll[Any](sigmaProp(false))) }", FuncValue( diff --git a/sc/shared/src/test/scala/sigmastate/helpers/SigmaPPrint.scala b/sc/shared/src/test/scala/sigmastate/helpers/SigmaPPrint.scala index 1193fc7db8..a9f7997d63 100644 --- a/sc/shared/src/test/scala/sigmastate/helpers/SigmaPPrint.scala +++ b/sc/shared/src/test/scala/sigmastate/helpers/SigmaPPrint.scala @@ -146,7 +146,7 @@ object SigmaPPrint extends PPrinter { case Some(v) => Tree.Apply("Some", treeifyMany(v)) - case coll: Coll[Byte @unchecked] if coll.tItem == RType.ByteType => + case coll: Coll[Byte @unchecked] if coll.tItem == sigma.ByteType => val hexString = ErgoAlgos.encode(coll) Tree.Apply("Helpers.decodeBytes", treeifyMany(hexString)) diff --git a/sc/shared/src/test/scala/sigmastate/lang/SigmaCompilerTest.scala b/sc/shared/src/test/scala/sigmastate/lang/SigmaCompilerTest.scala index f6266cf285..129f096d85 100644 --- a/sc/shared/src/test/scala/sigmastate/lang/SigmaCompilerTest.scala +++ b/sc/shared/src/test/scala/sigmastate/lang/SigmaCompilerTest.scala @@ -5,13 +5,15 @@ import org.ergoplatform._ import scorex.util.encode.Base58 import sigmastate.Values._ import sigmastate._ +import sigmastate.exceptions.{GraphBuildingException, InvalidArguments, TyperException} import sigmastate.helpers.CompilerTestingCommons import sigmastate.interpreter.Interpreter.ScriptEnv -import sigmastate.lang.Terms.{Apply, Ident, Lambda, MethodCall, ZKProofBlock} -import sigmastate.exceptions.{GraphBuildingException, InvalidArguments, TyperException} +import sigmastate.lang.Terms.{Apply, MethodCall, ZKProofBlock} import sigmastate.serialization.ValueSerializer import sigmastate.serialization.generators.ObjectGenerators -import sigmastate.utxo.{ByIndex, ExtractAmount, GetVar, SelectField} +import sigmastate.utxo.{ByIndex, ExtractAmount, GetVar} + +import scala.annotation.unused class SigmaCompilerTest extends CompilerTestingCommons with LangTests with ObjectGenerators { import CheckingSigmaBuilder._ @@ -22,11 +24,11 @@ class SigmaCompilerTest extends CompilerTestingCommons with LangTests with Objec private def comp(env: ScriptEnv, x: String): Value[SType] = compile(env, x) private def comp(x: String): Value[SType] = compile(env, x) - private def testMissingCosting(script: String, expected: SValue): Unit = { + private def testMissingCosting(script: String, @unused expected: SValue): Unit = { an [GraphBuildingException] should be thrownBy comp(env, script) } - private def testMissingCostingWOSerialization(script: String, expected: SValue): Unit = { + private def testMissingCostingWOSerialization(script: String, @unused expected: SValue): Unit = { an [GraphBuildingException] should be thrownBy comp(env, script) } diff --git a/sc/shared/src/test/scala/sigmastate/lang/SigmaTyperTest.scala b/sc/shared/src/test/scala/sigmastate/lang/SigmaTyperTest.scala index 35c21b5c82..5a1b93fdf5 100644 --- a/sc/shared/src/test/scala/sigmastate/lang/SigmaTyperTest.scala +++ b/sc/shared/src/test/scala/sigmastate/lang/SigmaTyperTest.scala @@ -59,7 +59,7 @@ class SigmaTyperTest extends AnyPropSpec sourceContext.line shouldBe expectedLine sourceContext.column shouldBe expectedCol true - case pe: ParserException => true + case _: ParserException => true case t => throw t }) } diff --git a/sc/shared/src/test/scala/sigmastate/utxo/BasicOpsSpecification.scala b/sc/shared/src/test/scala/sigmastate/utxo/BasicOpsSpecification.scala index 2d8d62380e..004564cf9f 100644 --- a/sc/shared/src/test/scala/sigmastate/utxo/BasicOpsSpecification.scala +++ b/sc/shared/src/test/scala/sigmastate/utxo/BasicOpsSpecification.scala @@ -338,7 +338,7 @@ class BasicOpsSpecification extends CompilerTestingCommons val dataVar = (lastExtVar + 1).toByte val Colls = IR.sigmaDslBuilderValue.Colls - implicit val eAny = RType.AnyType + implicit val eAny = sigma.AnyType val data = Colls.fromItems((Array[Byte](1,2,3).toColl, 10L)) val env1 = env + ("dataVar" -> CAnyValue(dataVar)) val dataType = SCollection(STuple(SByteArray, SLong)) diff --git a/sc/shared/src/test/scala/special/wrappers/WRTypeTests.scala b/sc/shared/src/test/scala/special/wrappers/WRTypeTests.scala index 400a4355f6..86fe106075 100644 --- a/sc/shared/src/test/scala/special/wrappers/WRTypeTests.scala +++ b/sc/shared/src/test/scala/special/wrappers/WRTypeTests.scala @@ -19,7 +19,7 @@ class WRTypeTests extends WrappersTests { } test("Implicit conversion from RType to Elem") { - val eInt: Elem[Int] = RType.IntType + val eInt: Elem[Int] = sigma.IntType eInt shouldBe IntElement val ePair: Elem[(Int, Coll[Byte])] = RType[(Int, SColl[Byte])] diff --git a/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Type.scala b/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Type.scala index 846407737b..5c79513f9c 100644 --- a/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Type.scala +++ b/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Type.scala @@ -20,16 +20,16 @@ class Type(private[js] final val rtype: RType[_]) extends js.Object { @JSExportTopLevel("TypeObj") object Type extends js.Object { /** Descriptor of ErgoScript type Byte. */ - val Byte = new Type(RType.ByteType) + val Byte = new Type(sigma.ByteType) /** Descriptor of ErgoScript type Short. */ - val Short = new Type(RType.ShortType) + val Short = new Type(sigma.ShortType) /** Descriptor of ErgoScript type Int. */ - val Int = new Type(RType.IntType) + val Int = new Type(sigma.IntType) /** Descriptor of ErgoScript type Long. */ - val Long = new Type(RType.LongType) + val Long = new Type(sigma.LongType) /** Descriptor of ErgoScript type BigInt. */ val BigInt = new Type(sigma.BigIntRType) diff --git a/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Value.scala b/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Value.scala index 852bd867a8..ff739a7f43 100644 --- a/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Value.scala +++ b/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Value.scala @@ -82,9 +82,9 @@ object Value extends js.Object { * in register and [[sigmastate.Values.Constant]] nodes. */ final private[js] def toRuntimeData(data: Any, rtype: RType[_]): Any = rtype match { - case RType.BooleanType => data - case RType.ByteType | RType.ShortType | RType.IntType => data - case RType.LongType => java.lang.Long.parseLong(data.asInstanceOf[js.BigInt].toString(10)) + case sigma.BooleanType => data + case sigma.ByteType | sigma.ShortType | sigma.IntType => data + case sigma.LongType => java.lang.Long.parseLong(data.asInstanceOf[js.BigInt].toString(10)) case sigma.BigIntRType => val v = data.asInstanceOf[js.BigInt] SigmaDsl.BigInt(new BigInteger(v.toString(16), 16)) @@ -110,7 +110,7 @@ object Value extends js.Object { val x = toRuntimeData(p(0), pt.tFst).asInstanceOf[a] val y = toRuntimeData(p(1), pt.tSnd).asInstanceOf[b] (x, y) - case RType.UnitType => data + case sigma.UnitType => data case _ => throw new IllegalArgumentException(s"Unsupported type $rtype") } @@ -122,9 +122,9 @@ object Value extends js.Object { * @param rtype type descriptor of Sigma runtime value */ final private[js] def fromRuntimeData(value: Any, rtype: RType[_]): Any = rtype match { - case RType.BooleanType => value - case RType.ByteType | RType.ShortType | RType.IntType => value - case RType.LongType => js.BigInt(value.asInstanceOf[Long].toString) + case sigma.BooleanType => value + case sigma.ByteType | sigma.ShortType | sigma.IntType => value + case sigma.LongType => js.BigInt(value.asInstanceOf[Long].toString) case sigma.BigIntRType => val hex = SigmaDsl.toBigInteger(value.asInstanceOf[sigma.BigInt]).toString(10) js.BigInt(hex) @@ -143,7 +143,7 @@ object Value extends js.Object { case pt: PairType[a, b] => val p = value.asInstanceOf[(a, b)] js.Array(fromRuntimeData(p._1, pt.tFst), fromRuntimeData(p._2, pt.tSnd)) - case RType.UnitType => value + case sigma.UnitType => value case _ => throw new IllegalArgumentException(s"Unsupported type $rtype") } @@ -154,10 +154,10 @@ object Value extends js.Object { * @param rtype type descriptor of Sigma runtime value */ final private def checkJsData[T](data: T, rtype: RType[_]): Any = rtype match { - case RType.ByteType => data.asInstanceOf[Int].toByteExact - case RType.ShortType => data.asInstanceOf[Int].toShortExact - case RType.IntType => data.asInstanceOf[Int].toLong.toIntExact - case RType.LongType => + case sigma.ByteType => data.asInstanceOf[Int].toByteExact + case sigma.ShortType => data.asInstanceOf[Int].toShortExact + case sigma.IntType => data.asInstanceOf[Int].toLong.toIntExact + case sigma.LongType => val n = data.asInstanceOf[js.BigInt] if (n < MinLong || n > MaxLong) throw new ArithmeticException(s"value $n is out of long range") diff --git a/sdk/shared/src/main/scala/org/ergoplatform/sdk/ContractTemplate.scala b/sdk/shared/src/main/scala/org/ergoplatform/sdk/ContractTemplate.scala index 4320555628..f763824400 100644 --- a/sdk/shared/src/main/scala/org/ergoplatform/sdk/ContractTemplate.scala +++ b/sdk/shared/src/main/scala/org/ergoplatform/sdk/ContractTemplate.scala @@ -1,19 +1,18 @@ package org.ergoplatform.sdk -import cats.syntax.either._ import debox.cfor import io.circe._ -import io.circe.syntax.{EncoderOps, _} +import io.circe.syntax.EncoderOps import org.ergoplatform.sdk.utils.SerializationUtils.{parseString, serializeString} import org.ergoplatform.sdk.utils.Zero +import sigma.util.safeNewArray import sigmastate.Values.ErgoTree.headerWithVersion import sigmastate.Values.{ErgoTree, _} import sigmastate._ -import sigmastate.eval.{Colls, _} +import sigmastate.eval._ import sigmastate.exceptions.SerializerException import sigmastate.lang.{DeserializationSigmaBuilder, StdSigmaBuilder} import sigmastate.serialization._ -import sigma.util.safeNewArray import sigmastate.utils.{SigmaByteReader, SigmaByteWriter} import java.util.Objects diff --git a/sdk/shared/src/main/scala/org/ergoplatform/sdk/DataJsonEncoder.scala b/sdk/shared/src/main/scala/org/ergoplatform/sdk/DataJsonEncoder.scala index 71e460cd42..06ffa951db 100644 --- a/sdk/shared/src/main/scala/org/ergoplatform/sdk/DataJsonEncoder.scala +++ b/sdk/shared/src/main/scala/org/ergoplatform/sdk/DataJsonEncoder.scala @@ -190,7 +190,7 @@ object DataJsonEncoder { cfor(1)(_ <= tArr.length, _ + 1) { i => collSource += decodeData(json.hcursor.downField(s"_${i}").focus.get, tArr(i - 1)) } - val coll = Colls.fromArray(collSource.result())(RType.AnyType) + val coll = Colls.fromArray(collSource.result())(sigma.AnyType) Evaluation.toDslTuple(coll, t) case SGroupElement => val str = decodeBytes(json) diff --git a/sdk/shared/src/main/scala/org/ergoplatform/sdk/JavaHelpers.scala b/sdk/shared/src/main/scala/org/ergoplatform/sdk/JavaHelpers.scala index 769455e252..0d4db24003 100644 --- a/sdk/shared/src/main/scala/org/ergoplatform/sdk/JavaHelpers.scala +++ b/sdk/shared/src/main/scala/org/ergoplatform/sdk/JavaHelpers.scala @@ -242,12 +242,12 @@ object JavaHelpers { def toErgoTree: ErgoTree = decodeStringToErgoTree(base16) } - implicit val TokenIdRType: RType[TokenId] = collRType(RType.ByteType).asInstanceOf[RType[TokenId]] - implicit val JByteRType: RType[JByte] = RType.ByteType.asInstanceOf[RType[JByte]] - implicit val JShortRType: RType[JShort] = RType.ShortType.asInstanceOf[RType[JShort]] - implicit val JIntRType: RType[JInt] = RType.IntType.asInstanceOf[RType[JInt]] - implicit val JLongRType: RType[JLong] = RType.LongType.asInstanceOf[RType[JLong]] - implicit val JBooleanRType: RType[JBoolean] = RType.BooleanType.asInstanceOf[RType[JBoolean]] + implicit val TokenIdRType: RType[TokenId] = collRType(sigma.ByteType).asInstanceOf[RType[TokenId]] + implicit val JByteRType: RType[JByte] = sigma.ByteType.asInstanceOf[RType[JByte]] + implicit val JShortRType: RType[JShort] = sigma.ShortType.asInstanceOf[RType[JShort]] + implicit val JIntRType: RType[JInt] = sigma.IntType.asInstanceOf[RType[JInt]] + implicit val JLongRType: RType[JLong] = sigma.LongType.asInstanceOf[RType[JLong]] + implicit val JBooleanRType: RType[JBoolean] = sigma.BooleanType.asInstanceOf[RType[JBoolean]] val HeaderRType: RType[Header] = sigma.HeaderRType val PreHeaderRType: RType[sigma.PreHeader] = sigma.PreHeaderRType diff --git a/sdk/shared/src/main/scala/org/ergoplatform/sdk/OutBoxBuilder.scala b/sdk/shared/src/main/scala/org/ergoplatform/sdk/OutBoxBuilder.scala index 0a5bd8c1d0..142ad31c06 100644 --- a/sdk/shared/src/main/scala/org/ergoplatform/sdk/OutBoxBuilder.scala +++ b/sdk/shared/src/main/scala/org/ergoplatform/sdk/OutBoxBuilder.scala @@ -68,7 +68,7 @@ object OutBoxBuilder { val nRegs = registers.length require(nRegs <= nonMandatoryRegisters.length, s"Too many additional registers $nRegs. Max allowed ${nonMandatoryRegisters.length}") - implicit val TokenIdRType: RType[TokenId] = collRType(RType.ByteType).asInstanceOf[RType[TokenId]] + implicit val TokenIdRType: RType[TokenId] = collRType(sigma.ByteType).asInstanceOf[RType[TokenId]] val ts = Colls.fromItems(tokens.map(Iso.isoErgoTokenToPair.to(_)): _*) val rs = registers.zipWithIndex.map { case (c, i) => val id = ErgoBox.nonMandatoryRegisters(i) diff --git a/sdk/shared/src/main/scala/org/ergoplatform/sdk/utils/Zero.scala b/sdk/shared/src/main/scala/org/ergoplatform/sdk/utils/Zero.scala index fd3bb455d6..6c7cbde440 100644 --- a/sdk/shared/src/main/scala/org/ergoplatform/sdk/utils/Zero.scala +++ b/sdk/shared/src/main/scala/org/ergoplatform/sdk/utils/Zero.scala @@ -1,7 +1,7 @@ package org.ergoplatform.sdk.utils import org.ergoplatform.ErgoBox -import sigma.core.{CollType, RType} +import sigma.core.{CollType, RType, TupleType} import sigma.core.RType._ import scorex.crypto.authds.avltree.batch.BatchAVLProver import scorex.crypto.hash.{Blake2b256, Digest32} diff --git a/sdk/shared/src/test/scala/org/ergoplatform/sdk/DataJsonEncoderSpecification.scala b/sdk/shared/src/test/scala/org/ergoplatform/sdk/DataJsonEncoderSpecification.scala index 019db458c0..e4a1b2b7e2 100644 --- a/sdk/shared/src/test/scala/org/ergoplatform/sdk/DataJsonEncoderSpecification.scala +++ b/sdk/shared/src/test/scala/org/ergoplatform/sdk/DataJsonEncoderSpecification.scala @@ -2,8 +2,8 @@ package org.ergoplatform.sdk import java.math.BigInteger - import org.scalacheck.Arbitrary._ +import org.scalacheck.Gen import sigma.core.RType import sigmastate.SCollection.SByteArray import sigmastate.SType.AnyOps @@ -13,9 +13,12 @@ import sigmastate.eval.Extensions._ import sigmastate.eval.{Evaluation, _} import sigmastate.crypto.CryptoConstants.EcPointType import sigmastate.exceptions.SerializerException -import sigma.{Box, AvlTree} +import sigma.{AvlTree, Box} import sigmastate.serialization.SerializationSpecification +import scala.annotation.nowarn +import scala.reflect.ClassTag + class DataJsonEncoderSpecification extends SerializationSpecification { object JsonCodecs extends JsonCodecs @@ -47,9 +50,9 @@ class DataJsonEncoderSpecification extends SerializationSpecification { } def testTuples[T <: SType](tpe: T) = { - implicit val wWrapped = wrappedTypeGen(tpe) - implicit val tag = tpe.classTag[T#WrappedType] - implicit val tAny = RType.AnyType + implicit val wWrapped: Gen[T#WrappedType] = wrappedTypeGen(tpe) + implicit val tag : ClassTag[T#WrappedType] = tpe.classTag[T#WrappedType] + implicit val tAny : RType[Any] = sigma.AnyType forAll { in: (T#WrappedType, T#WrappedType) => val (x,y) = (in._1, in._2) roundtrip[SType]((x, y).asWrappedType, STuple(tpe, tpe)) @@ -58,11 +61,11 @@ class DataJsonEncoderSpecification extends SerializationSpecification { } } - def testAnyValue[T <: SType](tpe: T) = { + @nowarn def testAnyValue[T <: SType](tpe: T) = { implicit val wWrapped = wrappedTypeGen(tpe) implicit val tag = tpe.classTag[T#WrappedType] implicit val tT = Evaluation.stypeToRType(tpe) - implicit val tAny = RType.AnyType + implicit val tAny = sigma.AnyType forAll { in: T#WrappedType => val x = CAnyValue(in) val json = JsonCodecs.anyValueEncoder(x) @@ -181,7 +184,7 @@ class DataJsonEncoderSpecification extends SerializationSpecification { def testEncodeError[T <: SType](tpe: T) = { implicit val wWrapped = wrappedTypeGen(tpe) implicit val tag = tpe.classTag[T#WrappedType] - implicit val tAny = RType.AnyType + implicit val tAny = sigma.AnyType forAll { x: T#WrappedType => an[SerializerException] should be thrownBy { DataJsonEncoder.encode(TupleColl(x, x, x).asWrappedType, STuple(tpe, tpe, tpe)) From 86c83e0b8c31d03faade0d5d7ce581ad0d099dab Mon Sep 17 00:00:00 2001 From: Alexander Slesarenko Date: Thu, 24 Aug 2023 23:32:36 +0200 Subject: [PATCH 18/37] minimize-modules: CollType and TupleType moved to RType.scala --- .../main/scala/sigma/CollsOverArrays.scala | 2 +- .../src/main/scala/sigma/core/CollType.scala | 24 --- .../src/main/scala/sigma/core/RType.scala | 190 +++++++++++------- .../src/main/scala/sigma/core/TupleType.scala | 24 --- .../shared/src/main/scala/sigma/package.scala | 4 +- .../scala/sigmastate/eval/Evaluation.scala | 2 +- .../main/scala/sigmastate/eval/package.scala | 1 - .../src/main/scala/sigmastate/types.scala | 22 +- .../src/main/scala/scalan/TypeDescs.scala | 12 +- .../test/scala/sigma/SigmaDslTesting.scala | 3 +- .../sigmastate/helpers/SigmaPPrint.scala | 3 +- .../scala/org/ergoplatform/sdk/js/Value.scala | 2 +- .../ergoplatform/sdk/ContractTemplate.scala | 1 + .../org/ergoplatform/sdk/utils/Zero.scala | 2 +- 14 files changed, 145 insertions(+), 147 deletions(-) delete mode 100644 common/shared/src/main/scala/sigma/core/CollType.scala delete mode 100644 common/shared/src/main/scala/sigma/core/TupleType.scala diff --git a/common/shared/src/main/scala/sigma/CollsOverArrays.scala b/common/shared/src/main/scala/sigma/CollsOverArrays.scala index 7d57c8a4fb..25799ea61f 100644 --- a/common/shared/src/main/scala/sigma/CollsOverArrays.scala +++ b/common/shared/src/main/scala/sigma/CollsOverArrays.scala @@ -1,7 +1,7 @@ package sigma import sigma.util.CollectionUtil -import sigma.core.RType +import sigma.core.{PairType, RType} import debox.Buffer import sigma.core.RType._ import sigma.util.{MaxArrayLength, safeConcatArrays_v5} diff --git a/common/shared/src/main/scala/sigma/core/CollType.scala b/common/shared/src/main/scala/sigma/core/CollType.scala deleted file mode 100644 index dc526abd69..0000000000 --- a/common/shared/src/main/scala/sigma/core/CollType.scala +++ /dev/null @@ -1,24 +0,0 @@ -package sigma.core - -import sigma.Coll - -import scala.language.implicitConversions -import scala.reflect.ClassTag - -/** Type descriptor for `Coll[A]` type. */ -case class CollType[A](tItem: RType[A]) extends RType[Coll[A]] { - override val classTag: ClassTag[Coll[A]] = ClassTag[Coll[A]](classOf[Coll[A]]) - - override def name: String = s"Coll[${tItem.name}]" -} - -object CollType { - /** Conversion to underlying descriptor class. - * Allows syntax like - * - * ```val tColl: RType[Coll[A]] = ...; tColl.tItem``` - * - * where `tItem` is a method of `CollType`, but is not defined on `RType`. - */ - implicit def downcastCollType[A](ct: RType[Coll[A]]): CollType[A] = ct.asInstanceOf[CollType[A]] -} diff --git a/common/shared/src/main/scala/sigma/core/RType.scala b/common/shared/src/main/scala/sigma/core/RType.scala index ead1968c09..e245733bc3 100644 --- a/common/shared/src/main/scala/sigma/core/RType.scala +++ b/common/shared/src/main/scala/sigma/core/RType.scala @@ -1,7 +1,11 @@ package sigma.core +import sigma.{Coll, TupleData} +import sigma.core.RType.{SomeType, ThunkData} +import sigma.util.CollectionUtil + import scala.reflect.ClassTag -import scala.annotation.{implicitNotFound, unused} +import scala.annotation.{implicitNotFound, nowarn, unused} import scala.language.implicitConversions /** Base type for all runtime type descriptors. Sigma uses type descriptors to @@ -11,7 +15,7 @@ import scala.language.implicitConversions * @see [[getReg]], [[getVar]] */ @implicitNotFound(msg = "No RType available for ${A}.") -abstract class RType[A] { +sealed abstract class RType[A] { /** Class tag suitable for construct instances of Array[A]. */ def classTag: ClassTag[A] @@ -22,6 +26,108 @@ abstract class RType[A] { def emptyArray: Array[A] = Array.empty[A](classTag) } +/** Type descriptor for types with limited type information like Any, AnyRef, Nothing. + * It also used to wrap class tags which are GenericClassTag instances + * (also with limited information about type structure). + * To describe structure of the type more precisely use concrete classes + * in the hierarchy of RType. + */ +case class GeneralType[A](classTag: ClassTag[A]) extends RType[A] { + override def name: String = classTag match { + case ClassTag.Any => "Any" + case ClassTag.AnyRef => "AnyRef" + case ClassTag.Nothing => "Nothing" + case ct => ct.runtimeClass.getSimpleName() + } +} + +/** 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() +} + +case class StringType() extends RType[String] { + override def classTag: ClassTag[String] = ClassTag[String](classOf[String]) + + override def name: String = "String" +} + +/** Descriptor of descriptor to represent type of RType[_] instances. + * This describes any possible descriptor, disregarding its underlying type. + * Thus the underlying type is assumed to be Any. */ +case object RTypeType extends RType[RType[_]] { + val classTag: ClassTag[RType[_]] = ClassTag[RType[_]](classOf[RType[_]]) + + override def name: String = s"RType[Any]" +} + +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})" +} + +case class ArrayType[A](tA: RType[A]) extends RType[Array[A]] { + val classTag: ClassTag[Array[A]] = { + @nowarn implicit val ctA: ClassTag[A] = tA.classTag + scala.reflect.classTag[Array[A]] + } + + override def name: String = s"Array[${tA.name}]" +} + +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}" +} + +case class OptionType[A](tA: RType[A]) extends RType[Option[A]] { + val classTag: ClassTag[Option[A]] = { + @unused // avoid warning about unused ctA + implicit val ctA: ClassTag[A] = tA.classTag + scala.reflect.classTag[Option[A]] + } + + override def name: String = s"Option[${tA.name}]" +} + +/** Type descriptor for `Coll[A]` type. */ +case class CollType[A](tItem: RType[A]) extends RType[Coll[A]] { + override val classTag: ClassTag[Coll[A]] = ClassTag[Coll[A]](classOf[Coll[A]]) + + override def name: String = s"Coll[${tItem.name}]" +} + +case class ThunkType[A](tA: RType[A]) extends RType[ThunkData[A]] { + val classTag: ClassTag[ThunkData[A]] = { + @unused // avoid warning about unused ctA + implicit val ctA: ClassTag[A] = tA.classTag + scala.reflect.classTag[ThunkData[A]] + } + + override def name: String = s"Thunk[${tA.name}]" +} + +/** Descriptor (in RType family) of tuple types. + * + * @param items types of tuple items + */ +case class TupleType(items: Array[SomeType]) extends RType[TupleData] { + override val classTag: ClassTag[TupleData] = scala.reflect.classTag[TupleData] + + override def name: String = items.map(_.name).mkString("(", ", ", ")") + + override def hashCode(): Int = CollectionUtil.deepHashCode(items) + + override def equals(obj: Any): Boolean = (this eq obj.asInstanceOf[AnyRef]) || (obj match { + case that: TupleType => java.util.Arrays.equals(items.asInstanceOf[Array[AnyRef]], that.items.asInstanceOf[Array[AnyRef]]) + case _ => false + }) +} + object RType { /** Helper to request RType instances from an implicit scope.*/ def apply[A](implicit t: RType[A]): RType[A] = t @@ -41,91 +147,31 @@ object RType { type SomeType = RType[_] - /** Type descriptor for types with limited type information like Any, AnyRef, Nothing. - * It also used to wrap class tags which are GenericClassTag instances - * (also with limited information about type structure). - * To describe structure of the type more precisely use concrete classes - * in the hierarchy of RType. - */ - case class GeneralType[A](classTag: ClassTag[A]) extends RType[A] { - override def name: String = classTag match { - case ClassTag.Any => "Any" - case ClassTag.AnyRef => "AnyRef" - case ClassTag.Nothing => "Nothing" - case ct => ct.runtimeClass.getSimpleName() - } - } - - /** 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() - } - - implicit case object StringType extends RType[String] { - override def classTag: ClassTag[String] = ClassTag[String](classOf[String]) - override def name: String = "String" - } + /** Underlying type of Thunk[A] values (or by-name values of type A). */ + type ThunkData[A] = () => A - /** Descriptor of descriptor to represent type of RType[_] instances. - * This describes any possible descriptor, disregarding its underlying type. - * Thus the underlying type is assumed to be Any. */ - case object RTypeType extends RType[RType[_]] { - val classTag: ClassTag[RType[_]] = ClassTag[RType[_]](classOf[RType[_]]) - override def name: String = s"RType[Any]" - } /** Implicitly obtain the single RTypeType descriptor casted to the given type A. */ implicit def rtypeRType[A]: RType[RType[A]] = asType[RType[A]](RTypeType) implicit def pairRType[A,B](implicit tA: RType[A], tB: RType[B]): RType[(A,B)] = PairType(tA, tB) - 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})" - } implicit def extendPairType[A,B](pt: RType[(A,B)]): PairType[A,B] = pt.asInstanceOf[PairType[A,B]] 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}" - } - implicit def arrayRType[A](implicit tA: RType[A]): RType[Array[A]] = ArrayType(tA) - case class ArrayType[A](tA: RType[A]) extends RType[Array[A]] { - val classTag: ClassTag[Array[A]] = { - @unused // avoid warning about unused ctA - implicit val ctA: ClassTag[A] = tA.classTag - scala.reflect.classTag[Array[A]] - } - override def name: String = s"Array[${tA.name}]" - } - implicit def optionRType[A](implicit tA: RType[A]): RType[Option[A]] = OptionType(tA) - case class OptionType[A](tA: RType[A]) extends RType[Option[A]] { - val classTag: ClassTag[Option[A]] = { - @unused // avoid warning about unused ctA - implicit val ctA: ClassTag[A] = tA.classTag - scala.reflect.classTag[Option[A]] - } - override def name: String = s"Option[${tA.name}]" - } - - /** Underlying type of Thunk[A] values (or by-name values of type A). */ - type ThunkData[A] = () => A + /** Conversion to underlying descriptor class. + * Allows syntax like + * + * ```val tColl: RType[Coll[A]] = ...; tColl.tItem``` + * + * where `tItem` is a method of `CollType`, but is not defined on `RType`. + */ + implicit def downcastCollType[A](ct: RType[Coll[A]]): CollType[A] = ct.asInstanceOf[CollType[A]] implicit def thunkRType[A](implicit tA: RType[A]): RType[ThunkData[A]] = ThunkType(tA) - case class ThunkType[A](tA: RType[A]) extends RType[ThunkData[A]] { - val classTag: ClassTag[ThunkData[A]] = { - @unused // avoid warning about unused ctA - implicit val ctA: ClassTag[A] = tA.classTag - scala.reflect.classTag[ThunkData[A]] - } - override def name: String = s"Thunk[${tA.name}]" - } - } diff --git a/common/shared/src/main/scala/sigma/core/TupleType.scala b/common/shared/src/main/scala/sigma/core/TupleType.scala deleted file mode 100644 index ad16ec59d5..0000000000 --- a/common/shared/src/main/scala/sigma/core/TupleType.scala +++ /dev/null @@ -1,24 +0,0 @@ -package sigma.core - -import sigma.TupleData -import sigma.core.RType.SomeType -import sigma.util.CollectionUtil - -import scala.reflect.ClassTag - -/** Descriptor (in RType family) of tuple types. - * - * @param items types of tuple items - */ -case class TupleType(items: Array[SomeType]) extends RType[TupleData] { - override val classTag: ClassTag[TupleData] = scala.reflect.classTag[TupleData] - - override def name: String = items.map(_.name).mkString("(", ", ", ")") - - override def hashCode(): Int = CollectionUtil.deepHashCode(items) - - override def equals(obj: Any): Boolean = (this eq obj.asInstanceOf[AnyRef]) || (obj match { - case that: TupleType => java.util.Arrays.equals(items.asInstanceOf[Array[AnyRef]], that.items.asInstanceOf[Array[AnyRef]]) - case _ => false - }) -} diff --git a/common/shared/src/main/scala/sigma/package.scala b/common/shared/src/main/scala/sigma/package.scala index 0c0bab03c1..54a64fe25c 100644 --- a/common/shared/src/main/scala/sigma/package.scala +++ b/common/shared/src/main/scala/sigma/package.scala @@ -1,6 +1,6 @@ import sigma.core._ -import sigma.core.RType.{GeneralType, PrimitiveType, SomeType} +import sigma.core.RType.SomeType import scala.reflect.ClassTag @@ -25,6 +25,8 @@ package object sigma { implicit val UnitType : RType[Unit] = PrimitiveType[Unit](ClassTag.Unit, Array[Unit]()(ClassTag.Unit)) + implicit val StringType : RType[String] = core.StringType() + implicit val BigIntRType: RType[BigInt] = GeneralType(BigIntClassTag) implicit val GroupElementRType: RType[GroupElement] = GeneralType(GroupElementClassTag) implicit val SigmaPropRType: RType[SigmaProp] = GeneralType(SigmaPropClassTag) diff --git a/interpreter/shared/src/main/scala/sigmastate/eval/Evaluation.scala b/interpreter/shared/src/main/scala/sigmastate/eval/Evaluation.scala index 0dd9f9cf0b..7f087d3982 100644 --- a/interpreter/shared/src/main/scala/sigmastate/eval/Evaluation.scala +++ b/interpreter/shared/src/main/scala/sigmastate/eval/Evaluation.scala @@ -1,7 +1,7 @@ package sigmastate.eval import org.ergoplatform._ -import sigma.core.{CollType, RType, TupleType} +import sigma.core._ import sigma.core.RType._ import sigmastate.SType._ import sigmastate.Values.SigmaBoolean diff --git a/interpreter/shared/src/main/scala/sigmastate/eval/package.scala b/interpreter/shared/src/main/scala/sigmastate/eval/package.scala index 21a8240cf4..83efbc18b0 100644 --- a/interpreter/shared/src/main/scala/sigmastate/eval/package.scala +++ b/interpreter/shared/src/main/scala/sigmastate/eval/package.scala @@ -39,7 +39,6 @@ package object eval { type Digest32Coll = Digest32Coll.Type implicit val Digest32CollRType: RType[Digest32Coll] = RType[Coll[Byte]].asInstanceOf[RType[Digest32Coll] ] - implicit val Digest32RType: RType[Digest32] = RType[Array[Byte]].asInstanceOf[RType[Digest32] ] /** Implicit conversions between Dsl type and the type wrapped by the corresponding type Dsl type. * Here BigInt is Dsl type and BigInteger is wrapped type. diff --git a/interpreter/shared/src/main/scala/sigmastate/types.scala b/interpreter/shared/src/main/scala/sigmastate/types.scala index 0ca0cc50c1..ae3d316e95 100644 --- a/interpreter/shared/src/main/scala/sigmastate/types.scala +++ b/interpreter/shared/src/main/scala/sigmastate/types.scala @@ -4,7 +4,7 @@ import java.math.BigInteger import org.ergoplatform._ import org.ergoplatform.validation._ import sigma.core.{Nullable, RType} -import sigma.core.RType.GeneralType +import sigma.core.GeneralType import sigmastate.SType.TypeCode import sigmastate.interpreter._ import sigmastate.utils.Overloading.Overload1 @@ -100,16 +100,16 @@ object SType { val DummyValue = 0.asWrappedType - implicit val typeByte = SByte - implicit val typeShort = SShort - implicit val typeInt = SInt - implicit val typeLong = SLong - implicit val typeBigInt = SBigInt - implicit val typeBoolean = SBoolean - implicit val typeAvlTree = SAvlTree - implicit val typeGroupElement = SGroupElement - implicit val typeSigmaProp = SSigmaProp - implicit val typeBox = SBox + implicit val typeByte : SByte.type = SByte + implicit val typeShort : SShort.type = SShort + implicit val typeInt : SInt.type = SInt + implicit val typeLong : SLong.type = SLong + implicit val typeBigInt : SBigInt.type = SBigInt + implicit val typeBoolean : SBoolean.type = SBoolean + implicit val typeAvlTree : SAvlTree.type = SAvlTree + implicit val typeGroupElement: SGroupElement.type = SGroupElement + implicit val typeSigmaProp : SSigmaProp.type = SSigmaProp + implicit val typeBox : SBox.type = SBox /** Costructs a collection type with the given type of elements. */ implicit def typeCollection[V <: SType](implicit tV: V): SCollection[V] = SCollection[V](tV) diff --git a/sc/shared/src/main/scala/scalan/TypeDescs.scala b/sc/shared/src/main/scala/scalan/TypeDescs.scala index 6449861d11..9543f96b5c 100644 --- a/sc/shared/src/main/scala/scalan/TypeDescs.scala +++ b/sc/shared/src/main/scala/scalan/TypeDescs.scala @@ -367,12 +367,12 @@ abstract class TypeDescs extends Base { self: Scalan => val LazyAnyElement = Lazy(AnyElement) implicit val BooleanElement: Elem[Boolean] = new BaseElemLiftable(false, sigma.BooleanType) - implicit val ByteElement: Elem[Byte] = new BaseElemLiftable(0.toByte, sigma.ByteType) - implicit val ShortElement: Elem[Short] = new BaseElemLiftable(0.toShort, sigma.ShortType) - implicit val IntElement: Elem[Int] = new BaseElemLiftable(0, sigma.IntType) - implicit val LongElement: Elem[Long] = new BaseElemLiftable(0L, sigma.LongType) - implicit val UnitElement: Elem[Unit] = new BaseElemLiftable((), sigma.UnitType) - implicit val StringElement: Elem[String] = new BaseElemLiftable("", StringType) + implicit val ByteElement : Elem[Byte] = new BaseElemLiftable(0.toByte, sigma.ByteType) + implicit val ShortElement : Elem[Short] = new BaseElemLiftable(0.toShort, sigma.ShortType) + implicit val IntElement : Elem[Int] = new BaseElemLiftable(0, sigma.IntType) + implicit val LongElement : Elem[Long] = new BaseElemLiftable(0L, sigma.LongType) + implicit val UnitElement : Elem[Unit] = new BaseElemLiftable((), sigma.UnitType) + implicit val StringElement : Elem[String] = new BaseElemLiftable("", sigma.StringType) /** Implicitly defines element type for pairs. */ implicit final def pairElement[A, B](implicit ea: Elem[A], eb: Elem[B]): Elem[(A, B)] = diff --git a/sc/shared/src/test/scala/sigma/SigmaDslTesting.scala b/sc/shared/src/test/scala/sigma/SigmaDslTesting.scala index 1da3968468..f738444dcf 100644 --- a/sc/shared/src/test/scala/sigma/SigmaDslTesting.scala +++ b/sc/shared/src/test/scala/sigma/SigmaDslTesting.scala @@ -13,8 +13,7 @@ import org.scalatest.matchers.should.Matchers import org.scalatest.propspec.AnyPropSpec import org.scalatestplus.scalacheck.ScalaCheckPropertyChecks import scalan.Platform.threadSleepOrNoOp -import sigma.core.{CollType, RType} -import sigma.core.RType._ +import sigma.core.{CollType, OptionType, PairType, RType} import sigma.util.BenchmarkUtil import sigma.util.CollectionUtil._ import sigma.util.Extensions._ diff --git a/sc/shared/src/test/scala/sigmastate/helpers/SigmaPPrint.scala b/sc/shared/src/test/scala/sigmastate/helpers/SigmaPPrint.scala index a9f7997d63..576d670528 100644 --- a/sc/shared/src/test/scala/sigmastate/helpers/SigmaPPrint.scala +++ b/sc/shared/src/test/scala/sigmastate/helpers/SigmaPPrint.scala @@ -4,8 +4,7 @@ import org.ergoplatform.ErgoBox import org.ergoplatform.ErgoBox.RegisterId import org.ergoplatform.settings.ErgoAlgos import pprint.{PPrinter, Tree} -import sigma.core.RType.PrimitiveType -import sigma.core.{CollType, RType} +import sigma.core.{CollType, PrimitiveType} import sigma.{Coll, GroupElement} import sigmastate.SCollection._ import sigmastate.Values.{ConstantNode, ErgoTree, FuncValue, ValueCompanion} diff --git a/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Value.scala b/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Value.scala index ff739a7f43..556c0f4cf2 100644 --- a/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Value.scala +++ b/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Value.scala @@ -2,7 +2,7 @@ package org.ergoplatform.sdk.js import org.ergoplatform.sdk.js.Value.toRuntimeData import sigma.core.{CollType, RType} -import sigma.core.RType.PairType +import sigma.core.PairType import scorex.util.Extensions.{IntOps, LongOps} import scorex.util.encode.Base16 import sigmastate.SType diff --git a/sdk/shared/src/main/scala/org/ergoplatform/sdk/ContractTemplate.scala b/sdk/shared/src/main/scala/org/ergoplatform/sdk/ContractTemplate.scala index f763824400..47d2a06d3e 100644 --- a/sdk/shared/src/main/scala/org/ergoplatform/sdk/ContractTemplate.scala +++ b/sdk/shared/src/main/scala/org/ergoplatform/sdk/ContractTemplate.scala @@ -1,5 +1,6 @@ package org.ergoplatform.sdk +import cats.syntax.either._ // required for Scala 2.11 import debox.cfor import io.circe._ import io.circe.syntax.EncoderOps diff --git a/sdk/shared/src/main/scala/org/ergoplatform/sdk/utils/Zero.scala b/sdk/shared/src/main/scala/org/ergoplatform/sdk/utils/Zero.scala index 6c7cbde440..1d22086213 100644 --- a/sdk/shared/src/main/scala/org/ergoplatform/sdk/utils/Zero.scala +++ b/sdk/shared/src/main/scala/org/ergoplatform/sdk/utils/Zero.scala @@ -1,7 +1,7 @@ package org.ergoplatform.sdk.utils import org.ergoplatform.ErgoBox -import sigma.core.{CollType, RType, TupleType} +import sigma.core.{CollType, FuncType, OptionType, PairType, RType, TupleType} import sigma.core.RType._ import scorex.crypto.authds.avltree.batch.BatchAVLProver import scorex.crypto.hash.{Blake2b256, Digest32} From c5d4022845118fd58006514c352564a85952c55c Mon Sep 17 00:00:00 2001 From: Alexander Slesarenko Date: Thu, 24 Aug 2023 23:36:42 +0200 Subject: [PATCH 19/37] minimize-modules: CollsTests, CollGens moved to sigma package --- .../src/test/scala/sigma/{collection => }/CollGens.scala | 6 ++---- .../src/test/scala/sigma/{collection => }/CollsTests.scala | 3 +-- .../src/test/scala/special/collections/BenchmarkGens.scala | 4 +--- .../test/scala/org/ergoplatform/sdk/ExtensionsSpec.scala | 3 +-- 4 files changed, 5 insertions(+), 11 deletions(-) rename common/shared/src/test/scala/sigma/{collection => }/CollGens.scala (98%) rename common/shared/src/test/scala/sigma/{collection => }/CollsTests.scala (99%) diff --git a/common/shared/src/test/scala/sigma/collection/CollGens.scala b/common/shared/src/test/scala/sigma/CollGens.scala similarity index 98% rename from common/shared/src/test/scala/sigma/collection/CollGens.scala rename to common/shared/src/test/scala/sigma/CollGens.scala index a203124c14..278ddb0462 100644 --- a/common/shared/src/test/scala/sigma/collection/CollGens.scala +++ b/common/shared/src/test/scala/sigma/CollGens.scala @@ -1,15 +1,13 @@ -package sigma.collection +package sigma -import scala.language.implicitConversions import org.scalacheck.util.Buildable import org.scalacheck.{Arbitrary, Gen} -import sigma.{Coll, CollBuilder, CollOverArrayBuilder, PairColl} -import sigma._ import sigma.core.RType import spire.scalacompat.BuilderCompat import scala.collection.mutable import scala.collection.mutable.ArrayBuffer +import scala.language.implicitConversions trait CollGens { testSuite => import Gen._ diff --git a/common/shared/src/test/scala/sigma/collection/CollsTests.scala b/common/shared/src/test/scala/sigma/CollsTests.scala similarity index 99% rename from common/shared/src/test/scala/sigma/collection/CollsTests.scala rename to common/shared/src/test/scala/sigma/CollsTests.scala index 1f24d1959c..4b286b549a 100644 --- a/common/shared/src/test/scala/sigma/collection/CollsTests.scala +++ b/common/shared/src/test/scala/sigma/CollsTests.scala @@ -1,11 +1,10 @@ -package sigma.collection +package sigma import org.scalacheck.Gen import org.scalatest.exceptions.TestFailedException import org.scalatest.matchers.should.Matchers import org.scalatest.propspec.AnyPropSpec import org.scalatestplus.scalacheck.ScalaCheckPropertyChecks -import sigma._ import sigma.core._ import scala.language.existentials diff --git a/sc/jvm/src/test/scala/special/collections/BenchmarkGens.scala b/sc/jvm/src/test/scala/special/collections/BenchmarkGens.scala index 3819772202..aced1cc381 100644 --- a/sc/jvm/src/test/scala/special/collections/BenchmarkGens.scala +++ b/sc/jvm/src/test/scala/special/collections/BenchmarkGens.scala @@ -1,8 +1,6 @@ package sigma -import org.scalameter.KeyValue -import org.scalameter.api.{Bench, Gen, _} -import sigma.collection.CollGens +import org.scalameter.api._ trait BenchmarkGens extends CollGens { suite: Bench[Double] => def maxSize = 100000 diff --git a/sdk/shared/src/test/scala/org/ergoplatform/sdk/ExtensionsSpec.scala b/sdk/shared/src/test/scala/org/ergoplatform/sdk/ExtensionsSpec.scala index c84918d128..cc555d6fab 100644 --- a/sdk/shared/src/test/scala/org/ergoplatform/sdk/ExtensionsSpec.scala +++ b/sdk/shared/src/test/scala/org/ergoplatform/sdk/ExtensionsSpec.scala @@ -3,9 +3,8 @@ package org.ergoplatform.sdk import org.scalatest.matchers.should.Matchers import org.scalatest.propspec.AnyPropSpec import org.scalatestplus.scalacheck.ScalaCheckPropertyChecks -import sigma.Coll +import sigma.{Coll, CollGens} import org.ergoplatform.sdk.Extensions.{CollBuilderOps, CollOps, GenIterableOps, PairCollOps} -import sigma.collection.CollGens import sigma.core.RType import sigmastate.eval.CostingSigmaDslBuilder From ca26fb4749afb855af5416ebfdb4e6b675d09b47 Mon Sep 17 00:00:00 2001 From: Alexander Slesarenko Date: Fri, 25 Aug 2023 15:29:08 +0200 Subject: [PATCH 20/37] minimize-modules: renamed package sigma.core -> sigma.data --- common/shared/src/main/scala/sigma/Colls.scala | 2 +- common/shared/src/main/scala/sigma/CollsOverArrays.scala | 4 ++-- .../shared/src/main/scala/sigma/CoreLibReflection.scala | 2 +- common/shared/src/main/scala/sigma/SigmaDsl.scala | 2 +- .../src/main/scala/sigma/{core => data}/AnyVals.scala | 2 +- .../src/main/scala/sigma/{core => data}/DFunc.scala | 2 +- .../shared/src/main/scala/sigma/{core => data}/Lazy.scala | 2 +- .../main/scala/sigma/{core => data}/OverloadHack.scala | 2 +- .../src/main/scala/sigma/{core => data}/RType.scala | 4 ++-- .../src/main/scala/sigma/{core => data}/package.scala | 2 +- common/shared/src/main/scala/sigma/package.scala | 6 +++--- common/shared/src/main/scala/sigma/util/GraphUtil.scala | 2 +- .../shared/src/main/scala/sigma/util/MemoizedFunc.scala | 2 +- common/shared/src/test/scala/sigma/CollGens.scala | 2 +- common/shared/src/test/scala/sigma/CollsTests.scala | 2 +- common/shared/src/test/scala/sigma/TypesTests.scala | 4 ++-- .../shared/src/test/scala/sigma/util/GraphUtilTests.scala | 2 +- interpreter/js/src/main/scala/sigmastate/Platform.scala | 2 +- .../js/src/main/scala/sigmastate/crypto/Platform.scala | 2 +- interpreter/jvm/src/main/scala/sigmastate/Platform.scala | 2 +- .../src/main/scala/sigmastate/DataValueComparer.scala | 2 +- interpreter/shared/src/main/scala/sigmastate/Values.scala | 2 +- .../src/main/scala/sigmastate/eval/BigIntegerOps.scala | 2 +- .../main/scala/sigmastate/eval/CostingDataContext.scala | 4 ++-- .../src/main/scala/sigmastate/eval/Evaluation.scala | 4 ++-- .../src/main/scala/sigmastate/eval/ExactIntegral.scala | 2 +- .../src/main/scala/sigmastate/eval/ExactNumeric.scala | 4 ++-- .../src/main/scala/sigmastate/eval/ExactOrdering.scala | 2 +- .../src/main/scala/sigmastate/eval/Extensions.scala | 2 +- .../shared/src/main/scala/sigmastate/eval/package.scala | 2 +- .../src/main/scala/sigmastate/lang/SigmaBuilder.scala | 2 +- .../src/main/scala/sigmastate/lang/SigmaPredef.scala | 2 +- .../shared/src/main/scala/sigmastate/lang/Terms.scala | 2 +- .../scala/sigmastate/serialization/DataSerializer.scala | 2 +- interpreter/shared/src/main/scala/sigmastate/trees.scala | 8 ++++---- interpreter/shared/src/main/scala/sigmastate/types.scala | 4 ++-- .../shared/src/main/scala/sigmastate/utils/Helpers.scala | 2 +- .../src/main/scala/sigmastate/utxo/transformers.scala | 2 +- .../src/test/scala/sigmastate/lang/SigmaBuilderTest.scala | 2 +- .../serialization/ConstantSerializerSpecification.scala | 2 +- .../serialization/DataSerializerSpecification.scala | 2 +- .../serialization/generators/ObjectGenerators.scala | 2 +- .../src/test/scala/special/sigma/ContractsTestkit.scala | 4 ++-- .../src/test/scala/special/sigma/SigmaTestingData.scala | 2 +- .../src/main/scala/sigmastate/lang/SigmaParser.scala | 2 +- .../src/main/scala/sigmastate/lang/syntax/Basic.scala | 2 +- .../test/scala/sigmastate/helpers/SigmaPPrintSpec.scala | 2 +- .../src/test/scala/special/collections/MapBenchmark.scala | 2 +- .../main/scala/org/ergoplatform/dsl/ContractSpec.scala | 2 +- .../main/scala/org/ergoplatform/dsl/ContractSyntax.scala | 2 +- sc/shared/src/main/scala/scalan/Base.scala | 4 ++-- sc/shared/src/main/scala/scalan/DefRewriting.scala | 2 +- sc/shared/src/main/scala/scalan/GraphIRReflection.scala | 2 +- sc/shared/src/main/scala/scalan/Library.scala | 2 +- sc/shared/src/main/scala/scalan/TypeDescs.scala | 6 +++--- .../src/main/scala/scalan/primitives/Functions.scala | 2 +- .../src/main/scala/scalan/primitives/NumericOps.scala | 2 +- .../src/main/scala/scalan/primitives/OrderingOps.scala | 2 +- sc/shared/src/main/scala/scalan/primitives/Thunks.scala | 4 ++-- sc/shared/src/main/scala/scalan/primitives/Tuples.scala | 2 +- sc/shared/src/main/scala/scalan/staged/AstGraphs.scala | 2 +- .../src/main/scala/scalan/staged/ProgramGraphs.scala | 2 +- sc/shared/src/main/scala/scalan/staged/Transforming.scala | 2 +- .../src/main/scala/sigmastate/eval/GraphBuilding.scala | 6 +++--- .../src/main/scala/sigmastate/lang/SigmaBinder.scala | 2 +- sc/shared/src/main/scala/sigmastate/lang/SigmaTyper.scala | 2 +- .../main/scala/special/collection/impl/CollsImpl.scala | 2 +- .../src/main/scala/special/sigma/impl/SigmaDslImpl.scala | 2 +- .../src/main/scala/special/wrappers/WrappersSpec.scala | 2 +- .../src/main/scala/wrappers/scala/impl/WOptionsImpl.scala | 2 +- sc/shared/src/main/scala/wrappers/scalan/WRTypes.scala | 2 +- .../src/main/scala/wrappers/scalan/impl/WRTypesImpl.scala | 2 +- .../scala/wrappers/special/impl/WSpecialPredefsImpl.scala | 2 +- .../scala/org/ergoplatform/dsl/TestContractSpec.scala | 2 +- .../test/scala/sigma/DataValueComparerSpecification.scala | 2 +- .../src/test/scala/sigma/SigmaDslSpecification.scala | 4 ++-- sc/shared/src/test/scala/sigma/SigmaDslTesting.scala | 2 +- .../src/test/scala/sigmastate/ErgoTreeSpecification.scala | 4 ++-- .../scala/sigmastate/helpers/CompilerTestingCommons.scala | 2 +- .../src/test/scala/sigmastate/helpers/SigmaPPrint.scala | 2 +- .../scala/sigmastate/utxo/BasicOpsSpecification.scala | 2 +- .../src/test/scala/special/wrappers/WRTypeTests.scala | 2 +- .../test/scala/special/wrappers/WSpecialPredefTests.scala | 2 +- sdk/js/src/main/scala/org/ergoplatform/sdk/js/Isos.scala | 2 +- sdk/js/src/main/scala/org/ergoplatform/sdk/js/Type.scala | 2 +- sdk/js/src/main/scala/org/ergoplatform/sdk/js/Value.scala | 4 ++-- .../main/scala/org/ergoplatform/sdk/DataJsonEncoder.scala | 2 +- .../src/main/scala/org/ergoplatform/sdk/Extensions.scala | 2 +- .../src/main/scala/org/ergoplatform/sdk/JavaHelpers.scala | 4 ++-- .../main/scala/org/ergoplatform/sdk/OutBoxBuilder.scala | 2 +- .../src/main/scala/org/ergoplatform/sdk/Utils.scala | 2 +- .../src/main/scala/org/ergoplatform/sdk/utils/Zero.scala | 4 ++-- .../ergoplatform/sdk/DataJsonEncoderSpecification.scala | 2 +- .../test/scala/org/ergoplatform/sdk/ExtensionsSpec.scala | 2 +- 94 files changed, 118 insertions(+), 118 deletions(-) rename common/shared/src/main/scala/sigma/{core => data}/AnyVals.scala (99%) rename common/shared/src/main/scala/sigma/{core => data}/DFunc.scala (89%) rename common/shared/src/main/scala/sigma/{core => data}/Lazy.scala (96%) rename common/shared/src/main/scala/sigma/{core => data}/OverloadHack.scala (97%) rename common/shared/src/main/scala/sigma/{core => data}/RType.scala (98%) rename common/shared/src/main/scala/sigma/{core => data}/package.scala (98%) diff --git a/common/shared/src/main/scala/sigma/Colls.scala b/common/shared/src/main/scala/sigma/Colls.scala index 874e116d3f..625120deac 100644 --- a/common/shared/src/main/scala/sigma/Colls.scala +++ b/common/shared/src/main/scala/sigma/Colls.scala @@ -1,6 +1,6 @@ package sigma -import sigma.core.RType +import sigma.data.RType /** Indexed (zero-based) collection of elements of type `A`. * NOTE: declaring it `abstract class` makes some performance benefits, but doesn't work diff --git a/common/shared/src/main/scala/sigma/CollsOverArrays.scala b/common/shared/src/main/scala/sigma/CollsOverArrays.scala index 25799ea61f..3f441919ab 100644 --- a/common/shared/src/main/scala/sigma/CollsOverArrays.scala +++ b/common/shared/src/main/scala/sigma/CollsOverArrays.scala @@ -1,9 +1,9 @@ package sigma import sigma.util.CollectionUtil -import sigma.core.{PairType, RType} +import sigma.data.{PairType, RType} import debox.Buffer -import sigma.core.RType._ +import sigma.data.RType._ import sigma.util.{MaxArrayLength, safeConcatArrays_v5} import debox.cfor diff --git a/common/shared/src/main/scala/sigma/CoreLibReflection.scala b/common/shared/src/main/scala/sigma/CoreLibReflection.scala index 989b3dd66f..3b68b1547f 100644 --- a/common/shared/src/main/scala/sigma/CoreLibReflection.scala +++ b/common/shared/src/main/scala/sigma/CoreLibReflection.scala @@ -1,6 +1,6 @@ package sigma -import sigma.core.RType +import sigma.data.RType import sigma.reflection.CommonReflection.registerClassEntry import sigma.reflection._ diff --git a/common/shared/src/main/scala/sigma/SigmaDsl.scala b/common/shared/src/main/scala/sigma/SigmaDsl.scala index 91d49cc7cd..5516ddea6a 100644 --- a/common/shared/src/main/scala/sigma/SigmaDsl.scala +++ b/common/shared/src/main/scala/sigma/SigmaDsl.scala @@ -2,7 +2,7 @@ package sigma import java.math.BigInteger -import sigma.core._ +import sigma.data._ import scorex.crypto.authds.{ADDigest, ADValue} import scorex.crypto.authds.avltree.batch.Operation diff --git a/common/shared/src/main/scala/sigma/core/AnyVals.scala b/common/shared/src/main/scala/sigma/data/AnyVals.scala similarity index 99% rename from common/shared/src/main/scala/sigma/core/AnyVals.scala rename to common/shared/src/main/scala/sigma/data/AnyVals.scala index 763048ce9c..51262bfe71 100644 --- a/common/shared/src/main/scala/sigma/core/AnyVals.scala +++ b/common/shared/src/main/scala/sigma/data/AnyVals.scala @@ -1,4 +1,4 @@ -package sigma.core +package sigma.data import java.util.HashMap diff --git a/common/shared/src/main/scala/sigma/core/DFunc.scala b/common/shared/src/main/scala/sigma/data/DFunc.scala similarity index 89% rename from common/shared/src/main/scala/sigma/core/DFunc.scala rename to common/shared/src/main/scala/sigma/data/DFunc.scala index 29ab5cf1b5..39c4ce0db7 100644 --- a/common/shared/src/main/scala/sigma/core/DFunc.scala +++ b/common/shared/src/main/scala/sigma/data/DFunc.scala @@ -1,4 +1,4 @@ -package sigma.core +package sigma.data /** Function interface which support specialization and thus unboxed invocations. */ abstract class DFunc[@specialized(Int) A, B] { diff --git a/common/shared/src/main/scala/sigma/core/Lazy.scala b/common/shared/src/main/scala/sigma/data/Lazy.scala similarity index 96% rename from common/shared/src/main/scala/sigma/core/Lazy.scala rename to common/shared/src/main/scala/sigma/data/Lazy.scala index 2e4c8efdca..6e35a0b9b9 100644 --- a/common/shared/src/main/scala/sigma/core/Lazy.scala +++ b/common/shared/src/main/scala/sigma/data/Lazy.scala @@ -1,4 +1,4 @@ -package sigma.core +package sigma.data /** Non-thread safe (but efficient on single thread) immutable lazy value. * The `block` is executed only once. */ diff --git a/common/shared/src/main/scala/sigma/core/OverloadHack.scala b/common/shared/src/main/scala/sigma/data/OverloadHack.scala similarity index 97% rename from common/shared/src/main/scala/sigma/core/OverloadHack.scala rename to common/shared/src/main/scala/sigma/data/OverloadHack.scala index 88663fd32d..7de6892144 100644 --- a/common/shared/src/main/scala/sigma/core/OverloadHack.scala +++ b/common/shared/src/main/scala/sigma/data/OverloadHack.scala @@ -1,4 +1,4 @@ -package sigma.core +package sigma.data /** Scala specific trick to appease erasure of methods argument types. * Example usage: diff --git a/common/shared/src/main/scala/sigma/core/RType.scala b/common/shared/src/main/scala/sigma/data/RType.scala similarity index 98% rename from common/shared/src/main/scala/sigma/core/RType.scala rename to common/shared/src/main/scala/sigma/data/RType.scala index e245733bc3..281e032aa4 100644 --- a/common/shared/src/main/scala/sigma/core/RType.scala +++ b/common/shared/src/main/scala/sigma/data/RType.scala @@ -1,7 +1,7 @@ -package sigma.core +package sigma.data import sigma.{Coll, TupleData} -import sigma.core.RType.{SomeType, ThunkData} +import sigma.data.RType.{SomeType, ThunkData} import sigma.util.CollectionUtil import scala.reflect.ClassTag diff --git a/common/shared/src/main/scala/sigma/core/package.scala b/common/shared/src/main/scala/sigma/data/package.scala similarity index 98% rename from common/shared/src/main/scala/sigma/core/package.scala rename to common/shared/src/main/scala/sigma/data/package.scala index 81091f0387..8c34f7e9b9 100644 --- a/common/shared/src/main/scala/sigma/core/package.scala +++ b/common/shared/src/main/scala/sigma/data/package.scala @@ -4,7 +4,7 @@ import scala.annotation.nowarn import scala.reflect.classTag /** Contains cores definitions which serves as a basis for [[sigma]] package implementations. */ -package object core { +package object data { /** Shadow the implicit from sigma package so it doesn't interfere with the resolution * of ClassTags below. */ diff --git a/common/shared/src/main/scala/sigma/package.scala b/common/shared/src/main/scala/sigma/package.scala index 54a64fe25c..d9c0a18712 100644 --- a/common/shared/src/main/scala/sigma/package.scala +++ b/common/shared/src/main/scala/sigma/package.scala @@ -1,6 +1,6 @@ -import sigma.core._ -import sigma.core.RType.SomeType +import sigma.data._ +import sigma.data.RType.SomeType import scala.reflect.ClassTag @@ -25,7 +25,7 @@ package object sigma { implicit val UnitType : RType[Unit] = PrimitiveType[Unit](ClassTag.Unit, Array[Unit]()(ClassTag.Unit)) - implicit val StringType : RType[String] = core.StringType() + implicit val StringType : RType[String] = sigma.data.StringType() implicit val BigIntRType: RType[BigInt] = GeneralType(BigIntClassTag) implicit val GroupElementRType: RType[GroupElement] = GeneralType(GroupElementClassTag) diff --git a/common/shared/src/main/scala/sigma/util/GraphUtil.scala b/common/shared/src/main/scala/sigma/util/GraphUtil.scala index dafbda3244..11400b348a 100644 --- a/common/shared/src/main/scala/sigma/util/GraphUtil.scala +++ b/common/shared/src/main/scala/sigma/util/GraphUtil.scala @@ -1,6 +1,6 @@ package sigma.util -import sigma.core.DFunc +import sigma.data.DFunc import debox.{Set => DSet, Buffer => DBuffer} import debox.cfor import scala.reflect.ClassTag diff --git a/common/shared/src/main/scala/sigma/util/MemoizedFunc.scala b/common/shared/src/main/scala/sigma/util/MemoizedFunc.scala index 0ae516ea02..de5e4fc56a 100644 --- a/common/shared/src/main/scala/sigma/util/MemoizedFunc.scala +++ b/common/shared/src/main/scala/sigma/util/MemoizedFunc.scala @@ -1,6 +1,6 @@ package sigma.util -import sigma.core.AVHashMap +import sigma.data.AVHashMap /** Transforms a given function into memoized equivalent function. * Memoization is implemented by computing function f only once for each diff --git a/common/shared/src/test/scala/sigma/CollGens.scala b/common/shared/src/test/scala/sigma/CollGens.scala index 278ddb0462..c8096332f4 100644 --- a/common/shared/src/test/scala/sigma/CollGens.scala +++ b/common/shared/src/test/scala/sigma/CollGens.scala @@ -2,7 +2,7 @@ package sigma import org.scalacheck.util.Buildable import org.scalacheck.{Arbitrary, Gen} -import sigma.core.RType +import sigma.data.RType import spire.scalacompat.BuilderCompat import scala.collection.mutable diff --git a/common/shared/src/test/scala/sigma/CollsTests.scala b/common/shared/src/test/scala/sigma/CollsTests.scala index 4b286b549a..4886112742 100644 --- a/common/shared/src/test/scala/sigma/CollsTests.scala +++ b/common/shared/src/test/scala/sigma/CollsTests.scala @@ -5,7 +5,7 @@ import org.scalatest.exceptions.TestFailedException import org.scalatest.matchers.should.Matchers import org.scalatest.propspec.AnyPropSpec import org.scalatestplus.scalacheck.ScalaCheckPropertyChecks -import sigma.core._ +import sigma.data._ import scala.language.existentials diff --git a/common/shared/src/test/scala/sigma/TypesTests.scala b/common/shared/src/test/scala/sigma/TypesTests.scala index f0fd6ac95d..9d946fbee4 100644 --- a/common/shared/src/test/scala/sigma/TypesTests.scala +++ b/common/shared/src/test/scala/sigma/TypesTests.scala @@ -1,7 +1,7 @@ package sigma -import sigma.core.RType._ -import sigma.core.RType +import sigma.data.RType._ +import sigma.data.RType class TypesTests extends BaseTests { diff --git a/common/shared/src/test/scala/sigma/util/GraphUtilTests.scala b/common/shared/src/test/scala/sigma/util/GraphUtilTests.scala index 29e710cbeb..61fd9b5089 100644 --- a/common/shared/src/test/scala/sigma/util/GraphUtilTests.scala +++ b/common/shared/src/test/scala/sigma/util/GraphUtilTests.scala @@ -2,7 +2,7 @@ package sigma.util import sigma.{BaseNestedTests} import debox.{Set => DSet, Buffer => DBuffer} -import sigma.core.DFunc +import sigma.data.DFunc class GraphUtilTests extends BaseNestedTests { import GraphUtil._ diff --git a/interpreter/js/src/main/scala/sigmastate/Platform.scala b/interpreter/js/src/main/scala/sigmastate/Platform.scala index 2f9f0c6b6d..bff11b53a8 100644 --- a/interpreter/js/src/main/scala/sigmastate/Platform.scala +++ b/interpreter/js/src/main/scala/sigmastate/Platform.scala @@ -1,7 +1,7 @@ package sigmastate import org.ergoplatform.ErgoBox -import sigma.core.Nullable +import sigma.data.Nullable import sigma.VersionContext import sigmastate.Values.{Constant, FalseLeaf, SigmaBoolean, TrueLeaf} import sigmastate.eval.{Evaluation, SigmaDsl} diff --git a/interpreter/js/src/main/scala/sigmastate/crypto/Platform.scala b/interpreter/js/src/main/scala/sigmastate/crypto/Platform.scala index 3786e233ea..fdb3b128fd 100644 --- a/interpreter/js/src/main/scala/sigmastate/crypto/Platform.scala +++ b/interpreter/js/src/main/scala/sigmastate/crypto/Platform.scala @@ -1,6 +1,6 @@ package sigmastate.crypto -import sigma.core.RType +import sigma.data.RType import scorex.util.encode.Base16 import sigmastate._ import sigma.Coll diff --git a/interpreter/jvm/src/main/scala/sigmastate/Platform.scala b/interpreter/jvm/src/main/scala/sigmastate/Platform.scala index bf146df289..fa44f9a16f 100644 --- a/interpreter/jvm/src/main/scala/sigmastate/Platform.scala +++ b/interpreter/jvm/src/main/scala/sigmastate/Platform.scala @@ -1,7 +1,7 @@ package sigmastate import org.ergoplatform.ErgoBox -import sigma.core.Nullable +import sigma.data.Nullable import sigma.VersionContext import sigmastate.Values.{Constant, FalseLeaf, SigmaBoolean, TrueLeaf} import sigmastate.eval.{Evaluation, SigmaDsl} diff --git a/interpreter/shared/src/main/scala/sigmastate/DataValueComparer.scala b/interpreter/shared/src/main/scala/sigmastate/DataValueComparer.scala index f625ccd23c..6812d3bc15 100644 --- a/interpreter/shared/src/main/scala/sigmastate/DataValueComparer.scala +++ b/interpreter/shared/src/main/scala/sigmastate/DataValueComparer.scala @@ -1,6 +1,6 @@ package sigmastate -import sigma.core.{AVHashMap, Nullable, RType} +import sigma.data.{AVHashMap, Nullable, RType} import debox.{cfor, sp} import sigmastate.Values.SigmaBoolean import sigmastate.crypto.DLogProtocol.ProveDlog diff --git a/interpreter/shared/src/main/scala/sigmastate/Values.scala b/interpreter/shared/src/main/scala/sigmastate/Values.scala index bc15b54df0..dd3f2881a0 100644 --- a/interpreter/shared/src/main/scala/sigmastate/Values.scala +++ b/interpreter/shared/src/main/scala/sigmastate/Values.scala @@ -5,7 +5,7 @@ import java.util.{Arrays, Objects} import sigma.kiama.rewriting.Rewriter.{count, everywherebu, strategy} import org.ergoplatform.settings.ErgoAlgos import org.ergoplatform.validation.ValidationException -import sigma.core.{Nullable, RType} +import sigma.data.{Nullable, RType} import sigma.util.CollectionUtil._ import sigmastate.SCollection.{SByteArray, SIntArray} import sigmastate.crypto.CryptoConstants.EcPointType diff --git a/interpreter/shared/src/main/scala/sigmastate/eval/BigIntegerOps.scala b/interpreter/shared/src/main/scala/sigmastate/eval/BigIntegerOps.scala index e249b38864..058676b0fe 100644 --- a/interpreter/shared/src/main/scala/sigmastate/eval/BigIntegerOps.scala +++ b/interpreter/shared/src/main/scala/sigmastate/eval/BigIntegerOps.scala @@ -1,6 +1,6 @@ package sigmastate.eval -import sigma.core.{ExactOrderingImpl, ExactIntegral} +import sigma.data.{ExactOrderingImpl, ExactIntegral} import scala.math.{Integral, Ordering} import sigma._ diff --git a/interpreter/shared/src/main/scala/sigmastate/eval/CostingDataContext.scala b/interpreter/shared/src/main/scala/sigmastate/eval/CostingDataContext.scala index 2f5a09c6ef..09afa54a32 100644 --- a/interpreter/shared/src/main/scala/sigmastate/eval/CostingDataContext.scala +++ b/interpreter/shared/src/main/scala/sigmastate/eval/CostingDataContext.scala @@ -3,8 +3,8 @@ package sigmastate.eval import debox.cfor import org.ergoplatform.validation.{SigmaValidationSettings, ValidationRules} import org.ergoplatform.{ErgoBox, SigmaConstants} -import sigma.core.OverloadHack.Overloaded1 -import sigma.core.RType +import sigma.data.OverloadHack.Overloaded1 +import sigma.data.RType import sigma.util.Extensions.BigIntegerOps import scorex.crypto.authds.avltree.batch._ import scorex.crypto.authds.{ADDigest, ADKey, ADValue, SerializedAdProof} diff --git a/interpreter/shared/src/main/scala/sigmastate/eval/Evaluation.scala b/interpreter/shared/src/main/scala/sigmastate/eval/Evaluation.scala index 7f087d3982..242b4c9be2 100644 --- a/interpreter/shared/src/main/scala/sigmastate/eval/Evaluation.scala +++ b/interpreter/shared/src/main/scala/sigmastate/eval/Evaluation.scala @@ -1,8 +1,8 @@ package sigmastate.eval import org.ergoplatform._ -import sigma.core._ -import sigma.core.RType._ +import sigma.data._ +import sigma.data.RType._ import sigmastate.SType._ import sigmastate.Values.SigmaBoolean import sigmastate._ diff --git a/interpreter/shared/src/main/scala/sigmastate/eval/ExactIntegral.scala b/interpreter/shared/src/main/scala/sigmastate/eval/ExactIntegral.scala index e8092789fd..34e2f47f63 100644 --- a/interpreter/shared/src/main/scala/sigmastate/eval/ExactIntegral.scala +++ b/interpreter/shared/src/main/scala/sigmastate/eval/ExactIntegral.scala @@ -1,4 +1,4 @@ -package sigma.core +package sigma.data import sigma.util.Extensions.{ByteOps, ShortOps} diff --git a/interpreter/shared/src/main/scala/sigmastate/eval/ExactNumeric.scala b/interpreter/shared/src/main/scala/sigmastate/eval/ExactNumeric.scala index 75a33d11a1..2e9b799a61 100644 --- a/interpreter/shared/src/main/scala/sigmastate/eval/ExactNumeric.scala +++ b/interpreter/shared/src/main/scala/sigmastate/eval/ExactNumeric.scala @@ -1,6 +1,6 @@ -package sigma.core +package sigma.data -import sigma.core.ExactIntegral._ +import sigma.data.ExactIntegral._ /** Numeric operations with overflow checks. * Raise exception when overflow is detected. diff --git a/interpreter/shared/src/main/scala/sigmastate/eval/ExactOrdering.scala b/interpreter/shared/src/main/scala/sigmastate/eval/ExactOrdering.scala index 95264cb979..7c65b53075 100644 --- a/interpreter/shared/src/main/scala/sigmastate/eval/ExactOrdering.scala +++ b/interpreter/shared/src/main/scala/sigmastate/eval/ExactOrdering.scala @@ -1,4 +1,4 @@ -package sigma.core +package sigma.data import scala.math.Numeric.{ByteIsIntegral, LongIsIntegral, ShortIsIntegral, IntIsIntegral} diff --git a/interpreter/shared/src/main/scala/sigmastate/eval/Extensions.scala b/interpreter/shared/src/main/scala/sigmastate/eval/Extensions.scala index 2b89c5ca70..c2ecc29971 100644 --- a/interpreter/shared/src/main/scala/sigmastate/eval/Extensions.scala +++ b/interpreter/shared/src/main/scala/sigmastate/eval/Extensions.scala @@ -3,7 +3,7 @@ package sigmastate.eval import debox.{cfor, Buffer => DBuffer} import org.ergoplatform.ErgoBox import org.ergoplatform.ErgoBox.TokenId -import sigma.core.{Nullable, RType} +import sigma.data.{Nullable, RType} import scorex.util.encode.Base16 import sigmastate.SType.AnyOps import sigmastate.Values.{Constant, ConstantNode} diff --git a/interpreter/shared/src/main/scala/sigmastate/eval/package.scala b/interpreter/shared/src/main/scala/sigmastate/eval/package.scala index 83efbc18b0..79775d8c37 100644 --- a/interpreter/shared/src/main/scala/sigmastate/eval/package.scala +++ b/interpreter/shared/src/main/scala/sigmastate/eval/package.scala @@ -3,7 +3,7 @@ package sigmastate import java.math.BigInteger import org.ergoplatform.ErgoBox -import sigma.core.RType +import sigma.data.RType import scorex.crypto.hash.Digest32 import sigmastate.Values.SigmaBoolean import sigmastate.crypto.CryptoConstants.EcPointType diff --git a/interpreter/shared/src/main/scala/sigmastate/lang/SigmaBuilder.scala b/interpreter/shared/src/main/scala/sigmastate/lang/SigmaBuilder.scala index 93d526dfae..2e38aaab99 100644 --- a/interpreter/shared/src/main/scala/sigmastate/lang/SigmaBuilder.scala +++ b/interpreter/shared/src/main/scala/sigmastate/lang/SigmaBuilder.scala @@ -2,7 +2,7 @@ package sigmastate.lang import debox.cfor import org.ergoplatform.ErgoBox.RegisterId -import sigma.core.Nullable +import sigma.data.Nullable import sigma.Environment import sigmastate.SCollection.{SByteArray, SIntArray} import sigmastate.SOption.SIntOption diff --git a/interpreter/shared/src/main/scala/sigmastate/lang/SigmaPredef.scala b/interpreter/shared/src/main/scala/sigmastate/lang/SigmaPredef.scala index 747046fb1a..5b1d3dc2ca 100644 --- a/interpreter/shared/src/main/scala/sigmastate/lang/SigmaPredef.scala +++ b/interpreter/shared/src/main/scala/sigmastate/lang/SigmaPredef.scala @@ -2,7 +2,7 @@ package sigmastate.lang import org.ergoplatform.ErgoAddressEncoder.NetworkPrefix import org.ergoplatform.{ErgoAddressEncoder, P2PKAddress} -import sigma.core.Nullable +import sigma.data.Nullable import scorex.util.encode.{Base64, Base58, Base16} import sigmastate.SCollection.{SIntArray, SByteArray} import sigmastate.SOption._ diff --git a/interpreter/shared/src/main/scala/sigmastate/lang/Terms.scala b/interpreter/shared/src/main/scala/sigmastate/lang/Terms.scala index 9743edbb19..bbb19434bf 100644 --- a/interpreter/shared/src/main/scala/sigmastate/lang/Terms.scala +++ b/interpreter/shared/src/main/scala/sigmastate/lang/Terms.scala @@ -1,7 +1,7 @@ package sigmastate.lang import sigma.kiama.rewriting.Rewriter._ -import sigma.core.Nullable +import sigma.data.Nullable import sigmastate.SCollection.{SIntArray, SByteArray} import sigmastate.Values._ import sigmastate.utils.Overloading.Overload1 diff --git a/interpreter/shared/src/main/scala/sigmastate/serialization/DataSerializer.scala b/interpreter/shared/src/main/scala/sigmastate/serialization/DataSerializer.scala index 30660093ea..0c42617ef4 100644 --- a/interpreter/shared/src/main/scala/sigmastate/serialization/DataSerializer.scala +++ b/interpreter/shared/src/main/scala/sigmastate/serialization/DataSerializer.scala @@ -5,7 +5,7 @@ import java.nio.charset.StandardCharsets import org.ergoplatform.ErgoBox import org.ergoplatform.validation.ValidationRules.CheckSerializableTypeCode -import sigma.core.RType +import sigma.data.RType import sigmastate.Values.SigmaBoolean import sigmastate.utils.{SigmaByteReader, SigmaByteWriter} import sigmastate._ diff --git a/interpreter/shared/src/main/scala/sigmastate/trees.scala b/interpreter/shared/src/main/scala/sigmastate/trees.scala index 690be2ebe3..ef21a47cea 100644 --- a/interpreter/shared/src/main/scala/sigmastate/trees.scala +++ b/interpreter/shared/src/main/scala/sigmastate/trees.scala @@ -3,10 +3,10 @@ package sigmastate import debox.{cfor, Map => DMap} import org.ergoplatform.SigmaConstants import org.ergoplatform.validation.SigmaValidationSettings -import sigma.core.ExactIntegral._ -import sigma.core.ExactOrdering._ -import sigma.core.OverloadHack.Overloaded1 -import sigma.core.{ExactIntegral, ExactOrdering} +import sigma.data.ExactIntegral._ +import sigma.data.ExactOrdering._ +import sigma.data.OverloadHack.Overloaded1 +import sigma.data.{ExactIntegral, ExactOrdering} import scorex.crypto.hash.{Blake2b256, CryptographicHash32, Sha256} import sigma.VersionContext import sigmastate.ArithOp.OperationImpl diff --git a/interpreter/shared/src/main/scala/sigmastate/types.scala b/interpreter/shared/src/main/scala/sigmastate/types.scala index ae3d316e95..99c730167a 100644 --- a/interpreter/shared/src/main/scala/sigmastate/types.scala +++ b/interpreter/shared/src/main/scala/sigmastate/types.scala @@ -3,8 +3,8 @@ package sigmastate import java.math.BigInteger import org.ergoplatform._ import org.ergoplatform.validation._ -import sigma.core.{Nullable, RType} -import sigma.core.GeneralType +import sigma.data.{Nullable, RType} +import sigma.data.GeneralType import sigmastate.SType.TypeCode import sigmastate.interpreter._ import sigmastate.utils.Overloading.Overload1 diff --git a/interpreter/shared/src/main/scala/sigmastate/utils/Helpers.scala b/interpreter/shared/src/main/scala/sigmastate/utils/Helpers.scala index b689c59f66..b6427c880b 100644 --- a/interpreter/shared/src/main/scala/sigmastate/utils/Helpers.scala +++ b/interpreter/shared/src/main/scala/sigmastate/utils/Helpers.scala @@ -3,7 +3,7 @@ package sigmastate.utils import debox.cfor import io.circe.Decoder import org.ergoplatform.settings.ErgoAlgos -import sigma.core.{OverloadHack, RType} +import sigma.data.{OverloadHack, RType} import scorex.utils.Ints import sigma.Environment import sigmastate.eval.{CAnyValue, Colls, SigmaDsl} diff --git a/interpreter/shared/src/main/scala/sigmastate/utxo/transformers.scala b/interpreter/shared/src/main/scala/sigmastate/utxo/transformers.scala index a8e4b2d233..8150359eb1 100644 --- a/interpreter/shared/src/main/scala/sigmastate/utxo/transformers.scala +++ b/interpreter/shared/src/main/scala/sigmastate/utxo/transformers.scala @@ -7,7 +7,7 @@ import sigmastate._ import sigmastate.serialization.OpCodes.OpCode import sigmastate.serialization.OpCodes import org.ergoplatform.ErgoBox.RegisterId -import sigma.core.RType +import sigma.data.RType import sigmastate.Operations._ import sigmastate.eval.{Evaluation, SigmaDsl} import sigmastate.exceptions.InterpreterException diff --git a/interpreter/shared/src/test/scala/sigmastate/lang/SigmaBuilderTest.scala b/interpreter/shared/src/test/scala/sigmastate/lang/SigmaBuilderTest.scala index 779b7f33eb..657ded51ce 100644 --- a/interpreter/shared/src/test/scala/sigmastate/lang/SigmaBuilderTest.scala +++ b/interpreter/shared/src/test/scala/sigmastate/lang/SigmaBuilderTest.scala @@ -3,7 +3,7 @@ package sigmastate.lang import org.scalatest.matchers.should.Matchers import org.scalatest.propspec.AnyPropSpec import org.scalatestplus.scalacheck.ScalaCheckPropertyChecks -import sigma.core.{Nullable, RType} +import sigma.data.{Nullable, RType} import sigma.{Environment, VersionContext} import sigmastate.Values._ import sigmastate._ diff --git a/interpreter/shared/src/test/scala/sigmastate/serialization/ConstantSerializerSpecification.scala b/interpreter/shared/src/test/scala/sigmastate/serialization/ConstantSerializerSpecification.scala index 92813e44cf..23c4f69201 100644 --- a/interpreter/shared/src/test/scala/sigmastate/serialization/ConstantSerializerSpecification.scala +++ b/interpreter/shared/src/test/scala/sigmastate/serialization/ConstantSerializerSpecification.scala @@ -3,7 +3,7 @@ package sigmastate.serialization import java.math.BigInteger import org.ergoplatform._ import org.scalacheck.Arbitrary._ -import sigma.core.RType +import sigma.data.RType import sigmastate.SCollection.SByteArray import sigmastate.Values.{BigIntConstant, ByteArrayConstant, Constant, FalseLeaf, GroupGenerator, LongConstant, SValue, TrueLeaf} import sigmastate.crypto.CryptoConstants.EcPointType diff --git a/interpreter/shared/src/test/scala/sigmastate/serialization/DataSerializerSpecification.scala b/interpreter/shared/src/test/scala/sigmastate/serialization/DataSerializerSpecification.scala index 1dee51c26f..eba0e9b90c 100644 --- a/interpreter/shared/src/test/scala/sigmastate/serialization/DataSerializerSpecification.scala +++ b/interpreter/shared/src/test/scala/sigmastate/serialization/DataSerializerSpecification.scala @@ -3,7 +3,7 @@ package sigmastate.serialization import java.math.BigInteger import org.ergoplatform.ErgoBox import org.scalacheck.Arbitrary._ -import sigma.core.RType +import sigma.data.RType import sigmastate.SCollection.SByteArray import sigmastate.Values.{ErgoTree, SigmaBoolean} import sigmastate._ diff --git a/interpreter/shared/src/test/scala/sigmastate/serialization/generators/ObjectGenerators.scala b/interpreter/shared/src/test/scala/sigmastate/serialization/generators/ObjectGenerators.scala index f8f8ccf614..4c57f86246 100644 --- a/interpreter/shared/src/test/scala/sigmastate/serialization/generators/ObjectGenerators.scala +++ b/interpreter/shared/src/test/scala/sigmastate/serialization/generators/ObjectGenerators.scala @@ -8,7 +8,7 @@ import org.scalacheck.Arbitrary._ import org.scalacheck.Gen.{choose, frequency} import org.scalacheck.util.Buildable import org.scalacheck.{Arbitrary, Gen} -import sigma.core.RType +import sigma.data.RType import scorex.crypto.authds.{ADDigest, ADKey} import scorex.util.encode.{Base58, Base64} import scorex.util.{ModifierId, bytesToId} diff --git a/interpreter/shared/src/test/scala/special/sigma/ContractsTestkit.scala b/interpreter/shared/src/test/scala/special/sigma/ContractsTestkit.scala index 928632dd29..a1226b1d03 100644 --- a/interpreter/shared/src/test/scala/special/sigma/ContractsTestkit.scala +++ b/interpreter/shared/src/test/scala/special/sigma/ContractsTestkit.scala @@ -1,12 +1,12 @@ package sigma -import sigma.core.RType +import sigma.data.RType import sigmastate.Values.ErgoTree import sigmastate.{AvlTreeData, Values} import sigmastate.eval._ import sigmastate.eval.Extensions._ import sigmastate.helpers.TestingHelpers._ -import sigma.core._ +import sigma.data._ import scala.annotation.nowarn // imports implicit ClassTag diff --git a/interpreter/shared/src/test/scala/special/sigma/SigmaTestingData.scala b/interpreter/shared/src/test/scala/special/sigma/SigmaTestingData.scala index c4c207d44c..5c7827b5cc 100644 --- a/interpreter/shared/src/test/scala/special/sigma/SigmaTestingData.scala +++ b/interpreter/shared/src/test/scala/special/sigma/SigmaTestingData.scala @@ -6,7 +6,7 @@ import org.scalacheck.Arbitrary.arbitrary import org.scalacheck.Gen.containerOfN import org.scalacheck.util.Buildable import org.scalacheck.{Arbitrary, Gen} -import sigma.core.RType +import sigma.data.RType import scorex.crypto.authds.{ADKey, ADValue} import scorex.crypto.hash.{Blake2b256, Digest32} import scorex.util.ModifierId diff --git a/parsers/shared/src/main/scala/sigmastate/lang/SigmaParser.scala b/parsers/shared/src/main/scala/sigmastate/lang/SigmaParser.scala index a218f24347..155e4ab879 100644 --- a/parsers/shared/src/main/scala/sigmastate/lang/SigmaParser.scala +++ b/parsers/shared/src/main/scala/sigmastate/lang/SigmaParser.scala @@ -3,7 +3,7 @@ package sigmastate.lang import fastparse.internal.Logger import sigmastate._ import Values._ -import sigma.core.Nullable +import sigma.data.Nullable import sigmastate.lang.Terms._ import sigmastate.lang.syntax.Basic._ import sigmastate.lang.syntax.{Core, Exprs} diff --git a/parsers/shared/src/main/scala/sigmastate/lang/syntax/Basic.scala b/parsers/shared/src/main/scala/sigmastate/lang/syntax/Basic.scala index cae64d2c80..55bdd4e399 100644 --- a/parsers/shared/src/main/scala/sigmastate/lang/syntax/Basic.scala +++ b/parsers/shared/src/main/scala/sigmastate/lang/syntax/Basic.scala @@ -3,7 +3,7 @@ package sigmastate.lang.syntax import fastparse._ import NoWhitespace._ import fastparse.CharPredicates._ -import sigma.core.Nullable +import sigma.data.Nullable import sigmastate.lang.SourceContext import sigmastate.exceptions.CompilerException diff --git a/sc/jvm/src/test/scala/sigmastate/helpers/SigmaPPrintSpec.scala b/sc/jvm/src/test/scala/sigmastate/helpers/SigmaPPrintSpec.scala index 38feb207b6..5a2c65d565 100644 --- a/sc/jvm/src/test/scala/sigmastate/helpers/SigmaPPrintSpec.scala +++ b/sc/jvm/src/test/scala/sigmastate/helpers/SigmaPPrintSpec.scala @@ -2,7 +2,7 @@ package sigmastate.helpers import org.ergoplatform.settings.ErgoAlgos import org.ergoplatform.{ErgoBox, Outputs} -import sigma.core.{CollType, RType} +import sigma.data.{CollType, RType} import scorex.util.ModifierId import sigmastate.Values._ import sigmastate._ diff --git a/sc/jvm/src/test/scala/special/collections/MapBenchmark.scala b/sc/jvm/src/test/scala/special/collections/MapBenchmark.scala index 2bbe149ccc..1b737729ad 100644 --- a/sc/jvm/src/test/scala/special/collections/MapBenchmark.scala +++ b/sc/jvm/src/test/scala/special/collections/MapBenchmark.scala @@ -1,7 +1,7 @@ package sigma import org.scalameter.api.Bench -import sigma.core.{AVHashMap, Nullable} +import sigma.data.{AVHashMap, Nullable} import debox.cfor trait MapBenchmarkCases extends BenchmarkGens { suite: Bench[Double] => diff --git a/sc/shared/src/main/scala/org/ergoplatform/dsl/ContractSpec.scala b/sc/shared/src/main/scala/org/ergoplatform/dsl/ContractSpec.scala index 95be10d40c..98b8a79bba 100644 --- a/sc/shared/src/main/scala/org/ergoplatform/dsl/ContractSpec.scala +++ b/sc/shared/src/main/scala/org/ergoplatform/dsl/ContractSpec.scala @@ -2,7 +2,7 @@ package org.ergoplatform.dsl import org.ergoplatform.ErgoBox.{BoxId, NonMandatoryRegisterId, TokenId} import sigmastate.interpreter.{CostedProverResult, ProverResult} -import sigma.core.RType +import sigma.data.RType import org.ergoplatform.{ErgoLikeContext, ErgoBox} import sigma.{SigmaDslBuilder, AnyValue, SigmaProp} import sigmastate.Values.ErgoTree diff --git a/sc/shared/src/main/scala/org/ergoplatform/dsl/ContractSyntax.scala b/sc/shared/src/main/scala/org/ergoplatform/dsl/ContractSyntax.scala index 135799520c..665899cb5c 100644 --- a/sc/shared/src/main/scala/org/ergoplatform/dsl/ContractSyntax.scala +++ b/sc/shared/src/main/scala/org/ergoplatform/dsl/ContractSyntax.scala @@ -1,7 +1,7 @@ package org.ergoplatform.dsl import org.ergoplatform.ErgoBox.TokenId -import sigma.core.RType +import sigma.data.RType import sigmastate.SType import sigmastate.SType.AnyOps import org.ergoplatform.dsl.ContractSyntax.{ErgoScript, Proposition} diff --git a/sc/shared/src/main/scala/scalan/Base.scala b/sc/shared/src/main/scala/scalan/Base.scala index e5705aa508..46f8557dd7 100644 --- a/sc/shared/src/main/scala/scalan/Base.scala +++ b/sc/shared/src/main/scala/scalan/Base.scala @@ -1,8 +1,8 @@ package scalan import debox.{cfor, Buffer => DBuffer} -import sigma.core.{AVHashMap, Nullable, RType} -import sigma.core.OverloadHack.Overloaded1 +import sigma.data.{AVHashMap, Nullable, RType} +import sigma.data.OverloadHack.Overloaded1 import sigma.util.StringUtil import sigma.reflection.RConstructor diff --git a/sc/shared/src/main/scala/scalan/DefRewriting.scala b/sc/shared/src/main/scala/scalan/DefRewriting.scala index 94c5dda699..fe63bb6b2b 100644 --- a/sc/shared/src/main/scala/scalan/DefRewriting.scala +++ b/sc/shared/src/main/scala/scalan/DefRewriting.scala @@ -1,6 +1,6 @@ package scalan -import sigma.core.ExactNumeric +import sigma.data.ExactNumeric trait DefRewriting { scalan: Scalan => diff --git a/sc/shared/src/main/scala/scalan/GraphIRReflection.scala b/sc/shared/src/main/scala/scalan/GraphIRReflection.scala index 711629b318..2b1e8c95b6 100644 --- a/sc/shared/src/main/scala/scalan/GraphIRReflection.scala +++ b/sc/shared/src/main/scala/scalan/GraphIRReflection.scala @@ -7,7 +7,7 @@ import sigma.CoreLibReflection import sigmastate.eval.SigmaLibrary import sigma.Colls import sigma.SigmaDsl -import sigma.core.RType +import sigma.data.RType import special.wrappers.{OptionWrapSpec, RTypeWrapSpec} import wrappers.scalan.WRTypes diff --git a/sc/shared/src/main/scala/scalan/Library.scala b/sc/shared/src/main/scala/scalan/Library.scala index e3b3bc592a..ee1ff80ad3 100644 --- a/sc/shared/src/main/scala/scalan/Library.scala +++ b/sc/shared/src/main/scala/scalan/Library.scala @@ -2,7 +2,7 @@ package scalan import scala.language.implicitConversions import sigma._ -import sigma.core.{Nullable, RType} +import sigma.data.{Nullable, RType} import special.wrappers.WrappersModule import sigma.util.MemoizedFunc diff --git a/sc/shared/src/main/scala/scalan/TypeDescs.scala b/sc/shared/src/main/scala/scalan/TypeDescs.scala index 9543f96b5c..cb5f954109 100644 --- a/sc/shared/src/main/scala/scalan/TypeDescs.scala +++ b/sc/shared/src/main/scala/scalan/TypeDescs.scala @@ -3,12 +3,12 @@ package scalan import scala.language.implicitConversions import scala.annotation.implicitNotFound import scala.collection.immutable.ListMap -import sigma.core.RType._ +import sigma.data.RType._ import scala.collection.mutable import debox.cfor import scalan.core.{Contravariant, Covariant, Variance} -import sigma.core.{AVHashMap, Lazy, Nullable, RType} +import sigma.data.{AVHashMap, Lazy, Nullable, RType} import sigma.reflection.{RClass, RConstructor, RMethod} import sigma.util.CollectionUtil import special.wrappers.WrapSpec @@ -70,7 +70,7 @@ abstract class TypeDescs extends Base { self: Scalan => // TODO optimize performance hot spot (45% of invokeUnlifted time), reduce allocation of Some final def getSourceValues(dataEnv: DataEnv, forWrapper: Boolean, stagedValues: AnyRef*): Seq[AnyRef] = { - import sigma.core.OverloadHack._ + import sigma.data.OverloadHack._ val limit = stagedValues.length val res = mutable.ArrayBuilder.make[AnyRef] res.sizeHint(limit) diff --git a/sc/shared/src/main/scala/scalan/primitives/Functions.scala b/sc/shared/src/main/scala/scalan/primitives/Functions.scala index 011a96df98..e5cd6f345e 100644 --- a/sc/shared/src/main/scala/scalan/primitives/Functions.scala +++ b/sc/shared/src/main/scala/scalan/primitives/Functions.scala @@ -7,7 +7,7 @@ import debox.{Buffer => DBuffer} import scala.language.implicitConversions import debox.cfor -import sigma.core.{Lazy, Nullable, emptyDBufferOfInt} +import sigma.data.{Lazy, Nullable, emptyDBufferOfInt} import sigma.util.GraphUtil trait Functions extends Base with ProgramGraphs { self: Scalan => diff --git a/sc/shared/src/main/scala/scalan/primitives/NumericOps.scala b/sc/shared/src/main/scala/scalan/primitives/NumericOps.scala index 018e5dae4e..3c3d80e94d 100644 --- a/sc/shared/src/main/scala/scalan/primitives/NumericOps.scala +++ b/sc/shared/src/main/scala/scalan/primitives/NumericOps.scala @@ -1,7 +1,7 @@ package scalan.primitives import scalan.{Base, Scalan} -import sigma.core.{ExactIntegral, ExactNumeric} +import sigma.data.{ExactIntegral, ExactNumeric} /** Slice in Scala cake with definitions of numeric operations. */ trait NumericOps extends Base { self: Scalan => diff --git a/sc/shared/src/main/scala/scalan/primitives/OrderingOps.scala b/sc/shared/src/main/scala/scalan/primitives/OrderingOps.scala index 1f1a4a1ac1..8e6f5e0134 100644 --- a/sc/shared/src/main/scala/scalan/primitives/OrderingOps.scala +++ b/sc/shared/src/main/scala/scalan/primitives/OrderingOps.scala @@ -1,7 +1,7 @@ package scalan.primitives import scalan.{Base, Scalan} -import sigma.core.ExactOrdering +import sigma.data.ExactOrdering import scala.language.implicitConversions diff --git a/sc/shared/src/main/scala/scalan/primitives/Thunks.scala b/sc/shared/src/main/scala/scalan/primitives/Thunks.scala index 88dcd0d0ca..ce51dc5638 100644 --- a/sc/shared/src/main/scala/scalan/primitives/Thunks.scala +++ b/sc/shared/src/main/scala/scalan/primitives/Thunks.scala @@ -5,7 +5,7 @@ import scalan._ import debox.{Buffer => DBuffer, Set => DSet} import debox.cfor import scalan.core.Covariant -import sigma.core.{AVHashMap, DFunc, Lazy, Nullable, RType} +import sigma.data.{AVHashMap, DFunc, Lazy, Nullable, RType} import sigma.reflection.RClass import sigma.util.GraphUtil @@ -82,7 +82,7 @@ trait Thunks extends Functions { self: Scalan => /** Implementation of Liftable type class for `Thunk[T]` given liftable for `T`. */ case class LiftableThunk[ST, T](lT: Liftable[ST, T]) extends Liftable[SThunk[ST], Thunk[T]] { - import sigma.core.RType._ + import sigma.data.RType._ override def eW: Elem[Thunk[T]] = thunkElement(lT.eW) override def sourceType: RType[SThunk[ST]] = { implicit val tST = lT.sourceType diff --git a/sc/shared/src/main/scala/scalan/primitives/Tuples.scala b/sc/shared/src/main/scala/scalan/primitives/Tuples.scala index 4e47e28e6b..c22b8a31f4 100644 --- a/sc/shared/src/main/scala/scalan/primitives/Tuples.scala +++ b/sc/shared/src/main/scala/scalan/primitives/Tuples.scala @@ -6,7 +6,7 @@ package scalan.primitives import scalan.{Base, Scalan} import scala.language.implicitConversions -import sigma.core.{AVHashMap} +import sigma.data.{AVHashMap} trait Tuples extends Base { self: Scalan => object Pair { diff --git a/sc/shared/src/main/scala/scalan/staged/AstGraphs.scala b/sc/shared/src/main/scala/scalan/staged/AstGraphs.scala index 090fedeaae..7ad5c24f17 100644 --- a/sc/shared/src/main/scala/scalan/staged/AstGraphs.scala +++ b/sc/shared/src/main/scala/scalan/staged/AstGraphs.scala @@ -4,7 +4,7 @@ import scala.collection._ import scalan.Scalan import debox.cfor import debox.{Buffer => DBuffer, Map => DMap, Set => DSet} -import sigma.core.emptyDBufferOfInt +import sigma.data.emptyDBufferOfInt trait AstGraphs extends Transforming { self: Scalan => diff --git a/sc/shared/src/main/scala/scalan/staged/ProgramGraphs.scala b/sc/shared/src/main/scala/scalan/staged/ProgramGraphs.scala index b0654e7fa9..19d762c5bb 100644 --- a/sc/shared/src/main/scala/scalan/staged/ProgramGraphs.scala +++ b/sc/shared/src/main/scala/scalan/staged/ProgramGraphs.scala @@ -4,7 +4,7 @@ import scalan.Scalan import debox.{Buffer => DBuffer} import sigma.util.GraphUtil import debox.cfor -import sigma.core.{DFunc, Nullable} +import sigma.data.{DFunc, Nullable} import scala.collection.compat.immutable.ArraySeq trait ProgramGraphs extends AstGraphs { self: Scalan => diff --git a/sc/shared/src/main/scala/scalan/staged/Transforming.scala b/sc/shared/src/main/scala/scalan/staged/Transforming.scala index d1f458b19b..045340e503 100644 --- a/sc/shared/src/main/scala/scalan/staged/Transforming.scala +++ b/sc/shared/src/main/scala/scalan/staged/Transforming.scala @@ -5,7 +5,7 @@ import scala.language.existentials import scalan.Scalan import debox.{Buffer => DBuffer} import debox.cfor -import sigma.core.{Lazy, Nullable} +import sigma.data.{Lazy, Nullable} import sigma.reflection.RMethod trait Transforming { self: Scalan => diff --git a/sc/shared/src/main/scala/sigmastate/eval/GraphBuilding.scala b/sc/shared/src/main/scala/sigmastate/eval/GraphBuilding.scala index e560655812..99467289f2 100644 --- a/sc/shared/src/main/scala/sigmastate/eval/GraphBuilding.scala +++ b/sc/shared/src/main/scala/sigmastate/eval/GraphBuilding.scala @@ -2,10 +2,10 @@ package sigmastate.eval import org.ergoplatform._ import scalan.MutableLazy -import sigma.core.ExactIntegral.{ByteIsExactIntegral, IntIsExactIntegral, LongIsExactIntegral, ShortIsExactIntegral} -import sigma.core.ExactOrdering.{ByteIsExactOrdering, IntIsExactOrdering, LongIsExactOrdering, ShortIsExactOrdering} +import sigma.data.ExactIntegral.{ByteIsExactIntegral, IntIsExactIntegral, LongIsExactIntegral, ShortIsExactIntegral} +import sigma.data.ExactOrdering.{ByteIsExactOrdering, IntIsExactOrdering, LongIsExactOrdering, ShortIsExactOrdering} import sigma.util.Extensions.ByteOps -import sigma.core.{ExactIntegral, ExactNumeric, ExactOrdering, Lazy, Nullable} +import sigma.data.{ExactIntegral, ExactNumeric, ExactOrdering, Lazy, Nullable} import sigmastate.Values.Value.Typed import sigmastate.Values._ import sigmastate.interpreter.Interpreter.ScriptEnv diff --git a/sc/shared/src/main/scala/sigmastate/lang/SigmaBinder.scala b/sc/shared/src/main/scala/sigmastate/lang/SigmaBinder.scala index 4f006e7223..3295429ffe 100644 --- a/sc/shared/src/main/scala/sigmastate/lang/SigmaBinder.scala +++ b/sc/shared/src/main/scala/sigmastate/lang/SigmaBinder.scala @@ -2,7 +2,7 @@ package sigmastate.lang import org.ergoplatform.ErgoAddressEncoder.NetworkPrefix import org.ergoplatform._ -import sigma.core.Nullable +import sigma.data.Nullable import sigma.kiama.rewriting.CallbackRewriter import sigmastate.Values._ import sigmastate._ diff --git a/sc/shared/src/main/scala/sigmastate/lang/SigmaTyper.scala b/sc/shared/src/main/scala/sigmastate/lang/SigmaTyper.scala index 62e8fd75a1..beb17a98b0 100644 --- a/sc/shared/src/main/scala/sigmastate/lang/SigmaTyper.scala +++ b/sc/shared/src/main/scala/sigmastate/lang/SigmaTyper.scala @@ -5,7 +5,7 @@ import sigmastate.SCollection._ import sigmastate.Values._ import sigmastate._ import SCollection.SBooleanArray -import sigma.core.Nullable +import sigma.data.Nullable import sigma.util.Extensions.Ensuring import sigmastate.lang.Terms._ import sigmastate.exceptions._ diff --git a/sc/shared/src/main/scala/special/collection/impl/CollsImpl.scala b/sc/shared/src/main/scala/special/collection/impl/CollsImpl.scala index 0525101ee8..881b1c750c 100644 --- a/sc/shared/src/main/scala/special/collection/impl/CollsImpl.scala +++ b/sc/shared/src/main/scala/special/collection/impl/CollsImpl.scala @@ -5,7 +5,7 @@ import scalan._ import scala.collection.compat.immutable.ArraySeq package impl { - import sigma.core.{Nullable, RType} + import sigma.data.{Nullable, RType} import sigma.reflection.{RClass, RMethod} // Abs ----------------------------------- diff --git a/sc/shared/src/main/scala/special/sigma/impl/SigmaDslImpl.scala b/sc/shared/src/main/scala/special/sigma/impl/SigmaDslImpl.scala index 1505efbb00..e2ce41ad1e 100644 --- a/sc/shared/src/main/scala/special/sigma/impl/SigmaDslImpl.scala +++ b/sc/shared/src/main/scala/special/sigma/impl/SigmaDslImpl.scala @@ -7,7 +7,7 @@ import sigmastate.eval.SigmaLibrary import scala.collection.compat.immutable.ArraySeq package impl { - import sigma.core.{Nullable, RType} + import sigma.data.{Nullable, RType} import sigma.reflection.{RClass, RMethod} import sigmastate.eval.SigmaLibrary diff --git a/sc/shared/src/main/scala/special/wrappers/WrappersSpec.scala b/sc/shared/src/main/scala/special/wrappers/WrappersSpec.scala index 8c25fe1eb5..d520ce9006 100644 --- a/sc/shared/src/main/scala/special/wrappers/WrappersSpec.scala +++ b/sc/shared/src/main/scala/special/wrappers/WrappersSpec.scala @@ -1,6 +1,6 @@ package special.wrappers -import sigma.core.RType +import sigma.data.RType /** Base class for wrappers of such types as WOption, WRType etc. * Used in graph IR to implement method invocation. diff --git a/sc/shared/src/main/scala/wrappers/scala/impl/WOptionsImpl.scala b/sc/shared/src/main/scala/wrappers/scala/impl/WOptionsImpl.scala index fe8dd78f7e..45d0a91ad6 100644 --- a/sc/shared/src/main/scala/wrappers/scala/impl/WOptionsImpl.scala +++ b/sc/shared/src/main/scala/wrappers/scala/impl/WOptionsImpl.scala @@ -7,7 +7,7 @@ import special.wrappers.OptionWrapSpec import scala.collection.compat.immutable.ArraySeq package impl { - import sigma.core.{Nullable, RType} + import sigma.data.{Nullable, RType} import sigma.reflection.{RClass, RMethod} // Abs ----------------------------------- diff --git a/sc/shared/src/main/scala/wrappers/scalan/WRTypes.scala b/sc/shared/src/main/scala/wrappers/scalan/WRTypes.scala index a9f0335ae9..0d55f5dd9e 100644 --- a/sc/shared/src/main/scala/wrappers/scalan/WRTypes.scala +++ b/sc/shared/src/main/scala/wrappers/scalan/WRTypes.scala @@ -3,7 +3,7 @@ package wrappers.scalan { import impl._ - import sigma.core.RType + import sigma.data.RType import special.wrappers.WrappersModule diff --git a/sc/shared/src/main/scala/wrappers/scalan/impl/WRTypesImpl.scala b/sc/shared/src/main/scala/wrappers/scalan/impl/WRTypesImpl.scala index 5fa2ec3e8a..9b2676f70d 100644 --- a/sc/shared/src/main/scala/wrappers/scalan/impl/WRTypesImpl.scala +++ b/sc/shared/src/main/scala/wrappers/scalan/impl/WRTypesImpl.scala @@ -1,7 +1,7 @@ package wrappers.scalan import scala.language.{existentials,implicitConversions} -import sigma.core.RType +import sigma.data.RType import special.wrappers.WrappersModule import special.wrappers.RTypeWrapSpec import scala.collection.compat.immutable.ArraySeq diff --git a/sc/shared/src/main/scala/wrappers/special/impl/WSpecialPredefsImpl.scala b/sc/shared/src/main/scala/wrappers/special/impl/WSpecialPredefsImpl.scala index 0efa5348da..1f80e71676 100644 --- a/sc/shared/src/main/scala/wrappers/special/impl/WSpecialPredefsImpl.scala +++ b/sc/shared/src/main/scala/wrappers/special/impl/WSpecialPredefsImpl.scala @@ -5,7 +5,7 @@ import scalan._ import special.wrappers.WrappersModule package impl { - import sigma.core.Nullable + import sigma.data.Nullable import sigma.reflection.RClass // Abs ----------------------------------- diff --git a/sc/shared/src/test/scala/org/ergoplatform/dsl/TestContractSpec.scala b/sc/shared/src/test/scala/org/ergoplatform/dsl/TestContractSpec.scala index 8d260ccee0..46668c3b1a 100644 --- a/sc/shared/src/test/scala/org/ergoplatform/dsl/TestContractSpec.scala +++ b/sc/shared/src/test/scala/org/ergoplatform/dsl/TestContractSpec.scala @@ -7,7 +7,7 @@ import sigmastate.interpreter.{CostedProverResult, ProverResult} import scala.collection.mutable.ArrayBuffer import org.ergoplatform.ErgoBox.{NonMandatoryRegisterId, TokenId} -import sigma.core.Nullable +import sigma.data.Nullable import scala.util.Try import org.ergoplatform.{ErgoBox, ErgoLikeContext} diff --git a/sc/shared/src/test/scala/sigma/DataValueComparerSpecification.scala b/sc/shared/src/test/scala/sigma/DataValueComparerSpecification.scala index 8749d6e52a..df3c5dc7ed 100644 --- a/sc/shared/src/test/scala/sigma/DataValueComparerSpecification.scala +++ b/sc/shared/src/test/scala/sigma/DataValueComparerSpecification.scala @@ -1,7 +1,7 @@ package sigma import org.scalatest.BeforeAndAfterAll -import sigma.core.RType +import sigma.data.RType import sigma.util.BenchmarkUtil import sigmastate.{DataValueComparer, JitCost, TrivialProp} import sigmastate.Values.ErgoTree diff --git a/sc/shared/src/test/scala/sigma/SigmaDslSpecification.scala b/sc/shared/src/test/scala/sigma/SigmaDslSpecification.scala index 6a90429e20..f5c47a055f 100644 --- a/sc/shared/src/test/scala/sigma/SigmaDslSpecification.scala +++ b/sc/shared/src/test/scala/sigma/SigmaDslSpecification.scala @@ -4,7 +4,7 @@ import java.math.BigInteger import org.ergoplatform._ import org.ergoplatform.settings.ErgoAlgos import org.scalacheck.{Arbitrary, Gen} -import sigma.core.{ExactIntegral, ExactNumeric, ExactOrdering, RType} +import sigma.data.{ExactIntegral, ExactNumeric, ExactOrdering, RType} import scorex.crypto.authds.avltree.batch._ import scorex.crypto.authds.{ADKey, ADValue} import scorex.crypto.hash.{Blake2b256, Digest32} @@ -33,7 +33,7 @@ import org.ergoplatform.ErgoBox.AdditionalRegisters import org.scalacheck.Arbitrary._ import org.scalacheck.Gen.frequency import org.scalatest.{BeforeAndAfterAll, Tag} -import sigma.core.RType._ +import sigma.data.RType._ import scorex.util.ModifierId import sigmastate.crypto.ProveDHTuple import sigmastate.interpreter._ diff --git a/sc/shared/src/test/scala/sigma/SigmaDslTesting.scala b/sc/shared/src/test/scala/sigma/SigmaDslTesting.scala index f738444dcf..2d93ff597c 100644 --- a/sc/shared/src/test/scala/sigma/SigmaDslTesting.scala +++ b/sc/shared/src/test/scala/sigma/SigmaDslTesting.scala @@ -13,7 +13,7 @@ import org.scalatest.matchers.should.Matchers import org.scalatest.propspec.AnyPropSpec import org.scalatestplus.scalacheck.ScalaCheckPropertyChecks import scalan.Platform.threadSleepOrNoOp -import sigma.core.{CollType, OptionType, PairType, RType} +import sigma.data.{CollType, OptionType, PairType, RType} import sigma.util.BenchmarkUtil import sigma.util.CollectionUtil._ import sigma.util.Extensions._ diff --git a/sc/shared/src/test/scala/sigmastate/ErgoTreeSpecification.scala b/sc/shared/src/test/scala/sigmastate/ErgoTreeSpecification.scala index 9e8f5d7fb3..8c909d1695 100644 --- a/sc/shared/src/test/scala/sigmastate/ErgoTreeSpecification.scala +++ b/sc/shared/src/test/scala/sigmastate/ErgoTreeSpecification.scala @@ -3,8 +3,8 @@ package sigmastate import org.ergoplatform.settings.ErgoAlgos import org.ergoplatform.validation.{ValidationException, ValidationRules} import org.ergoplatform.{ErgoAddressEncoder, ErgoBox, ErgoLikeContext, Self} -import sigma.core.RType.asType -import sigma.core.{Nullable, RType} +import sigma.data.RType.asType +import sigma.data.{Nullable, RType} import sigma.VersionContext import sigmastate.SCollection.{SByteArray, checkValidFlatmap} import sigmastate.Values._ diff --git a/sc/shared/src/test/scala/sigmastate/helpers/CompilerTestingCommons.scala b/sc/shared/src/test/scala/sigmastate/helpers/CompilerTestingCommons.scala index 2af556d8ab..51ddde1afa 100644 --- a/sc/shared/src/test/scala/sigmastate/helpers/CompilerTestingCommons.scala +++ b/sc/shared/src/test/scala/sigmastate/helpers/CompilerTestingCommons.scala @@ -9,7 +9,7 @@ import org.scalatest.Assertion import sigma.util.BenchmarkUtil import scalan.TestContexts import sigma.TestUtils -import sigma.core.RType +import sigma.data.RType import sigmastate.Values.{Constant, ErgoTree, SValue, SigmaBoolean, SigmaPropValue} import sigmastate.eval._ import sigmastate.helpers.TestingHelpers._ diff --git a/sc/shared/src/test/scala/sigmastate/helpers/SigmaPPrint.scala b/sc/shared/src/test/scala/sigmastate/helpers/SigmaPPrint.scala index 576d670528..690630d327 100644 --- a/sc/shared/src/test/scala/sigmastate/helpers/SigmaPPrint.scala +++ b/sc/shared/src/test/scala/sigmastate/helpers/SigmaPPrint.scala @@ -4,7 +4,7 @@ import org.ergoplatform.ErgoBox import org.ergoplatform.ErgoBox.RegisterId import org.ergoplatform.settings.ErgoAlgos import pprint.{PPrinter, Tree} -import sigma.core.{CollType, PrimitiveType} +import sigma.data.{CollType, PrimitiveType} import sigma.{Coll, GroupElement} import sigmastate.SCollection._ import sigmastate.Values.{ConstantNode, ErgoTree, FuncValue, ValueCompanion} diff --git a/sc/shared/src/test/scala/sigmastate/utxo/BasicOpsSpecification.scala b/sc/shared/src/test/scala/sigmastate/utxo/BasicOpsSpecification.scala index 004564cf9f..eddd607178 100644 --- a/sc/shared/src/test/scala/sigmastate/utxo/BasicOpsSpecification.scala +++ b/sc/shared/src/test/scala/sigmastate/utxo/BasicOpsSpecification.scala @@ -3,7 +3,7 @@ package sigmastate.utxo import java.math.BigInteger import org.ergoplatform.ErgoBox.{AdditionalRegisters, R6, R8} import org.ergoplatform._ -import sigma.core.RType +import sigma.data.RType import sigmastate.SCollection.SByteArray import sigmastate.Values._ import sigmastate._ diff --git a/sc/shared/src/test/scala/special/wrappers/WRTypeTests.scala b/sc/shared/src/test/scala/special/wrappers/WRTypeTests.scala index 86fe106075..51c7231935 100644 --- a/sc/shared/src/test/scala/special/wrappers/WRTypeTests.scala +++ b/sc/shared/src/test/scala/special/wrappers/WRTypeTests.scala @@ -1,6 +1,6 @@ package special.wrappers -import sigma.core.RType +import sigma.data.RType import scala.language.reflectiveCalls diff --git a/sc/shared/src/test/scala/special/wrappers/WSpecialPredefTests.scala b/sc/shared/src/test/scala/special/wrappers/WSpecialPredefTests.scala index f3e07be7d9..e1097ebf6c 100644 --- a/sc/shared/src/test/scala/special/wrappers/WSpecialPredefTests.scala +++ b/sc/shared/src/test/scala/special/wrappers/WSpecialPredefTests.scala @@ -2,7 +2,7 @@ package special.wrappers import scala.language.reflectiveCalls -import sigma.core.RType +import sigma.data.RType class WSpecialPredefTests extends WrappersTests { diff --git a/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Isos.scala b/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Isos.scala index dedaa1fcd0..0367ad54cc 100644 --- a/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Isos.scala +++ b/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Isos.scala @@ -5,7 +5,7 @@ import org.ergoplatform.sdk.JavaHelpers.UniversalConverter import org.ergoplatform.sdk.{ExtendedInputBox, Iso} import org.ergoplatform.sdk.wallet.protocol.context import org.ergoplatform._ -import sigma.core.RType +import sigma.data.RType import scorex.crypto.authds.ADKey import scorex.util.ModifierId import scorex.util.encode.Base16 diff --git a/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Type.scala b/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Type.scala index 5c79513f9c..a0930cc99a 100644 --- a/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Type.scala +++ b/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Type.scala @@ -1,6 +1,6 @@ package org.ergoplatform.sdk.js -import sigma.core.RType +import sigma.data.RType import scala.scalajs.js import scala.scalajs.js.annotation.JSExportTopLevel diff --git a/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Value.scala b/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Value.scala index 556c0f4cf2..6bcae003fa 100644 --- a/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Value.scala +++ b/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Value.scala @@ -1,8 +1,8 @@ package org.ergoplatform.sdk.js import org.ergoplatform.sdk.js.Value.toRuntimeData -import sigma.core.{CollType, RType} -import sigma.core.PairType +import sigma.data.{CollType, RType} +import sigma.data.PairType import scorex.util.Extensions.{IntOps, LongOps} import scorex.util.encode.Base16 import sigmastate.SType diff --git a/sdk/shared/src/main/scala/org/ergoplatform/sdk/DataJsonEncoder.scala b/sdk/shared/src/main/scala/org/ergoplatform/sdk/DataJsonEncoder.scala index 06ffa951db..a92eef9947 100644 --- a/sdk/shared/src/main/scala/org/ergoplatform/sdk/DataJsonEncoder.scala +++ b/sdk/shared/src/main/scala/org/ergoplatform/sdk/DataJsonEncoder.scala @@ -6,7 +6,7 @@ import io.circe.syntax._ import org.ergoplatform.ErgoBox import org.ergoplatform.ErgoBox.{NonMandatoryRegisterId, Token} import org.ergoplatform.settings.ErgoAlgos -import sigma.core.RType +import sigma.data.RType import scorex.util._ import sigmastate.Values.{Constant, EvaluatedValue} import sigmastate._ diff --git a/sdk/shared/src/main/scala/org/ergoplatform/sdk/Extensions.scala b/sdk/shared/src/main/scala/org/ergoplatform/sdk/Extensions.scala index 98e78188cd..c8fb2e57f8 100644 --- a/sdk/shared/src/main/scala/org/ergoplatform/sdk/Extensions.scala +++ b/sdk/shared/src/main/scala/org/ergoplatform/sdk/Extensions.scala @@ -1,7 +1,7 @@ package org.ergoplatform.sdk import debox.cfor -import sigma.core.RType +import sigma.data.RType import sigma.rtypeToClassTag // actually used import sigmastate.eval.CPreHeader import sigma.{Coll, CollBuilder, PairColl} diff --git a/sdk/shared/src/main/scala/org/ergoplatform/sdk/JavaHelpers.scala b/sdk/shared/src/main/scala/org/ergoplatform/sdk/JavaHelpers.scala index 0d4db24003..6a63599059 100644 --- a/sdk/shared/src/main/scala/org/ergoplatform/sdk/JavaHelpers.scala +++ b/sdk/shared/src/main/scala/org/ergoplatform/sdk/JavaHelpers.scala @@ -1,6 +1,6 @@ package org.ergoplatform.sdk -import sigma.core.RType +import sigma.data.RType import sigma.Coll import scala.collection.{JavaConverters, mutable} @@ -26,7 +26,7 @@ import org.ergoplatform.sdk.JavaHelpers.{TokenColl, TokenIdRType} import org.ergoplatform.sdk.Extensions.{CollBuilderOps, PairCollOps} import org.ergoplatform.sdk.wallet.{Constants, TokensMap} import org.ergoplatform.sdk.wallet.secrets.{DerivationPath, ExtendedSecretKey} -import sigma.core.ExactIntegral.LongIsExactIntegral +import sigma.data.ExactIntegral.LongIsExactIntegral import sigma.util.StringUtil.StringUtilExtensions import sigmastate.crypto.CryptoConstants.EcPointType import sigmastate.crypto.{DiffieHellmanTupleProverInput, ProveDHTuple} diff --git a/sdk/shared/src/main/scala/org/ergoplatform/sdk/OutBoxBuilder.scala b/sdk/shared/src/main/scala/org/ergoplatform/sdk/OutBoxBuilder.scala index 142ad31c06..fa963d524d 100644 --- a/sdk/shared/src/main/scala/org/ergoplatform/sdk/OutBoxBuilder.scala +++ b/sdk/shared/src/main/scala/org/ergoplatform/sdk/OutBoxBuilder.scala @@ -3,7 +3,7 @@ package org.ergoplatform.sdk import org.ergoplatform.ErgoBox.TokenId import org.ergoplatform.sdk.JavaHelpers.collRType import org.ergoplatform.{ErgoBox, ErgoBoxCandidate, SigmaConstants} -import sigma.core.RType +import sigma.data.RType import sigmastate.SType import sigmastate.Values.{Constant, ErgoTree, EvaluatedValue} import sigmastate.eval.Colls diff --git a/sdk/shared/src/main/scala/org/ergoplatform/sdk/Utils.scala b/sdk/shared/src/main/scala/org/ergoplatform/sdk/Utils.scala index 4c5e8a9df5..83abf76c72 100644 --- a/sdk/shared/src/main/scala/org/ergoplatform/sdk/Utils.scala +++ b/sdk/shared/src/main/scala/org/ergoplatform/sdk/Utils.scala @@ -1,6 +1,6 @@ package org.ergoplatform.sdk -import sigma.core.ExactIntegral +import sigma.data.ExactIntegral import scala.collection.mutable import scala.reflect.ClassTag diff --git a/sdk/shared/src/main/scala/org/ergoplatform/sdk/utils/Zero.scala b/sdk/shared/src/main/scala/org/ergoplatform/sdk/utils/Zero.scala index 1d22086213..6cc7e6718c 100644 --- a/sdk/shared/src/main/scala/org/ergoplatform/sdk/utils/Zero.scala +++ b/sdk/shared/src/main/scala/org/ergoplatform/sdk/utils/Zero.scala @@ -1,8 +1,8 @@ package org.ergoplatform.sdk.utils import org.ergoplatform.ErgoBox -import sigma.core.{CollType, FuncType, OptionType, PairType, RType, TupleType} -import sigma.core.RType._ +import sigma.data.{CollType, FuncType, OptionType, PairType, RType, TupleType} +import sigma.data.RType._ import scorex.crypto.authds.avltree.batch.BatchAVLProver import scorex.crypto.hash.{Blake2b256, Digest32} import scorex.util.ModifierId diff --git a/sdk/shared/src/test/scala/org/ergoplatform/sdk/DataJsonEncoderSpecification.scala b/sdk/shared/src/test/scala/org/ergoplatform/sdk/DataJsonEncoderSpecification.scala index e4a1b2b7e2..0886fb845b 100644 --- a/sdk/shared/src/test/scala/org/ergoplatform/sdk/DataJsonEncoderSpecification.scala +++ b/sdk/shared/src/test/scala/org/ergoplatform/sdk/DataJsonEncoderSpecification.scala @@ -4,7 +4,7 @@ package org.ergoplatform.sdk import java.math.BigInteger import org.scalacheck.Arbitrary._ import org.scalacheck.Gen -import sigma.core.RType +import sigma.data.RType import sigmastate.SCollection.SByteArray import sigmastate.SType.AnyOps import sigmastate.Values.SigmaBoolean diff --git a/sdk/shared/src/test/scala/org/ergoplatform/sdk/ExtensionsSpec.scala b/sdk/shared/src/test/scala/org/ergoplatform/sdk/ExtensionsSpec.scala index cc555d6fab..f250b9fce5 100644 --- a/sdk/shared/src/test/scala/org/ergoplatform/sdk/ExtensionsSpec.scala +++ b/sdk/shared/src/test/scala/org/ergoplatform/sdk/ExtensionsSpec.scala @@ -5,7 +5,7 @@ import org.scalatest.propspec.AnyPropSpec import org.scalatestplus.scalacheck.ScalaCheckPropertyChecks import sigma.{Coll, CollGens} import org.ergoplatform.sdk.Extensions.{CollBuilderOps, CollOps, GenIterableOps, PairCollOps} -import sigma.core.RType +import sigma.data.RType import sigmastate.eval.CostingSigmaDslBuilder class ExtensionsSpec extends AnyPropSpec with ScalaCheckPropertyChecks with Matchers with CollGens { From ec37de7626d0415574f260a66ef310a6acac7700 Mon Sep 17 00:00:00 2001 From: Alexander Slesarenko Date: Fri, 25 Aug 2023 15:39:06 +0200 Subject: [PATCH 21/37] minimize-modules: move CollsOverArrays.scala to sigma.data --- .../main/scala/sigma/{ => data}/CollsOverArrays.scala | 11 +++++------ common/shared/src/test/scala/sigma/CollGens.scala | 2 +- .../src/main/scala/sigmastate/DataValueComparer.scala | 2 +- .../scala/sigmastate/eval/CostingDataContext.scala | 2 +- .../scala/sigmastate/helpers/TestingHelpers.scala | 5 +++-- .../src/test/scala/sigma/CollsStagingTests.scala | 5 +++-- 6 files changed, 14 insertions(+), 13 deletions(-) rename common/shared/src/main/scala/sigma/{ => data}/CollsOverArrays.scala (98%) diff --git a/common/shared/src/main/scala/sigma/CollsOverArrays.scala b/common/shared/src/main/scala/sigma/data/CollsOverArrays.scala similarity index 98% rename from common/shared/src/main/scala/sigma/CollsOverArrays.scala rename to common/shared/src/main/scala/sigma/data/CollsOverArrays.scala index 3f441919ab..9b620898e8 100644 --- a/common/shared/src/main/scala/sigma/CollsOverArrays.scala +++ b/common/shared/src/main/scala/sigma/data/CollsOverArrays.scala @@ -1,11 +1,10 @@ -package sigma +package sigma.data -import sigma.util.CollectionUtil -import sigma.data.{PairType, RType} -import debox.Buffer +import debox.{Buffer, cfor} import sigma.data.RType._ -import sigma.util.{MaxArrayLength, safeConcatArrays_v5} -import debox.cfor +import sigma.util.{CollectionUtil, MaxArrayLength, safeConcatArrays_v5} +import sigma.{Coll, CollBuilder, PairColl, VersionContext, requireSameLength} +import sigma.rtypeToClassTag class CollOverArray[@specialized A](val toArray: Array[A], val builder: CollBuilder) (implicit tA: RType[A]) extends Coll[A] { diff --git a/common/shared/src/test/scala/sigma/CollGens.scala b/common/shared/src/test/scala/sigma/CollGens.scala index c8096332f4..abe6b8ba85 100644 --- a/common/shared/src/test/scala/sigma/CollGens.scala +++ b/common/shared/src/test/scala/sigma/CollGens.scala @@ -2,7 +2,7 @@ package sigma import org.scalacheck.util.Buildable import org.scalacheck.{Arbitrary, Gen} -import sigma.data.RType +import sigma.data.{CollOverArrayBuilder, RType} import spire.scalacompat.BuilderCompat import scala.collection.mutable diff --git a/interpreter/shared/src/main/scala/sigmastate/DataValueComparer.scala b/interpreter/shared/src/main/scala/sigmastate/DataValueComparer.scala index 6812d3bc15..0bba6c0dc4 100644 --- a/interpreter/shared/src/main/scala/sigmastate/DataValueComparer.scala +++ b/interpreter/shared/src/main/scala/sigmastate/DataValueComparer.scala @@ -1,6 +1,6 @@ package sigmastate -import sigma.data.{AVHashMap, Nullable, RType} +import sigma.data.{AVHashMap, CollOverArray, Nullable, PairOfCols, RType} import debox.{cfor, sp} import sigmastate.Values.SigmaBoolean import sigmastate.crypto.DLogProtocol.ProveDlog diff --git a/interpreter/shared/src/main/scala/sigmastate/eval/CostingDataContext.scala b/interpreter/shared/src/main/scala/sigmastate/eval/CostingDataContext.scala index 09afa54a32..370f728c65 100644 --- a/interpreter/shared/src/main/scala/sigmastate/eval/CostingDataContext.scala +++ b/interpreter/shared/src/main/scala/sigmastate/eval/CostingDataContext.scala @@ -4,7 +4,7 @@ import debox.cfor import org.ergoplatform.validation.{SigmaValidationSettings, ValidationRules} import org.ergoplatform.{ErgoBox, SigmaConstants} import sigma.data.OverloadHack.Overloaded1 -import sigma.data.RType +import sigma.data.{CollOverArrayBuilder, RType} import sigma.util.Extensions.BigIntegerOps import scorex.crypto.authds.avltree.batch._ import scorex.crypto.authds.{ADDigest, ADKey, ADValue, SerializedAdProof} diff --git a/interpreter/shared/src/test/scala/sigmastate/helpers/TestingHelpers.scala b/interpreter/shared/src/test/scala/sigmastate/helpers/TestingHelpers.scala index afecd8d3b6..c0255b6adc 100644 --- a/interpreter/shared/src/test/scala/sigmastate/helpers/TestingHelpers.scala +++ b/interpreter/shared/src/test/scala/sigmastate/helpers/TestingHelpers.scala @@ -4,11 +4,12 @@ import org.ergoplatform.ErgoBox.{AdditionalRegisters, Token, allZerosModifierId} import org.ergoplatform.validation.SigmaValidationSettings import org.ergoplatform._ import scorex.util.ModifierId +import sigma.data.{CollOverArray, PairOfCols} import sigmastate.AvlTreeData import sigmastate.Values.ErgoTree -import sigmastate.eval.{CostingSigmaDslBuilder, _} +import sigmastate.eval._ import sigmastate.interpreter.ContextExtension -import sigma.{Coll, CollOverArray, PairOfCols} +import sigma.Coll import sigma.{Header, PreHeader} import scala.collection.compat.immutable.ArraySeq diff --git a/sc/shared/src/test/scala/sigma/CollsStagingTests.scala b/sc/shared/src/test/scala/sigma/CollsStagingTests.scala index 545ab7d916..3b56920c8d 100644 --- a/sc/shared/src/test/scala/sigma/CollsStagingTests.scala +++ b/sc/shared/src/test/scala/sigma/CollsStagingTests.scala @@ -3,6 +3,7 @@ package sigma import scala.language.reflectiveCalls import special.wrappers.WrappersTests import scalan._ +import sigma.data.CollOverArrayBuilder class CollsStagingTests extends WrappersTests { val printDebugInfo: Boolean = false @@ -47,7 +48,7 @@ class CollsStagingTests extends WrappersTests { import EnvRep._ import Liftables._ - val Cols: SCollBuilder = new sigma.CollOverArrayBuilder + val Cols: SCollBuilder = new CollOverArrayBuilder val arr = Array(1, 2, 3) val col = Cols.fromArray(arr) @@ -63,7 +64,7 @@ class CollsStagingTests extends WrappersTests { import Coll._ import CollBuilder._ - val Cols: SCollBuilder = new sigma.CollOverArrayBuilder + val Cols: SCollBuilder = new CollOverArrayBuilder val colData = Cols.replicate(10, 10) val colSym = colBuilder.replicate(10, 10) val resSym = colSym.append(colSym) From fdeda45281cab89d8c8a120e369a8afb9dabde17 Mon Sep 17 00:00:00 2001 From: Alexander Slesarenko Date: Fri, 25 Aug 2023 17:35:11 +0200 Subject: [PATCH 22/37] minimize-modules: introduced sigma.Colls --- .../scala/sigma/data/CollsOverArrays.scala | 4 +- .../shared/src/main/scala/sigma/package.scala | 6 +++ .../src/test/scala/sigma/CollGens.scala | 9 ++-- .../main/scala/org/ergoplatform/ErgoBox.scala | 2 +- .../org/ergoplatform/ErgoBoxCandidate.scala | 17 ++++---- .../ergoplatform/ErgoLikeTransaction.scala | 7 +-- .../main/scala/sigmastate/AvlTreeData.scala | 3 +- .../src/main/scala/sigmastate/Values.scala | 3 +- .../sigmastate/eval/CostingDataContext.scala | 5 +-- .../scala/sigmastate/eval/Extensions.scala | 1 - .../main/scala/sigmastate/eval/package.scala | 5 --- .../scala/sigmastate/lang/SigmaBuilder.scala | 4 +- .../src/main/scala/sigmastate/trees.scala | 6 +-- .../scala/sigmastate/utils/Extensions.scala | 10 ++--- .../main/scala/sigmastate/utils/Helpers.scala | 6 +-- .../helpers/ErgoLikeContextTesting.scala | 3 +- .../serialization/AvlTreeSpecification.scala | 1 + .../ConstantSerializerSpecification.scala | 2 +- .../DataSerializerSpecification.scala | 2 +- .../special/sigma/SigmaTestingData.scala | 2 +- .../org/ergoplatform/dsl/ContractSpec.scala | 8 ++-- .../org/ergoplatform/dsl/ContractSyntax.scala | 1 - sc/shared/src/main/scala/scalan/Base.scala | 4 +- .../src/main/scala/scalan/DefRewriting.scala | 5 ++- .../src/main/scala/scalan/Entities.scala | 2 - .../org/ergoplatform/ErgoTreePredefSpec.scala | 3 +- .../SoftForkabilitySpecification.scala | 3 +- .../helpers/CompilerTestingCommons.scala | 4 +- .../sigmastate/lang/SigmaTyperTest.scala | 2 +- .../DeserializationResilience.scala | 2 +- .../BlockchainSimulationTestingCommons.scala | 4 +- .../examples/CoinEmissionSpecification.scala | 9 ++-- .../examples/FsmExampleSpecification.scala | 3 +- .../sigmastate/utxo/examples/IcoExample.scala | 1 + .../utxo/examples/LetsSpecification.scala | 3 +- .../utxo/examples/Rule110Specification.scala | 3 +- .../scala/org/ergoplatform/sdk/js/Isos.scala | 5 +-- .../scala/org/ergoplatform/sdk/js/Value.scala | 4 +- .../org/ergoplatform/sdk/js/IsosSpec.scala | 4 +- .../org/ergoplatform/sdk/JavaHelpers.scala | 43 ++++++++----------- .../org/ergoplatform/sdk/JsonCodecs.scala | 3 +- .../org/ergoplatform/sdk/OutBoxBuilder.scala | 2 +- .../sdk/DataJsonEncoderSpecification.scala | 2 +- 43 files changed, 101 insertions(+), 117 deletions(-) diff --git a/common/shared/src/main/scala/sigma/data/CollsOverArrays.scala b/common/shared/src/main/scala/sigma/data/CollsOverArrays.scala index 9b620898e8..a5bb543e1b 100644 --- a/common/shared/src/main/scala/sigma/data/CollsOverArrays.scala +++ b/common/shared/src/main/scala/sigma/data/CollsOverArrays.scala @@ -142,7 +142,7 @@ class CollOverArray[@specialized A](val toArray: Array[A], val builder: CollBuil override def hashCode() = CollectionUtil.deepHashCode(toArray) } -class CollOverArrayBuilder extends CollBuilder { builder => +private[sigma] class CollOverArrayBuilder extends CollBuilder { builder => @inline override def pairColl[@specialized A, @specialized B](as: Coll[A], bs: Coll[B]): PairColl[A, B] = { if (VersionContext.current.isJitActivated) { @@ -250,7 +250,7 @@ class PairOfCols[@specialized L, @specialized R](val ls: Coll[L], val rs: Coll[R RType.pairRType(tL, tR) } - override def builder: CollBuilder = new CollOverArrayBuilder + override def builder: CollBuilder = ls.builder override def toArray: Array[(L, R)] = ls.toArray.zip(rs.toArray) @inline override def length: Int = if (ls.length <= rs.length) ls.length else rs.length @inline override def apply(i: Int): (L, R) = (ls(i), rs(i)) diff --git a/common/shared/src/main/scala/sigma/package.scala b/common/shared/src/main/scala/sigma/package.scala index d9c0a18712..7ccb5990fd 100644 --- a/common/shared/src/main/scala/sigma/package.scala +++ b/common/shared/src/main/scala/sigma/package.scala @@ -68,4 +68,10 @@ package object sigma { * @return An RType object for the tuple type. */ def tupleRType(types: Array[SomeType]): RType[TupleData] = TupleType(types) + + /** The primary reference to global Coll operations. Can be used to create collections from Array etc. + * + * @see CollBuilder + */ + val Colls: CollBuilder = new CollOverArrayBuilder } \ No newline at end of file diff --git a/common/shared/src/test/scala/sigma/CollGens.scala b/common/shared/src/test/scala/sigma/CollGens.scala index abe6b8ba85..d18fcad29f 100644 --- a/common/shared/src/test/scala/sigma/CollGens.scala +++ b/common/shared/src/test/scala/sigma/CollGens.scala @@ -7,12 +7,11 @@ import spire.scalacompat.BuilderCompat import scala.collection.mutable import scala.collection.mutable.ArrayBuffer -import scala.language.implicitConversions trait CollGens { testSuite => import Gen._ - val builder: CollBuilder = new CollOverArrayBuilder + val builder: CollBuilder = sigma.Colls val valGen = choose(-100, 100) val byteGen = choose[Byte](-100, 100) val indexGen = choose(0, 100) @@ -115,8 +114,8 @@ trait CollGens { testSuite => val superGenByte = getSuperGen(1, Gen.oneOf(bytesOverArrayGen, replBytesCollGen)) val superGen = Gen.oneOf(superGenInt, superGenByte) val allGen = Gen.oneOf(superGen, collGen) - implicit val arbColl = Arbitrary(collGen) - implicit val arbBytes = Arbitrary(bytesGen) + implicit val arbColl : Arbitrary[Coll[Int]] = Arbitrary(collGen) + implicit val arbBytes: Arbitrary[Coll[Byte]] = Arbitrary(bytesGen) def eq0(x: Int) = x == 0 @@ -139,7 +138,7 @@ trait CollGens { testSuite => res } - implicit def buildableColl[T: RType] = new Buildable[T, Coll[T]] { + implicit def buildableColl[T: RType]: Buildable[T, Coll[T]] = new Buildable[T, Coll[T]] { def builder = new BuilderCompat[T, Coll[T]] { val al = new ArrayBuffer[T] diff --git a/interpreter/shared/src/main/scala/org/ergoplatform/ErgoBox.scala b/interpreter/shared/src/main/scala/org/ergoplatform/ErgoBox.scala index a3abf97920..409c8e2a63 100644 --- a/interpreter/shared/src/main/scala/org/ergoplatform/ErgoBox.scala +++ b/interpreter/shared/src/main/scala/org/ergoplatform/ErgoBox.scala @@ -15,7 +15,7 @@ import sigmastate.eval._ import sigmastate.serialization.SigmaSerializer import sigmastate.utils.{Helpers, SigmaByteReader, SigmaByteWriter} import sigmastate.utxo.ExtractCreationInfo -import sigma._ +import sigma.{Colls, _} /** * Box (aka coin, or an unspent output) is a basic concept of a UTXO-based cryptocurrency. In Bitcoin, such an object diff --git a/interpreter/shared/src/main/scala/org/ergoplatform/ErgoBoxCandidate.scala b/interpreter/shared/src/main/scala/org/ergoplatform/ErgoBoxCandidate.scala index 13ae47b2e2..a167b95143 100644 --- a/interpreter/shared/src/main/scala/org/ergoplatform/ErgoBoxCandidate.scala +++ b/interpreter/shared/src/main/scala/org/ergoplatform/ErgoBoxCandidate.scala @@ -1,21 +1,20 @@ package org.ergoplatform -import java.util +import debox.cfor import org.ergoplatform.ErgoBox._ import org.ergoplatform.settings.ErgoAlgos import scorex.util.{ModifierId, bytesToId} +import sigma.Extensions.CollOps +import sigma.util.safeNewArray +import sigma.{Coll, Colls} +import sigmastate.SType.AnyOps import sigmastate.Values._ import sigmastate._ -import sigmastate.SType.AnyOps -import sigmastate.serialization.{SigmaSerializer, ValueSerializer} -import sigmastate.utils.{SigmaByteReader, SigmaByteWriter} -import sigma.Coll -import sigmastate.eval._ import sigmastate.eval.Extensions._ +import sigmastate.eval._ import sigmastate.serialization.ErgoTreeSerializer.DefaultSerializer -import sigma.util.safeNewArray -import debox.cfor -import sigma.Extensions.CollOps +import sigmastate.serialization.SigmaSerializer +import sigmastate.utils.{SigmaByteReader, SigmaByteWriter} import scala.collection.{immutable, mutable} import scala.runtime.ScalaRunTime diff --git a/interpreter/shared/src/main/scala/org/ergoplatform/ErgoLikeTransaction.scala b/interpreter/shared/src/main/scala/org/ergoplatform/ErgoLikeTransaction.scala index 2582b84e76..77ffc71f47 100644 --- a/interpreter/shared/src/main/scala/org/ergoplatform/ErgoLikeTransaction.scala +++ b/interpreter/shared/src/main/scala/org/ergoplatform/ErgoLikeTransaction.scala @@ -1,17 +1,18 @@ package org.ergoplatform +import debox.cfor import org.ergoplatform.ErgoBox.TokenId import scorex.crypto.authds.ADKey import scorex.crypto.hash.Blake2b256 import scorex.util._ +import sigma.Colls +import sigma.util.safeNewArray import sigmastate.SType._ import sigmastate.eval.Extensions._ import sigmastate.eval._ import sigmastate.interpreter.ProverResult -import sigmastate.serialization.{SigmaSerializer, ValueSerializer} -import sigma.util.safeNewArray +import sigmastate.serialization.SigmaSerializer import sigmastate.utils.{SigmaByteReader, SigmaByteWriter} -import debox.cfor import scala.util.Try diff --git a/interpreter/shared/src/main/scala/sigmastate/AvlTreeData.scala b/interpreter/shared/src/main/scala/sigmastate/AvlTreeData.scala index 042df327b5..83f9b756c7 100644 --- a/interpreter/shared/src/main/scala/sigmastate/AvlTreeData.scala +++ b/interpreter/shared/src/main/scala/sigmastate/AvlTreeData.scala @@ -1,10 +1,9 @@ package sigmastate import sigmastate.crypto.CryptoConstants -import sigmastate.eval.Colls import sigmastate.serialization.SigmaSerializer import sigmastate.utils.{SigmaByteReader, SigmaByteWriter} -import sigma.Coll +import sigma.{Coll, Colls} case class AvlTreeFlags(insertAllowed: Boolean, updateAllowed: Boolean, removeAllowed: Boolean) { diff --git a/interpreter/shared/src/main/scala/sigmastate/Values.scala b/interpreter/shared/src/main/scala/sigmastate/Values.scala index dd3f2881a0..dafea8a8f5 100644 --- a/interpreter/shared/src/main/scala/sigmastate/Values.scala +++ b/interpreter/shared/src/main/scala/sigmastate/Values.scala @@ -32,10 +32,9 @@ import sigmastate.lang.CheckingSigmaBuilder._ import sigmastate.serialization.ErgoTreeSerializer.DefaultSerializer import sigmastate.serialization.transformers.ProveDHTupleSerializer import sigmastate.utils.{SigmaByteReader, SigmaByteWriter} -import sigma.{AvlTree, Header, PreHeader, _} +import sigma.{AvlTree, Coll, Colls, Header, PreHeader, _} import sigmastate.lang.SourceContext import sigma.util.safeNewArray -import sigma.Coll import scala.collection.compat.immutable.ArraySeq import scala.collection.mutable diff --git a/interpreter/shared/src/main/scala/sigmastate/eval/CostingDataContext.scala b/interpreter/shared/src/main/scala/sigmastate/eval/CostingDataContext.scala index 370f728c65..839215226f 100644 --- a/interpreter/shared/src/main/scala/sigmastate/eval/CostingDataContext.scala +++ b/interpreter/shared/src/main/scala/sigmastate/eval/CostingDataContext.scala @@ -171,9 +171,6 @@ class CAvlTreeVerifier(startingDigest: ADDigest, * @see [[AvlTree]] for detailed descriptions */ case class CAvlTree(treeData: AvlTreeData) extends AvlTree with WrapperOf[AvlTreeData] { - val builder = CostingSigmaDslBuilder - val Colls = builder.Colls - override def wrappedValue: AvlTreeData = treeData override def keyLength: Int = treeData.keyLength @@ -494,7 +491,7 @@ class CostingSigmaDslBuilder extends SigmaDslBuilder { dsl => implicit val validationSettings: SigmaValidationSettings = ValidationRules.currentSettings // manual fix - override val Colls: CollBuilder = new CollOverArrayBuilder + override val Colls: CollBuilder = sigma.Colls override def BigInt(n: BigInteger): BigInt = CBigInt(n) diff --git a/interpreter/shared/src/main/scala/sigmastate/eval/Extensions.scala b/interpreter/shared/src/main/scala/sigmastate/eval/Extensions.scala index c2ecc29971..c7cac60d81 100644 --- a/interpreter/shared/src/main/scala/sigmastate/eval/Extensions.scala +++ b/interpreter/shared/src/main/scala/sigmastate/eval/Extensions.scala @@ -17,7 +17,6 @@ import sigma._ import java.math.BigInteger object Extensions { - private val Colls = CostingSigmaDslBuilder.Colls implicit class ByteExt(val b: Byte) extends AnyVal { @inline def toBigInt: BigInt = CostingSigmaDslBuilder.BigInt(BigInteger.valueOf(b.toLong)) diff --git a/interpreter/shared/src/main/scala/sigmastate/eval/package.scala b/interpreter/shared/src/main/scala/sigmastate/eval/package.scala index 79775d8c37..12b73de5f6 100644 --- a/interpreter/shared/src/main/scala/sigmastate/eval/package.scala +++ b/interpreter/shared/src/main/scala/sigmastate/eval/package.scala @@ -22,11 +22,6 @@ package object eval { */ val SigmaDsl = CostingSigmaDslBuilder - /** The primary reference to global Coll operations. Can be used to create collections from Array etc. - * @see CollBuilder - */ - val Colls: CollBuilder = SigmaDsl.Colls - /** Constructor of tuple value with more than 2 items. * Such long tuples are represented as Coll[Any]. * This representaion of tuples is different from representation of pairs (x, y), diff --git a/interpreter/shared/src/main/scala/sigmastate/lang/SigmaBuilder.scala b/interpreter/shared/src/main/scala/sigmastate/lang/SigmaBuilder.scala index 2e38aaab99..8d87d8ffce 100644 --- a/interpreter/shared/src/main/scala/sigmastate/lang/SigmaBuilder.scala +++ b/interpreter/shared/src/main/scala/sigmastate/lang/SigmaBuilder.scala @@ -3,7 +3,7 @@ package sigmastate.lang import debox.cfor import org.ergoplatform.ErgoBox.RegisterId import sigma.data.Nullable -import sigma.Environment +import sigma.{AnyValue, Coll, Colls, Environment} import sigmastate.SCollection.{SByteArray, SIntArray} import sigmastate.SOption.SIntOption import sigmastate.Values._ @@ -15,8 +15,6 @@ import sigmastate.lang.Terms.{STypeSubst, _} import sigmastate.serialization.OpCodes import sigmastate.serialization.OpCodes.OpCode import sigmastate.utxo._ -import sigma.Coll -import sigma.AnyValue import scala.util.DynamicVariable diff --git a/interpreter/shared/src/main/scala/sigmastate/trees.scala b/interpreter/shared/src/main/scala/sigmastate/trees.scala index ef21a47cea..2346ccd9e6 100644 --- a/interpreter/shared/src/main/scala/sigmastate/trees.scala +++ b/interpreter/shared/src/main/scala/sigmastate/trees.scala @@ -8,7 +8,7 @@ import sigma.data.ExactOrdering._ import sigma.data.OverloadHack.Overloaded1 import sigma.data.{ExactIntegral, ExactOrdering} import scorex.crypto.hash.{Blake2b256, CryptographicHash32, Sha256} -import sigma.VersionContext +import sigma.{Coll, Colls, GroupElement, SigmaProp, VersionContext} import sigmastate.ArithOp.OperationImpl import sigmastate.Operations._ import sigmastate.SCollection.{SByteArray, SIntArray} @@ -16,14 +16,12 @@ import sigmastate.SOption.SIntOption import sigmastate.Values._ import sigmastate.eval.Extensions.EvalCollOps import sigmastate.eval.NumericOps.{BigIntIsExactIntegral, BigIntIsExactOrdering} -import sigmastate.eval.{Colls, SigmaDsl} +import sigmastate.eval.SigmaDsl import sigmastate.interpreter.ErgoTreeEvaluator import sigmastate.interpreter.ErgoTreeEvaluator.DataEnv import sigmastate.serialization.OpCodes._ import sigmastate.serialization._ import sigmastate.utxo.{SimpleTransformerCompanion, Transformer} -import sigma.Coll -import sigma.{GroupElement, SigmaProp} import scala.collection.mutable import scala.collection.mutable.ArrayBuffer diff --git a/interpreter/shared/src/main/scala/sigmastate/utils/Extensions.scala b/interpreter/shared/src/main/scala/sigmastate/utils/Extensions.scala index f7ce8b46c4..9490f76965 100644 --- a/interpreter/shared/src/main/scala/sigmastate/utils/Extensions.scala +++ b/interpreter/shared/src/main/scala/sigmastate/utils/Extensions.scala @@ -4,7 +4,7 @@ import org.ergoplatform.ErgoBox.TokenId import scorex.util.{ModifierId, idToBytes} import scorex.utils.{Ints, Longs, Shorts} import sigmastate.eval.{Digest32Coll, SigmaDsl} -import sigma.Coll +import sigma.{Coll, Colls} object Extensions { implicit class ByteOpsForSigma(val b: Byte) extends AnyVal { @@ -25,7 +25,7 @@ object Extensions { * For example, the Short value {@code 0x1213} would yield the * byte array {@code {0x12, 0x13}}. */ - def toBytes: Coll[Byte] = SigmaDsl.Colls.fromArray(Shorts.toByteArray(x)) + def toBytes: Coll[Byte] = Colls.fromArray(Shorts.toByteArray(x)) /** Returns a big-endian representation of this numeric in a collection of Booleans. * Each boolean corresponds to one bit. @@ -38,7 +38,7 @@ object Extensions { * For example, the Int value {@code 0x12131415} would yield the * byte array {@code {0x12, 0x13, 0x14, 0x15}}. */ - def toBytes: Coll[Byte] = SigmaDsl.Colls.fromArray(Ints.toByteArray(x)) + def toBytes: Coll[Byte] = Colls.fromArray(Ints.toByteArray(x)) /** Returns a big-endian representation of this numeric in a collection of Booleans. * Each boolean corresponds to one bit. @@ -51,7 +51,7 @@ object Extensions { * For example, the Long value {@code 0x1213141516171819} would yield the * byte array {@code {0x12, 0x13, 0x14, 0x15, 0x16, 0x17, 0x18, 0x19}}. */ - def toBytes: Coll[Byte] = SigmaDsl.Colls.fromArray(Longs.toByteArray(x)) + def toBytes: Coll[Byte] = Colls.fromArray(Longs.toByteArray(x)) /** Returns a big-endian representation of this numeric in a collection of Booleans. * Each boolean corresponds to one bit. @@ -67,7 +67,7 @@ object Extensions { */ implicit class ModifierIdOps(val id: ModifierId) extends AnyVal { /** @return a `Coll[Byte]` representation of the `ModifierId` (decodes using Base16). */ - def toColl: Coll[Byte] = SigmaDsl.Colls.fromArray(idToBytes(id)) + def toColl: Coll[Byte] = Colls.fromArray(idToBytes(id)) /** Converts this modifier id to to token id. */ def toTokenId: TokenId = Digest32Coll @@ toColl diff --git a/interpreter/shared/src/main/scala/sigmastate/utils/Helpers.scala b/interpreter/shared/src/main/scala/sigmastate/utils/Helpers.scala index b6427c880b..5693def9af 100644 --- a/interpreter/shared/src/main/scala/sigmastate/utils/Helpers.scala +++ b/interpreter/shared/src/main/scala/sigmastate/utils/Helpers.scala @@ -5,11 +5,9 @@ import io.circe.Decoder import org.ergoplatform.settings.ErgoAlgos import sigma.data.{OverloadHack, RType} import scorex.utils.Ints -import sigma.Environment -import sigmastate.eval.{CAnyValue, Colls, SigmaDsl} +import sigma.{Coll, Colls, Environment, GroupElement} +import sigmastate.eval.{CAnyValue, SigmaDsl} import sigmastate.crypto.CryptoConstants.EcPointType -import sigma.Coll -import sigma.GroupElement import java.util import java.util.concurrent.locks.Lock diff --git a/interpreter/shared/src/test/scala/sigmastate/helpers/ErgoLikeContextTesting.scala b/interpreter/shared/src/test/scala/sigmastate/helpers/ErgoLikeContextTesting.scala index a98915c55d..70f644bd66 100644 --- a/interpreter/shared/src/test/scala/sigmastate/helpers/ErgoLikeContextTesting.scala +++ b/interpreter/shared/src/test/scala/sigmastate/helpers/ErgoLikeContextTesting.scala @@ -9,8 +9,7 @@ import sigmastate.eval._ import sigmastate.interpreter.ContextExtension import sigmastate.interpreter.ErgoTreeEvaluator.DefaultEvalSettings import sigmastate.serialization.{GroupElementSerializer, SigmaSerializer} -import sigma.Coll -import sigma.{Box, Header, PreHeader} +import sigma.{Box, Coll, Colls, Header, PreHeader} object ErgoLikeContextTesting { /* NO HF PROOF: diff --git a/interpreter/shared/src/test/scala/sigmastate/serialization/AvlTreeSpecification.scala b/interpreter/shared/src/test/scala/sigmastate/serialization/AvlTreeSpecification.scala index 42c71278ef..8a0b4b9255 100644 --- a/interpreter/shared/src/test/scala/sigmastate/serialization/AvlTreeSpecification.scala +++ b/interpreter/shared/src/test/scala/sigmastate/serialization/AvlTreeSpecification.scala @@ -3,6 +3,7 @@ package sigmastate.serialization import scorex.crypto.authds.{ADKey, ADValue} import scorex.crypto.authds.avltree.batch.{BatchAVLProver, Insert} import scorex.crypto.hash.{Blake2b256, Digest32} +import sigma.Colls import sigmastate.Values.AvlTreeConstant import sigmastate.AvlTreeFlags import sigmastate._ diff --git a/interpreter/shared/src/test/scala/sigmastate/serialization/ConstantSerializerSpecification.scala b/interpreter/shared/src/test/scala/sigmastate/serialization/ConstantSerializerSpecification.scala index 23c4f69201..04b016376a 100644 --- a/interpreter/shared/src/test/scala/sigmastate/serialization/ConstantSerializerSpecification.scala +++ b/interpreter/shared/src/test/scala/sigmastate/serialization/ConstantSerializerSpecification.scala @@ -12,7 +12,7 @@ import sigmastate.eval._ import sigmastate.eval.Extensions._ import sigmastate.Values._ import sigmastate.eval.Evaluation -import sigma.AvlTree +import sigma.{AvlTree, Colls} import SType.AnyOps import scorex.util.encode.Base16 import sigmastate.exceptions.SerializerException diff --git a/interpreter/shared/src/test/scala/sigmastate/serialization/DataSerializerSpecification.scala b/interpreter/shared/src/test/scala/sigmastate/serialization/DataSerializerSpecification.scala index eba0e9b90c..c02df973dc 100644 --- a/interpreter/shared/src/test/scala/sigmastate/serialization/DataSerializerSpecification.scala +++ b/interpreter/shared/src/test/scala/sigmastate/serialization/DataSerializerSpecification.scala @@ -11,7 +11,7 @@ import sigmastate.eval.Evaluation import sigmastate.eval._ import sigmastate.eval.Extensions._ import sigmastate.crypto.CryptoConstants.EcPointType -import sigma.AvlTree +import sigma.{AvlTree, Colls} import SType.AnyOps import sigmastate.exceptions.SerializerException import sigmastate.interpreter.{CostAccumulator, ErgoTreeEvaluator} diff --git a/interpreter/shared/src/test/scala/special/sigma/SigmaTestingData.scala b/interpreter/shared/src/test/scala/special/sigma/SigmaTestingData.scala index 5c7827b5cc..f5e695e32d 100644 --- a/interpreter/shared/src/test/scala/special/sigma/SigmaTestingData.scala +++ b/interpreter/shared/src/test/scala/special/sigma/SigmaTestingData.scala @@ -14,7 +14,7 @@ import sigmastate.Values.{ByteArrayConstant, ConcreteCollection, ConstantPlaceho import sigmastate.crypto.CryptoConstants.EcPointType import sigmastate.crypto.DLogProtocol.ProveDlog import sigmastate.crypto.ProveDHTuple -import sigmastate.eval.{Colls, _} +import sigmastate.eval._ import sigmastate.eval.Extensions._ import sigmastate.eval.{CAvlTree, CBigInt, CHeader, CPreHeader, CSigmaProp, CostingBox, CostingSigmaDslBuilder, SigmaDsl} import sigmastate.helpers.TestingCommons diff --git a/sc/shared/src/main/scala/org/ergoplatform/dsl/ContractSpec.scala b/sc/shared/src/main/scala/org/ergoplatform/dsl/ContractSpec.scala index 98b8a79bba..5950b8fcdb 100644 --- a/sc/shared/src/main/scala/org/ergoplatform/dsl/ContractSpec.scala +++ b/sc/shared/src/main/scala/org/ergoplatform/dsl/ContractSpec.scala @@ -3,10 +3,10 @@ package org.ergoplatform.dsl import org.ergoplatform.ErgoBox.{BoxId, NonMandatoryRegisterId, TokenId} import sigmastate.interpreter.{CostedProverResult, ProverResult} import sigma.data.RType -import org.ergoplatform.{ErgoLikeContext, ErgoBox} -import sigma.{SigmaDslBuilder, AnyValue, SigmaProp} +import org.ergoplatform.{ErgoBox, ErgoLikeContext} +import sigma.{AnyValue, Coll, SigmaDslBuilder, SigmaProp} import sigmastate.Values.ErgoTree -import sigmastate.eval.{IRContext, CostingSigmaDslBuilder} +import sigmastate.eval.{CostingSigmaDslBuilder, IRContext} import scala.util.Try import org.ergoplatform.dsl.ContractSyntax.{ErgoScript, Proposition, Token} @@ -17,7 +17,7 @@ trait ContractSpec { val dsl: SigmaDslBuilder = CostingSigmaDslBuilder val Colls = dsl.Colls - implicit def Coll[T](items: Array[T])(implicit cT: RType[T]) = Colls.fromArray(items) + implicit def Coll[T](items: Array[T])(implicit cT: RType[T]): Coll[T] = Colls.fromArray(items) val IR: IRContext diff --git a/sc/shared/src/main/scala/org/ergoplatform/dsl/ContractSyntax.scala b/sc/shared/src/main/scala/org/ergoplatform/dsl/ContractSyntax.scala index 665899cb5c..de3012ff8f 100644 --- a/sc/shared/src/main/scala/org/ergoplatform/dsl/ContractSyntax.scala +++ b/sc/shared/src/main/scala/org/ergoplatform/dsl/ContractSyntax.scala @@ -8,7 +8,6 @@ import org.ergoplatform.dsl.ContractSyntax.{ErgoScript, Proposition} import sigmastate.eval.{CostingSigmaDslBuilder, Evaluation} import sigmastate.interpreter.Interpreter.ScriptEnv import sigma.{SigmaProp, SigmaContract, Context, SigmaDslBuilder} -import scala.language.implicitConversions /** Defines methods to be used in contract implementations based on [[SigmaContract]]. */ trait ContractSyntax { contract: SigmaContract => diff --git a/sc/shared/src/main/scala/scalan/Base.scala b/sc/shared/src/main/scala/scalan/Base.scala index 46f8557dd7..cc29af45b9 100644 --- a/sc/shared/src/main/scala/scalan/Base.scala +++ b/sc/shared/src/main/scala/scalan/Base.scala @@ -7,7 +7,7 @@ import sigma.util.StringUtil import sigma.reflection.RConstructor import java.util.Arrays -import scala.annotation.implicitNotFound +import scala.annotation.{implicitNotFound, unused} import scala.annotation.unchecked.uncheckedVariance import scala.collection.compat.immutable.ArraySeq import scala.collection.mutable @@ -453,7 +453,7 @@ abstract class Base { scalan: Scalan => } /** Apply this transformer to the nodes present in the sequence, * and leave non-Ref items unchanged. */ - final def apply(xs: Seq[Any])(implicit o: Overloaded1): Seq[Any] = { + final def apply(xs: Seq[Any])(implicit @unused o: Overloaded1): Seq[Any] = { val len = xs.length if (len == 0) ArraySeq.empty else { diff --git a/sc/shared/src/main/scala/scalan/DefRewriting.scala b/sc/shared/src/main/scala/scalan/DefRewriting.scala index fe63bb6b2b..114fb1b0e6 100644 --- a/sc/shared/src/main/scala/scalan/DefRewriting.scala +++ b/sc/shared/src/main/scala/scalan/DefRewriting.scala @@ -14,18 +14,19 @@ trait DefRewriting { scalan: Scalan => case Tup(Def(First(a)), Def(Second(b))) if a == b => a // Rule: convert(eFrom, eTo, x, conv) if x.elem <:< eFrom ==> conv(x) - case Convert(eFrom: Elem[from], eTo: Elem[to], x, conv) if x.elem <:< eFrom => + case Convert(eFrom: Elem[from], _: Elem[to], x, conv) if x.elem <:< eFrom => mkApply(conv, x) case Apply(f @ Def(l: Lambda[a,b]), x, mayInline) if mayInline && l.mayInline => mkApply(f, x) - case call @ MethodCall(receiver, m, args, neverInvoke) => + case call @ MethodCall(receiver, m, args, _) => call.tryInvoke match { // Rule: receiver.m(args) ==> body(m).subst{xs -> args} case InvokeSuccess(res) => res case InvokeFailure(e) if !e.isInstanceOf[DelayInvokeException] => throwInvocationException("Method invocation in rewriteDef", e, receiver, m, args) + case InvokeFailure(ex) => throw ex case InvokeImpossible => val res = rewriteNonInvokableMethodCall(call) if (res != null) res diff --git a/sc/shared/src/main/scala/scalan/Entities.scala b/sc/shared/src/main/scala/scalan/Entities.scala index 1a74349cc7..8a32dcde10 100644 --- a/sc/shared/src/main/scala/scalan/Entities.scala +++ b/sc/shared/src/main/scala/scalan/Entities.scala @@ -1,7 +1,5 @@ package scalan -import scala.language.higherKinds - /** A slice in the Scalan cake with base classes for various descriptors. */ trait Entities extends TypeDescs { self: Scalan => diff --git a/sc/shared/src/test/scala/org/ergoplatform/ErgoTreePredefSpec.scala b/sc/shared/src/test/scala/org/ergoplatform/ErgoTreePredefSpec.scala index eb22fdc92e..d017b6ca35 100644 --- a/sc/shared/src/test/scala/org/ergoplatform/ErgoTreePredefSpec.scala +++ b/sc/shared/src/test/scala/org/ergoplatform/ErgoTreePredefSpec.scala @@ -7,6 +7,7 @@ import org.ergoplatform.settings.MonetarySettings import org.scalacheck.Gen import scorex.crypto.hash.Blake2b256 import scorex.util.Random +import sigma.Colls import sigma.util.BenchmarkUtil.measure import sigmastate.Values.{ByteArrayConstant, CollectionConstant, ErgoTree, IntConstant, SigmaPropConstant} import sigmastate._ @@ -18,7 +19,7 @@ import sigmastate.interpreter.{ContextExtension, ProverResult} import sigmastate.lang.Terms.ValueOps import sigmastate.serialization.ValueSerializer import sigmastate.utxo.{ByIndex, ExtractCreationInfo, SelectField} -import sigmastate.eval.{Colls, Digest32Coll} +import sigmastate.eval.Digest32Coll import sigmastate.utils.Helpers._ import scala.util.Try diff --git a/sc/shared/src/test/scala/sigmastate/SoftForkabilitySpecification.scala b/sc/shared/src/test/scala/sigmastate/SoftForkabilitySpecification.scala index c576e24096..c46b5a3119 100644 --- a/sc/shared/src/test/scala/sigmastate/SoftForkabilitySpecification.scala +++ b/sc/shared/src/test/scala/sigmastate/SoftForkabilitySpecification.scala @@ -7,7 +7,6 @@ import org.scalatest.BeforeAndAfterAll import sigmastate.SPrimType.MaxPrimTypeCode import sigmastate.Values.ErgoTree.EmptyConstants import sigmastate.Values.{ByteArrayConstant, ErgoTree, IntConstant, NotReadyValueInt, UnparsedErgoTree, ValueCompanion} -import sigmastate.eval.Colls import sigmastate.exceptions.{InterpreterException, SerializerException} import sigmastate.helpers.TestingHelpers._ import sigmastate.helpers.{CompilerTestingCommons, ErgoLikeContextTesting, ErgoLikeTestInterpreter, ErgoLikeTestProvingInterpreter} @@ -20,7 +19,7 @@ import sigmastate.serialization.SigmaSerializer.startReader import sigmastate.serialization._ import sigmastate.utils.Helpers._ import sigmastate.utxo.DeserializeContext -import sigma.SigmaTestingData +import sigma.{Colls, SigmaTestingData} class SoftForkabilitySpecification extends SigmaTestingData with CompilerTestingCommons diff --git a/sc/shared/src/test/scala/sigmastate/helpers/CompilerTestingCommons.scala b/sc/shared/src/test/scala/sigmastate/helpers/CompilerTestingCommons.scala index 51ddde1afa..3ff75079ab 100644 --- a/sc/shared/src/test/scala/sigmastate/helpers/CompilerTestingCommons.scala +++ b/sc/shared/src/test/scala/sigmastate/helpers/CompilerTestingCommons.scala @@ -8,7 +8,7 @@ import org.scalacheck.Gen import org.scalatest.Assertion import sigma.util.BenchmarkUtil import scalan.TestContexts -import sigma.TestUtils +import sigma.{Colls, TestUtils} import sigma.data.RType import sigmastate.Values.{Constant, ErgoTree, SValue, SigmaBoolean, SigmaPropValue} import sigmastate.eval._ @@ -63,7 +63,7 @@ trait CompilerTestingCommons extends TestingCommons val buf = new Array[sigma.AnyValue](2) Array.copy(vars, 0, buf, 0, vars.length) buf(1) = ctxVar - CostingSigmaDslBuilder.Colls.fromArray(buf) + Colls.fromArray(buf) } else { ctx.vars.updated(1, ctxVar) } diff --git a/sc/shared/src/test/scala/sigmastate/lang/SigmaTyperTest.scala b/sc/shared/src/test/scala/sigmastate/lang/SigmaTyperTest.scala index 5a1b93fdf5..b12938db03 100644 --- a/sc/shared/src/test/scala/sigmastate/lang/SigmaTyperTest.scala +++ b/sc/shared/src/test/scala/sigmastate/lang/SigmaTyperTest.scala @@ -5,12 +5,12 @@ import org.ergoplatform._ import org.scalatest.matchers.should.Matchers import org.scalatest.propspec.AnyPropSpec import org.scalatestplus.scalacheck.ScalaCheckPropertyChecks +import sigma.Colls import sigmastate.SCollection._ import sigmastate.Values._ import sigmastate._ import sigmastate.crypto.CryptoConstants import sigmastate.crypto.DLogProtocol.{DLogProverInput, ProveDlog} -import sigmastate.eval.Colls import sigmastate.exceptions.TyperException import sigmastate.interpreter.Interpreter.ScriptEnv import sigmastate.lang.SigmaPredef._ diff --git a/sc/shared/src/test/scala/sigmastate/serialization/DeserializationResilience.scala b/sc/shared/src/test/scala/sigmastate/serialization/DeserializationResilience.scala index 817b42ffdf..7300731fc3 100644 --- a/sc/shared/src/test/scala/sigmastate/serialization/DeserializationResilience.scala +++ b/sc/shared/src/test/scala/sigmastate/serialization/DeserializationResilience.scala @@ -9,7 +9,7 @@ import scorex.crypto.authds.avltree.batch.{BatchAVLProver, Insert} import scorex.crypto.authds.{ADKey, ADValue} import scorex.crypto.hash.{Blake2b256, Digest32} import scorex.util.serialization.{Reader, VLQByteBufferReader} -import sigma.Environment +import sigma.{Colls, Environment} import sigmastate.Values.{BlockValue, GetVarInt, IntConstant, SValue, SigmaBoolean, SigmaPropValue, Tuple, ValDef, ValUse} import sigmastate._ import sigmastate.crypto.CryptoConstants diff --git a/sc/shared/src/test/scala/sigmastate/utxo/blockchain/BlockchainSimulationTestingCommons.scala b/sc/shared/src/test/scala/sigmastate/utxo/blockchain/BlockchainSimulationTestingCommons.scala index d22b706267..e9cf82616b 100644 --- a/sc/shared/src/test/scala/sigmastate/utxo/blockchain/BlockchainSimulationTestingCommons.scala +++ b/sc/shared/src/test/scala/sigmastate/utxo/blockchain/BlockchainSimulationTestingCommons.scala @@ -8,12 +8,14 @@ import scorex.crypto.hash.{Blake2b256, Digest32} import sigmastate.{AvlTreeData, AvlTreeFlags, Values} import sigmastate.Values.{ErgoTree, LongConstant} import sigmastate.eval._ -import sigmastate.helpers.{BlockchainState, ErgoLikeContextTesting, ErgoLikeTestProvingInterpreter, ErgoTransactionValidator, CompilerTestingCommons} +import sigmastate.helpers.{BlockchainState, CompilerTestingCommons, ErgoLikeContextTesting, ErgoLikeTestProvingInterpreter, ErgoTransactionValidator} import sigmastate.helpers.TestingHelpers._ import sigmastate.utils.Helpers._ + import scala.collection.mutable import scala.util.{Random, Try} import scorex.util._ +import sigma.Colls import sigmastate.interpreter.ContextExtension import sigmastate.interpreter.Interpreter.{ScriptNameProp, emptyEnv} import sigmastate.utxo.blockchain.BlockchainSimulationTestingCommons.{FullBlock, ValidationState} diff --git a/sc/shared/src/test/scala/sigmastate/utxo/examples/CoinEmissionSpecification.scala b/sc/shared/src/test/scala/sigmastate/utxo/examples/CoinEmissionSpecification.scala index 382962c8fc..a6c612a037 100644 --- a/sc/shared/src/test/scala/sigmastate/utxo/examples/CoinEmissionSpecification.scala +++ b/sc/shared/src/test/scala/sigmastate/utxo/examples/CoinEmissionSpecification.scala @@ -2,16 +2,17 @@ package sigmastate.utxo.examples import org.ergoplatform._ import org.ergoplatform.settings.ErgoAlgos +import sigma.Colls import sigmastate.Values.{BlockValue, ErgoTree, IntConstant, LongConstant, ValDef, ValUse} -import sigmastate.helpers.{ContextEnrichingTestProvingInterpreter, ErgoLikeContextTesting, SigmaPPrint, CompilerTestingCommons} +import sigmastate._ +import sigmastate.eval._ import sigmastate.helpers.TestingHelpers._ +import sigmastate.helpers.{CompilerTestingCommons, ContextEnrichingTestProvingInterpreter, ErgoLikeContextTesting} import sigmastate.interpreter.ContextExtension import sigmastate.interpreter.Interpreter.{ScriptNameProp, emptyEnv} import sigmastate.lang.Terms._ -import sigmastate.utxo.blockchain.BlockchainSimulationTestingCommons._ import sigmastate.utxo._ -import sigmastate._ -import sigmastate.eval._ +import sigmastate.utxo.blockchain.BlockchainSimulationTestingCommons._ /** * An example of currency emission contract. diff --git a/sc/shared/src/test/scala/sigmastate/utxo/examples/FsmExampleSpecification.scala b/sc/shared/src/test/scala/sigmastate/utxo/examples/FsmExampleSpecification.scala index 99008b9e21..77918e453a 100644 --- a/sc/shared/src/test/scala/sigmastate/utxo/examples/FsmExampleSpecification.scala +++ b/sc/shared/src/test/scala/sigmastate/utxo/examples/FsmExampleSpecification.scala @@ -5,12 +5,13 @@ import scorex.crypto.authds.avltree.batch.{BatchAVLProver, Insert, Lookup} import scorex.crypto.authds.{ADKey, ADValue} import scorex.crypto.hash import scorex.crypto.hash.{Blake2b256, Digest32} +import sigma.Colls import sigmastate.SCollection.SByteArray import sigmastate.Values._ import sigmastate._ import sigmastate.eval._ import sigmastate.lang.Terms._ -import sigmastate.helpers.{ContextEnrichingTestProvingInterpreter, ErgoLikeContextTesting, ErgoLikeTestInterpreter, CompilerTestingCommons} +import sigmastate.helpers.{CompilerTestingCommons, ContextEnrichingTestProvingInterpreter, ErgoLikeContextTesting, ErgoLikeTestInterpreter} import sigmastate.helpers.TestingHelpers._ import sigmastate.interpreter.Interpreter.{ScriptNameProp, emptyEnv} import sigmastate.serialization.ValueSerializer diff --git a/sc/shared/src/test/scala/sigmastate/utxo/examples/IcoExample.scala b/sc/shared/src/test/scala/sigmastate/utxo/examples/IcoExample.scala index bab97e59e8..95899f0aa9 100644 --- a/sc/shared/src/test/scala/sigmastate/utxo/examples/IcoExample.scala +++ b/sc/shared/src/test/scala/sigmastate/utxo/examples/IcoExample.scala @@ -8,6 +8,7 @@ import org.scalatest.BeforeAndAfterAll import scorex.crypto.authds.avltree.batch._ import scorex.crypto.authds.{ADKey, ADValue} import scorex.crypto.hash.{Blake2b256, Digest32} +import sigma.Colls import sigmastate.Values._ import sigmastate._ import sigmastate.crypto.CryptoConstants diff --git a/sc/shared/src/test/scala/sigmastate/utxo/examples/LetsSpecification.scala b/sc/shared/src/test/scala/sigmastate/utxo/examples/LetsSpecification.scala index ef95e480f8..22f7f1c7c9 100644 --- a/sc/shared/src/test/scala/sigmastate/utxo/examples/LetsSpecification.scala +++ b/sc/shared/src/test/scala/sigmastate/utxo/examples/LetsSpecification.scala @@ -5,10 +5,11 @@ import org.ergoplatform.ErgoBox.{R4, R5} import scorex.crypto.authds.{ADKey, ADValue} import scorex.crypto.authds.avltree.batch.{BatchAVLProver, Insert, Lookup} import scorex.crypto.hash.{Blake2b256, Digest32} +import sigma.Colls import sigmastate.{AvlTreeData, AvlTreeFlags, CompilerCrossVersionProps, TrivialProp} import sigmastate.Values.{AvlTreeConstant, ByteArrayConstant, LongConstant, SigmaPropConstant} import sigmastate.eval.Extensions.ArrayOps -import sigmastate.eval.{Colls, Digest32Coll, IRContext, SigmaDsl} +import sigmastate.eval.{Digest32Coll, IRContext, SigmaDsl} import sigmastate.helpers.{CompilerTestingCommons, ContextEnrichingTestProvingInterpreter, ErgoLikeContextTesting, ErgoLikeTestProvingInterpreter} import sigmastate.helpers.TestingHelpers._ import sigmastate.interpreter.Interpreter.ScriptNameProp diff --git a/sc/shared/src/test/scala/sigmastate/utxo/examples/Rule110Specification.scala b/sc/shared/src/test/scala/sigmastate/utxo/examples/Rule110Specification.scala index 62fbaf37a7..00b25ba8e1 100644 --- a/sc/shared/src/test/scala/sigmastate/utxo/examples/Rule110Specification.scala +++ b/sc/shared/src/test/scala/sigmastate/utxo/examples/Rule110Specification.scala @@ -3,10 +3,11 @@ package sigmastate.utxo.examples import org.ergoplatform._ import scorex.crypto.hash.Blake2b256 import scorex.util._ +import sigma.Colls import sigmastate.Values._ import sigmastate._ import sigmastate.eval._ -import sigmastate.helpers.{ContextEnrichingTestProvingInterpreter, ErgoLikeContextTesting, CompilerTestingCommons, ErgoLikeTestInterpreter} +import sigmastate.helpers.{CompilerTestingCommons, ContextEnrichingTestProvingInterpreter, ErgoLikeContextTesting, ErgoLikeTestInterpreter} import sigmastate.helpers.TestingHelpers._ import sigmastate.interpreter.ContextExtension import sigmastate.lang.Terms._ diff --git a/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Isos.scala b/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Isos.scala index 0367ad54cc..aa5abb1856 100644 --- a/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Isos.scala +++ b/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Isos.scala @@ -11,7 +11,7 @@ import scorex.util.ModifierId import scorex.util.encode.Base16 import sigmastate.Values.{Constant, GroupElementConstant} import sigmastate.eval.Extensions.ArrayOps -import sigmastate.eval.{CAvlTree, CBigInt, CHeader, CPreHeader, Colls, Digest32Coll, Evaluation} +import sigmastate.eval.{CAvlTree, CBigInt, CHeader, CPreHeader, Digest32Coll, Evaluation} import sigmastate.fleetSdkCommon.distEsmTypesBoxesMod.Box import sigmastate.fleetSdkCommon.distEsmTypesCommonMod.HexString import sigmastate.fleetSdkCommon.distEsmTypesRegistersMod.NonMandatoryRegisters @@ -21,9 +21,8 @@ import sigmastate.fleetSdkCommon.{distEsmTypesBoxesMod => boxesMod, distEsmTypes import sigmastate.interpreter.{ContextExtension, ProverResult} import sigmastate.serialization.{ErgoTreeSerializer, ValueSerializer} import sigmastate.{AvlTreeData, AvlTreeFlags, SType} -import sigma.Coll +import sigma.{Coll, Colls, GroupElement} import sigma.Extensions.CollBytesOps -import sigma.GroupElement import java.math.BigInteger import scala.collection.immutable.ListMap diff --git a/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Value.scala b/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Value.scala index 6bcae003fa..e3a3d15b9a 100644 --- a/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Value.scala +++ b/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Value.scala @@ -7,13 +7,13 @@ import scorex.util.Extensions.{IntOps, LongOps} import scorex.util.encode.Base16 import sigmastate.SType import sigmastate.crypto.Platform -import sigmastate.eval.{CAvlTree, CGroupElement, CSigmaProp, Colls, CostingBox, Evaluation, SigmaDsl} +import sigmastate.eval.{CAvlTree, CGroupElement, CSigmaProp, CostingBox, Evaluation, SigmaDsl} import sigmastate.fleetSdkCommon.distEsmTypesBoxesMod.Box import sigmastate.fleetSdkCommon.distEsmTypesCommonMod import sigmastate.fleetSdkCommon.distEsmTypesRegistersMod.NonMandatoryRegisters import sigmastate.lang.DeserializationSigmaBuilder import sigmastate.serialization.{ConstantSerializer, DataSerializer, SigmaSerializer} -import sigma.Coll +import sigma.{Coll, Colls} import java.math.BigInteger import scala.scalajs.js diff --git a/sdk/js/src/test/scala/org/ergoplatform/sdk/js/IsosSpec.scala b/sdk/js/src/test/scala/org/ergoplatform/sdk/js/IsosSpec.scala index aaa7159758..135571aabe 100644 --- a/sdk/js/src/test/scala/org/ergoplatform/sdk/js/IsosSpec.scala +++ b/sdk/js/src/test/scala/org/ergoplatform/sdk/js/IsosSpec.scala @@ -10,11 +10,9 @@ import org.scalatest.propspec.AnyPropSpec import org.scalatestplus.scalacheck.ScalaCheckPropertyChecks import sigmastate.SType import sigmastate.Values.Constant -import sigmastate.eval.Colls import sigmastate.interpreter.{ContextExtension, ProverResult} import sigmastate.serialization.generators.ObjectGenerators -import sigma.Coll -import sigma.GroupElement +import sigma.{Coll, Colls, GroupElement} import scala.scalajs.js diff --git a/sdk/shared/src/main/scala/org/ergoplatform/sdk/JavaHelpers.scala b/sdk/shared/src/main/scala/org/ergoplatform/sdk/JavaHelpers.scala index 6a63599059..d0c64fbfa7 100644 --- a/sdk/shared/src/main/scala/org/ergoplatform/sdk/JavaHelpers.scala +++ b/sdk/shared/src/main/scala/org/ergoplatform/sdk/JavaHelpers.scala @@ -1,38 +1,33 @@ package org.ergoplatform.sdk -import sigma.data.RType -import sigma.Coll - -import scala.collection.{JavaConverters, mutable} -import org.ergoplatform._ +import org.ergoplatform.ErgoAddressEncoder.NetworkPrefix import org.ergoplatform.ErgoBox.{Token, TokenId} -import sigmastate.SType -import sigmastate.Values.{Constant, ErgoTree, EvaluatedValue, SValue, SigmaBoolean, SigmaPropConstant} -import sigmastate.serialization.{ErgoTreeSerializer, GroupElementSerializer, SigmaSerializer, ValueSerializer} -import scorex.crypto.authds.ADKey +import org.ergoplatform._ +import org.ergoplatform.sdk.Extensions.{CollBuilderOps, PairCollOps} +import org.ergoplatform.sdk.JavaHelpers.{TokenColl, TokenIdRType} +import org.ergoplatform.sdk.wallet.secrets.{DerivationPath, ExtendedSecretKey} +import org.ergoplatform.sdk.wallet.{Constants, TokensMap} import org.ergoplatform.settings.ErgoAlgos -import sigmastate.eval.{CPreHeader, Colls, CostingSigmaDslBuilder, Digest32Coll, Evaluation} -import sigma.{AnyValue, AvlTree, GroupElement, Header} -import sigmastate.utils.Helpers._ // don't remove, required for Scala 2.11 - -import java.util -import java.lang.{Boolean => JBoolean, Byte => JByte, Integer => JInt, Long => JLong, Short => JShort, String => JString} -import java.util.{List => JList, Map => JMap} -import org.ergoplatform.ErgoAddressEncoder.NetworkPrefix +import scorex.crypto.authds.ADKey import scorex.util.encode.Base16 -import sigmastate.crypto.DLogProtocol.ProveDlog import scorex.util.{ModifierId, bytesToId, idToBytes} -import org.ergoplatform.sdk.JavaHelpers.{TokenColl, TokenIdRType} -import org.ergoplatform.sdk.Extensions.{CollBuilderOps, PairCollOps} -import org.ergoplatform.sdk.wallet.{Constants, TokensMap} -import org.ergoplatform.sdk.wallet.secrets.{DerivationPath, ExtendedSecretKey} import sigma.data.ExactIntegral.LongIsExactIntegral +import sigma.data.RType import sigma.util.StringUtil.StringUtilExtensions +import sigma.{AnyValue, AvlTree, Coll, Colls, GroupElement, Header} +import sigmastate.SType +import sigmastate.Values.{Constant, ErgoTree, EvaluatedValue, SValue, SigmaBoolean, SigmaPropConstant} import sigmastate.crypto.CryptoConstants.EcPointType -import sigmastate.crypto.{DiffieHellmanTupleProverInput, ProveDHTuple} -import sigmastate.crypto.CryptoFacade +import sigmastate.crypto.DLogProtocol.ProveDlog +import sigmastate.crypto.{CryptoFacade, DiffieHellmanTupleProverInput, ProveDHTuple} +import sigmastate.eval.{CostingSigmaDslBuilder, Digest32Coll, Evaluation} +import sigmastate.serialization.{ErgoTreeSerializer, GroupElementSerializer, SigmaSerializer, ValueSerializer} +import java.lang.{Boolean => JBoolean, Byte => JByte, Integer => JInt, Long => JLong, Short => JShort, String => JString} import java.math.BigInteger +import java.util +import java.util.{List => JList, Map => JMap} +import scala.collection.{JavaConverters, mutable} /** Type-class of isomorphisms between types. * Isomorphism between two types `A` and `B` essentially say that both types diff --git a/sdk/shared/src/main/scala/org/ergoplatform/sdk/JsonCodecs.scala b/sdk/shared/src/main/scala/org/ergoplatform/sdk/JsonCodecs.scala index 905983d7a2..bad2ce21bd 100644 --- a/sdk/shared/src/main/scala/org/ergoplatform/sdk/JsonCodecs.scala +++ b/sdk/shared/src/main/scala/org/ergoplatform/sdk/JsonCodecs.scala @@ -16,8 +16,7 @@ import sigmastate.eval.{CPreHeader, WrapperOf, _} import sigmastate.exceptions.SigmaException import sigmastate.interpreter.{ContextExtension, ProverResult} import sigmastate.{AvlTreeData, AvlTreeFlags, SType} -import sigma.Coll -import sigma.{AnyValue, Header, PreHeader} +import sigma.{AnyValue, Coll, Colls, Header, PreHeader} import scala.util.Try import sigmastate.utils.Helpers._ // required for Scala 2.11 diff --git a/sdk/shared/src/main/scala/org/ergoplatform/sdk/OutBoxBuilder.scala b/sdk/shared/src/main/scala/org/ergoplatform/sdk/OutBoxBuilder.scala index fa963d524d..61a71fcfa2 100644 --- a/sdk/shared/src/main/scala/org/ergoplatform/sdk/OutBoxBuilder.scala +++ b/sdk/shared/src/main/scala/org/ergoplatform/sdk/OutBoxBuilder.scala @@ -3,10 +3,10 @@ package org.ergoplatform.sdk import org.ergoplatform.ErgoBox.TokenId import org.ergoplatform.sdk.JavaHelpers.collRType import org.ergoplatform.{ErgoBox, ErgoBoxCandidate, SigmaConstants} +import sigma.Colls import sigma.data.RType import sigmastate.SType import sigmastate.Values.{Constant, ErgoTree, EvaluatedValue} -import sigmastate.eval.Colls import scala.collection.mutable.ArrayBuffer diff --git a/sdk/shared/src/test/scala/org/ergoplatform/sdk/DataJsonEncoderSpecification.scala b/sdk/shared/src/test/scala/org/ergoplatform/sdk/DataJsonEncoderSpecification.scala index 0886fb845b..89330bc759 100644 --- a/sdk/shared/src/test/scala/org/ergoplatform/sdk/DataJsonEncoderSpecification.scala +++ b/sdk/shared/src/test/scala/org/ergoplatform/sdk/DataJsonEncoderSpecification.scala @@ -13,7 +13,7 @@ import sigmastate.eval.Extensions._ import sigmastate.eval.{Evaluation, _} import sigmastate.crypto.CryptoConstants.EcPointType import sigmastate.exceptions.SerializerException -import sigma.{AvlTree, Box} +import sigma.{AvlTree, Box, Colls} import sigmastate.serialization.SerializationSpecification import scala.annotation.nowarn From 9676d888251e171a23435b45a766fc87b74f7d3f Mon Sep 17 00:00:00 2001 From: Alexander Slesarenko Date: Fri, 25 Aug 2023 17:51:58 +0200 Subject: [PATCH 23/37] minimize-modules: Removed CoreLibReflection.scala --- .../main/scala/sigma/CoreLibReflection.scala | 405 ------------------ .../shared/src/main/scala/sigma/package.scala | 2 - .../sigma/reflection/CommonReflection.scala | 394 ++++++++++++++++- .../sigmastate/InterpreterReflection.scala | 6 +- .../main/scala/scalan/GraphIRReflection.scala | 3 +- .../src/test/scala/scalan/TestContexts.scala | 4 +- .../org/ergoplatform/sdk/JavaHelpers.scala | 1 + 7 files changed, 400 insertions(+), 415 deletions(-) delete mode 100644 common/shared/src/main/scala/sigma/CoreLibReflection.scala diff --git a/common/shared/src/main/scala/sigma/CoreLibReflection.scala b/common/shared/src/main/scala/sigma/CoreLibReflection.scala deleted file mode 100644 index 3b68b1547f..0000000000 --- a/common/shared/src/main/scala/sigma/CoreLibReflection.scala +++ /dev/null @@ -1,405 +0,0 @@ -package sigma - -import sigma.data.RType -import sigma.reflection.CommonReflection.registerClassEntry -import sigma.reflection._ - -/** Registrations of reflection metadata for core-lib module. - * For each class of this module that needs reflection metadata, - * we register a class entry with the necessary information. - * Only information that is needed at runtime is registered. - */ -object CoreLibReflection { - val reflection = CommonReflection - - { val clazz = classOf[SigmaProp] - registerClassEntry(clazz, - methods = Map( - mkMethod(clazz, "$bar$bar", Array[Class[_]](classOf[SigmaProp])) { (obj, args) => - obj.asInstanceOf[SigmaProp].$bar$bar(args(0).asInstanceOf[SigmaProp]) - }, - mkMethod(clazz, "isValid", Array[Class[_]]()) { (obj, _) => - obj.asInstanceOf[SigmaProp].isValid - }, - mkMethod(clazz, "propBytes", Array[Class[_]]()) { (obj, _) => - obj.asInstanceOf[SigmaProp].propBytes - }, - mkMethod(clazz, "$amp$amp", Array[Class[_]](classOf[SigmaProp])) { (obj, args) => - obj.asInstanceOf[SigmaProp].$amp$amp(args(0).asInstanceOf[SigmaProp]) - } - ) - ) - } - - { val clazz = classOf[sigma.BigInt] - val paramTypes = Array[Class[_]](clazz) - registerClassEntry(clazz, - methods = Map( - mkMethod(clazz, "add", paramTypes) { (obj, args) => - obj.asInstanceOf[BigInt].add(args(0).asInstanceOf[BigInt]) - }, - mkMethod(clazz, "max", paramTypes) { (obj, args) => - obj.asInstanceOf[BigInt].max(args(0).asInstanceOf[BigInt]) - }, - mkMethod(clazz, "min", paramTypes) { (obj, args) => - obj.asInstanceOf[BigInt].min(args(0).asInstanceOf[BigInt]) - }, - mkMethod(clazz, "subtract", paramTypes) { (obj, args) => - obj.asInstanceOf[BigInt].subtract(args(0).asInstanceOf[BigInt]) - }, - mkMethod(clazz, "multiply", paramTypes) { (obj, args) => - obj.asInstanceOf[BigInt].multiply(args(0).asInstanceOf[BigInt]) - }, - mkMethod(clazz, "mod", paramTypes) { (obj, args) => - obj.asInstanceOf[BigInt].mod(args(0).asInstanceOf[BigInt]) - }, - mkMethod(clazz, "divide", paramTypes) { (obj, args) => - obj.asInstanceOf[BigInt].divide(args(0).asInstanceOf[BigInt]) - } - ) - ) - } - - { val clazz = classOf[CollBuilder] - registerClassEntry(clazz, - methods = Map( - mkMethod(clazz, "xor", Array[Class[_]](classOf[Coll[_]], classOf[Coll[_]])) { (obj, args) => - obj.asInstanceOf[CollBuilder].xor( - args(0).asInstanceOf[Coll[Byte]], - args(1).asInstanceOf[Coll[Byte]]) - }, - mkMethod(clazz, "fromItems", Array[Class[_]](classOf[Seq[_]], classOf[RType[_]])) { (obj, args) => - obj.asInstanceOf[CollBuilder].fromItems[Any]( - args(0).asInstanceOf[Seq[Any]]: _*)(args(1).asInstanceOf[RType[Any]]) - }, - mkMethod(clazz, "replicate", Array[Class[_]](classOf[Int], classOf[Object], classOf[RType[_]])) { (obj, args) => - obj.asInstanceOf[CollBuilder].replicate(args(0).asInstanceOf[Int], - args(1).asInstanceOf[Any])(args(2).asInstanceOf[RType[Any]]) - } - ) - ) - } - - { val clazz = classOf[Coll[_]] - registerClassEntry(clazz, - methods = Map( - mkMethod(clazz, "updated", Array[Class[_]](classOf[Int], classOf[java.lang.Object])) { (obj, args) => - obj.asInstanceOf[Coll[Any]].updated(args(0).asInstanceOf[Int], args(1).asInstanceOf[Any]) - }, - mkMethod(clazz, "flatMap", Array[Class[_]](classOf[Function1[_, _]], classOf[RType[_]])) { (obj, args) => - obj.asInstanceOf[Coll[Any]].flatMap( - args(0).asInstanceOf[Any => Coll[Any]])(args(1).asInstanceOf[RType[Any]]) - }, - mkMethod(clazz, "apply", Array[Class[_]](classOf[Int])) { (obj, args) => - obj.asInstanceOf[Coll[_]].apply(args(0).asInstanceOf[Int]) - }, - mkMethod(clazz, "append", Array[Class[_]](classOf[Coll[_]])) { (obj, args) => - obj.asInstanceOf[Coll[Any]].append(args(0).asInstanceOf[Coll[Any]]) - }, - mkMethod(clazz, "indexOf", Array[Class[_]](classOf[java.lang.Object], classOf[Int])) { (obj, args) => - obj.asInstanceOf[Coll[Any]].indexOf(args(0).asInstanceOf[Any], args(1).asInstanceOf[Int]) - }, - mkMethod(clazz, "map", Array[Class[_]](classOf[Function1[_, _]], classOf[RType[_]])) { (obj, args) => - obj.asInstanceOf[Coll[Any]].map(args(0).asInstanceOf[Any => Any])(args(1).asInstanceOf[RType[Any]]) - } - ) - ) - } - - { val clazz = classOf[AvlTree] - registerClassEntry(clazz, - methods = Map( - mkMethod(clazz, "updateOperations", Array[Class[_]](classOf[Byte])) { (obj, args) => - obj.asInstanceOf[AvlTree].updateOperations(args(0).asInstanceOf[Byte]) - }, - mkMethod(clazz, "getMany", Array[Class[_]](classOf[Coll[_]], classOf[Coll[_]])) { (obj, args) => - obj.asInstanceOf[AvlTree].getMany(args(0).asInstanceOf[Coll[Coll[Byte]]], - args(1).asInstanceOf[Coll[Byte]]) - }, - mkMethod(clazz, "update", Array[Class[_]](classOf[Coll[_]], classOf[Coll[_]])) { (obj, args) => - obj.asInstanceOf[AvlTree].update(args(0).asInstanceOf[Coll[(Coll[Byte], Coll[Byte])]], - args(1).asInstanceOf[Coll[Byte]]) - }, - mkMethod(clazz, "keyLength", Array[Class[_]]()) { (obj, _) => - obj.asInstanceOf[AvlTree].keyLength - }, - mkMethod(clazz, "enabledOperations", Array[Class[_]]()) { (obj, _) => - obj.asInstanceOf[AvlTree].enabledOperations - }, - mkMethod(clazz, "updateDigest", Array[Class[_]](classOf[Coll[_]])) { (obj, args) => - obj.asInstanceOf[AvlTree].updateDigest(args(0).asInstanceOf[Coll[Byte]]) - }, - mkMethod(clazz, "digest", Array[Class[_]]()) { (obj, _) => - obj.asInstanceOf[AvlTree].digest - }, - mkMethod(clazz, "insert", Array[Class[_]](classOf[Coll[_]], classOf[Coll[_]])) { (obj, args) => - obj.asInstanceOf[AvlTree].insert(args(0).asInstanceOf[Coll[(Coll[Byte], Coll[Byte])]], - args(1).asInstanceOf[Coll[Byte]]) - }, - mkMethod(clazz, "isRemoveAllowed", Array[Class[_]]()) { (obj, _) => - obj.asInstanceOf[AvlTree].isRemoveAllowed - }, - mkMethod(clazz, "valueLengthOpt", Array[Class[_]]()) { (obj, _) => - obj.asInstanceOf[AvlTree].valueLengthOpt - }, - mkMethod(clazz, "get", Array[Class[_]](classOf[Coll[_]], classOf[Coll[_]])) { (obj, args) => - obj.asInstanceOf[AvlTree].get(args(0).asInstanceOf[Coll[Byte]], - args(1).asInstanceOf[Coll[Byte]]) - }, - mkMethod(clazz, "remove", Array[Class[_]](classOf[Coll[_]], classOf[Coll[_]])) { (obj, args) => - obj.asInstanceOf[AvlTree].remove(args(0).asInstanceOf[Coll[Coll[Byte]]], args(1).asInstanceOf[Coll[Byte]]) - }, - mkMethod(clazz, "contains", Array[Class[_]](classOf[Coll[_]], classOf[Coll[_]])) { (obj, args) => - obj.asInstanceOf[AvlTree].contains(args(0).asInstanceOf[Coll[Byte]], - args(1).asInstanceOf[Coll[Byte]]) - }, - mkMethod(clazz, "isUpdateAllowed", Array[Class[_]]()) { (obj, _) => - obj.asInstanceOf[AvlTree].isUpdateAllowed - }, - mkMethod(clazz, "isInsertAllowed", Array[Class[_]]()) { (obj, _) => - obj.asInstanceOf[AvlTree].isInsertAllowed - } - ) - ) - } - - { val clazz = classOf[Box] - registerClassEntry(clazz, - methods = Map( - mkMethod(clazz, "value", Array[Class[_]]()) { (obj, _) => - obj.asInstanceOf[Box].value - }, - mkMethod(clazz, "id", Array[Class[_]]()) { (obj, _) => - obj.asInstanceOf[Box].id - }, - mkMethod(clazz, "creationInfo", Array[Class[_]]()) { (obj, _) => - obj.asInstanceOf[Box].creationInfo - }, - mkMethod(clazz, "bytes", Array[Class[_]]()) { (obj, _) => - obj.asInstanceOf[Box].bytes - }, - mkMethod(clazz, "tokens", Array[Class[_]]()) { (obj, _) => - obj.asInstanceOf[Box].tokens - }, - mkMethod(clazz, "getReg", Array[Class[_]](classOf[Int], classOf[RType[_]])) { (obj, args) => - obj.asInstanceOf[Box].getReg(args(0).asInstanceOf[Int])(args(1).asInstanceOf[RType[_]]) - }, - mkMethod (clazz, "bytesWithoutRef", Array[Class[_]]()) { (obj, _) => - obj.asInstanceOf[Box].bytesWithoutRef - }, - mkMethod(clazz, "propositionBytes", Array[Class[_]]()) { (obj, _) => - obj.asInstanceOf[Box].propositionBytes - } - ) - ) - } - - { val clazz = classOf[Context] - registerClassEntry(clazz, - methods = Map( - mkMethod(clazz, "LastBlockUtxoRootHash", Array[Class[_]]()) { (obj, _) => - obj.asInstanceOf[Context].LastBlockUtxoRootHash - }, - mkMethod(clazz, "dataInputs", Array[Class[_]]()) { (obj, _) => - obj.asInstanceOf[Context].dataInputs - }, - mkMethod(clazz, "selfBoxIndex", Array[Class[_]]()) { (obj, _) => - obj.asInstanceOf[Context].selfBoxIndex - }, - mkMethod(clazz, "INPUTS", Array[Class[_]]()) { (obj, _) => - obj.asInstanceOf[Context].INPUTS - }, - mkMethod(clazz, "minerPubKey", Array[Class[_]]()) { (obj, _) => - obj.asInstanceOf[Context].minerPubKey - }, - mkMethod(clazz, "HEIGHT", Array[Class[_]]()) { (obj, _) => - obj.asInstanceOf[Context].HEIGHT - }, - mkMethod(clazz, "OUTPUTS", Array[Class[_]]()) { (obj, _) => - obj.asInstanceOf[Context].OUTPUTS - }, - mkMethod(clazz, "SELF", Array[Class[_]]()) { (obj, _) => - obj.asInstanceOf[Context].SELF - }, - mkMethod(clazz, "preHeader", Array[Class[_]]()) { (obj, _) => - obj.asInstanceOf[Context].preHeader - }, - mkMethod(clazz, "getVar", Array[Class[_]](classOf[Byte], classOf[RType[_]])) { (obj, args) => - obj.asInstanceOf[Context].getVar(args(0).asInstanceOf[Byte])(args(1).asInstanceOf[RType[_]]) - }, - mkMethod(clazz, "headers", Array[Class[_]]()) { (obj, _) => - obj.asInstanceOf[Context].headers - } - ) - ) - } - - { val clazz = classOf[GroupElement] - registerClassEntry(clazz, - methods = Map( - mkMethod(clazz, "exp", Array[Class[_]](classOf[BigInt])) { (obj, args) => - obj.asInstanceOf[GroupElement].exp(args(0).asInstanceOf[BigInt]) - }, - mkMethod(clazz, "multiply", Array[Class[_]](classOf[GroupElement])) { (obj, args) => - obj.asInstanceOf[GroupElement].multiply(args(0).asInstanceOf[GroupElement]) - }, - mkMethod(clazz, "getEncoded", Array[Class[_]]()) { (obj, _) => - obj.asInstanceOf[GroupElement].getEncoded - }, - mkMethod(clazz, "negate", Array[Class[_]]()) { (obj, _) => - obj.asInstanceOf[GroupElement].negate - } - ) - ) - } - - { val clazz = classOf[Header] - registerClassEntry(clazz, - methods = Map( - mkMethod(clazz, "minerPk", Array[Class[_]]()) { (obj, _) => - obj.asInstanceOf[Header].minerPk - }, - mkMethod(clazz, "powNonce", Array[Class[_]]()) { (obj, _) => - obj.asInstanceOf[Header].powNonce - }, - mkMethod(clazz, "transactionsRoot", Array[Class[_]]()) { (obj, _) => - obj.asInstanceOf[Header].transactionsRoot - }, - mkMethod(clazz, "powOnetimePk", Array[Class[_]]()) { (obj, _) => - obj.asInstanceOf[Header].powOnetimePk - }, - mkMethod(clazz, "nBits", Array[Class[_]]()) { (obj, _) => - obj.asInstanceOf[Header].nBits - }, - mkMethod(clazz, "votes", Array[Class[_]]()) { (obj, _) => - obj.asInstanceOf[Header].votes - }, - mkMethod(clazz, "id", Array[Class[_]]()) { (obj, _) => - obj.asInstanceOf[Header].id - }, - mkMethod(clazz, "version", Array[Class[_]]()) { (obj, _) => - obj.asInstanceOf[Header].version - }, - mkMethod(clazz, "parentId", Array[Class[_]]()) { (obj, _) => - obj.asInstanceOf[Header].parentId - }, - mkMethod(clazz, "timestamp", Array[Class[_]]()) { (obj, _) => - obj.asInstanceOf[Header].timestamp - }, - mkMethod(clazz, "height", Array[Class[_]]()) { (obj, _) => - obj.asInstanceOf[Header].height - }, - mkMethod(clazz, "extensionRoot", Array[Class[_]]()) { (obj, _) => - obj.asInstanceOf[Header].extensionRoot - }, - mkMethod(clazz, "ADProofsRoot", Array[Class[_]]()) { (obj, _) => - obj.asInstanceOf[Header].ADProofsRoot - }, - mkMethod(clazz, "stateRoot", Array[Class[_]]()) { (obj, _) => - obj.asInstanceOf[Header].stateRoot - }, - mkMethod(clazz, "powDistance", Array[Class[_]]()) { (obj, _) => - obj.asInstanceOf[Header].powDistance - } - ) - ) - } - - { val clazz = classOf[PreHeader] - registerClassEntry(clazz, - methods = Map( - mkMethod(clazz, "minerPk", Array[Class[_]]()) { (obj, _) => - obj.asInstanceOf[PreHeader].minerPk - }, - mkMethod(clazz, "votes", Array[Class[_]]()) { (obj, _) => - obj.asInstanceOf[PreHeader].votes - }, - mkMethod(clazz, "nBits", Array[Class[_]]()) { (obj, _) => - obj.asInstanceOf[PreHeader].nBits - }, - mkMethod(clazz, "version", Array[Class[_]]()) { (obj, _) => - obj.asInstanceOf[PreHeader].version - }, - mkMethod(clazz, "timestamp", Array[Class[_]]()) { (obj, _) => - obj.asInstanceOf[PreHeader].timestamp - }, - mkMethod(clazz, "parentId", Array[Class[_]]()) { (obj, _) => - obj.asInstanceOf[PreHeader].parentId - }, - mkMethod(clazz, "height", Array[Class[_]]()) { (obj, _) => - obj.asInstanceOf[PreHeader].height - } - ) - ) - } - - { val clazz = classOf[SigmaDslBuilder] - val cColl = classOf[Coll[_]] - val cGroupElement = classOf[GroupElement] - registerClassEntry(clazz, - methods = Map( - mkMethod(clazz, "byteArrayToLong", Array[Class[_]](cColl)) { (obj, args) => - obj.asInstanceOf[SigmaDslBuilder].byteArrayToLong(args(0).asInstanceOf[Coll[Byte]]) - }, - mkMethod(clazz, "anyOf", Array[Class[_]](cColl)) { (obj, args) => - obj.asInstanceOf[SigmaDslBuilder].anyOf(args(0).asInstanceOf[Coll[Boolean]]) - }, - mkMethod(clazz, "allZK", Array[Class[_]](cColl)) { (obj, args) => - obj.asInstanceOf[SigmaDslBuilder].allZK(args(0).asInstanceOf[Coll[SigmaProp]]) - }, - mkMethod(clazz, "xorOf", Array[Class[_]](cColl)) { (obj, args) => - obj.asInstanceOf[SigmaDslBuilder].xorOf(args(0).asInstanceOf[Coll[Boolean]]) - }, - mkMethod(clazz, "substConstants", Array[Class[_]](cColl, cColl, cColl)) { (obj, args) => - obj.asInstanceOf[SigmaDslBuilder].substConstants(args(0).asInstanceOf[Coll[Byte]], - args(1).asInstanceOf[Coll[Int]], args(2).asInstanceOf[Coll[Any]]) - }, - mkMethod(clazz, "groupGenerator", Array[Class[_]]()) { (obj, _) => - obj.asInstanceOf[SigmaDslBuilder].groupGenerator - }, - mkMethod(clazz, "sigmaProp", Array[Class[_]](classOf[Boolean])) { (obj, args) => - obj.asInstanceOf[SigmaDslBuilder].sigmaProp(args(0).asInstanceOf[Boolean]) - }, - mkMethod(clazz, "proveDlog", Array[Class[_]](cGroupElement)) { (obj, args) => - obj.asInstanceOf[SigmaDslBuilder].proveDlog(args(0).asInstanceOf[GroupElement]) - }, - mkMethod(clazz, "blake2b256", Array[Class[_]](cColl)) { (obj, args) => - obj.asInstanceOf[SigmaDslBuilder].blake2b256(args(0).asInstanceOf[Coll[Byte]]) - }, - mkMethod(clazz, "longToByteArray", Array[Class[_]](classOf[Long])) { (obj, args) => - obj.asInstanceOf[SigmaDslBuilder].longToByteArray(args(0).asInstanceOf[Long]) - }, - mkMethod(clazz, "xor", Array[Class[_]](cColl, cColl)) { (obj, args) => - obj.asInstanceOf[SigmaDslBuilder].xor(args(0).asInstanceOf[Coll[Byte]], - args(1).asInstanceOf[Coll[Byte]]) - }, - mkMethod(clazz, "atLeast", Array[Class[_]](classOf[Int], cColl)) { (obj, args) => - obj.asInstanceOf[SigmaDslBuilder].atLeast(args(0).asInstanceOf[Int], - args(1).asInstanceOf[Coll[SigmaProp]]) - }, - mkMethod(clazz, "byteArrayToBigInt", Array[Class[_]](cColl)) { (obj, args) => - obj.asInstanceOf[SigmaDslBuilder].byteArrayToBigInt(args(0).asInstanceOf[Coll[Byte]]) - }, - mkMethod(clazz, "allOf", Array[Class[_]](cColl)) { (obj, args) => - obj.asInstanceOf[SigmaDslBuilder].allOf(args(0).asInstanceOf[Coll[Boolean]]) - }, - mkMethod(clazz, "proveDHTuple", Array[Class[_]](cGroupElement, cGroupElement, cGroupElement, cGroupElement)) { (obj, args) => - obj.asInstanceOf[SigmaDslBuilder].proveDHTuple(args(0).asInstanceOf[GroupElement], - args(1).asInstanceOf[GroupElement], - args(2).asInstanceOf[GroupElement], - args(3).asInstanceOf[GroupElement]) - }, - mkMethod(clazz, "anyZK", Array[Class[_]](cColl)) { (obj, args) => - obj.asInstanceOf[SigmaDslBuilder].anyZK(args(0).asInstanceOf[Coll[SigmaProp]]) - }, - mkMethod(clazz, "sha256", Array[Class[_]](cColl)) { (obj, args) => - obj.asInstanceOf[SigmaDslBuilder].sha256(args(0).asInstanceOf[Coll[Byte]]) - }, - mkMethod(clazz, "decodePoint", Array[Class[_]](cColl)) { (obj, args) => - obj.asInstanceOf[SigmaDslBuilder].decodePoint(args(0).asInstanceOf[Coll[Byte]]) - } - ) - ) - } - -} diff --git a/common/shared/src/main/scala/sigma/package.scala b/common/shared/src/main/scala/sigma/package.scala index 7ccb5990fd..d4fc53d978 100644 --- a/common/shared/src/main/scala/sigma/package.scala +++ b/common/shared/src/main/scala/sigma/package.scala @@ -8,8 +8,6 @@ import scala.reflect.ClassTag * @see [[RType]] class */ package object sigma { - /** Forces reflection data initialization */ - val coreLibReflection = CoreLibReflection val AnyType: RType[Any] = GeneralType[Any](ClassTag.Any) diff --git a/common/shared/src/main/scala/sigma/reflection/CommonReflection.scala b/common/shared/src/main/scala/sigma/reflection/CommonReflection.scala index 9bf15b0e1b..782ae819e7 100644 --- a/common/shared/src/main/scala/sigma/reflection/CommonReflection.scala +++ b/common/shared/src/main/scala/sigma/reflection/CommonReflection.scala @@ -1,5 +1,8 @@ package sigma.reflection +import sigma._ +import sigma.data.RType + import scala.collection.compat.immutable.ArraySeq import scala.collection.mutable import scala.collection.immutable @@ -70,5 +73,394 @@ object CommonReflection { ) ) } - + { + val clazz = classOf[SigmaProp] + registerClassEntry(clazz, + methods = Map( + mkMethod(clazz, "$bar$bar", Array[Class[_]](classOf[SigmaProp])) { (obj, args) => + obj.asInstanceOf[SigmaProp].$bar$bar(args(0).asInstanceOf[SigmaProp]) + }, + mkMethod(clazz, "isValid", Array[Class[_]]()) { (obj, _) => + obj.asInstanceOf[SigmaProp].isValid + }, + mkMethod(clazz, "propBytes", Array[Class[_]]()) { (obj, _) => + obj.asInstanceOf[SigmaProp].propBytes + }, + mkMethod(clazz, "$amp$amp", Array[Class[_]](classOf[SigmaProp])) { (obj, args) => + obj.asInstanceOf[SigmaProp].$amp$amp(args(0).asInstanceOf[SigmaProp]) + } + ) + ) + } + { + val clazz = classOf[sigma.BigInt] + val paramTypes = Array[Class[_]](clazz) + registerClassEntry(clazz, + methods = Map( + mkMethod(clazz, "add", paramTypes) { (obj, args) => + obj.asInstanceOf[BigInt].add(args(0).asInstanceOf[BigInt]) + }, + mkMethod(clazz, "max", paramTypes) { (obj, args) => + obj.asInstanceOf[BigInt].max(args(0).asInstanceOf[BigInt]) + }, + mkMethod(clazz, "min", paramTypes) { (obj, args) => + obj.asInstanceOf[BigInt].min(args(0).asInstanceOf[BigInt]) + }, + mkMethod(clazz, "subtract", paramTypes) { (obj, args) => + obj.asInstanceOf[BigInt].subtract(args(0).asInstanceOf[BigInt]) + }, + mkMethod(clazz, "multiply", paramTypes) { (obj, args) => + obj.asInstanceOf[BigInt].multiply(args(0).asInstanceOf[BigInt]) + }, + mkMethod(clazz, "mod", paramTypes) { (obj, args) => + obj.asInstanceOf[BigInt].mod(args(0).asInstanceOf[BigInt]) + }, + mkMethod(clazz, "divide", paramTypes) { (obj, args) => + obj.asInstanceOf[BigInt].divide(args(0).asInstanceOf[BigInt]) + } + ) + ) + } + { + val clazz = classOf[CollBuilder] + registerClassEntry(clazz, + methods = Map( + mkMethod(clazz, "xor", Array[Class[_]](classOf[Coll[_]], classOf[Coll[_]])) { (obj, args) => + obj.asInstanceOf[CollBuilder].xor( + args(0).asInstanceOf[Coll[Byte]], + args(1).asInstanceOf[Coll[Byte]]) + }, + mkMethod(clazz, "fromItems", Array[Class[_]](classOf[Seq[_]], classOf[RType[_]])) { (obj, args) => + obj.asInstanceOf[CollBuilder].fromItems[Any]( + args(0).asInstanceOf[Seq[Any]]: _*)(args(1).asInstanceOf[RType[Any]]) + }, + mkMethod(clazz, "replicate", Array[Class[_]](classOf[Int], classOf[Object], classOf[RType[_]])) { (obj, args) => + obj.asInstanceOf[CollBuilder].replicate(args(0).asInstanceOf[Int], + args(1).asInstanceOf[Any])(args(2).asInstanceOf[RType[Any]]) + } + ) + ) + } + { + val clazz = classOf[Coll[_]] + registerClassEntry(clazz, + methods = Map( + mkMethod(clazz, "updated", Array[Class[_]](classOf[Int], classOf[java.lang.Object])) { (obj, args) => + obj.asInstanceOf[Coll[Any]].updated(args(0).asInstanceOf[Int], args(1).asInstanceOf[Any]) + }, + mkMethod(clazz, "flatMap", Array[Class[_]](classOf[Function1[_, _]], classOf[RType[_]])) { (obj, args) => + obj.asInstanceOf[Coll[Any]].flatMap( + args(0).asInstanceOf[Any => Coll[Any]])(args(1).asInstanceOf[RType[Any]]) + }, + mkMethod(clazz, "apply", Array[Class[_]](classOf[Int])) { (obj, args) => + obj.asInstanceOf[Coll[_]].apply(args(0).asInstanceOf[Int]) + }, + mkMethod(clazz, "append", Array[Class[_]](classOf[Coll[_]])) { (obj, args) => + obj.asInstanceOf[Coll[Any]].append(args(0).asInstanceOf[Coll[Any]]) + }, + mkMethod(clazz, "indexOf", Array[Class[_]](classOf[java.lang.Object], classOf[Int])) { (obj, args) => + obj.asInstanceOf[Coll[Any]].indexOf(args(0).asInstanceOf[Any], args(1).asInstanceOf[Int]) + }, + mkMethod(clazz, "map", Array[Class[_]](classOf[Function1[_, _]], classOf[RType[_]])) { (obj, args) => + obj.asInstanceOf[Coll[Any]].map(args(0).asInstanceOf[Any => Any])(args(1).asInstanceOf[RType[Any]]) + } + ) + ) + } + { + val clazz = classOf[AvlTree] + registerClassEntry(clazz, + methods = Map( + mkMethod(clazz, "updateOperations", Array[Class[_]](classOf[Byte])) { (obj, args) => + obj.asInstanceOf[AvlTree].updateOperations(args(0).asInstanceOf[Byte]) + }, + mkMethod(clazz, "getMany", Array[Class[_]](classOf[Coll[_]], classOf[Coll[_]])) { (obj, args) => + obj.asInstanceOf[AvlTree].getMany(args(0).asInstanceOf[Coll[Coll[Byte]]], + args(1).asInstanceOf[Coll[Byte]]) + }, + mkMethod(clazz, "update", Array[Class[_]](classOf[Coll[_]], classOf[Coll[_]])) { (obj, args) => + obj.asInstanceOf[AvlTree].update(args(0).asInstanceOf[Coll[(Coll[Byte], Coll[Byte])]], + args(1).asInstanceOf[Coll[Byte]]) + }, + mkMethod(clazz, "keyLength", Array[Class[_]]()) { (obj, _) => + obj.asInstanceOf[AvlTree].keyLength + }, + mkMethod(clazz, "enabledOperations", Array[Class[_]]()) { (obj, _) => + obj.asInstanceOf[AvlTree].enabledOperations + }, + mkMethod(clazz, "updateDigest", Array[Class[_]](classOf[Coll[_]])) { (obj, args) => + obj.asInstanceOf[AvlTree].updateDigest(args(0).asInstanceOf[Coll[Byte]]) + }, + mkMethod(clazz, "digest", Array[Class[_]]()) { (obj, _) => + obj.asInstanceOf[AvlTree].digest + }, + mkMethod(clazz, "insert", Array[Class[_]](classOf[Coll[_]], classOf[Coll[_]])) { (obj, args) => + obj.asInstanceOf[AvlTree].insert(args(0).asInstanceOf[Coll[(Coll[Byte], Coll[Byte])]], + args(1).asInstanceOf[Coll[Byte]]) + }, + mkMethod(clazz, "isRemoveAllowed", Array[Class[_]]()) { (obj, _) => + obj.asInstanceOf[AvlTree].isRemoveAllowed + }, + mkMethod(clazz, "valueLengthOpt", Array[Class[_]]()) { (obj, _) => + obj.asInstanceOf[AvlTree].valueLengthOpt + }, + mkMethod(clazz, "get", Array[Class[_]](classOf[Coll[_]], classOf[Coll[_]])) { (obj, args) => + obj.asInstanceOf[AvlTree].get(args(0).asInstanceOf[Coll[Byte]], + args(1).asInstanceOf[Coll[Byte]]) + }, + mkMethod(clazz, "remove", Array[Class[_]](classOf[Coll[_]], classOf[Coll[_]])) { (obj, args) => + obj.asInstanceOf[AvlTree].remove(args(0).asInstanceOf[Coll[Coll[Byte]]], args(1).asInstanceOf[Coll[Byte]]) + }, + mkMethod(clazz, "contains", Array[Class[_]](classOf[Coll[_]], classOf[Coll[_]])) { (obj, args) => + obj.asInstanceOf[AvlTree].contains(args(0).asInstanceOf[Coll[Byte]], + args(1).asInstanceOf[Coll[Byte]]) + }, + mkMethod(clazz, "isUpdateAllowed", Array[Class[_]]()) { (obj, _) => + obj.asInstanceOf[AvlTree].isUpdateAllowed + }, + mkMethod(clazz, "isInsertAllowed", Array[Class[_]]()) { (obj, _) => + obj.asInstanceOf[AvlTree].isInsertAllowed + } + ) + ) + } + { + val clazz = classOf[Box] + registerClassEntry(clazz, + methods = Map( + mkMethod(clazz, "value", Array[Class[_]]()) { (obj, _) => + obj.asInstanceOf[Box].value + }, + mkMethod(clazz, "id", Array[Class[_]]()) { (obj, _) => + obj.asInstanceOf[Box].id + }, + mkMethod(clazz, "creationInfo", Array[Class[_]]()) { (obj, _) => + obj.asInstanceOf[Box].creationInfo + }, + mkMethod(clazz, "bytes", Array[Class[_]]()) { (obj, _) => + obj.asInstanceOf[Box].bytes + }, + mkMethod(clazz, "tokens", Array[Class[_]]()) { (obj, _) => + obj.asInstanceOf[Box].tokens + }, + mkMethod(clazz, "getReg", Array[Class[_]](classOf[Int], classOf[RType[_]])) { (obj, args) => + obj.asInstanceOf[Box].getReg(args(0).asInstanceOf[Int])(args(1).asInstanceOf[RType[_]]) + }, + mkMethod(clazz, "bytesWithoutRef", Array[Class[_]]()) { (obj, _) => + obj.asInstanceOf[Box].bytesWithoutRef + }, + mkMethod(clazz, "propositionBytes", Array[Class[_]]()) { (obj, _) => + obj.asInstanceOf[Box].propositionBytes + } + ) + ) + } + { + val clazz = classOf[Context] + registerClassEntry(clazz, + methods = Map( + mkMethod(clazz, "LastBlockUtxoRootHash", Array[Class[_]]()) { (obj, _) => + obj.asInstanceOf[Context].LastBlockUtxoRootHash + }, + mkMethod(clazz, "dataInputs", Array[Class[_]]()) { (obj, _) => + obj.asInstanceOf[Context].dataInputs + }, + mkMethod(clazz, "selfBoxIndex", Array[Class[_]]()) { (obj, _) => + obj.asInstanceOf[Context].selfBoxIndex + }, + mkMethod(clazz, "INPUTS", Array[Class[_]]()) { (obj, _) => + obj.asInstanceOf[Context].INPUTS + }, + mkMethod(clazz, "minerPubKey", Array[Class[_]]()) { (obj, _) => + obj.asInstanceOf[Context].minerPubKey + }, + mkMethod(clazz, "HEIGHT", Array[Class[_]]()) { (obj, _) => + obj.asInstanceOf[Context].HEIGHT + }, + mkMethod(clazz, "OUTPUTS", Array[Class[_]]()) { (obj, _) => + obj.asInstanceOf[Context].OUTPUTS + }, + mkMethod(clazz, "SELF", Array[Class[_]]()) { (obj, _) => + obj.asInstanceOf[Context].SELF + }, + mkMethod(clazz, "preHeader", Array[Class[_]]()) { (obj, _) => + obj.asInstanceOf[Context].preHeader + }, + mkMethod(clazz, "getVar", Array[Class[_]](classOf[Byte], classOf[RType[_]])) { (obj, args) => + obj.asInstanceOf[Context].getVar(args(0).asInstanceOf[Byte])(args(1).asInstanceOf[RType[_]]) + }, + mkMethod(clazz, "headers", Array[Class[_]]()) { (obj, _) => + obj.asInstanceOf[Context].headers + } + ) + ) + } + { + val clazz = classOf[GroupElement] + registerClassEntry(clazz, + methods = Map( + mkMethod(clazz, "exp", Array[Class[_]](classOf[BigInt])) { (obj, args) => + obj.asInstanceOf[GroupElement].exp(args(0).asInstanceOf[BigInt]) + }, + mkMethod(clazz, "multiply", Array[Class[_]](classOf[GroupElement])) { (obj, args) => + obj.asInstanceOf[GroupElement].multiply(args(0).asInstanceOf[GroupElement]) + }, + mkMethod(clazz, "getEncoded", Array[Class[_]]()) { (obj, _) => + obj.asInstanceOf[GroupElement].getEncoded + }, + mkMethod(clazz, "negate", Array[Class[_]]()) { (obj, _) => + obj.asInstanceOf[GroupElement].negate + } + ) + ) + } + { + val clazz = classOf[Header] + registerClassEntry(clazz, + methods = Map( + mkMethod(clazz, "minerPk", Array[Class[_]]()) { (obj, _) => + obj.asInstanceOf[Header].minerPk + }, + mkMethod(clazz, "powNonce", Array[Class[_]]()) { (obj, _) => + obj.asInstanceOf[Header].powNonce + }, + mkMethod(clazz, "transactionsRoot", Array[Class[_]]()) { (obj, _) => + obj.asInstanceOf[Header].transactionsRoot + }, + mkMethod(clazz, "powOnetimePk", Array[Class[_]]()) { (obj, _) => + obj.asInstanceOf[Header].powOnetimePk + }, + mkMethod(clazz, "nBits", Array[Class[_]]()) { (obj, _) => + obj.asInstanceOf[Header].nBits + }, + mkMethod(clazz, "votes", Array[Class[_]]()) { (obj, _) => + obj.asInstanceOf[Header].votes + }, + mkMethod(clazz, "id", Array[Class[_]]()) { (obj, _) => + obj.asInstanceOf[Header].id + }, + mkMethod(clazz, "version", Array[Class[_]]()) { (obj, _) => + obj.asInstanceOf[Header].version + }, + mkMethod(clazz, "parentId", Array[Class[_]]()) { (obj, _) => + obj.asInstanceOf[Header].parentId + }, + mkMethod(clazz, "timestamp", Array[Class[_]]()) { (obj, _) => + obj.asInstanceOf[Header].timestamp + }, + mkMethod(clazz, "height", Array[Class[_]]()) { (obj, _) => + obj.asInstanceOf[Header].height + }, + mkMethod(clazz, "extensionRoot", Array[Class[_]]()) { (obj, _) => + obj.asInstanceOf[Header].extensionRoot + }, + mkMethod(clazz, "ADProofsRoot", Array[Class[_]]()) { (obj, _) => + obj.asInstanceOf[Header].ADProofsRoot + }, + mkMethod(clazz, "stateRoot", Array[Class[_]]()) { (obj, _) => + obj.asInstanceOf[Header].stateRoot + }, + mkMethod(clazz, "powDistance", Array[Class[_]]()) { (obj, _) => + obj.asInstanceOf[Header].powDistance + } + ) + ) + } + { + val clazz = classOf[PreHeader] + registerClassEntry(clazz, + methods = Map( + mkMethod(clazz, "minerPk", Array[Class[_]]()) { (obj, _) => + obj.asInstanceOf[PreHeader].minerPk + }, + mkMethod(clazz, "votes", Array[Class[_]]()) { (obj, _) => + obj.asInstanceOf[PreHeader].votes + }, + mkMethod(clazz, "nBits", Array[Class[_]]()) { (obj, _) => + obj.asInstanceOf[PreHeader].nBits + }, + mkMethod(clazz, "version", Array[Class[_]]()) { (obj, _) => + obj.asInstanceOf[PreHeader].version + }, + mkMethod(clazz, "timestamp", Array[Class[_]]()) { (obj, _) => + obj.asInstanceOf[PreHeader].timestamp + }, + mkMethod(clazz, "parentId", Array[Class[_]]()) { (obj, _) => + obj.asInstanceOf[PreHeader].parentId + }, + mkMethod(clazz, "height", Array[Class[_]]()) { (obj, _) => + obj.asInstanceOf[PreHeader].height + } + ) + ) + } + { + val clazz = classOf[SigmaDslBuilder] + val cColl = classOf[Coll[_]] + val cGroupElement = classOf[GroupElement] + registerClassEntry(clazz, + methods = Map( + mkMethod(clazz, "byteArrayToLong", Array[Class[_]](cColl)) { (obj, args) => + obj.asInstanceOf[SigmaDslBuilder].byteArrayToLong(args(0).asInstanceOf[Coll[Byte]]) + }, + mkMethod(clazz, "anyOf", Array[Class[_]](cColl)) { (obj, args) => + obj.asInstanceOf[SigmaDslBuilder].anyOf(args(0).asInstanceOf[Coll[Boolean]]) + }, + mkMethod(clazz, "allZK", Array[Class[_]](cColl)) { (obj, args) => + obj.asInstanceOf[SigmaDslBuilder].allZK(args(0).asInstanceOf[Coll[SigmaProp]]) + }, + mkMethod(clazz, "xorOf", Array[Class[_]](cColl)) { (obj, args) => + obj.asInstanceOf[SigmaDslBuilder].xorOf(args(0).asInstanceOf[Coll[Boolean]]) + }, + mkMethod(clazz, "substConstants", Array[Class[_]](cColl, cColl, cColl)) { (obj, args) => + obj.asInstanceOf[SigmaDslBuilder].substConstants(args(0).asInstanceOf[Coll[Byte]], + args(1).asInstanceOf[Coll[Int]], args(2).asInstanceOf[Coll[Any]]) + }, + mkMethod(clazz, "groupGenerator", Array[Class[_]]()) { (obj, _) => + obj.asInstanceOf[SigmaDslBuilder].groupGenerator + }, + mkMethod(clazz, "sigmaProp", Array[Class[_]](classOf[Boolean])) { (obj, args) => + obj.asInstanceOf[SigmaDslBuilder].sigmaProp(args(0).asInstanceOf[Boolean]) + }, + mkMethod(clazz, "proveDlog", Array[Class[_]](cGroupElement)) { (obj, args) => + obj.asInstanceOf[SigmaDslBuilder].proveDlog(args(0).asInstanceOf[GroupElement]) + }, + mkMethod(clazz, "blake2b256", Array[Class[_]](cColl)) { (obj, args) => + obj.asInstanceOf[SigmaDslBuilder].blake2b256(args(0).asInstanceOf[Coll[Byte]]) + }, + mkMethod(clazz, "longToByteArray", Array[Class[_]](classOf[Long])) { (obj, args) => + obj.asInstanceOf[SigmaDslBuilder].longToByteArray(args(0).asInstanceOf[Long]) + }, + mkMethod(clazz, "xor", Array[Class[_]](cColl, cColl)) { (obj, args) => + obj.asInstanceOf[SigmaDslBuilder].xor(args(0).asInstanceOf[Coll[Byte]], + args(1).asInstanceOf[Coll[Byte]]) + }, + mkMethod(clazz, "atLeast", Array[Class[_]](classOf[Int], cColl)) { (obj, args) => + obj.asInstanceOf[SigmaDslBuilder].atLeast(args(0).asInstanceOf[Int], + args(1).asInstanceOf[Coll[SigmaProp]]) + }, + mkMethod(clazz, "byteArrayToBigInt", Array[Class[_]](cColl)) { (obj, args) => + obj.asInstanceOf[SigmaDslBuilder].byteArrayToBigInt(args(0).asInstanceOf[Coll[Byte]]) + }, + mkMethod(clazz, "allOf", Array[Class[_]](cColl)) { (obj, args) => + obj.asInstanceOf[SigmaDslBuilder].allOf(args(0).asInstanceOf[Coll[Boolean]]) + }, + mkMethod(clazz, "proveDHTuple", Array[Class[_]](cGroupElement, cGroupElement, cGroupElement, cGroupElement)) { (obj, args) => + obj.asInstanceOf[SigmaDslBuilder].proveDHTuple(args(0).asInstanceOf[GroupElement], + args(1).asInstanceOf[GroupElement], + args(2).asInstanceOf[GroupElement], + args(3).asInstanceOf[GroupElement]) + }, + mkMethod(clazz, "anyZK", Array[Class[_]](cColl)) { (obj, args) => + obj.asInstanceOf[SigmaDslBuilder].anyZK(args(0).asInstanceOf[Coll[SigmaProp]]) + }, + mkMethod(clazz, "sha256", Array[Class[_]](cColl)) { (obj, args) => + obj.asInstanceOf[SigmaDslBuilder].sha256(args(0).asInstanceOf[Coll[Byte]]) + }, + mkMethod(clazz, "decodePoint", Array[Class[_]](cColl)) { (obj, args) => + obj.asInstanceOf[SigmaDslBuilder].decodePoint(args(0).asInstanceOf[Coll[Byte]]) + } + ) + ) + } } diff --git a/interpreter/shared/src/main/scala/sigmastate/InterpreterReflection.scala b/interpreter/shared/src/main/scala/sigmastate/InterpreterReflection.scala index 4f89b9a465..3e92ac1b31 100644 --- a/interpreter/shared/src/main/scala/sigmastate/InterpreterReflection.scala +++ b/interpreter/shared/src/main/scala/sigmastate/InterpreterReflection.scala @@ -2,9 +2,9 @@ package sigmastate import org.ergoplatform.ErgoBox.RegisterId import sigma.reflection.CommonReflection.registerClassEntry -import sigma.reflection.{mkConstructor, mkMethod} +import sigma.reflection.{CommonReflection, mkConstructor, mkMethod} import sigma.Coll -import sigma.{AvlTree, CoreLibReflection, SigmaDslBuilder} +import sigma.{AvlTree, SigmaDslBuilder} import sigmastate.SAvlTree.KeyValueColl import sigmastate.SCollection.{SBooleanArray, SByteArray, SIntArray} import sigmastate.Values._ @@ -21,7 +21,7 @@ import sigmastate.utxo._ * Only information that is needed at runtime is registered. */ object InterpreterReflection { - val reflection = CoreLibReflection + val reflection = CommonReflection registerClassEntry(classOf[AND], constructors = Array( diff --git a/sc/shared/src/main/scala/scalan/GraphIRReflection.scala b/sc/shared/src/main/scala/scalan/GraphIRReflection.scala index 2b1e8c95b6..52686c14f5 100644 --- a/sc/shared/src/main/scala/scalan/GraphIRReflection.scala +++ b/sc/shared/src/main/scala/scalan/GraphIRReflection.scala @@ -3,7 +3,6 @@ package scalan import scalan.primitives.Thunks import sigma.reflection.CommonReflection.registerClassEntry import sigma.reflection.{CommonReflection, mkConstructor, mkMethod} -import sigma.CoreLibReflection import sigmastate.eval.SigmaLibrary import sigma.Colls import sigma.SigmaDsl @@ -18,7 +17,7 @@ import wrappers.scalan.WRTypes */ object GraphIRReflection { /** Forces initialization of reflection data. */ - val reflection = (CommonReflection, CoreLibReflection) + val reflection = CommonReflection { val clazz = classOf[wrappers.scala.WOptions#WOption[_]] val ctx = null.asInstanceOf[scalan.Library] // ok! type level only diff --git a/sc/shared/src/test/scala/scalan/TestContexts.scala b/sc/shared/src/test/scala/scalan/TestContexts.scala index 9811473d3a..a86bf42276 100644 --- a/sc/shared/src/test/scala/scalan/TestContexts.scala +++ b/sc/shared/src/test/scala/scalan/TestContexts.scala @@ -1,7 +1,7 @@ package scalan import sigma.reflection.RMethod -import sigma.{BaseNestedTests, BaseShouldTests, BaseTests, CoreLibReflection, TestUtils} +import sigma.{BaseNestedTests, BaseShouldTests, BaseTests, TestUtils} trait TestContexts extends TestUtils { @@ -35,7 +35,7 @@ trait TestContexts extends TestUtils { } abstract class BaseCtxTests extends BaseTests with TestContexts { - val reflection = (CoreLibReflection, GraphIRReflection) + val reflection = GraphIRReflection } abstract class BaseNestedCtxTests extends BaseNestedTests with TestContexts diff --git a/sdk/shared/src/main/scala/org/ergoplatform/sdk/JavaHelpers.scala b/sdk/shared/src/main/scala/org/ergoplatform/sdk/JavaHelpers.scala index d0c64fbfa7..328ffba714 100644 --- a/sdk/shared/src/main/scala/org/ergoplatform/sdk/JavaHelpers.scala +++ b/sdk/shared/src/main/scala/org/ergoplatform/sdk/JavaHelpers.scala @@ -9,6 +9,7 @@ import org.ergoplatform.sdk.wallet.secrets.{DerivationPath, ExtendedSecretKey} import org.ergoplatform.sdk.wallet.{Constants, TokensMap} import org.ergoplatform.settings.ErgoAlgos import scorex.crypto.authds.ADKey +import sigmastate.utils.Helpers._ // don't remove, required for Scala 2.11 import scorex.util.encode.Base16 import scorex.util.{ModifierId, bytesToId, idToBytes} import sigma.data.ExactIntegral.LongIsExactIntegral From c01113a0988e5db6ef52d7b56170a1d9a0642abc Mon Sep 17 00:00:00 2001 From: Alexander Slesarenko Date: Fri, 25 Aug 2023 18:39:21 +0200 Subject: [PATCH 24/37] minimize-modules: common module renamed to core --- build.sbt | 14 +++++++------- .../src/main/scala/sigma/reflection/Platform.scala | 0 .../src/main/scala/sigma/reflection/JavaImpl.scala | 0 .../src/main/scala/sigma/reflection/Platform.scala | 0 .../jvm/src/test/scala/sigma/util/FileUtil.scala | 0 .../src/test/scala/sigma/util/FileUtilTests.scala | 0 .../src/test/scala/sigma/util/ProcessUtil.scala | 0 .../scala-2.11/sigma/kiama/util/Collections.scala | 0 .../scala-2.12/sigma/kiama/util/Collections.scala | 0 .../scala-2.13/sigma/kiama/util/Collections.scala | 0 .../shared/src/main/scala/java7/compat/Math.scala | 0 .../shared/src/main/scala/sigma/Colls.scala | 0 .../shared/src/main/scala/sigma/Environment.scala | 0 .../shared/src/main/scala/sigma/Extensions.scala | 0 .../src/main/scala/sigma/RuntimePlatform.scala | 0 .../shared/src/main/scala/sigma/SigmaDsl.scala | 0 .../src/main/scala/sigma/VersionContext.scala | 0 .../shared/src/main/scala/sigma/data/AnyVals.scala | 0 .../main/scala/sigma/data/CollsOverArrays.scala | 0 .../shared/src/main/scala/sigma/data/DFunc.scala | 0 .../shared/src/main/scala/sigma/data/Lazy.scala | 0 .../src/main/scala/sigma/data/OverloadHack.scala | 0 .../shared/src/main/scala/sigma/data/RType.scala | 0 .../shared/src/main/scala/sigma/data/package.scala | 0 .../shared/src/main/scala/sigma/kiama/kiama.scala | 0 .../sigma/kiama/rewriting/CallbackRewriter.scala | 0 .../scala/sigma/kiama/rewriting/PlusStrategy.scala | 0 .../scala/sigma/kiama/rewriting/Rewriter.scala | 0 .../scala/sigma/kiama/rewriting/Strategy.scala | 0 .../main/scala/sigma/kiama/util/Comparison.scala | 0 .../shared/src/main/scala/sigma/package.scala | 0 .../scala/sigma/reflection/CommonReflection.scala | 0 .../src/main/scala/sigma/reflection/RClass.scala | 0 .../main/scala/sigma/reflection/StaticImpl.scala | 0 .../src/main/scala/sigma/reflection/package.scala | 0 .../src/main/scala/sigma/util/CollectionUtil.scala | 0 .../src/main/scala/sigma/util/Extensions.scala | 0 .../src/main/scala/sigma/util/GraphUtil.scala | 0 .../src/main/scala/sigma/util/MemoizedFunc.scala | 0 .../src/main/scala/sigma/util/StringUtil.scala | 0 .../shared/src/main/scala/sigma/util/package.scala | 0 .../shared/src/test/resources/root/A.txt | 0 .../shared/src/test/resources/root/B.txt | 0 .../shared/src/test/resources/root/subdir/C.txt | 0 .../src/test/resources/root/subdir/subsubdir/D.txt | 0 .../shared/src/test/scala/sigma/BaseTests.scala | 0 .../shared/src/test/scala/sigma/CollGens.scala | 0 .../shared/src/test/scala/sigma/CollsTests.scala | 0 .../shared/src/test/scala/sigma/TestUtils.scala | 0 .../shared/src/test/scala/sigma/TypesTests.scala | 0 .../src/test/scala/sigma/VersionTesting.scala | 0 .../test/scala/sigma/VersionTestingProperty.scala | 0 .../src/test/scala/sigma/util/BenchmarkUtil.scala | 0 .../scala/sigma/util/CollectionUtilTests.scala | 0 .../src/test/scala/sigma/util/GraphUtilTests.scala | 0 .../test/scala/sigma/util/PrintExtensions.scala | 0 .../test/scala/sigma/util/StringUtilTests.scala | 0 .../util/StronglyConnectedComponentsTests.scala | 0 58 files changed, 7 insertions(+), 7 deletions(-) rename {common => core}/js/src/main/scala/sigma/reflection/Platform.scala (100%) rename {common => core}/jvm/src/main/scala/sigma/reflection/JavaImpl.scala (100%) rename {common => core}/jvm/src/main/scala/sigma/reflection/Platform.scala (100%) rename {common => core}/jvm/src/test/scala/sigma/util/FileUtil.scala (100%) rename {common => core}/jvm/src/test/scala/sigma/util/FileUtilTests.scala (100%) rename {common => core}/jvm/src/test/scala/sigma/util/ProcessUtil.scala (100%) rename {common => core}/shared/src/main/scala-2.11/sigma/kiama/util/Collections.scala (100%) rename {common => core}/shared/src/main/scala-2.12/sigma/kiama/util/Collections.scala (100%) rename {common => core}/shared/src/main/scala-2.13/sigma/kiama/util/Collections.scala (100%) rename {common => core}/shared/src/main/scala/java7/compat/Math.scala (100%) rename {common => core}/shared/src/main/scala/sigma/Colls.scala (100%) rename {common => core}/shared/src/main/scala/sigma/Environment.scala (100%) rename {common => core}/shared/src/main/scala/sigma/Extensions.scala (100%) rename {common => core}/shared/src/main/scala/sigma/RuntimePlatform.scala (100%) rename {common => core}/shared/src/main/scala/sigma/SigmaDsl.scala (100%) rename {common => core}/shared/src/main/scala/sigma/VersionContext.scala (100%) rename {common => core}/shared/src/main/scala/sigma/data/AnyVals.scala (100%) rename {common => core}/shared/src/main/scala/sigma/data/CollsOverArrays.scala (100%) rename {common => core}/shared/src/main/scala/sigma/data/DFunc.scala (100%) rename {common => core}/shared/src/main/scala/sigma/data/Lazy.scala (100%) rename {common => core}/shared/src/main/scala/sigma/data/OverloadHack.scala (100%) rename {common => core}/shared/src/main/scala/sigma/data/RType.scala (100%) rename {common => core}/shared/src/main/scala/sigma/data/package.scala (100%) rename {common => core}/shared/src/main/scala/sigma/kiama/kiama.scala (100%) rename {common => core}/shared/src/main/scala/sigma/kiama/rewriting/CallbackRewriter.scala (100%) rename {common => core}/shared/src/main/scala/sigma/kiama/rewriting/PlusStrategy.scala (100%) rename {common => core}/shared/src/main/scala/sigma/kiama/rewriting/Rewriter.scala (100%) rename {common => core}/shared/src/main/scala/sigma/kiama/rewriting/Strategy.scala (100%) rename {common => core}/shared/src/main/scala/sigma/kiama/util/Comparison.scala (100%) rename {common => core}/shared/src/main/scala/sigma/package.scala (100%) rename {common => core}/shared/src/main/scala/sigma/reflection/CommonReflection.scala (100%) rename {common => core}/shared/src/main/scala/sigma/reflection/RClass.scala (100%) rename {common => core}/shared/src/main/scala/sigma/reflection/StaticImpl.scala (100%) rename {common => core}/shared/src/main/scala/sigma/reflection/package.scala (100%) rename {common => core}/shared/src/main/scala/sigma/util/CollectionUtil.scala (100%) rename {common => core}/shared/src/main/scala/sigma/util/Extensions.scala (100%) rename {common => core}/shared/src/main/scala/sigma/util/GraphUtil.scala (100%) rename {common => core}/shared/src/main/scala/sigma/util/MemoizedFunc.scala (100%) rename {common => core}/shared/src/main/scala/sigma/util/StringUtil.scala (100%) rename {common => core}/shared/src/main/scala/sigma/util/package.scala (100%) rename {common => core}/shared/src/test/resources/root/A.txt (100%) rename {common => core}/shared/src/test/resources/root/B.txt (100%) rename {common => core}/shared/src/test/resources/root/subdir/C.txt (100%) rename {common => core}/shared/src/test/resources/root/subdir/subsubdir/D.txt (100%) rename {common => core}/shared/src/test/scala/sigma/BaseTests.scala (100%) rename {common => core}/shared/src/test/scala/sigma/CollGens.scala (100%) rename {common => core}/shared/src/test/scala/sigma/CollsTests.scala (100%) rename {common => core}/shared/src/test/scala/sigma/TestUtils.scala (100%) rename {common => core}/shared/src/test/scala/sigma/TypesTests.scala (100%) rename {common => core}/shared/src/test/scala/sigma/VersionTesting.scala (100%) rename {common => core}/shared/src/test/scala/sigma/VersionTestingProperty.scala (100%) rename {common => core}/shared/src/test/scala/sigma/util/BenchmarkUtil.scala (100%) rename {common => core}/shared/src/test/scala/sigma/util/CollectionUtilTests.scala (100%) rename {common => core}/shared/src/test/scala/sigma/util/GraphUtilTests.scala (100%) rename {common => core}/shared/src/test/scala/sigma/util/PrintExtensions.scala (100%) rename {common => core}/shared/src/test/scala/sigma/util/StringUtilTests.scala (100%) rename {common => core}/shared/src/test/scala/sigma/util/StronglyConnectedComponentsTests.scala (100%) diff --git a/build.sbt b/build.sbt index 9474790e54..88d5a597fe 100644 --- a/build.sbt +++ b/build.sbt @@ -188,8 +188,8 @@ lazy val commonDependenies2 = libraryDependencies ++= Seq( val sigmajsCryptoFacadeVersion = "0.0.7" -lazy val common = crossProject(JVMPlatform, JSPlatform) - .in(file("common")) +lazy val core = crossProject(JVMPlatform, JSPlatform) + .in(file("core")) .settings(commonSettings ++ testSettings2, commonDependenies2, testingDependencies2, @@ -210,12 +210,12 @@ lazy val common = crossProject(JVMPlatform, JSPlatform) ), useYarn := true ) -lazy val commonJS = common.js +lazy val coreJS = core.js .enablePlugins(ScalaJSBundlerPlugin) lazy val interpreter = crossProject(JVMPlatform, JSPlatform) .in(file("interpreter")) - .dependsOn(common % allConfigDependency) + .dependsOn(core % allConfigDependency) .settings( commonSettings ++ testSettings2, commonDependenies2, @@ -278,7 +278,7 @@ lazy val parsersJS = parsers.js lazy val sdk = crossProject(JVMPlatform, JSPlatform) .in(file("sdk")) - .dependsOn(common % allConfigDependency, interpreter % allConfigDependency, parsers % allConfigDependency) + .dependsOn(core % allConfigDependency, interpreter % allConfigDependency, parsers % allConfigDependency) .settings(commonSettings ++ testSettings2, commonDependenies2, testingDependencies2, @@ -355,13 +355,13 @@ lazy val scJS = sc.js lazy val sigma = (project in file(".")) - .aggregate(common.jvm, interpreter.jvm, parsers.jvm, sdk.jvm, sc.jvm) + .aggregate(core.jvm, interpreter.jvm, parsers.jvm, sdk.jvm, sc.jvm) .settings(libraryDefSettings, rootSettings) .settings(publish / aggregate := false) .settings(publishLocal / aggregate := false) lazy val aggregateCompile = ScopeFilter( - inProjects(common.jvm, interpreter.jvm, parsers.jvm, sdk.jvm, sc.jvm), + inProjects(core.jvm, interpreter.jvm, parsers.jvm, sdk.jvm, sc.jvm), inConfigurations(Compile)) lazy val rootSettings = Seq( diff --git a/common/js/src/main/scala/sigma/reflection/Platform.scala b/core/js/src/main/scala/sigma/reflection/Platform.scala similarity index 100% rename from common/js/src/main/scala/sigma/reflection/Platform.scala rename to core/js/src/main/scala/sigma/reflection/Platform.scala diff --git a/common/jvm/src/main/scala/sigma/reflection/JavaImpl.scala b/core/jvm/src/main/scala/sigma/reflection/JavaImpl.scala similarity index 100% rename from common/jvm/src/main/scala/sigma/reflection/JavaImpl.scala rename to core/jvm/src/main/scala/sigma/reflection/JavaImpl.scala diff --git a/common/jvm/src/main/scala/sigma/reflection/Platform.scala b/core/jvm/src/main/scala/sigma/reflection/Platform.scala similarity index 100% rename from common/jvm/src/main/scala/sigma/reflection/Platform.scala rename to core/jvm/src/main/scala/sigma/reflection/Platform.scala diff --git a/common/jvm/src/test/scala/sigma/util/FileUtil.scala b/core/jvm/src/test/scala/sigma/util/FileUtil.scala similarity index 100% rename from common/jvm/src/test/scala/sigma/util/FileUtil.scala rename to core/jvm/src/test/scala/sigma/util/FileUtil.scala diff --git a/common/jvm/src/test/scala/sigma/util/FileUtilTests.scala b/core/jvm/src/test/scala/sigma/util/FileUtilTests.scala similarity index 100% rename from common/jvm/src/test/scala/sigma/util/FileUtilTests.scala rename to core/jvm/src/test/scala/sigma/util/FileUtilTests.scala diff --git a/common/jvm/src/test/scala/sigma/util/ProcessUtil.scala b/core/jvm/src/test/scala/sigma/util/ProcessUtil.scala similarity index 100% rename from common/jvm/src/test/scala/sigma/util/ProcessUtil.scala rename to core/jvm/src/test/scala/sigma/util/ProcessUtil.scala diff --git a/common/shared/src/main/scala-2.11/sigma/kiama/util/Collections.scala b/core/shared/src/main/scala-2.11/sigma/kiama/util/Collections.scala similarity index 100% rename from common/shared/src/main/scala-2.11/sigma/kiama/util/Collections.scala rename to core/shared/src/main/scala-2.11/sigma/kiama/util/Collections.scala diff --git a/common/shared/src/main/scala-2.12/sigma/kiama/util/Collections.scala b/core/shared/src/main/scala-2.12/sigma/kiama/util/Collections.scala similarity index 100% rename from common/shared/src/main/scala-2.12/sigma/kiama/util/Collections.scala rename to core/shared/src/main/scala-2.12/sigma/kiama/util/Collections.scala diff --git a/common/shared/src/main/scala-2.13/sigma/kiama/util/Collections.scala b/core/shared/src/main/scala-2.13/sigma/kiama/util/Collections.scala similarity index 100% rename from common/shared/src/main/scala-2.13/sigma/kiama/util/Collections.scala rename to core/shared/src/main/scala-2.13/sigma/kiama/util/Collections.scala diff --git a/common/shared/src/main/scala/java7/compat/Math.scala b/core/shared/src/main/scala/java7/compat/Math.scala similarity index 100% rename from common/shared/src/main/scala/java7/compat/Math.scala rename to core/shared/src/main/scala/java7/compat/Math.scala diff --git a/common/shared/src/main/scala/sigma/Colls.scala b/core/shared/src/main/scala/sigma/Colls.scala similarity index 100% rename from common/shared/src/main/scala/sigma/Colls.scala rename to core/shared/src/main/scala/sigma/Colls.scala diff --git a/common/shared/src/main/scala/sigma/Environment.scala b/core/shared/src/main/scala/sigma/Environment.scala similarity index 100% rename from common/shared/src/main/scala/sigma/Environment.scala rename to core/shared/src/main/scala/sigma/Environment.scala diff --git a/common/shared/src/main/scala/sigma/Extensions.scala b/core/shared/src/main/scala/sigma/Extensions.scala similarity index 100% rename from common/shared/src/main/scala/sigma/Extensions.scala rename to core/shared/src/main/scala/sigma/Extensions.scala diff --git a/common/shared/src/main/scala/sigma/RuntimePlatform.scala b/core/shared/src/main/scala/sigma/RuntimePlatform.scala similarity index 100% rename from common/shared/src/main/scala/sigma/RuntimePlatform.scala rename to core/shared/src/main/scala/sigma/RuntimePlatform.scala diff --git a/common/shared/src/main/scala/sigma/SigmaDsl.scala b/core/shared/src/main/scala/sigma/SigmaDsl.scala similarity index 100% rename from common/shared/src/main/scala/sigma/SigmaDsl.scala rename to core/shared/src/main/scala/sigma/SigmaDsl.scala diff --git a/common/shared/src/main/scala/sigma/VersionContext.scala b/core/shared/src/main/scala/sigma/VersionContext.scala similarity index 100% rename from common/shared/src/main/scala/sigma/VersionContext.scala rename to core/shared/src/main/scala/sigma/VersionContext.scala diff --git a/common/shared/src/main/scala/sigma/data/AnyVals.scala b/core/shared/src/main/scala/sigma/data/AnyVals.scala similarity index 100% rename from common/shared/src/main/scala/sigma/data/AnyVals.scala rename to core/shared/src/main/scala/sigma/data/AnyVals.scala diff --git a/common/shared/src/main/scala/sigma/data/CollsOverArrays.scala b/core/shared/src/main/scala/sigma/data/CollsOverArrays.scala similarity index 100% rename from common/shared/src/main/scala/sigma/data/CollsOverArrays.scala rename to core/shared/src/main/scala/sigma/data/CollsOverArrays.scala diff --git a/common/shared/src/main/scala/sigma/data/DFunc.scala b/core/shared/src/main/scala/sigma/data/DFunc.scala similarity index 100% rename from common/shared/src/main/scala/sigma/data/DFunc.scala rename to core/shared/src/main/scala/sigma/data/DFunc.scala diff --git a/common/shared/src/main/scala/sigma/data/Lazy.scala b/core/shared/src/main/scala/sigma/data/Lazy.scala similarity index 100% rename from common/shared/src/main/scala/sigma/data/Lazy.scala rename to core/shared/src/main/scala/sigma/data/Lazy.scala diff --git a/common/shared/src/main/scala/sigma/data/OverloadHack.scala b/core/shared/src/main/scala/sigma/data/OverloadHack.scala similarity index 100% rename from common/shared/src/main/scala/sigma/data/OverloadHack.scala rename to core/shared/src/main/scala/sigma/data/OverloadHack.scala diff --git a/common/shared/src/main/scala/sigma/data/RType.scala b/core/shared/src/main/scala/sigma/data/RType.scala similarity index 100% rename from common/shared/src/main/scala/sigma/data/RType.scala rename to core/shared/src/main/scala/sigma/data/RType.scala diff --git a/common/shared/src/main/scala/sigma/data/package.scala b/core/shared/src/main/scala/sigma/data/package.scala similarity index 100% rename from common/shared/src/main/scala/sigma/data/package.scala rename to core/shared/src/main/scala/sigma/data/package.scala diff --git a/common/shared/src/main/scala/sigma/kiama/kiama.scala b/core/shared/src/main/scala/sigma/kiama/kiama.scala similarity index 100% rename from common/shared/src/main/scala/sigma/kiama/kiama.scala rename to core/shared/src/main/scala/sigma/kiama/kiama.scala diff --git a/common/shared/src/main/scala/sigma/kiama/rewriting/CallbackRewriter.scala b/core/shared/src/main/scala/sigma/kiama/rewriting/CallbackRewriter.scala similarity index 100% rename from common/shared/src/main/scala/sigma/kiama/rewriting/CallbackRewriter.scala rename to core/shared/src/main/scala/sigma/kiama/rewriting/CallbackRewriter.scala diff --git a/common/shared/src/main/scala/sigma/kiama/rewriting/PlusStrategy.scala b/core/shared/src/main/scala/sigma/kiama/rewriting/PlusStrategy.scala similarity index 100% rename from common/shared/src/main/scala/sigma/kiama/rewriting/PlusStrategy.scala rename to core/shared/src/main/scala/sigma/kiama/rewriting/PlusStrategy.scala diff --git a/common/shared/src/main/scala/sigma/kiama/rewriting/Rewriter.scala b/core/shared/src/main/scala/sigma/kiama/rewriting/Rewriter.scala similarity index 100% rename from common/shared/src/main/scala/sigma/kiama/rewriting/Rewriter.scala rename to core/shared/src/main/scala/sigma/kiama/rewriting/Rewriter.scala diff --git a/common/shared/src/main/scala/sigma/kiama/rewriting/Strategy.scala b/core/shared/src/main/scala/sigma/kiama/rewriting/Strategy.scala similarity index 100% rename from common/shared/src/main/scala/sigma/kiama/rewriting/Strategy.scala rename to core/shared/src/main/scala/sigma/kiama/rewriting/Strategy.scala diff --git a/common/shared/src/main/scala/sigma/kiama/util/Comparison.scala b/core/shared/src/main/scala/sigma/kiama/util/Comparison.scala similarity index 100% rename from common/shared/src/main/scala/sigma/kiama/util/Comparison.scala rename to core/shared/src/main/scala/sigma/kiama/util/Comparison.scala diff --git a/common/shared/src/main/scala/sigma/package.scala b/core/shared/src/main/scala/sigma/package.scala similarity index 100% rename from common/shared/src/main/scala/sigma/package.scala rename to core/shared/src/main/scala/sigma/package.scala diff --git a/common/shared/src/main/scala/sigma/reflection/CommonReflection.scala b/core/shared/src/main/scala/sigma/reflection/CommonReflection.scala similarity index 100% rename from common/shared/src/main/scala/sigma/reflection/CommonReflection.scala rename to core/shared/src/main/scala/sigma/reflection/CommonReflection.scala diff --git a/common/shared/src/main/scala/sigma/reflection/RClass.scala b/core/shared/src/main/scala/sigma/reflection/RClass.scala similarity index 100% rename from common/shared/src/main/scala/sigma/reflection/RClass.scala rename to core/shared/src/main/scala/sigma/reflection/RClass.scala diff --git a/common/shared/src/main/scala/sigma/reflection/StaticImpl.scala b/core/shared/src/main/scala/sigma/reflection/StaticImpl.scala similarity index 100% rename from common/shared/src/main/scala/sigma/reflection/StaticImpl.scala rename to core/shared/src/main/scala/sigma/reflection/StaticImpl.scala diff --git a/common/shared/src/main/scala/sigma/reflection/package.scala b/core/shared/src/main/scala/sigma/reflection/package.scala similarity index 100% rename from common/shared/src/main/scala/sigma/reflection/package.scala rename to core/shared/src/main/scala/sigma/reflection/package.scala diff --git a/common/shared/src/main/scala/sigma/util/CollectionUtil.scala b/core/shared/src/main/scala/sigma/util/CollectionUtil.scala similarity index 100% rename from common/shared/src/main/scala/sigma/util/CollectionUtil.scala rename to core/shared/src/main/scala/sigma/util/CollectionUtil.scala diff --git a/common/shared/src/main/scala/sigma/util/Extensions.scala b/core/shared/src/main/scala/sigma/util/Extensions.scala similarity index 100% rename from common/shared/src/main/scala/sigma/util/Extensions.scala rename to core/shared/src/main/scala/sigma/util/Extensions.scala diff --git a/common/shared/src/main/scala/sigma/util/GraphUtil.scala b/core/shared/src/main/scala/sigma/util/GraphUtil.scala similarity index 100% rename from common/shared/src/main/scala/sigma/util/GraphUtil.scala rename to core/shared/src/main/scala/sigma/util/GraphUtil.scala diff --git a/common/shared/src/main/scala/sigma/util/MemoizedFunc.scala b/core/shared/src/main/scala/sigma/util/MemoizedFunc.scala similarity index 100% rename from common/shared/src/main/scala/sigma/util/MemoizedFunc.scala rename to core/shared/src/main/scala/sigma/util/MemoizedFunc.scala diff --git a/common/shared/src/main/scala/sigma/util/StringUtil.scala b/core/shared/src/main/scala/sigma/util/StringUtil.scala similarity index 100% rename from common/shared/src/main/scala/sigma/util/StringUtil.scala rename to core/shared/src/main/scala/sigma/util/StringUtil.scala diff --git a/common/shared/src/main/scala/sigma/util/package.scala b/core/shared/src/main/scala/sigma/util/package.scala similarity index 100% rename from common/shared/src/main/scala/sigma/util/package.scala rename to core/shared/src/main/scala/sigma/util/package.scala diff --git a/common/shared/src/test/resources/root/A.txt b/core/shared/src/test/resources/root/A.txt similarity index 100% rename from common/shared/src/test/resources/root/A.txt rename to core/shared/src/test/resources/root/A.txt diff --git a/common/shared/src/test/resources/root/B.txt b/core/shared/src/test/resources/root/B.txt similarity index 100% rename from common/shared/src/test/resources/root/B.txt rename to core/shared/src/test/resources/root/B.txt diff --git a/common/shared/src/test/resources/root/subdir/C.txt b/core/shared/src/test/resources/root/subdir/C.txt similarity index 100% rename from common/shared/src/test/resources/root/subdir/C.txt rename to core/shared/src/test/resources/root/subdir/C.txt diff --git a/common/shared/src/test/resources/root/subdir/subsubdir/D.txt b/core/shared/src/test/resources/root/subdir/subsubdir/D.txt similarity index 100% rename from common/shared/src/test/resources/root/subdir/subsubdir/D.txt rename to core/shared/src/test/resources/root/subdir/subsubdir/D.txt diff --git a/common/shared/src/test/scala/sigma/BaseTests.scala b/core/shared/src/test/scala/sigma/BaseTests.scala similarity index 100% rename from common/shared/src/test/scala/sigma/BaseTests.scala rename to core/shared/src/test/scala/sigma/BaseTests.scala diff --git a/common/shared/src/test/scala/sigma/CollGens.scala b/core/shared/src/test/scala/sigma/CollGens.scala similarity index 100% rename from common/shared/src/test/scala/sigma/CollGens.scala rename to core/shared/src/test/scala/sigma/CollGens.scala diff --git a/common/shared/src/test/scala/sigma/CollsTests.scala b/core/shared/src/test/scala/sigma/CollsTests.scala similarity index 100% rename from common/shared/src/test/scala/sigma/CollsTests.scala rename to core/shared/src/test/scala/sigma/CollsTests.scala diff --git a/common/shared/src/test/scala/sigma/TestUtils.scala b/core/shared/src/test/scala/sigma/TestUtils.scala similarity index 100% rename from common/shared/src/test/scala/sigma/TestUtils.scala rename to core/shared/src/test/scala/sigma/TestUtils.scala diff --git a/common/shared/src/test/scala/sigma/TypesTests.scala b/core/shared/src/test/scala/sigma/TypesTests.scala similarity index 100% rename from common/shared/src/test/scala/sigma/TypesTests.scala rename to core/shared/src/test/scala/sigma/TypesTests.scala diff --git a/common/shared/src/test/scala/sigma/VersionTesting.scala b/core/shared/src/test/scala/sigma/VersionTesting.scala similarity index 100% rename from common/shared/src/test/scala/sigma/VersionTesting.scala rename to core/shared/src/test/scala/sigma/VersionTesting.scala diff --git a/common/shared/src/test/scala/sigma/VersionTestingProperty.scala b/core/shared/src/test/scala/sigma/VersionTestingProperty.scala similarity index 100% rename from common/shared/src/test/scala/sigma/VersionTestingProperty.scala rename to core/shared/src/test/scala/sigma/VersionTestingProperty.scala diff --git a/common/shared/src/test/scala/sigma/util/BenchmarkUtil.scala b/core/shared/src/test/scala/sigma/util/BenchmarkUtil.scala similarity index 100% rename from common/shared/src/test/scala/sigma/util/BenchmarkUtil.scala rename to core/shared/src/test/scala/sigma/util/BenchmarkUtil.scala diff --git a/common/shared/src/test/scala/sigma/util/CollectionUtilTests.scala b/core/shared/src/test/scala/sigma/util/CollectionUtilTests.scala similarity index 100% rename from common/shared/src/test/scala/sigma/util/CollectionUtilTests.scala rename to core/shared/src/test/scala/sigma/util/CollectionUtilTests.scala diff --git a/common/shared/src/test/scala/sigma/util/GraphUtilTests.scala b/core/shared/src/test/scala/sigma/util/GraphUtilTests.scala similarity index 100% rename from common/shared/src/test/scala/sigma/util/GraphUtilTests.scala rename to core/shared/src/test/scala/sigma/util/GraphUtilTests.scala diff --git a/common/shared/src/test/scala/sigma/util/PrintExtensions.scala b/core/shared/src/test/scala/sigma/util/PrintExtensions.scala similarity index 100% rename from common/shared/src/test/scala/sigma/util/PrintExtensions.scala rename to core/shared/src/test/scala/sigma/util/PrintExtensions.scala diff --git a/common/shared/src/test/scala/sigma/util/StringUtilTests.scala b/core/shared/src/test/scala/sigma/util/StringUtilTests.scala similarity index 100% rename from common/shared/src/test/scala/sigma/util/StringUtilTests.scala rename to core/shared/src/test/scala/sigma/util/StringUtilTests.scala diff --git a/common/shared/src/test/scala/sigma/util/StronglyConnectedComponentsTests.scala b/core/shared/src/test/scala/sigma/util/StronglyConnectedComponentsTests.scala similarity index 100% rename from common/shared/src/test/scala/sigma/util/StronglyConnectedComponentsTests.scala rename to core/shared/src/test/scala/sigma/util/StronglyConnectedComponentsTests.scala From 7d5762885d1910a720c541911008a35e04c36f73 Mon Sep 17 00:00:00 2001 From: Alexander Slesarenko Date: Fri, 25 Aug 2023 20:45:01 +0200 Subject: [PATCH 25/37] minimize-modules: fix file tests + renamed ReflectionData --- core/js/src/main/scala/sigma/reflection/Platform.scala | 2 +- core/jvm/src/test/scala/sigma/util/FileUtilTests.scala | 2 +- .../{CommonReflection.scala => ReflectionData.scala} | 2 +- .../src/main/scala/sigmastate/InterpreterReflection.scala | 6 +++--- .../sigmastate/InterpreterReflectionGeneratorTests.scala | 2 +- sc/jvm/src/test/scala/sigmastate/ReflectionGenerator.scala | 4 ++-- sc/shared/src/main/scala/scalan/GraphIRReflection.scala | 6 +++--- .../src/test/scala/scalan/core/ScalaNameUtilSuite.scala | 2 +- 8 files changed, 13 insertions(+), 13 deletions(-) rename core/shared/src/main/scala/sigma/reflection/{CommonReflection.scala => ReflectionData.scala} (99%) diff --git a/core/js/src/main/scala/sigma/reflection/Platform.scala b/core/js/src/main/scala/sigma/reflection/Platform.scala index af98382329..199729fc7a 100644 --- a/core/js/src/main/scala/sigma/reflection/Platform.scala +++ b/core/js/src/main/scala/sigma/reflection/Platform.scala @@ -14,7 +14,7 @@ object Platform { * found. */ def resolveClass[T](clazz: Class[T]): RClass[T] = { - val res = CommonReflection.classes.get(clazz) match { + val res = ReflectionData.classes.get(clazz) match { case Some(c) => assert(c.clazz == clazz) c diff --git a/core/jvm/src/test/scala/sigma/util/FileUtilTests.scala b/core/jvm/src/test/scala/sigma/util/FileUtilTests.scala index 9b6eddb0a7..7a09ad1685 100644 --- a/core/jvm/src/test/scala/sigma/util/FileUtilTests.scala +++ b/core/jvm/src/test/scala/sigma/util/FileUtilTests.scala @@ -21,7 +21,7 @@ class FileUtilTests extends BaseNestedTests { } describe("File traversals") { - val root = file("common/shared/src/test/resources/root") + val root = file("core/shared/src/test/resources/root") val subdir = file(root, "subdir") val subsubdir = file(subdir, "subsubdir") val empty = { val dir = file(root, "empty"); dir.mkdir(); dir } diff --git a/core/shared/src/main/scala/sigma/reflection/CommonReflection.scala b/core/shared/src/main/scala/sigma/reflection/ReflectionData.scala similarity index 99% rename from core/shared/src/main/scala/sigma/reflection/CommonReflection.scala rename to core/shared/src/main/scala/sigma/reflection/ReflectionData.scala index 782ae819e7..cdab5d5be7 100644 --- a/core/shared/src/main/scala/sigma/reflection/CommonReflection.scala +++ b/core/shared/src/main/scala/sigma/reflection/ReflectionData.scala @@ -12,7 +12,7 @@ import scala.collection.immutable * we register a class entry with the necessary information. * Only information that is needed at runtime is registered. */ -object CommonReflection { +object ReflectionData { /** Descriptors of classes. */ val classes = mutable.HashMap.empty[Class[_], SRClass[_]] diff --git a/interpreter/shared/src/main/scala/sigmastate/InterpreterReflection.scala b/interpreter/shared/src/main/scala/sigmastate/InterpreterReflection.scala index 3e92ac1b31..c6cec6c3da 100644 --- a/interpreter/shared/src/main/scala/sigmastate/InterpreterReflection.scala +++ b/interpreter/shared/src/main/scala/sigmastate/InterpreterReflection.scala @@ -1,8 +1,8 @@ package sigmastate import org.ergoplatform.ErgoBox.RegisterId -import sigma.reflection.CommonReflection.registerClassEntry -import sigma.reflection.{CommonReflection, mkConstructor, mkMethod} +import sigma.reflection.ReflectionData.registerClassEntry +import sigma.reflection.{ReflectionData, mkConstructor, mkMethod} import sigma.Coll import sigma.{AvlTree, SigmaDslBuilder} import sigmastate.SAvlTree.KeyValueColl @@ -21,7 +21,7 @@ import sigmastate.utxo._ * Only information that is needed at runtime is registered. */ object InterpreterReflection { - val reflection = CommonReflection + val reflection = ReflectionData registerClassEntry(classOf[AND], constructors = Array( diff --git a/sc/jvm/src/test/scala/sigmastate/InterpreterReflectionGeneratorTests.scala b/sc/jvm/src/test/scala/sigmastate/InterpreterReflectionGeneratorTests.scala index 965e33c460..aaa1d6c424 100644 --- a/sc/jvm/src/test/scala/sigmastate/InterpreterReflectionGeneratorTests.scala +++ b/sc/jvm/src/test/scala/sigmastate/InterpreterReflectionGeneratorTests.scala @@ -3,7 +3,7 @@ package sigmastate import org.scalatest.matchers.should.Matchers import org.scalatest.propspec.AnyPropSpec import scalan.TypeDescs -import sigma.reflection.CommonReflection.registerClassEntry +import sigma.reflection.ReflectionData.registerClassEntry import sigma.reflection.SRConstructor object ObjA { diff --git a/sc/jvm/src/test/scala/sigmastate/ReflectionGenerator.scala b/sc/jvm/src/test/scala/sigmastate/ReflectionGenerator.scala index 76a39a026f..28b2733c31 100644 --- a/sc/jvm/src/test/scala/sigmastate/ReflectionGenerator.scala +++ b/sc/jvm/src/test/scala/sigmastate/ReflectionGenerator.scala @@ -178,12 +178,12 @@ object ReflectionGenerator { private def collectEmptyClasses = { sigma.reflection.Platform.unknownClasses.toSeq.filter(e => isEmpty(e._2) && // don't contain constructors, fields or methods - !CommonReflection.classes.contains(e._1)) // not already registered + !ReflectionData.classes.contains(e._1)) // not already registered } private def collectNonEmptyClasses = { sigma.reflection.Platform.unknownClasses.toSeq.filter(e => !isEmpty(e._2) && - !CommonReflection.classes.contains(e._1)) + !ReflectionData.classes.contains(e._1)) } } diff --git a/sc/shared/src/main/scala/scalan/GraphIRReflection.scala b/sc/shared/src/main/scala/scalan/GraphIRReflection.scala index 52686c14f5..f7218afc92 100644 --- a/sc/shared/src/main/scala/scalan/GraphIRReflection.scala +++ b/sc/shared/src/main/scala/scalan/GraphIRReflection.scala @@ -1,8 +1,8 @@ package scalan import scalan.primitives.Thunks -import sigma.reflection.CommonReflection.registerClassEntry -import sigma.reflection.{CommonReflection, mkConstructor, mkMethod} +import sigma.reflection.ReflectionData.registerClassEntry +import sigma.reflection.{ReflectionData, mkConstructor, mkMethod} import sigmastate.eval.SigmaLibrary import sigma.Colls import sigma.SigmaDsl @@ -17,7 +17,7 @@ import wrappers.scalan.WRTypes */ object GraphIRReflection { /** Forces initialization of reflection data. */ - val reflection = CommonReflection + val reflection = ReflectionData { val clazz = classOf[wrappers.scala.WOptions#WOption[_]] val ctx = null.asInstanceOf[scalan.Library] // ok! type level only diff --git a/sc/shared/src/test/scala/scalan/core/ScalaNameUtilSuite.scala b/sc/shared/src/test/scala/scalan/core/ScalaNameUtilSuite.scala index 443735d0e6..15fad91b54 100644 --- a/sc/shared/src/test/scala/scalan/core/ScalaNameUtilSuite.scala +++ b/sc/shared/src/test/scala/scalan/core/ScalaNameUtilSuite.scala @@ -1,7 +1,7 @@ package scalan.core import sigma.BaseTests -import sigma.reflection.CommonReflection.registerClassEntry +import sigma.reflection.ReflectionData.registerClassEntry import sigma.reflection.{RClass, mkMethod} class ScalaNameUtilSuite extends BaseTests { From 3eba2d1e0ed26fb5284e17b76d7f4bee7d70552c Mon Sep 17 00:00:00 2001 From: Alexander Slesarenko Date: Sat, 26 Aug 2023 10:29:11 +0200 Subject: [PATCH 26/37] minimize-modules: AvlTreeVerifier moved out of core --- build.sbt | 4 +- .../src/main/scala/sigma/SigmaDsl.scala | 51 +++---------------- .../src/test/scala/sigma/CollGens.scala | 2 +- .../sigmastate/eval/CostingDataContext.scala | 39 +++++++------- .../src/main/scala/sigmastate/types.scala | 2 +- .../DeserializationResilience.scala | 2 +- 6 files changed, 32 insertions(+), 68 deletions(-) diff --git a/build.sbt b/build.sbt index 88d5a597fe..a76c73d885 100644 --- a/build.sbt +++ b/build.sbt @@ -193,7 +193,7 @@ lazy val core = crossProject(JVMPlatform, JSPlatform) .settings(commonSettings ++ testSettings2, commonDependenies2, testingDependencies2, - scryptoDependency, + scorexUtilDependency, publish / skip := true ) .jvmSettings( crossScalaSettings ) @@ -220,7 +220,7 @@ lazy val interpreter = crossProject(JVMPlatform, JSPlatform) commonSettings ++ testSettings2, commonDependenies2, testingDependencies2, - scorexUtilDependency, fastparseDependency, circeDependency, + scorexUtilDependency, fastparseDependency, circeDependency, scryptoDependency, publish / skip := true ) .jvmSettings( crossScalaSettings ) diff --git a/core/shared/src/main/scala/sigma/SigmaDsl.scala b/core/shared/src/main/scala/sigma/SigmaDsl.scala index 5516ddea6a..66da280fa4 100644 --- a/core/shared/src/main/scala/sigma/SigmaDsl.scala +++ b/core/shared/src/main/scala/sigma/SigmaDsl.scala @@ -3,10 +3,6 @@ package sigma import java.math.BigInteger import sigma.data._ -import scorex.crypto.authds.{ADDigest, ADValue} -import scorex.crypto.authds.avltree.batch.Operation - -import scala.util.Try /** * All `modQ` operations assume that Q is a global constant (an order of the only one cryptographically strong group @@ -484,48 +480,15 @@ trait AvlTree { */ def remove(operations: Coll[Coll[Byte]], proof: Coll[Byte]): Option[AvlTree] - /** Creates a new instance of [[AvlTreeVerifier]] with the given `proof` and using - * properties of this AvlTree (digest, keyLength, valueLengthOpt) for constructor - * arguments. - * - * @param proof bytes of the serialized proof which is used to represent the tree. - */ - def createVerifier(proof: Coll[Byte]): AvlTreeVerifier +// /** Creates a new instance of [[AvlTreeVerifier]] with the given `proof` and using +// * properties of this AvlTree (digest, keyLength, valueLengthOpt) for constructor +// * arguments. +// * +// * @param proof bytes of the serialized proof which is used to represent the tree. +// */ +// def createVerifier(proof: Coll[Byte]): AvlTreeVerifier } -/** Represents operations of AVL tree verifier in an abstract (implementation independent) - * way which allows declaration of the [[AvlTree.createVerifier()]] method. - */ -trait AvlTreeVerifier { - /** - * If operation.key exists in the tree and the operation succeeds, - * returns Success(Some(v)), where v is the value associated with operation.key - * before the operation. - * If operation.key does not exists in the tree and the operation succeeds, returns Success(None). - * Returns Failure if the operation fails or the proof does not verify. - * After one failure, all subsequent operations will fail and digest - * is None. - * - * @param operation an operation descriptor - * @return - Success(Some(old value)), Success(None), or Failure - */ - def performOneOperation(operation: Operation): Try[Option[ADValue]] - - /** Returns the max height of the tree extracted from the root digest. */ - def treeHeight: Int - - /** - * Returns Some[the current digest of the authenticated data structure], - * where the digest contains the root hash and the root height - * Returns None if the proof verification failed at construction - * or during any of the operations. - * - * @return - Some[digest] or None - */ - def digest: Option[ADDigest] -} - - /** Only header fields that can be predicted by a miner. */ trait PreHeader { /** Block version, to be increased on every soft and hardfork. */ diff --git a/core/shared/src/test/scala/sigma/CollGens.scala b/core/shared/src/test/scala/sigma/CollGens.scala index d18fcad29f..2c8b044546 100644 --- a/core/shared/src/test/scala/sigma/CollGens.scala +++ b/core/shared/src/test/scala/sigma/CollGens.scala @@ -2,7 +2,7 @@ package sigma import org.scalacheck.util.Buildable import org.scalacheck.{Arbitrary, Gen} -import sigma.data.{CollOverArrayBuilder, RType} +import sigma.data.RType import spire.scalacompat.BuilderCompat import scala.collection.mutable diff --git a/interpreter/shared/src/main/scala/sigmastate/eval/CostingDataContext.scala b/interpreter/shared/src/main/scala/sigmastate/eval/CostingDataContext.scala index 839215226f..74458e6931 100644 --- a/interpreter/shared/src/main/scala/sigmastate/eval/CostingDataContext.scala +++ b/interpreter/shared/src/main/scala/sigmastate/eval/CostingDataContext.scala @@ -149,23 +149,31 @@ case class CSigmaProp(sigmaTree: SigmaBoolean) extends SigmaProp with WrapperOf[ override def toString: String = s"SigmaProp(${wrappedValue.showToString})" } -/** Implementation of the [[sigma.AvlTreeVerifier]] trait based on +/** Implements operations of AVL tree verifier based on * [[scorex.crypto.authds.avltree.batch.BatchAVLVerifier]]. * - * @see BatchAVLVerifier, AvlTreeVerifier + * @see BatchAVLVerifier */ -class CAvlTreeVerifier(startingDigest: ADDigest, +class AvlTreeVerifier(startingDigest: ADDigest, proof: SerializedAdProof, override val keyLength: Int, override val valueLengthOpt: Option[Int]) extends BatchAVLVerifier[Digest32, Blake2b256.type]( - startingDigest, proof, keyLength, valueLengthOpt) - with AvlTreeVerifier { - override def treeHeight: Int = rootNodeHeight + startingDigest, proof, keyLength, valueLengthOpt) { + def treeHeight: Int = rootNodeHeight /** Override default logging which outputs stack trace to the console. */ override protected def logError(t: Throwable): Unit = {} } +object AvlTreeVerifier { + def apply(tree: AvlTree, proof: Coll[Byte]): AvlTreeVerifier = { + val treeData = tree.asInstanceOf[CAvlTree].treeData + val adProof = SerializedAdProof @@ proof.toArray + val bv = new AvlTreeVerifier( + ADDigest @@ treeData.digest.toArray, adProof, treeData.keyLength, treeData.valueLengthOpt) + bv + } +} /** A default implementation of [[AvlTree]] interface. * @see [[AvlTree]] for detailed descriptions @@ -197,16 +205,9 @@ case class CAvlTree(treeData: AvlTreeData) extends AvlTree with WrapperOf[AvlTre this.copy(treeData = td) } - override def createVerifier(proof: Coll[Byte]): AvlTreeVerifier = { - val adProof = SerializedAdProof @@ proof.toArray - val bv = new CAvlTreeVerifier( - ADDigest @@ treeData.digest.toArray, adProof, treeData.keyLength, treeData.valueLengthOpt) - bv - } - override def contains(key: Coll[Byte], proof: Coll[Byte]): Boolean = { val keyBytes = key.toArray - val bv = createVerifier(proof) + val bv = AvlTreeVerifier(this, proof) bv.performOneOperation(Lookup(ADKey @@ keyBytes)) match { case Success(r) => r match { case Some(_) => true @@ -218,7 +219,7 @@ case class CAvlTree(treeData: AvlTreeData) extends AvlTree with WrapperOf[AvlTre override def get(key: Coll[Byte], proof: Coll[Byte]): Option[Coll[Byte]] = { val keyBytes = key.toArray - val bv = createVerifier(proof) + val bv = AvlTreeVerifier(this, proof) bv.performOneOperation(Lookup(ADKey @@ keyBytes)) match { case Success(r) => r match { case Some(v) => Some(Colls.fromArray(v)) @@ -229,7 +230,7 @@ case class CAvlTree(treeData: AvlTreeData) extends AvlTree with WrapperOf[AvlTre } override def getMany(keys: Coll[Coll[Byte]], proof: Coll[Byte]): Coll[Option[Coll[Byte]]] = { - val bv = createVerifier(proof) + val bv = AvlTreeVerifier(this, proof) keys.map { key => bv.performOneOperation(Lookup(ADKey @@ key.toArray)) match { case Success(r) => r match { @@ -245,7 +246,7 @@ case class CAvlTree(treeData: AvlTreeData) extends AvlTree with WrapperOf[AvlTre if (!isInsertAllowed) { None } else { - val bv = createVerifier(proof) + val bv = AvlTreeVerifier(this, proof) entries.forall { case (key, value) => val insertRes = bv.performOneOperation(Insert(ADKey @@ key.toArray, ADValue @@ value.toArray)) if (insertRes.isFailure) { @@ -264,7 +265,7 @@ case class CAvlTree(treeData: AvlTreeData) extends AvlTree with WrapperOf[AvlTre if (!isUpdateAllowed) { None } else { - val bv = createVerifier(proof) + val bv = AvlTreeVerifier(this, proof) operations.forall { case (key, value) => bv.performOneOperation(Update(ADKey @@ key.toArray, ADValue @@ value.toArray)).isSuccess } @@ -279,7 +280,7 @@ case class CAvlTree(treeData: AvlTreeData) extends AvlTree with WrapperOf[AvlTre if (!isRemoveAllowed) { None } else { - val bv = createVerifier(proof) + val bv = AvlTreeVerifier(this, proof) cfor(0)(_ < operations.length, _ + 1) { i => val key = operations(i).toArray bv.performOneOperation(Remove(ADKey @@ key)) diff --git a/interpreter/shared/src/main/scala/sigmastate/types.scala b/interpreter/shared/src/main/scala/sigmastate/types.scala index 99c730167a..e3a7fc529a 100644 --- a/interpreter/shared/src/main/scala/sigmastate/types.scala +++ b/interpreter/shared/src/main/scala/sigmastate/types.scala @@ -2183,7 +2183,7 @@ case object SAvlTree extends SProduct with SPredefType with SMonoType { def createVerifier(tree: AvlTree, proof: Coll[Byte])(implicit E: ErgoTreeEvaluator) = { // the cost of tree reconstruction from proof is O(proof.length) E.addSeqCost(CreateAvlVerifier_Info, proof.length) { () => - tree.createVerifier(proof) + AvlTreeVerifier(tree, proof) } } diff --git a/sc/shared/src/test/scala/sigmastate/serialization/DeserializationResilience.scala b/sc/shared/src/test/scala/sigmastate/serialization/DeserializationResilience.scala index 7300731fc3..52ef46c642 100644 --- a/sc/shared/src/test/scala/sigmastate/serialization/DeserializationResilience.scala +++ b/sc/shared/src/test/scala/sigmastate/serialization/DeserializationResilience.scala @@ -413,7 +413,7 @@ class DeserializationResilience extends DeserializationResilienceTesting { val v = k avlProver.performOneOperation(Insert(ADKey @@@ k, ADValue @@@ v)) val proof = avlProver.generateProof() - val verifier = tree.createVerifier(Colls.fromArray(proof)) + val verifier = AvlTreeVerifier(tree, Colls.fromArray(proof)) verifier.performOneOperation(Insert(ADKey @@@ k, ADValue @@@ v)).isFailure shouldBe true // NOTE, even though performOneOperation fails, some AvlTree$ methods used in Interpreter // (remove_eval, update_eval, contains_eval) won't throw, while others will. From 71e67c4dbbabfad1f732f1244d251c815fe80474 Mon Sep 17 00:00:00 2001 From: Alexander Slesarenko Date: Sat, 26 Aug 2023 12:03:41 +0200 Subject: [PATCH 27/37] minimize-modules: RType implicits moved from SType --- .github/workflows/ci.yml | 2 +- .../org/ergoplatform/ErgoLikeTransaction.scala | 2 +- .../src/main/scala/sigmastate/sigmastate.scala | 17 +++++++++++++++++ .../src/main/scala/sigmastate/types.scala | 8 -------- .../ergoplatform/ErgoLikeTransactionSpec.scala | 1 + 5 files changed, 20 insertions(+), 10 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index b828c8a34f..fa239b73f5 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -103,7 +103,7 @@ jobs: key: ${{ runner.os }}-sbt-cache-v2-${{ hashFiles('**/*.sbt') }}-${{ hashFiles('project/build.properties') }} - name: Runs tests and collect coverage - run: sbt -jvm-opts ci/ci.jvmopts ++${{ matrix.scala }} commonJS/test interpreterJS/test parsersJS/test sdkJS/test scJS/test + run: sbt -jvm-opts ci/ci.jvmopts ++${{ matrix.scala }} coreJS/test interpreterJS/test parsersJS/test sdkJS/test scJS/test - name: Publish a JVM snapshot ${{ github.ref }} if: env.HAS_SECRETS == 'true' diff --git a/interpreter/shared/src/main/scala/org/ergoplatform/ErgoLikeTransaction.scala b/interpreter/shared/src/main/scala/org/ergoplatform/ErgoLikeTransaction.scala index 77ffc71f47..fcfdbc922b 100644 --- a/interpreter/shared/src/main/scala/org/ergoplatform/ErgoLikeTransaction.scala +++ b/interpreter/shared/src/main/scala/org/ergoplatform/ErgoLikeTransaction.scala @@ -7,7 +7,7 @@ import scorex.crypto.hash.Blake2b256 import scorex.util._ import sigma.Colls import sigma.util.safeNewArray -import sigmastate.SType._ +import sigmastate._ import sigmastate.eval.Extensions._ import sigmastate.eval._ import sigmastate.interpreter.ProverResult diff --git a/interpreter/shared/src/main/scala/sigmastate/sigmastate.scala b/interpreter/shared/src/main/scala/sigmastate/sigmastate.scala index 96d11e8a2e..4ebc1cb2ce 100644 --- a/interpreter/shared/src/main/scala/sigmastate/sigmastate.scala +++ b/interpreter/shared/src/main/scala/sigmastate/sigmastate.scala @@ -1,9 +1,26 @@ +import org.ergoplatform.{ErgoBox, ErgoBoxCandidate, ErgoLikeContext} +import sigma.data.{GeneralType, RType} import sigmastate.Values._ import sigmastate.lang.CheckingSigmaBuilder +import scala.reflect.classTag + package object sigmastate { import CheckingSigmaBuilder._ + /** RType descriptors for predefined types used in AOTC-based interpreter. */ + def rtypeToClassTag = ??? + + implicit val SigmaBooleanRType : RType[SigmaBoolean] = RType.fromClassTag(classTag[SigmaBoolean]) + + implicit val ErgoBoxRType : RType[ErgoBox] = RType.fromClassTag(classTag[ErgoBox]) + + implicit val ErgoBoxCandidateRType: RType[ErgoBoxCandidate] = RType.fromClassTag(classTag[ErgoBoxCandidate]) + + implicit val AvlTreeDataRType : RType[AvlTreeData] = GeneralType(classTag[AvlTreeData]) + + implicit val ErgoLikeContextRType : RType[ErgoLikeContext] = RType.fromClassTag(classTag[ErgoLikeContext]) + /** Helper method to create "+" operation node. */ def Plus[T <: SNumericType](left: Value[T], right: Value[T]): Value[T] = mkPlus(left, right) diff --git a/interpreter/shared/src/main/scala/sigmastate/types.scala b/interpreter/shared/src/main/scala/sigmastate/types.scala index e3a7fc529a..586a06432e 100644 --- a/interpreter/shared/src/main/scala/sigmastate/types.scala +++ b/interpreter/shared/src/main/scala/sigmastate/types.scala @@ -114,14 +114,6 @@ object SType { /** Costructs a collection type with the given type of elements. */ implicit def typeCollection[V <: SType](implicit tV: V): SCollection[V] = SCollection[V](tV) - /** RType descriptors for predefined types used in AOTC-based interpreter. */ - def rtypeToClassTag = ??? - implicit val SigmaBooleanRType: RType[SigmaBoolean] = RType.fromClassTag(classTag[SigmaBoolean]) - implicit val ErgoBoxRType: RType[ErgoBox] = RType.fromClassTag(classTag[ErgoBox]) - implicit val ErgoBoxCandidateRType: RType[ErgoBoxCandidate] = RType.fromClassTag(classTag[ErgoBoxCandidate]) - implicit val AvlTreeDataRType: RType[AvlTreeData] = GeneralType(classTag[AvlTreeData]) - implicit val ErgoLikeContextRType: RType[ErgoLikeContext] = RType.fromClassTag(classTag[ErgoLikeContext]) - /** Named type variables and parameters used in generic types and method signatures. * Generic type terms like `(Coll[IV],(IV) => Boolean) => Boolean` are used to represent * method types of `Coll`` and `Option`` types. Each such type is an instance of [[SFunc]]. diff --git a/sc/shared/src/test/scala/org/ergoplatform/ErgoLikeTransactionSpec.scala b/sc/shared/src/test/scala/org/ergoplatform/ErgoLikeTransactionSpec.scala index c07dc58d3a..b8579ddedf 100644 --- a/sc/shared/src/test/scala/org/ergoplatform/ErgoLikeTransactionSpec.scala +++ b/sc/shared/src/test/scala/org/ergoplatform/ErgoLikeTransactionSpec.scala @@ -11,6 +11,7 @@ import sigmastate.interpreter.{ContextExtension, ProverResult} import sigmastate.serialization.SigmaSerializer import sigmastate.eval._ import sigmastate.eval.Extensions._ +import sigmastate._ import sigmastate.SType._ import sigmastate.helpers.TestingHelpers.copyTransaction import sigmastate.utils.Helpers From 008d909dd14c84fbc70a613f4b7b46848d6abfce Mon Sep 17 00:00:00 2001 From: Alexander Slesarenko Date: Wed, 30 Aug 2023 16:35:41 +0200 Subject: [PATCH 28/37] minimize-modules: fixes after merge --- sdk/js/src/main/scala/org/ergoplatform/sdk/js/Isos.scala | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Isos.scala b/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Isos.scala index b781ea1bb8..5794b1d636 100644 --- a/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Isos.scala +++ b/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Isos.scala @@ -11,7 +11,7 @@ import scorex.util.ModifierId import scorex.util.encode.Base16 import sigmastate.Values.{Constant, GroupElementConstant} import sigmastate.eval.Extensions.ArrayOps -import sigmastate.eval.{CBigInt, Digest32Coll, Evaluation, CAvlTree, Colls, CGroupElement, CPreHeader, CHeader} +import sigmastate.eval.{CBigInt, Digest32Coll, Evaluation, CAvlTree, CGroupElement, CPreHeader, CHeader} import sigmastate.fleetSdkCommon.distEsmTypesBoxesMod.Box import sigmastate.fleetSdkCommon.distEsmTypesCommonMod.HexString import sigmastate.fleetSdkCommon.distEsmTypesRegistersMod.NonMandatoryRegisters @@ -21,7 +21,7 @@ import sigmastate.fleetSdkCommon.{distEsmTypesProverResultMod => proverResultMod import sigmastate.interpreter.{ContextExtension, ProverResult} import sigmastate.serialization.{ErgoTreeSerializer, ValueSerializer} import sigmastate.{AvlTreeData, AvlTreeFlags, SType} -import sigma.{Coll, Colls, GroupElement} +import sigma.{Coll, Colls} import sigma.Extensions.CollBytesOps import java.math.BigInteger @@ -66,7 +66,7 @@ object Isos { } } - val isoGroupElement: Iso[GroupElement, special.sigma.GroupElement] = new Iso[GroupElement, special.sigma.GroupElement] { + val isoGroupElement: Iso[GroupElement, sigma.GroupElement] = new Iso[GroupElement, sigma.GroupElement] { override def to(x: GroupElement): sigma.GroupElement = { CGroupElement(x.point) } From a13a03c41e0599f434ca6848c2fad4419784d4b7 Mon Sep 17 00:00:00 2001 From: Alexander Slesarenko Date: Mon, 11 Sep 2023 12:03:37 +0200 Subject: [PATCH 29/37] minimize-modules: addressed review comments --- .../sigma/kiama/rewriting/Rewriter.scala | 1 - .../shared/src/main/scala/sigma/package.scala | 2 ++ .../sigmastate/eval/CostingDataContext.scala | 29 ++++++++++--------- .../scala/sigmastate/eval/Evaluation.scala | 9 ++++-- .../main/scala/sigmastate/sigmastate.scala | 9 ++++-- .../special/collection/impl/CollsImpl.scala | 4 --- .../special/sigma/impl/SigmaDslImpl.scala | 4 --- .../sdk/multisig/SigningSpec.scala | 0 8 files changed, 32 insertions(+), 26 deletions(-) delete mode 100644 sdk/shared/src/test/scala/org/ergoplatform/sdk/multisig/SigningSpec.scala diff --git a/core/shared/src/main/scala/sigma/kiama/rewriting/Rewriter.scala b/core/shared/src/main/scala/sigma/kiama/rewriting/Rewriter.scala index 92deb2d140..d5e9fd2f7e 100644 --- a/core/shared/src/main/scala/sigma/kiama/rewriting/Rewriter.scala +++ b/core/shared/src/main/scala/sigma/kiama/rewriting/Rewriter.scala @@ -12,7 +12,6 @@ package sigma.kiama package rewriting import sigma.reflection.{Platform, RClass, RConstructor} -//import sigma.kiama.==> /** * Strategy-based term rewriting in the style of Stratego (http://strategoxt.org/). diff --git a/core/shared/src/main/scala/sigma/package.scala b/core/shared/src/main/scala/sigma/package.scala index d4fc53d978..f7f2321096 100644 --- a/core/shared/src/main/scala/sigma/package.scala +++ b/core/shared/src/main/scala/sigma/package.scala @@ -45,6 +45,8 @@ package object sigma { /** Allows implicit resolution to find appropriate instance of ClassTag in * the scope where RType is implicitly available. + * NOTE, this implicit is shadowed internally in some places (search for `def rtypeToClassTag`), + * hence renaming it requires changing of the shadowing methods. */ implicit def rtypeToClassTag[A](implicit t: RType[A]): ClassTag[A] = t.classTag diff --git a/interpreter/shared/src/main/scala/sigmastate/eval/CostingDataContext.scala b/interpreter/shared/src/main/scala/sigmastate/eval/CostingDataContext.scala index 74458e6931..870cbbb5bf 100644 --- a/interpreter/shared/src/main/scala/sigmastate/eval/CostingDataContext.scala +++ b/interpreter/shared/src/main/scala/sigmastate/eval/CostingDataContext.scala @@ -1,35 +1,33 @@ package sigmastate.eval import debox.cfor -import org.ergoplatform.validation.{SigmaValidationSettings, ValidationRules} -import org.ergoplatform.{ErgoBox, SigmaConstants} +import org.ergoplatform.validation.{ValidationRules, SigmaValidationSettings} +import org.ergoplatform.{SigmaConstants, ErgoBox} import sigma.data.OverloadHack.Overloaded1 -import sigma.data.{CollOverArrayBuilder, RType} +import sigma.data.RType import sigma.util.Extensions.BigIntegerOps import scorex.crypto.authds.avltree.batch._ -import scorex.crypto.authds.{ADDigest, ADKey, ADValue, SerializedAdProof} +import scorex.crypto.authds.{SerializedAdProof, ADDigest, ADValue, ADKey} import scorex.crypto.hash.{Blake2b256, Digest32, Sha256} -import scorex.utils.{Ints, Longs} -import sigma.VersionContext +import scorex.utils.{Longs, Ints} import sigmastate.SCollection.SByteArray import sigmastate.Values.ErgoTree.EmptyConstants -import sigmastate.Values.{ConstantNode, ErgoTree, EvaluatedValue, SValue, SigmaBoolean} +import sigmastate.Values.{EvaluatedValue, SValue, ConstantNode, ErgoTree, SigmaBoolean} import sigmastate._ import sigmastate.crypto.CryptoConstants.EcPointType import sigmastate.crypto.DLogProtocol.ProveDlog -import sigmastate.crypto.{CryptoConstants, ProveDHTuple} -import sigmastate.crypto.{CryptoFacade, Ecp} +import sigmastate.crypto.{ProveDHTuple, CryptoConstants, Ecp, CryptoFacade} import sigmastate.eval.Extensions._ import sigmastate.interpreter.Interpreter import sigmastate.serialization.ErgoTreeSerializer.DefaultSerializer import sigmastate.serialization.{GroupElementSerializer, SigmaSerializer} -import sigma._ +import sigma.{VersionContext, _} import java.math.BigInteger import java.util.Arrays import scala.annotation.unused import scala.reflect.ClassTag -import scala.util.{Failure, Success} +import scala.util.{Success, Failure} /** Interface implmented by wrappers to provide access to the underlying wrapped value. */ trait WrapperOf[T] { @@ -154,7 +152,7 @@ case class CSigmaProp(sigmaTree: SigmaBoolean) extends SigmaProp with WrapperOf[ * * @see BatchAVLVerifier */ -class AvlTreeVerifier(startingDigest: ADDigest, +class AvlTreeVerifier private (startingDigest: ADDigest, proof: SerializedAdProof, override val keyLength: Int, override val valueLengthOpt: Option[Int]) @@ -166,6 +164,12 @@ class AvlTreeVerifier(startingDigest: ADDigest, override protected def logError(t: Throwable): Unit = {} } object AvlTreeVerifier { + /** Create an instance of [[AvlTreeVerifier]] for the given tree and proof. + * Both tree and proof are immutable. + * @param tree represents a tree state to verify + * @param proof proof of tree operations leading to the state digest in the tree + * @return a new verifier instance + */ def apply(tree: AvlTree, proof: Coll[Byte]): AvlTreeVerifier = { val treeData = tree.asInstanceOf[CAvlTree].treeData val adProof = SerializedAdProof @@ proof.toArray @@ -491,7 +495,6 @@ object CHeader { class CostingSigmaDslBuilder extends SigmaDslBuilder { dsl => implicit val validationSettings: SigmaValidationSettings = ValidationRules.currentSettings - // manual fix override val Colls: CollBuilder = sigma.Colls override def BigInt(n: BigInteger): BigInt = CBigInt(n) diff --git a/interpreter/shared/src/main/scala/sigmastate/eval/Evaluation.scala b/interpreter/shared/src/main/scala/sigmastate/eval/Evaluation.scala index 242b4c9be2..8771fe2b32 100644 --- a/interpreter/shared/src/main/scala/sigmastate/eval/Evaluation.scala +++ b/interpreter/shared/src/main/scala/sigmastate/eval/Evaluation.scala @@ -118,7 +118,8 @@ object Evaluation { } /** Tries to reconstruct RType of the given value. - * If not successfull returns failure. */ + * If not successfull returns failure. + * NOTE, this method is NOT used in consensus. */ def rtypeOf(value: Any): Try[RType[_]] = Try { value match { case arr if arr.getClass.isArray => val itemClass = arr.getClass.getComponentType @@ -140,7 +141,11 @@ object Evaluation { case _: Unit => UnitType case _: sigma.BigInt => BigIntRType case _: GroupElement => GroupElementRType - case _: ErgoBox => ErgoBoxRType // TODO remove this RType + // TODO remove this case to allow removing of RType instances + // for ErgoBox, AvlTreeData, SigmaBoolean. + // RType describes only the types that can be put into registers, context variables and + // used as ErgoTree evaluation intermediate values. + case _: ErgoBox => ErgoBoxRType case _: Box => BoxRType case _: AvlTreeData => AvlTreeDataRType // TODO remove this RType diff --git a/interpreter/shared/src/main/scala/sigmastate/sigmastate.scala b/interpreter/shared/src/main/scala/sigmastate/sigmastate.scala index 4ebc1cb2ce..185fbebb9d 100644 --- a/interpreter/shared/src/main/scala/sigmastate/sigmastate.scala +++ b/interpreter/shared/src/main/scala/sigmastate/sigmastate.scala @@ -1,15 +1,20 @@ import org.ergoplatform.{ErgoBox, ErgoBoxCandidate, ErgoLikeContext} -import sigma.data.{GeneralType, RType} +import sigma.data.{RType, GeneralType} import sigmastate.Values._ import sigmastate.lang.CheckingSigmaBuilder +import scala.annotation.nowarn import scala.reflect.classTag package object sigmastate { import CheckingSigmaBuilder._ + /** Shadow the implicit from sigma package so it doesn't interfere with the resolution + * of ClassTags below. + */ + @nowarn private def rtypeToClassTag = ??? + /** RType descriptors for predefined types used in AOTC-based interpreter. */ - def rtypeToClassTag = ??? implicit val SigmaBooleanRType : RType[SigmaBoolean] = RType.fromClassTag(classTag[SigmaBoolean]) diff --git a/sc/shared/src/main/scala/special/collection/impl/CollsImpl.scala b/sc/shared/src/main/scala/special/collection/impl/CollsImpl.scala index 881b1c750c..239bfff4e5 100644 --- a/sc/shared/src/main/scala/special/collection/impl/CollsImpl.scala +++ b/sc/shared/src/main/scala/special/collection/impl/CollsImpl.scala @@ -332,8 +332,6 @@ class CollCls extends EntityObject("Coll") { def map[A,B](xs: Ref[Coll[A]])(f: Ref[A] => Ref[B]) = { implicit val eA = unlift(xs.elem); xs.map(fun(f))} } - // manual fix: CollIso, collIso - // familyElem class CollElem[A, To <: Coll[A]](implicit _eA: Elem[A]) extends EntityElem1[A, To, Coll](_eA, container[Coll]) { @@ -354,8 +352,6 @@ class CollCls extends EntityObject("Coll") { implicit final def collElement[A](implicit eA: Elem[A]): Elem[Coll[A]] = cachedElemByClass(eA)(RClass(classOf[CollElem[A, Coll[A]]])) - // manual fix: ViewColl - object CollMethods { object length { def unapply(d: Def[_]): Nullable[Ref[Coll[A]] forSome {type A}] = d match { diff --git a/sc/shared/src/main/scala/special/sigma/impl/SigmaDslImpl.scala b/sc/shared/src/main/scala/special/sigma/impl/SigmaDslImpl.scala index e2ce41ad1e..8da36ce6cf 100644 --- a/sc/shared/src/main/scala/special/sigma/impl/SigmaDslImpl.scala +++ b/sc/shared/src/main/scala/special/sigma/impl/SigmaDslImpl.scala @@ -437,7 +437,6 @@ object SigmaProp extends EntityObject("SigmaProp") { true, false, element[Coll[Byte]])) } - // manual fix && override def &&(other: Ref[SigmaProp]): Ref[SigmaProp] = { asRep[SigmaProp](mkMethodCall(self, SigmaPropClass.getMethod("$amp$amp", classOf[Sym]), @@ -445,7 +444,6 @@ object SigmaProp extends EntityObject("SigmaProp") { true, false, element[SigmaProp])) } - // manual fix || override def ||(other: Ref[SigmaProp]): Ref[SigmaProp] = { asRep[SigmaProp](mkMethodCall(self, SigmaPropClass.getMethod("$bar$bar", classOf[Sym]), @@ -486,7 +484,6 @@ object SigmaProp extends EntityObject("SigmaProp") { true, true, element[Coll[Byte]])) } - // manual fix && def &&(other: Ref[SigmaProp]): Ref[SigmaProp] = { asRep[SigmaProp](mkMethodCall(source, SigmaPropClass.getMethod("$amp$amp", classOf[Sym]), @@ -494,7 +491,6 @@ object SigmaProp extends EntityObject("SigmaProp") { true, true, element[SigmaProp])) } - // manual fix || def ||(other: Ref[SigmaProp]): Ref[SigmaProp] = { asRep[SigmaProp](mkMethodCall(source, SigmaPropClass.getMethod("$bar$bar", classOf[Sym]), diff --git a/sdk/shared/src/test/scala/org/ergoplatform/sdk/multisig/SigningSpec.scala b/sdk/shared/src/test/scala/org/ergoplatform/sdk/multisig/SigningSpec.scala deleted file mode 100644 index e69de29bb2..0000000000 From 36ca6c90d758d33f8922a7b4a1c0080779782afc Mon Sep 17 00:00:00 2001 From: Alexander Slesarenko Date: Thu, 21 Sep 2023 21:48:59 +0200 Subject: [PATCH 30/37] new-p2sh: changed scriptId value to 126 --- .../scala/org/ergoplatform/ErgoAddress.scala | 24 +++++++++++-------- .../ErgoAddressSpecification.scala | 6 ++--- 2 files changed, 17 insertions(+), 13 deletions(-) diff --git a/interpreter/shared/src/main/scala/org/ergoplatform/ErgoAddress.scala b/interpreter/shared/src/main/scala/org/ergoplatform/ErgoAddress.scala index 483a0c1dde..5813ff99e7 100644 --- a/interpreter/shared/src/main/scala/org/ergoplatform/ErgoAddress.scala +++ b/interpreter/shared/src/main/scala/org/ergoplatform/ErgoAddress.scala @@ -2,11 +2,11 @@ package org.ergoplatform import scorex.utils.Ints import org.ergoplatform.ErgoAddressEncoder.NetworkPrefix -import scorex.crypto.hash.{Digest32, Blake2b256} +import scorex.crypto.hash.{Blake2b256, Digest32} import scorex.util.encode.Base58 import sigmastate.Values._ import sigmastate._ -import sigmastate.crypto.DLogProtocol.{ProveDlogProp, ProveDlog} +import sigmastate.crypto.DLogProtocol.{ProveDlog, ProveDlogProp} import sigmastate.exceptions.SigmaException import sigmastate.serialization._ import sigmastate.utxo.{DeserializeContext, Slice} @@ -128,7 +128,9 @@ object P2PKAddress { } } -/** Implementation of pay-to-script-hash [[ErgoAddress]]. */ +/** Implementation of pay-to-script-hash [[ErgoAddress]]. + * @param scriptHash first 192 bits of the Blake2b256 hash of serialized script bytes + */ class Pay2SHAddress(val scriptHash: Array[Byte])(implicit val encoder: ErgoAddressEncoder) extends ErgoAddress { override val addressTypePrefix: Byte = Pay2SHAddress.addressTypePrefix @@ -141,12 +143,12 @@ class Pay2SHAddress(val scriptHash: Array[Byte])(implicit val encoder: ErgoAddre /** The proposition which checks that `contextVar(scriptId)` has original script * (whose hash equals to this [[scriptHash]]) which evaluates to true. * - * Assumes the context variable is accessed as `getVar[Coll[Byte]](1).get` + * Assumes the context variable is accessed as `getVar[Coll[Byte]](126).get` * and contains serialized original script bytes. * - * NOTE: This script is not stored in [[contentBytes]] of the address. + * NOTE: This `script` field is not stored in [[contentBytes]] of the address. * So the address doesn't depend on this script which means this specific script can be - * changed without breaking the addresses. + * changed without breaking the existing p2sh addresses. * * NOTE: The ErgoTree is created without segregation of the constants. * @@ -158,7 +160,7 @@ class Pay2SHAddress(val scriptHash: Array[Byte])(implicit val encoder: ErgoAddre override val script = { val hashEquals = EQ( Slice(CalcBlake2b256(GetVarByteArray(scriptId).get), IntConstant(0), IntConstant(24)), - scriptHash + ByteArrayConstant(scriptHash) ) val scriptIsCorrect = DeserializeContext(scriptId, SSigmaProp) ErgoTree.withoutSegregation(SigmaAnd(hashEquals.toSigmaProp, scriptIsCorrect)) @@ -176,9 +178,10 @@ class Pay2SHAddress(val scriptHash: Array[Byte])(implicit val encoder: ErgoAddre object Pay2SHAddress { /** An id of the context variable used in pay-to-script-hash address script. + * Note, value 127 is used for strage rent in Ergo node, see org.ergoplatform.wallet.interpreter.ErgoInterpreter * @see [[Pay2SHAddress.script]] */ - val scriptId = 1: Byte + val scriptId = 126: Byte /** Value added to the prefix byte in the serialized bytes of an encoded P2SH address. * @see [[ErgoAddressEncoder.toString]] @@ -300,7 +303,7 @@ case class ErgoAddressEncoder(networkPrefix: NetworkPrefix) { new P2PKAddress(ProveDlog(p), contentBytes) case Pay2SHAddress.addressTypePrefix => if (contentBytes.length != 24) { //192-bits hash used - throw new Exception(s"Improper content in P2SH script: $addrBase58Str") + throw new Exception(s"Invalid length of the hash bytes in P2SH address: $addrBase58Str") } new Pay2SHAddress(contentBytes) case Pay2SAddress.addressTypePrefix => @@ -328,7 +331,8 @@ case class ErgoAddressEncoder(networkPrefix: NetworkPrefix) { } /** Converts the given [[ErgoTree]] to the corresponding [[ErgoAddress]]. - * It is inverse of [[ErgoAddress.script]] such that `fromProposition(addr.script) == addr` + * It is inverse of [[ErgoAddress.script]] such that + * `ErgoAddressEncoder.fromProposition(addr.script) == addr` * * @return Failure(ex) if the `proposition` cannot be converted to any type of address. */ diff --git a/sc/shared/src/test/scala/org/ergoplatform/ErgoAddressSpecification.scala b/sc/shared/src/test/scala/org/ergoplatform/ErgoAddressSpecification.scala index b4153ff4f2..73156ca1b8 100644 --- a/sc/shared/src/test/scala/org/ergoplatform/ErgoAddressSpecification.scala +++ b/sc/shared/src/test/scala/org/ergoplatform/ErgoAddressSpecification.scala @@ -170,7 +170,7 @@ class ErgoAddressSpecification extends SigmaDslTesting assertExceptionThrown( ergoAddressEncoder.fromString(addrStr).getOrThrow, - t => t.getMessage.contains("Improper content in P2SH script: 41fKjb7zWNw") + t => t.getMessage.contains("Invalid length of the hash bytes in P2SH address: 41fKjb7zWNw") ) } @@ -228,7 +228,7 @@ class ErgoAddressSpecification extends SigmaDslTesting } def testPay2SHAddress(address: Pay2SHAddress, scriptBytes: Array[Byte]) = { - val scriptId = 1.toByte + val scriptId = Pay2SHAddress.scriptId val boxToSpend = testBox(10, address.script, creationHeight = 5) val ctx = ErgoLikeContextTesting.dummy(boxToSpend, activatedVersionInTests) .withExtension(ContextExtension(Seq( @@ -271,7 +271,7 @@ class ErgoAddressSpecification extends SigmaDslTesting res } - val scriptVarId = 1.toByte + val scriptVarId = Pay2SHAddress.scriptId val script = "{ 1 < 2 }" val prop = compile(Map.empty, script).asBoolValue.toSigmaProp val scriptBytes = ValueSerializer.serialize(prop) From c21fd9c646d808f2b39010933cd289b18a49b11c Mon Sep 17 00:00:00 2001 From: Alexander Slesarenko Date: Mon, 25 Sep 2023 16:43:05 +0200 Subject: [PATCH 31/37] ergotree-version: abstract classes for BlockchainParameters and BlockchainStateContext --- .../scala/org/ergoplatform/sdk/js/Isos.scala | 4 +- .../org/ergoplatform/sdk/js/IsosSpec.scala | 4 +- .../sdk/BlockchainParameters.scala | 44 ++++++++++++------- .../context/BlockchainStateContext.scala | 21 +++++---- 4 files changed, 46 insertions(+), 27 deletions(-) diff --git a/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Isos.scala b/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Isos.scala index 5794b1d636..b2ffd664e8 100644 --- a/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Isos.scala +++ b/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Isos.scala @@ -188,7 +188,7 @@ object Isos { val isoBlockchainParameters: Iso[BlockchainParameters, sdk.BlockchainParameters] = new Iso[BlockchainParameters, sdk.BlockchainParameters] { override def to(a: BlockchainParameters): sdk.BlockchainParameters = { - sdk.BlockchainParameters( + sdk.CBlockchainParameters( storageFeeFactor = a.storageFeeFactor, minValuePerByte = a.minValuePerByte, maxBlockSize = a.maxBlockSize, @@ -221,7 +221,7 @@ object Isos { implicit val isoBlockchainStateContext: Iso[BlockchainStateContext, context.BlockchainStateContext] = new Iso[BlockchainStateContext, context.BlockchainStateContext] { override def to(a: BlockchainStateContext): context.BlockchainStateContext = { - context.BlockchainStateContext( + context.CBlockchainStateContext( sigmaLastHeaders = isoArrayToColl(isoHeader).to(a.sigmaLastHeaders), previousStateDigest = isoStringToColl.to(a.previousStateDigest), sigmaPreHeader = isoPreHeader.to(a.sigmaPreHeader) diff --git a/sdk/js/src/test/scala/org/ergoplatform/sdk/js/IsosSpec.scala b/sdk/js/src/test/scala/org/ergoplatform/sdk/js/IsosSpec.scala index 135571aabe..2164b9b339 100644 --- a/sdk/js/src/test/scala/org/ergoplatform/sdk/js/IsosSpec.scala +++ b/sdk/js/src/test/scala/org/ergoplatform/sdk/js/IsosSpec.scala @@ -2,7 +2,7 @@ package org.ergoplatform.sdk.js import org.ergoplatform.ErgoBox.{AdditionalRegisters, BoxId, TokenId} import org.ergoplatform._ -import org.ergoplatform.sdk.wallet.protocol.context.BlockchainStateContext +import org.ergoplatform.sdk.wallet.protocol.context.{BlockchainStateContext, CBlockchainStateContext} import org.ergoplatform.sdk.{ExtendedInputBox, Iso} import org.scalacheck.{Arbitrary, Gen} import org.scalatest.matchers.should.Matchers @@ -27,7 +27,7 @@ class IsosSpec extends AnyPropSpec with Matchers with ObjectGenerators with Sca stateRoot <- avlTreeGen headers <- headersGen(stateRoot) preHeader <- preHeaderGen(headers.headOption.map(_.id).getOrElse(modifierIdBytesGen.sample.get)) - } yield BlockchainStateContext( + } yield CBlockchainStateContext( sigmaLastHeaders = Colls.fromItems(headers:_*), previousStateDigest = stateRoot.digest, sigmaPreHeader = preHeader diff --git a/sdk/shared/src/main/scala/org/ergoplatform/sdk/BlockchainParameters.scala b/sdk/shared/src/main/scala/org/ergoplatform/sdk/BlockchainParameters.scala index 4a1014b112..6f799ff8d8 100644 --- a/sdk/shared/src/main/scala/org/ergoplatform/sdk/BlockchainParameters.scala +++ b/sdk/shared/src/main/scala/org/ergoplatform/sdk/BlockchainParameters.scala @@ -1,21 +1,35 @@ package org.ergoplatform.sdk /** Blockchain parameters re-adjustable via miners voting and voting-related data. - * All these fields are included into extension section of a first block of a voting epoch. - * - * @param storageFeeFactor cost of storing 1 byte in UTXO for four years, in nanoErgs - * @param minValuePerByte cost of a transaction output, in computation unit - * @param maxBlockSize max block size, in bytes - * @param tokenAccessCost cost of a token contained in a transaction, in computation unit - * @param inputCost cost of a transaction input, in computation unit - * @param dataInputCost cost of a transaction data input, in computation unit - * @param outputCost cost of a transaction output, in computation unit - * @param maxBlockCost computation units limit per block - * @param softForkStartingHeight height when voting for a soft-fork had been started - * @param softForkVotesCollected votes for soft-fork collected in previous epochs - * @param blockVersion Protocol version activated on the network + * All these parameters are included into extension section of a first block of a voting epoch. */ -case class BlockchainParameters( +abstract class BlockchainParameters { + /** Cost of storing 1 byte in UTXO for four years, in nanoErgs. */ + def storageFeeFactor: Int + /** Cost of a transaction output, in computation unit. */ + def minValuePerByte: Int + /** Max block size, in bytes. */ + def maxBlockSize: Int + /** Cost of a token contained in a transaction, in computation unit. */ + def tokenAccessCost: Int + /** Cost of a transaction input, in computation unit. */ + def inputCost: Int + /** Cost of a transaction data input, in computation unit. */ + def dataInputCost: Int + /** Cost of a transaction output, in computation unit. */ + def outputCost: Int + /** Computation units limit per block. */ + def maxBlockCost: Int + /** Height when voting for a soft-fork had been started. */ + def softForkStartingHeight: Option[Int] + /** Votes for soft-fork collected in previous epochs. */ + def softForkVotesCollected: Option[Int] + /** Protocol version activated on the network. */ + def blockVersion: Byte +} + +/** Concete implementation of blockchain parameters. */ +case class CBlockchainParameters( storageFeeFactor: Int, minValuePerByte: Int, maxBlockSize: Int, @@ -27,7 +41,7 @@ case class BlockchainParameters( softForkStartingHeight: Option[Int], softForkVotesCollected: Option[Int], blockVersion: Byte -) +) extends BlockchainParameters /** Global parameters used by SDK */ object BlockchainParameters { diff --git a/sdk/shared/src/main/scala/org/ergoplatform/sdk/wallet/protocol/context/BlockchainStateContext.scala b/sdk/shared/src/main/scala/org/ergoplatform/sdk/wallet/protocol/context/BlockchainStateContext.scala index 172c24fc0f..28e79867a5 100644 --- a/sdk/shared/src/main/scala/org/ergoplatform/sdk/wallet/protocol/context/BlockchainStateContext.scala +++ b/sdk/shared/src/main/scala/org/ergoplatform/sdk/wallet/protocol/context/BlockchainStateContext.scala @@ -2,14 +2,19 @@ package org.ergoplatform.sdk.wallet.protocol.context import sigma.Coll -/** Blockchain context used in tx signing. - * - * @param sigmaLastHeaders fixed number (10 in Ergo) of last block headers - * @param previousStateDigest UTXO set digest from a last header (of sigmaLastHeaders) - * @param sigmaPreHeader returns pre-header (header without certain fields) of the current block - */ -case class BlockchainStateContext( +/** Blockchain context used in tx signing. */ +abstract class BlockchainStateContext { + /** Fixed number (10 in Ergo) of last block headers. */ + def sigmaLastHeaders: Coll[sigma.Header] + /** UTXO set digest from a last header (of sigmaLastHeaders). */ + def previousStateDigest: Coll[Byte] + /** Returns pre-header (header without certain fields) of the current block. */ + def sigmaPreHeader: sigma.PreHeader +} + +/** Blockchain context used in tx signing. */ +case class CBlockchainStateContext( sigmaLastHeaders: Coll[sigma.Header], previousStateDigest: Coll[Byte], sigmaPreHeader: sigma.PreHeader -) +) extends BlockchainStateContext From d98325ea0a5707ccfe896d552404b59b0b8e4f6f Mon Sep 17 00:00:00 2001 From: Alexander Slesarenko Date: Mon, 25 Sep 2023 16:43:05 +0200 Subject: [PATCH 32/37] ergotree-version: abstract classes for BlockchainParameters and BlockchainStateContext --- .../scala/org/ergoplatform/sdk/js/Isos.scala | 4 +- .../org/ergoplatform/sdk/js/IsosSpec.scala | 4 +- .../sdk/BlockchainParameters.scala | 44 ++++++++++++------- .../context/BlockchainStateContext.scala | 25 ++++++----- 4 files changed, 48 insertions(+), 29 deletions(-) diff --git a/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Isos.scala b/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Isos.scala index a317e3ab29..56df9cd2c9 100644 --- a/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Isos.scala +++ b/sdk/js/src/main/scala/org/ergoplatform/sdk/js/Isos.scala @@ -189,7 +189,7 @@ object Isos { val isoBlockchainParameters: Iso[BlockchainParameters, sdk.BlockchainParameters] = new Iso[BlockchainParameters, sdk.BlockchainParameters] { override def to(a: BlockchainParameters): sdk.BlockchainParameters = { - sdk.BlockchainParameters( + sdk.CBlockchainParameters( storageFeeFactor = a.storageFeeFactor, minValuePerByte = a.minValuePerByte, maxBlockSize = a.maxBlockSize, @@ -222,7 +222,7 @@ object Isos { implicit val isoBlockchainStateContext: Iso[BlockchainStateContext, context.BlockchainStateContext] = new Iso[BlockchainStateContext, context.BlockchainStateContext] { override def to(a: BlockchainStateContext): context.BlockchainStateContext = { - context.BlockchainStateContext( + context.CBlockchainStateContext( sigmaLastHeaders = isoArrayToColl(isoHeader).to(a.sigmaLastHeaders), previousStateDigest = isoStringToColl.to(a.previousStateDigest), sigmaPreHeader = isoPreHeader.to(a.sigmaPreHeader) diff --git a/sdk/js/src/test/scala/org/ergoplatform/sdk/js/IsosSpec.scala b/sdk/js/src/test/scala/org/ergoplatform/sdk/js/IsosSpec.scala index 47eedf2706..3e27513f02 100644 --- a/sdk/js/src/test/scala/org/ergoplatform/sdk/js/IsosSpec.scala +++ b/sdk/js/src/test/scala/org/ergoplatform/sdk/js/IsosSpec.scala @@ -2,7 +2,7 @@ package org.ergoplatform.sdk.js import org.ergoplatform.ErgoBox.{AdditionalRegisters, BoxId, TokenId} import org.ergoplatform._ -import org.ergoplatform.sdk.wallet.protocol.context.BlockchainStateContext +import org.ergoplatform.sdk.wallet.protocol.context.{BlockchainStateContext, CBlockchainStateContext} import org.ergoplatform.sdk.{ExtendedInputBox, Iso} import org.scalacheck.{Arbitrary, Gen} import org.scalatest.matchers.should.Matchers @@ -30,7 +30,7 @@ class IsosSpec extends AnyPropSpec with Matchers with ObjectGenerators with Sca stateRoot <- avlTreeGen headers <- headersGen(stateRoot) preHeader <- preHeaderGen(headers.headOption.map(_.id).getOrElse(modifierIdBytesGen.sample.get)) - } yield BlockchainStateContext( + } yield CBlockchainStateContext( sigmaLastHeaders = Colls.fromItems(headers:_*), previousStateDigest = stateRoot.digest, sigmaPreHeader = preHeader diff --git a/sdk/shared/src/main/scala/org/ergoplatform/sdk/BlockchainParameters.scala b/sdk/shared/src/main/scala/org/ergoplatform/sdk/BlockchainParameters.scala index 4a1014b112..6f799ff8d8 100644 --- a/sdk/shared/src/main/scala/org/ergoplatform/sdk/BlockchainParameters.scala +++ b/sdk/shared/src/main/scala/org/ergoplatform/sdk/BlockchainParameters.scala @@ -1,21 +1,35 @@ package org.ergoplatform.sdk /** Blockchain parameters re-adjustable via miners voting and voting-related data. - * All these fields are included into extension section of a first block of a voting epoch. - * - * @param storageFeeFactor cost of storing 1 byte in UTXO for four years, in nanoErgs - * @param minValuePerByte cost of a transaction output, in computation unit - * @param maxBlockSize max block size, in bytes - * @param tokenAccessCost cost of a token contained in a transaction, in computation unit - * @param inputCost cost of a transaction input, in computation unit - * @param dataInputCost cost of a transaction data input, in computation unit - * @param outputCost cost of a transaction output, in computation unit - * @param maxBlockCost computation units limit per block - * @param softForkStartingHeight height when voting for a soft-fork had been started - * @param softForkVotesCollected votes for soft-fork collected in previous epochs - * @param blockVersion Protocol version activated on the network + * All these parameters are included into extension section of a first block of a voting epoch. */ -case class BlockchainParameters( +abstract class BlockchainParameters { + /** Cost of storing 1 byte in UTXO for four years, in nanoErgs. */ + def storageFeeFactor: Int + /** Cost of a transaction output, in computation unit. */ + def minValuePerByte: Int + /** Max block size, in bytes. */ + def maxBlockSize: Int + /** Cost of a token contained in a transaction, in computation unit. */ + def tokenAccessCost: Int + /** Cost of a transaction input, in computation unit. */ + def inputCost: Int + /** Cost of a transaction data input, in computation unit. */ + def dataInputCost: Int + /** Cost of a transaction output, in computation unit. */ + def outputCost: Int + /** Computation units limit per block. */ + def maxBlockCost: Int + /** Height when voting for a soft-fork had been started. */ + def softForkStartingHeight: Option[Int] + /** Votes for soft-fork collected in previous epochs. */ + def softForkVotesCollected: Option[Int] + /** Protocol version activated on the network. */ + def blockVersion: Byte +} + +/** Concete implementation of blockchain parameters. */ +case class CBlockchainParameters( storageFeeFactor: Int, minValuePerByte: Int, maxBlockSize: Int, @@ -27,7 +41,7 @@ case class BlockchainParameters( softForkStartingHeight: Option[Int], softForkVotesCollected: Option[Int], blockVersion: Byte -) +) extends BlockchainParameters /** Global parameters used by SDK */ object BlockchainParameters { diff --git a/sdk/shared/src/main/scala/org/ergoplatform/sdk/wallet/protocol/context/BlockchainStateContext.scala b/sdk/shared/src/main/scala/org/ergoplatform/sdk/wallet/protocol/context/BlockchainStateContext.scala index 5c8d97df4f..e2fc88eaf9 100644 --- a/sdk/shared/src/main/scala/org/ergoplatform/sdk/wallet/protocol/context/BlockchainStateContext.scala +++ b/sdk/shared/src/main/scala/org/ergoplatform/sdk/wallet/protocol/context/BlockchainStateContext.scala @@ -2,14 +2,19 @@ package org.ergoplatform.sdk.wallet.protocol.context import special.collection.Coll -/** Blockchain context used in tx signing. - * - * @param sigmaLastHeaders fixed number (10 in Ergo) of last block headers - * @param previousStateDigest UTXO set digest from a last header (of sigmaLastHeaders) - * @param sigmaPreHeader returns pre-header (header without certain fields) of the current block - */ -case class BlockchainStateContext( - sigmaLastHeaders: Coll[special.sigma.Header], +/** Blockchain context used in tx signing. */ +abstract class BlockchainStateContext { + /** Fixed number (10 in Ergo) of last block headers. */ + def sigmaLastHeaders: Coll[sigma.Header] + /** UTXO set digest from a last header (of sigmaLastHeaders). */ + def previousStateDigest: Coll[Byte] + /** Returns pre-header (header without certain fields) of the current block. */ + def sigmaPreHeader: sigma.PreHeader +} + +/** Blockchain context used in tx signing. */ +case class CBlockchainStateContext( + sigmaLastHeaders: Coll[sigma.Header], previousStateDigest: Coll[Byte], - sigmaPreHeader: special.sigma.PreHeader -) + sigmaPreHeader: sigma.PreHeader +) extends BlockchainStateContext From dca61811bd8dc839b97178d9c862d65c210c3af2 Mon Sep 17 00:00:00 2001 From: Alexander Slesarenko Date: Tue, 26 Sep 2023 22:38:21 +0200 Subject: [PATCH 33/37] v5.0.11-fix1: abstract classes for BlockchainParameters and BlockchainStateContext --- .../wallet/protocol/context/BlockchainStateContext.scala | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sdk/shared/src/main/scala/org/ergoplatform/sdk/wallet/protocol/context/BlockchainStateContext.scala b/sdk/shared/src/main/scala/org/ergoplatform/sdk/wallet/protocol/context/BlockchainStateContext.scala index e2fc88eaf9..985a4acf8d 100644 --- a/sdk/shared/src/main/scala/org/ergoplatform/sdk/wallet/protocol/context/BlockchainStateContext.scala +++ b/sdk/shared/src/main/scala/org/ergoplatform/sdk/wallet/protocol/context/BlockchainStateContext.scala @@ -5,16 +5,16 @@ import special.collection.Coll /** Blockchain context used in tx signing. */ abstract class BlockchainStateContext { /** Fixed number (10 in Ergo) of last block headers. */ - def sigmaLastHeaders: Coll[sigma.Header] + def sigmaLastHeaders: Coll[special.sigma.Header] /** UTXO set digest from a last header (of sigmaLastHeaders). */ def previousStateDigest: Coll[Byte] /** Returns pre-header (header without certain fields) of the current block. */ - def sigmaPreHeader: sigma.PreHeader + def sigmaPreHeader: special.sigma.PreHeader } /** Blockchain context used in tx signing. */ case class CBlockchainStateContext( - sigmaLastHeaders: Coll[sigma.Header], + sigmaLastHeaders: Coll[special.sigma.Header], previousStateDigest: Coll[Byte], - sigmaPreHeader: sigma.PreHeader + sigmaPreHeader: special.sigma.PreHeader ) extends BlockchainStateContext From 770d297b53529f1cbd2a3a4074d4f3ddd0b74042 Mon Sep 17 00:00:00 2001 From: Alexander Slesarenko Date: Thu, 28 Sep 2023 11:55:37 +0200 Subject: [PATCH 34/37] v5.0.11-fix1: fix issue with tx decoders --- .../src/main/scala/org/ergoplatform/sdk/JsonCodecs.scala | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/sdk/shared/src/main/scala/org/ergoplatform/sdk/JsonCodecs.scala b/sdk/shared/src/main/scala/org/ergoplatform/sdk/JsonCodecs.scala index 52e1565ca3..0806e78098 100644 --- a/sdk/shared/src/main/scala/org/ergoplatform/sdk/JsonCodecs.scala +++ b/sdk/shared/src/main/scala/org/ergoplatform/sdk/JsonCodecs.scala @@ -379,8 +379,7 @@ trait JsonCodecs { implicit val ergoLikeTransactionDecoder: Decoder[ErgoLikeTransaction] = Decoder.instance({ implicit cursor => for { - t <- cursor.downField("type").as[String] - inputs <- {require(t == "ELT"); cursor.downField("inputs").as[IndexedSeq[Input]] } + inputs <- cursor.downField("inputs").as[IndexedSeq[Input]] dataInputs <- cursor.downField("dataInputs").as[IndexedSeq[DataInput]] outputs <- cursor.downField("outputs").as[IndexedSeq[ErgoBoxCandidate]] } yield new ErgoLikeTransaction(inputs, dataInputs, outputs) @@ -398,8 +397,7 @@ trait JsonCodecs { implicit val unsignedErgoLikeTransactionDecoder: Decoder[UnsignedErgoLikeTransaction] = Decoder.instance({ implicit cursor => for { - t <- cursor.downField("type").as[String] - inputs <- {require(t == "UELT"); cursor.downField("inputs").as[IndexedSeq[UnsignedInput]] } + inputs <- cursor.downField("inputs").as[IndexedSeq[UnsignedInput]] dataInputs <- cursor.downField("dataInputs").as[IndexedSeq[DataInput]] outputs <- cursor.downField("outputs").as[IndexedSeq[ErgoBoxCandidate]] } yield new UnsignedErgoLikeTransaction(inputs, dataInputs, outputs) From 7de88b03806c588d46487e0873ea9648cbbc0c65 Mon Sep 17 00:00:00 2001 From: Alexander Slesarenko Date: Thu, 28 Sep 2023 12:52:12 +0200 Subject: [PATCH 35/37] v5.0.11-fix1: rollback changes in decoders --- .../scala/org/ergoplatform/sdk/JsonCodecs.scala | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/sdk/shared/src/main/scala/org/ergoplatform/sdk/JsonCodecs.scala b/sdk/shared/src/main/scala/org/ergoplatform/sdk/JsonCodecs.scala index 0806e78098..d4a3c08ea6 100644 --- a/sdk/shared/src/main/scala/org/ergoplatform/sdk/JsonCodecs.scala +++ b/sdk/shared/src/main/scala/org/ergoplatform/sdk/JsonCodecs.scala @@ -369,7 +369,6 @@ trait JsonCodecs { implicit val ergoLikeTransactionEncoder: Encoder[ErgoLikeTransaction] = Encoder.instance({ tx => Json.obj( - "type" -> "ELT".asJson, // ErgoLikeTransaction "id" -> tx.id.asJson, "inputs" -> tx.inputs.asJson, "dataInputs" -> tx.dataInputs.asJson, @@ -387,7 +386,6 @@ trait JsonCodecs { implicit val unsignedErgoLikeTransactionEncoder: Encoder[UnsignedErgoLikeTransaction] = Encoder.instance({ tx => Json.obj( - "type" -> "UELT".asJson, // UnsignedErgoLikeTransaction "id" -> tx.id.asJson, "inputs" -> tx.inputs.asJson, "dataInputs" -> tx.dataInputs.asJson, @@ -409,15 +407,10 @@ trait JsonCodecs { case t => throw new SigmaException(s"Don't know how to encode transaction $t") }) - implicit val ergoLikeTransactionTemplateDecoder: Decoder[ErgoLikeTransactionTemplate[_ <: UnsignedInput]] = Decoder.instance({ implicit cursor => - for { - t <- cursor.downField("type").as[String] - tx <- t match { - case "ELT" => ergoLikeTransactionDecoder(cursor) - case "UELT" => unsignedErgoLikeTransactionDecoder(cursor) - } - } yield tx - }) + implicit val ergoLikeTransactionTemplateDecoder: Decoder[ErgoLikeTransactionTemplate[_ <: UnsignedInput]] = { + ergoLikeTransactionDecoder.asInstanceOf[Decoder[ErgoLikeTransactionTemplate[_ <: UnsignedInput]]] or + unsignedErgoLikeTransactionDecoder.asInstanceOf[Decoder[ErgoLikeTransactionTemplate[_ <: UnsignedInput]]] + } implicit val sigmaValidationSettingsEncoder: Encoder[SigmaValidationSettings] = Encoder.instance({ v => SigmaValidationSettingsSerializer.toBytes(v).asJson From 4c5386420fb0bf014a8b228825bd6aa04c189dc3 Mon Sep 17 00:00:00 2001 From: Alexander Slesarenko Date: Thu, 28 Sep 2023 13:54:04 +0200 Subject: [PATCH 36/37] v5.0.11-fix1: rollback changes in decoders (2) --- .../src/main/scala/org/ergoplatform/sdk/JsonCodecs.scala | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/sdk/shared/src/main/scala/org/ergoplatform/sdk/JsonCodecs.scala b/sdk/shared/src/main/scala/org/ergoplatform/sdk/JsonCodecs.scala index d4a3c08ea6..008f71bb68 100644 --- a/sdk/shared/src/main/scala/org/ergoplatform/sdk/JsonCodecs.scala +++ b/sdk/shared/src/main/scala/org/ergoplatform/sdk/JsonCodecs.scala @@ -372,7 +372,7 @@ trait JsonCodecs { "id" -> tx.id.asJson, "inputs" -> tx.inputs.asJson, "dataInputs" -> tx.dataInputs.asJson, - "outputs" -> tx.outputCandidates.asJson + "outputs" -> tx.outputs.asJson ) }) @@ -389,7 +389,7 @@ trait JsonCodecs { "id" -> tx.id.asJson, "inputs" -> tx.inputs.asJson, "dataInputs" -> tx.dataInputs.asJson, - "outputs" -> tx.outputCandidates.asJson + "outputs" -> tx.outputs.asJson ) }) From ca85d0fa09af36058b1c003b16b82eb5bd1de263 Mon Sep 17 00:00:00 2001 From: Alexander Slesarenko Date: Thu, 28 Sep 2023 22:31:26 +0200 Subject: [PATCH 37/37] v5.0.12-RC: added JavaHelpers.JUnitRType --- sdk/shared/src/main/scala/org/ergoplatform/sdk/JavaHelpers.scala | 1 + 1 file changed, 1 insertion(+) diff --git a/sdk/shared/src/main/scala/org/ergoplatform/sdk/JavaHelpers.scala b/sdk/shared/src/main/scala/org/ergoplatform/sdk/JavaHelpers.scala index 328ffba714..75825defa3 100644 --- a/sdk/shared/src/main/scala/org/ergoplatform/sdk/JavaHelpers.scala +++ b/sdk/shared/src/main/scala/org/ergoplatform/sdk/JavaHelpers.scala @@ -244,6 +244,7 @@ object JavaHelpers { implicit val JIntRType: RType[JInt] = sigma.IntType.asInstanceOf[RType[JInt]] implicit val JLongRType: RType[JLong] = sigma.LongType.asInstanceOf[RType[JLong]] implicit val JBooleanRType: RType[JBoolean] = sigma.BooleanType.asInstanceOf[RType[JBoolean]] + implicit val JUnitRType: RType[Unit] = sigma.UnitType val HeaderRType: RType[Header] = sigma.HeaderRType val PreHeaderRType: RType[sigma.PreHeader] = sigma.PreHeaderRType