simplify stylized watch row building rules; allow buttons to be editable, maintain expr key stability even in different watch row styles

This commit is contained in:
Ryan Fleury
2025-02-17 09:48:26 -08:00
parent 5d8e6dac91
commit 2636f296cc
9 changed files with 120 additions and 49 deletions
+1
View File
@@ -127,6 +127,7 @@ E_ExprKindTable:
{ LeafF32 Null 0 "F32" "" "" "" }
{ LeafIdent Null 0 "leaf_ident" "" "" "" }
{ LeafOffset Null 0 "leaf_offset" "" "" "" }
{ LeafValue Null 0 "leaf_value" "" "" "" }
{ LeafFilePath Null 0 "leaf_filepath" "" "" "" }
{ TypeIdent Null 0 "type_ident" "" "" "" }
+24 -3
View File
@@ -170,7 +170,7 @@ E_LOOKUP_RANGE_FUNCTION_DEF(folder)
{
String8 folder_name = accel->folders.v[idx - 0];
String8 folder_path = push_str8f(scratch.arena, "%S/%S", accel->folder_path, folder_name);
expr = e_push_expr(arena, E_ExprKind_LeafOffset, 0);
expr = e_push_expr(arena, E_ExprKind_LeafValue, 0);
expr->type_key = e_type_key_cons(.kind = E_TypeKind_Set, .name = str8_lit("folder"));
expr->space = e_space_make(E_SpaceKind_FileSystem);
expr->value.u64 = e_id_from_string(folder_path);
@@ -180,7 +180,7 @@ E_LOOKUP_RANGE_FUNCTION_DEF(folder)
{
String8 file_name = accel->files.v[idx - accel->folders.count];
String8 file_path = push_str8f(scratch.arena, "%S/%S", accel->folder_path, file_name);
expr = e_push_expr(arena, E_ExprKind_LeafOffset, 0);
expr = e_push_expr(arena, E_ExprKind_LeafValue, 0);
expr->type_key = e_type_key_cons(.kind = E_TypeKind_Set, .name = str8_lit("file"));
expr->space = e_space_make(E_SpaceKind_FileSystem);
expr->value.u64 = e_id_from_string(file_path);
@@ -305,6 +305,7 @@ E_LOOKUP_RANGE_FUNCTION_DEF(file)
typedef struct E_SliceAccel E_SliceAccel;
struct E_SliceAccel
{
Arch arch;
U64 count;
U64 base_ptr_vaddr;
E_TypeKey element_type_key;
@@ -343,6 +344,14 @@ E_LOOKUP_INFO_FUNCTION_DEF(slice)
}
}
// rjf: determine architecture
Arch arch = e_type_state->ctx->primary_module->arch;
if(base_ptr_member != 0)
{
E_Type *type = e_type_from_key__cached(base_ptr_member->type_key);
arch = type->arch;
}
// rjf: evaluate count member, determine count
U64 count = 0;
if(count_member != 0)
@@ -372,6 +381,7 @@ E_LOOKUP_INFO_FUNCTION_DEF(slice)
if(count_member && base_ptr_member)
{
E_SliceAccel *accel = push_array(arena, E_SliceAccel, 1);
accel->arch = arch;
accel->count = count;
accel->base_ptr_vaddr = base_ptr_vaddr;
accel->element_type_key = element_type_key;
@@ -2219,13 +2229,24 @@ E_IRGEN_FUNCTION_DEF(default)
case E_ExprKind_LeafOffset:
{
E_IRNode *new_tree = e_push_irnode(arena, RDI_EvalOp_ConstU64);
new_tree->value.u64 = expr->value.u64;
new_tree->value = expr->value;
new_tree->space = expr->space;
result.root = new_tree;
result.type_key = expr->type_key;
result.mode = E_Mode_Offset;
}break;
//- rjf: leaf values
case E_ExprKind_LeafValue:
{
E_IRNode *new_tree = e_push_irnode(arena, RDI_EvalOp_ConstU64);
new_tree->value = expr->value;
new_tree->space = expr->space;
result.root = new_tree;
result.type_key = expr->type_key;
result.mode = E_Mode_Value;
}break;
//- rjf: leaf file paths
case E_ExprKind_LeafFilePath:
{
+13
View File
@@ -628,6 +628,7 @@ e_type_from_key(Arena *arena, E_TypeKey key)
type->direct_type_key = node->params.direct_key;
type->count = node->params.count;
type->depth = node->params.depth;
type->arch = node->params.arch;
type->byte_size = node->byte_size;
switch(type->kind)
{
@@ -706,6 +707,7 @@ e_type_from_key(Arena *arena, E_TypeKey key)
type->name = push_str8_copy(arena, name);
type->byte_size = (U64)rdi_type->byte_size;
type->count = members_count;
type->arch = e_type_state->ctx->modules[rdi_idx].arch;
type->members = members;
}
@@ -750,6 +752,7 @@ e_type_from_key(Arena *arena, E_TypeKey key)
type->name = push_str8_copy(arena, name);
type->byte_size = (U64)rdi_type->byte_size;
type->count = enum_vals_count;
type->arch = e_type_state->ctx->modules[rdi_idx].arch;
type->enum_vals = enum_vals;
type->direct_type_key = direct_type_key;
}
@@ -789,6 +792,7 @@ e_type_from_key(Arena *arena, E_TypeKey key)
type->direct_type_key = direct_type_key;
type->byte_size = direct_type_byte_size;
type->flags = flags;
type->arch = e_type_state->ctx->modules[rdi_idx].arch;
}break;
case RDI_TypeKind_Ptr:
case RDI_TypeKind_LRef:
@@ -799,6 +803,7 @@ e_type_from_key(Arena *arena, E_TypeKey key)
type->direct_type_key = direct_type_key;
type->byte_size = bit_size_from_arch(e_type_state->ctx->modules[rdi_idx].arch)/8;
type->count = 1;
type->arch = e_type_state->ctx->modules[rdi_idx].arch;
}break;
case RDI_TypeKind_Array:
@@ -808,6 +813,7 @@ e_type_from_key(Arena *arena, E_TypeKey key)
type->direct_type_key = direct_type_key;
type->count = rdi_type->constructed.count;
type->byte_size = direct_type_byte_size * type->count;
type->arch = e_type_state->ctx->modules[rdi_idx].arch;
}break;
case RDI_TypeKind_Function:
{
@@ -823,6 +829,7 @@ e_type_from_key(Arena *arena, E_TypeKey key)
type->direct_type_key = direct_type_key;
type->count = count;
type->param_type_keys = push_array_no_zero(arena, E_TypeKey, type->count);
type->arch = e_type_state->ctx->modules[rdi_idx].arch;
for(U32 idx = 0; idx < type->count; idx += 1)
{
U32 param_type_idx = idx_run[idx];
@@ -856,6 +863,7 @@ e_type_from_key(Arena *arena, E_TypeKey key)
type->owner_type_key = direct_type_key;
type->count = count;
type->param_type_keys = push_array_no_zero(arena, E_TypeKey, type->count);
type->arch = e_type_state->ctx->modules[rdi_idx].arch;
for(U32 idx = 0; idx < type->count; idx += 1)
{
U32 param_type_idx = idx_run[idx];
@@ -893,6 +901,7 @@ e_type_from_key(Arena *arena, E_TypeKey key)
type->byte_size = bit_size_from_arch(e_type_state->ctx->modules[rdi_idx].arch)/8;
type->owner_type_key = owner_type_key;
type->direct_type_key = direct_type_key;
type->arch = e_type_state->ctx->modules[rdi_idx].arch;
}break;
}
}
@@ -921,6 +930,7 @@ e_type_from_key(Arena *arena, E_TypeKey key)
type->name = push_str8_copy(arena, name);
type->byte_size = direct_type_byte_size;
type->direct_type_key = direct_type_key;
type->arch = e_type_state->ctx->modules[rdi_idx].arch;
}
//- rjf: bitfields
@@ -944,6 +954,7 @@ e_type_from_key(Arena *arena, E_TypeKey key)
type->direct_type_key = direct_type_key;
type->off = (U32)rdi_type->bitfield.off;
type->count = (U64)rdi_type->bitfield.size;
type->arch = e_type_state->ctx->modules[rdi_idx].arch;
}
//- rjf: incomplete types
@@ -957,6 +968,7 @@ e_type_from_key(Arena *arena, E_TypeKey key)
type = push_array(arena, E_Type, 1);
type->kind = kind;
type->name = push_str8_copy(arena, name);
type->arch = e_type_state->ctx->modules[rdi_idx].arch;
}
}
@@ -984,6 +996,7 @@ e_type_from_key(Arena *arena, E_TypeKey key)
type->kind = E_TypeKind_Union;
type->name = push_str8f(arena, "reg_%I64u_bit", reg_byte_count*8);
type->byte_size = (U64)reg_byte_count;
type->arch = (Arch)key.u32[0];
// rjf: build register type members
E_MemberList members = {0};
+8 -6
View File
@@ -67,12 +67,13 @@ E_MemberKind;
typedef U32 E_TypeFlags;
enum
{
E_TypeFlag_Const = (1<<0),
E_TypeFlag_Volatile = (1<<1),
E_TypeFlag_External = (1<<2),
E_TypeFlag_IsPlainText= (1<<3),
E_TypeFlag_IsCodeText = (1<<4),
E_TypeFlag_IsPathText = (1<<5),
E_TypeFlag_Const = (1<<0),
E_TypeFlag_Volatile = (1<<1),
E_TypeFlag_External = (1<<2),
E_TypeFlag_IsPlainText = (1<<3),
E_TypeFlag_IsCodeText = (1<<4),
E_TypeFlag_IsPathText = (1<<5),
E_TypeFlag_EditableChildren = (1<<6),
};
typedef struct E_Member E_Member;
@@ -131,6 +132,7 @@ struct E_Type
U64 count;
U64 depth;
U32 off;
Arch arch;
E_TypeKey direct_type_key;
E_TypeKey owner_type_key;
E_TypeKey *param_type_keys;
+4 -2
View File
@@ -14,7 +14,7 @@ str8_lit_comp("CharLiteral"),
str8_lit_comp("Symbol"),
};
String8 e_expr_kind_strings[50] =
String8 e_expr_kind_strings[51] =
{
str8_lit_comp("Nil"),
str8_lit_comp("Ref"),
@@ -59,6 +59,7 @@ str8_lit_comp("LeafF64"),
str8_lit_comp("LeafF32"),
str8_lit_comp("LeafIdent"),
str8_lit_comp("LeafOffset"),
str8_lit_comp("LeafValue"),
str8_lit_comp("LeafFilePath"),
str8_lit_comp("TypeIdent"),
str8_lit_comp("Ptr"),
@@ -83,7 +84,7 @@ str8_lit_comp("Insufficient evaluation machine stack space."),
str8_lit_comp("Malformed bytecode."),
};
E_OpInfo e_expr_kind_op_info_table[50] =
E_OpInfo e_expr_kind_op_info_table[51] =
{
{ E_OpKind_Null, 0, str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp("") },
{ E_OpKind_Null, 0, str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp("") },
@@ -133,6 +134,7 @@ E_OpInfo e_expr_kind_op_info_table[50] =
{ E_OpKind_Null, 0, str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp("") },
{ E_OpKind_Null, 0, str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp("") },
{ E_OpKind_Null, 0, str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp("") },
{ E_OpKind_Null, 0, str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp("") },
{ E_OpKind_Binary, 13, str8_lit_comp(""), str8_lit_comp("="), str8_lit_comp("") },
{ E_OpKind_Null, 0, str8_lit_comp("=>"), str8_lit_comp(","), str8_lit_comp("") },
};
+3 -2
View File
@@ -134,6 +134,7 @@ E_ExprKind_LeafF64,
E_ExprKind_LeafF32,
E_ExprKind_LeafIdent,
E_ExprKind_LeafOffset,
E_ExprKind_LeafValue,
E_ExprKind_LeafFilePath,
E_ExprKind_TypeIdent,
E_ExprKind_Ptr,
@@ -162,9 +163,9 @@ E_InterpretationCode_COUNT,
C_LINKAGE_BEGIN
extern String8 e_token_kind_strings[6];
extern String8 e_expr_kind_strings[50];
extern String8 e_expr_kind_strings[51];
extern String8 e_interpretation_code_display_strings[11];
extern E_OpInfo e_expr_kind_op_info_table[50];
extern E_OpInfo e_expr_kind_op_info_table[51];
extern U8 e_kind_basic_byte_size_table[56];
extern String8 e_kind_basic_string_table[56];