-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'origin/master' into v5.0.9-RC
# Conflicts: # build.sbt # common/shared/src/main/scala/scalan/util/ReflectionUtil.scala # graph-ir/src/main/scala/scalan/TypeDescs.scala
- Loading branch information
Showing
171 changed files
with
3,373 additions
and
1,456 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,78 @@ | ||
# Contributing | ||
|
||
## Building | ||
|
||
Clone the repository. | ||
|
||
```shell | ||
$ git clone git@github.com:ScorexFoundation/sigmastate-interpreter.git | ||
$ cd sigmastate-interpreter | ||
$ sbt test | ||
``` | ||
|
||
Then you can compile the library with SBT and run tests. | ||
|
||
```shell | ||
$ sbt | ||
sbt:sigma-state> compile | ||
sbt:sigma-state> test | ||
``` | ||
|
||
By default SBT uses Scala 2.12 for compilation and running tests. To compile for Scala 2.13 use the following commands: | ||
|
||
```shell | ||
$ sbt | ||
sbt:sigma-state> ++2.13.8 | ||
sbt:sigma-state> compile | ||
sbt:sigma-state> test | ||
``` | ||
|
||
You can also run SBT commands for all Scala versions at once: | ||
|
||
```shell | ||
$ sbt | ||
sbt:sigma-state> +compile | ||
sbt:sigma-state> +test | ||
``` | ||
|
||
To run specific test suite use the following command: | ||
|
||
```shell | ||
sbt:sigma-state> testOnly <full test class name> | ||
``` | ||
|
||
## Releasing | ||
|
||
### Setup GPG key | ||
|
||
Follow [instructions](https://central.sonatype.org/publish/requirements/gpg/) to set up GPG key. | ||
You will need: | ||
- create a GPG key pair; | ||
- publish your public key to a public key server; | ||
|
||
### Check Sonatype credentials | ||
Try to login to Nexus Repository Manager with your credentials [here](https://oss.sonatype.org/#welcome) | ||
|
||
### Using Sonatype with SBT | ||
|
||
Follow [instructions](https://www.scala-sbt.org/release/docs/Using-Sonatype.html) to set up Sonatype with SBT. | ||
You will also need: | ||
- [how to publish a release](https://docs.scala-lang.org/overviews/contributors/index.html#publish-a-release) | ||
- [sbt-sonatype plugin](https://github.com/xerial/sbt-sonatype) | ||
- [sbt-dynver plugin](https://github.com/sbt/sbt-dynver) | ||
|
||
### Publishing release | ||
This can be done manually or automatically by Github Actions. | ||
|
||
#### Manual publishing | ||
To publish release to Sonatype, use the following: | ||
``` | ||
$sbt | ||
sbt:sigma-state> +publishSigned | ||
sbt:sigma-state> sonatypeBundleRelease | ||
``` | ||
|
||
#### Automatic publishing | ||
To publish release version to Sonatype, do the following: | ||
- make a tag with version number `vX.Y.Z` (used by `sbt-dynver` to set `version` in `build.sbt`); | ||
- make a tag with version number `vX.Y.Z` (used by `sbt-dynver` to set `version` key); | ||
- use the new tag to make a Github release, which triggers [`release.yml`](.github/workflows/release.yml) workflow and publishes release version to Sonatype; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
package scalan.reflection | ||
|
||
import scala.collection.mutable | ||
|
||
/** JS Platform dependent implementation of reflection methods. */ | ||
object Platform { | ||
/** Returns an RClass instance for the given class. | ||
* | ||
* @param clazz The class for which to retrieve an RClass instance. | ||
* @tparam T The type of the class. | ||
* @return An RClass instance for the given class. | ||
* @throws java.lang.RuntimeException if RClass metadata for the given class cannot be | ||
* found. | ||
*/ | ||
def resolveClass[T](clazz: Class[T]): RClass[T] = { | ||
val res = CommonReflection.classes.get(clazz) match { | ||
case Some(c) => | ||
assert(c.clazz == clazz) | ||
c | ||
case _ => | ||
sys.error(s"Cannot find RClass data for $clazz") | ||
// Uncomment the following line to collect missing reflection data and generate Scala code for it | ||
// memoize(classes)(clazz, new JRClass[T](clazz)) | ||
} | ||
res.asInstanceOf[RClass[T]] | ||
} | ||
|
||
/** A cache that stores key-value pairs using HashMap. | ||
* This class is thread-safe using the synchronized access to the underlying HashMap | ||
* instance. | ||
* | ||
* @tparam K the type of keys used in the cache | ||
* @tparam V the type of values stored in the cache | ||
*/ | ||
class Cache[K, V] { | ||
private val map = mutable.HashMap.empty[K, V] | ||
|
||
/** Retrieves the value associated with the given key from the cache or | ||
* computes and stores the value if the key is not present in the cache. | ||
* This method is thread-safe using the synchronized block. | ||
* | ||
* @param key the key to look up or store in the cache | ||
* @param value a by-name parameter that computes the value to be stored if the key is not present | ||
* @return the value associated with the key, either retrieved or computed | ||
*/ | ||
def getOrElseUpdate(key: K, value: => V): V = synchronized { | ||
map.getOrElseUpdate(key, value) | ||
} | ||
} | ||
} |
Oops, something went wrong.