Expand description
Swift symbol demangling library with high-level semantic types.
This crate provides both low-level (raw) and high-level APIs for working
with Swift mangled symbols.
§High-Level API
The high-level API provides semantic types that make it easy to work with
demangled symbols. Create a Context and use Symbol::parse to
get started:
use swift_demangler::{Context, HasFunctionSignature, HasModule, Symbol};
let ctx = Context::new();
if let Some(symbol) = Symbol::parse(&ctx, "$s4main5helloSSyYaKF") {
if let Some(func) = symbol.as_function() {
println!("Function: {}", func.name().unwrap_or("?"));
println!("Module: {}", func.module().unwrap_or("?"));
println!("Async: {}", func.is_async());
println!("Throws: {}", func.is_throwing());
}
}§Low-Level API
The raw module provides direct access to the node tree:
use swift_demangler::Context;
use swift_demangler::raw::{Node, NodeKind};
let ctx = Context::new();
if let Some(root) = Node::parse(&ctx, "$s4main5helloSSyYaKF") {
for node in root.descendants() {
println!("{:?}: {:?}", node.kind(), node.text());
}
}Re-exports§
Modules§
- raw
- Low-level Swift symbol demangling API.
Structs§
- Accessor
- A Swift property accessor symbol.
- Async
Symbol - A Swift async or coroutine symbol.
- Attributed
Symbol - A symbol with an attribute modifier (@objc, @nonobjc, dynamic, distributed).
- Auto
Diff - A Swift automatic differentiation symbol.
- Auto
Diff Thunk - An automatic differentiation thunk.
- Closure
- A Swift closure symbol.
- Constructor
- A Swift constructor (initializer) symbol.
- Default
Argument - A default argument initializer.
- Descriptor
- A Swift metadata descriptor symbol.
- Destructor
- A Swift destructor (deinitializer) symbol.
- Enum
Case - A Swift enum case constructor symbol.
- Function
- A Swift function symbol.
- Function
Param - A parameter in a function type.
- Function
Signature Param - A parameter in a function signature specialization.
- Function
Signature Param Flags - Option flags that can be combined with the base param kind.
- Function
Type - A Swift function type.
- Generic
Requirement - A generic requirement (constraint) on a generic parameter.
- Generic
Signature - A generic signature describing generic parameters and their constraints.
- Impl
Function Type - A SIL implementation function type.
- Impl
Param - A parameter in a SIL implementation function type.
- Impl
Result - A result in a SIL implementation function type.
- Macro
Symbol - A Swift macro symbol.
- Metadata
- A Swift type metadata symbol.
- Named
Type - A named Swift type (class, struct, enum, protocol, type alias).
- Opaque
Source - Information about the source of an opaque return type.
- Outlined
- A Swift outlined operation symbol.
- Outlined
Symbol - An outlined symbol containing both the outlined operation metadata and the context symbol.
- Protocol
Conformance - Information about a protocol conformance.
- Protocol
Witness Thunk - A protocol witness thunk that adapts a concrete implementation to a protocol requirement.
- Reabstraction
Thunk - A reabstraction thunk that converts between calling conventions.
- Specialization
- A Swift specialization symbol.
- Specialized
Symbol - A specialized symbol containing both the specialization metadata and the inner symbol.
- Suffixed
Symbol - A symbol with an unmangled suffix.
- Symbol
Context - The context (location) of a Swift symbol.
- Tuple
Element - A tuple element.
- TypeRef
- A reference to a Swift type.
- Variable
- A global variable symbol.
- Witness
Table - A Swift witness table symbol.
Enums§
- Accessor
Kind - The kind of accessor.
- Async
Symbol Kind - The kind of async or coroutine symbol.
- Auto
Diff Kind - The kind of automatic differentiation symbol.
- Auto
Diff Thunk Kind - The kind of autodiff thunk.
- Closure
Kind - The kind of closure.
- Constructor
Kind - The kind of constructor.
- Context
Component - A component in a symbol’s context path.
- Descriptor
Kind - The kind of metadata descriptor.
- Destructor
Kind - The kind of destructor.
- Dispatch
Kind - The kind of dispatch thunk.
- Function
Convention - The calling convention of a function type.
- Function
Signature Param Kind - The base kind of function signature parameter transformation.
- Generic
Requirement Kind - The kind of generic requirement.
- Macro
Symbol Kind - The kind of macro symbol.
- Metadata
Kind - The kind of type metadata.
- Other
Thunk Kind - Other thunk kinds that don’t need specialized handling.
- Outlined
Kind - The kind of outlined operation.
- Specialization
Kind - The kind of specialization.
- Symbol
- A parsed Swift symbol.
- Symbol
Attribute - Symbol attributes that can be applied to declarations.
- Thunk
- A Swift thunk symbol.
- Type
Kind - The kind of a Swift type.
- Value
Witness Kind - The kind of value witness.
- Witness
Table Kind - The kind of witness table.
Traits§
- HasExtension
Context - Trait for types that can be defined in an extension.
- HasFunction
Signature - Trait for types that have a function signature.
- HasGeneric
Signature - Trait for types that may have a generic signature.
- HasModule
- Trait for types that can provide their containing module.