Program
public protocol Program : Sendable
Types representing Hylo programs at some stage after syntactic and scope analysis.
-
The AST of the program.
Declaration
Swift
var ast: AST { get } -
A map from node to the innermost scope that contains it.
Declaration
Swift
var nodeToScope: ASTProperty<AnyScopeID> { get } -
A map from scope to the declarations that it contains.
Declaration
Swift
var scopeToDecls: ASTProperty<DeclIDs> { get } -
A map from variable declaration its containing binding declaration.
Declaration
Swift
var varToBinding: [VarDecl.ID : BindingDecl.ID] { get } -
subscript(_:Extension method) Projects the node associated with
idbundled with its extrinsic relationships.Declaration
Swift
public subscript<T>(id: T) -> BundledNode<T, Self> where T : NodeIDProtocol { get } -
isModuleEntry(_:Extension method) Returns
trueiffdis a module’s entry function.Declaration
Swift
public func isModuleEntry(_ d: FunctionDecl.ID) -> Bool -
builtinIsVisible(in:Extension method) trueiff theBuiltinmodule is visible ins.Declaration
Swift
public func builtinIsVisible(in s: AnyScopeID) -> Bool -
isContained(_:Extension methodin: ) Returns whether
childis contained inancestor.Lexical scope containment is transitive and reflexive; this method returns
trueif:child == ancestor, orparent[child] == ancestor, orisContained(parent[child], ancestor).
Requires
childis the identifier of a scope in this hierarchy.Declaration
Swift
public func isContained<T, U>(_ child: T, in ancestor: U) -> Bool where T : NodeIDProtocol, U : ScopeID -
areInSameModule(_:Extension method_: ) Returns whether
landrare in the same module.Declaration
Swift
public func areInSameModule<L, R>(_ l: L, _ r: R) -> Bool where L : NodeIDProtocol, R : NodeIDProtocol -
areOverlapping(_:Extension method_: ) Returns whether
loverlaps withr.Declaration
Swift
public func areOverlapping(_ l: AnyScopeID, _ r: AnyScopeID) -> Bool -
hasMoreAncestors(_:Extension methodthan: ) Returns
trueifflis lexically enclosed in more scopes thanr.Declaration
Swift
public func hasMoreAncestors<T: NodeIDProtocol, U: NodeIDProtocol>( _ l: T, than r: U ) -> Bool -
compareLexicalDepth(_:Extension method_: in: ) Compares
lhsandrhsinscopeOfUseand returns whether one lexically shadows the other.lhsis lexically deeper thanrhsw.r.t.scopeOfUseif any of these statements hold:lhsis declared in the module containingscopeOfUseandrhsisn’t.lhsandrhsare declared in module containingscopeOfUseandlhshas more ancestors thanrhs.
Declaration
Swift
public func compareLexicalDepth<T: NodeIDProtocol, U: NodeIDProtocol>( _ lhs: T, _ rhs: U, in scopeOfUse: AnyScopeID ) -> StrictPartialOrdering -
scopeContainingBody(of:Extension method) Returns the scope of
d‘s body, if any.Declaration
Swift
public func scopeContainingBody(of d: FunctionDecl.ID) -> AnyScopeID? -
scopeContainingBody(of:Extension method) Returns the scope of
d‘s body, if any.Declaration
Swift
public func scopeContainingBody(of d: MethodImpl.ID) -> AnyScopeID? -
scopeContainingBody(of:Extension method) Returns the scope of
d‘s body, if any.Declaration
Swift
public func scopeContainingBody(of d: SubscriptImpl.ID) -> AnyScopeID? -
isCallableBody(_:Extension method) Returns
trueiffsis the body of a function, initializer, or subscript.Declaration
Swift
public func isCallableBody(_ s: BraceStmt.ID) -> Bool -
siblings(of:Extension method) Returns
dand the parameters and explicit captures introduced in the same scope.Declaration
Swift
public func siblings(of d: ParameterDecl.ID) -> [AnyDeclID] -
parametersAndCaptures(inBodyOf:Extension method) Returns the parameters and explicit captures introduced in the body of
d. -
isAtModuleScope(_:Extension method) Returns
trueiffdis at module scope.Declaration
Swift
public func isAtModuleScope<T>(_ d: T) -> Bool where T : DeclID -
isGlobal(_:Extension method) Returns whether
declis global.A declaration is global if and only if:
- it is a type declaration; or
- it is declared at global or namespace scope; or
- it is declared at type scope and it is static; or
- it is introduced with
initormemberwise init.
Declaration
Swift
public func isGlobal<T>(_ decl: T) -> Bool where T : DeclID -
isMember(_:Extension method) Returns whether
dis member of a type declaration.Declaration
Swift
public func isMember<T>(_ d: T) -> Bool where T : DeclID -
isNonStaticMember(_:Extension method) Returns whether
declis a non-static member of a type declaration.Declaration
Swift
public func isNonStaticMember<T>(_ decl: T) -> Bool where T : DeclID -
isNonStaticMember(_:Extension method) Returns whether
declis a non-static member of a type declaration.Declaration
Swift
public func isNonStaticMember(_ decl: FunctionDecl.ID) -> Bool -
isNonStaticMember(_:Extension method) Returns whether
declis a non-static member of a type declaration.Declaration
Swift
public func isNonStaticMember(_ decl: MethodDecl.ID) -> Bool -
isNonStaticMember(_:Extension method) Returns whether
declis a non-static member of a type declaration.Declaration
Swift
public func isNonStaticMember(_ decl: SubscriptDecl.ID) -> Bool -
isLocal(_:Extension method) -
isPublic(_:Extension method) Returns
trueiffdis public.Declaration
Swift
public func isPublic<T>(_ d: T) -> Bool where T : DeclID -
isAccessibleAsRequirementImplementation(_:Extension method) Returns
trueiffdhas the appropriate visibility when used as the implementation of a trait requirement.Declaration
Swift
public func isAccessibleAsRequirementImplementation<T>(_ d: T) -> Bool where T : DeclID -
isExported(_:Extension method) Returns
trueiffdis visible outside of its module.Note
modules are considered exported.Declaration
Swift
public func isExported<T>(_ d: T) -> Bool where T : DeclID -
isExportingDecls(_:Extension method) Returns
trueiff the public declarations insare visible outside of their module.Declaration
Swift
public func isExportingDecls(_ s: AnyScopeID) -> Bool -
isDefinedInExtension(_:Extension method) Returns
trueiffdis defined in an extension.Declaration
Swift
public func isDefinedInExtension<T>(_ d: T) -> Bool where T : DeclID -
isRequirement(_:Extension method) Returns
trueiffdis a trait requirement.Declaration
Swift
public func isRequirement<T>(_ d: T) -> Bool where T : DeclID -
isImplicitDefinition(_:Extension method) Returns
trueiffddeclares a value usable as an implicit parameter.Declaration
Swift
public func isImplicitDefinition(_ d: AnyDeclID) -> Bool -
innermostReceiver(in:Extension method) If
sis in a member context, returns the innermost receiver declaration exposed tos. Otherwise, returnsnilDeclaration
Swift
public func innermostReceiver(in useScope: AnyScopeID) -> ParameterDecl.ID? -
scopes(from:Extension method) Returns a sequence containing
scopeand all its ancestors, from inner to outer.Declaration
Swift
public func scopes<S>(from scope: S) -> LexicalScopeSequence where S : ScopeID -
innermostCommonScope(_:Extension method_: ) Returns the innermost scope that is a common ancestor of
aandbornilifaandbare in different modules.Declaration
Swift
public func innermostCommonScope(_ a: AnyScopeID, _ b: AnyScopeID) -> AnyScopeID? -
module(containing:Extension method) Returns the module containing
scope.Declaration
Swift
public func module<S>(containing scope: S) -> ModuleDecl.ID where S : ScopeID -
source(containing:Extension method) Returns the translation unit containing
scope.Requires
Requires:scopeis not a module.Declaration
Swift
public func source<S>(containing scope: S) -> TranslationUnit.ID where S : ScopeID -
name(of:Extension method) Returns the name of
d. -
subfieldRelativeToRoot(of:Extension method) Returns
(root: r, path: p)whererootis the binding declaration introducingdandpis the path to the object bound todrelative toroot.Declaration
Swift
public func subfieldRelativeToRoot( of d: VarDecl.ID ) -> (root: BindingDecl.ID, path: RecordPath) -
storedParts(of:Extension method) Returns the declarations of the stored part of
p.Declaration
Swift
public func storedParts(of p: ProductTypeDecl.ID) -> [VarDecl.ID] -
debugDescription(_:Extension method) Returns a textual description of
nsuitable for debugging.Declaration
Swift
public func debugDescription<T>(_ n: T) -> String where T : NodeIDProtocol -
debugDescription(_:Extension method) Returns a textual description of
dsuitable for debugging.Declaration
Swift
public func debugDescription(_ d: BindingDecl.ID) -> String -
Returns a reference to
das a member ofparent, specialized byspecialization, exposed toscopeOfUse, and used as a constructor ifisConstructoristrue.Declaration
Swift
fileprivate func makeReference( to d: AnyDeclID, specializedBy specialization: GenericArguments, memberOf parent: NameResolutionContext?, exposedTo scopeOfUse: AnyScopeID, usedAsConstructor isConstructor: Bool ) -> DeclReference
View on GitHub