TypedProgram
public struct TypedProgram : Sendable
extension TypedProgram: Program
A data structure representing a typed Hylo program ready to be lowered.
-
A set of conformances represented to answer “does A conform to T in S” efficiently.
Declaration
Swift
public typealias ConformanceSet = [AnyType : ConformanceTable] -
A table from trait to its conformances for a given type.
Declaration
Swift
public typealias ConformanceTable = [TraitType : Set<Conformance>] -
The program annotated by the properties of
self.Declaration
Swift
public private(set) var base: ScopedProgram { get } -
A map from translation unit to its imports.
Declaration
Swift
public internal(set) var imports: [TranslationUnit.ID : Set<ModuleDecl.ID>] { get } -
The overarching type of each declaration.
-
The type of each expression.
-
The type of each pattern.
Declaration
Swift
public internal(set) var patternType: [AnyPatternID : AnyType] { get } -
A map from function and subscript declarations to their implicit captures.
Declaration
Swift
public internal(set) var implicitCaptures: [AnyDeclID : [ImplicitCapture]] { get } -
A map from generic declarations to their environment.
Declaration
Swift
public internal(set) var environment: [AnyDeclID : GenericEnvironment] { get } -
A map from module to its synthesized declarations.
Declaration
Swift
public internal(set) var synthesizedDecls: [ModuleDecl.ID : Set<SynthesizedFunctionDecl>] { get } -
A map from name expression to its referred declaration.
Declaration
Swift
public internal(set) var referredDecl: BindingMap { get } -
A map from call expression to its operands after desugaring and implicit resolution.
Declaration
Swift
public internal(set) var callOperands: [CallID : [ArgumentResolutionResult]] { get } -
A map from sequence expressions to their evaluation order.
Declaration
Swift
public internal(set) var foldedForm: [SequenceExpr.ID : FoldedSequenceExpr] { get } -
A map from functions to their attributes.
Declaration
Swift
public internal(set) var functionAttributes: [FunctionDecl.ID : FunctionAttributes] { get } -
The conformances in the program.
Declaration
Swift
public internal(set) var conformances: ConformanceSet { get } -
Creates an instance annotating
basewith semantic information, reporting diagnostics tologand throwing iff an error was found.Declaration
Swift
public init( annotating base: ScopedProgram, inParallel typeCheckingIsParallel: Bool = false, reportingDiagnosticsTo log: inout DiagnosticSet, tracingInferenceIf shouldTraceInference: (@Sendable (AnyNodeID, TypedProgram) -> Bool)? = nil, loggingRequirementSystemIf shouldLogRequirements: (@Sendable (AnyDeclID, TypedProgram) -> Bool)? = nil ) throwsParameters
typeCheckingIsParallelif
true, the program is partitioned into chucks that are type checked separately. Otherwise, type checking is performed sequentially. Either way, the order in which declarations are being checked is nondeterministic.shouldTraceInferenceA closure accepting a node and its containing program, returning
trueif a trace of type inference should be logged on the console for that node. The closure is not called iftypeCheckingIsParallelistrue. -
A module within a TypedProgram.
Declaration
Swift
public typealias Module = Module_<`Self`> -
loadModule(reportingDiagnosticsTo:tracingInferenceIf: loggingRequirementSystemIf: creatingContentsWith: ) Returns a copy of
selfin which a new module has been loaded, callingmaketo form its contents and reporting diagnostics tolog.Declaration
Swift
public func loadModule( reportingDiagnosticsTo log: inout DiagnosticSet, tracingInferenceIf shouldTraceInference: (@Sendable (AnyNodeID, TypedProgram) -> Bool)? = nil, loggingRequirementSystemIf shouldLogRequirements: (@Sendable (AnyDeclID, TypedProgram) -> Bool)? = nil, creatingContentsWith make: AST.ModuleLoader ) throws -> ModuleParameters
shouldTraceInferenceA closure accepting a node and its containing program, returning
trueif a trace of type inference should be logged on the console for that node. -
The type checking of a collection of source files.
See moreDeclaration
Swift
private final class TypeCheckTask : Operation, @unchecked Sendable -
Creates a partially formed instance with empty property in preparation for type checking.
Declaration
Swift
private init(partiallyFormedFrom base: ScopedProgram) -
Returns the canonical form of
d‘s type. -
Returns the canonical form of
e‘s type. -
Returns the canonical form of
tinscopeOfUse.Declaration
Swift
public func canonical(_ t: AnyType, in scopeOfUse: AnyScopeID) -> AnyType -
Returns the canonical form of
vinscopeOfUse.Declaration
Swift
public func canonical(_ v: CompileTimeValue, in scopeOfUse: AnyScopeID) -> CompileTimeValue -
Returns
argumentswith all types replaced by their canonical form inscopeOfUse.Declaration
Swift
public func canonical( _ arguments: GenericArguments, in scopeOfUse: AnyScopeID ) -> GenericArguments -
Returns true iff t and u are semantically equivalent in scopeOfUse.
Declaration
Swift
public func areEquivalent(_ t: AnyType, _ u: AnyType, in scopeOfUse: AnyScopeID) -> Bool -
Returns
genericwith occurrences of parameters keyingspecializationreplaced by their corresponding value, performing necessary name lookups fromscopeOfUse.This method has no effect if
substitutionsis empty.Declaration
Swift
public func specialize( _ generic: AnyType, for specialization: GenericArguments, in scopeOfUse: AnyScopeID ) -> AnyType -
Returns
argumentsapplyingspecializationon each value inscopeOfUse.Declaration
Swift
public func specialize( _ arguments: GenericArguments, for specialization: GenericArguments, in scopeOfUse: AnyScopeID ) -> GenericArguments -
Returns
trueiff deinitializing an instance oftinscopeOfUseis a no-op.A type is “trivially deinitializable” if deinitializing its instances doesn’t have runtime effects. Built-in types are trivially deinitializable. Types composed only of trivially deinitializable parts are trivially deinitializable unless there exists a non-synthetic conformance to
Deinitializablein scope.Declaration
Swift
public func isTriviallyDeinitializable(_ t: AnyType, in scopeOfUse: AnyScopeID) -> Bool -
Returns
trueifftmodelscoreConceptwithout any user-defined semantics.Declaration
Swift
private func isTrivialModel( _ t: AnyType, of coreConcept: TraitType, in scopeOfUse: AnyScopeID ) -> Bool -
Returns
trueiffchas no user-defined semantics.Declaration
Swift
public func isTrivial(_ c: Conformance) -> Bool -
If
thas a record layout, returns the names and types of its stored properties. -
Returns the names and types of
t‘s stored properties. -
Returns the names and types of
t‘s stored properties.Declaration
Swift
public func storage(of t: BoundGenericType) -> [TupleType.Element] -
Returns the names and types of
t‘s stored properties.Declaration
Swift
public func storage(of t: BufferType) -> [TupleType.Element] -
Returns the names and types of
t‘s stored properties.Declaration
Swift
public func storage(of t: ProductType) -> [TupleType.Element] -
Returns generic parameters captured by
sand the scopes semantically containings.Declaration
Swift
public func accumulatedGenericParameters<T: ScopeID>( in s: T ) -> [GenericParameterDecl.ID] -
Returns the trait of which
dis a member, ornilifdisn’t member of a trait. -
If
dis member of a traitc, returns(d, c)ifdis a requirement, or(r, c)ifdis a default implementation of a requirementr; returnsnilotherwise.Declaration
-
Returns
trueiffmodelconforms toconceptinscopeOfUse.Declaration
Swift
public func conforms( _ model: AnyType, to concept: TraitType, in scopeOfUse: AnyScopeID ) -> Bool -
Returns
trueiff all elements inmodelsconform toconceptinscopeOfUse.Declaration
Swift
public func allConform<S: Sequence<AnyType>>( _ models: S, to concept: TraitType, in scopeOfUse: AnyScopeID ) -> Bool -
Returns the conformance of
modeltoconceptthat is exposed toscopeOfUse, ornilif such a conformance doesn’t exist.Declaration
Swift
public func conformance( of model: AnyType, to concept: TraitType, exposedTo scopeOfUse: AnyScopeID ) -> Conformance? -
Returns the explicitly declared conformance of
modeltoconceptthat is exposed toscopeOfUse, ornilif such a conformance doesn’t exist.This method returns
nilif the conformance ofmodeltoconceptis structural (e.g., a tuple’s synthesized conformance toMovable) or if the conformance is implied by a trait bound (e.g.,T: Pinfun f<T: P>() {}).Do not call
concreteConformanceduring type checking.Requires
modelis canonical.Declaration
Swift
private func concreteConformance( of model: AnyType, to concept: TraitType, exposedTo scopeOfUse: AnyScopeID ) -> Conformance? -
Returns the conformance of
modeltoconceptthat is implied by the generic environment introducingmodelinscopeOfUse, ornilif such a conformance doesn’t exist.The result of this method is valid iff a call to
concreteConformance(of:to:exposedTo:)with the same arguments has returnednil.Requires
modelis canonical.Declaration
Swift
private func abstractConformance( of model: AnyType, to concept: TraitType, exposedTo scopeOfUse: AnyScopeID ) -> Conformance? -
Returns the implicit structural conformance of
modeltoconceptthat is exposed toscopeOfUse, ornilif such a conformance doesn’t exist.Declaration
Swift
private func structuralConformance( of model: AnyType, to concept: TraitType, exposedTo scopeOfUse: AnyScopeID ) -> Conformance? -
Returns the type satisfying the associated type requirement
nin conformancec.Requires
nis declared by the trait for whichchas been established.Declaration
Swift
public func associatedType(_ n: AssociatedTypeDecl.ID, for c: Conformance) -> AnyType -
Returns the foreign representation of
tusing its conformance toForeignConvertibleinscopeOfUse.Requires
tconforms toForeignConvertibleinscopeOfUse.Declaration
Swift
public func foreignRepresentation( of t: AnyType, exposedTo scopeOfUse: AnyScopeID ) -> AnyType -
Returns the modules visible to
s.Declaration
Swift
public func modules(exposedTo s: AnyScopeID) -> Set<ModuleDecl.ID> -
Returns the type of
dspecialized byspecializationinscopeOfUse.Declaration
Swift
public func canonicalType<T: Decl>( of d: T.ID, specializedBy specialization: GenericArguments, in scopeOfUse: AnyScopeID ) -> AnyType -
Returns the declarations of
d‘s captures.If
dis a member, its receiver is its only capture. Otherwise, this method returnsnonMemberCaptures(d).Declaration
Swift
public func captures(of d: FunctionDecl.ID) -> [AnyDeclID] -
Returns the declarations of
d‘s captures.If
dis a member, its receiver is its only capture. Otherwise, this method returnsnonMemberCaptures(d).Declaration
Swift
public func captures(of d: SubscriptImpl.ID) -> [AnyDeclID] -
Returns the declarations of
d‘s captures.Explicit captures come first, in the order they appear in its capture list, from left to right. Implicit captures come next, in the order they were found during type checking.
Requires
dis not a member declaration.Declaration
Swift
public func nonMemberCaptures<T>(of d: T.ID) -> [AnyDeclID] where T : CapturingDecl -
Returns the run-time parameters of
e, which is the callee of a function or subscript call, ifeis a reference to a callable declaration.Declaration
Swift
public func runtimeParameters(of callee: AnyExprID) -> [ParameterDecl.ID]? -
Applies
merge(self[keyPath: path], value).Declaration
Swift
mutating func write<V>( _ value: V, at path: WritableKeyPath<Self, V>, mergingWith merge: (inout V, V) -> Void )Parameters
mergeA closure that merges
valueinto the value currently stored atpath, guaranteeing that the result of the merge is a refinement. -
Writes
valueatpath.Requires
valuecontains at least as much information asself[keyPath: path].Declaration
Swift
mutating func write<V>( _ value: V, at path: WritableKeyPath<Self, V> ) where V: Monotonic -
Returns a debug description of
m.Declaration
Swift
func describe(_ m: RequirementSystem) -> String -
Returns a debug description of
r.Declaration
Swift
func describe(_ r: RequirementRule) -> String -
Returns a debug description of
t.Declaration
Swift
func describe(_ t: RequirementTerm) -> String -
The AST of the program.
Declaration
Swift
public var ast: AST { get } -
A map from node to the innermost scope that contains it.
Declaration
Swift
public var nodeToScope: ASTProperty<AnyScopeID> { get } -
A map from scope to the declarations directly contained in it.
Declaration
Swift
public var scopeToDecls: ASTProperty<DeclIDs> { get } -
A map from variable declaration its containing binding declaration.
Declaration
Swift
public var varToBinding: [VarDecl.ID : BindingDecl.ID] { get }
View on GitHub