From b154c5a120c82df61f5b0f0a176eaf2182a673a5 Mon Sep 17 00:00:00 2001 From: Ryan Fleury Date: Wed, 26 Mar 2025 14:57:54 -0700 Subject: [PATCH] use slightly looser mapping for auto-view-rules, to not generate false negatives when looking up --- src/eval/eval_ir.c | 10 +++---- src/eval/eval_ir.h | 2 +- .../eval_visualization_core.h | 28 ------------------- 3 files changed, 6 insertions(+), 34 deletions(-) diff --git a/src/eval/eval_ir.c b/src/eval/eval_ir.c index a20e36e9..06dd5356 100644 --- a/src/eval/eval_ir.c +++ b/src/eval/eval_ir.c @@ -1326,13 +1326,13 @@ e_auto_hook_map_insert_new_(Arena *arena, E_AutoHookMap *map, E_AutoHookParams * type_key = irtree.type_key; } E_AutoHookNode *node = push_array(arena, E_AutoHookNode, 1); - node->type_key = type_key; + node->type_string = str8_skip_chop_whitespace(e_type_string_from_key(arena, type_key)); U8 pattern_split = '?'; node->type_pattern_parts = str8_split(arena, params->type_pattern, &pattern_split, 1, StringSplitFlag_KeepEmpties); node->tag_exprs = e_parse_expr_from_text(arena, push_str8_copy(arena, params->tag_expr_string)).exprs; if(!e_type_key_match(e_type_key_zero(), type_key)) { - U64 hash = e_hash_from_string(5381, str8_struct(&type_key)); + U64 hash = e_hash_from_string(5381, node->type_string); U64 slot_idx = hash%map->slots_count; SLLQueuePush_N(map->slots[slot_idx].first, map->slots[slot_idx].last, node, hash_next); } @@ -1352,15 +1352,16 @@ e_auto_hook_tag_exprs_from_type_key(Arena *arena, E_TypeKey type_key) { Temp scratch = scratch_begin(&arena, 1); E_AutoHookMap *map = e_ir_state->ctx->auto_hook_map; + String8 type_string = str8_skip_chop_whitespace(e_type_string_from_key(scratch.arena, type_key)); //- rjf: gather exact-type-key-matches from the map if(map != 0 && map->slots_count != 0) { - U64 hash = e_hash_from_string(5381, str8_struct(&type_key)); + U64 hash = e_hash_from_string(5381, type_string); U64 slot_idx = hash%map->slots_count; for(E_AutoHookNode *n = map->slots[slot_idx].first; n != 0; n = n->hash_next) { - if(e_type_key_match(n->type_key, type_key)) + if(str8_match(n->type_string, type_string, 0)) { for(E_Expr *e = n->tag_exprs.first; e != &e_expr_nil; e = e->next) { @@ -1373,7 +1374,6 @@ e_auto_hook_tag_exprs_from_type_key(Arena *arena, E_TypeKey type_key) //- rjf: gather fuzzy matches from all patterns in the map if(map != 0 && map->first_pattern != 0) { - String8 type_string = str8_skip_chop_whitespace(e_type_string_from_key(scratch.arena, type_key)); for(E_AutoHookNode *auto_hook_node = map->first_pattern; auto_hook_node != 0; auto_hook_node = auto_hook_node->pattern_order_next) diff --git a/src/eval/eval_ir.h b/src/eval/eval_ir.h index d06cb232..93210498 100644 --- a/src/eval/eval_ir.h +++ b/src/eval/eval_ir.h @@ -188,7 +188,7 @@ struct E_AutoHookNode { E_AutoHookNode *hash_next; E_AutoHookNode *pattern_order_next; - E_TypeKey type_key; + String8 type_string; String8List type_pattern_parts; E_ExprChain tag_exprs; }; diff --git a/src/eval_visualization/eval_visualization_core.h b/src/eval_visualization/eval_visualization_core.h index 57e24759..e247c273 100644 --- a/src/eval_visualization/eval_visualization_core.h +++ b/src/eval_visualization/eval_visualization_core.h @@ -224,33 +224,6 @@ struct EV_WindowedRowList U64 count_before_semantic; }; -//////////////////////////////// -//~ rjf: Automatic Type -> View Rule Map Types - -typedef struct EV_AutoViewRuleNode EV_AutoViewRuleNode; -struct EV_AutoViewRuleNode -{ - EV_AutoViewRuleNode *next; - E_TypeKey key; - String8 view_rule; - B32 is_required; -}; - -typedef struct EV_AutoViewRuleSlot EV_AutoViewRuleSlot; -struct EV_AutoViewRuleSlot -{ - EV_AutoViewRuleNode *first; - EV_AutoViewRuleNode *last; - U64 count; -}; - -typedef struct EV_AutoViewRuleTable EV_AutoViewRuleTable; -struct EV_AutoViewRuleTable -{ - EV_AutoViewRuleSlot *slots; - U64 slots_count; -}; - //////////////////////////////// //~ rjf: Generated Code @@ -280,7 +253,6 @@ global read_only EV_ExpandRule ev_nil_expand_rule = EV_EXPAND_RULE_INFO_FUNCTION_NAME(nil), }; thread_static EV_ExpandRuleTable *ev_view_rule_info_table = 0; -thread_static EV_AutoViewRuleTable *ev_auto_view_rule_table = 0; global read_only EV_Block ev_nil_block = {&ev_nil_block, &ev_nil_block, &ev_nil_block, &ev_nil_block, &ev_nil_block, {0}, 0, {0}, &e_expr_nil, &e_expr_nil, &e_expr_nil, &e_lookup_rule__nil, &ev_nil_expand_rule}; ////////////////////////////////