rdi format - namespaces

This commit is contained in:
Ryan Fleury
2026-03-09 09:37:50 -07:00
parent 953f58fd44
commit e2b9618101
7 changed files with 665 additions and 504 deletions
+7 -4
View File
@@ -123,13 +123,16 @@ for /f %%i in ('call git describe --always --dirty') do set compile=%compile%
for /f %%i in ('call git rev-parse HEAD') do set compile=%compile% -DBUILD_GIT_HASH_FULL=\"%%i\" for /f %%i in ('call git rev-parse HEAD') do set compile=%compile% -DBUILD_GIT_HASH_FULL=\"%%i\"
:: --- Build & Run Metaprogram ------------------------------------------------ :: --- Build & Run Metaprogram ------------------------------------------------
pushd build
if "%meta%"=="1" ( if "%meta%"=="1" (
echo [doing metagen] echo [building metagen]
pushd build
%compile_debug% ..\src\metagen\metagen_main.c %compile_link% %out%metagen.exe || exit /b 1 %compile_debug% ..\src\metagen\metagen_main.c %compile_link% %out%metagen.exe || exit /b 1
metagen.exe || exit /b 1
popd
) )
if "%no_meta%"=="" (
echo [running metagen]
metagen.exe || exit /b 1
)
popd
:: --- Build Everything (@build_targets) -------------------------------------- :: --- Build Everything (@build_targets) --------------------------------------
pushd build pushd build
+2 -1
View File
@@ -10,7 +10,7 @@
#ifndef RDI_C #ifndef RDI_C
#define RDI_C #define RDI_C
RDI_U16 rdi_section_element_size_table[44] = RDI_U16 rdi_section_element_size_table[45] =
{ {
sizeof(RDI_U8), sizeof(RDI_U8),
sizeof(RDI_TopLevelInfo), sizeof(RDI_TopLevelInfo),
@@ -30,6 +30,7 @@ sizeof(RDI_U32),
sizeof(RDI_U64), sizeof(RDI_U64),
sizeof(RDI_Unit), sizeof(RDI_Unit),
sizeof(RDI_VMapEntry), sizeof(RDI_VMapEntry),
sizeof(RDI_Namespace),
sizeof(RDI_TypeNode), sizeof(RDI_TypeNode),
sizeof(RDI_UDT), sizeof(RDI_UDT),
sizeof(RDI_Member), sizeof(RDI_Member),
+498 -465
View File
File diff suppressed because it is too large Load Diff
+24
View File
@@ -806,6 +806,29 @@ rdim_unit_chunk_list_concat_in_place(RDIM_UnitChunkList *dst, RDIM_UnitChunkList
RDIM_IdxedChunkListConcatInPlace(RDIM_UnitChunkNode, dst, to_push); RDIM_IdxedChunkListConcatInPlace(RDIM_UnitChunkNode, dst, to_push);
} }
////////////////////////////////
//~ rjf: [Building] Namespace Info Building
RDI_PROC RDIM_Namespace *
rdim_namespace_chunk_list_push(RDIM_Arena *arena, RDIM_NamespaceChunkList *list, RDI_U64 cap)
{
RDIM_IdxedChunkListPush(arena, list, RDIM_NamespaceChunkNode, RDIM_Namespace, cap, result);
return result;
}
RDI_PROC RDI_U64
rdim_idx_from_namespace(RDIM_Namespace *ns)
{
RDIM_IdxedChunkListElementGetIdx(ns, idx);
return idx;
}
RDI_PROC void
rdim_namespace_chunk_list_concat_in_place(RDIM_NamespaceChunkList *dst, RDIM_NamespaceChunkList *to_push)
{
RDIM_IdxedChunkListConcatInPlace(RDIM_NamespaceChunkNode, dst, to_push);
}
//////////////////////////////// ////////////////////////////////
//~ rjf: [Building] Type Info Building //~ rjf: [Building] Type Info Building
@@ -2162,6 +2185,7 @@ rdim_serialized_section_bundle_from_bake_results(RDIM_BakeResults *results)
bundle.sections[RDI_SectionKind_SourceLineMapVOffs] = rdim_serialized_section_make_unpacked_array(results->src_files.source_line_map_voffs, results->src_files.source_line_map_voffs_count); bundle.sections[RDI_SectionKind_SourceLineMapVOffs] = rdim_serialized_section_make_unpacked_array(results->src_files.source_line_map_voffs, results->src_files.source_line_map_voffs_count);
bundle.sections[RDI_SectionKind_Units] = rdim_serialized_section_make_unpacked_array(results->units.units, results->units.units_count); bundle.sections[RDI_SectionKind_Units] = rdim_serialized_section_make_unpacked_array(results->units.units, results->units.units_count);
bundle.sections[RDI_SectionKind_UnitVMap] = rdim_serialized_section_make_unpacked_array(results->unit_vmap.vmap.vmap, results->unit_vmap.vmap.count); bundle.sections[RDI_SectionKind_UnitVMap] = rdim_serialized_section_make_unpacked_array(results->unit_vmap.vmap.vmap, results->unit_vmap.vmap.count);
bundle.sections[RDI_SectionKind_Namespaces] = rdim_serialized_section_make_unpacked_array(results->namespaces.namespaces, results->namespaces.namespaces_count);
bundle.sections[RDI_SectionKind_TypeNodes] = rdim_serialized_section_make_unpacked_array(results->type_nodes.type_nodes, results->type_nodes.type_nodes_count); bundle.sections[RDI_SectionKind_TypeNodes] = rdim_serialized_section_make_unpacked_array(results->type_nodes.type_nodes, results->type_nodes.type_nodes_count);
bundle.sections[RDI_SectionKind_UDTs] = rdim_serialized_section_make_unpacked_array(results->udts.udts, results->udts.udts_count); bundle.sections[RDI_SectionKind_UDTs] = rdim_serialized_section_make_unpacked_array(results->udts.udts, results->udts.udts_count);
bundle.sections[RDI_SectionKind_Members] = rdim_serialized_section_make_unpacked_array(results->udts.members, results->udts.members_count); bundle.sections[RDI_SectionKind_Members] = rdim_serialized_section_make_unpacked_array(results->udts.members, results->udts.members_count);
+48 -5
View File
@@ -665,6 +665,38 @@ struct RDIM_UnitChunkList
RDI_U64 total_count; RDI_U64 total_count;
}; };
////////////////////////////////
//~ rjf: Namespace Types
typedef struct RDIM_Namespace RDIM_Namespace;
struct RDIM_Namespace
{
struct RDIM_NamespaceChunkNode *chunk;
RDIM_Namespace *parent_namespace;
struct RDIM_Scope *parent_scope;
struct RDIM_UDT *parent_udt;
RDIM_String8 name;
};
typedef struct RDIM_NamespaceChunkNode RDIM_NamespaceChunkNode;
struct RDIM_NamespaceChunkNode
{
RDIM_NamespaceChunkNode *next;
RDIM_Namespace *v;
RDI_U64 count;
RDI_U64 cap;
RDI_U64 base_idx;
};
typedef struct RDIM_NamespaceChunkList RDIM_NamespaceChunkList;
struct RDIM_NamespaceChunkList
{
RDIM_NamespaceChunkNode *first;
RDIM_NamespaceChunkNode *last;
RDI_U64 chunk_count;
RDI_U64 total_count;
};
//////////////////////////////// ////////////////////////////////
//~ rjf: Type System Node Types //~ rjf: Type System Node Types
@@ -1010,6 +1042,7 @@ struct RDIM_BakeParams
RDIM_TopLevelInfo top_level_info; RDIM_TopLevelInfo top_level_info;
RDIM_BinarySectionList binary_sections; RDIM_BinarySectionList binary_sections;
RDIM_UnitChunkList units; RDIM_UnitChunkList units;
RDIM_NamespaceChunkList namespaces;
RDIM_TypeChunkList types; RDIM_TypeChunkList types;
RDIM_UDTChunkList udts; RDIM_UDTChunkList udts;
RDIM_SrcFileChunkList src_files; RDIM_SrcFileChunkList src_files;
@@ -1349,6 +1382,13 @@ struct RDIM_LineTableBakeResult
RDI_U64 line_table_columns_count; RDI_U64 line_table_columns_count;
}; };
typedef struct RDIM_NamespaceBakeResult RDIM_NamespaceBakeResult;
struct RDIM_NamespaceBakeResult
{
RDI_Namespace *namespaces;
RDI_U64 namespaces_count;
};
typedef struct RDIM_TypeNodeBakeResult RDIM_TypeNodeBakeResult; typedef struct RDIM_TypeNodeBakeResult RDIM_TypeNodeBakeResult;
struct RDIM_TypeNodeBakeResult struct RDIM_TypeNodeBakeResult
{ {
@@ -1492,6 +1532,7 @@ struct RDIM_BakeResults
RDIM_SrcFileBakeResult src_files; RDIM_SrcFileBakeResult src_files;
RDIM_ChecksumBakeResult checksums; RDIM_ChecksumBakeResult checksums;
RDIM_LineTableBakeResult line_tables; RDIM_LineTableBakeResult line_tables;
RDIM_NamespaceBakeResult namespaces;
RDIM_TypeNodeBakeResult type_nodes; RDIM_TypeNodeBakeResult type_nodes;
RDIM_UDTBakeResult udts; RDIM_UDTBakeResult udts;
RDIM_GlobalVariableBakeResult global_variables; RDIM_GlobalVariableBakeResult global_variables;
@@ -1626,6 +1667,13 @@ RDI_PROC RDIM_Unit *rdim_unit_chunk_list_push(RDIM_Arena *arena, RDIM_UnitChunkL
RDI_PROC RDI_U64 rdim_idx_from_unit(RDIM_Unit *unit); RDI_PROC RDI_U64 rdim_idx_from_unit(RDIM_Unit *unit);
RDI_PROC void rdim_unit_chunk_list_concat_in_place(RDIM_UnitChunkList *dst, RDIM_UnitChunkList *to_push); RDI_PROC void rdim_unit_chunk_list_concat_in_place(RDIM_UnitChunkList *dst, RDIM_UnitChunkList *to_push);
////////////////////////////////
//~ rjf: [Building] Namespace Info Building
RDI_PROC RDIM_Namespace *rdim_namespace_chunk_list_push(RDIM_Arena *arena, RDIM_NamespaceChunkList *list, RDI_U64 cap);
RDI_PROC RDI_U64 rdim_idx_from_namespace(RDIM_Namespace *ns);
RDI_PROC void rdim_namespace_chunk_list_concat_in_place(RDIM_NamespaceChunkList *dst, RDIM_NamespaceChunkList *to_push);
//////////////////////////////// ////////////////////////////////
//~ rjf: [Building] Type Info & UDT Building //~ rjf: [Building] Type Info & UDT Building
@@ -1757,9 +1805,4 @@ RDI_PROC RDIM_SerializedSection rdim_serialized_section_make_unpacked(void *data
RDI_PROC RDIM_SerializedSectionBundle rdim_serialized_section_bundle_from_bake_results(RDIM_BakeResults *results); RDI_PROC RDIM_SerializedSectionBundle rdim_serialized_section_bundle_from_bake_results(RDIM_BakeResults *results);
RDI_PROC RDIM_String8List rdim_file_blobs_from_section_bundle(RDIM_Arena *arena, RDIM_SerializedSectionBundle *bundle); RDI_PROC RDIM_String8List rdim_file_blobs_from_section_bundle(RDIM_Arena *arena, RDIM_SerializedSectionBundle *bundle);
////////////////////////////////
//~ rjf: [Serializing] Parsed RDI -> Bake Results
RDI_PROC RDIM_BakeResults *rdim_bake_results_from_rdi(RDIM_Arena *arena, RDI_Parsed *rdi);
#endif // RDI_MAKE_H #endif // RDI_MAKE_H
+71 -27
View File
@@ -77,7 +77,7 @@
""; "";
"// \"raddbg\\0\\0\""; "// \"raddbg\\0\\0\"";
"#define RDI_MAGIC_CONSTANT 0x0000676264646172"; "#define RDI_MAGIC_CONSTANT 0x0000676264646172";
"#define RDI_ENCODING_VERSION 18"; "#define RDI_ENCODING_VERSION 19";
""; "";
"////////////////////////////////////////////////////////////////"; "////////////////////////////////////////////////////////////////";
"//~ Format Types & Functions"; "//~ Format Types & Functions";
@@ -153,32 +153,33 @@ RDI_SectionTable:
{SourceLineMapVOffs source_line_map_voffs RDI_U64 0x000F U32 ""} {SourceLineMapVOffs source_line_map_voffs RDI_U64 0x000F U32 ""}
{Units units RDI_Unit 0x0010 U32 ""} {Units units RDI_Unit 0x0010 U32 ""}
{UnitVMap unit_vmap RDI_VMapEntry 0x0011 - ""} {UnitVMap unit_vmap RDI_VMapEntry 0x0011 - ""}
{TypeNodes type_nodes RDI_TypeNode 0x0012 U32 ""} {Namespaces namespaces RDI_Namespace 0x0012 U32 ""}
{UDTs udts RDI_UDT 0x0013 U32 ""} {TypeNodes type_nodes RDI_TypeNode 0x0013 U32 ""}
{Members members RDI_Member 0x0014 U32 ""} {UDTs udts RDI_UDT 0x0014 U32 ""}
{EnumMembers enum_members RDI_EnumMember 0x0015 U32 ""} {Members members RDI_Member 0x0015 U32 ""}
{GlobalVariables global_variables RDI_GlobalVariable 0x0016 U32 ""} {EnumMembers enum_members RDI_EnumMember 0x0016 U32 ""}
{GlobalVMap global_vmap RDI_VMapEntry 0x0017 - ""} {GlobalVariables global_variables RDI_GlobalVariable 0x0017 U32 ""}
{ThreadVariables thread_variables RDI_ThreadVariable 0x0018 U32 ""} {GlobalVMap global_vmap RDI_VMapEntry 0x0018 - ""}
{Constants constants RDI_Constant 0x0019 U32 ""} {ThreadVariables thread_variables RDI_ThreadVariable 0x0019 U32 ""}
{Procedures procedures RDI_Procedure 0x001A U32 ""} {Constants constants RDI_Constant 0x001A U32 ""}
{Scopes scopes RDI_Scope 0x001B U32 ""} {Procedures procedures RDI_Procedure 0x001B U32 ""}
{ScopeVOffData scope_voff_data RDI_U64 0x001C U32 ""} {Scopes scopes RDI_Scope 0x001C U32 ""}
{ScopeVMap scope_vmap RDI_VMapEntry 0x001D - ""} {ScopeVOffData scope_voff_data RDI_U64 0x001D U32 ""}
{InlineSites inline_sites RDI_InlineSite 0x001E U32 ""} {ScopeVMap scope_vmap RDI_VMapEntry 0x001E - ""}
{Locals locals RDI_Local 0x001F U32 ""} {InlineSites inline_sites RDI_InlineSite 0x001F U32 ""}
{LocationBlocks location_blocks RDI_LocationBlock 0x0020 U32 ""} {Locals locals RDI_Local 0x0020 U32 ""}
{LocationData location_data RDI_U8 0x0021 U32 ""} {LocationBlocks location_blocks RDI_LocationBlock 0x0021 U32 ""}
{ConstantValueData constant_value_data RDI_U8 0x0022 U32 ""} {LocationData location_data RDI_U8 0x0022 U32 ""}
{ConstantValueTable constant_value_table RDI_U32 0x0023 U32 ""} {ConstantValueData constant_value_data RDI_U8 0x0023 U32 ""}
{MD5Checksums md5_checksums RDI_MD5 0x0024 U32 ""} {ConstantValueTable constant_value_table RDI_U32 0x0024 U32 ""}
{SHA1Checksums sha1_checksums RDI_SHA1 0x0025 U32 ""} {MD5Checksums md5_checksums RDI_MD5 0x0025 U32 ""}
{SHA256Checksums sha256_checksums RDI_SHA256 0x0026 U32 ""} {SHA1Checksums sha1_checksums RDI_SHA1 0x0026 U32 ""}
{Timestamps timestamps RDI_U64 0x0027 U32 ""} {SHA256Checksums sha256_checksums RDI_SHA256 0x0027 U32 ""}
{NameMaps name_maps RDI_NameMap 0x0028 U32 ""} {Timestamps timestamps RDI_U64 0x0028 U32 ""}
{NameMapBuckets name_map_buckets RDI_NameMapBucket 0x0029 U32 ""} {NameMaps name_maps RDI_NameMap 0x0029 U32 ""}
{NameMapNodes name_map_nodes RDI_NameMapNode 0x002A U32 ""} {NameMapBuckets name_map_buckets RDI_NameMapBucket 0x002A U32 ""}
{COUNT count RDI_U8 0x002B - ""} {NameMapNodes name_map_nodes RDI_NameMapNode 0x002B U32 ""}
{COUNT count RDI_U8 0x002C - ""}
} }
@table(name value) @table(name value)
@@ -943,6 +944,20 @@ RDI_EnumMemberTable:
//- rjf: tables //- rjf: tables
@table(name value)
RDI_ContainerKindTable:
{
{Type 0x0}
{Scope 0x1}
{Namespace 0x2}
}
@table(name value)
RDI_ContainerFlagTable:
{
{External `1<<8`}
}
@table(name value) @table(name value)
RDI_LinkFlagTable: RDI_LinkFlagTable:
{ {
@@ -970,6 +985,14 @@ RDI_LocationKindTable:
{ValReg 0x5} {ValReg 0x5}
} }
@table(name type desc)
RDI_NamespaceMemberTable:
{
{name_string_idx RDI_U32 ""}
{container_flags RDI_ContainerFlags ""}
{container_idx RDI_U32 ""}
}
@table(name type desc) @table(name type desc)
RDI_GlobalVariableMemberTable: RDI_GlobalVariableMemberTable:
{ {
@@ -1077,6 +1100,17 @@ RDI_LocationRegMemberTable:
//- rjf: enums //- rjf: enums
@enum(RDI_U8) RDI_ContainerKind:
{
@expand(RDI_ContainerKindTable a) `$(a.name .. =>20) = $(a.value)`
}
@enum(RDI_U32) RDI_ContainerFlags:
{
@expand(RDI_ContainerFlagTable a) `$(a.name .. =>20) = $(a.value)`,
`KindMask = 0xff`,
}
@enum(RDI_U32) RDI_LinkFlags: @enum(RDI_U32) RDI_LinkFlags:
{ {
@expand(RDI_LinkFlagTable a) `$(a.name .. =>20) = $(a.value)` @expand(RDI_LinkFlagTable a) `$(a.name .. =>20) = $(a.value)`
@@ -1109,6 +1143,11 @@ RDI_LocationRegMemberTable:
@expand(RDI_LocationKindTable a) `$(a.name != COUNT -> a.name)`; @expand(RDI_LocationKindTable a) `$(a.name != COUNT -> a.name)`;
} }
@xlist RDI_Namespace_XList:
{
@expand(RDI_NamespaceMemberTable a) `$(a.type), $(a.name)`
}
@xlist RDI_GlobalVariable_XList: @xlist RDI_GlobalVariable_XList:
{ {
@expand(RDI_GlobalVariableMemberTable a) `$(a.type), $(a.name)` @expand(RDI_GlobalVariableMemberTable a) `$(a.type), $(a.name)`
@@ -1161,6 +1200,11 @@ RDI_LocationRegMemberTable:
//- rjf: structs //- rjf: structs
@struct RDI_Namespace:
{
@expand(RDI_NamespaceMemberTable a) `$(a.type) $(a.name)`
}
@struct RDI_GlobalVariable: @struct RDI_GlobalVariable:
{ {
@expand(RDI_GlobalVariableMemberTable a) `$(a.type) $(a.name)` @expand(RDI_GlobalVariableMemberTable a) `$(a.type) $(a.name)`
+13
View File
@@ -1110,6 +1110,19 @@ rdim_bake(Arena *arena, RDIM_BakeParams *params)
} }
} }
// rjf: push strings from namespaces
ProfScope("namespaces")
{
for EachNode(n, RDIM_NamespaceChunkNode, params->namespaces.first)
{
Rng1U64 range = lane_range(n->count);
for EachInRange(n_idx, range)
{
rdim_bake_string_map_loose_insert(arena, top, lane_map, 4, n->v[n_idx].name);
}
}
}
// rjf: push strings from types // rjf: push strings from types
ProfScope("types") ProfScope("types")
{ {