1
0
mirror of synced 2024-11-24 07:40:17 +01:00

patterns: Added demangle function

This commit is contained in:
WerWolv 2022-09-30 12:49:49 +02:00
parent 663fb88367
commit 84530e0817

View File

@ -7,6 +7,7 @@
#include <pl/core/evaluator.hpp>
#include <pl/patterns/pattern.hpp>
#include <llvm/Demangle/Demangle.h>
namespace hex::plugin::builtin {
void registerPatternLanguageFunctions() {
@ -16,7 +17,7 @@ namespace hex::plugin::builtin {
pl::api::Namespace nsHexCore = { "builtin", "hex", "core" };
{
/* get_selection() */
ContentRegistry::PatternLanguage::addDangerousFunction(nsHexCore, "get_selection", FunctionParameterCount::none(), [](Evaluator *, auto) -> std::optional<Token::Literal> {
ContentRegistry::PatternLanguage::addFunction(nsHexCore, "get_selection", FunctionParameterCount::none(), [](Evaluator *, auto) -> std::optional<Token::Literal> {
if (!ImHexApi::HexEditor::isSelectionValid())
return std::numeric_limits<u128>::max();
@ -26,6 +27,16 @@ namespace hex::plugin::builtin {
});
}
pl::api::Namespace nsHexDec = { "builtin", "hex", "dec" };
{
/* demangle(mangled_string) */
ContentRegistry::PatternLanguage::addFunction(nsHexDec, "demangle", FunctionParameterCount::exactly(1), [](Evaluator *, auto params) -> std::optional<Token::Literal> {
const auto mangledString = Token::literalToString(params[0], false);
return llvm::demangle(mangledString);
});
}
pl::api::Namespace nsHexHttp = { "builtin", "hex", "http" };
{
/* get(url) */