scalus.compiler.sir.lowering.simple
Members list
Type members
Classlikes
Base class for simple lowering from Scalus Intermediate Representation SIR to UPLC scalus.uplc.Term.
Base class for simple lowering from Scalus Intermediate Representation SIR to UPLC scalus.uplc.Term.
This class contains common functionality shared between different lowering strategies. Subclasses must implement the encoding-specific methods for constructors, pattern matching, and field selection.
Value parameters
- generateErrorTraces
-
whether to generate error traces
- sir
-
the Scalus Intermediate Representation to lower
- targetLanguage
-
the target Plutus language version
Attributes
- Supertypes
- Known subtypes
-
class ScottEncodingLoweringclass SumOfProductsLowering
Trait providing Data type lowering support for simple lowering backends.
Trait providing Data type lowering support for simple lowering backends.
Data is a builtin Plutus type with 5 constructors:
- Constr(tag: Integer, args: List[Data])
- Map(entries: List[(Data, Data)])
- List(elements: List[Data])
- I(value: Integer)
- B(value: ByteString)
This trait provides methods for:
- Lowering Data constructors to UPLC builtins (iData, bData, listData, mapData, constrData)
- Lowering pattern matches on Data (chooseData for V3, Case on Data for V4)
- Lowering field selections on Data variants (unIData, unBData, etc.)
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Known subtypes
- Self type
Let-floating transformation that moves lazy let bindings closer to their usage points.
Let-floating transformation that moves lazy let bindings closer to their usage points.
This transformation implements "floating inward" as described in: Simon Peyton Jones, Will Partain, and André Santos. 1996. Let-floating: moving bindings to give faster programs.
The algorithm works in three phases:
- Enrichment pass (down-traversal): Build enriched SIR with node indices, track variable usage, lambda context, and dependencies
- Analysis pass: Find dominating nodes for each lazy let binding using tracked usage information and transitive dependency propagation
- Output generation pass (down-traversal): Reconstruct SIR, moving lazy lets to their computed dominating nodes
Lambda barrier: Non-effortless bindings (computations) are prevented from crossing lambda boundaries to avoid duplicating work when the lambda is called multiple times. Effortless bindings (constants, variables, lambdas) can cross freely.
TODO: optimization can introduce expressions like App((lambda x, x),y) which can be eliminated. Maybe add a beta-reduction pass after let-floating, or just handle it here.
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
LetFloating.type
Scott encoding-based lowering from Scalus Intermediate Representation SIR to UPLC scalus.uplc.Term.
Scott encoding-based lowering from Scalus Intermediate Representation SIR to UPLC scalus.uplc.Term.
This implementation uses Scott encoding for data types:
Nilis represented as\Nil Cons -> force NilCons h tlis represented as(\head tail Nil Cons -> Cons head tail) h tl
Value parameters
- generateErrorTraces
-
whether to generate error traces
- sir
-
the Scalus Intermediate Representation to lower
- targetLanguage
-
the target Plutus language version
Attributes
- Supertypes
UPLC 1.1.0-based lowering from Scalus Intermediate Representation SIR to UPLC scalus.uplc.Term.
UPLC 1.1.0-based lowering from Scalus Intermediate Representation SIR to UPLC scalus.uplc.Term.
We use UPLC version 1.1.0 and generate Sums of Products (SoP) constructors case and constr to represent data types. Also we optimize newtype kind of constructors to be represented as just values.
Value parameters
- generateErrorTraces
-
whether to generate error traces
- sir
-
the Scalus Intermediate Representation to lower
- targetLanguage
-
the target Plutus language version
Attributes
- Example
-
case class Wrapper(a: BigInt) val x = Wrapper(1) // lowers to just (const integer 1) - Supertypes
Deprecated types
Attributes
- Deprecated
-
[Since version 0.13.0]Use ScottEncodingLowering instead
Attributes
- Deprecated
-
[Since version 0.13.0]Use SumOfProductsLowering instead