mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-07-11 03:51:26 -07:00
rdi: first pass of eliminating remainder of non-top-level sections; simplification/cleanup of rdi parsing layer
This commit is contained in:
+115
-155
@@ -73,10 +73,9 @@ eval_push_locals_map_from_rdi_voff(Arena *arena, RDI_Parsed *rdi, U64 voff)
|
||||
|
||||
//- rjf: voff -> tightest scope
|
||||
RDI_Scope *tightest_scope = 0;
|
||||
if(rdi->scope_vmap != 0 && rdi->scopes != 0)
|
||||
{
|
||||
U64 scope_idx = rdi_vmap_idx_from_voff(rdi->scope_vmap, rdi->scope_vmap_count, voff);
|
||||
RDI_Scope *scope = &rdi->scopes[scope_idx];
|
||||
U64 scope_idx = rdi_vmap_idx_from_section_kind_voff(rdi, RDI_SectionKind_ScopeVMap, voff);
|
||||
RDI_Scope *scope = rdi_element_from_name_idx(rdi, Scopes, scope_idx);
|
||||
Task *task = push_array(scratch.arena, Task, 1);
|
||||
task->scope = scope;
|
||||
SLLQueuePush(first_task, last_task, task);
|
||||
@@ -84,10 +83,10 @@ eval_push_locals_map_from_rdi_voff(Arena *arena, RDI_Parsed *rdi, U64 voff)
|
||||
}
|
||||
|
||||
//- rjf: voff-1 -> scope
|
||||
if(voff > 0 && rdi->scope_vmap != 0 && rdi->scopes != 0)
|
||||
if(voff > 0)
|
||||
{
|
||||
U64 scope_idx = rdi_vmap_idx_from_voff(rdi->scope_vmap, rdi->scope_vmap_count, voff-1);
|
||||
RDI_Scope *scope = &rdi->scopes[scope_idx];
|
||||
U64 scope_idx = rdi_vmap_idx_from_section_kind_voff(rdi, RDI_SectionKind_ScopeVMap, voff-1);
|
||||
RDI_Scope *scope = rdi_element_from_name_idx(rdi, Scopes, scope_idx);
|
||||
if(scope != tightest_scope)
|
||||
{
|
||||
Task *task = push_array(scratch.arena, Task, 1);
|
||||
@@ -99,9 +98,10 @@ eval_push_locals_map_from_rdi_voff(Arena *arena, RDI_Parsed *rdi, U64 voff)
|
||||
//- rjf: tightest scope -> walk up the tree & build tasks for each parent scope
|
||||
if(tightest_scope != 0)
|
||||
{
|
||||
for(RDI_Scope *scope = &rdi->scopes[tightest_scope->parent_scope_idx];
|
||||
scope != 0 && scope != &rdi->scopes[0];
|
||||
scope = &rdi->scopes[scope->parent_scope_idx])
|
||||
RDI_Scope *nil_scope = rdi_element_from_name_idx(rdi, Scopes, 0);
|
||||
for(RDI_Scope *scope = rdi_element_from_name_idx(rdi, Scopes, tightest_scope->parent_scope_idx);
|
||||
scope != 0 && scope != nil_scope;
|
||||
scope = rdi_element_from_name_idx(rdi, Scopes, scope->parent_scope_idx))
|
||||
{
|
||||
Task *task = push_array(scratch.arena, Task, 1);
|
||||
task->scope = scope;
|
||||
@@ -122,7 +122,7 @@ eval_push_locals_map_from_rdi_voff(Arena *arena, RDI_Parsed *rdi, U64 voff)
|
||||
U32 local_opl_idx = scope->local_first + scope->local_count;
|
||||
for(U32 local_idx = scope->local_first; local_idx < local_opl_idx; local_idx += 1)
|
||||
{
|
||||
RDI_Local *local_var = &rdi->locals[local_idx];
|
||||
RDI_Local *local_var = rdi_element_from_name_idx(rdi, Locals, local_idx);
|
||||
U64 local_name_size = 0;
|
||||
U8 *local_name_str = rdi_string_from_idx(rdi, local_var->name_string_idx, &local_name_size);
|
||||
String8 name = push_str8_copy(arena, str8(local_name_str, local_name_size));
|
||||
@@ -139,52 +139,30 @@ internal EVAL_String2NumMap *
|
||||
eval_push_member_map_from_rdi_voff(Arena *arena, RDI_Parsed *rdi, U64 voff)
|
||||
{
|
||||
//- rjf: voff -> tightest scope
|
||||
RDI_Scope *tightest_scope = 0;
|
||||
if(rdi->scope_vmap != 0 && rdi->scopes != 0)
|
||||
{
|
||||
U64 scope_idx = rdi_vmap_idx_from_voff(rdi->scope_vmap, rdi->scope_vmap_count, voff);
|
||||
tightest_scope = &rdi->scopes[scope_idx];
|
||||
}
|
||||
U64 scope_idx = rdi_vmap_idx_from_section_kind_voff(rdi, RDI_SectionKind_ScopeVMap, voff);
|
||||
RDI_Scope *tightest_scope = rdi_element_from_name_idx(rdi, Scopes, scope_idx);
|
||||
|
||||
//- rjf: tightest scope -> procedure
|
||||
RDI_Procedure *procedure = 0;
|
||||
if(tightest_scope != 0 && rdi->procedures != 0)
|
||||
{
|
||||
U32 proc_idx = tightest_scope->proc_idx;
|
||||
if(0 < proc_idx && proc_idx < rdi->procedures_count)
|
||||
{
|
||||
procedure = &rdi->procedures[proc_idx];
|
||||
}
|
||||
}
|
||||
U32 proc_idx = tightest_scope->proc_idx;
|
||||
RDI_Procedure *procedure = rdi_element_from_name_idx(rdi, Procedures, proc_idx);
|
||||
|
||||
//- rjf: procedure -> udt
|
||||
RDI_UDT *udt = 0;
|
||||
if(procedure != 0 && rdi->udts != 0 && procedure->link_flags & RDI_LinkFlag_TypeScoped)
|
||||
{
|
||||
U32 udt_idx = procedure->container_idx;
|
||||
if(0 < udt_idx && udt_idx < rdi->udts_count)
|
||||
{
|
||||
udt = &rdi->udts[udt_idx];
|
||||
}
|
||||
}
|
||||
U32 udt_idx = procedure->container_idx;
|
||||
RDI_UDT *udt = rdi_element_from_name_idx(rdi, UDTs, udt_idx);
|
||||
|
||||
//- rjf: build blank map
|
||||
EVAL_String2NumMap *map = push_array(arena, EVAL_String2NumMap, 1);
|
||||
*map = eval_string2num_map_make(arena, 64);
|
||||
|
||||
//- rjf: udt -> fill member map
|
||||
if(udt != 0 && !(udt->flags & RDI_UDTFlag_EnumMembers) && rdi->members != 0)
|
||||
if(!(udt->flags & RDI_UDTFlag_EnumMembers))
|
||||
{
|
||||
U64 data_member_num = 1;
|
||||
for(U32 member_idx = udt->member_first;
|
||||
member_idx < udt->member_first+udt->member_count;
|
||||
member_idx += 1)
|
||||
{
|
||||
if(member_idx < 1 || rdi->members_count <= member_idx)
|
||||
{
|
||||
break;
|
||||
}
|
||||
RDI_Member *m = &rdi->members[member_idx];
|
||||
RDI_Member *m = rdi_element_from_name_idx(rdi, Members, member_idx);
|
||||
if(m->kind == RDI_MemberKind_DataField)
|
||||
{
|
||||
String8 name = {0};
|
||||
@@ -476,11 +454,10 @@ eval_leaf_type_from_name(RDI_Parsed *rdi, String8 name)
|
||||
{
|
||||
TG_Key key = zero_struct;
|
||||
B32 found = 0;
|
||||
if(rdi->type_nodes != 0)
|
||||
{
|
||||
RDI_NameMap *name_map = rdi_name_map_from_kind(rdi, RDI_NameMapKind_Types);
|
||||
RDI_NameMap *name_map = rdi_element_from_name_idx(rdi, NameMaps, RDI_NameMapKind_Types);
|
||||
RDI_ParsedNameMap parsed_name_map = {0};
|
||||
rdi_name_map_parse(rdi, name_map, &parsed_name_map);
|
||||
rdi_parsed_from_name_map(rdi, name_map, &parsed_name_map);
|
||||
RDI_NameMapNode *node = rdi_name_map_lookup(rdi, &parsed_name_map, name.str, name.size);
|
||||
if(node != 0)
|
||||
{
|
||||
@@ -488,7 +465,7 @@ eval_leaf_type_from_name(RDI_Parsed *rdi, String8 name)
|
||||
U32 *matches = rdi_matches_from_map_node(rdi, node, &match_count);
|
||||
if(match_count != 0)
|
||||
{
|
||||
RDI_TypeNode *type_node = rdi_element_from_idx(rdi, type_nodes, matches[0]);
|
||||
RDI_TypeNode *type_node = rdi_element_from_name_idx(rdi, TypeNodes, matches[0]);
|
||||
found = type_node->kind != RDI_TypeKind_NULL;
|
||||
key = tg_key_ext(tg_kind_from_rdi_type_kind(type_node->kind), (U64)matches[0]);
|
||||
}
|
||||
@@ -838,12 +815,11 @@ eval_parse_expr_from_text_tokens__prec(Arena *arena, EVAL_ParseCtx *ctx, String8
|
||||
|
||||
//- rjf: form namespaceified fallback versions of this lookup string
|
||||
String8List namespaceified_token_strings = {0};
|
||||
if(ctx->rdi->procedures != 0 && ctx->rdi->scopes != 0 && ctx->rdi->scope_vmap != 0)
|
||||
{
|
||||
U64 scope_idx = rdi_vmap_idx_from_voff(ctx->rdi->scope_vmap, ctx->rdi->scope_vmap_count, ctx->ip_voff);
|
||||
RDI_Scope *scope = &ctx->rdi->scopes[scope_idx];
|
||||
U64 scope_idx = rdi_vmap_idx_from_section_kind_voff(ctx->rdi, RDI_SectionKind_ScopeVMap, ctx->ip_voff);
|
||||
RDI_Scope *scope = rdi_element_from_name_idx(ctx->rdi, Scopes, scope_idx);
|
||||
U64 proc_idx = scope->proc_idx;
|
||||
RDI_Procedure *procedure = &ctx->rdi->procedures[proc_idx];
|
||||
RDI_Procedure *procedure = rdi_element_from_name_idx(ctx->rdi, Procedures, proc_idx);
|
||||
U64 name_size = 0;
|
||||
U8 *name_ptr = rdi_string_from_idx(ctx->rdi, procedure->name_string_idx, &name_size);
|
||||
String8 containing_procedure_name = str8(name_ptr, name_size);
|
||||
@@ -883,8 +859,8 @@ eval_parse_expr_from_text_tokens__prec(Arena *arena, EVAL_ParseCtx *ctx, String8
|
||||
{
|
||||
mapped_identifier = 1;
|
||||
identifier_type_is_possibly_dynamically_overridden = 1;
|
||||
RDI_Local *local_var = rdi_element_from_idx(ctx->rdi, locals, local_num-1);
|
||||
RDI_TypeNode *type_node = rdi_element_from_idx(ctx->rdi, type_nodes, local_var->type_idx);
|
||||
RDI_Local *local_var = rdi_element_from_name_idx(ctx->rdi, Locals, local_num-1);
|
||||
RDI_TypeNode *type_node = rdi_element_from_name_idx(ctx->rdi, TypeNodes, local_var->type_idx);
|
||||
type_key = tg_key_ext(tg_kind_from_rdi_type_kind(type_node->kind), (U64)local_var->type_idx);
|
||||
|
||||
// rjf: grab location info
|
||||
@@ -892,19 +868,21 @@ eval_parse_expr_from_text_tokens__prec(Arena *arena, EVAL_ParseCtx *ctx, String8
|
||||
loc_block_idx < local_var->location_opl;
|
||||
loc_block_idx += 1)
|
||||
{
|
||||
RDI_LocationBlock *block = &ctx->rdi->location_blocks[loc_block_idx];
|
||||
RDI_LocationBlock *block = rdi_element_from_name_idx(ctx->rdi, LocationBlocks, loc_block_idx);
|
||||
if(block->scope_off_first <= ctx->ip_voff && ctx->ip_voff < block->scope_off_opl)
|
||||
{
|
||||
loc_kind = *((RDI_LocationKind *)(ctx->rdi->location_data + block->location_data_off));
|
||||
U64 all_location_data_size = 0;
|
||||
U8 *all_location_data = rdi_table_from_name(ctx->rdi, LocationData, &all_location_data_size);
|
||||
loc_kind = *((RDI_LocationKind *)(all_location_data + block->location_data_off));
|
||||
switch(loc_kind)
|
||||
{
|
||||
default:{mapped_identifier = 0;}break;
|
||||
case RDI_LocationKind_AddrBytecodeStream:
|
||||
case RDI_LocationKind_ValBytecodeStream:
|
||||
{
|
||||
U8 *bytecode_base = ctx->rdi->location_data + block->location_data_off + sizeof(RDI_LocationKind);
|
||||
U8 *bytecode_base = all_location_data + block->location_data_off + sizeof(RDI_LocationKind);
|
||||
U64 bytecode_size = 0;
|
||||
for(U64 idx = 0; idx < ctx->rdi->location_data_size; idx += 1)
|
||||
for(U64 idx = 0; idx < all_location_data_size; idx += 1)
|
||||
{
|
||||
U8 op = bytecode_base[idx];
|
||||
if(op == 0)
|
||||
@@ -920,11 +898,11 @@ eval_parse_expr_from_text_tokens__prec(Arena *arena, EVAL_ParseCtx *ctx, String8
|
||||
case RDI_LocationKind_AddrRegPlusU16:
|
||||
case RDI_LocationKind_AddrAddrRegPlusU16:
|
||||
{
|
||||
MemoryCopy(&loc_reg_u16, (ctx->rdi->location_data + block->location_data_off), sizeof(loc_reg_u16));
|
||||
MemoryCopy(&loc_reg_u16, (all_location_data + block->location_data_off), sizeof(loc_reg_u16));
|
||||
}break;
|
||||
case RDI_LocationKind_ValReg:
|
||||
{
|
||||
MemoryCopy(&loc_reg, (ctx->rdi->location_data + block->location_data_off), sizeof(loc_reg));
|
||||
MemoryCopy(&loc_reg, (all_location_data + block->location_data_off), sizeof(loc_reg));
|
||||
}break;
|
||||
}
|
||||
}
|
||||
@@ -959,120 +937,102 @@ eval_parse_expr_from_text_tokens__prec(Arena *arena, EVAL_ParseCtx *ctx, String8
|
||||
//- rjf: try global variables
|
||||
if(mapped_identifier == 0)
|
||||
{
|
||||
RDI_NameMap *name_map = rdi_name_map_from_kind(ctx->rdi, RDI_NameMapKind_GlobalVariables);
|
||||
if(name_map != 0 && ctx->rdi->global_variables != 0)
|
||||
RDI_NameMap *name_map = rdi_element_from_name_idx(ctx->rdi, NameMaps, RDI_NameMapKind_GlobalVariables);
|
||||
RDI_ParsedNameMap parsed_name_map = {0};
|
||||
rdi_parsed_from_name_map(ctx->rdi, name_map, &parsed_name_map);
|
||||
RDI_NameMapNode *node = rdi_name_map_lookup(ctx->rdi, &parsed_name_map, token_string.str, token_string.size);
|
||||
U32 matches_count = 0;
|
||||
U32 *matches = rdi_matches_from_map_node(ctx->rdi, node, &matches_count);
|
||||
for(String8Node *n = namespaceified_token_strings.first;
|
||||
n != 0 && matches_count == 0;
|
||||
n = n->next)
|
||||
{
|
||||
RDI_ParsedNameMap parsed_name_map = {0};
|
||||
rdi_name_map_parse(ctx->rdi, name_map, &parsed_name_map);
|
||||
RDI_NameMapNode *node = rdi_name_map_lookup(ctx->rdi, &parsed_name_map, token_string.str, token_string.size);
|
||||
U32 matches_count = 0;
|
||||
U32 *matches = rdi_matches_from_map_node(ctx->rdi, node, &matches_count);
|
||||
for(String8Node *n = namespaceified_token_strings.first;
|
||||
n != 0 && matches_count == 0;
|
||||
n = n->next)
|
||||
{
|
||||
node = rdi_name_map_lookup(ctx->rdi, &parsed_name_map, n->string.str, n->string.size);
|
||||
matches_count = 0;
|
||||
matches = rdi_matches_from_map_node(ctx->rdi, node, &matches_count);
|
||||
}
|
||||
if(matches_count != 0)
|
||||
{
|
||||
// NOTE(rjf): apparently, PDBs can be produced such that they
|
||||
// also keep stale *GLOBAL VARIABLE SYMBOLS* around too. I
|
||||
// don't know of a magic hash table fixup path in PDBs, so
|
||||
// in this case, I'm going to prefer the latest-added global.
|
||||
U32 match_idx = matches[matches_count-1];
|
||||
RDI_GlobalVariable *global_var = &ctx->rdi->global_variables[match_idx];
|
||||
EVAL_OpList oplist = {0};
|
||||
eval_oplist_push_op(arena, &oplist, RDI_EvalOp_ModuleOff, global_var->voff);
|
||||
loc_kind = RDI_LocationKind_AddrBytecodeStream;
|
||||
loc_bytecode = eval_bytecode_from_oplist(arena, &oplist);
|
||||
U32 type_idx = global_var->type_idx;
|
||||
if(type_idx < ctx->rdi->type_nodes_count)
|
||||
{
|
||||
RDI_TypeNode *type_node = &ctx->rdi->type_nodes[type_idx];
|
||||
type_key = tg_key_ext(tg_kind_from_rdi_type_kind(type_node->kind), (U64)type_idx);
|
||||
}
|
||||
mapped_identifier = 1;
|
||||
}
|
||||
node = rdi_name_map_lookup(ctx->rdi, &parsed_name_map, n->string.str, n->string.size);
|
||||
matches_count = 0;
|
||||
matches = rdi_matches_from_map_node(ctx->rdi, node, &matches_count);
|
||||
}
|
||||
if(matches_count != 0)
|
||||
{
|
||||
// NOTE(rjf): apparently, PDBs can be produced such that they
|
||||
// also keep stale *GLOBAL VARIABLE SYMBOLS* around too. I
|
||||
// don't know of a magic hash table fixup path in PDBs, so
|
||||
// in this case, I'm going to prefer the latest-added global.
|
||||
U32 match_idx = matches[matches_count-1];
|
||||
RDI_GlobalVariable *global_var = rdi_element_from_name_idx(ctx->rdi, GlobalVariables, match_idx);
|
||||
EVAL_OpList oplist = {0};
|
||||
eval_oplist_push_op(arena, &oplist, RDI_EvalOp_ModuleOff, global_var->voff);
|
||||
loc_kind = RDI_LocationKind_AddrBytecodeStream;
|
||||
loc_bytecode = eval_bytecode_from_oplist(arena, &oplist);
|
||||
U32 type_idx = global_var->type_idx;
|
||||
RDI_TypeNode *type_node = rdi_element_from_name_idx(ctx->rdi, TypeNodes, type_idx);
|
||||
type_key = tg_key_ext(tg_kind_from_rdi_type_kind(type_node->kind), (U64)type_idx);
|
||||
mapped_identifier = 1;
|
||||
}
|
||||
}
|
||||
|
||||
//- rjf: try thread variables
|
||||
if(mapped_identifier == 0)
|
||||
{
|
||||
RDI_NameMap *name_map = rdi_name_map_from_kind(ctx->rdi, RDI_NameMapKind_ThreadVariables);
|
||||
if(name_map != 0 && ctx->rdi->global_variables != 0)
|
||||
RDI_NameMap *name_map = rdi_element_from_name_idx(ctx->rdi, NameMaps, RDI_NameMapKind_ThreadVariables);
|
||||
RDI_ParsedNameMap parsed_name_map = {0};
|
||||
rdi_parsed_from_name_map(ctx->rdi, name_map, &parsed_name_map);
|
||||
RDI_NameMapNode *node = rdi_name_map_lookup(ctx->rdi, &parsed_name_map, token_string.str, token_string.size);
|
||||
U32 matches_count = 0;
|
||||
U32 *matches = rdi_matches_from_map_node(ctx->rdi, node, &matches_count);
|
||||
for(String8Node *n = namespaceified_token_strings.first;
|
||||
n != 0 && matches_count == 0;
|
||||
n = n->next)
|
||||
{
|
||||
RDI_ParsedNameMap parsed_name_map = {0};
|
||||
rdi_name_map_parse(ctx->rdi, name_map, &parsed_name_map);
|
||||
RDI_NameMapNode *node = rdi_name_map_lookup(ctx->rdi, &parsed_name_map, token_string.str, token_string.size);
|
||||
U32 matches_count = 0;
|
||||
U32 *matches = rdi_matches_from_map_node(ctx->rdi, node, &matches_count);
|
||||
for(String8Node *n = namespaceified_token_strings.first;
|
||||
n != 0 && matches_count == 0;
|
||||
n = n->next)
|
||||
{
|
||||
node = rdi_name_map_lookup(ctx->rdi, &parsed_name_map, n->string.str, n->string.size);
|
||||
matches_count = 0;
|
||||
matches = rdi_matches_from_map_node(ctx->rdi, node, &matches_count);
|
||||
}
|
||||
if(matches_count != 0)
|
||||
{
|
||||
U32 match_idx = matches[0];
|
||||
RDI_ThreadVariable *thread_var = &ctx->rdi->thread_variables[match_idx];
|
||||
EVAL_OpList oplist = {0};
|
||||
eval_oplist_push_op(arena, &oplist, RDI_EvalOp_TLSOff, thread_var->tls_off);
|
||||
loc_kind = RDI_LocationKind_AddrBytecodeStream;
|
||||
loc_bytecode = eval_bytecode_from_oplist(arena, &oplist);
|
||||
U32 type_idx = thread_var->type_idx;
|
||||
if(type_idx < ctx->rdi->type_nodes_count)
|
||||
{
|
||||
RDI_TypeNode *type_node = &ctx->rdi->type_nodes[type_idx];
|
||||
type_key = tg_key_ext(tg_kind_from_rdi_type_kind(type_node->kind), (U64)type_idx);
|
||||
}
|
||||
mapped_identifier = 1;
|
||||
}
|
||||
node = rdi_name_map_lookup(ctx->rdi, &parsed_name_map, n->string.str, n->string.size);
|
||||
matches_count = 0;
|
||||
matches = rdi_matches_from_map_node(ctx->rdi, node, &matches_count);
|
||||
}
|
||||
if(matches_count != 0)
|
||||
{
|
||||
U32 match_idx = matches[0];
|
||||
RDI_ThreadVariable *thread_var = rdi_element_from_name_idx(ctx->rdi, ThreadVariables, match_idx);
|
||||
EVAL_OpList oplist = {0};
|
||||
eval_oplist_push_op(arena, &oplist, RDI_EvalOp_TLSOff, thread_var->tls_off);
|
||||
loc_kind = RDI_LocationKind_AddrBytecodeStream;
|
||||
loc_bytecode = eval_bytecode_from_oplist(arena, &oplist);
|
||||
U32 type_idx = thread_var->type_idx;
|
||||
RDI_TypeNode *type_node = rdi_element_from_name_idx(ctx->rdi, TypeNodes, type_idx);
|
||||
type_key = tg_key_ext(tg_kind_from_rdi_type_kind(type_node->kind), (U64)type_idx);
|
||||
mapped_identifier = 1;
|
||||
}
|
||||
}
|
||||
|
||||
//- rjf: try procedures
|
||||
if(mapped_identifier == 0)
|
||||
{
|
||||
RDI_NameMap *name_map = rdi_name_map_from_kind(ctx->rdi, RDI_NameMapKind_Procedures);
|
||||
if(name_map != 0 && ctx->rdi->procedures != 0 && ctx->rdi->scopes != 0 && ctx->rdi->scope_voffs)
|
||||
RDI_NameMap *name_map = rdi_element_from_name_idx(ctx->rdi, NameMaps, RDI_NameMapKind_Procedures);
|
||||
RDI_ParsedNameMap parsed_name_map = {0};
|
||||
rdi_parsed_from_name_map(ctx->rdi, name_map, &parsed_name_map);
|
||||
RDI_NameMapNode *node = rdi_name_map_lookup(ctx->rdi, &parsed_name_map, token_string.str, token_string.size);
|
||||
U32 matches_count = 0;
|
||||
U32 *matches = rdi_matches_from_map_node(ctx->rdi, node, &matches_count);
|
||||
for(String8Node *n = namespaceified_token_strings.first;
|
||||
n != 0 && matches_count == 0;
|
||||
n = n->next)
|
||||
{
|
||||
RDI_ParsedNameMap parsed_name_map = {0};
|
||||
rdi_name_map_parse(ctx->rdi, name_map, &parsed_name_map);
|
||||
RDI_NameMapNode *node = rdi_name_map_lookup(ctx->rdi, &parsed_name_map, token_string.str, token_string.size);
|
||||
U32 matches_count = 0;
|
||||
U32 *matches = rdi_matches_from_map_node(ctx->rdi, node, &matches_count);
|
||||
for(String8Node *n = namespaceified_token_strings.first;
|
||||
n != 0 && matches_count == 0;
|
||||
n = n->next)
|
||||
{
|
||||
node = rdi_name_map_lookup(ctx->rdi, &parsed_name_map, n->string.str, n->string.size);
|
||||
matches_count = 0;
|
||||
matches = rdi_matches_from_map_node(ctx->rdi, node, &matches_count);
|
||||
}
|
||||
if(matches_count != 0)
|
||||
{
|
||||
U32 match_idx = matches[0];
|
||||
RDI_Procedure *procedure = &ctx->rdi->procedures[match_idx];
|
||||
RDI_Scope *scope = &ctx->rdi->scopes[procedure->root_scope_idx];
|
||||
U64 voff = ctx->rdi->scope_voffs[scope->voff_range_first];
|
||||
EVAL_OpList oplist = {0};
|
||||
eval_oplist_push_op(arena, &oplist, RDI_EvalOp_ModuleOff, voff);
|
||||
loc_kind = RDI_LocationKind_ValBytecodeStream;
|
||||
loc_bytecode = eval_bytecode_from_oplist(arena, &oplist);
|
||||
U32 type_idx = procedure->type_idx;
|
||||
if(type_idx < ctx->rdi->type_nodes_count)
|
||||
{
|
||||
RDI_TypeNode *type_node = &ctx->rdi->type_nodes[type_idx];
|
||||
type_key = tg_key_ext(tg_kind_from_rdi_type_kind(type_node->kind), (U64)type_idx);
|
||||
}
|
||||
mapped_identifier = 1;
|
||||
}
|
||||
node = rdi_name_map_lookup(ctx->rdi, &parsed_name_map, n->string.str, n->string.size);
|
||||
matches_count = 0;
|
||||
matches = rdi_matches_from_map_node(ctx->rdi, node, &matches_count);
|
||||
}
|
||||
if(matches_count != 0)
|
||||
{
|
||||
U32 match_idx = matches[0];
|
||||
RDI_Procedure *procedure = rdi_element_from_name_idx(ctx->rdi, Procedures, match_idx);
|
||||
RDI_Scope *scope = rdi_element_from_name_idx(ctx->rdi, Scopes, procedure->root_scope_idx);
|
||||
U64 voff = *rdi_element_from_name_idx(ctx->rdi, ScopeVOffData, scope->voff_range_first);
|
||||
EVAL_OpList oplist = {0};
|
||||
eval_oplist_push_op(arena, &oplist, RDI_EvalOp_ModuleOff, voff);
|
||||
loc_kind = RDI_LocationKind_ValBytecodeStream;
|
||||
loc_bytecode = eval_bytecode_from_oplist(arena, &oplist);
|
||||
U32 type_idx = procedure->type_idx;
|
||||
RDI_TypeNode *type_node = rdi_element_from_name_idx(ctx->rdi, TypeNodes, type_idx);
|
||||
type_key = tg_key_ext(tg_kind_from_rdi_type_kind(type_node->kind), (U64)type_idx);
|
||||
mapped_identifier = 1;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user