2018-06-23 03:03:58 +00:00
|
|
|
/*
|
|
|
|
* Mr. 4th Dimention - Allen Webster
|
|
|
|
*
|
|
|
|
* 22.06.2018
|
|
|
|
*
|
|
|
|
* Dynamic variable system
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
// TOP
|
|
|
|
|
|
|
|
#if !defined(FRED_DYNAMIC_VARIABLES_H)
|
|
|
|
#define FRED_DYNAMIC_VARIABLES_H
|
|
|
|
|
2018-09-07 22:39:33 +00:00
|
|
|
union Managed_Object_Standard_Header{
|
2018-09-04 00:37:54 +00:00
|
|
|
u64 eight_byte_alignment__;
|
|
|
|
struct{
|
2018-09-07 22:39:33 +00:00
|
|
|
Managed_Object_Type type;
|
|
|
|
u32 item_size;
|
|
|
|
u32 count;
|
2018-09-04 00:37:54 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2018-09-07 22:39:33 +00:00
|
|
|
struct Managed_Memory_Header{
|
|
|
|
Managed_Object_Standard_Header std_header;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Managed_Buffer_Markers_Header{
|
|
|
|
Managed_Object_Standard_Header std_header;
|
|
|
|
Managed_Buffer_Markers_Header *next;
|
|
|
|
Managed_Buffer_Markers_Header *prev;
|
|
|
|
Buffer_ID buffer_id;
|
2018-09-28 23:42:32 +00:00
|
|
|
};
|
|
|
|
|
2019-02-26 19:59:57 +00:00
|
|
|
struct Managed_Arena_Header{
|
|
|
|
Managed_Object_Standard_Header std_header;
|
|
|
|
Managed_Arena_Header *next;
|
|
|
|
Managed_Arena_Header *prev;
|
|
|
|
Arena arena;
|
|
|
|
};
|
|
|
|
|
2018-09-04 00:37:54 +00:00
|
|
|
global_const i32 managed_header_type_sizes[ManagedObjectType_COUNT] = {
|
|
|
|
0,
|
|
|
|
sizeof(Managed_Memory_Header),
|
|
|
|
sizeof(Managed_Buffer_Markers_Header),
|
2019-02-26 19:59:57 +00:00
|
|
|
sizeof(Managed_Arena_Header),
|
2018-09-04 00:37:54 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct Managed_Buffer_Markers_Header_List{
|
|
|
|
Managed_Buffer_Markers_Header *first;
|
|
|
|
Managed_Buffer_Markers_Header *last;
|
|
|
|
i32 count;
|
|
|
|
};
|
|
|
|
|
2019-02-26 19:59:57 +00:00
|
|
|
struct Managed_Arena_Header_List{
|
|
|
|
Managed_Arena_Header *first;
|
|
|
|
Managed_Arena_Header *last;
|
|
|
|
i32 count;
|
|
|
|
};
|
|
|
|
|
2018-09-04 00:37:54 +00:00
|
|
|
////////////////////////////////
|
|
|
|
|
2019-11-24 23:13:51 +00:00
|
|
|
struct Managed_ID_Group{
|
2019-09-04 05:31:35 +00:00
|
|
|
Table_Data_u64 name_to_id_table;
|
|
|
|
Managed_ID id_counter;
|
2018-06-23 03:03:58 +00:00
|
|
|
};
|
|
|
|
|
2019-11-24 23:13:51 +00:00
|
|
|
struct Managed_ID_Set{
|
|
|
|
Arena arena;
|
|
|
|
Table_Data_u64 name_to_group_table;
|
|
|
|
};
|
|
|
|
|
2018-06-23 03:03:58 +00:00
|
|
|
struct Dynamic_Variable_Block{
|
2019-09-04 05:31:35 +00:00
|
|
|
Arena arena;
|
|
|
|
Table_u64_Data id_to_data_table;
|
2018-06-23 03:03:58 +00:00
|
|
|
};
|
|
|
|
|
2018-08-11 05:42:00 +00:00
|
|
|
////////////////////////////////
|
|
|
|
|
2018-08-18 08:16:52 +00:00
|
|
|
struct Dynamic_Workspace{
|
|
|
|
Dynamic_Variable_Block var_block;
|
2019-09-04 05:31:35 +00:00
|
|
|
Heap heap;
|
|
|
|
Base_Allocator heap_wrapper;
|
|
|
|
Table_u64_u64 object_id_to_object_ptr;
|
2018-08-26 09:55:12 +00:00
|
|
|
u32 object_id_counter;
|
2018-09-30 12:14:47 +00:00
|
|
|
u32 visual_id_counter;
|
2018-09-07 22:39:33 +00:00
|
|
|
u32 scope_id;
|
2018-08-26 09:55:12 +00:00
|
|
|
i32 user_type;
|
|
|
|
void *user_back_ptr;
|
2018-09-04 00:37:54 +00:00
|
|
|
Managed_Buffer_Markers_Header_List buffer_markers_list;
|
2019-02-26 19:59:57 +00:00
|
|
|
Managed_Arena_Header_List arena_list;
|
2018-10-02 22:04:57 +00:00
|
|
|
i32 total_marker_count;
|
2018-08-12 06:33:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
////////////////////////////////
|
|
|
|
|
2018-08-12 03:45:09 +00:00
|
|
|
global_const i32 lifetime_key_reference_per_node = 32;
|
|
|
|
|
|
|
|
struct Lifetime_Key_Ref_Node{
|
|
|
|
Lifetime_Key_Ref_Node *next;
|
|
|
|
Lifetime_Key_Ref_Node *prev;
|
|
|
|
struct Lifetime_Key *keys[lifetime_key_reference_per_node];
|
2018-08-11 05:42:00 +00:00
|
|
|
};
|
|
|
|
|
2019-10-22 04:10:29 +00:00
|
|
|
union Lifetime_Object{
|
|
|
|
Lifetime_Object *next;
|
|
|
|
struct{
|
|
|
|
Lifetime_Key_Ref_Node *key_node_first;
|
|
|
|
Lifetime_Key_Ref_Node *key_node_last;
|
|
|
|
i32 key_count;
|
|
|
|
Dynamic_Workspace workspace;
|
2018-08-11 05:42:00 +00:00
|
|
|
};
|
2018-08-12 03:45:09 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct Lifetime_Key{
|
|
|
|
union{
|
|
|
|
struct{
|
|
|
|
Lifetime_Key *next;
|
|
|
|
Lifetime_Key *prev;
|
|
|
|
};
|
|
|
|
struct{
|
2019-10-22 04:10:29 +00:00
|
|
|
Lifetime_Object **members;
|
2018-08-12 03:45:09 +00:00
|
|
|
i32 count;
|
2018-08-18 08:16:52 +00:00
|
|
|
Dynamic_Workspace dynamic_workspace;
|
2018-08-12 03:45:09 +00:00
|
|
|
};
|
2018-08-11 05:42:00 +00:00
|
|
|
};
|
|
|
|
};
|
|
|
|
|
2018-08-12 03:45:09 +00:00
|
|
|
global_const u64 LifetimeKeyHash_Empty = 0&(~bit_63);
|
|
|
|
global_const u64 LifetimeKeyHash_Deleted = max_u64&(~bit_63);
|
|
|
|
|
2018-08-11 05:42:00 +00:00
|
|
|
struct Lifetime_Allocator{
|
2019-09-04 05:31:35 +00:00
|
|
|
Base_Allocator *allocator;
|
2019-10-22 04:10:29 +00:00
|
|
|
Arena node_arena;
|
2019-11-07 00:48:37 +00:00
|
|
|
Lifetime_Key_Ref_Node *free_key_references;
|
|
|
|
Lifetime_Key* free_keys;
|
2019-10-22 04:10:29 +00:00
|
|
|
Lifetime_Object *free_objects;
|
2019-09-04 05:31:35 +00:00
|
|
|
Table_Data_u64 key_table;
|
|
|
|
Table_u64_u64 key_check_table;
|
|
|
|
Table_u64_u64 scope_id_to_scope_ptr_table;
|
2018-08-26 09:55:12 +00:00
|
|
|
u32 scope_id_counter;
|
2018-08-12 06:33:52 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
struct Lifetime_Key_With_Opaque_ID{
|
|
|
|
Lifetime_Key *key;
|
|
|
|
u64 opaque_id;
|
2018-08-11 05:42:00 +00:00
|
|
|
};
|
|
|
|
|
2018-09-07 22:39:33 +00:00
|
|
|
////////////////////////////////
|
|
|
|
|
|
|
|
struct Managed_Object_Ptr_And_Workspace{
|
|
|
|
Dynamic_Workspace *workspace;
|
|
|
|
Managed_Object_Standard_Header *header;
|
|
|
|
};
|
|
|
|
|
2018-06-23 03:03:58 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
// BOTTOM
|
|
|
|
|