Structured_manglingStructured name mangling for OxCaml symbols.
This module implements a mangling scheme that encodes OxCaml identifiers into a restricted character set (ASCII alphanumeric and underscore) suitable for use in linker symbols. The scheme preserves the lexical structure of the source program by encoding each scope (compilation unit, module, function, etc.) as a tagged path item.
A mangled symbol has the form _Caml<path> where <path> is a sequence of tagged, length-prefixed identifiers:
U - compilation UnitI - Inline markerM - ModuleS - anonymous StructO - class (O for object)F - FunctionL - anonymous function (L for lambda)P - Partial applicationFor example, Foo.Bar.baz in compilation unit Foo mangles to _CamlU3FooM3BarF3baz.
type path_item = | Compilation_unit of Compilation_unit.tA compilation unit (file)
*)| Inline_markerA separator (between destination and source) to track inlining
*)| Module of stringA named module
*)| Anonymous_module of int * int * string optionstruct ... end at (line, col, file)
| Class of stringA class definition
*)| Function of stringA named function
*)| Anonymous_function of int * int * string optionfun ... -> ... at (line, col, file)
| Partial_function of int * int * string optionA partial application at (line, col, file)
*)A path item represents a single lexical scope in the mangling path.
type path = path_item listA mangling path is a list of path items representing the full lexical context of an identifier.
val mangle_ident : Compilation_unit.t -> path -> stringTransform a Compilation_unit.t and a path into a mangled name suitable for creating a LinkageName.t