allow implicit namespacification of identifier mapping path in eval parser, based on namespace of the procedure (if any) that the instruction pointer is currently within

This commit is contained in:
Ryan Fleury
2024-01-19 18:29:11 -08:00
parent d88000ddeb
commit f48d8431c0
2 changed files with 60 additions and 0 deletions
+47
View File
@@ -789,6 +789,35 @@ eval_parse_expr_from_text_tokens__prec(Arena *arena, EVAL_ParseCtx *ctx, String8
TG_Key type_key = zero_struct;
String8 local_lookup_string = token_string;
//- rjf: form namespaceify fallback
String8 namespaceified_token_string = token_string;
if(ctx->rdbg->procedures != 0 && ctx->rdbg->scopes != 0 && ctx->rdbg->scope_vmap != 0)
{
U64 scope_idx = raddbg_vmap_idx_from_voff(ctx->rdbg->scope_vmap, ctx->rdbg->scope_vmap_count, ctx->ip_voff);
RADDBG_Scope *scope = &ctx->rdbg->scopes[scope_idx];
U64 proc_idx = scope->proc_idx;
RADDBG_Procedure *procedure = &ctx->rdbg->procedures[proc_idx];
U64 name_size = 0;
U8 *name_ptr = raddbg_string_from_idx(ctx->rdbg, procedure->name_string_idx, &name_size);
String8 name = str8(name_ptr, name_size);
U64 past_scope_resolution_pos = 0;
for(;;)
{
U64 past_next_dbl_colon_pos = str8_find_needle(name, past_scope_resolution_pos, str8_lit("::"), 0)+2;
U64 past_next_dot_pos = str8_find_needle(name, 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 < name.size)
{
past_scope_resolution_pos = past_next_scope_resolution_pos;
}
else
{
break;
}
}
namespaceified_token_string = push_str8f(scratch.arena, "%S%S", str8_prefix(name, past_scope_resolution_pos), token_string);
}
//- rjf: try members
if(mapped_identifier == 0)
{
@@ -888,6 +917,12 @@ eval_parse_expr_from_text_tokens__prec(Arena *arena, EVAL_ParseCtx *ctx, String8
RADDBG_NameMapNode *node = raddbg_name_map_lookup(ctx->rdbg, &parsed_name_map, token_string.str, token_string.size);
U32 matches_count = 0;
U32 *matches = raddbg_matches_from_map_node(ctx->rdbg, node, &matches_count);
if(matches_count == 0)
{
node = raddbg_name_map_lookup(ctx->rdbg, &parsed_name_map, namespaceified_token_string.str, namespaceified_token_string.size);
matches_count = 0;
matches = raddbg_matches_from_map_node(ctx->rdbg, node, &matches_count);
}
if(matches_count != 0)
{
U32 match_idx = matches[0];
@@ -918,6 +953,12 @@ eval_parse_expr_from_text_tokens__prec(Arena *arena, EVAL_ParseCtx *ctx, String8
RADDBG_NameMapNode *node = raddbg_name_map_lookup(ctx->rdbg, &parsed_name_map, token_string.str, token_string.size);
U32 matches_count = 0;
U32 *matches = raddbg_matches_from_map_node(ctx->rdbg, node, &matches_count);
if(matches_count == 0)
{
node = raddbg_name_map_lookup(ctx->rdbg, &parsed_name_map, namespaceified_token_string.str, namespaceified_token_string.size);
matches_count = 0;
matches = raddbg_matches_from_map_node(ctx->rdbg, node, &matches_count);
}
if(matches_count != 0)
{
U32 match_idx = matches[0];
@@ -948,6 +989,12 @@ eval_parse_expr_from_text_tokens__prec(Arena *arena, EVAL_ParseCtx *ctx, String8
RADDBG_NameMapNode *node = raddbg_name_map_lookup(ctx->rdbg, &parsed_name_map, token_string.str, token_string.size);
U32 matches_count = 0;
U32 *matches = raddbg_matches_from_map_node(ctx->rdbg, node, &matches_count);
if(matches_count == 0)
{
node = raddbg_name_map_lookup(ctx->rdbg, &parsed_name_map, namespaceified_token_string.str, namespaceified_token_string.size);
matches_count = 0;
matches = raddbg_matches_from_map_node(ctx->rdbg, node, &matches_count);
}
if(matches_count != 0)
{
U32 match_idx = matches[0];
+13
View File
@@ -1,7 +1,20 @@
#include <fstream>
namespace SomeWeirdNamespace
{
int X = 0;
int Y = 0;
void Foo(void)
{
X = 123;
Y = 456;
int x = 0;
}
}
int main()
{
std::fstream temp;
SomeWeirdNamespace::Foo();
return 0;
}