plug in visualizer view ui rules in new eval viz code; cfg-tree/vocab-driven tab titles

This commit is contained in:
Ryan Fleury
2025-02-07 11:40:49 -08:00
parent 31b0772137
commit 412c55a474
10 changed files with 197 additions and 33 deletions
+7 -2
View File
@@ -1924,7 +1924,7 @@ e_parse_expr_from_text_tokens__prec(Arena *arena, String8 text, E_TokenArray *to
}
}break;
// rjf: string => leaf string literal, or file path
//- rjf: string => leaf string literal, or file path
case E_TokenKind_StringLiteral:
{
if(str8_match(resolution_qualifier, str8_lit("file"), 0))
@@ -1944,7 +1944,12 @@ e_parse_expr_from_text_tokens__prec(Arena *arena, String8 text, E_TokenArray *to
it += 1;
}
}break;
}
//- rjf: upgrade atom w/ qualifier
if(resolution_qualifier.size != 0)
{
atom->qualifier = resolution_qualifier;
}
}
}
+1
View File
@@ -64,6 +64,7 @@ struct E_Expr
E_TypeKey type_key;
E_Value value;
String8 string;
String8 qualifier;
String8 bytecode;
};
@@ -318,6 +318,7 @@ internal void ev_key_set_view_rule(EV_View *view, EV_Key key, String8 view_rule_
//~ rjf: View Rule Info Table Building / Selection / Lookups
internal void ev_expand_rule_table_push(Arena *arena, EV_ExpandRuleTable *table, EV_ExpandRule *info);
#define ev_expand_rule_table_push_new(arena, table, ...) ev_expand_rule_table_push((arena), (table), &(EV_ExpandRule){__VA_ARGS__})
internal void ev_select_expand_rule_table(EV_ExpandRuleTable *table);
internal EV_ExpandRule *ev_expand_rule_from_string(String8 string);
+13 -1
View File
@@ -28,7 +28,7 @@ RD_CmdKind_Null,
RD_CmdKind_Null,
};
RD_VocabularyInfo rd_vocabulary_info_table[45] =
RD_VocabularyInfo rd_vocabulary_info_table[57] =
{
{str8_lit_comp("auto_view_rule"), str8_lit_comp("auto_view_rules"), str8_lit_comp("Auto View Rule"), str8_lit_comp("Auto View Rules"), RD_IconKind_Binoculars},
{str8_lit_comp("file_path_map"), str8_lit_comp("file_path_maps"), str8_lit_comp("File Path Map"), str8_lit_comp("File Path Maps"), RD_IconKind_FileOutline},
@@ -75,6 +75,18 @@ RD_VocabularyInfo rd_vocabulary_info_table[45] =
{str8_lit_comp("process"), str8_lit_comp("processes"), str8_lit_comp("Process"), str8_lit_comp("Processes"), RD_IconKind_Threads},
{str8_lit_comp("machine"), str8_lit_comp("machines"), str8_lit_comp("Machine"), str8_lit_comp("Machines"), RD_IconKind_Machine},
{str8_lit_comp("module"), str8_lit_comp("modules"), str8_lit_comp("Module"), str8_lit_comp("Modules"), RD_IconKind_Module},
{str8_lit_comp("getting_started"), str8_lit_comp(""), str8_lit_comp("Getting Started"), str8_lit_comp(""), RD_IconKind_QuestionMark},
{str8_lit_comp("disasm"), str8_lit_comp(""), str8_lit_comp("Disassembly"), str8_lit_comp(""), RD_IconKind_Glasses},
{str8_lit_comp("text"), str8_lit_comp(""), str8_lit_comp("Text"), str8_lit_comp(""), RD_IconKind_FileOutline},
{str8_lit_comp("type"), str8_lit_comp("types"), str8_lit_comp("Type"), str8_lit_comp("Types"), RD_IconKind_Null},
{str8_lit_comp("procedure"), str8_lit_comp("procedures"), str8_lit_comp("Procedure"), str8_lit_comp("Procedures"), RD_IconKind_Null},
{str8_lit_comp("global_variable"), str8_lit_comp("global_variables"), str8_lit_comp("Global Variable"), str8_lit_comp("Global Variables"), RD_IconKind_Null},
{str8_lit_comp("global"), str8_lit_comp("globals"), str8_lit_comp("Global"), str8_lit_comp("Globals"), RD_IconKind_Null},
{str8_lit_comp("thread_variable"), str8_lit_comp("thread_variables"), str8_lit_comp("Thread Variable"), str8_lit_comp("Thread Variables"), RD_IconKind_Null},
{str8_lit_comp("thread_local"), str8_lit_comp("thread_locals"), str8_lit_comp("Thread Local"), str8_lit_comp("Thread Locals"), RD_IconKind_Null},
{str8_lit_comp("call_stack"), str8_lit_comp("call_stacks"), str8_lit_comp("Call Stack"), str8_lit_comp("Call Stacks"), RD_IconKind_Thread},
{str8_lit_comp("output"), str8_lit_comp("outputs"), str8_lit_comp("Output"), str8_lit_comp("Outputs"), RD_IconKind_List},
{str8_lit_comp("scheduler"), str8_lit_comp("schedulers"), str8_lit_comp("Scheduler"), str8_lit_comp("Schedulers"), RD_IconKind_Scheduler},
};
RD_NameSchemaInfo rd_name_schema_info_table[10] =
+1 -1
View File
@@ -570,7 +570,7 @@ C_LINKAGE_BEGIN
extern String8 rd_cfg_src_string_table[4];
extern RD_CmdKind rd_cfg_src_load_cmd_kind_table[4];
extern RD_CmdKind rd_cfg_src_write_cmd_kind_table[4];
extern RD_VocabularyInfo rd_vocabulary_info_table[45];
extern RD_VocabularyInfo rd_vocabulary_info_table[57];
extern RD_NameSchemaInfo rd_name_schema_info_table[10];
extern Rng1U64 rd_reg_slot_range_table[38];
extern RD_StringBindingPair rd_default_binding_table[111];
+12
View File
@@ -96,6 +96,18 @@ RD_VocabularyMap:
{process processes "Process" "Processes" Threads }
{machine _ "Machine" _ Machine }
{module _ "Module" _ Module }
{getting_started "" "Getting Started" "" QuestionMark }
{disasm "" "Disassembly" "" Glasses }
{text "" "Text" "" FileOutline }
{type _ "Type" _ Null }
{procedure _ "Procedure" _ Null }
{global_variable _ "Global Variable" _ Null }
{global _ "Global" _ Null }
{thread_variable _ "Thread Variable" _ Null }
{thread_local _ "Thread Local" _ Null }
{call_stack _ "Call Stack" _ Thread }
{output _ "Output" _ List }
{scheduler _ "Scheduler" _ Scheduler }
}
@struct RD_VocabularyInfo:
+119 -24
View File
@@ -1137,6 +1137,14 @@ rd_location_from_cfg(RD_Cfg *cfg)
return dst_loc;
}
internal String8
rd_label_from_cfg(RD_Cfg *cfg)
{
RD_Cfg *label_root = rd_cfg_child_from_string(cfg, str8_lit("label"));
String8 result = label_root->first->string;
return result;
}
internal String8
rd_expr_from_cfg(RD_Cfg *cfg)
{
@@ -1176,6 +1184,10 @@ rd_title_fstrs_from_cfg(Arena *arena, RD_Cfg *cfg, Vec4F32 secondary_color, F32
B32 is_disabled = rd_disabled_from_cfg(cfg);
RD_Location loc = rd_location_from_cfg(cfg);
D_Target target = rd_target_from_cfg(scratch.arena, cfg);
String8 label_string = rd_label_from_cfg(cfg);
String8 expr_string = rd_expr_from_cfg(cfg);
String8 collection_name = {0};
String8 file_path = {0};
Vec4F32 rgba = rd_rgba_from_cfg(cfg);
if(rgba.w == 0)
{
@@ -1194,6 +1206,45 @@ rd_title_fstrs_from_cfg(Arena *arena, RD_Cfg *cfg, Vec4F32 secondary_color, F32
}
}
}
B32 is_within_window = 0;
{
for(RD_Cfg *p = cfg->parent; p != &rd_nil_cfg; p = p->parent)
{
if(str8_match(p->string, str8_lit("window"), 0))
{
is_within_window = 1;
break;
}
}
}
if(expr_string.size != 0)
{
String8 query_name = rd_query_from_eval_string(arena, expr_string);
if(query_name.size != 0)
{
String8 query_code_name = query_name;
String8 query_display_name = rd_display_from_code_name(query_code_name);
collection_name = query_display_name;
if(query_display_name.size == 0)
{
query_code_name = rd_singular_from_code_name_plural(query_name);
collection_name = rd_display_plural_from_code_name(query_code_name);
}
RD_IconKind query_icon_kind = rd_icon_kind_from_code_name(query_code_name);
if(query_icon_kind != RD_IconKind_Null)
{
icon_kind = query_icon_kind;
}
}
else
{
file_path = rd_file_path_from_eval_string(arena, expr_string);
if(file_path.size != 0)
{
icon_kind = RD_IconKind_FileOutline;
}
}
}
//- rjf: set up color/size for all parts of the title
//
@@ -1223,24 +1274,44 @@ rd_title_fstrs_from_cfg(Arena *arena, RD_Cfg *cfg, Vec4F32 secondary_color, F32
dr_fancy_string_list_push_new(arena, &result, rd_font_from_slot(RD_FontSlot_Code), size, secondary_color, str8_lit(" "));
}
//- rjf: push label
//- rjf: push view title, if from window, and no file path
if(is_within_window && file_path.size == 0 && collection_name.size == 0)
{
String8 label = rd_cfg_child_from_string(cfg, str8_lit("label"))->first->string;
if(label.size != 0)
String8 view_display_name = rd_display_from_code_name(cfg->string);
if(view_display_name.size != 0)
{
dr_fancy_string_list_push_new(arena, &result, rd_font_from_slot(RD_FontSlot_Code), running_size, running_rgba, label);
dr_fancy_string_list_push_new(arena, &result, rd_font_from_slot(RD_FontSlot_Main), running_size, running_rgba, view_display_name);
dr_fancy_string_list_push_new(arena, &result, rd_font_from_slot(RD_FontSlot_Code), size, secondary_color, str8_lit(" "));
start_secondary();
}
}
//- rjf: push expression
//- rjf: push label
if(label_string.size != 0)
{
String8 expr = rd_cfg_child_from_string(cfg, str8_lit("expression"))->first->string;
if(expr.size != 0)
{
dr_fancy_string_list_push_new(arena, &result, rd_font_from_slot(RD_FontSlot_Code), running_size, running_rgba, expr);
start_secondary();
}
dr_fancy_string_list_push_new(arena, &result, rd_font_from_slot(RD_FontSlot_Code), running_size, running_rgba, label_string);
dr_fancy_string_list_push_new(arena, &result, rd_font_from_slot(RD_FontSlot_Code), size, secondary_color, str8_lit(" "));
start_secondary();
}
//- rjf: push expression
if(collection_name.size != 0)
{
dr_fancy_string_list_push_new(arena, &result, rd_font_from_slot(RD_FontSlot_Main), running_size, running_rgba, collection_name);
dr_fancy_string_list_push_new(arena, &result, rd_font_from_slot(RD_FontSlot_Code), size, secondary_color, str8_lit(" "));
start_secondary();
}
else if(file_path.size != 0)
{
dr_fancy_string_list_push_new(arena, &result, rd_font_from_slot(RD_FontSlot_Main), running_size, running_rgba, file_path);
dr_fancy_string_list_push_new(arena, &result, rd_font_from_slot(RD_FontSlot_Code), size, secondary_color, str8_lit(" "));
start_secondary();
}
else if(expr_string.size != 0)
{
dr_fancy_string_list_push_new(arena, &result, rd_font_from_slot(RD_FontSlot_Code), running_size, running_rgba, expr_string);
dr_fancy_string_list_push_new(arena, &result, rd_font_from_slot(RD_FontSlot_Code), size, secondary_color, str8_lit(" "));
start_secondary();
}
//- rjf: push text location
@@ -2578,10 +2649,10 @@ rd_file_path_from_eval_string(Arena *arena, String8 string)
String8 result = {0};
{
Temp scratch = scratch_begin(&arena, 1);
E_Eval eval = e_eval_from_string(scratch.arena, string);
if(eval.expr->kind == E_ExprKind_LeafFilePath)
E_Expr *expr = e_parse_expr_from_text(scratch.arena, string);
if(expr->kind == E_ExprKind_LeafFilePath)
{
result = raw_from_escaped_str8(arena, eval.expr->string);
result = raw_from_escaped_str8(arena, expr->string);
}
scratch_end(scratch);
}
@@ -2598,6 +2669,25 @@ rd_eval_string_from_file_path(Arena *arena, String8 string)
return result;
}
//- rjf: eval -> query
internal String8
rd_query_from_eval_string(Arena *arena, String8 string)
{
String8 result = {0};
{
Temp scratch = scratch_begin(&arena, 1);
E_Expr *expr = e_parse_expr_from_text(scratch.arena, string);
if(expr->kind == E_ExprKind_LeafIdent &&
str8_match(expr->qualifier, str8_lit("query"), 0))
{
result = expr->string;
}
scratch_end(scratch);
}
return result;
}
////////////////////////////////
//~ rjf: View Functions
@@ -12959,7 +13049,7 @@ rd_frame(void)
expr->space = space;
expr->mode = E_Mode_Offset;
expr->type_key = e_type_key_cons_array(e_type_key_basic(E_TypeKind_U8), data.size);
e_string2expr_map_insert(scratch.arena, ctx->macro_map, str8_lit("output_log"), expr);
e_string2expr_map_insert(scratch.arena, ctx->macro_map, str8_lit("output"), expr);
hs_scope_close(hs_scope);
}
@@ -13025,21 +13115,26 @@ rd_frame(void)
{
String8 name;
RD_ViewUIFunctionType *ui;
EV_ExpandRuleInfoHookFunctionType *expand;
}
table[] =
{
{str8_lit("watch"), RD_VIEW_UI_FUNCTION_NAME(watch)},
{str8_lit("text"), RD_VIEW_UI_FUNCTION_NAME(text)},
{str8_lit("disasm"), RD_VIEW_UI_FUNCTION_NAME(disasm)},
{str8_lit("memory"), RD_VIEW_UI_FUNCTION_NAME(memory)},
{str8_lit("bitmap"), RD_VIEW_UI_FUNCTION_NAME(bitmap)},
{str8_lit("checkbox"), RD_VIEW_UI_FUNCTION_NAME(checkbox)},
{str8_lit("color_rgba"), RD_VIEW_UI_FUNCTION_NAME(color_rgba)},
{str8_lit("geo3d"), RD_VIEW_UI_FUNCTION_NAME(geo3d)},
{str8_lit("watch"), RD_VIEW_UI_FUNCTION_NAME(watch), EV_EXPAND_RULE_INFO_FUNCTION_NAME(watch)},
{str8_lit("text"), RD_VIEW_UI_FUNCTION_NAME(text), EV_EXPAND_RULE_INFO_FUNCTION_NAME(text)},
{str8_lit("disasm"), RD_VIEW_UI_FUNCTION_NAME(disasm), EV_EXPAND_RULE_INFO_FUNCTION_NAME(disasm)},
{str8_lit("memory"), RD_VIEW_UI_FUNCTION_NAME(memory), EV_EXPAND_RULE_INFO_FUNCTION_NAME(memory)},
{str8_lit("bitmap"), RD_VIEW_UI_FUNCTION_NAME(bitmap), EV_EXPAND_RULE_INFO_FUNCTION_NAME(bitmap)},
{str8_lit("checkbox"), RD_VIEW_UI_FUNCTION_NAME(checkbox), 0},
{str8_lit("color_rgba"), RD_VIEW_UI_FUNCTION_NAME(color_rgba), EV_EXPAND_RULE_INFO_FUNCTION_NAME(color_rgba)},
{str8_lit("geo3d"), RD_VIEW_UI_FUNCTION_NAME(geo3d), EV_EXPAND_RULE_INFO_FUNCTION_NAME(geo3d)},
};
for EachElement(idx, table)
{
rd_view_ui_rule_map_insert(scratch.arena, rd_state->view_ui_rule_map, table[idx].name, table[idx].ui);
if(table[idx].expand != 0)
{
ev_expand_rule_table_push_new(scratch.arena, expand_rule_table, table[idx].name, table[idx].expand);
}
}
}
@@ -14321,7 +14416,7 @@ X(watch_pins)\
X(targets)\
X(scheduler)\
X(modules)\
Y(output, text, "query:output_log")\
Y(output, text, "query:output")\
Y(disasm, disasm, "")\
Y(memory, memory, "")\
Z(getting_started)
+4
View File
@@ -1019,6 +1019,7 @@ internal Vec4F32 rd_rgba_from_cfg(RD_Cfg *cfg);
internal B32 rd_disabled_from_cfg(RD_Cfg *cfg);
internal RD_Location rd_location_from_cfg(RD_Cfg *cfg);
internal String8 rd_label_from_cfg(RD_Cfg *cfg);
internal String8 rd_expr_from_cfg(RD_Cfg *cfg);
internal D_Target rd_target_from_cfg(Arena *arena, RD_Cfg *cfg);
internal DR_FancyStringList rd_title_fstrs_from_cfg(Arena *arena, RD_Cfg *cfg, Vec4F32 secondary_color, F32 size);
@@ -1094,6 +1095,9 @@ internal R_Tex2DFormat rd_tex2dformat_from_eval_params(E_Eval eval, MD_Node *par
internal String8 rd_file_path_from_eval_string(Arena *arena, String8 string);
internal String8 rd_eval_string_from_file_path(Arena *arena, String8 string);
//- rjf: eval -> query
internal String8 rd_query_from_eval_string(Arena *arena, String8 string);
////////////////////////////////
//~ rjf: View Functions
+28 -5
View File
@@ -909,6 +909,7 @@ rd_watch_row_info_from_row(Arena *arena, EV_Row *row)
.group_cfg = &rd_nil_cfg,
.group_entity = &ctrl_entity_nil,
.callstack_thread = &ctrl_entity_nil,
.view_ui_rule = &rd_nil_view_ui_rule,
};
{
Temp scratch = scratch_begin(&arena, 1);
@@ -964,12 +965,26 @@ rd_watch_row_info_from_row(Arena *arena, EV_Row *row)
info.group_cfg = rd_cfg_from_id(id);
}
// rjf: determine view ui rule
info.view_ui_rule = rd_view_ui_rule_from_string(row->block->expand_rule->string);
// rjf: fill row's cells
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Expr, .pct = 0.25f);
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Eval, .pct = 0.35f);
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Eval, .string = str8_lit("typeof($expr)"), .pct = 0.15f);
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Tag, .pct = 0.25f);
// rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Eval, .string = str8_lit("sizeof($expr)"), .pct = 0.15f);
{
// rjf: singular cell for view ui
if(info.view_ui_rule != &rd_nil_view_ui_rule)
{
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_ViewUI, .pct = 1.f);
}
// rjf: default cells
else
{
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Expr, .pct = 0.25f);
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Eval, .pct = 0.35f);
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Eval, .string = str8_lit("typeof($expr)"), .pct = 0.15f);
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Tag, .pct = 0.25f);
}
}
di_scope_close(di_scope);
scratch_end(scratch);
@@ -3993,6 +4008,14 @@ RD_VIEW_UI_FUNCTION_DEF(null) {}
////////////////////////////////
//~ rjf: watch @view_hook_impl
EV_EXPAND_RULE_INFO_FUNCTION_DEF(watch)
{
EV_ExpandInfo info = {0};
info.row_count = 8;
info.single_item = 1;
return info;
}
RD_VIEW_UI_FUNCTION_DEF(watch)
{
ProfBeginFunction();
+11
View File
@@ -46,6 +46,7 @@ typedef enum RD_WatchCellKind
RD_WatchCellKind_Expr, // strings to represent expression itself
RD_WatchCellKind_Tag, // strings to represent attached tags at row-granularity
RD_WatchCellKind_Eval, // an evaluation of the expression, with some optional modification - e.g. `$expr.some_member`, or `typeof($expr)`
RD_WatchCellKind_ViewUI,
}
RD_WatchCellKind;
@@ -78,6 +79,7 @@ struct RD_WatchRowInfo
U64 callstack_unwind_index;
U64 callstack_inline_depth;
RD_WatchCellList cells;
RD_ViewUIRule *view_ui_rule;
};
typedef struct RD_WatchRowCellInfo RD_WatchRowCellInfo;
@@ -241,6 +243,15 @@ internal void rd_watch_view_build(RD_WatchViewState *ewv, Rng2F32 rect);
// TODO(rjf): @cfg eliminate once we are predeclaring these with metacode
RD_VIEW_UI_FUNCTION_DEF(null);
EV_EXPAND_RULE_INFO_FUNCTION_DEF(watch);
EV_EXPAND_RULE_INFO_FUNCTION_DEF(text);
EV_EXPAND_RULE_INFO_FUNCTION_DEF(disasm);
EV_EXPAND_RULE_INFO_FUNCTION_DEF(memory);
EV_EXPAND_RULE_INFO_FUNCTION_DEF(bitmap);
EV_EXPAND_RULE_INFO_FUNCTION_DEF(color_rgba);
EV_EXPAND_RULE_INFO_FUNCTION_DEF(geo3d);
RD_VIEW_UI_FUNCTION_DEF(watch);
RD_VIEW_UI_FUNCTION_DEF(text);
RD_VIEW_UI_FUNCTION_DEF(disasm);