mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-06-13 23:52:22 -07:00
formalize file/folder evaluations; use set-types for files/folders so that we can evaluate both file metadata & contents, rather than just assuming the contents; adjust slice view rule to just expand to the contents, rather than achieving the slice with a changed type
This commit is contained in:
@@ -71,7 +71,6 @@ E_TypeKindTable:
|
||||
{IncompleteEnum "enum" 0 }
|
||||
{Bitfield "bitfield" 0 }
|
||||
{Variadic "variadic" 0 }
|
||||
{SpacePtr "space_ptr" 0 }
|
||||
{Set "set" 0 }
|
||||
}
|
||||
|
||||
|
||||
@@ -94,6 +94,7 @@ enum
|
||||
{
|
||||
E_SpaceKind_Null,
|
||||
E_SpaceKind_HashStoreKey,
|
||||
E_SpaceKind_FileSystem,
|
||||
E_SpaceKind_FirstUserDefined,
|
||||
};
|
||||
|
||||
|
||||
+309
-78
@@ -84,6 +84,233 @@ e_select_ir_ctx(E_IRCtx *ctx)
|
||||
e_ir_state->type_auto_hook_cache_map->slots = push_array(e_ir_state->arena, E_TypeAutoHookCacheSlot, e_ir_state->type_auto_hook_cache_map->slots_count);
|
||||
e_ir_state->irtree_and_type_cache_slots_count = 1024;
|
||||
e_ir_state->irtree_and_type_cache_slots = push_array(e_ir_state->arena, E_IRTreeAndTypeCacheSlot, e_ir_state->irtree_and_type_cache_slots_count);
|
||||
e_ir_state->string_id_gen = 0;
|
||||
e_ir_state->string_id_map = push_array(e_ir_state->arena, E_StringIDMap, 1);
|
||||
e_ir_state->string_id_map->id_slots_count = 1024;
|
||||
e_ir_state->string_id_map->id_slots = push_array(e_ir_state->arena, E_StringIDSlot, e_ir_state->string_id_map->id_slots_count);
|
||||
e_ir_state->string_id_map->hash_slots_count = 1024;
|
||||
e_ir_state->string_id_map->hash_slots = push_array(e_ir_state->arena, E_StringIDSlot, e_ir_state->string_id_map->hash_slots_count);
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: File System Lookup Rules
|
||||
|
||||
typedef struct E_FolderAccel E_FolderAccel;
|
||||
struct E_FolderAccel
|
||||
{
|
||||
String8 folder_path;
|
||||
String8Array folders;
|
||||
String8Array files;
|
||||
};
|
||||
|
||||
E_LOOKUP_INFO_FUNCTION_DEF(folder)
|
||||
{
|
||||
E_LookupInfo info = {0};
|
||||
{
|
||||
Temp scratch = scratch_begin(&arena, 1);
|
||||
|
||||
//- rjf: evaluate lhs file path ID
|
||||
E_OpList lhs_oplist = e_oplist_from_irtree(scratch.arena, lhs->root);
|
||||
String8 lhs_bytecode = e_bytecode_from_oplist(scratch.arena, &lhs_oplist);
|
||||
E_Interpretation lhs_interp = e_interpret(lhs_bytecode);
|
||||
E_Value lhs_value = lhs_interp.value;
|
||||
U64 lhs_string_id = lhs_value.u64;
|
||||
|
||||
//- rjf: gather files in this folder
|
||||
String8 folder_path = e_string_from_id(lhs_string_id);
|
||||
String8List folder_paths = {0};
|
||||
String8List file_paths = {0};
|
||||
{
|
||||
OS_FileIter *iter = os_file_iter_begin(scratch.arena, folder_path, 0);
|
||||
for(OS_FileInfo info = {0}; os_file_iter_next(scratch.arena, iter, &info);)
|
||||
{
|
||||
if(info.props.flags & FilePropertyFlag_IsFolder)
|
||||
{
|
||||
str8_list_push(scratch.arena, &folder_paths, push_str8_copy(arena, info.name));
|
||||
}
|
||||
else
|
||||
{
|
||||
str8_list_push(scratch.arena, &file_paths, push_str8_copy(arena, info.name));
|
||||
}
|
||||
}
|
||||
os_file_iter_end(iter);
|
||||
}
|
||||
|
||||
//- rjf: build filtered paths
|
||||
String8List folder_paths__filtered = {0};
|
||||
String8List file_paths__filtered = {0};
|
||||
{
|
||||
// TODO(rjf)
|
||||
folder_paths__filtered = folder_paths;
|
||||
file_paths__filtered = file_paths;
|
||||
}
|
||||
|
||||
//- rjf: build accelerator
|
||||
E_FolderAccel *accel = push_array(arena, E_FolderAccel, 1);
|
||||
accel->folder_path = push_str8_copy(arena, folder_path);
|
||||
accel->folders = str8_array_from_list(arena, &folder_paths__filtered);
|
||||
accel->files = str8_array_from_list(arena, &file_paths__filtered);
|
||||
info.user_data = accel;
|
||||
info.idxed_expr_count = accel->folders.count + accel->files.count;
|
||||
scratch_end(scratch);
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
E_LOOKUP_ACCESS_FUNCTION_DEF(folder)
|
||||
{
|
||||
E_LookupAccess result = {{&e_irnode_nil}};
|
||||
if(kind == E_ExprKind_ArrayIndex)
|
||||
{
|
||||
Temp scratch = scratch_begin(&arena, 1);
|
||||
E_FolderAccel *accel = (E_FolderAccel *)user_data;
|
||||
U64 idx = e_value_from_expr(rhs).u64;
|
||||
if(0 <= idx && idx < accel->folders.count)
|
||||
{
|
||||
String8 folder_path = push_str8f(scratch.arena, "%S/%S", accel->folder_path, accel->folders.v[idx - 0]);
|
||||
U64 string_id = e_id_from_string(folder_path);
|
||||
E_Space space = e_space_make(E_SpaceKind_FileSystem);
|
||||
result.irtree_and_type.root = e_irtree_set_space(arena, space, e_irtree_const_u(arena, string_id));
|
||||
result.irtree_and_type.type_key = e_type_key_cons(.kind = E_TypeKind_Set, .name = str8_lit("folder"));
|
||||
result.irtree_and_type.mode = E_Mode_Value;
|
||||
}
|
||||
else if(accel->folders.count <= idx && idx < accel->folders.count + accel->files.count)
|
||||
{
|
||||
String8 file_path = push_str8f(scratch.arena, "%S/%S", accel->folder_path, accel->files.v[idx - accel->folders.count]);
|
||||
U64 string_id = e_id_from_string(file_path);
|
||||
E_Space space = e_space_make(E_SpaceKind_FileSystem);
|
||||
result.irtree_and_type.root = e_irtree_set_space(arena, space, e_irtree_const_u(arena, string_id));
|
||||
result.irtree_and_type.type_key = e_type_key_cons(.kind = E_TypeKind_Set, .name = str8_lit("file"));
|
||||
result.irtree_and_type.mode = E_Mode_Value;
|
||||
}
|
||||
scratch_end(scratch);
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
E_LOOKUP_INFO_FUNCTION_DEF(file)
|
||||
{
|
||||
E_LookupInfo info = {0};
|
||||
return info;
|
||||
}
|
||||
|
||||
E_LOOKUP_ACCESS_FUNCTION_DEF(file)
|
||||
{
|
||||
E_LookupAccess result = {{&e_irnode_nil}};
|
||||
return result;
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Slice Lookup Rules
|
||||
|
||||
typedef struct E_SliceAccel E_SliceAccel;
|
||||
struct E_SliceAccel
|
||||
{
|
||||
U64 count;
|
||||
U64 base_ptr_vaddr;
|
||||
E_TypeKey element_type_key;
|
||||
};
|
||||
|
||||
E_LOOKUP_INFO_FUNCTION_DEF(slice)
|
||||
{
|
||||
E_LookupInfo info = {0};
|
||||
{
|
||||
Temp scratch = scratch_begin(&arena, 1);
|
||||
E_TypeKind type_kind = e_type_kind_from_key(lhs->type_key);
|
||||
if(type_kind == E_TypeKind_Struct || type_kind == E_TypeKind_Class)
|
||||
{
|
||||
// rjf: unpack members
|
||||
E_MemberArray members = e_type_data_members_from_key__cached(lhs->type_key);
|
||||
|
||||
// rjf: choose base pointer & count members
|
||||
E_Member *base_ptr_member = 0;
|
||||
E_Member *count_member = 0;
|
||||
for(U64 idx = 0; idx < members.count; idx += 1)
|
||||
{
|
||||
E_Member *member = &members.v[idx];
|
||||
E_TypeKey member_type = e_type_unwrap(member->type_key);
|
||||
E_TypeKind member_type_kind = e_type_kind_from_key(member_type);
|
||||
if(count_member == 0 && e_type_kind_is_integer(member_type_kind))
|
||||
{
|
||||
count_member = member;
|
||||
}
|
||||
if(base_ptr_member == 0 && e_type_kind_is_pointer_or_ref(member_type_kind))
|
||||
{
|
||||
base_ptr_member = &members.v[idx];
|
||||
}
|
||||
if(count_member != 0 && base_ptr_member != 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// rjf: evaluate count member, determine count
|
||||
U64 count = 0;
|
||||
if(count_member != 0)
|
||||
{
|
||||
E_Expr *count_member_expr = e_expr_irext_member_access(arena, &e_expr_nil, lhs, count_member->name);
|
||||
E_Value count_member_value = e_value_from_expr(count_member_expr);
|
||||
count = count_member_value.u64;
|
||||
}
|
||||
|
||||
// rjf: evaluate base ptr member, determine base address
|
||||
U64 base_ptr_vaddr = 0;
|
||||
if(base_ptr_member != 0)
|
||||
{
|
||||
E_Expr *base_ptr_member_expr = e_expr_irext_member_access(arena, &e_expr_nil, lhs, base_ptr_member->name);
|
||||
E_Value base_ptr_member_value = e_value_from_expr(base_ptr_member_expr);
|
||||
base_ptr_vaddr = base_ptr_member_value.u64;
|
||||
}
|
||||
|
||||
// rjf: determine element type
|
||||
E_TypeKey element_type_key = zero_struct;
|
||||
if(base_ptr_member != 0)
|
||||
{
|
||||
element_type_key = e_type_direct_from_key(base_ptr_member->type_key);
|
||||
}
|
||||
|
||||
// rjf: fill
|
||||
if(count_member && base_ptr_member)
|
||||
{
|
||||
E_SliceAccel *accel = push_array(arena, E_SliceAccel, 1);
|
||||
accel->count = count;
|
||||
accel->base_ptr_vaddr = base_ptr_vaddr;
|
||||
accel->element_type_key = element_type_key;
|
||||
info.user_data = accel;
|
||||
info.idxed_expr_count = accel->count;
|
||||
}
|
||||
|
||||
// rjf: fall back to default
|
||||
else
|
||||
{
|
||||
info = E_LOOKUP_INFO_FUNCTION_NAME(default)(arena, lhs, filter);
|
||||
}
|
||||
}
|
||||
scratch_end(scratch);
|
||||
}
|
||||
return info;
|
||||
}
|
||||
|
||||
E_LOOKUP_RANGE_FUNCTION_DEF(slice)
|
||||
{
|
||||
if(user_data == 0)
|
||||
{
|
||||
E_LOOKUP_RANGE_FUNCTION_NAME(default)(arena, lhs, idx_range, exprs, exprs_strings, user_data);
|
||||
}
|
||||
else
|
||||
{
|
||||
E_SliceAccel *accel = (E_SliceAccel *)user_data;
|
||||
U64 out_idx = 0;
|
||||
U64 element_type_size = e_type_byte_size_from_key(accel->element_type_key);
|
||||
for(U64 idx = idx_range.min; idx < idx_range.max; idx += 1, out_idx += 1)
|
||||
{
|
||||
E_Expr *expr = e_push_expr(arena, E_ExprKind_LeafOffset, 0);
|
||||
expr->value.u64 = accel->base_ptr_vaddr + idx*element_type_size;
|
||||
expr->type_key = accel->element_type_key;
|
||||
exprs[out_idx] = expr;
|
||||
exprs_strings[out_idx] = push_str8f(arena, "[%I64u]", idx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
@@ -95,6 +322,15 @@ e_lookup_rule_map_make(Arena *arena, U64 slots_count)
|
||||
E_LookupRuleMap map = {0};
|
||||
map.slots_count = slots_count;
|
||||
map.slots = push_array(arena, E_LookupRuleSlot, map.slots_count);
|
||||
e_lookup_rule_map_insert_new(arena, &map, str8_lit("folder"),
|
||||
.info = E_LOOKUP_INFO_FUNCTION_NAME(folder),
|
||||
.access = E_LOOKUP_ACCESS_FUNCTION_NAME(folder));
|
||||
e_lookup_rule_map_insert_new(arena, &map, str8_lit("file"),
|
||||
.info = E_LOOKUP_INFO_FUNCTION_NAME(file),
|
||||
.access = E_LOOKUP_ACCESS_FUNCTION_NAME(file));
|
||||
e_lookup_rule_map_insert_new(arena, &map, str8_lit("slice"),
|
||||
.info = E_LOOKUP_INFO_FUNCTION_NAME(slice),
|
||||
.range = E_LOOKUP_RANGE_FUNCTION_NAME(slice));
|
||||
return map;
|
||||
}
|
||||
|
||||
@@ -582,75 +818,6 @@ E_IRGEN_FUNCTION_DEF(array)
|
||||
return irtree;
|
||||
}
|
||||
|
||||
E_IRGEN_FUNCTION_DEF(slice)
|
||||
{
|
||||
Temp scratch = scratch_begin(&arena, 1);
|
||||
E_IRTreeAndType irtree = e_irtree_and_type_from_expr(arena, expr);
|
||||
E_TypeKind type_kind = e_type_kind_from_key(irtree.type_key);
|
||||
if(type_kind == E_TypeKind_Struct || type_kind == E_TypeKind_Class)
|
||||
{
|
||||
// rjf: unpack members
|
||||
E_MemberArray members = e_type_data_members_from_key__cached(irtree.type_key);
|
||||
|
||||
// rjf: choose base pointer & count members
|
||||
E_Member *base_ptr_member = 0;
|
||||
E_Member *count_member = 0;
|
||||
for(U64 idx = 0; idx < members.count; idx += 1)
|
||||
{
|
||||
E_Member *member = &members.v[idx];
|
||||
E_TypeKey member_type = e_type_unwrap(member->type_key);
|
||||
E_TypeKind member_type_kind = e_type_kind_from_key(member_type);
|
||||
if(count_member == 0 && e_type_kind_is_integer(member_type_kind))
|
||||
{
|
||||
count_member = member;
|
||||
}
|
||||
if(base_ptr_member == 0 && e_type_kind_is_pointer_or_ref(member_type_kind))
|
||||
{
|
||||
base_ptr_member = &members.v[idx];
|
||||
}
|
||||
if(count_member != 0 && base_ptr_member != 0)
|
||||
{
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// rjf: evaluate count member, determine count
|
||||
U64 count = 0;
|
||||
if(count_member != 0)
|
||||
{
|
||||
E_Expr *count_member_expr = e_expr_irext_member_access(arena, expr, &irtree, count_member->name);
|
||||
E_Value count_member_value = e_value_from_expr(count_member_expr);
|
||||
count = count_member_value.u64;
|
||||
}
|
||||
|
||||
// rjf: generate new struct slice type
|
||||
E_TypeKey slice_type_key = zero_struct;
|
||||
if(base_ptr_member != 0 && count_member != 0)
|
||||
{
|
||||
String8 struct_name = e_type_string_from_key(scratch.arena, irtree.type_key);
|
||||
E_TypeKey element_type_key = e_type_ptee_from_key(base_ptr_member->type_key);
|
||||
E_TypeKey sized_base_ptr_type_key = e_type_key_cons_ptr(e_type_state->ctx->primary_module->arch, element_type_key, count, 0);
|
||||
E_MemberList slice_type_members = {0};
|
||||
e_member_list_push(scratch.arena, &slice_type_members, count_member);
|
||||
e_member_list_push(scratch.arena, &slice_type_members, &(E_Member){.kind = E_MemberKind_DataField, .type_key = sized_base_ptr_type_key, .name = base_ptr_member->name, .off = base_ptr_member->off});
|
||||
E_MemberArray slice_type_members_array = e_member_array_from_list(scratch.arena, &slice_type_members);
|
||||
slice_type_key = e_type_key_cons(.arch = e_type_state->ctx->primary_module->arch,
|
||||
.kind = E_TypeKind_Struct,
|
||||
.name = struct_name,
|
||||
.members = slice_type_members_array.v,
|
||||
.count = slice_type_members_array.count);
|
||||
}
|
||||
|
||||
// rjf: overwrite type
|
||||
if(!e_type_key_match(slice_type_key, e_type_key_zero()))
|
||||
{
|
||||
irtree.type_key = slice_type_key;
|
||||
}
|
||||
}
|
||||
scratch_end(scratch);
|
||||
return irtree;
|
||||
}
|
||||
|
||||
E_IRGEN_FUNCTION_DEF(wrap)
|
||||
{
|
||||
Temp scratch = scratch_begin(&arena, 1);
|
||||
@@ -703,7 +870,6 @@ e_irgen_rule_map_make(Arena *arena, U64 slots_count)
|
||||
e_irgen_rule_map_insert_new(arena, &map, str8_lit("cast"), .irgen = E_IRGEN_FUNCTION_NAME(cast));
|
||||
e_irgen_rule_map_insert_new(arena, &map, str8_lit("bswap"), .irgen = E_IRGEN_FUNCTION_NAME(bswap));
|
||||
e_irgen_rule_map_insert_new(arena, &map, str8_lit("array"), .irgen = E_IRGEN_FUNCTION_NAME(array));
|
||||
e_irgen_rule_map_insert_new(arena, &map, str8_lit("slice"), .irgen = E_IRGEN_FUNCTION_NAME(slice));
|
||||
e_irgen_rule_map_insert_new(arena, &map, str8_lit("wrap"), .irgen = E_IRGEN_FUNCTION_NAME(wrap));
|
||||
return map;
|
||||
}
|
||||
@@ -877,6 +1043,59 @@ e_auto_hook_tag_exprs_from_type_key__cached(E_TypeKey type_key)
|
||||
return exprs;
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Evaluated String IDs
|
||||
|
||||
internal U64
|
||||
e_id_from_string(String8 string)
|
||||
{
|
||||
U64 hash = e_hash_from_string(5381, string);
|
||||
U64 hash_slot_idx = hash%e_ir_state->string_id_map->hash_slots_count;
|
||||
E_StringIDNode *node = 0;
|
||||
for(E_StringIDNode *n = e_ir_state->string_id_map->hash_slots[hash_slot_idx].first; n != 0; n = n->hash_next)
|
||||
{
|
||||
if(str8_match(n->string, string, 0))
|
||||
{
|
||||
node = n;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(node == 0)
|
||||
{
|
||||
e_ir_state->string_id_gen += 1;
|
||||
U64 id = e_ir_state->string_id_gen;
|
||||
U64 id_slot_idx = id%e_ir_state->string_id_map->id_slots_count;
|
||||
node = push_array(e_ir_state->arena, E_StringIDNode, 1);
|
||||
SLLQueuePush_N(e_ir_state->string_id_map->hash_slots[hash_slot_idx].first, e_ir_state->string_id_map->hash_slots[hash_slot_idx].last, node, hash_next);
|
||||
SLLQueuePush_N(e_ir_state->string_id_map->id_slots[id_slot_idx].first, e_ir_state->string_id_map->hash_slots[id_slot_idx].last, node, id_next);
|
||||
node->id = id;
|
||||
node->string = push_str8_copy(e_ir_state->arena, string);
|
||||
}
|
||||
U64 result = node->id;
|
||||
return result;
|
||||
}
|
||||
|
||||
internal String8
|
||||
e_string_from_id(U64 id)
|
||||
{
|
||||
U64 id_slot_idx = id%e_ir_state->string_id_map->id_slots_count;
|
||||
E_StringIDNode *node = 0;
|
||||
for(E_StringIDNode *n = e_ir_state->string_id_map->id_slots[id_slot_idx].first; n != 0; n = n->id_next)
|
||||
{
|
||||
if(n->id == id)
|
||||
{
|
||||
node = n;
|
||||
break;
|
||||
}
|
||||
}
|
||||
String8 result = {0};
|
||||
if(node != 0)
|
||||
{
|
||||
result = node->string;
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: IR-ization Functions
|
||||
|
||||
@@ -1910,14 +2129,26 @@ E_IRGEN_FUNCTION_DEF(default)
|
||||
//- rjf: leaf file paths
|
||||
case E_ExprKind_LeafFilePath:
|
||||
{
|
||||
U128 key = fs_key_from_path_range(expr->string, r1u64(0, max_U64));
|
||||
E_Space space = {E_SpaceKind_HashStoreKey, .u128 = key};
|
||||
U64 size = fs_size_from_path(expr->string);
|
||||
E_IRNode *base_offset = e_irtree_const_u(arena, 0);
|
||||
base_offset->space = space;
|
||||
result.root = base_offset;
|
||||
result.type_key = e_type_key_cons_array(e_type_key_basic(E_TypeKind_U8), size);
|
||||
result.mode = E_Mode_Offset;
|
||||
FileProperties props = fs_properties_from_path(expr->string);
|
||||
if(props.flags & FilePropertyFlag_IsFolder)
|
||||
{
|
||||
E_Space space = e_space_make(E_SpaceKind_FileSystem);
|
||||
result.root = e_irtree_set_space(arena, space, e_irtree_const_u(arena, e_id_from_string(expr->string)));
|
||||
result.type_key = e_type_key_cons(.kind = E_TypeKind_Set, .name = str8_lit("folder"));
|
||||
result.mode = E_Mode_Value;
|
||||
}
|
||||
else
|
||||
{
|
||||
U128 key = fs_key_from_path_range(expr->string, r1u64(0, max_U64));
|
||||
E_Space space = {E_SpaceKind_HashStoreKey, .u128 = key};
|
||||
U64 size = props.size;
|
||||
E_IRNode *base_offset = e_irtree_const_u(arena, 0);
|
||||
base_offset->space = space;
|
||||
result.root = base_offset;
|
||||
result.root->string = push_str8_copy(arena, expr->string);
|
||||
result.type_key = e_type_key_cons_array(e_type_key_basic(E_TypeKind_U8), size);
|
||||
result.mode = E_Mode_Offset;
|
||||
}
|
||||
}break;
|
||||
|
||||
//- rjf: types
|
||||
|
||||
@@ -266,6 +266,34 @@ struct E_TypeAutoHookCacheMap
|
||||
E_TypeAutoHookCacheSlot *slots;
|
||||
};
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Evaluated String ID Map
|
||||
|
||||
typedef struct E_StringIDNode E_StringIDNode;
|
||||
struct E_StringIDNode
|
||||
{
|
||||
E_StringIDNode *hash_next;
|
||||
E_StringIDNode *id_next;
|
||||
U64 id;
|
||||
String8 string;
|
||||
};
|
||||
|
||||
typedef struct E_StringIDSlot E_StringIDSlot;
|
||||
struct E_StringIDSlot
|
||||
{
|
||||
E_StringIDNode *first;
|
||||
E_StringIDNode *last;
|
||||
};
|
||||
|
||||
typedef struct E_StringIDMap E_StringIDMap;
|
||||
struct E_StringIDMap
|
||||
{
|
||||
U64 id_slots_count;
|
||||
E_StringIDSlot *id_slots;
|
||||
U64 hash_slots_count;
|
||||
E_StringIDSlot *hash_slots;
|
||||
};
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: IR Context
|
||||
|
||||
@@ -310,6 +338,8 @@ struct E_IRState
|
||||
E_TypeAutoHookCacheMap *type_auto_hook_cache_map;
|
||||
U64 irtree_and_type_cache_slots_count;
|
||||
E_IRTreeAndTypeCacheSlot *irtree_and_type_cache_slots;
|
||||
U64 string_id_gen;
|
||||
E_StringIDMap *string_id_map;
|
||||
};
|
||||
|
||||
////////////////////////////////
|
||||
@@ -380,6 +410,12 @@ internal void e_auto_hook_map_insert_new_(Arena *arena, E_AutoHookMap *map, E_Au
|
||||
internal E_ExprList e_auto_hook_tag_exprs_from_type_key(Arena *arena, E_TypeKey type_key);
|
||||
internal E_ExprList e_auto_hook_tag_exprs_from_type_key__cached(E_TypeKey type_key);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Evaluated String IDs
|
||||
|
||||
internal U64 e_id_from_string(String8 string);
|
||||
internal String8 e_string_from_id(U64 id);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: IR-ization Functions
|
||||
|
||||
|
||||
@@ -432,10 +432,6 @@ e_type_key_cons_(E_ConsTypeParams *params)
|
||||
{
|
||||
node->byte_size = bit_size_from_arch(node->params.arch)/8;
|
||||
}break;
|
||||
case E_TypeKind_SpacePtr:
|
||||
{
|
||||
node->byte_size = sizeof(U64) + sizeof(E_Space);
|
||||
}break;
|
||||
case E_TypeKind_Array:
|
||||
{
|
||||
U64 ptee_size = e_type_byte_size_from_key(node->params.direct_key);
|
||||
@@ -1693,12 +1689,6 @@ e_type_lhs_string_from_key(Arena *arena, E_TypeKey key, String8List *out, U32 pr
|
||||
}
|
||||
}break;
|
||||
|
||||
case E_TypeKind_SpacePtr:
|
||||
{
|
||||
E_TypeKey direct = e_type_direct_from_key(key);
|
||||
e_type_lhs_string_from_key(arena, direct, out, 1, skip_return);
|
||||
}break;
|
||||
|
||||
case E_TypeKind_LRef:
|
||||
{
|
||||
E_TypeKey direct = e_type_direct_from_key(key);
|
||||
|
||||
@@ -139,7 +139,7 @@ E_OpInfo e_expr_kind_op_info_table[51] =
|
||||
{ E_OpKind_Null, 0, str8_lit_comp("=>"), str8_lit_comp(","), str8_lit_comp("") },
|
||||
};
|
||||
|
||||
U8 e_kind_basic_byte_size_table[57] =
|
||||
U8 e_kind_basic_byte_size_table[56] =
|
||||
{
|
||||
0,
|
||||
0,
|
||||
@@ -197,10 +197,9 @@ U8 e_kind_basic_byte_size_table[57] =
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
0,
|
||||
};
|
||||
|
||||
String8 e_kind_basic_string_table[57] =
|
||||
String8 e_kind_basic_string_table[56] =
|
||||
{
|
||||
str8_lit_comp(""),
|
||||
str8_lit_comp("void"),
|
||||
@@ -257,7 +256,6 @@ str8_lit_comp("class"),
|
||||
str8_lit_comp("enum"),
|
||||
str8_lit_comp("bitfield"),
|
||||
str8_lit_comp("variadic"),
|
||||
str8_lit_comp("space_ptr"),
|
||||
str8_lit_comp("set"),
|
||||
};
|
||||
|
||||
|
||||
@@ -74,7 +74,6 @@ E_TypeKind_IncompleteClass,
|
||||
E_TypeKind_IncompleteEnum,
|
||||
E_TypeKind_Bitfield,
|
||||
E_TypeKind_Variadic,
|
||||
E_TypeKind_SpacePtr,
|
||||
E_TypeKind_Set,
|
||||
E_TypeKind_COUNT,
|
||||
E_TypeKind_FirstBasic = E_TypeKind_Void,
|
||||
@@ -167,8 +166,8 @@ extern String8 e_token_kind_strings[6];
|
||||
extern String8 e_expr_kind_strings[51];
|
||||
extern String8 e_interpretation_code_display_strings[11];
|
||||
extern E_OpInfo e_expr_kind_op_info_table[51];
|
||||
extern U8 e_kind_basic_byte_size_table[57];
|
||||
extern String8 e_kind_basic_string_table[57];
|
||||
extern U8 e_kind_basic_byte_size_table[56];
|
||||
extern String8 e_kind_basic_string_table[56];
|
||||
|
||||
C_LINKAGE_END
|
||||
|
||||
|
||||
@@ -498,7 +498,7 @@ ev_keyed_expr_push_tags(Arena *arena, EV_View *view, EV_Block *block, EV_Key key
|
||||
//~ rjf: Block Building
|
||||
|
||||
internal EV_BlockTree
|
||||
ev_block_tree_from_eval(Arena *arena, EV_View *view, String8 filter, E_Eval eval)
|
||||
ev_block_tree_from_exprs(Arena *arena, EV_View *view, String8 filter, E_ExprChain exprs)
|
||||
{
|
||||
ProfBeginFunction();
|
||||
EV_BlockTree tree = {&ev_nil_block};
|
||||
@@ -508,7 +508,7 @@ ev_block_tree_from_eval(Arena *arena, EV_View *view, String8 filter, E_Eval eval
|
||||
//- rjf: generate root expression
|
||||
EV_Key root_key = ev_key_root();
|
||||
EV_Key root_row_key = ev_key_make(ev_hash_from_key(root_key), 1);
|
||||
E_Expr *root_expr = e_expr_copy(arena, eval.exprs.last);
|
||||
E_Expr *root_expr = e_expr_copy(arena, exprs.last);
|
||||
ev_keyed_expr_push_tags(arena, view, &ev_nil_block, root_row_key, root_expr);
|
||||
|
||||
//- rjf: generate root block
|
||||
|
||||
@@ -337,7 +337,7 @@ internal void ev_keyed_expr_push_tags(Arena *arena, EV_View *view, EV_Block *blo
|
||||
////////////////////////////////
|
||||
//~ rjf: Block Building
|
||||
|
||||
internal EV_BlockTree ev_block_tree_from_eval(Arena *arena, EV_View *view, String8 filter, E_Eval eval);
|
||||
internal EV_BlockTree ev_block_tree_from_exprs(Arena *arena, EV_View *view, String8 filter, E_ExprChain exprs);
|
||||
internal U64 ev_depth_from_block(EV_Block *block);
|
||||
|
||||
////////////////////////////////
|
||||
|
||||
@@ -189,11 +189,11 @@ fs_key_from_path_range(String8 path, Rng1U64 range)
|
||||
return key;
|
||||
}
|
||||
|
||||
internal U64
|
||||
fs_timestamp_from_path(String8 path)
|
||||
internal FileProperties
|
||||
fs_properties_from_path(String8 path)
|
||||
{
|
||||
Temp scratch = scratch_begin(0, 0);
|
||||
U64 result = 0;
|
||||
FileProperties result = {0};
|
||||
path = path_normalized_from_string(scratch.arena, path);
|
||||
U64 path_hash = fs_little_hash_from_string(path);
|
||||
U64 slot_idx = path_hash%fs_shared->slots_count;
|
||||
@@ -206,33 +206,7 @@ fs_timestamp_from_path(String8 path)
|
||||
{
|
||||
if(str8_match(path, n->path, 0))
|
||||
{
|
||||
result = n->timestamp;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
scratch_end(scratch);
|
||||
return result;
|
||||
}
|
||||
|
||||
internal U64
|
||||
fs_size_from_path(String8 path)
|
||||
{
|
||||
Temp scratch = scratch_begin(0, 0);
|
||||
U64 result = 0;
|
||||
path = path_normalized_from_string(scratch.arena, path);
|
||||
U64 path_hash = fs_little_hash_from_string(path);
|
||||
U64 slot_idx = path_hash%fs_shared->slots_count;
|
||||
U64 stripe_idx = slot_idx%fs_shared->stripes_count;
|
||||
FS_Slot *slot = &fs_shared->slots[slot_idx];
|
||||
FS_Stripe *stripe = &fs_shared->stripes[stripe_idx];
|
||||
OS_MutexScopeR(stripe->rw_mutex)
|
||||
{
|
||||
for(FS_Node *n = slot->first; n != 0; n = n->next)
|
||||
{
|
||||
if(str8_match(path, n->path, 0))
|
||||
{
|
||||
result = n->size;
|
||||
result = n->props;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -333,7 +307,7 @@ ASYNC_WORK_DEF(fs_stream_work)
|
||||
B32 read_good = (pre_props.modified == post_props.modified &&
|
||||
pre_props.size == post_props.size &&
|
||||
read_size == data.size &&
|
||||
file_handle_is_valid);
|
||||
(file_handle_is_valid || pre_props.flags & FilePropertyFlag_IsFolder));
|
||||
if(!read_good)
|
||||
{
|
||||
ProfScope("abort")
|
||||
@@ -367,12 +341,11 @@ ASYNC_WORK_DEF(fs_stream_work)
|
||||
}
|
||||
if(node != 0 && read_good)
|
||||
{
|
||||
if(node->timestamp != 0)
|
||||
if(node->props.modified != 0)
|
||||
{
|
||||
ins_atomic_u64_inc_eval(&fs_shared->change_gen);
|
||||
}
|
||||
node->timestamp = post_props.modified;
|
||||
node->size = post_props.size;
|
||||
node->props = post_props;
|
||||
}
|
||||
}
|
||||
os_condition_variable_broadcast(path_stripe->cv);
|
||||
@@ -403,7 +376,7 @@ fs_detector_thread__entry_point(void *p)
|
||||
for(FS_Node *n = slot->first; n != 0; n = n->next)
|
||||
{
|
||||
FileProperties props = os_properties_from_file_path(n->path);
|
||||
if(props.modified != n->timestamp)
|
||||
if(props.modified != n->props.modified)
|
||||
{
|
||||
for(U64 range_slot_idx = 0; range_slot_idx < n->slots_count; range_slot_idx += 1)
|
||||
{
|
||||
|
||||
@@ -31,8 +31,7 @@ struct FS_Node
|
||||
|
||||
// rjf: file metadata
|
||||
String8 path;
|
||||
U64 timestamp;
|
||||
U64 size;
|
||||
FileProperties props;
|
||||
|
||||
// rjf: sub-table of per-requested-file-range info
|
||||
U64 slots_count;
|
||||
@@ -108,8 +107,7 @@ internal U64 fs_change_gen(void);
|
||||
internal U128 fs_hash_from_path_range(String8 path, Rng1U64 range, U64 endt_us);
|
||||
internal U128 fs_key_from_path_range(String8 path, Rng1U64 range);
|
||||
|
||||
internal U64 fs_timestamp_from_path(String8 path);
|
||||
internal U64 fs_size_from_path(String8 path);
|
||||
internal FileProperties fs_properties_from_path(String8 path);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Streaming Work
|
||||
|
||||
@@ -555,8 +555,8 @@ fnt_hash2style_from_tag_size_flags(FNT_Tag tag, F32 size, FNT_RasterFlags flags)
|
||||
hash2style_node = push_array(f_state->raster_arena, FNT_Hash2StyleRasterCacheNode, 1);
|
||||
DLLPushBack_NP(slot->first, slot->last, hash2style_node, hash_next, hash_prev);
|
||||
hash2style_node->style_hash = style_hash;
|
||||
hash2style_node->ascent = metrics.ascent;
|
||||
hash2style_node->descent= metrics.descent;
|
||||
hash2style_node->ascent = metrics.ascent;
|
||||
hash2style_node->descent = metrics.descent;
|
||||
hash2style_node->utf8_class1_direct_map = push_array_no_zero(f_state->raster_arena, F_RasterCacheInfo, 256);
|
||||
hash2style_node->hash2info_slots_count = 1024;
|
||||
hash2style_node->hash2info_slots = push_array(f_state->raster_arena, FNT_Hash2InfoRasterCacheSlot, hash2style_node->hash2info_slots_count);
|
||||
|
||||
@@ -241,7 +241,7 @@ E_LOOKUP_RANGE_FUNCTION_DEF(registers)
|
||||
}
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Top-Level Config Eval Hooks
|
||||
//~ rjf: Config Eval Hooks
|
||||
|
||||
typedef struct RD_CfgLookupAccel RD_CfgLookupAccel;
|
||||
struct RD_CfgLookupAccel
|
||||
@@ -2057,7 +2057,7 @@ rd_title_fstrs_from_cfg(Arena *arena, RD_Cfg *cfg, Vec4F32 secondary_color, F32
|
||||
//
|
||||
DR_FStrParams params = {rd_font_from_slot(RD_FontSlot_Main), rd_raster_flags_from_slot(RD_FontSlot_Main), rgba, size};
|
||||
B32 running_is_secondary = 0;
|
||||
#define start_secondary() if(!running_is_secondary){running_is_secondary = 1; params.color = secondary_color; params.size = size*0.8f;}
|
||||
#define start_secondary() if(!running_is_secondary){running_is_secondary = 1; params.color = secondary_color; params.size = size*0.95f;}
|
||||
|
||||
//- rjf: push icon
|
||||
if(icon_kind != RD_IconKind_Null)
|
||||
@@ -6941,7 +6941,7 @@ rd_window_frame(void)
|
||||
RD_RegsScope(.view = view->id)
|
||||
{
|
||||
rd_cfg_new_replace(expr, ws->hover_eval_string);
|
||||
EV_BlockTree predicted_block_tree = ev_block_tree_from_eval(scratch.arena, rd_view_eval_view(), str8_zero(), hover_eval);
|
||||
EV_BlockTree predicted_block_tree = ev_block_tree_from_exprs(scratch.arena, rd_view_eval_view(), str8_zero(), hover_eval.exprs);
|
||||
F32 row_height_px = floor_f32(ui_top_font_size()*2.5f);
|
||||
U64 max_row_count = (U64)floor_f32(ui_top_font_size()*10.f / row_height_px);
|
||||
if(ws->hover_eval_focused)
|
||||
|
||||
@@ -1108,7 +1108,7 @@ rd_watch_row_info_from_row(Arena *arena, EV_Row *row)
|
||||
}
|
||||
|
||||
// rjf: for 'add-new' rows in meta-cfg evaluation spaces, only do expr
|
||||
else if(info.eval.exprs.last == &e_expr_nil && info.group_cfg_name.size != 0)
|
||||
else if(info.eval.exprs.last == &e_expr_nil && info.group_cfg_name.size != 0 && info.group_cfg_child == &rd_nil_cfg)
|
||||
{
|
||||
rd_watch_cell_list_push_new(arena, &info.cells, RD_WatchCellKind_Expr, .pct = 1.f);
|
||||
}
|
||||
@@ -1554,7 +1554,7 @@ RD_VIEW_UI_FUNCTION_DEF(watch)
|
||||
{
|
||||
ev_key_set_expansion(eval_view, ev_key_root(), ev_key_make(ev_hash_from_key(ev_key_root()), 1), 1);
|
||||
}
|
||||
block_tree = ev_block_tree_from_eval(scratch.arena, eval_view, filter, eval);
|
||||
block_tree = ev_block_tree_from_exprs(scratch.arena, eval_view, filter, eval.exprs);
|
||||
block_ranges = ev_block_range_list_from_tree(scratch.arena, &block_tree);
|
||||
if(implicit_root && block_ranges.first != 0)
|
||||
{
|
||||
@@ -3438,7 +3438,7 @@ RD_VIEW_UI_FUNCTION_DEF(text)
|
||||
B32 file_is_out_of_date = 0;
|
||||
String8 out_of_date_dbgi_name = {0};
|
||||
{
|
||||
U64 file_timestamp = fs_timestamp_from_path(rd_regs()->file_path);
|
||||
U64 file_timestamp = fs_properties_from_path(rd_regs()->file_path).modified;
|
||||
if(file_timestamp != 0)
|
||||
{
|
||||
for(DI_KeyNode *n = dbgi_keys.first; n != 0; n = n->next)
|
||||
|
||||
Reference in New Issue
Block a user