mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-08-05 13:28:40 +00:00
eliminate watches as a top-level entity, nest watch expressions under tabs - allow many watch windows, each with their own set of expressions.
This commit is contained in:
+115
-101
@@ -84,107 +84,6 @@ E_TYPE_EXPAND_RANGE_FUNCTION_DEF(commands)
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: `watches` Type Hooks
|
||||
|
||||
E_TYPE_EXPAND_INFO_FUNCTION_DEF(watches)
|
||||
{
|
||||
E_TypeExpandInfo result = {0};
|
||||
Temp scratch = scratch_begin(&arena, 1);
|
||||
{
|
||||
RD_CfgList cfgs_list = rd_cfg_top_level_list_from_string(scratch.arena, str8_lit("watch"));
|
||||
RD_CfgList cfgs_list__filtered = cfgs_list;
|
||||
if(filter.size != 0)
|
||||
{
|
||||
MemoryZeroStruct(&cfgs_list__filtered);
|
||||
for(RD_CfgNode *n = cfgs_list.first; n != 0; n = n->next)
|
||||
{
|
||||
String8 expr = rd_expr_from_cfg(n->v);
|
||||
B32 passes_filter = 1;
|
||||
if(filter.size != 0)
|
||||
{
|
||||
E_Eval eval = e_eval_from_string(expr);
|
||||
E_Type *type = e_type_from_key__cached(eval.irtree.type_key);
|
||||
if(type->kind != E_TypeKind_Set)
|
||||
{
|
||||
passes_filter = 0;
|
||||
FuzzyMatchRangeList matches = fuzzy_match_find(scratch.arena, filter, expr);
|
||||
if(matches.count == matches.needle_part_count)
|
||||
{
|
||||
passes_filter = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
if(passes_filter)
|
||||
{
|
||||
rd_cfg_list_push(scratch.arena, &cfgs_list__filtered, n->v);
|
||||
}
|
||||
}
|
||||
}
|
||||
RD_CfgArray *cfgs = push_array(arena, RD_CfgArray, 1);
|
||||
cfgs[0] = rd_cfg_array_from_list(arena, &cfgs_list__filtered);
|
||||
result.user_data = cfgs;
|
||||
result.expr_count = cfgs->count + 1;
|
||||
}
|
||||
scratch_end(scratch);
|
||||
return result;
|
||||
}
|
||||
|
||||
E_TYPE_EXPAND_RANGE_FUNCTION_DEF(watches)
|
||||
{
|
||||
RD_CfgArray *cfgs = (RD_CfgArray *)user_data;
|
||||
Rng1U64 legal_idx_range = r1u64(0, cfgs->count);
|
||||
Rng1U64 read_range = intersect_1u64(idx_range, legal_idx_range);
|
||||
U64 read_range_count = dim_1u64(read_range);
|
||||
for(U64 idx = 0; idx < read_range_count; idx += 1)
|
||||
{
|
||||
U64 cfg_idx = read_range.min + idx;
|
||||
if(cfg_idx < cfgs->count)
|
||||
{
|
||||
String8 expr_string = rd_cfg_child_from_string(cfgs->v[cfg_idx], str8_lit("expression"))->first->string;
|
||||
evals_out[idx] = e_eval_from_string(expr_string);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
E_TYPE_EXPAND_ID_FROM_NUM_FUNCTION_DEF(watches)
|
||||
{
|
||||
U64 id = 0;
|
||||
RD_CfgArray *cfgs = (RD_CfgArray *)user_data;
|
||||
if(1 <= num && num <= cfgs->count)
|
||||
{
|
||||
U64 idx = (num-1);
|
||||
id = cfgs->v[idx]->id;
|
||||
}
|
||||
else if(num == cfgs->count+1)
|
||||
{
|
||||
id = max_U64;
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
E_TYPE_EXPAND_NUM_FROM_ID_FUNCTION_DEF(watches)
|
||||
{
|
||||
U64 num = 0;
|
||||
RD_CfgArray *cfgs = (RD_CfgArray *)user_data;
|
||||
if(id != 0 && id != max_U64)
|
||||
{
|
||||
for EachIndex(idx, cfgs->count)
|
||||
{
|
||||
if(cfgs->v[idx]->id == id)
|
||||
{
|
||||
num = idx+1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(id == max_U64)
|
||||
{
|
||||
num = cfgs->count + 1;
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: `locals` Type Hooks
|
||||
|
||||
@@ -1028,6 +927,121 @@ E_TYPE_EXPAND_NUM_FROM_ID_FUNCTION_DEF(environment)
|
||||
return num;
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: `watches` Type Hooks
|
||||
|
||||
typedef struct RD_WatchesAccel RD_WatchesAccel;
|
||||
struct RD_WatchesAccel
|
||||
{
|
||||
RD_CfgArray cfgs;
|
||||
};
|
||||
|
||||
E_TYPE_IREXT_FUNCTION_DEF(watches)
|
||||
{
|
||||
RD_WatchesAccel *accel = push_array(arena, RD_WatchesAccel, 1);
|
||||
{
|
||||
Temp scratch = scratch_begin(&arena, 1);
|
||||
E_OpList oplist = e_oplist_from_irtree(scratch.arena, irtree->root);
|
||||
String8 bytecode = e_bytecode_from_oplist(scratch.arena, &oplist);
|
||||
E_Interpretation interpret = e_interpret(bytecode);
|
||||
E_Space space = interpret.space;
|
||||
RD_Cfg *target = rd_cfg_from_eval_space(space);
|
||||
RD_CfgList env_strings = {0};
|
||||
for(RD_Cfg *child = target->first; child != &rd_nil_cfg; child = child->next)
|
||||
{
|
||||
if(str8_match(child->string, str8_lit("watch"), 0))
|
||||
{
|
||||
rd_cfg_list_push(scratch.arena, &env_strings, child);
|
||||
}
|
||||
}
|
||||
accel->cfgs = rd_cfg_array_from_list(arena, &env_strings);
|
||||
scratch_end(scratch);
|
||||
}
|
||||
E_IRExt result = {accel};
|
||||
return result;
|
||||
}
|
||||
|
||||
E_TYPE_ACCESS_FUNCTION_DEF(watches)
|
||||
{
|
||||
E_IRTreeAndType result = {&e_irnode_nil};
|
||||
if(expr->kind == E_ExprKind_ArrayIndex)
|
||||
{
|
||||
RD_WatchesAccel *accel = (RD_WatchesAccel *)lhs_irtree->user_data;
|
||||
RD_CfgArray *cfgs = &accel->cfgs;
|
||||
E_Value rhs_value = e_value_from_expr(expr->first->next);
|
||||
if(0 <= rhs_value.u64 && rhs_value.u64 < cfgs->count)
|
||||
{
|
||||
RD_Cfg *cfg = cfgs->v[rhs_value.u64];
|
||||
result.root = e_irtree_set_space(arena, rd_eval_space_from_cfg(cfg), e_irtree_const_u(arena, 0));
|
||||
result.type_key = e_type_key_cons_array(e_type_key_basic(E_TypeKind_U8), cfg->first->string.size, E_TypeFlag_IsCodeText);
|
||||
result.mode = E_Mode_Offset;
|
||||
}
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
E_TYPE_EXPAND_INFO_FUNCTION_DEF(watches)
|
||||
{
|
||||
RD_WatchesAccel *accel = (RD_WatchesAccel *)eval.irtree.user_data;
|
||||
E_TypeExpandInfo result = {accel, accel->cfgs.count + 1};
|
||||
return result;
|
||||
}
|
||||
|
||||
E_TYPE_EXPAND_RANGE_FUNCTION_DEF(watches)
|
||||
{
|
||||
RD_WatchesAccel *accel = (RD_WatchesAccel *)user_data;
|
||||
Rng1U64 legal_idx_range = r1u64(0, accel->cfgs.count);
|
||||
Rng1U64 read_range = intersect_1u64(idx_range, legal_idx_range);
|
||||
U64 read_range_count = dim_1u64(read_range);
|
||||
for(U64 idx = 0; idx < read_range_count; idx += 1)
|
||||
{
|
||||
U64 cfg_idx = read_range.min + idx;
|
||||
if(cfg_idx < accel->cfgs.count)
|
||||
{
|
||||
RD_Cfg *cfg = accel->cfgs.v[cfg_idx];
|
||||
evals_out[idx] = e_eval_from_string(cfg->first->string);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
E_TYPE_EXPAND_ID_FROM_NUM_FUNCTION_DEF(watches)
|
||||
{
|
||||
U64 id = 0;
|
||||
RD_WatchesAccel *accel = (RD_WatchesAccel *)user_data;
|
||||
if(1 <= num && num <= accel->cfgs.count)
|
||||
{
|
||||
U64 idx = (num-1);
|
||||
id = accel->cfgs.v[idx]->id;
|
||||
}
|
||||
else if(num == accel->cfgs.count+1)
|
||||
{
|
||||
id = max_U64;
|
||||
}
|
||||
return id;
|
||||
}
|
||||
|
||||
E_TYPE_EXPAND_NUM_FROM_ID_FUNCTION_DEF(watches)
|
||||
{
|
||||
U64 num = 0;
|
||||
RD_WatchesAccel *accel = (RD_WatchesAccel *)user_data;
|
||||
if(id != 0 && id != max_U64)
|
||||
{
|
||||
for EachIndex(idx, accel->cfgs.count)
|
||||
{
|
||||
if(accel->cfgs.v[idx]->id == id)
|
||||
{
|
||||
num = idx+1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
else if(id == max_U64)
|
||||
{
|
||||
num = accel->cfgs.count + 1;
|
||||
}
|
||||
return num;
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: `unattached_processes` Type Hooks
|
||||
|
||||
|
||||
Reference in New Issue
Block a user