Skip to content

Commit

Permalink
minimize-modules: move code around
Browse files Browse the repository at this point in the history
  • Loading branch information
aslesarenko committed Aug 22, 2023
1 parent 83c38cd commit cbbd0f3
Show file tree
Hide file tree
Showing 13 changed files with 33 additions and 35 deletions.
3 changes: 0 additions & 3 deletions common/jvm/src/main/scala/scalan/reflection/JavaImpl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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:_*)
}

Expand Down
11 changes: 11 additions & 0 deletions common/shared/src/main/scala/special/collection/CollType.scala
Original file line number Diff line number Diff line change
@@ -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}]"
}
Original file line number Diff line number Diff line change
@@ -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
Expand Down
11 changes: 0 additions & 11 deletions common/shared/src/main/scala/special/collection/Helpers.scala

This file was deleted.

19 changes: 9 additions & 10 deletions common/shared/src/main/scala/special/collection/package.scala
Original file line number Diff line number Diff line change
@@ -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 */
Expand All @@ -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))
}
}
2 changes: 1 addition & 1 deletion common/shared/src/main/scala/special/sigma/SigmaDsl.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
*/
Expand Down
3 changes: 2 additions & 1 deletion sc/shared/src/main/scala/scalan/GraphIRReflection.scala
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -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. */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions sc/shared/src/main/scala/special/sigma/SigmaDslUnit.scala
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package special.sigma {
import scalan._
import sigmastate.eval.SigmaLibrary

trait SigmaDsl extends Base { self: SigmaLibrary =>
trait BigInt extends Def[BigInt] {
Expand Down
Original file line number Diff line number Diff line change
@@ -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 {
Expand Down

0 comments on commit cbbd0f3

Please sign in to comment.