Symbol Mangling
Zynx uses a custom mangling scheme inspired by the Itanium C++ ABI to support namespacing, overloading, and interoperation with C toolchains.
General Format
_ZN <scope> <name> E <params>
_ZN: Prefix for all Zynx mangled symbols.<scope>: One or more name segments (module, struct/interface) encoded as<len><name>.<name>: The function name (or operator code).E: Terminates the nested name portion.<params>: Mangled types of the function parameters. Usevif there are no parameters.
Name Encoding
- Regular names: Encoded as
<len><name>. - Dotted names: Each segment is encoded separately (e.g.,
foo.bar->3foo3bar). - Operators: Use two-letter codes (e.g.,
+->pl,-->mi).
Type Mangling Codes
| Type | Code | Type | Code |
|---|---|---|---|
i8 | a | u8 | h |
i32 | i | u32 | j |
i64 | l | u64 | m |
f32 | f | f64 | d |
str | Di | bool | b |
void | v | usize | y |
Type Modifiers
- Reference (
&T):R - Pointer (
*T):P - Array (
T[]):A_ - Nullable (
T?):u
Examples
Functions
fn foo()in modulemain:_ZN4main3fooEvfn add(a: i32, b: i32)in modulemath:_ZN4math3addEii
Structs
struct Pointin modulegeo:_ZN3geo5PointEstruct Wrapper<i32>in moduleutil:_ZN4util7WrapperIiEE
Verification
Since Zynx's mangling scheme is heavily inspired by the Itanium C++ ABI, standard tools like c++filt can be used to decode and verify mangled names:
echo <mangled name> | c++filt -n
For example:
echo _ZN4math3addEii | c++filt -n
# Output: math::add(int, int)
See also
- Memory Model - ownership rules and lifetime behavior that influence symbol lifetimes.
- Compiler Internals - how mangling fits into the overall compilation pipeline and C code generation.
- C Interoperability Overview - how mangled Zynx symbols coexist with C symbols at the ABI boundary.