Skip to content

mapper

DEFAULT_MAPPER = BUILTIN_MAPPERS['default_mapper'] module-attribute

The default mapping function used to match decompiled functions to source functions.

Mapper = Callable[[DecompiledFunction, SourceFunction], bool] module-attribute

Callable type describing a mapping function that determines if a decompiled function corresponds to a given source function.

name_mapper(function, uid)

Maps a decompiled function to a source function by comparing their function names.

Parameters:

Name Type Description Default
function DecompiledFunction

The decompiled function to map.

required
uid Union[SourceFunction, str]

The source function UID or a SourceFunction object to map against.

required

Returns:

Type Description
bool

True if the decompiled function name matches the source function name.

Source code in src/codablellm/core/mapper.py
def name_mapper(function: DecompiledFunction, uid: Union[SourceFunction, str]) -> bool:
    """
    Maps a decompiled function to a source function by comparing their function names.

    Parameters:
        function: The decompiled function to map.
        uid: The source function UID or a `SourceFunction` object to map against.

    Returns:
        `True` if the decompiled function name matches the source function name.
    """
    if isinstance(uid, SourceFunction):
        uid = uid.uid
    return function.name == SourceFunction.get_function_name(uid)