define ctrl entity eval spaces once, in ctrl layer - nest in rd layer

This commit is contained in:
Ryan Fleury
2025-10-13 12:40:28 -07:00
parent 6bcbf5909d
commit 87edc583bf
11 changed files with 166 additions and 102 deletions
+2 -2
View File
@@ -745,8 +745,8 @@ struct E_AutoHookParams
////////////////////////////////
//~ rjf: Evaluation Context
typedef U64 E_SpaceGenFunction(void *user_data, E_Space space);
typedef B32 E_SpaceRWFunction(void *user_data, E_Space space, void *out, Rng1U64 offset_range);
typedef U64 E_SpaceGenFunction(E_Space space);
typedef B32 E_SpaceRWFunction(E_Space space, void *out, Rng1U64 offset_range);
//- rjf: base context
+71 -4
View File
@@ -61,7 +61,7 @@ e_space_gen(E_Space space)
U64 result = 0;
if(e_base_ctx->space_gen != 0)
{
result = e_base_ctx->space_gen(e_base_ctx->space_rw_user_data, space);
result = e_base_ctx->space_gen(space);
}
return result;
}
@@ -71,9 +71,70 @@ e_space_read(E_Space space, void *out, Rng1U64 range)
{
ProfBeginFunction();
B32 result = 0;
if(e_interpret_ctx->space_read != 0)
{
result = e_interpret_ctx->space_read(e_interpret_ctx->space_rw_user_data, space, out, range);
switch(space.kind)
{
//- rjf: reads from hash store key
case E_SpaceKind_HashStoreKey:
{
C_Root root = {space.u64_0};
C_ID id = {space.u128};
C_Key key = c_key_make(root, id);
U128 hash = c_hash_from_key(key, 0);
Access *access = access_open();
{
String8 data = c_data_from_hash(access, hash);
Rng1U64 legal_range = r1u64(0, data.size);
Rng1U64 read_range = intersect_1u64(range, legal_range);
if(read_range.min < read_range.max)
{
result = 1;
MemoryCopy(out, data.str + read_range.min, dim_1u64(read_range));
}
}
access_close(access);
}break;
//- rjf: file reads
case E_SpaceKind_File:
{
// rjf: unpack space/path
U64 file_path_string_id = space.u64_0;
String8 file_path = e_string_from_id(file_path_string_id);
// rjf: find containing chunk range
U64 chunk_size = KB(4);
Rng1U64 containing_range = range;
containing_range.min -= containing_range.min%chunk_size;
containing_range.max += chunk_size-1;
containing_range.max -= containing_range.max%chunk_size;
// rjf: map to hash
C_Key key = fs_key_from_path_range(file_path, containing_range, 0);
U128 hash = c_hash_from_key(key, 0);
// rjf: look up from hash store
Access *access = access_open();
{
String8 data = c_data_from_hash(access, hash);
Rng1U64 legal_range = r1u64(containing_range.min, containing_range.min + data.size);
Rng1U64 read_range = intersect_1u64(range, legal_range);
if(read_range.min < read_range.max)
{
result = 1;
MemoryCopy(out, data.str + read_range.min - containing_range.min, dim_1u64(read_range));
}
}
access_close(access);
}break;
//- rjf: default -> use hooks
default:
if(e_interpret_ctx->space_read != 0)
{
result = e_interpret_ctx->space_read(space, out, range);
}break;
}
}
ProfEnd();
return result;
@@ -86,7 +147,13 @@ e_space_write(E_Space space, void *in, Rng1U64 range)
B32 result = 0;
if(e_interpret_ctx->space_write != 0)
{
result = e_interpret_ctx->space_write(e_interpret_ctx->space_rw_user_data, space, in, range);
switch(space.kind)
{
default:
{
result = e_interpret_ctx->space_write(space, in, range);
}break;
}
}
ProfEnd();
return result;
-1
View File
@@ -10,7 +10,6 @@
typedef struct E_InterpretCtx E_InterpretCtx;
struct E_InterpretCtx
{
void *space_rw_user_data;
E_SpaceRWFunction *space_read;
E_SpaceRWFunction *space_write;
E_Space primary_space;
+53
View File
@@ -2570,6 +2570,59 @@ E_TYPE_EXPAND_RANGE_FUNCTION_DEF(array)
}
}
////////////////////////////////
//~ rjf: (Built-In Type Hooks) `list` lens
typedef struct E_ListGatherArtifact E_ListGatherArtifact;
struct E_ListGatherArtifact
{
U64 *node_vaddrs;
U64 node_vaddrs_count;
};
internal AC_Artifact
e_list_gather_artifact_create(String8 key, B32 *cancel_signal, B32 *retry_out, U64 *gen_out)
{
}
internal void
e_list_gather_artifact_destroy(AC_Artifact artifact)
{
}
E_TYPE_EXPAND_INFO_FUNCTION_DEF(list)
{
E_Type *type = e_type_from_key(eval.irtree.type_key);
String8 next_link_member_name = str8_lit("next");
if(type->args != 0 && type->count > 0)
{
next_link_member_name = type->args[0]->string;
}
E_TypeKey node_type_key = e_type_key_unwrap(eval.irtree.type_key, E_TypeUnwrapFlag_All);
E_Member next_link_member = e_type_member_from_key_name__cached(node_type_key, next_link_member_name);
if(next_link_member.kind != E_MemberKind_DataField)
{
// TODO(rjf): error reporting
}
else
{
}
E_TypeExpandInfo info = {0, 0};
return info;
}
E_TYPE_EXPAND_RANGE_FUNCTION_DEF(list)
{
U64 read_range_count = dim_1u64(idx_range);
for(U64 idx = 0; idx < read_range_count; idx += 1)
{
evals_out[idx] = e_eval_wrapf(eval, "$[%I64u]", idx_range.min + idx);
}
}
////////////////////////////////
//~ rjf: (Built-In Type Hooks) `slice` lens