Skip to content

Commit

Permalink
refactoring: cleanup and updates in docs directory
Browse files Browse the repository at this point in the history
  • Loading branch information
aslesarenko committed Aug 9, 2023
1 parent cf8e3a3 commit 39e793b
Show file tree
Hide file tree
Showing 8 changed files with 67 additions and 573 deletions.
446 changes: 0 additions & 446 deletions docs/Costing.md

This file was deleted.

56 changes: 56 additions & 0 deletions docs/ergoscript-compiler.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@

# ErgoScript Compiler

Sigma frontend implements the following pipeline:

`SourceCode` --> `parse` --> `bind` -> `typecheck` -> `buildGraph` -> `buildTree` -> `ErgoTree`

Here:
- `SourceCode` - a string of unicode characters
- `parse` - method `SigmaCompiler.parse`
- `bind` - method `SigmaBinder.bind`
- `typecheck` - method `SigmaTyper.typecheck`
- `buildGraph` - method `IRContext.buildGraph`
- `buildTree` - method `IRContext.buildTree`
- `ErgoTree` - an intermediate representation which can be processed by Sigma [Interpreter](https://github.com/ScorexFoundation/sigmastate-interpreter/blob/master/interpreter/shared/src/main/scala/sigmastate/interpreter/Interpreter.scala#L46)

## Parser
`parse` takes a string and produces abstract syntax tree, AST, of a Sigma expression represented by `Value` type in Scala.

In case of any errors it throws `ParserException`

## Binder
`SigmaBinder` takes an AST of successfully parsed Sigma expression and resolves
global variables and predefined functions that are looked up in the provided environment.
Binder transforms environment values of predefined Scala types (such as Int, Boolean, Box, etc.)
into constant nodes (IntConstant, BoxConstant, etc) of the corresponding type. (See also `Constant` class)

In case of any error it throws `BinderException`

## Typer
`SigmaTyper` takes an AST from the output of `SigmaBinder` and assigns types
to all tree nodes. Since AST is immutable data structure the typer produces a new tree.

Type assignment is performed by `assignType` tree transformation which assign correct types for all
tree nodes.

In case of any error it throws `TyperException`

## Graph Building

`IRContext.buildGraph` takes an AST from the output of `SigmaTyper` and builds a graph where nodes are operations and edges are dependencies between operations.
During graph building the following optimizations are performed:
- constant propagation
- common subexpression elimination
- dead code elimination

## Tree Building

`IRContext.buildTree` takes a graph from the output of `IRContext.buildGraph` and builds the resulting ErgoTree.

## IR contexts

- `IRContext` - the main interface of graph IR which mixes in both GraphBuilding and TreeBuilding traits.
Since v5.0 it is not used by Interpreter and thus not part of consensus.

- `CompiletimeIRContext` - the main implementation of IRContext
14 changes: 7 additions & 7 deletions docs/notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,13 @@

These dependencies can be removed with refactoring

| Jar | Size, Kb |
|---------------|---------------|
| - jline-2.14.3.jar | 268 |
| cats-core_2.12-1.4.0.jar | 4400 |
| - cats-kernel_2.12-1.4.0.jar | 3200 |
| - algebra_2.12-0.7.0.jar | 1100 |
| - spire-macros_2.12-0.14.1.jar | 73 |
| Jar | Size, Kb |
|--------------------------------|----------|
| - jline-3.10.0.jar | 715 |
| cats-core_2.12-2.1.0.jar | 4900 |
| - cats-kernel_2.12-1.4.0.jar | 3500 |
| - algebra_2.12-2.0.0-M2.jar | 1400 |
| - spire-macros_2.12-0.14.1.jar | 79 |



Expand Down
21 changes: 0 additions & 21 deletions docs/releasenotes.md

This file was deleted.

8 changes: 3 additions & 5 deletions docs/sigma-dsl.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,8 @@
code directly in Scala IDE (e.g. IntelliJ IDEA) and copy-paste code snippets
between SigmaDsl and SigmaScript.
Special Scala macros can also be used to automatically translate SigmaDsl to
Sigma byte code.

SigmaDsl is implemented as Scala library using [Special](https://github.com/scalan/special)
framework.
Sigma byte code. Some prototype has been implemented [here](https://github.com/ergoplatform/ergo-scala-compiler)

## See also
[Special](https://github.com/scalan/special)

[ergo-scala-compiler](https://github.com/ergoplatform/ergo-scala-compiler)
55 changes: 0 additions & 55 deletions docs/sigma-front-end.md

This file was deleted.

38 changes: 0 additions & 38 deletions docs/soft-fork-log.md

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ case class EvalSettings(
/** Maximum execution cost of a script used by profiler.
* @see ErgoTreeEvaluator
*/
scriptCostLimitInEvaluator: Int = 1000000,
scriptCostLimitInEvaluator: Int = 1000000
)

object EvalSettings {
Expand Down

0 comments on commit 39e793b

Please sign in to comment.