This commit is contained in:
T0b1
2023-06-29 02:13:07 +02:00
parent 83fb234d5c
commit 6f0b3b9e99
4 changed files with 65 additions and 17 deletions

View File

@@ -82,7 +82,9 @@ namespace dbgui::frontend
{
std::string expr_path;
size_t id;
size_t id2;
bool used_this_frame = false;
bool is_cstr = false;
};
Target(std::string filename);
@@ -115,26 +117,37 @@ namespace dbgui::frontend
return &*data_res_nodes[*idx];
}
size_t find_or_create_expr_path(std::string &&path)
size_t find_or_create_expr_path(std::string &&path, bool is_cstr = false)
{
for (auto &entry : expr_cache)
{
if (entry.expr_path == path)
{
entry.used_this_frame = true;
return entry.id;
return entry.is_cstr ? entry.id2 : entry.id;
}
}
using namespace data::source;
auto id = this->id++;
auto id = this->id++;
size_t cstr_id = -1;
this->backend->add_data_node(
Node{.id = id,
.type = Node::Type::source,
.data = Source{.type = Source::Type::variable,
.data = Source::Variable{.expr_path = path}}});
expr_cache.push_back(ExprCacheEntry{
.expr_path = std::move(path), .id = id, .used_this_frame = true});
if (is_cstr)
{
cstr_id = this->id++;
this->backend->add_data_node(Node{.id = cstr_id,
.type = Node::Type::read_cstr,
.data = ReadAsCStr{.src_id = id}});
}
expr_cache.push_back(ExprCacheEntry{.expr_path = std::move(path),
.id = id,
.id2 = cstr_id,
.used_this_frame = true,
.is_cstr = is_cstr});
return id;
}