Skip to content

Commit

Permalink
minimize-modules: replaced special.collection -> sigma.collection and…
Browse files Browse the repository at this point in the history
… special.sigma -> sigma
  • Loading branch information
aslesarenko committed Aug 22, 2023
1 parent d9638b4 commit 9d4d53c
Show file tree
Hide file tree
Showing 135 changed files with 359 additions and 368 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
@@ -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,
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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(
Expand Down Expand Up @@ -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[_]])
}
)
)
}
}
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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]
Expand Down
Original file line number Diff line number Diff line change
@@ -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. */
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package special.collection
package sigma.collection

import scalan.RType

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package special.collection
package sigma.collection

import scalan._

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package special.collection
package sigma.collection

import java.util
import scalan._ // required
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package special.collection
package sigma.collection

import debox.cfor
import scorex.util.encode.Base16
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package special
package sigma

import scalan.RType

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
package special

import java.math.BigInteger
import scalan.RType
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package special
package sigma

import scalan.RType._
import scalan.{BaseTests, RType}
import RType._
import Types._
import sigma.Types._

class TypesTests extends BaseTests {

test("RType has name") {
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])")
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package special.collections
package sigma.collections

import org.scalacheck.Gen
import org.scalatest.exceptions.TestFailedException
Expand All @@ -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))

Expand Down Expand Up @@ -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)
*/
}
Expand All @@ -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)
Expand Down
8 changes: 4 additions & 4 deletions interpreter/js/src/main/scala/sigmastate/Platform.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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))
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
8 changes: 4 additions & 4 deletions interpreter/jvm/src/main/scala/sigmastate/Platform.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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))
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down
Loading

0 comments on commit 9d4d53c

Please sign in to comment.