Module Ppx_template_expander.MangleSource
We piggyback on Ast_traverse because it gives us a lot of AST traversal code for free. However, only the methods we currently need are implemented - if adding support for new kinds of bindings in Monomorphize, be sure to update Mangle.
An alternative implementation for this could be Suffix.t -> location Ast_traverse.map_with_context, with Suffix.t = string list, rather than string list loc as it secretly is now. That is, we don't modify the string list part of the suffix as we traverse. The location is updated as we traverse to the nearest enclosing location, to be used in error reporting.
However, passing the string list via map_with_context allows us to cheaply reuse a global singleton Mangle object for every identifier we need to mangle, calling pure functions, rather than creating a fresh object with many methods and potentially some closures each time.
val mangle :
'a Attribute_handler.Context.mono ->
'a ->
Language.{Typed}3/shadowed/(b6b9680872d43a7fcf8333602ce3b156).Expression.Basic.packed
Ppxlib.Loc.t
list
Explicitness.With.t
Language.Typed.Axis.Map.t ->
env:Env.t ->
'aApply name mangling to the item, using the given attribute expressions and environment.
val suffix_for_manual_mangling :
?modes:(Explicitness.t * Ppxlib_jane.Shim.Modes.t) ->
?kinds:(Explicitness.t * Ppxlib_jane.Shim.jkind_annotation list) ->
unit ->
(string, Syntax_error.t) resultThis is useful for ppxes outside of ppx_template, when they want to generate names that are mangled based on jkind annotations and don't want to generate attribute and extension annotations to get that done.
This is only for use by other ppxs: code in ppx_template should always use Mangle.t instead.