mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-06-18 01:52:22 -07:00
eliminate mutual exclusion of expression/evaluation cells; allow both paths to be turned on in a single cell
This commit is contained in:
+50
-60
@@ -3277,13 +3277,11 @@ rd_view_ui(Rng2F32 rect)
|
||||
edit_state->cursor = op.cursor;
|
||||
edit_state->mark = op.mark;
|
||||
|
||||
// rjf: commit edited cell string
|
||||
switch(cell->kind)
|
||||
// rjf: commit edited cell string - first try to commit eval value, if that path is
|
||||
// enabled on this cell, next try to commit expression string, if that path is enabled
|
||||
if(cell->kind == RD_WatchCellKind_Eval)
|
||||
{
|
||||
case RD_WatchCellKind_ViewUI:
|
||||
case RD_WatchCellKind_CallStackFrame:
|
||||
{}break;
|
||||
case RD_WatchCellKind_Expr:
|
||||
if(cell->flags & RD_WatchCellFlag_Expr && cell->flags & RD_WatchCellFlag_NoEval)
|
||||
{
|
||||
RD_Cfg *cfg = row_info.group_cfg_child;
|
||||
String8 child_key = str8_lit("expression");
|
||||
@@ -3312,31 +3310,28 @@ rd_view_ui(Rng2F32 rect)
|
||||
RD_Cfg *expr = child_key.size != 0 ? rd_cfg_child_from_string_or_alloc(cfg, child_key) : cfg;
|
||||
rd_cfg_new_replace(expr, new_string);
|
||||
}
|
||||
}break;
|
||||
case RD_WatchCellKind_Eval:
|
||||
}
|
||||
else
|
||||
{
|
||||
if(cell->eval.irtree.mode == E_Mode_Offset)
|
||||
B32 should_commit_asap = editing_complete;
|
||||
if(cell->eval.space.kind == RD_EvalSpaceKind_MetaCfg)
|
||||
{
|
||||
B32 should_commit_asap = editing_complete;
|
||||
if(cell->eval.space.kind == RD_EvalSpaceKind_MetaCfg)
|
||||
should_commit_asap = 1;
|
||||
}
|
||||
else if(evt->slot != UI_EventActionSlot_Cancel)
|
||||
{
|
||||
should_commit_asap = editing_complete;
|
||||
}
|
||||
if(should_commit_asap)
|
||||
{
|
||||
B32 success = 0;
|
||||
success = rd_commit_eval_value_string(cell->eval, new_string);
|
||||
if(!success)
|
||||
{
|
||||
should_commit_asap = 1;
|
||||
}
|
||||
else if(evt->slot != UI_EventActionSlot_Cancel)
|
||||
{
|
||||
should_commit_asap = editing_complete;
|
||||
}
|
||||
if(should_commit_asap)
|
||||
{
|
||||
B32 success = 0;
|
||||
success = rd_commit_eval_value_string(cell->eval, new_string);
|
||||
if(!success)
|
||||
{
|
||||
log_user_error(str8_lit("Could not commit value successfully."));
|
||||
}
|
||||
log_user_error(str8_lit("Could not commit value successfully."));
|
||||
}
|
||||
}
|
||||
}break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -3418,43 +3413,39 @@ rd_view_ui(Rng2F32 rect)
|
||||
continue;
|
||||
}
|
||||
RD_WatchPt pt = {row->block->key, row->key, rd_id_from_watch_cell(cell)};
|
||||
switch(cell->kind)
|
||||
if(cell->flags & RD_WatchCellFlag_Expr && cell->flags & RD_WatchCellFlag_NoEval)
|
||||
{
|
||||
default:{}break;
|
||||
case RD_WatchCellKind_Expr:
|
||||
RD_Cfg *cfg = row_info.group_cfg_child;
|
||||
if(cfg != &rd_nil_cfg)
|
||||
{
|
||||
RD_Cfg *cfg = row_info.group_cfg_child;
|
||||
if(cfg != &rd_nil_cfg)
|
||||
rd_cfg_list_push(scratch.arena, &cfgs_to_remove, cfg);
|
||||
U64 deleted_num = ev_block_num_from_id(row->block, row->key.child_id);
|
||||
if(deleted_num != 0)
|
||||
{
|
||||
rd_cfg_list_push(scratch.arena, &cfgs_to_remove, cfg);
|
||||
U64 deleted_num = ev_block_num_from_id(row->block, row->key.child_id);
|
||||
if(deleted_num != 0)
|
||||
EV_Key parent_key = row->block->parent->key;
|
||||
EV_Key key = row->block->key;
|
||||
U64 fallback_id_prev = ev_block_id_from_num(row->block, deleted_num-1);
|
||||
U64 fallback_id_next = ev_block_id_from_num(row->block, deleted_num+1);
|
||||
if(fallback_id_next != 0)
|
||||
{
|
||||
EV_Key parent_key = row->block->parent->key;
|
||||
EV_Key key = row->block->key;
|
||||
U64 fallback_id_prev = ev_block_id_from_num(row->block, deleted_num-1);
|
||||
U64 fallback_id_next = ev_block_id_from_num(row->block, deleted_num+1);
|
||||
if(fallback_id_next != 0)
|
||||
{
|
||||
parent_key = row->block->key;
|
||||
key = ev_key_make(row->key.parent_hash, fallback_id_next);
|
||||
}
|
||||
else if(fallback_id_prev != 0)
|
||||
{
|
||||
parent_key = row->block->key;
|
||||
key = ev_key_make(row->key.parent_hash, fallback_id_prev);
|
||||
}
|
||||
RD_WatchPt new_pt = {parent_key, key, pt.cell_id};
|
||||
next_cursor_pt = new_pt;
|
||||
next_cursor_set = 1;
|
||||
state_dirty = 1;
|
||||
parent_key = row->block->key;
|
||||
key = ev_key_make(row->key.parent_hash, fallback_id_next);
|
||||
}
|
||||
else if(fallback_id_prev != 0)
|
||||
{
|
||||
parent_key = row->block->key;
|
||||
key = ev_key_make(row->key.parent_hash, fallback_id_prev);
|
||||
}
|
||||
RD_WatchPt new_pt = {parent_key, key, pt.cell_id};
|
||||
next_cursor_pt = new_pt;
|
||||
next_cursor_set = 1;
|
||||
state_dirty = 1;
|
||||
}
|
||||
}break;
|
||||
case RD_WatchCellKind_Eval:
|
||||
{
|
||||
rd_commit_eval_value_string(cell->eval, str8_zero());
|
||||
}break;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
rd_commit_eval_value_string(cell->eval, str8_zero());
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4325,8 +4316,7 @@ rd_view_ui(Rng2F32 rect)
|
||||
else
|
||||
{
|
||||
// rjf: compute visual params
|
||||
B32 fancy_editors_in_expr = (row_info->cells.count == 1);
|
||||
B32 cell_has_fancy_editors = (cell->kind != RD_WatchCellKind_Expr || fancy_editors_in_expr);
|
||||
B32 cell_has_fancy_editors = (!(cell->flags & RD_WatchCellFlag_NoEval));
|
||||
B32 is_button = !!(cell_info.flags & RD_WatchCellFlag_Button);
|
||||
B32 has_background = !!(cell_info.flags & RD_WatchCellFlag_Background);
|
||||
B32 is_toggle_switch = (cell_has_fancy_editors && cell->eval.irtree.mode != E_Mode_Null && e_type_kind_from_key(e_type_key_unwrap(cell->eval.irtree.type_key, E_TypeUnwrapFlag_AllDecorative)) == E_TypeKind_Bool);
|
||||
@@ -4334,7 +4324,7 @@ rd_view_ui(Rng2F32 rect)
|
||||
B32 is_activated_on_single_click = !!(cell_info.flags & RD_WatchCellFlag_ActivateWithSingleClick);
|
||||
B32 is_non_code = !!(cell_info.flags & RD_WatchCellFlag_IsNonCode);
|
||||
String8 ghost_text = {0};
|
||||
if(cell_selected && ewv->text_editing && cell->kind == RD_WatchCellKind_Expr)
|
||||
if(cell_selected && ewv->text_editing && cell->flags & RD_WatchCellFlag_Expr && cell->flags & RD_WatchCellFlag_NoEval)
|
||||
{
|
||||
is_non_code = 0;
|
||||
is_button = 0;
|
||||
|
||||
+172
-166
@@ -823,7 +823,7 @@ rd_id_from_watch_cell(RD_WatchCell *cell)
|
||||
{
|
||||
U64 result = 5381;
|
||||
result = e_hash_from_string(result, str8_struct(&cell->kind));
|
||||
if(cell->kind != RD_WatchCellKind_Expr)
|
||||
if(!(cell->flags & RD_WatchCellFlag_Expr))
|
||||
{
|
||||
result = e_hash_from_string(result, str8_struct(&cell->index));
|
||||
result = e_hash_from_string(result, str8_struct(&cell->default_pct));
|
||||
@@ -1129,7 +1129,7 @@ rd_watch_row_info_from_row(Arena *arena, EV_Row *row)
|
||||
if(type->kind == E_TypeKind_Set)
|
||||
{
|
||||
String8 file_path = e_string_from_id(row->eval.value.u64);
|
||||
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Expr, row->eval, .edit_string = row->edit_string, .flags = RD_WatchCellFlag_Indented|RD_WatchCellFlag_Button|RD_WatchCellFlag_IsNonCode, .pct = 1.f);
|
||||
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Eval, row->eval, .edit_string = row->edit_string, .flags = RD_WatchCellFlag_Expr|RD_WatchCellFlag_Indented|RD_WatchCellFlag_Button|RD_WatchCellFlag_IsNonCode, .pct = 1.f);
|
||||
if(str8_match(type->name, str8_lit("file"), 0))
|
||||
{
|
||||
info.can_expand = 0;
|
||||
@@ -1143,7 +1143,7 @@ rd_watch_row_info_from_row(Arena *arena, EV_Row *row)
|
||||
RD_Cfg *w_cfg = style->first;
|
||||
F32 next_pct = 0;
|
||||
#define take_pct() (next_pct = (F32)f64_from_str8(w_cfg->string), w_cfg = w_cfg->next, next_pct)
|
||||
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Expr, row->eval, .edit_string = row->edit_string, .flags = RD_WatchCellFlag_Indented, .default_pct = 0.35f, .pct = take_pct());
|
||||
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Eval, row->eval, .edit_string = row->edit_string, .flags = RD_WatchCellFlag_Expr|RD_WatchCellFlag_NoEval|RD_WatchCellFlag_Indented, .default_pct = 0.35f, .pct = take_pct());
|
||||
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Eval, row->eval, .default_pct = 0.65f, .pct = take_pct());
|
||||
#undef take_pct
|
||||
}
|
||||
@@ -1155,7 +1155,10 @@ rd_watch_row_info_from_row(Arena *arena, EV_Row *row)
|
||||
else if(row->eval.space.kind == RD_EvalSpaceKind_MetaUnattachedProcess &&
|
||||
str8_match(row_type->name, str8_lit("unattached_process"), 0))
|
||||
{
|
||||
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Expr, row->eval, .edit_string = row->edit_string, .flags = RD_WatchCellFlag_Button|RD_WatchCellFlag_Indented, .pct = 1.f);
|
||||
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Eval, row->eval,
|
||||
.edit_string = row->edit_string,
|
||||
.flags = RD_WatchCellFlag_Button|RD_WatchCellFlag_Indented,
|
||||
.pct = 1.f);
|
||||
}
|
||||
|
||||
////////////////////////////
|
||||
@@ -1164,7 +1167,7 @@ rd_watch_row_info_from_row(Arena *arena, EV_Row *row)
|
||||
else if(rd_cfg_child_from_string(rd_cfg_from_id(rd_regs()->view), str8_lit("lister")) != &rd_nil_cfg)
|
||||
{
|
||||
info.can_expand = 0;
|
||||
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Expr, row->eval, .edit_string = row->edit_string, .flags = RD_WatchCellFlag_Button|RD_WatchCellFlag_Indented, .pct = 1.f);
|
||||
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Eval, row->eval, .edit_string = row->edit_string, .flags = RD_WatchCellFlag_Expr|RD_WatchCellFlag_Button|RD_WatchCellFlag_Indented, .pct = 1.f);
|
||||
}
|
||||
|
||||
////////////////////////////
|
||||
@@ -1173,7 +1176,7 @@ rd_watch_row_info_from_row(Arena *arena, EV_Row *row)
|
||||
else if(is_top_level && evalled_cfg != &rd_nil_cfg)
|
||||
{
|
||||
RD_Cfg *cfg = evalled_cfg;
|
||||
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Expr, row->eval, .edit_string = row->edit_string, .flags = RD_WatchCellFlag_Button|RD_WatchCellFlag_Indented, .pct = 1.f);
|
||||
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Eval, row->eval, .edit_string = row->edit_string, .flags = RD_WatchCellFlag_Button|RD_WatchCellFlag_Indented, .pct = 1.f);
|
||||
MD_NodePtrList schemas = rd_schemas_from_name(cfg->string);
|
||||
for(MD_NodePtrNode *n = schemas.first; n != 0; n = n->next)
|
||||
{
|
||||
@@ -1243,7 +1246,7 @@ rd_watch_row_info_from_row(Arena *arena, EV_Row *row)
|
||||
else if(is_top_level && evalled_entity != &ctrl_entity_nil)
|
||||
{
|
||||
CTRL_Entity *entity = evalled_entity;
|
||||
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Expr, row->eval,
|
||||
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Eval, row->eval,
|
||||
.edit_string = row->edit_string,
|
||||
.flags = RD_WatchCellFlag_Indented|RD_WatchCellFlag_Button,
|
||||
.pct = 1.f);
|
||||
@@ -1275,7 +1278,7 @@ rd_watch_row_info_from_row(Arena *arena, EV_Row *row)
|
||||
//
|
||||
else if(row->eval.space.kind == RD_EvalSpaceKind_MetaQuery)
|
||||
{
|
||||
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Expr, row->eval, .edit_string = row->edit_string,.flags = RD_WatchCellFlag_Indented, .pct = 1.f);
|
||||
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Eval, row->eval, .edit_string = row->edit_string,.flags = RD_WatchCellFlag_Indented, .pct = 1.f);
|
||||
}
|
||||
|
||||
////////////////////////////
|
||||
@@ -1286,13 +1289,13 @@ rd_watch_row_info_from_row(Arena *arena, EV_Row *row)
|
||||
E_Type *type = e_type_from_key__cached(row->eval.irtree.type_key);
|
||||
if(type->kind == E_TypeKind_Set)
|
||||
{
|
||||
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Expr, row->eval,
|
||||
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Eval, row->eval,
|
||||
.edit_string = row->edit_string,
|
||||
.flags = RD_WatchCellFlag_Indented, .pct = 1.f);
|
||||
}
|
||||
else
|
||||
{
|
||||
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Expr, row->eval,
|
||||
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Eval, row->eval,
|
||||
.edit_string = row->edit_string,
|
||||
.flags = RD_WatchCellFlag_Indented|RD_WatchCellFlag_Button|RD_WatchCellFlag_ActivateWithSingleClick,
|
||||
.pct = 1.f);
|
||||
@@ -1312,9 +1315,9 @@ rd_watch_row_info_from_row(Arena *arena, EV_Row *row)
|
||||
//
|
||||
else if(row->eval.expr == &e_expr_nil && info.group_cfg_name.size != 0 && info.group_cfg_child == &rd_nil_cfg)
|
||||
{
|
||||
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Expr, row->eval,
|
||||
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Eval, row->eval,
|
||||
.edit_string = row->edit_string,
|
||||
.flags = RD_WatchCellFlag_Indented, .pct = 1.f);
|
||||
.flags = RD_WatchCellFlag_Expr|RD_WatchCellFlag_NoEval|RD_WatchCellFlag_Indented, .pct = 1.f);
|
||||
}
|
||||
|
||||
////////////////////////////
|
||||
@@ -1325,9 +1328,9 @@ rd_watch_row_info_from_row(Arena *arena, EV_Row *row)
|
||||
row->eval.space.kind == RD_EvalSpaceKind_MetaCmd ||
|
||||
row->eval.space.kind == RD_EvalSpaceKind_MetaCtrlEntity))
|
||||
{
|
||||
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Expr, row->eval,
|
||||
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Eval, row->eval,
|
||||
.edit_string = row->edit_string,
|
||||
.flags = RD_WatchCellFlag_Indented, .pct = 1.f);
|
||||
.flags = RD_WatchCellFlag_Expr|RD_WatchCellFlag_Indented, .pct = 1.f);
|
||||
}
|
||||
|
||||
////////////////////////////
|
||||
@@ -1349,9 +1352,9 @@ rd_watch_row_info_from_row(Arena *arena, EV_Row *row)
|
||||
RD_Cfg *w_cfg = style->first;
|
||||
F32 next_pct = 0;
|
||||
#define take_pct() (next_pct = (F32)f64_from_str8(w_cfg->string), w_cfg = w_cfg->next, next_pct)
|
||||
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Expr, row->eval,
|
||||
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Eval, row->eval,
|
||||
.edit_string = row->edit_string,
|
||||
.flags = RD_WatchCellFlag_Indented, .default_pct = 0.35f, .pct = take_pct());
|
||||
.flags = RD_WatchCellFlag_Expr|RD_WatchCellFlag_NoEval|RD_WatchCellFlag_Indented, .default_pct = 0.35f, .pct = take_pct());
|
||||
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Eval, row->eval,
|
||||
.edit_string = row->edit_string,
|
||||
.default_pct = 0.65f, .pct = take_pct());
|
||||
@@ -1369,9 +1372,9 @@ rd_watch_row_info_from_row(Arena *arena, EV_Row *row)
|
||||
RD_Cfg *w_cfg = style->first;
|
||||
F32 next_pct = 0;
|
||||
#define take_pct() (next_pct = (F32)f64_from_str8(w_cfg->string), w_cfg = w_cfg->next, next_pct)
|
||||
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Expr, row->eval,
|
||||
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Eval, row->eval,
|
||||
.edit_string = row->edit_string,
|
||||
.flags = RD_WatchCellFlag_Indented,
|
||||
.flags = RD_WatchCellFlag_Expr|RD_WatchCellFlag_NoEval|RD_WatchCellFlag_Indented,
|
||||
.default_pct = 0.75f,
|
||||
.pct = take_pct());
|
||||
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Eval, e_eval_wrapf(arena, row->eval, "lens:hex((uint64)$)"), .default_pct = 0.25f, .pct = take_pct());
|
||||
@@ -1416,9 +1419,9 @@ rd_watch_row_info_from_row(Arena *arena, EV_Row *row)
|
||||
RD_Cfg *w_cfg = style->first;
|
||||
F32 next_pct = 0;
|
||||
#define take_pct() (next_pct = (F32)f64_from_str8(w_cfg->string), w_cfg = w_cfg->next, next_pct)
|
||||
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Expr, row->eval,
|
||||
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Eval, row->eval,
|
||||
.edit_string = row->edit_string,
|
||||
.flags = RD_WatchCellFlag_Indented,
|
||||
.flags = RD_WatchCellFlag_Expr|RD_WatchCellFlag_NoEval|RD_WatchCellFlag_Indented,
|
||||
.default_pct = 0.35f,
|
||||
.pct = take_pct());
|
||||
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Eval, row->eval, .default_pct = 0.40f, .pct = take_pct());
|
||||
@@ -1489,23 +1492,22 @@ rd_info_from_watch_row_cell(Arena *arena, EV_Row *row, EV_StringFlags string_fla
|
||||
//////////////////////////////
|
||||
//- rjf: determine cell editability
|
||||
//
|
||||
switch(cell->kind)
|
||||
if(cell->kind == RD_WatchCellKind_Eval)
|
||||
{
|
||||
default:{}break;
|
||||
case RD_WatchCellKind_Expr:
|
||||
if(cell->flags & RD_WatchCellFlag_Expr && cell->flags & RD_WatchCellFlag_NoEval)
|
||||
{
|
||||
if(row_info->expr_is_editable)
|
||||
{
|
||||
result.flags |= RD_WatchCellFlag_CanEdit;
|
||||
}
|
||||
}break;
|
||||
case RD_WatchCellKind_Eval:
|
||||
}
|
||||
else
|
||||
{
|
||||
if(ev_type_key_is_editable(cell->eval.irtree.type_key) && cell->eval.irtree.mode == E_Mode_Offset)
|
||||
{
|
||||
result.flags |= RD_WatchCellFlag_CanEdit;
|
||||
}
|
||||
}break;
|
||||
}
|
||||
}
|
||||
|
||||
//////////////////////////////
|
||||
@@ -1563,172 +1565,176 @@ rd_info_from_watch_row_cell(Arena *arena, EV_Row *row, EV_StringFlags string_fla
|
||||
result.flags |= RD_WatchCellFlag_Button;
|
||||
}
|
||||
|
||||
//- rjf: expression cell -> need to form "left-hand-side", or "meta" string, for some evaluation
|
||||
else if(cell->kind == RD_WatchCellKind_Expr)
|
||||
//- rjf: catchall cell -> need to form "left-hand-side", or "meta" string, for expression, and/or value string
|
||||
else
|
||||
{
|
||||
// rjf: funnel-through this cell's string, if it has one
|
||||
B32 is_non_code = 0;
|
||||
String8 expr_string = cell->edit_string;
|
||||
|
||||
// rjf: if this cell has a meta-display-name, then use that
|
||||
if(expr_string.size == 0)
|
||||
//- rjf: build left-hand-side strings
|
||||
if(cell->flags & RD_WatchCellFlag_Expr)
|
||||
{
|
||||
for(E_Type *t = e_type_from_key__cached(cell->eval.irtree.type_key);
|
||||
t != &e_type_nil;
|
||||
t = e_type_from_key__cached(t->direct_type_key))
|
||||
// rjf: funnel-through this cell's string, if it has one
|
||||
B32 is_non_code = 0;
|
||||
String8 expr_string = cell->edit_string;
|
||||
|
||||
// rjf: if this cell has a meta-display-name, then use that
|
||||
if(expr_string.size == 0)
|
||||
{
|
||||
if(t->kind == E_TypeKind_MetaDisplayName)
|
||||
for(E_Type *t = e_type_from_key__cached(cell->eval.irtree.type_key);
|
||||
t != &e_type_nil;
|
||||
t = e_type_from_key__cached(t->direct_type_key))
|
||||
{
|
||||
is_non_code = 1;
|
||||
expr_string = t->name;
|
||||
break;
|
||||
if(t->kind == E_TypeKind_MetaDisplayName)
|
||||
{
|
||||
is_non_code = 1;
|
||||
expr_string = t->name;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// rjf: if this cell has no string specified, then we need to synthesize one from the evaluation
|
||||
if(expr_string.size == 0)
|
||||
{
|
||||
// rjf: first, locate a notable expression - we special-case things like member accesses
|
||||
// or array indices, so we should grab those if possible
|
||||
E_Expr *notable_expr = cell->eval.expr;
|
||||
for(B32 good = 0; !good;)
|
||||
|
||||
// rjf: if this cell has no string specified, then we need to synthesize one from the evaluation
|
||||
if(expr_string.size == 0)
|
||||
{
|
||||
// rjf: first, locate a notable expression - we special-case things like member accesses
|
||||
// or array indices, so we should grab those if possible
|
||||
E_Expr *notable_expr = cell->eval.expr;
|
||||
for(B32 good = 0; !good;)
|
||||
{
|
||||
switch(notable_expr->kind)
|
||||
{
|
||||
default:{good = 1;}break;
|
||||
case E_ExprKind_Address:
|
||||
case E_ExprKind_Deref:
|
||||
case E_ExprKind_Cast:
|
||||
{
|
||||
notable_expr = notable_expr->last;
|
||||
}break;
|
||||
case E_ExprKind_Ref:
|
||||
{
|
||||
notable_expr = notable_expr->ref;
|
||||
}break;
|
||||
}
|
||||
}
|
||||
|
||||
// rjf: generate expression string based on our notable expression
|
||||
switch(notable_expr->kind)
|
||||
{
|
||||
default:{good = 1;}break;
|
||||
case E_ExprKind_Address:
|
||||
case E_ExprKind_Deref:
|
||||
case E_ExprKind_Cast:
|
||||
// rjf: default case -> just walk the expression tree & generate a string
|
||||
default:
|
||||
{
|
||||
notable_expr = notable_expr->last;
|
||||
expr_string = e_string_from_expr(arena, notable_expr, str8_zero());
|
||||
}break;
|
||||
case E_ExprKind_Ref:
|
||||
|
||||
// rjf: array indices -> fast path to [index]
|
||||
case E_ExprKind_ArrayIndex:
|
||||
{
|
||||
notable_expr = notable_expr->ref;
|
||||
expr_string = push_str8f(arena, "[%S]", e_string_from_expr(arena, notable_expr->last, str8_zero()));
|
||||
}break;
|
||||
|
||||
// rjf: member accesses -> fast-path to .name
|
||||
case E_ExprKind_MemberAccess:
|
||||
{
|
||||
Temp scratch = scratch_begin(&arena, 1);
|
||||
|
||||
// TODO(rjf): @cfg need to build inheritance tooltips
|
||||
#if 0
|
||||
if(member.inheritance_key_chain.count != 0)
|
||||
{
|
||||
String8List strings = {0};
|
||||
for(E_TypeKeyNode *n = member.inheritance_key_chain.first; n != 0; n = n->next)
|
||||
{
|
||||
String8 base_class_name = e_type_string_from_key(scratch.arena, n->v);
|
||||
str8_list_push(scratch.arena, &strings, base_class_name);
|
||||
}
|
||||
result.inheritance_tooltip = str8_list_join(arena, &strings, &(StringJoin){.sep = str8_lit_comp("::")});
|
||||
}
|
||||
#endif
|
||||
|
||||
// rjf: in meta-evaluation spaces, we will try to look up into our vocabulary map
|
||||
// to see if we have a fancy display string for this member. otherwise, we will just
|
||||
// do a code-string of ".member_name"
|
||||
String8 member_name = notable_expr->first->next->string;
|
||||
if(cell->eval.space.kind == RD_EvalSpaceKind_MetaCfg ||
|
||||
cell->eval.space.kind == RD_EvalSpaceKind_MetaCtrlEntity ||
|
||||
cell->eval.space.kind == E_SpaceKind_File ||
|
||||
cell->eval.space.kind == E_SpaceKind_FileSystem)
|
||||
{
|
||||
String8 fancy_name = rd_display_from_code_name(member_name);
|
||||
if(fancy_name.size != 0)
|
||||
{
|
||||
expr_string = fancy_name;
|
||||
is_non_code = 1;
|
||||
}
|
||||
}
|
||||
if(expr_string.size == 0)
|
||||
{
|
||||
expr_string = push_str8f(arena, ".%S", member_name);
|
||||
}
|
||||
scratch_end(scratch);
|
||||
}break;
|
||||
}
|
||||
}
|
||||
|
||||
// rjf: generate expression string based on our notable expression
|
||||
switch(notable_expr->kind)
|
||||
// rjf: use expression string / params to generate fancy strings
|
||||
if(is_non_code)
|
||||
{
|
||||
// rjf: default case -> just walk the expression tree & generate a string
|
||||
default:
|
||||
UI_TagF("weak")
|
||||
{
|
||||
expr_string = e_string_from_expr(arena, notable_expr, str8_zero());
|
||||
}break;
|
||||
|
||||
// rjf: array indices -> fast path to [index]
|
||||
case E_ExprKind_ArrayIndex:
|
||||
{
|
||||
expr_string = push_str8f(arena, "[%S]", e_string_from_expr(arena, notable_expr->last, str8_zero()));
|
||||
}break;
|
||||
|
||||
// rjf: member accesses -> fast-path to .name
|
||||
case E_ExprKind_MemberAccess:
|
||||
{
|
||||
Temp scratch = scratch_begin(&arena, 1);
|
||||
|
||||
// TODO(rjf): @cfg need to build inheritance tooltips
|
||||
#if 0
|
||||
if(member.inheritance_key_chain.count != 0)
|
||||
{
|
||||
String8List strings = {0};
|
||||
for(E_TypeKeyNode *n = member.inheritance_key_chain.first; n != 0; n = n->next)
|
||||
{
|
||||
String8 base_class_name = e_type_string_from_key(scratch.arena, n->v);
|
||||
str8_list_push(scratch.arena, &strings, base_class_name);
|
||||
}
|
||||
result.inheritance_tooltip = str8_list_join(arena, &strings, &(StringJoin){.sep = str8_lit_comp("::")});
|
||||
}
|
||||
#endif
|
||||
|
||||
// rjf: in meta-evaluation spaces, we will try to look up into our vocabulary map
|
||||
// to see if we have a fancy display string for this member. otherwise, we will just
|
||||
// do a code-string of ".member_name"
|
||||
String8 member_name = notable_expr->first->next->string;
|
||||
if(cell->eval.space.kind == RD_EvalSpaceKind_MetaCfg ||
|
||||
cell->eval.space.kind == RD_EvalSpaceKind_MetaCtrlEntity ||
|
||||
cell->eval.space.kind == E_SpaceKind_File ||
|
||||
cell->eval.space.kind == E_SpaceKind_FileSystem)
|
||||
{
|
||||
String8 fancy_name = rd_display_from_code_name(member_name);
|
||||
if(fancy_name.size != 0)
|
||||
{
|
||||
expr_string = fancy_name;
|
||||
is_non_code = 1;
|
||||
}
|
||||
}
|
||||
if(expr_string.size == 0)
|
||||
{
|
||||
expr_string = push_str8f(arena, ".%S", member_name);
|
||||
}
|
||||
scratch_end(scratch);
|
||||
}break;
|
||||
DR_FStrParams params = {rd_font_from_slot(RD_FontSlot_Main), rd_raster_flags_from_slot(RD_FontSlot_Main), ui_color_from_name(str8_lit("text")), font_size, 0, 0};
|
||||
dr_fstrs_push_new(arena, &result.fstrs, ¶ms, expr_string);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
result.fstrs = rd_fstrs_from_code_string(arena, 1, 0, ui_color_from_name(str8_lit("text")), expr_string);
|
||||
}
|
||||
}
|
||||
|
||||
// rjf: use expression string / params to generate fancy strings
|
||||
if(is_non_code)
|
||||
//- rjf: evaluation -> need to form value string
|
||||
if(!(cell->flags & RD_WatchCellFlag_NoEval))
|
||||
{
|
||||
UI_TagF("weak")
|
||||
// rjf: determine string generation parameters based on evaluation
|
||||
EV_StringParams string_params = {string_flags, 10};
|
||||
{
|
||||
if(cell->eval.space.kind == RD_EvalSpaceKind_MetaCfg ||
|
||||
cell->eval.space.kind == RD_EvalSpaceKind_MetaCtrlEntity)
|
||||
{
|
||||
string_params.flags |= EV_StringFlag_DisableStringQuotes|EV_StringFlag_DisableAddresses;
|
||||
}
|
||||
if(cell->eval.space.kind == RD_EvalSpaceKind_MetaCtrlEntity &&
|
||||
rd_ctrl_entity_from_eval_space(cell->eval.space)->kind == CTRL_EntityKind_Module)
|
||||
{
|
||||
string_params.radix = 16;
|
||||
}
|
||||
if(cell->eval.space.kind == RD_EvalSpaceKind_CtrlEntity &&
|
||||
rd_ctrl_entity_from_eval_space(cell->eval.space)->kind == CTRL_EntityKind_Thread)
|
||||
{
|
||||
string_params.radix = 16;
|
||||
}
|
||||
}
|
||||
|
||||
// rjf: determine if code
|
||||
B32 is_code = 1;
|
||||
{
|
||||
E_Type *type = e_type_from_key__cached(cell->eval.irtree.type_key);
|
||||
if(type->flags & (E_TypeFlag_IsPlainText|E_TypeFlag_IsPathText))
|
||||
{
|
||||
is_code = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// rjf: generate string based on that expression & fill
|
||||
String8 string = rd_value_string_from_eval(arena, rd_view_query_input(), &string_params, font, font_size, max_size_px, cell->eval);
|
||||
if(is_code)
|
||||
{
|
||||
result.fstrs = rd_fstrs_from_code_string(arena, 1, 0, ui_color_from_name(str8_lit("text")), string);
|
||||
}
|
||||
else UI_TagF("weak")
|
||||
{
|
||||
DR_FStrParams params = {rd_font_from_slot(RD_FontSlot_Main), rd_raster_flags_from_slot(RD_FontSlot_Main), ui_color_from_name(str8_lit("text")), font_size, 0, 0};
|
||||
dr_fstrs_push_new(arena, &result.fstrs, ¶ms, expr_string);
|
||||
dr_fstrs_push_new(arena, &result.fstrs, ¶ms, string);
|
||||
result.flags |= RD_WatchCellFlag_IsNonCode;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
result.fstrs = rd_fstrs_from_code_string(arena, 1, 0, ui_color_from_name(str8_lit("text")), expr_string);
|
||||
}
|
||||
}
|
||||
|
||||
//- rjf: evaluation -> need to form value string
|
||||
else if(cell->kind == RD_WatchCellKind_Eval)
|
||||
{
|
||||
// rjf: determine string generation parameters based on evaluation
|
||||
EV_StringParams string_params = {string_flags, 10};
|
||||
{
|
||||
if(cell->eval.space.kind == RD_EvalSpaceKind_MetaCfg ||
|
||||
cell->eval.space.kind == RD_EvalSpaceKind_MetaCtrlEntity)
|
||||
{
|
||||
string_params.flags |= EV_StringFlag_DisableStringQuotes|EV_StringFlag_DisableAddresses;
|
||||
}
|
||||
if(cell->eval.space.kind == RD_EvalSpaceKind_MetaCtrlEntity &&
|
||||
rd_ctrl_entity_from_eval_space(cell->eval.space)->kind == CTRL_EntityKind_Module)
|
||||
{
|
||||
string_params.radix = 16;
|
||||
}
|
||||
if(cell->eval.space.kind == RD_EvalSpaceKind_CtrlEntity &&
|
||||
rd_ctrl_entity_from_eval_space(cell->eval.space)->kind == CTRL_EntityKind_Thread)
|
||||
{
|
||||
string_params.radix = 16;
|
||||
}
|
||||
}
|
||||
|
||||
// rjf: determine if code
|
||||
B32 is_code = 1;
|
||||
{
|
||||
E_Type *type = e_type_from_key__cached(cell->eval.irtree.type_key);
|
||||
if(type->flags & (E_TypeFlag_IsPlainText|E_TypeFlag_IsPathText))
|
||||
{
|
||||
is_code = 0;
|
||||
}
|
||||
}
|
||||
|
||||
// rjf: generate string based on that expression & fill
|
||||
String8 string = rd_value_string_from_eval(arena, rd_view_query_input(), &string_params, font, font_size, max_size_px, cell->eval);
|
||||
if(is_code)
|
||||
{
|
||||
result.fstrs = rd_fstrs_from_code_string(arena, 1, 0, ui_color_from_name(str8_lit("text")), string);
|
||||
}
|
||||
else UI_TagF("weak")
|
||||
{
|
||||
DR_FStrParams params = {rd_font_from_slot(RD_FontSlot_Main), rd_raster_flags_from_slot(RD_FontSlot_Main), ui_color_from_name(str8_lit("text")), font_size, 0, 0};
|
||||
dr_fstrs_push_new(arena, &result.fstrs, ¶ms, string);
|
||||
result.flags |= RD_WatchCellFlag_IsNonCode;
|
||||
}
|
||||
}
|
||||
}break;
|
||||
|
||||
|
||||
+11
-10
@@ -43,9 +43,8 @@ struct RD_CodeViewBuildResult
|
||||
|
||||
typedef enum RD_WatchCellKind
|
||||
{
|
||||
RD_WatchCellKind_Expr, // strings to represent expression itself
|
||||
RD_WatchCellKind_Eval, // an evaluation of the expression, with some optional modification - e.g. `$expr.some_member`, or `typeof($expr)`
|
||||
RD_WatchCellKind_ViewUI, // an arbitrary user interface, supplied by a hook
|
||||
RD_WatchCellKind_Eval, // an evaluation cell
|
||||
RD_WatchCellKind_ViewUI, // an arbitrary user interface, supplied by a hook
|
||||
RD_WatchCellKind_CallStackFrame, // a slot for a yellow arrow, to show call stack frame selection
|
||||
}
|
||||
RD_WatchCellKind;
|
||||
@@ -53,13 +52,15 @@ RD_WatchCellKind;
|
||||
typedef U32 RD_WatchCellFlags;
|
||||
enum
|
||||
{
|
||||
RD_WatchCellFlag_Button = (1<<0),
|
||||
RD_WatchCellFlag_Background = (1<<1),
|
||||
RD_WatchCellFlag_ActivateWithSingleClick = (1<<2),
|
||||
RD_WatchCellFlag_IsNonCode = (1<<3),
|
||||
RD_WatchCellFlag_CanEdit = (1<<4),
|
||||
RD_WatchCellFlag_IsErrored = (1<<5),
|
||||
RD_WatchCellFlag_Indented = (1<<6),
|
||||
RD_WatchCellFlag_Expr = (1<<0),
|
||||
RD_WatchCellFlag_NoEval = (1<<1),
|
||||
RD_WatchCellFlag_Button = (1<<2),
|
||||
RD_WatchCellFlag_Background = (1<<3),
|
||||
RD_WatchCellFlag_ActivateWithSingleClick = (1<<4),
|
||||
RD_WatchCellFlag_IsNonCode = (1<<5),
|
||||
RD_WatchCellFlag_CanEdit = (1<<6),
|
||||
RD_WatchCellFlag_IsErrored = (1<<7),
|
||||
RD_WatchCellFlag_Indented = (1<<8),
|
||||
};
|
||||
|
||||
typedef struct RD_WatchCell RD_WatchCell;
|
||||
|
||||
Reference in New Issue
Block a user