From dc79c06031a7b5387ffc6957c24595bb289d3236 Mon Sep 17 00:00:00 2001 From: Ryan Fleury Date: Mon, 30 Jun 2025 09:33:23 -0700 Subject: [PATCH] adjust implicit accessing rules with nested auto hooks (slice-of-slices case); prefer to not show address value with string prefix content in single-line eval stringification --- src/eval/eval_ir.c | 20 ++++++++++++++----- src/eval/eval_types.c | 2 +- .../eval_visualization_core.c | 4 +++- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/src/eval/eval_ir.c b/src/eval/eval_ir.c index a7c59754..8f2aa277 100644 --- a/src/eval/eval_ir.c +++ b/src/eval/eval_ir.c @@ -686,10 +686,16 @@ e_push_irtree_and_type_from_expr(Arena *arena, E_IRTreeAndType *root_parent, E_I } // rjf: call into hook to do access - result = lhs_access(arena, parent, expr, lhs_irtree_try); + E_IRTreeAndType new_result_maybe = lhs_access(arena, parent, expr, lhs_irtree_try); - // rjf: end chain if we found a result - if(result.root != &e_irnode_nil) + // rjf: if we got a valid result -> store + if(new_result_maybe.root != &e_irnode_nil && (result.root == &e_irnode_nil || lhs_irtree_try->auto_hook == 0)) + { + result = new_result_maybe; + } + + // rjf: end chain if we found a result that is not an autohook + if(new_result_maybe.root != &e_irnode_nil && lhs_irtree_try->auto_hook == 0) { break; } @@ -1672,7 +1678,8 @@ e_push_irtree_and_type_from_expr(Arena *arena, E_IRTreeAndType *root_parent, E_I for(E_IRTreeAndType *prev = parent; prev != 0; prev = prev->prev) { E_Expr *access = e_expr_irext_member_access(scratch.arena, &e_expr_nil, prev, string); - E_IRTreeAndType access_irtree = e_push_irtree_and_type_from_expr(scratch.arena, root_parent, &e_default_identifier_resolution_rule, disallow_autohooks, 1, access); + E_IRTreeAndType access_parent = {&e_irnode_nil}; + E_IRTreeAndType access_irtree = e_push_irtree_and_type_from_expr(scratch.arena, prev->prev ? prev->prev : &access_parent, &e_default_identifier_resolution_rule, 1, 1, access); if(access_irtree.root != &e_irnode_nil) { string_mapped = 1; @@ -1681,7 +1688,10 @@ e_push_irtree_and_type_from_expr(Arena *arena, E_IRTreeAndType *root_parent, E_I mapped_bytecode = e_bytecode_from_oplist(arena, &oplist); mapped_bytecode_mode = access_irtree.mode; e_msg_list_concat_in_place(&result.msgs, &access_irtree.msgs); - break; + if(!prev->auto_hook) + { + break; + } } } }break; diff --git a/src/eval/eval_types.c b/src/eval/eval_types.c index 1dde0f1d..e045ef6e 100644 --- a/src/eval/eval_types.c +++ b/src/eval/eval_types.c @@ -2541,7 +2541,7 @@ E_TYPE_EXPAND_INFO_FUNCTION_DEF(array) { E_Type *type = e_type_from_key(eval.irtree.type_key); U64 count = 1; - if(type->args != 0 && type->count > 0) E_ParentKey(e_key_match(e_key_zero(), eval.parent_key) ? eval.key : eval.parent_key) + if(type->args != 0 && type->count > 0) E_ParentKey(eval.key) { E_Key count_key = e_key_from_expr(type->args[0]); E_Value count_value = e_value_from_key(count_key); diff --git a/src/eval_visualization/eval_visualization_core.c b/src/eval_visualization/eval_visualization_core.c index c6bbab59..34f56f76 100644 --- a/src/eval_visualization/eval_visualization_core.c +++ b/src/eval_visualization/eval_visualization_core.c @@ -1776,6 +1776,7 @@ ev_string_iter_next(Arena *arena, EV_StringIter *it, String8 *out_string) B32 ptee_has_content; B32 ptee_has_string; B32 did_prefix_content; + B32 did_prefix_string; B32 did_redirect; }; EV_StringPtrData *ptr_data = it->top_task->user_data; @@ -1862,6 +1863,7 @@ ev_string_iter_next(Arena *arena, EV_StringIter *it, String8 *out_string) // rjf: report *out_string = push_str8_copy(arena, string__escaped_and_quoted); ptr_data->did_prefix_content = 1; + ptr_data->did_prefix_string = 1; scratch_end(scratch); } @@ -2043,7 +2045,7 @@ ev_string_iter_next(Arena *arena, EV_StringIter *it, String8 *out_string) // // rjf: [read only] if we did prefix content, do a parenthesized pointer value - if(!(params->flags & EV_StringFlag_DisableAddresses) && params->flags & EV_StringFlag_ReadOnlyDisplayRules && ptr_data->did_prefix_content) + if(!(params->flags & EV_StringFlag_DisableAddresses) && params->flags & EV_StringFlag_ReadOnlyDisplayRules && ptr_data->did_prefix_content && !ptr_data->did_prefix_string) { *out_string = push_str8f(arena, " (%S)", ptr_value_string); }