Skip to content

Commit 5360cf4

Browse files
authored
Merge pull request #873 from ScorexFoundation/v5.0.7-RC
Release candidate v5.0.7
2 parents f730a04 + 941a71b commit 5360cf4

File tree

395 files changed

+3911
-3589
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

395 files changed

+3911
-3589
lines changed

README.md

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -93,23 +93,19 @@ This library is
9393
on Maven repository and can be added to the SBT configuration of Scala project.
9494

9595
```scala
96-
libraryDependencies += "org.scorexfoundation" %% "sigma-state" % "4.0.3"
96+
libraryDependencies += "org.scorexfoundation" %% "sigma-state" % "5.0.6"
9797
```
9898

9999
## Repository Organization
100100

101-
| sub-module | description |
102-
|---|-----|
103-
| common | Used in all other submodules and contain basic utility classes |
104-
| core | Implementation of graph-based intermediate representation of ErgoTree, which is used in cost estimation and interpretation |
105-
| docs | Collection of documents |
106-
| library | Implementation of graph IR nodes for Coll, Size and other types |
107-
| library-api | Declarations of interfaces |
108-
| library-impl | Implementation of interfaces |
109-
| sigma-api | Declarations of runtime interfaces which are used in ErgoTree interpreter |
110-
| sigma-impl | Implementation of sigma-api interfaces |
111-
| sigma-library | Implementation of graph IR nodes for Sigma types |
112-
| sigmastate | Implementation ErgoTree, Interpreter and cost estimation |
101+
| sub-module | description |
102+
|-------------|-------------------------------------------------------------------------------------------|
103+
| common | Used in all other submodules and contain basic utility classes |
104+
| core-lib | Contains core classes such as Coll, BigInt used by interpreter |
105+
| docs | Collection of documents |
106+
| graph-ir | Implementation of graph-based intermediate representation of ErgoTree, which is used in by ErgoScript compiler |
107+
| interpreter | Implementation of ErgoTree Interpreter |
108+
| sc | Implementation of ErgoScript compiler |
113109

114110
## Contributing
115111

build.sbt

Lines changed: 34 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -70,13 +70,27 @@ dynverSonatypeSnapshots in ThisBuild := true
7070
dynverSeparator in ThisBuild := "-"
7171

7272
val bouncycastleBcprov = "org.bouncycastle" % "bcprov-jdk15on" % "1.66"
73-
val scrypto = "org.scorexfoundation" %% "scrypto" % "2.3.0-RC1"
73+
val scrypto = "org.scorexfoundation" %% "scrypto" % "2.3.0"
7474
val scorexUtil = "org.scorexfoundation" %% "scorex-util" % "0.2.0"
7575
val debox = "org.scorexfoundation" %% "debox" % "0.10.0"
7676
val spireMacros = "org.typelevel" %% "spire-macros" % "0.17.0-M1"
7777
val fastparse = "com.lihaoyi" %% "fastparse" % "2.3.3"
7878
val scalaCompat = "org.scala-lang.modules" %% "scala-collection-compat" % "2.7.0"
7979

80+
lazy val circeCore211 = "io.circe" %% "circe-core" % "0.10.0"
81+
lazy val circeGeneric211 = "io.circe" %% "circe-generic" % "0.10.0"
82+
lazy val circeParser211 = "io.circe" %% "circe-parser" % "0.10.0"
83+
84+
lazy val circeCore = "io.circe" %% "circe-core" % "0.13.0"
85+
lazy val circeGeneric = "io.circe" %% "circe-generic" % "0.13.0"
86+
lazy val circeParser = "io.circe" %% "circe-parser" % "0.13.0"
87+
88+
def circeDeps(scalaVersion: String) = if (scalaVersion == scala211)
89+
Seq(circeCore211, circeGeneric211, circeParser211)
90+
else
91+
Seq(circeCore, circeGeneric, circeParser)
92+
93+
8094
val testingDependencies = Seq(
8195
"org.scalatest" %% "scalatest" % "3.2.14" % Test,
8296
"org.scalactic" %% "scalactic" % "3.2.14" % Test,
@@ -101,19 +115,7 @@ libraryDependencies ++= Seq(
101115
scorexUtil,
102116
"org.bouncycastle" % "bcprov-jdk15on" % "1.+",
103117
fastparse, debox, spireMacros, scalaCompat
104-
) ++ testingDependencies ++
105-
(if (scalaVersion.value == scala211)
106-
Seq(circeCore211, circeGeneric211, circeParser211)
107-
else
108-
Seq(circeCore, circeGeneric, circeParser))
109-
110-
lazy val circeCore211 = "io.circe" %% "circe-core" % "0.10.0"
111-
lazy val circeGeneric211 = "io.circe" %% "circe-generic" % "0.10.0"
112-
lazy val circeParser211 = "io.circe" %% "circe-parser" % "0.10.0"
113-
114-
lazy val circeCore = "io.circe" %% "circe-core" % "0.13.0"
115-
lazy val circeGeneric = "io.circe" %% "circe-generic" % "0.13.0"
116-
lazy val circeParser = "io.circe" %% "circe-parser" % "0.13.0"
118+
) ++ testingDependencies ++ circeDeps(scalaVersion.value)
117119

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

@@ -152,76 +154,43 @@ lazy val common = Project("common", file("common"))
152154
))
153155
.settings(publish / skip := true)
154156

155-
lazy val libraryapi = Project("library-api", file("library-api"))
157+
lazy val corelib = Project("core-lib", file("core-lib"))
156158
.dependsOn(common % allConfigDependency)
157-
.settings(libraryDefSettings,
158-
libraryDependencies ++= Seq())
159-
.settings(publish / skip := true)
160-
161-
lazy val libraryimpl = Project("library-impl", file("library-impl"))
162-
.dependsOn(libraryapi % allConfigDependency)
163159
.settings(libraryDefSettings,
164-
libraryDependencies ++= Seq( debox ))
160+
libraryDependencies ++= Seq( debox, scrypto ))
165161
.settings(publish / skip := true)
166162

167-
lazy val core = Project("core", file("core"))
168-
.dependsOn(common % allConfigDependency, libraryapi % allConfigDependency)
169-
.settings(libraryDefSettings,
170-
libraryDependencies ++= Seq( debox ))
171-
.settings(publish / skip := true)
172-
173-
lazy val library = Project("library", file("library"))
174-
.dependsOn(common % allConfigDependency, core % allConfigDependency, libraryapi, libraryimpl)
163+
lazy val graphir = Project("graph-ir", file("graph-ir"))
164+
.dependsOn(common % allConfigDependency, corelib)
175165
.settings(
176166
libraryDefSettings,
177-
libraryDependencies ++= Seq( debox ))
167+
libraryDependencies ++= Seq( debox, scrypto, bouncycastleBcprov ))
178168
.settings(publish / skip := true)
179169

180-
lazy val sigmaapi = Project("sigma-api", file("sigma-api"))
181-
.dependsOn(common, libraryapi)
182-
.settings(libraryDefSettings,
183-
libraryDependencies ++= Seq(
184-
scrypto, bouncycastleBcprov
185-
))
186-
.settings(publish / skip := true)
187-
188-
lazy val sigmalibrary = Project("sigma-library", file("sigma-library"))
189-
.dependsOn(
190-
common % allConfigDependency,
191-
core % allConfigDependency,
192-
libraryapi % allConfigDependency,
193-
libraryimpl % allConfigDependency,
194-
library % allConfigDependency,
195-
sigmaapi % allConfigDependency)
196-
.settings(libraryDefSettings,
197-
libraryDependencies ++= Seq(
198-
scrypto,
199-
bouncycastleBcprov
200-
))
170+
lazy val interpreter = (project in file("interpreter"))
171+
.dependsOn(graphir % allConfigDependency)
172+
.settings(libraryDefSettings)
173+
.settings(libraryDependencies ++=
174+
Seq(scorexUtil, fastparse) ++ circeDeps(scalaVersion.value)
175+
)
201176
.settings(publish / skip := true)
202177

203-
lazy val sigmastate = (project in file("sigmastate"))
204-
.dependsOn(sigmalibrary % allConfigDependency)
178+
lazy val sc = (project in file("sc"))
179+
.dependsOn(graphir % allConfigDependency, interpreter % allConfigDependency)
205180
.settings(libraryDefSettings)
206-
.settings(libraryDependencies ++= Seq(
207-
scorexUtil, fastparse,
208-
if (scalaVersion.value == scala211) circeCore211 else circeCore,
209-
if (scalaVersion.value == scala211) circeGeneric211 else circeGeneric,
210-
if (scalaVersion.value == scala211) circeParser211 else circeParser
211-
))
181+
.settings(libraryDependencies ++=
182+
Seq(scorexUtil, fastparse) ++ circeDeps(scalaVersion.value)
183+
)
212184
.settings(publish / skip := true)
213185

214186
lazy val sigma = (project in file("."))
215-
.aggregate(
216-
sigmastate, common, core, libraryapi, libraryimpl, library,
217-
sigmaapi, sigmalibrary)
187+
.aggregate(common, corelib, graphir, interpreter, sc)
218188
.settings(libraryDefSettings, rootSettings)
219189
.settings(publish / aggregate := false)
220190
.settings(publishLocal / aggregate := false)
221191

222192
lazy val aggregateCompile = ScopeFilter(
223-
inProjects(common, core, libraryapi, libraryimpl, library, sigmaapi,
224-
sigmalibrary, sigmastate),
193+
inProjects(common, corelib, graphir, interpreter, sc),
225194
inConfigurations(Compile))
226195

227196
lazy val rootSettings = Seq(

common/src/main/scala/scalan/Typeclass.scala

Lines changed: 0 additions & 3 deletions
This file was deleted.

common/src/main/scala/scalan/package.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11

2-
import scala.language.experimental.macros
32
import scala.reflect.ClassTag
43

54
package object scalan {
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
package scalan.reflection
2+
3+
import scala.collection.compat.immutable.ArraySeq
4+
import scala.collection.mutable
5+
import scala.collection.immutable
6+
7+
/** Reflection metadata and global dictionaries to access it.
8+
* For each class of this module that needs reflection metadata,
9+
* we register a class entry with the necessary information.
10+
* Only information that is needed at runtime is registered.
11+
*/
12+
object CommonReflection {
13+
/** Descriptors of classes. */
14+
val classes = mutable.HashMap.empty[Class[_], SRClass[_]]
15+
16+
/** Registers a class entry in the map of classes.
17+
*
18+
* @tparam T the type of the class to be registered
19+
* @param clazz the class to be registered
20+
* @param constructors the constructors of the class
21+
* @param fields the fields of the class
22+
* @param methods the methods of the class (represented as a map of method names and argument types to the corresponding RMethod instances)
23+
*/
24+
def registerClassEntry[T](clazz: Class[T],
25+
constructors: Seq[SRConstructor[_]] = ArraySeq.empty,
26+
fields: Map[String, SRField] = Map.empty,
27+
methods: Map[(String, Seq[Class[_]]), RMethod] = Map.empty): Unit = classes.synchronized {
28+
classes.put(clazz, new SRClass(clazz, constructors, fields, methods))
29+
}
30+
31+
registerClassEntry(classOf[Boolean])
32+
33+
registerClassEntry(classOf[Byte])
34+
35+
registerClassEntry(classOf[Short])
36+
37+
registerClassEntry(classOf[Int])
38+
39+
registerClassEntry(classOf[Long])
40+
41+
registerClassEntry(classOf[Product2[_, _]])
42+
43+
registerClassEntry(classOf[immutable.$colon$colon[_]],
44+
constructors = Array(
45+
mkConstructor(Array(classOf[java.lang.Object], classOf[immutable.List[_]])) { args =>
46+
new immutable.$colon$colon(args(0).asInstanceOf[java.lang.Object], args(1).asInstanceOf[immutable.List[_]])
47+
}
48+
)
49+
)
50+
51+
{ val clazz = classOf[scala.Option[_]]
52+
registerClassEntry(clazz,
53+
methods = Map(
54+
mkMethod(clazz, "filter", Array(classOf[scala.Function1[_,_]])) { (obj, args) =>
55+
obj.asInstanceOf[Option[Any]].filter(args(0).asInstanceOf[Any => Boolean])
56+
},
57+
mkMethod(clazz, "map", Array(classOf[scala.Function1[_,_]])) { (obj, args) =>
58+
obj.asInstanceOf[Option[Any]].map(args(0).asInstanceOf[Any => Any])
59+
}
60+
)
61+
)
62+
}
63+
64+
{ val clazz = classOf[scala.Some[_]]
65+
registerClassEntry(clazz,
66+
constructors = Array(
67+
mkConstructor(Array(classOf[java.lang.Object])) { args =>
68+
new scala.Some(args(0).asInstanceOf[java.lang.Object])
69+
}
70+
)
71+
)
72+
}
73+
74+
}

0 commit comments

Comments
 (0)