This commit is contained in:
T0b1
2023-06-25 02:57:11 +02:00
parent 28dbf374e8
commit 10826ff2d5
9 changed files with 271 additions and 16 deletions

View File

@@ -78,6 +78,13 @@ namespace dbgui::frontend
}
};
struct ExprCacheEntry
{
std::string expr_path;
size_t id;
bool used_this_frame = false;
};
Target(std::string filename);
std::optional<uint16_t> data_idx_for_src_id(size_t id)
@@ -108,6 +115,29 @@ namespace dbgui::frontend
return &*data_res_nodes[*idx];
}
size_t find_or_create_expr_path(std::string &&path)
{
for (auto &entry : expr_cache)
{
if (entry.expr_path == path)
{
entry.used_this_frame = true;
return entry.id;
}
}
using namespace data::source;
auto id = this->id++;
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});
return id;
}
TargetState state = TargetState::stopped;
std::string filename;
uint64_t id;
@@ -124,6 +154,7 @@ namespace dbgui::frontend
std::vector<std::pair<size_t, uint16_t>> src_id_to_data_idx;
std::vector<std::optional<data::result::Node>> data_res_nodes;
std::vector<data::type_info::TypeInfo> types;
std::vector<ExprCacheEntry> expr_cache;
std::shared_ptr<backend::Backend> backend = nullptr;
};