patterns: Added ability to format patterns as strings.

This adds support for printing char16 strings
This commit is contained in:
WerWolv
2021-11-04 20:32:34 +01:00
parent beea4c4147
commit 1c1396bf4b
2 changed files with 32 additions and 2 deletions

View File

@@ -16,7 +16,7 @@
namespace hex::plugin::builtin {
std::string format(pl::Evaluator *, auto params) {
std::string format(pl::Evaluator *ctx, auto params) {
auto format = pl::Token::literalToString(params[0], true);
std::string message;
@@ -27,7 +27,7 @@ namespace hex::plugin::builtin {
std::visit(overloaded {
[&](pl::PatternData* value) {
formatArgs.push_back(hex::format("{} {} @ 0x{:X}", value->getTypeName(), value->getVariableName(), value->getOffset()));
formatArgs.push_back(value->toString(ctx->getProvider()));
},
[&](auto &&value) {
formatArgs.push_back(value);