SumUplcConstrOps

scalus.compiler.sir.lowering.typegens.SumUplcConstrOps

Type generator for sum types using UplcConstr representation.

Handles construction, pattern matching, field selection, and representation conversions for types stored as native UPLC Constr(tag, [fields]).

Used for:

  • Types with function/BLS fields (canBeConvertedToData = false)
  • Data-compatible types annotated with @UplcRepr("UplcConstr") (canBeConvertedToData = true)

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any
Self type

Members list

Value members

Concrete methods

Build SumUplcConstr with variant info from the type's DataDecl.

Build SumUplcConstr with variant info from the type's DataDecl.

pos is used in error messages so we can locate the SIR site that triggered the build (otherwise these errors only carry the JVM stack, no SIR file/line context).

Attributes

Handle all UplcConstr-related representation conversions (Phase 5).

Handle all UplcConstr-related representation conversions (Phase 5).

Attributes

def genMatchUplcConstr(matchData: Match, loweredScrutinee: LoweredValue, optTargetType: Option[SIRType])(using lctx: LoweringContext): LoweredValue
def genMatchUplcConstrAllVariants(scrutinee: LoweredValue, scrutineeRepr: SumUplcConstr, sumType: SIRType, outType: SIRType, outRepr: LoweredValueRepresentation, pos: SIRPosition, perVariant: (Int, Seq[IdentifiableLoweredValue]) => LoweringContext ?=> LoweredValue)(using lctx: LoweringContext): LoweredValue

Generic N-variant Case dispatch on a SumUplcConstr scrutinee.

Generic N-variant Case dispatch on a SumUplcConstr scrutinee.

Builds Term.Case(scrutinee, [branch_0, branch_1, ...]) where each branch is a nested lambda binding the variant's fields and evaluating the per-variant body. Variant order matches the DataDecl constructor order (tag = position).

The perVariant callback receives (constrIdx, fieldVars). Each fieldVar is an IdentifiableLoweredValue with the variant's field type substituted with the sum's concrete type args, and the field repr from scrutineeRepr.variants(constrIdx).

All per-variant bodies must produce values of outType with outRepr representation — the caller is responsible for any normalization.

Attributes

Direct Case-based match on a UplcConstr list — used by ScalusRuntime conversions.

Direct Case-based match on a UplcConstr list — used by ScalusRuntime conversions.

Generates: Case(scrutinee, [nilBranch, λh.λt.consBranch(h, t)]) List enum: Nil=tag 0, Cons(head, tail)=tag 1.

Attributes

def genSelectUplcConstr(sel: Select, loweredScrutinee: LoweredValue)(using LoweringContext): LoweredValue

Select a field from a UplcConstr-represented value.

Select a field from a UplcConstr-represented value.

Attributes