always prefer explicitly attached tags (view rules); give all tags a chance in sequence; allow 'default' to be explicitly attached, to disable auto-view-rules etc.

This commit is contained in:
Ryan Fleury
2025-02-20 16:38:27 -08:00
parent ec782fa39c
commit 428a3f2536
6 changed files with 28 additions and 25 deletions
+10 -7
View File
@@ -483,6 +483,11 @@ e_lookup_rule_map_make(Arena *arena, U64 slots_count)
E_LookupRuleMap map = {0};
map.slots_count = slots_count;
map.slots = push_array(arena, E_LookupRuleSlot, map.slots_count);
e_lookup_rule_map_insert_new(arena, &map, str8_lit("default"),
.info = E_LOOKUP_INFO_FUNCTION_NAME(default),
.range = E_LOOKUP_RANGE_FUNCTION_NAME(default),
.id_from_num = E_LOOKUP_ID_FROM_NUM_FUNCTION_NAME(default),
.num_from_id = E_LOOKUP_NUM_FROM_ID_FUNCTION_NAME(default));
e_lookup_rule_map_insert_new(arena, &map, str8_lit("folder"),
.info = E_LOOKUP_INFO_FUNCTION_NAME(folder),
.range = E_LOOKUP_RANGE_FUNCTION_NAME(folder),
@@ -1031,10 +1036,11 @@ e_irgen_rule_map_make(Arena *arena, U64 slots_count)
E_IRGenRuleMap map = {0};
map.slots_count = slots_count;
map.slots = push_array(arena, E_IRGenRuleSlot, map.slots_count);
e_irgen_rule_map_insert_new(arena, &map, str8_lit("cast"), .irgen = E_IRGEN_FUNCTION_NAME(cast));
e_irgen_rule_map_insert_new(arena, &map, str8_lit("bswap"), .irgen = E_IRGEN_FUNCTION_NAME(bswap));
e_irgen_rule_map_insert_new(arena, &map, str8_lit("array"), .irgen = E_IRGEN_FUNCTION_NAME(array));
e_irgen_rule_map_insert_new(arena, &map, str8_lit("wrap"), .irgen = E_IRGEN_FUNCTION_NAME(wrap));
e_irgen_rule_map_insert_new(arena, &map, str8_lit("default"), .irgen = E_IRGEN_FUNCTION_NAME(default));
e_irgen_rule_map_insert_new(arena, &map, str8_lit("cast"), .irgen = E_IRGEN_FUNCTION_NAME(cast));
e_irgen_rule_map_insert_new(arena, &map, str8_lit("bswap"), .irgen = E_IRGEN_FUNCTION_NAME(bswap));
e_irgen_rule_map_insert_new(arena, &map, str8_lit("array"), .irgen = E_IRGEN_FUNCTION_NAME(array));
e_irgen_rule_map_insert_new(arena, &map, str8_lit("wrap"), .irgen = E_IRGEN_FUNCTION_NAME(wrap));
return map;
}
@@ -2391,7 +2397,6 @@ e_irtree_and_type_from_expr(Arena *arena, E_Expr *expr)
{
explicit_irgen_rule = irgen_rule_candidate;
explicit_irgen_rule_tag = tag;
break;
}
}
}
@@ -2776,7 +2781,6 @@ e_lookup_rule_tag_pair_from_expr_irtree(E_Expr *expr, E_IRTreeAndType *irtree)
{
result.rule = candidate;
result.tag = tag;
break;
}
}
}
@@ -2809,7 +2813,6 @@ e_lookup_rule_tag_pair_from_expr_irtree(E_Expr *expr, E_IRTreeAndType *irtree)
{
result.rule = candidate;
result.tag = n->v;
break;
}
}
}
@@ -489,16 +489,6 @@ ev_keyed_expr_push_tags(Arena *arena, EV_View *view, EV_Block *block, EV_Key key
}
}
// rjf: push explicitly-attached tags (via key) next
String8 tag_expr = push_str8_copy(arena, ev_view_rule_from_key(view, key));
E_TokenArray tag_expr_tokens = e_token_array_from_text(scratch.arena, tag_expr);
E_Parse tag_expr_parse = e_parse_expr_from_text_tokens(arena, tag_expr, &tag_expr_tokens);
for(E_Expr *tag = tag_expr_parse.exprs.first, *next = &e_expr_nil; tag != &e_expr_nil; tag = next)
{
next = tag->next;
e_expr_push_tag(expr, tag);
}
// rjf: push tags inferred from the type
{
E_IRTreeAndType irtree = e_irtree_and_type_from_expr(scratch.arena, expr);
@@ -508,6 +498,16 @@ ev_keyed_expr_push_tags(Arena *arena, EV_View *view, EV_Block *block, EV_Key key
e_expr_push_tag(expr, e_expr_copy(arena, n->v));
}
}
// rjf: push explicitly-attached tags (via key) next
String8 tag_expr = push_str8_copy(arena, ev_view_rule_from_key(view, key));
E_TokenArray tag_expr_tokens = e_token_array_from_text(scratch.arena, tag_expr);
E_Parse tag_expr_parse = e_parse_expr_from_text_tokens(arena, tag_expr, &tag_expr_tokens);
for(E_Expr *tag = tag_expr_parse.exprs.first, *next = &e_expr_nil; tag != &e_expr_nil; tag = next)
{
next = tag->next;
e_expr_push_tag(expr, tag);
}
}
scratch_end(scratch);
}
+1 -1
View File
@@ -308,7 +308,7 @@ RD_NameSchemaInfo rd_name_schema_info_table[12] =
{str8_lit_comp("breakpoint"), str8_lit_comp("@commands(enable_cfg, remove_cfg)\n@collection_commands(add_breakpoint, add_address_breakpoint, add_function_breakpoint)\nx:\n{\n 'label': code_string,\n 'condition': code_string,\n 'location': location,\n 'hit_count': u64,\n 'disabled': bool,\n}\n")},
{str8_lit_comp("watch_pin"), str8_lit_comp("@commands(remove_cfg)\n@collection_commands(add_watch_pin)\nx:\n{\n 'expression': code_string,\n 'view_rule': code_string,\n 'location': location,\n}\n")},
{str8_lit_comp("file_path_map"), str8_lit_comp("@collection_commands(add_file_path_map) @commands(remove_cfg) x:{'source':path, 'dest':path}")},
{str8_lit_comp("auto_view_rule"), str8_lit_comp("@collection_commands(add_auto_view_rule) @commands(remove_cfg) x:{'source':code_string, 'dest':code_string}")},
{str8_lit_comp("auto_view_rule"), str8_lit_comp("@collection_commands(add_auto_view_rule) @commands(remove_cfg) x:{'type':code_string, 'view_rule':code_string}")},
{str8_lit_comp("recent_project"), str8_lit_comp("x:{'path':path}")},
{str8_lit_comp("recent_file"), str8_lit_comp("x:{'path':path}")},
{str8_lit_comp("machine"), str8_lit_comp("x:{'label':code_string, 'frozen':bool, 'unattached_processes':query, 'processes':query}")},
+1 -1
View File
@@ -213,7 +213,7 @@ RD_VocabTable:
//- rjf: auto view rules
{
auto_view_rule,
```@collection_commands(add_auto_view_rule) @commands(remove_cfg) x:{'source':code_string, 'dest':code_string}```,
```@collection_commands(add_auto_view_rule) @commands(remove_cfg) x:{'type':code_string, 'view_rule':code_string}```,
}
//- rjf: recent projects
+2 -2
View File
@@ -11527,8 +11527,8 @@ rd_frame(void)
for(RD_CfgNode *n = auto_view_rules.first; n != 0; n = n->next)
{
RD_Cfg *rule = n->v;
String8 type_string = rd_cfg_child_from_string(rule, str8_lit("source"))->first->string;
String8 view_rule_string = rd_cfg_child_from_string(rule, str8_lit("dest"))->first->string;
String8 type_string = rd_cfg_child_from_string(rule, str8_lit("type"))->first->string;
String8 view_rule_string = rd_cfg_child_from_string(rule, str8_lit("view_rule"))->first->string;
e_auto_hook_map_insert_new(scratch.arena, ctx->auto_hook_map, .type_pattern = type_string, .tag_expr_string = view_rule_string);
}
}
+4 -4
View File
@@ -301,8 +301,8 @@ rd_title_fstrs_from_cfg(Arena *arena, RD_Cfg *cfg)
//- rjf: special case: auto view rule
if(str8_match(cfg->string, str8_lit("auto_view_rule"), 0))
{
String8 src_string = rd_cfg_child_from_string(cfg, str8_lit("source"))->first->string;
String8 dst_string = rd_cfg_child_from_string(cfg, str8_lit("dest"))->first->string;
String8 src_string = rd_cfg_child_from_string(cfg, str8_lit("type"))->first->string;
String8 dst_string = rd_cfg_child_from_string(cfg, str8_lit("view_rule"))->first->string;
Vec4F32 src_color = rgba;
Vec4F32 dst_color = rgba;
DR_FStrList src_fstrs = {0};
@@ -328,9 +328,9 @@ rd_title_fstrs_from_cfg(Arena *arena, RD_Cfg *cfg)
dst_fstrs = rd_fstrs_from_code_string(arena, 1.f, 0, dst_color, dst_string);
}
dr_fstrs_concat_in_place(&result, &src_fstrs);
dr_fstrs_push_new(arena, &result, &params, str8_lit(" "));
dr_fstrs_push_new(arena, &result, &params, str8_lit(" "));
dr_fstrs_push_new(arena, &result, &params, rd_icon_kind_text_table[RD_IconKind_RightArrow], .font = rd_font_from_slot(RD_FontSlot_Icons), .raster_flags = rd_raster_flags_from_slot(RD_FontSlot_Icons), .color = rgba_secondary);
dr_fstrs_push_new(arena, &result, &params, str8_lit(" "));
dr_fstrs_push_new(arena, &result, &params, str8_lit(" "));
dr_fstrs_concat_in_place(&result, &dst_fstrs);
}