scalus.compiler.sir
Members list
Packages
Type members
Classlikes
Transforms error messages in SIR to abbreviated forms and collects a mapping of abbreviations to original messages.
Transforms error messages in SIR to abbreviated forms and collects a mapping of abbreviations to original messages.
This transformation helps reduce the size of error messages in the IR while maintaining traceability through a mapping of abbreviated forms to their original messages.
Attributes
- Example
-
// Input SIR containing: Error("Failed validation"), Error("Failed execution") // Transforms to: Error("FV"), Error("FE") // With mapping: Map("FV" -> "Failed validation", "FE" -> "Failed execution") val transformer = new AbbreviateErrorTraces val result = transformer.transformSIR(input) val abbrevMap = transformer.getAbbreviationMap - Supertypes
-
class Objecttrait Matchableclass Any
Attributes
- Companion
- object
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Attributes
- Companion
- class
- Supertypes
-
trait Singletontrait Producttrait Mirrortrait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
- Self type
-
AnnotationsDecl.type
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
EnrichedSIR[P,T] mirrors the structure of SIR trait but allows parameterization with pattern type P and info type T.
EnrichedSIR[P,T] mirrors the structure of SIR trait but allows parameterization with pattern type P and info type T.
For each SIR case class Xxx, there is a sealed trait Xxx[P,T] with two cases:
- XxxPattern[P,T](pattern: P, info: T) representing a pattern node
- XxxInfo[P,T] with the same parameters as origin SIR, but using appropriate traits from EnrichedSIR[P,T] and with additional info: T
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
EnrichedSIR.type
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Attributes
- Supertypes
- Self type
-
ModuleToExpr.type
Eliminates multi-binding recursive Let groups by rewriting each group into nested single-binding lets (peers-as-params), so the lowering backends only ever see single self-recursion, which they encode via self-application.
Eliminates multi-binding recursive Let groups by rewriting each group into nested single-binding lets (peers-as-params), so the lowering backends only ever see single self-recursion, which they encode via self-application.
For a group f1..fN (binding order) it emits, outermost first:
let fNp = λf1...f(N-1). rhsN' // fresh name fN$mutrec
...
let f2p = λf1. rhs2'
let f1 = rhs1'
in body'
where inside rhs_i' (context i; context 1 also covers rhs1' and the body), a reference to fj is rewritten to argExpr(j, i):
j < i: stays the (param) variablefj;j == i: the self-application chainfip f1 .. f(i-1)(or plainf1wheni == 1);j == i + 1: the adjacent chainf(i+1)p f1 .. fi, where thefiargument is thej == iself chain above - still built from plain variables only;j >= i + 2: a bounded reference tofjunder its original name, backed by a non-recursivelet fj = λ$eta. (fjp E(1) .. E(j-1)) $eta in ...emitted once per context around the rewritten rhs/body. The eta-wrapper defers the (potentially expensive) construction offjp's argument chain untilfjis actually called, which is required for correctness (a plain, non-eta-expandedlet fj = fjp E(1)..E(j-1)would force that application immediately, re-entering the still-being-defined peers and diverging), and lets everyE(k)fori + 2 = i + 2references recursively re-expand their own1 .. j-1argument lists (each of which may again contain far references), which is exponential in the reference distancej - i. With the eta-lets, each context does O(distance) work and the whole group is O(N^2).
Each member's rhs must be a lambda; a cyclic group of plain values is rejected. See docs/superpowers/specs/2026-08-04-mutual-recursion-design.md.
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
Pretty printers.
Pretty printers.
- Use
prettyto pretty print to a org.typelevel.paiges.Doc. - Use
prettyXTermto pretty print to a org.typelevel.paiges.Doc with syntax highlighting for XTerm.
For example:
PrettyPrinter.prettyXTerm(sir).render(80)
// renders a single line if possible
PrettyPrinter.pretty(sir).flatten.render(120)
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
PrettyPrinter.type
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
RemoveRecursivity.type
Removes fully-applied Trace builtin calls from SIR, replacing them with their value argument.
Removes fully-applied Trace builtin calls from SIR, replacing them with their value argument.
This is used for release builds to strip log() calls and their message computations (string concatenation, show calls, etc.) from the script, reducing size and execution cost.
The transformation also cleans up dead let bindings that become trivial () after trace removal (the common pattern from log("msg") → let _ = trace(msg)(()) in body → let _ = () in body → body).
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
RemoveTraces.type
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
RenamingTypeVars.type
Attributes
- Companion
- object
- Supertypes
-
class Objecttrait Matchableclass Any
- Known subtypes
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalstrait StaticAnnotationclass Annotationclass Objecttrait Matchableclass AnyShow all
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
SIRBuiltins.type
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
SIRChecker.type
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Known subtypes
-
class SIRModuleWithDeps
Default compiler options for SIR processing. Here to have a single place for default options, which is shared between the compiler plugin and the core library.
Default compiler options for SIR processing. Here to have a single place for default options, which is shared between the compiler plugin and the core library.
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
SIRDefaultOptions.type
Attributes
- Companion
- trait
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
SIRHashCodeInRec.type
Attributes
- Companion
- object
- Supertypes
-
class Objecttrait Matchableclass Any
- Known subtypes
-
object given_SIRHashCodeInRec_FunShow all
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
SIRMacro.type
Attributes
- Companion
- class
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
SIRModuleWithDeps.type
Attributes
- Companion
- object
- Supertypes
Attributes
- Companion
- trait
- Supertypes
-
trait Sumtrait Mirrorclass Objecttrait Matchableclass Any
- Self type
-
SIRPattern.type
Attributes
- Companion
- object
- Supertypes
-
class Objecttrait Matchableclass Any
- Known subtypes
-
class Annotatedclass CaseClassobject FreeUnificatorclass Funtrait Primitiveobject BLS12_381_G1_Elementobject BLS12_381_G2_Elementobject BLS12_381_MlResultobject Booleanobject BuiltinValueobject ByteStringobject Integerobject Stringobject Unitclass SumCaseClassclass TypeLambdaclass TypeNonCaseModuleobject TypeNothingclass TypeProxyclass TypeVarShow all
Attributes
- Supertypes
- Self type
-
SIRTypeToExpr.type
Attributes
- Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
SIRUnify.type
Attributes
- Companion
- trait
- Supertypes
-
trait Sumtrait Mirrorclass Objecttrait Matchableclass Any
- Self type
-
SIRVarStorage.type
Attributes
- Companion
- object
- Supertypes
-
class Objecttrait Matchableclass Any
- Known subtypes
Attributes
- Supertypes
-
trait Enumtrait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Attributes
- Supertypes
-
trait ToExpr[T]class Objecttrait Matchableclass Any
- Known subtypes
Called from SIRConverter via reflection.
Note, that this hashconsedflat should not be resolved as given. It is used only as parameter to ToExprHS. Given HashConsedFlat[(something other then Module)] is a no-no.
Note, that this hashconsedflat should not be resolved as given. It is used only as parameter to ToExprHS. Given HashConsedFlat[(something other then Module)] is a no-no.
Attributes
- Supertypes
- Self type
-
ToExprHSSIRTypeFlat.type
Attributes
- Supertypes
-
trait Serializabletrait Producttrait Equalsclass Objecttrait Matchableclass AnyShow all
Deprecated classlikes
Moved to scalus.compiler.sir.transform.BooleanOptimizer, alongside the other SIR-to-SIR passes. This alias forwards to the new location so existing callers keep compiling and linking.
Moved to scalus.compiler.sir.transform.BooleanOptimizer, alongside the other SIR-to-SIR passes. This alias forwards to the new location so existing callers keep compiling and linking.
Note that the pass itself changed when it moved: several rules that could drop an operand the original expression evaluates - and so delete an Error or a trace - were removed. See docs/internal/BOOLEAN_OPTIMIZER_FINDINGS.md.
Attributes
- Deprecated
-
[Since version 1.1.1]use scalus.compiler.sir.transform.BooleanOptimizer instead - Supertypes
-
class Objecttrait Matchableclass Any
- Self type
-
BooleanOptimizer.type
Moved to scalus.compiler.sir.transform.StaticArgumentTransformation, alongside the other SIR-to-SIR passes. This alias forwards to the new location so existing callers keep compiling and linking.
Moved to scalus.compiler.sir.transform.StaticArgumentTransformation, alongside the other SIR-to-SIR passes. This alias forwards to the new location so existing callers keep compiling and linking.
Attributes
- Deprecated
-
[Since version 1.1.1]use scalus.compiler.sir.transform.StaticArgumentTransformation instead - Supertypes
-
class Objecttrait Matchableclass Any
- Self type
Types
SIR Position - position in Scala source code. Now a type alias for ScalusSourcePos.
SIR Position - position in Scala source code. Now a type alias for ScalusSourcePos.