use more stable IDs for ctrl entity evaluations

This commit is contained in:
Ryan Fleury
2025-04-28 10:25:37 -07:00
parent 93b1e3988d
commit 81425e8b90
6 changed files with 44 additions and 15 deletions
-10
View File
@@ -217,16 +217,6 @@ ctrl_handle_from_string(String8 string)
return handle; return handle;
} }
internal E_Eval
ctrl_eval_from_handle(CTRL_Handle handle)
{
Temp scratch = scratch_begin(0, 0);
String8 string = ctrl_string_from_handle(scratch.arena, handle);
E_Eval eval = e_eval_from_string(string);
scratch_end(scratch);
return eval;
}
//////////////////////////////// ////////////////////////////////
//~ rjf: Trap Type Functions //~ rjf: Trap Type Functions
-1
View File
@@ -771,7 +771,6 @@ internal void ctrl_handle_list_push(Arena *arena, CTRL_HandleList *list, CTRL_Ha
internal CTRL_HandleList ctrl_handle_list_copy(Arena *arena, CTRL_HandleList *src); internal CTRL_HandleList ctrl_handle_list_copy(Arena *arena, CTRL_HandleList *src);
internal String8 ctrl_string_from_handle(Arena *arena, CTRL_Handle handle); internal String8 ctrl_string_from_handle(Arena *arena, CTRL_Handle handle);
internal CTRL_Handle ctrl_handle_from_string(String8 string); internal CTRL_Handle ctrl_handle_from_string(String8 string);
internal E_Eval ctrl_eval_from_handle(CTRL_Handle handle);
//////////////////////////////// ////////////////////////////////
//~ rjf: Trap Type Functions //~ rjf: Trap Type Functions
+14 -2
View File
@@ -3269,7 +3269,7 @@ rd_view_ui(Rng2F32 rect)
case RD_EvalSpaceKind_MetaCtrlEntity: case RD_EvalSpaceKind_MetaCtrlEntity:
{ {
CTRL_Entity *entity = rd_ctrl_entity_from_eval_space(eval.space); CTRL_Entity *entity = rd_ctrl_entity_from_eval_space(eval.space);
rd_cmd(RD_CmdKind_PushQuery, .expr = ctrl_string_from_handle(scratch.arena, entity->handle)); rd_cmd(RD_CmdKind_PushQuery, .expr = push_str8f(scratch.arena, "query:control.%S", ctrl_string_from_handle(scratch.arena, entity->handle)));
}break; }break;
} }
if(did_cmd) if(did_cmd)
@@ -11995,6 +11995,19 @@ rd_frame(void)
e_string2typekey_map_insert(rd_frame_arena(), rd_state->meta_name2type_map, name, type_key); e_string2typekey_map_insert(rd_frame_arena(), rd_state->meta_name2type_map, name, type_key);
} }
//- rjf: add macro for top-level control root
{
String8 name = str8_lit("control");
E_TypeKey type_key = e_type_key_cons(.name = name,
.kind = E_TypeKind_Set,
.access = E_TYPE_ACCESS_FUNCTION_NAME(control));
E_Expr *expr = e_push_expr(scratch.arena, E_ExprKind_LeafOffset, 0);
expr->type_key = type_key;
expr->space = e_space_make(RD_EvalSpaceKind_MetaQuery);
e_string2expr_map_insert(scratch.arena, macro_map, name, expr);
e_string2typekey_map_insert(rd_frame_arena(), rd_state->meta_name2type_map, name, type_key);
}
//- rjf: add macros for config "slice" collections (targets, breakpoints, etc.) //- rjf: add macros for config "slice" collections (targets, breakpoints, etc.)
String8 evallable_cfg_names[] = String8 evallable_cfg_names[] =
{ {
@@ -12209,7 +12222,6 @@ rd_frame(void)
expr->space = space; expr->space = space;
expr->mode = E_Mode_Offset; expr->mode = E_Mode_Offset;
expr->type_key = type_key; expr->type_key = type_key;
e_string2expr_map_insert(scratch.arena, macro_map, ctrl_string_from_handle(scratch.arena, entity->handle), expr);
if(entity->string.size != 0) if(entity->string.size != 0)
{ {
e_string2expr_map_insert(scratch.arena, macro_map, entity->string, expr); e_string2expr_map_insert(scratch.arena, macro_map, entity->string, expr);
+24 -1
View File
@@ -554,6 +554,27 @@ E_TYPE_ACCESS_FUNCTION_DEF(cfgs)
return result; return result;
} }
////////////////////////////////
//~ rjf: Control Type Hooks
E_TYPE_ACCESS_FUNCTION_DEF(control)
{
E_IRTreeAndType result = {&e_irnode_nil};
E_Expr *rhs = expr->first->next;
if(rhs->kind == E_ExprKind_LeafIdentifier &&
str8_match(str8_prefix(rhs->string, 1), str8_lit("$"), 0))
{
CTRL_Handle handle = ctrl_handle_from_string(rhs->string);
CTRL_Entity *entity = ctrl_entity_from_handle(d_state->ctrl_entity_store, handle);
E_Space space = rd_eval_space_from_ctrl_entity(entity, RD_EvalSpaceKind_MetaCtrlEntity);
result.root = e_irtree_set_space(arena, space, e_irtree_const_u(arena, 0));
result.type_key = e_string2typekey_map_lookup(rd_state->meta_name2type_map, ctrl_entity_kind_code_name_table[entity->kind]);
result.mode = E_Mode_Offset;
}
return result;
}
//////////////////////////////// ////////////////////////////////
//~ rjf: Config Collection Type Hooks //~ rjf: Config Collection Type Hooks
@@ -1329,8 +1350,10 @@ E_TYPE_EXPAND_RANGE_FUNCTION_DEF(ctrl_entities)
U64 read_count = dim_1u64(read_range); U64 read_count = dim_1u64(read_range);
for(U64 out_idx = 0; out_idx < read_count; out_idx += 1) for(U64 out_idx = 0; out_idx < read_count; out_idx += 1)
{ {
Temp scratch = scratch_begin(&arena, 1);
CTRL_Entity *entity = entities->v[out_idx + read_range.min]; CTRL_Entity *entity = entities->v[out_idx + read_range.min];
evals_out[out_idx] = ctrl_eval_from_handle(entity->handle); evals_out[out_idx] = e_eval_from_stringf("query:control.%S", ctrl_string_from_handle(scratch.arena, entity->handle));
scratch_end(scratch);
} }
} }
+5
View File
@@ -36,6 +36,11 @@ E_TYPE_EXPAND_RANGE_FUNCTION_DEF(schema);
E_TYPE_ACCESS_FUNCTION_DEF(cfgs); E_TYPE_ACCESS_FUNCTION_DEF(cfgs);
////////////////////////////////
//~ rjf: Control Type Hooks
E_TYPE_ACCESS_FUNCTION_DEF(control);
//////////////////////////////// ////////////////////////////////
//~ rjf: Config Slice Type Hooks //~ rjf: Config Slice Type Hooks
+1 -1
View File
@@ -1387,7 +1387,7 @@ rd_watch_row_info_from_row(Arena *arena, EV_Row *row)
info.cell_style_key = str8_lit("call_stack_frame"); info.cell_style_key = str8_lit("call_stack_frame");
CTRL_Entity *process = ctrl_process_from_entity(info.callstack_thread); CTRL_Entity *process = ctrl_process_from_entity(info.callstack_thread);
CTRL_Entity *module = ctrl_module_from_process_vaddr(process, info.callstack_vaddr); CTRL_Entity *module = ctrl_module_from_process_vaddr(process, info.callstack_vaddr);
E_Eval module_eval = ctrl_eval_from_handle(module->handle); E_Eval module_eval = e_eval_from_stringf("query:control.%S", ctrl_string_from_handle(scratch.arena, module->handle));
RD_Cfg *view = rd_cfg_from_id(rd_regs()->view); RD_Cfg *view = rd_cfg_from_id(rd_regs()->view);
RD_Cfg *style = rd_cfg_child_from_string(view, info.cell_style_key); RD_Cfg *style = rd_cfg_child_from_string(view, info.cell_style_key);
RD_Cfg *w_cfg = style->first; RD_Cfg *w_cfg = style->first;