diff --git a/src/lib_rdi_make/rdi_make.h b/src/lib_rdi_make/rdi_make.h index 214599e9..52c24443 100644 --- a/src/lib_rdi_make/rdi_make.h +++ b/src/lib_rdi_make/rdi_make.h @@ -637,7 +637,7 @@ struct RDIM_Namespace struct RDIM_NamespaceChunkNode *chunk; RDIM_Namespace *parent_namespace; struct RDIM_Scope *parent_scope; - struct RDIM_UDT *parent_udt; + struct RDIM_Type *parent_type; RDIM_String8 name; }; diff --git a/src/rdi/rdi_local.c b/src/rdi/rdi_local.c index 75309bc4..3e09527d 100644 --- a/src/rdi/rdi_local.c +++ b/src/rdi/rdi_local.c @@ -830,7 +830,7 @@ lane_sync(); if(flags & (1ull<<(kind))) ProfScope(rdi_name_title_from_dump_subse dumpf(" flags: `%S`\n", rdi_string_from_udt_flags(scratch.arena, udt->flags)); if(udt->container_idx != 0 && (udt->container_flags & RDI_ContainerFlag_KindMask) == RDI_ContainerKind_Type) { - dumpf(" container_type_idx: %u\n", udt->container_idx); + dumpf(" container_udt_idx: %u\n", udt->container_idx); } if(udt->container_idx != 0 && (udt->container_flags & RDI_ContainerFlag_KindMask) == RDI_ContainerKind_Scope) { @@ -941,7 +941,7 @@ lane_sync(); if(flags & (1ull<<(kind))) ProfScope(rdi_name_title_from_dump_subse } if(symbol->container_idx != 0 && (symbol->container_flags & RDI_ContainerFlag_KindMask) == RDI_ContainerKind_Type) { - dumpf(" container_type_idx: %u\n", symbol->container_idx); + dumpf(" container_udt_idx: %u\n", symbol->container_idx); } if(symbol->container_idx != 0 && (symbol->container_flags & RDI_ContainerFlag_KindMask) == RDI_ContainerKind_Scope) { diff --git a/src/rdi_from_pdb/rdi_from_pdb.c b/src/rdi_from_pdb/rdi_from_pdb.c index 43c4bbf0..73a4b1e2 100644 --- a/src/rdi_from_pdb/rdi_from_pdb.c +++ b/src/rdi_from_pdb/rdi_from_pdb.c @@ -2764,29 +2764,6 @@ p2r_convert(Arena *arena, P2R_ConvertParams *params) lane_sync_u64(&all_types__pre_typedefs_ptr, 0); all_types__pre_typedefs = *all_types__pre_typedefs_ptr; - ////////////////////////////////////////////////////////////// - //- rjf: upgrade namespace nodes with type info, if they match a type - // - ProfScope("upgrade namespace nodes with type info, if they match a type") - { -#define p2r_type_ptr_from_itype(itype) ((itype_type_ptrs && (itype) < tpi_leaf->itype_opl) ? (itype_type_ptrs[(itype_fwd_map[(itype)] ? itype_fwd_map[(itype)] : (itype))]) : 0) - Rng1U64 range = lane_range(all_namespace_slots_count); - for EachInRange(slot_idx, range) - { - for(P2R_NamespaceNode *n = all_namespace_slots[slot_idx]; n != 0; n = n->next) - { - String8 container_string = n->string; - CV_TypeId container_type_id = pdb_tpi_first_itype_from_name(tpi_hash, tpi_leaf, container_string, 0); - if(container_type_id != 0) - { - n->type = p2r_type_ptr_from_itype(container_type_id); - } - } - } -#undef p2r_type_ptr_from_itype - } - lane_sync(); - ////////////////////////////////////////////////////////////// //- rjf: set bit in all namespace nodes that correspond to scopes // @@ -2994,6 +2971,29 @@ p2r_convert(Arena *arena, P2R_ConvertParams *params) scratch_end(scratch2); } + ////////////////////////////////////////////////////////////// + //- rjf: upgrade namespace nodes with type info, if they match a type + // + ProfScope("upgrade namespace nodes with type info, if they match a type") + { +#define p2r_type_ptr_from_itype(itype) ((itype_type_ptrs && (itype) < tpi_leaf->itype_opl) ? (itype_type_ptrs[(itype_fwd_map[(itype)] ? itype_fwd_map[(itype)] : (itype))]) : 0) + Rng1U64 range = lane_range(all_namespace_slots_count); + for EachInRange(slot_idx, range) + { + for(P2R_NamespaceNode *n = all_namespace_slots[slot_idx]; n != 0; n = n->next) + { + String8 container_string = n->string; + CV_TypeId container_type_id = pdb_tpi_first_itype_from_name(tpi_hash, tpi_leaf, container_string, 0); + if(container_type_id != 0) + { + n->type = p2r_type_ptr_from_itype(container_type_id); + } + } + } +#undef p2r_type_ptr_from_itype + } + lane_sync(); + ////////////////////////////////////////////////////////////// //- rjf: build namespaces, that are not scopes, nor types // @@ -3023,13 +3023,14 @@ p2r_convert(Arena *arena, P2R_ConvertParams *params) for EachIndex(node_in_slot_idx, node_count) { P2R_NamespaceNode *n = nodes[node_in_slot_idx]; - // raddbg_log("%S%s\n", n->string, n->corresponds_to_scope ? " (is scope)" : n->type != 0 ? " (is type)" : ""); + raddbg_log("%S%s\n", n->string, n->corresponds_to_scope ? " (is scope)" : n->type != 0 ? " (is type)" : ""); if(n->corresponds_to_scope || n->scope != 0 || n->type != 0) { continue; } String8 string = n->string; RDIM_Namespace *ns = rdim_namespace_chunk_list_push(arena, &lane_namespaces, 32); ns->name = string; n->ns = ns; } + scratch_end(scratch); } @@ -4059,6 +4060,32 @@ p2r_convert(Arena *arena, P2R_ConvertParams *params) } lane_sync(); + ////////////////////////////////////////////////////////////// + //- rjf: upgrade namespaces with container info + // + for EachNode(n, RDIM_NamespaceChunkNode, all_namespaces.first) + { + Rng1U64 range = lane_range(n->count); + for EachInRange(n_idx, range) + { + RDIM_Namespace *ns = &n->v[n_idx]; + String8 container_name = str8_chop(str8_prefix(ns->name, p2r_end_of_cplusplus_container_name(ns->name)), 2); + U64 hash = u64_hash_from_str8(container_name); + U64 slot_idx = hash%all_namespace_slots_count; + for(P2R_NamespaceNode *ns_n = all_namespace_slots[slot_idx]; ns_n != 0; ns_n = ns_n->next) + { + if(str8_match(ns_n->string, container_name, 0)) + { + ns->parent_scope = ns_n->scope; + ns->parent_type = ns_n->type; + ns->parent_namespace = ns_n->ns; + break; + } + } + } + } + lane_sync(); + ////////////////////////////////////////////////////////////// //- rjf: join extra types from units // diff --git a/src/rdi_make/rdi_make_local.c b/src/rdi_make/rdi_make_local.c index 0cff69ae..26ef4a48 100644 --- a/src/rdi_make/rdi_make_local.c +++ b/src/rdi_make/rdi_make_local.c @@ -2576,10 +2576,10 @@ rdim_bake(Arena *arena, RDIM_BakeParams *params) dst->container_flags |= RDI_ContainerKind_Scope; dst->container_idx = rdim_idx_from_scope(src->parent_scope); } - else if(src->parent_udt != 0) + else if(src->parent_type != 0 && src->parent_type->udt != 0) { dst->container_flags |= RDI_ContainerKind_Type; - dst->container_idx = rdim_idx_from_udt(src->parent_udt); + dst->container_idx = rdim_idx_from_udt(src->parent_type->udt); } } }