ptr WIP
This commit is contained in:
@@ -1014,6 +1014,8 @@ bool WatchWindow::draw(Frontend &frontend)
|
||||
first = false;
|
||||
}
|
||||
|
||||
auto expr_path_vec = std::vector<ExprPathPart>{};
|
||||
|
||||
// ImGuiTableFlags_SizingFixedFit
|
||||
if (ImGui::BeginTable("##Variables", 2,
|
||||
ImGuiTableFlags_RowBg | ImGuiTableFlags_Resizable))
|
||||
@@ -1053,9 +1055,10 @@ bool WatchWindow::draw(Frontend &frontend)
|
||||
reinterpret_cast<const char *>(locals_data.data() + cur_off + 2),
|
||||
str_len};
|
||||
auto node_idx = local_node.children[cur_idx];
|
||||
expr_path_vec.clear();
|
||||
this->draw_value(frontend,
|
||||
frontend.target->data_res_nodes[node_idx]->type_id,
|
||||
name, node_idx, 0);
|
||||
name, node_idx, 0, expr_path_vec);
|
||||
|
||||
cur_idx += 1;
|
||||
cur_off += 2 + str_len;
|
||||
@@ -1078,8 +1081,9 @@ bool WatchWindow::draw(Frontend &frontend)
|
||||
no_success = false;
|
||||
const auto &child_node =
|
||||
*frontend.target->data_res_nodes[node.children[0]];
|
||||
expr_path_vec.clear();
|
||||
this->draw_value(frontend, child_node.type_id, &extra_slots[i],
|
||||
node.children[0], 0);
|
||||
node.children[0], 0, expr_path_vec);
|
||||
|
||||
if (extra_slots[i].bak == "")
|
||||
{
|
||||
@@ -1192,7 +1196,8 @@ bool WatchWindow::draw(Frontend &frontend)
|
||||
void WatchWindow::draw_value(Frontend &frontend,
|
||||
data::type_info::TypeID type_id,
|
||||
std::variant<std::string_view, ExtraSlot *> name,
|
||||
data::result::NodeIdx node_idx, size_t off)
|
||||
data::result::NodeIdx node_idx, size_t off,
|
||||
std::vector<ExprPathPart> &expr_path)
|
||||
{
|
||||
ImGui::TableNextRow();
|
||||
ImGui::TableSetColumnIndex(0);
|
||||
@@ -1367,8 +1372,12 @@ void WatchWindow::draw_value(Frontend &frontend,
|
||||
continue;
|
||||
}
|
||||
|
||||
expr_path.push_back(ExprPathPart{
|
||||
.ident = std::string_view{name_begin, name_end - name_begin},
|
||||
.deref = false});
|
||||
this->draw_value(frontend, member.type_id, member.name, node_idx,
|
||||
off + member.offset);
|
||||
off + member.offset, expr_path);
|
||||
expr_path.pop_back();
|
||||
}
|
||||
} else
|
||||
{
|
||||
@@ -1379,15 +1388,21 @@ void WatchWindow::draw_value(Frontend &frontend,
|
||||
size_t el_count =
|
||||
frontend.target->types[type_id.idx].byte_size / member_size;
|
||||
|
||||
expr_path.push_back(ExprPathPart{
|
||||
.ident = std::string_view{name_begin, name_end - name_begin},
|
||||
.array = true});
|
||||
|
||||
char buf[32];
|
||||
size_t member_off = 0;
|
||||
for (size_t i = 0; i < el_count; ++i)
|
||||
{
|
||||
std::snprintf(buf, sizeof(buf), "[%lu]", i);
|
||||
this->draw_value(frontend, member_ty_id, buf, node_idx,
|
||||
off + member_off);
|
||||
off + member_off, expr_path);
|
||||
member_off += member_size;
|
||||
}
|
||||
|
||||
expr_path.pop_back();
|
||||
}
|
||||
|
||||
ImGui::TreePop();
|
||||
@@ -1435,17 +1450,22 @@ void WatchWindow::draw_value(Frontend &frontend,
|
||||
}
|
||||
}
|
||||
|
||||
auto tree_open = false;
|
||||
if (!is_editing)
|
||||
{
|
||||
char tree_id_buf[128];
|
||||
std::snprintf(tree_id_buf, sizeof(tree_id_buf), "%u#off%lu", node_idx,
|
||||
off);
|
||||
ImGuiTreeNodeFlags flags = ImGuiTreeNodeFlags_SpanFullWidth;
|
||||
if (type_id.type != Type::ptr)
|
||||
{
|
||||
flags |= ImGuiTreeNodeFlags_Leaf | ImGuiTreeNodeFlags_NoTreePushOnOpen;
|
||||
}
|
||||
|
||||
// TODO: better id
|
||||
ImGui::TreeNodeEx(
|
||||
tree_id_buf,
|
||||
ImGuiTreeNodeFlags_SpanFullWidth | ImGuiTreeNodeFlags_Leaf
|
||||
| ImGuiTreeNodeFlags_NoTreePushOnOpen,
|
||||
"%.*s", static_cast<int>(name_end - name_begin), name_begin);
|
||||
tree_open =
|
||||
ImGui::TreeNodeEx(tree_id_buf, flags, "%.*s",
|
||||
static_cast<int>(name_end - name_begin), name_begin);
|
||||
//ImGui::TextUnformatted(name_begin, name_end);
|
||||
if (name.index() == 1
|
||||
&& ImGui::IsMouseDoubleClicked(ImGuiMouseButton_Left)
|
||||
@@ -1518,6 +1538,43 @@ void WatchWindow::draw_value(Frontend &frontend,
|
||||
{
|
||||
// TODO: ptr size
|
||||
ImGui::Text("%lX", node.get_primitive<uint64_t>(off));
|
||||
if (tree_open)
|
||||
{
|
||||
// TODO: make this func be able to not print the "outer" line
|
||||
// and just accept a bool to only draw the containing value
|
||||
std::string path{"*"};
|
||||
// why cant i just path name_begin, name_end to string_view? :[
|
||||
construct_expr_path(
|
||||
path, expr_path,
|
||||
std::string_view{name_begin,
|
||||
static_cast<size_t>(name_end - name_begin)});
|
||||
|
||||
auto src_id =
|
||||
frontend.target->find_or_create_expr_path(std::move(path));
|
||||
auto res_idx = frontend.target->data_idx_for_src_id(src_id);
|
||||
if (res_idx)
|
||||
{
|
||||
const auto &node = *frontend.target->data_res_nodes[*res_idx];
|
||||
if (node.success && node.children.size() == 1)
|
||||
{
|
||||
auto data_idx = node.children[0];
|
||||
const auto &data_node =
|
||||
*frontend.target->data_res_nodes[data_idx];
|
||||
expr_path.push_back(ExprPathPart{
|
||||
.ident = std::string_view{name_begin, static_cast<size_t>(
|
||||
name_end - name_begin)},
|
||||
.deref = true});
|
||||
|
||||
this->draw_value(frontend, data_node.type_id,
|
||||
std::string_view{"<pointee>"}, data_idx, 0,
|
||||
expr_path);
|
||||
|
||||
expr_path.pop_back();
|
||||
}
|
||||
}
|
||||
|
||||
ImGui::TreePop();
|
||||
}
|
||||
break;
|
||||
}
|
||||
case _enum:
|
||||
@@ -1563,6 +1620,30 @@ void WatchWindow::draw_value(Frontend &frontend,
|
||||
}
|
||||
}
|
||||
|
||||
void WatchWindow::construct_expr_path(std::string &out,
|
||||
const std::vector<ExprPathPart> &path,
|
||||
std::string_view tail)
|
||||
{
|
||||
for (const auto &entry : path)
|
||||
{
|
||||
// FIXME: BIGGEST HACK in cinema history
|
||||
if (entry.ident == "<pointee>")
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
out += entry.ident;
|
||||
if (entry.deref)
|
||||
{
|
||||
out += "->";
|
||||
} else if (!entry.array)
|
||||
{
|
||||
out += '.';
|
||||
}
|
||||
}
|
||||
out += tail;
|
||||
}
|
||||
|
||||
void Window::handle_source_updated(Target &target, size_t id)
|
||||
{
|
||||
switch (this->type)
|
||||
|
||||
Reference in New Issue
Block a user