enum type evaluation visualization - can now use watch windows to inspect all possible enum values

This commit is contained in:
Ryan Fleury
2024-02-02 11:50:21 -08:00
parent 847749337b
commit 5d3aa301f0
3 changed files with 73 additions and 2 deletions
+27 -2
View File
@@ -5255,6 +5255,27 @@ df_append_viz_blocks_for_parent__rec(Arena *arena, DBGI_Scope *scope, DF_EvalVie
df_eval_viz_block_end(list_out, last_vb);
}
//////////////////////////////
//- rjf: (enums) descend to members & make block(s)
//
if(parent_is_expanded && expand_rule == DF_EvalVizExpandRule_Default &&
udt_eval.mode == EVAL_EvalMode_NULL &&
udt_type_kind == TG_Kind_Enum)
ProfScope("build viz blocks for UDT type-eval enums")
{
//- rjf: type -> full type info
TG_Type *type = tg_type_from_graph_raddbg_key(scratch.arena, parse_ctx->type_graph, parse_ctx->rdbg, udt_eval.type_key);
//- rjf: build block for all members (cannot be expanded)
DF_EvalVizBlock *last_vb = df_eval_viz_block_begin(arena, DF_EvalVizBlockKind_EnumMembers, key, df_expand_key_make(df_hash_from_expand_key(key), 0), depth+1);
{
last_vb->eval = udt_eval;
last_vb->cfg_table = *cfg_table;
last_vb->visual_idx_range = last_vb->semantic_idx_range = r1u64(0, type->count);
}
df_eval_viz_block_end(list_out, last_vb);
}
//////////////////////////////
//- rjf: (structs, unions, classes) descend to members & make block(s), with linked list view
//
@@ -5609,10 +5630,14 @@ df_eval_viz_row_list_push_new(Arena *arena, EVAL_ParseCtx *parse_ctx, DF_EvalViz
{
break;
}
if(block->eval.mode != EVAL_EvalMode_NULL && ((TG_Kind_FirstBasic <= kind && kind <= TG_Kind_LastBasic) || kind == TG_Kind_Ptr || kind == TG_Kind_LRef || kind == TG_Kind_RRef))
if(eval.mode != EVAL_EvalMode_NULL && ((TG_Kind_FirstBasic <= kind && kind <= TG_Kind_LastBasic) || kind == TG_Kind_Ptr || kind == TG_Kind_LRef || kind == TG_Kind_RRef))
{
row->flags |= DF_EvalVizRowFlag_CanEditValue;
}
if(eval.mode == EVAL_EvalMode_NULL && kind == TG_Kind_Enum)
{
row->flags |= DF_EvalVizRowFlag_CanExpand;
}
if(kind == TG_Kind_Struct ||
kind == TG_Kind_Union ||
kind == TG_Kind_Class ||
@@ -5624,7 +5649,7 @@ df_eval_viz_row_list_push_new(Arena *arena, EVAL_ParseCtx *parse_ctx, DF_EvalViz
{
break;
}
if(block->eval.mode == EVAL_EvalMode_NULL)
if(eval.mode == EVAL_EvalMode_NULL)
{
break;
}
+1
View File
@@ -696,6 +696,7 @@ typedef enum DF_EvalVizBlockKind
DF_EvalVizBlockKind_Null, // empty
DF_EvalVizBlockKind_Root, // root of tree or subtree; possibly-expandable expression.
DF_EvalVizBlockKind_Members, // members of struct, class, union
DF_EvalVizBlockKind_EnumMembers, // members of enum
DF_EvalVizBlockKind_Elements, // elements of array
DF_EvalVizBlockKind_Links, // flattened nodes in a linked list
DF_EvalVizBlockKind_Canvas, // escape hatch for arbitrary UI
+45
View File
@@ -7252,6 +7252,51 @@ df_eval_viz_windowed_row_list_from_viz_block_list(Arena *arena, DBGI_Scope *scop
}
}break;
//////////////////////////////
//- rjf: enum members -> produce rows for the visible range of enum members.
//
case DF_EvalVizBlockKind_EnumMembers:
if(block_type_kind == TG_Kind_Enum)
{
TG_Type *type = tg_type_from_graph_raddbg_key(scratch.arena, parse_ctx->type_graph, parse_ctx->rdbg, block->eval.type_key);
for(U64 idx = visible_idx_range.min; idx < visible_idx_range.max && idx < type->count; idx += 1)
{
TG_EnumVal *enum_val = &type->enum_vals[idx];
DF_ExpandKey key = df_expand_key_make(df_hash_from_expand_key(block->parent_key), idx+1);
// rjf: produce eval for this enum member
DF_Eval eval = zero_struct;
{
eval.type_key = block->eval.type_key;
eval.mode = EVAL_EvalMode_Value;
eval.imm_u64 = enum_val->val;
}
// rjf: get view rules
String8 view_rule_string = df_eval_view_rule_from_key(eval_view, key);
DF_CfgTable view_rule_table = df_cfg_table_from_inheritance(scratch.arena, &block->cfg_table);
df_cfg_table_push_unparsed_string(scratch.arena, &view_rule_table, view_rule_string, DF_CfgSrc_User);
// rjf: apply view rules to eval
{
eval = df_dynamically_typed_eval_from_eval(parse_ctx->type_graph, parse_ctx->rdbg, ctrl_ctx, eval);
eval = df_eval_from_eval_cfg_table(arena, scope, ctrl_ctx, parse_ctx, eval, &view_rule_table);
}
// rjf: build & push row
String8List display_strings = df_single_line_eval_value_strings_from_eval(scratch.arena, DF_EvalVizStringFlag_ReadOnlyDisplayRules, parse_ctx->type_graph, parse_ctx->rdbg, ctrl_ctx, default_radix, font, font_size, 500, 0, eval, 0, &view_rule_table);
String8List edit_strings = df_single_line_eval_value_strings_from_eval(scratch.arena, 0, parse_ctx->type_graph, parse_ctx->rdbg, ctrl_ctx, default_radix, font, font_size, 500, 0, eval, 0, &view_rule_table);
DF_EvalVizRow *row = df_eval_viz_row_list_push_new(arena, parse_ctx, &list, block, key, eval);
row->expr = push_str8_copy(arena, enum_val->name);
row->display_value = str8_list_join(arena, &display_strings, 0);
row->edit_value = str8_list_join(arena, &edit_strings, 0);
row->value_ui_rule_node = value_ui_rule_node;
row->value_ui_rule_spec = value_ui_rule_spec;
row->expand_ui_rule_node = expand_ui_rule_node;
row->expand_ui_rule_spec = expand_ui_rule_spec;
}
}break;
//////////////////////////////
//- rjf: elements -> produce rows for the visible range of elements.
//