implicit member access path

This commit is contained in:
Ryan Fleury
2025-04-30 16:38:25 -07:00
parent c473cdf3b8
commit 78928974cb
2 changed files with 33 additions and 46 deletions
+32 -38
View File
@@ -1564,34 +1564,7 @@ e_push_irtree_and_type_from_expr(Arena *arena, E_IRTreeAndType *root_parent, B32
}
}
//- rjf: form namespaceified fallback versions of this lookup string
String8List namespaceified_strings = {0};
if(!string_mapped)
{
E_Module *module = e_base_ctx->primary_module;
RDI_Parsed *rdi = module->rdi;
RDI_Procedure *procedure = e_cache->thread_ip_procedure;
U64 name_size = 0;
U8 *name_ptr = rdi_string_from_idx(rdi, procedure->name_string_idx, &name_size);
String8 containing_procedure_name = str8(name_ptr, name_size);
U64 last_past_scope_resolution_pos = 0;
for(;;)
{
U64 past_next_dbl_colon_pos = str8_find_needle(containing_procedure_name, last_past_scope_resolution_pos, str8_lit("::"), 0)+2;
U64 past_next_dot_pos = str8_find_needle(containing_procedure_name, last_past_scope_resolution_pos, str8_lit("."), 0)+1;
U64 past_next_scope_resolution_pos = Min(past_next_dbl_colon_pos, past_next_dot_pos);
if(past_next_scope_resolution_pos >= containing_procedure_name.size)
{
break;
}
String8 new_namespace_prefix_possibility = str8_prefix(containing_procedure_name, past_next_scope_resolution_pos);
String8 namespaceified_string = push_str8f(scratch.arena, "%S%S", new_namespace_prefix_possibility, string);
str8_list_push_front(scratch.arena, &namespaceified_strings, namespaceified_string);
last_past_scope_resolution_pos = past_next_scope_resolution_pos;
}
}
//- rjf: try to map name as member - if found, string__redirected := "this", and turn
//- rjf: try to map name as member of `this` - if found, string__redirected := "this", and turn
// on later implicit-member-lookup generation
B32 string_is_implicit_member_name = 0;
if(!string_mapped && (qualifier.size == 0 || str8_match(qualifier, str8_lit("member"), 0)))
@@ -1734,6 +1707,33 @@ e_push_irtree_and_type_from_expr(Arena *arena, E_IRTreeAndType *root_parent, B32
}
}
//- rjf: form namespaceified fallback versions of this lookup string
String8List namespaceified_strings = {0};
if(!string_mapped)
{
E_Module *module = e_base_ctx->primary_module;
RDI_Parsed *rdi = module->rdi;
RDI_Procedure *procedure = e_cache->thread_ip_procedure;
U64 name_size = 0;
U8 *name_ptr = rdi_string_from_idx(rdi, procedure->name_string_idx, &name_size);
String8 containing_procedure_name = str8(name_ptr, name_size);
U64 last_past_scope_resolution_pos = 0;
for(;;)
{
U64 past_next_dbl_colon_pos = str8_find_needle(containing_procedure_name, last_past_scope_resolution_pos, str8_lit("::"), 0)+2;
U64 past_next_dot_pos = str8_find_needle(containing_procedure_name, last_past_scope_resolution_pos, str8_lit("."), 0)+1;
U64 past_next_scope_resolution_pos = Min(past_next_dbl_colon_pos, past_next_dot_pos);
if(past_next_scope_resolution_pos >= containing_procedure_name.size)
{
break;
}
String8 new_namespace_prefix_possibility = str8_prefix(containing_procedure_name, past_next_scope_resolution_pos);
String8 namespaceified_string = push_str8f(scratch.arena, "%S%S", new_namespace_prefix_possibility, string);
str8_list_push_front(scratch.arena, &namespaceified_strings, namespaceified_string);
last_past_scope_resolution_pos = past_next_scope_resolution_pos;
}
}
//- rjf: try globals
if(!string_mapped && (qualifier.size == 0 || str8_match(qualifier, str8_lit("global"), 0)))
{
@@ -1952,17 +1952,11 @@ e_push_irtree_and_type_from_expr(Arena *arena, E_IRTreeAndType *root_parent, B32
}
}
//- rjf: extend generation with member access, if original string was an
// implicit member access
if(generated && string_is_implicit_member_name)
//- rjf: extend generated result, if result was generated by an implicit member access
if(string_is_implicit_member_name)
{
// TODO(rjf): @cfg
#if 0
E_LookupRule *lookup_rule = &e_lookup_rule__default;
E_LookupInfo lookup_info = lookup_rule->info(arena, &result, &e_expr_nil, str8_zero());
E_LookupAccess lookup_access = lookup_rule->access(arena, E_ExprKind_MemberAccess, lhs, rhs, &e_expr_nil, lookup_info.user_data);
result = lookup_access.irtree_and_type;
#endif
E_Expr *access = e_expr_irext_member_access(arena, &e_expr_nil, &result, string);
result = e_push_irtree_and_type_from_expr(arena, parent, disallow_autohooks, 1, access);
}
//- rjf: error on failure-to-generate
+1 -8
View File
@@ -4934,13 +4934,6 @@ rd_view_ui(Rng2F32 rect)
{
String8 input = str8(cell_edit_state->input_buffer, cell_edit_state->input_size);
rd_set_autocomp_regs(.ui_key = sig.box->key, .string = input, .cursor = cell_edit_state->cursor);
#if 0 // TODO(rjf): @cfg (autocompletion)
rd_set_autocomp_lister_query(.ui_key = sig.box->key,
.off_px = v2f32(0, dim_2f32(sig.box->rect).y),
.string = input,
.cursor = cell_edit_state->cursor,
.lister_flags = cell_autocomp_flags);
#endif
}
}
}
@@ -6631,7 +6624,7 @@ rd_window_frame(void)
RD_Cfg *input = rd_cfg_child_from_string_or_alloc(query, str8_lit("input"));
rd_cfg_new_replace(input, ws->autocomp_regs->string);
RD_Cfg *expr = rd_cfg_child_from_string_or_alloc(view, str8_lit("expression"));
rd_cfg_new_replacef(expr, "query:locals, query:procedures, query:types");
rd_cfg_new_replacef(expr, "query:locals, query:globals, query:thread_locals, query:procedures, query:types");
// rjf: determine container size
EV_BlockTree predicted_block_tree = {0};