#abi

mangler

A simple Rust program that mangles and parse C++ symbol names using Itanium ABI

2 unstable releases

0.2.0 Aug 29, 2024
0.1.0 Aug 29, 2024

#26 in #abi

Download history 227/week @ 2024-08-29 32/week @ 2024-09-12 16/week @ 2024-09-19 12/week @ 2024-09-26 5/week @ 2024-10-03

65 downloads per month
Used in cxx_linker

MIT license

11KB
238 lines

mangler

A simple Rust program that mangles and parse C++ symbol names using Itanium ABI.

Example

use mangler::*;

fn main() {
    let mangled = mangle("foo::bar::hello(int, float, std::string)");
    println!("{}", mangled); // _ZN3foo3bar5helloEifSs

    let mangled = mangle(
        Symbol::Function(
            Box::new(
                Symbol::Namespace(
                    vec![
                        Symbol::Type("hello".to_string()),
                        Symbol::Type("world".to_string()),
                        Symbol::Generic(
                            vec![
                                Symbol::Typed(
                                    Box::new(
                                        Symbol::Type("int".to_string())
                                    ),
                                    vec![TypedElement::Ptr]
                                )
                            ]
                        ),
                        Symbol::Type("print".to_string())
                    ]
                )
            ),
            vec![
                Symbol::Type("int".to_string()),
                Symbol::Type("float".to_string()),
                Symbol::Type("std::string".to_string())
            ]
        )
    );

    println!("{}", mangled); // _ZN5hello5worldIPiE5printEifSs
  
}

Dependencies

~2.1–2.8MB
~57K SLoC