LoweringContext

scalus.compiler.sir.lowering.LoweringContext
class LoweringContext(var zCombinatorNeeded: Boolean = ..., val decls: Map[String, DataDecl] = ..., var varIdSeq: Int = ..., var scope: LocalScope = ..., val targetLanguage: Language = ..., val targetProtocolVersion: MajorProtocolVersion = ..., val generateErrorTraces: Boolean = ..., val uplcGeneratorPolicy: (SIRType, LoweringContext) => SirTypeUplcGenerator = ..., var typeUnifyEnv: Env = ..., var debug: Boolean = ..., var debugLevel: Int = ..., var nestingLevel: Int = ..., var enclosingLambdaParams: List[IdentifiableLoweredValue] = ..., val intrinsicModules: Map[String, Module] = ..., val supportModules: Map[String, Module] = ...)

Attributes

Graph
Supertypes
class Object
trait Matchable
class Any

Members list

Value members

Concrete methods

def findProviderBinding(providerModuleName: String, methodName: String): Option[Binding]

Find a binding in a provider module by module name and method name.

Find a binding in a provider module by module name and method name.

Attributes

def info(msg: String, pos: SIRPosition): Unit
def initSupportBindings(): Unit

Add all support module bindings to the base scope.

Add all support module bindings to the base scope.

Called during context initialization (like ScalusRuntime.initContext). Bindings are added to the initial scope so they survive all scope save/restore in lowerLet. They are only included in UPLC output if actually referenced (via termWithNeededVars).

Uses two passes because support bindings may be recursive (e.g., lengthSumDataList calls itself via ExternalVar). Pass 1 adds placeholders so recursive references resolve during lowering. Pass 2 lowers each binding, using monitoredExternalVars to detect self-references and wrap with LetRec only when needed.

Attributes

def log(msg: String): Unit
def lower(sir: SIR, optTargetType: Option[SIRType] = ...): LoweredValue

If this is typevariable, try get the value from context, else leave it as is.

If this is typevariable, try get the value from context, else leave it as is.

Attributes

def tryResolveTypeVar(tp: TypeVar): Option[SIRType]
def uniqueVarName(prefix: String = ...): String
def warn(msg: String, pos: SIRPosition): Unit

Concrete fields

var debug: Boolean
var debugLevel: Int
val decls: Map[String, DataDecl]
val generateErrorTraces: Boolean
val intrinsicModules: Map[String, Module]
var monitoredExternalVars: Option[Set[String]]

When set, ExternalVar resolution records resolved names here. Used by initSupportBindings to detect recursive bindings.

When set, ExternalVar resolution records resolved names here. Used by initSupportBindings to detect recursive bindings.

Attributes

var nestingLevel: Int
val precomputedValues: IdentityHashMap[SIR, LoweredValue]

Cache of pre-lowered SIR nodes, keyed by reference identity.

Cache of pre-lowered SIR nodes, keyed by reference identity.

Used during intrinsic resolution: the resolver adds an entry before lowering the substituted provider body, and removes it after. This way lowerSIR finds the cached value for the substituted argument without recomputing it.

Attributes

val supportModules: Map[String, Module]
var varIdSeq: Int
var zCombinatorNeeded: Boolean