Skip to content

Latest commit

 

History

History
69 lines (55 loc) · 1.96 KB

README.md

File metadata and controls

69 lines (55 loc) · 1.96 KB

Demangler

An Itanium ABI symbol demangler.

Usage

const { Demangler } = require("demangler");

try {
    const mangle = "_Z3fooPvS_";
    const demangled = new Demangler(mangle);

    console.info("%s becomes %s", mangle, demangled.toString());
} catch (error) {
    console.error(error);
}

Expected Log

_Z3fooPvS_ becomes foo(void *, void *);

Object Structure

class Demangler {
    isType: boolean // If the symbol is a type definition
    isVTable: boolean // If the symbol is a vtable definition
    isTypeStructure: boolean // If the symbol is a type structure definition
    isTypeName: boolean // If the symbol is a type name definition
    isNonVirtualThunk: boolean // If the symbol is a non-virtual thunk
    thunkOffset: number | null // The this pointer offset the thunk uses
    isConstant: boolean // If the symbol is constant
    isClassConstructor: boolean // If the symbol is a class constructor
    isClassDestructor: boolean // If the symbol is a class destructor
    objects: ObjectInfo[] // An array of parsed objects before any parameters
    parameters: Parameter[] // An array of parameters
    sections: (ObjectInfo[] | Parameter)[] // An array of substitute variable sections
    toString(): string // Generates a mostly accurate C++ definition
}
interface Parameter {
    isComplex: boolean, // If the parameter is a complex
    isConstant: boolean, // If the parameter is constant
    memoryType: string, // The pointer and reference characters
    type: ObjectInfo[] // An array of parameter type object info
}
interface ObjectInfo {
    object: string, // The object name
    templates: Parameter[] // An array of object templates
}

Supported

  • Non-virtual thunks
  • Types
  • Definitions
  • Template definitions
  • Objects
  • Methods

Due to the complexity of some symbols this module won't support anything that can't be generated by compiling C++, e.g. expressions. Callbacks and literals will be added in the future.