ScottEncodingLowering
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
- Graph
-
- Supertypes
Members list
Value members
Inherited methods
Check if a constructor name is a Data type constructor.
Check if a SIR type is the builtin Data type.
Check if a scrutinee type is a known Data variant (I, B, List, Map, Constr).
Check if a scrutinee type is a known Data variant (I, B, List, Map, Constr).
Attributes
- Inherited from:
- DataLowering
Lower the SIR to UPLC Term
Lower a single case branch for Data pattern matching.
Lower a single case branch for Data pattern matching.
For chooseData, branches are thunks that reference a pre-bound scrutinee. We extract values from the scrutinee within each branch.
Attributes
- Inherited from:
- DataLowering
Lower a Data constructor expression to UPLC.
Lower a Data constructor expression to UPLC.
Data constructors are lowered to their corresponding builtin functions:
- Data.I(value) → iData(value)
- Data.B(value) → bData(value)
- Data.List(values) → listData(values)
- Data.Map(values) → mapData(values)
- Data.Constr(tag, args) → constrData(tag, args)
Attributes
- Inherited from:
- DataLowering
Lower a match expression on Data type.
Lower a match expression on Data type.
Data has 5 constructors in a fixed order:
- 0: Constr (tag: Integer, args: List[Data])
- 1: Map (entries: List[(Data, Data)])
- 2: List (elements: List[Data])
- 3: I (value: Integer)
- 4: B (value: ByteString)
The variants are dispatched via the chooseData builtin on every protocol version. The Case instruction is no alternative: it rejects a Data scrutinee before dijkstraPV, and from dijkstraPV on it only scrutinizes Data.Constr, selecting the branch by the constructor tag.
- chooseData just selects a delayed branch, it doesn't pass arguments
- We bind the scrutinee first, then extract values within each branch
Attributes
- Inherited from:
- DataLowering
Lower a field selection on Data type.
Lower a field selection on Data type.
Data field selections are lowered to their corresponding builtin unpack functions:
- Data.I.value → unIData(scrutinee)
- Data.B.value → unBData(scrutinee)
- Data.List.values → unListData(scrutinee)
- Data.Map.values → unMapData(scrutinee)
- Data.Constr.constr → fstPair(unConstrData(scrutinee))
- Data.Constr.args → sndPair(unConstrData(scrutinee))
Attributes
- Inherited from:
- DataLowering