mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-06-18 01:52:22 -07:00
begin merging view state / view parameterizations - unify code for introspecting on each, thus allowing explicit parameterizations of view state via a lens call. also build out the path from an eval -> cfg tree
This commit is contained in:
@@ -246,6 +246,62 @@ e_value_from_expr(E_Expr *expr)
|
||||
return result;
|
||||
}
|
||||
|
||||
internal U64
|
||||
e_base_offset_from_eval(E_Eval eval)
|
||||
{
|
||||
if(e_type_kind_is_pointer_or_ref(e_type_kind_from_key(e_type_unwrap(eval.irtree.type_key))))
|
||||
{
|
||||
eval = e_value_eval_from_eval(eval);
|
||||
}
|
||||
return eval.value.u64;
|
||||
}
|
||||
|
||||
internal Rng1U64
|
||||
e_range_from_eval(E_Eval eval)
|
||||
{
|
||||
U64 size = 0;
|
||||
E_Type *type = e_type_from_key__cached(eval.irtree.type_key);
|
||||
if(type->kind == E_TypeKind_Lens)
|
||||
{
|
||||
for EachIndex(idx, type->count)
|
||||
{
|
||||
E_Expr *arg = type->args[idx];
|
||||
if(arg->kind == E_ExprKind_Define && str8_match(arg->first->string, str8_lit("size"), 0))
|
||||
{
|
||||
size = e_value_from_expr(arg->first->next).u64;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
E_TypeKey type_key = e_type_unwrap(eval.irtree.type_key);
|
||||
E_TypeKind type_kind = e_type_kind_from_key(type_key);
|
||||
E_TypeKey direct_type_key = e_type_unwrap(e_type_direct_from_key(eval.irtree.type_key));
|
||||
E_TypeKind direct_type_kind = e_type_kind_from_key(direct_type_key);
|
||||
if(size == 0 && e_type_kind_is_pointer_or_ref(type_kind) && (direct_type_kind == E_TypeKind_Struct ||
|
||||
direct_type_kind == E_TypeKind_Union ||
|
||||
direct_type_kind == E_TypeKind_Class ||
|
||||
direct_type_kind == E_TypeKind_Array))
|
||||
{
|
||||
size = e_type_byte_size_from_key(e_type_direct_from_key(e_type_unwrap(eval.irtree.type_key)));
|
||||
}
|
||||
if(size == 0 && eval.irtree.mode == E_Mode_Offset && (type_kind == E_TypeKind_Struct ||
|
||||
type_kind == E_TypeKind_Union ||
|
||||
type_kind == E_TypeKind_Class ||
|
||||
type_kind == E_TypeKind_Array))
|
||||
{
|
||||
size = e_type_byte_size_from_key(e_type_unwrap(eval.irtree.type_key));
|
||||
}
|
||||
if(size == 0)
|
||||
{
|
||||
size = KB(16);
|
||||
}
|
||||
Rng1U64 result = {0};
|
||||
result.min = e_base_offset_from_eval(eval);
|
||||
result.max = result.min + size;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Debug Logging Functions
|
||||
|
||||
|
||||
@@ -37,6 +37,9 @@ internal E_Value e_value_from_string(String8 string);
|
||||
internal E_Value e_value_from_stringf(char *fmt, ...);
|
||||
internal E_Value e_value_from_expr(E_Expr *expr);
|
||||
|
||||
internal U64 e_base_offset_from_eval(E_Eval eval);
|
||||
internal Rng1U64 e_range_from_eval(E_Eval eval);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Debug Logging Functions
|
||||
|
||||
|
||||
@@ -653,12 +653,12 @@ e_leaf_type_from_name(String8 name)
|
||||
found = 1;
|
||||
key = e_type_key_basic(E_TypeKind_Bool);
|
||||
}
|
||||
else if(Case("float") || Case("f32") || Case("F32") || Case("r32") || Case("R32"))
|
||||
else if(Case("float") || Case("float32") || Case("f32") || Case("F32") || Case("r32") || Case("R32"))
|
||||
{
|
||||
found = 1;
|
||||
key = e_type_key_basic(E_TypeKind_F32);
|
||||
}
|
||||
else if(Case("double") || Case("f64") || Case("F64") || Case("r64") || Case("R64"))
|
||||
else if(Case("double") || Case("float64") || Case("f64") || Case("F64") || Case("r64") || Case("R64"))
|
||||
{
|
||||
found = 1;
|
||||
key = e_type_key_basic(E_TypeKind_F64);
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
//- GENERATED CODE
|
||||
|
||||
C_LINKAGE_BEGIN
|
||||
RD_VocabInfo rd_vocab_info_table[311] =
|
||||
RD_VocabInfo rd_vocab_info_table[314] =
|
||||
{
|
||||
{str8_lit_comp("auto_view_rule"), str8_lit_comp("auto_view_rules"), str8_lit_comp("Auto View Rule"), str8_lit_comp("Auto View Rules"), RD_IconKind_Binoculars},
|
||||
{str8_lit_comp("file_path_map"), str8_lit_comp("file_path_maps"), str8_lit_comp("File Path Map"), str8_lit_comp("File Path Maps"), RD_IconKind_FileOutline},
|
||||
@@ -103,6 +103,9 @@ RD_VocabInfo rd_vocab_info_table[311] =
|
||||
{str8_lit_comp("break_on_read"), str8_lit_comp(""), str8_lit_comp("Break On Read"), str8_lit_comp(""), RD_IconKind_Null},
|
||||
{str8_lit_comp("break_on_write"), str8_lit_comp(""), str8_lit_comp("Break On Write"), str8_lit_comp(""), RD_IconKind_Null},
|
||||
{str8_lit_comp("break_on_execute"), str8_lit_comp(""), str8_lit_comp("Break On Execution"), str8_lit_comp(""), RD_IconKind_Null},
|
||||
{str8_lit_comp("yaw"), str8_lit_comp(""), str8_lit_comp("Yaw"), str8_lit_comp(""), RD_IconKind_Null},
|
||||
{str8_lit_comp("pitch"), str8_lit_comp(""), str8_lit_comp("Pitch"), str8_lit_comp(""), RD_IconKind_Null},
|
||||
{str8_lit_comp("zoom"), str8_lit_comp(""), str8_lit_comp("Zoom"), str8_lit_comp(""), RD_IconKind_Null},
|
||||
{str8_lit_comp("launch_and_run"), str8_lit_comp(""), str8_lit_comp("Launch and Run"), str8_lit_comp(""), RD_IconKind_Play},
|
||||
{str8_lit_comp("launch_and_step_into"), str8_lit_comp(""), str8_lit_comp("Launch and Step Into"), str8_lit_comp(""), RD_IconKind_PlayStepForward},
|
||||
{str8_lit_comp("kill"), str8_lit_comp(""), str8_lit_comp("Kill"), str8_lit_comp(""), RD_IconKind_X},
|
||||
@@ -319,15 +322,16 @@ RD_VocabInfo rd_vocab_info_table[311] =
|
||||
{str8_lit_comp("log_marker"), str8_lit_comp(""), str8_lit_comp("Log Marker"), str8_lit_comp(""), RD_IconKind_Null},
|
||||
};
|
||||
|
||||
RD_NameSchemaInfo rd_name_schema_info_table[16] =
|
||||
RD_NameSchemaInfo rd_name_schema_info_table[17] =
|
||||
{
|
||||
{str8_lit_comp("settings"), str8_lit_comp("x:\n{\n @default(1) 'hover_animations': bool,\n @default(1) 'press_animations': bool,\n @default(0) 'focus_animations': bool,\n @default(1) 'tooltip_animations': bool,\n @default(1) 'menu_animations': bool,\n @default(1) 'scrolling_animations': bool,\n @default(1) 'background_blur': bool,\n @default(1) 'thread_lines': bool,\n @default(1) 'breakpoint_lines': bool,\n @default(1) 'thread_glow': bool,\n @default(1) 'breakpoint_glow': bool,\n @default(0) 'opaque_backgrounds': bool,\n @default(1) 'smooth_main_text': bool,\n @default(0) 'smooth_code_text': bool,\n @default(1) 'hint_main_text': bool,\n @default(1) 'hint_code_text': bool,\n @default(2) 'tab_width': @range[1, 32] u64,\n @can_be_per_window 'main_font_size': @range[6, 72] u64,\n @can_be_per_window 'code_font_size': @range[1, 32] u64,\n}\n")},
|
||||
{str8_lit_comp("text"), str8_lit_comp("x:\n{\n 'lang':lang,\n 'size':code_string,\n @default(1) 'show_line_numbers':bool,\n}\n")},
|
||||
{str8_lit_comp("disasm"), str8_lit_comp("x:\n{\n 'arch': arch,\n 'syntax': dasm_syntax,\n 'size': code_string,\n @default(1) 'show_addresses': bool,\n @default(0) 'show_code_bytes': bool,\n @default(1) 'show_source_lines': bool,\n @default(1) 'show_symbol_names': bool,\n @default(1) 'show_line_numbers': bool,\n}\n")},
|
||||
{str8_lit_comp("memory"), str8_lit_comp("x:\n{\n 'size': code_string,\n @default(16) 'num_columns': @range[1, 64] u64,\n}\n")},
|
||||
{str8_lit_comp("bitmap"), str8_lit_comp("x:\n{\n 'w': code_string,\n 'h': code_string,\n 'fmt': tex2dformat,\n}\n")},
|
||||
{str8_lit_comp("bitmap"), str8_lit_comp("x:\n{\n @order(0) 'w': code_string,\n @order(1) 'h': code_string,\n 'fmt': tex2dformat,\n}\n")},
|
||||
{str8_lit_comp("geo3d"), str8_lit_comp("x:\n{\n 'count': code_string,\n 'vtx': code_string,\n 'vtx_size': code_string,\n 'yaw': code_string,\n 'pitch': code_string,\n 'zoom': code_string,\n}\n")},
|
||||
{str8_lit_comp("target"), str8_lit_comp("@commands(enable_cfg, launch_and_run, launch_and_step_into, remove_cfg)\n@collection_commands(add_target)\nx:\n{\n 'label': code_string,\n 'executable': path,\n 'arguments': string,\n 'working_directory': path,\n 'entry_point': code_string,\n 'stdout_path': path,\n 'stderr_path': path,\n 'stdin_path': path,\n 'environment': query,\n 'debug_subprocesses': bool,\n @no_expand @default(0) 'enabled': bool,\n}\n")},
|
||||
{str8_lit_comp("breakpoint"), str8_lit_comp("@commands(enable_cfg, remove_cfg)\n@collection_commands(toggle_breakpoint, add_breakpoint, add_address_breakpoint)\nx:\n{\n 'label': code_string,\n 'condition': code_string,\n 'source_location': path_pt,\n 'address_location': code_string,\n 'hit_count': u64,\n 'address_range_size': @or(1, 2, 4, 8) u64,\n 'break_on_write': bool,\n 'break_on_read': bool,\n 'break_on_execute': bool,\n @no_expand @default(1) 'enabled': bool,\n}\n")},
|
||||
{str8_lit_comp("breakpoint"), str8_lit_comp("@commands(enable_cfg, remove_cfg)\n@collection_commands(toggle_breakpoint, add_breakpoint, add_address_breakpoint)\nx:\n{\n 'label': code_string,\n 'condition': code_string,\n 'source_location': path_pt,\n 'address_location': code_string,\n 'hit_count': u64,\n 'address_range_size': @or(0, 1, 2, 4, 8) u64,\n 'break_on_write': bool,\n 'break_on_read': bool,\n 'break_on_execute': bool,\n @no_expand @default(1) 'enabled': bool,\n}\n")},
|
||||
{str8_lit_comp("watch_pin"), str8_lit_comp("@commands(remove_cfg)\n@collection_commands(add_watch_pin)\nx:\n{\n 'expression': code_string,\n 'view_rule': code_string,\n 'source_location': path_pt,\n 'address_location': code_string,\n}\n")},
|
||||
{str8_lit_comp("file_path_map"), str8_lit_comp("@collection_commands(add_file_path_map) @commands(remove_cfg) x:{'source':path, 'dest':path}")},
|
||||
{str8_lit_comp("auto_view_rule"), str8_lit_comp("@collection_commands(add_auto_view_rule) @commands(remove_cfg) x:{'type':code_string, 'view_rule':code_string}")},
|
||||
|
||||
@@ -644,8 +644,8 @@ RD_Query query;
|
||||
.os_event = rd_regs()->os_event,\
|
||||
|
||||
C_LINKAGE_BEGIN
|
||||
extern RD_VocabInfo rd_vocab_info_table[311];
|
||||
extern RD_NameSchemaInfo rd_name_schema_info_table[16];
|
||||
extern RD_VocabInfo rd_vocab_info_table[314];
|
||||
extern RD_NameSchemaInfo rd_name_schema_info_table[17];
|
||||
extern Rng1U64 rd_reg_slot_range_table[42];
|
||||
extern String8 rd_binding_version_remap_old_name_table[8];
|
||||
extern String8 rd_binding_version_remap_new_name_table[8];
|
||||
|
||||
+20
-3
@@ -116,6 +116,9 @@ RD_VocabTable:
|
||||
{break_on_read "" "Break On Read" "" Null }
|
||||
{break_on_write "" "Break On Write" "" Null }
|
||||
{break_on_execute "" "Break On Execution" "" Null }
|
||||
{yaw "" "Yaw" "" Null }
|
||||
{pitch "" "Pitch" "" Null }
|
||||
{zoom "" "Zoom" "" Null }
|
||||
}
|
||||
|
||||
@struct RD_VocabInfo:
|
||||
@@ -210,12 +213,26 @@ RD_VocabTable:
|
||||
```
|
||||
x:
|
||||
{
|
||||
'w': code_string,
|
||||
'h': code_string,
|
||||
@order(0) 'w': code_string,
|
||||
@order(1) 'h': code_string,
|
||||
'fmt': tex2dformat,
|
||||
}
|
||||
```
|
||||
}
|
||||
{
|
||||
geo3d,
|
||||
```
|
||||
x:
|
||||
{
|
||||
'count': code_string,
|
||||
'vtx': code_string,
|
||||
'vtx_size': code_string,
|
||||
'yaw': code_string,
|
||||
'pitch': code_string,
|
||||
'zoom': code_string,
|
||||
}
|
||||
```
|
||||
}
|
||||
|
||||
//- rjf: targets
|
||||
{
|
||||
@@ -253,7 +270,7 @@ RD_VocabTable:
|
||||
'source_location': path_pt,
|
||||
'address_location': code_string,
|
||||
'hit_count': u64,
|
||||
'address_range_size': @or(1, 2, 4, 8) u64,
|
||||
'address_range_size': @or(0, 1, 2, 4, 8) u64,
|
||||
'break_on_write': bool,
|
||||
'break_on_read': bool,
|
||||
'break_on_execute': bool,
|
||||
|
||||
+124
-161
@@ -2108,6 +2108,63 @@ rd_query_from_eval_string(Arena *arena, String8 string)
|
||||
////////////////////////////////
|
||||
//~ rjf: View Functions
|
||||
|
||||
internal RD_Cfg *
|
||||
rd_view_from_eval(RD_Cfg *parent, E_Eval eval)
|
||||
{
|
||||
Temp scratch = scratch_begin(0, 0);
|
||||
String8 schema_name = eval.expr->first->string;
|
||||
RD_Cfg *view = rd_cfg_child_from_string_or_alloc(parent, schema_name);
|
||||
rd_cfg_child_from_string_or_alloc(view, str8_lit("selected"));
|
||||
{
|
||||
MD_Node *schema = rd_schema_from_name(schema_name);
|
||||
E_Expr *primary_expr = eval.expr;
|
||||
E_Expr *first_arg = &e_expr_nil;
|
||||
if(eval.expr->kind == E_ExprKind_Call)
|
||||
{
|
||||
primary_expr = eval.expr->first->next;
|
||||
first_arg = primary_expr->next;
|
||||
}
|
||||
RD_Cfg *expr_root = rd_cfg_child_from_string_or_alloc(view, str8_lit("expression"));
|
||||
rd_cfg_new_replace(expr_root, e_string_from_expr(scratch.arena, primary_expr));
|
||||
{
|
||||
U64 unnamed_order_idx = 0;
|
||||
for(E_Expr *arg = first_arg; arg != &e_expr_nil; arg = arg->next)
|
||||
{
|
||||
String8 param_name = {0};
|
||||
E_Expr *arg_expr = arg;
|
||||
if(arg->kind == E_ExprKind_Define)
|
||||
{
|
||||
param_name = arg->first->string;
|
||||
arg_expr = arg->first->next;
|
||||
}
|
||||
else
|
||||
{
|
||||
for MD_EachNode(schema_child, schema->first)
|
||||
{
|
||||
MD_Node *order_tag = md_tag_from_string(schema_child, str8_lit("order"), 0);
|
||||
if(order_tag != &md_nil_node)
|
||||
{
|
||||
U64 schema_child_order_idx = 0;
|
||||
try_u64_from_str8_c_rules(order_tag->first->string, &schema_child_order_idx);
|
||||
if(schema_child_order_idx == unnamed_order_idx)
|
||||
{
|
||||
param_name = schema_child->string;
|
||||
arg_expr = arg;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
unnamed_order_idx += 1;
|
||||
}
|
||||
RD_Cfg *arg_root = rd_cfg_child_from_string_or_alloc(view, param_name);
|
||||
rd_cfg_new_replace(arg_root, e_string_from_expr(scratch.arena, arg_expr));
|
||||
}
|
||||
}
|
||||
}
|
||||
scratch_end(scratch);
|
||||
return view;
|
||||
}
|
||||
|
||||
internal RD_ViewState *
|
||||
rd_view_state_from_cfg(RD_Cfg *cfg)
|
||||
{
|
||||
@@ -2421,7 +2478,6 @@ rd_view_ui(Rng2F32 rect)
|
||||
}
|
||||
|
||||
// rjf: unpack view's target expression & hash
|
||||
String8 expr_string = rd_expr_from_cfg(view);
|
||||
E_Eval eval = e_eval_from_string(scratch.arena, expr_string);
|
||||
Rng1U64 range = r1u64(0, 1024);
|
||||
U128 key = rd_key_from_eval_space_range(eval.space, range, 0);
|
||||
@@ -4050,68 +4106,62 @@ rd_view_ui(Rng2F32 rect)
|
||||
//- rjf: cell has hook? -> build ui by calling hook
|
||||
else if(cell_info.view_ui_rule != &rd_nil_view_ui_rule)
|
||||
{
|
||||
RD_Cfg *root = rd_immediate_cfg_from_keyf("view_%I64x_%I64x", rd_regs()->view, row_hash);
|
||||
RD_Cfg *view = rd_view_from_eval(root, cell_info.eval);
|
||||
Rng2F32 cell_rect = r2f32p(cell_x_px, 0, next_cell_x_px, row_height_px*(row_node->visual_size_skipped + row->visual_size + row_node->visual_size_chopped));
|
||||
ui_set_next_fixed_y(-1.f * (row_node->visual_size_skipped) * row_height_px);
|
||||
ui_set_next_fixed_height((row_node->visual_size_skipped + row->visual_size + row_node->visual_size_chopped) * row_height_px);
|
||||
UI_Box *box = ui_build_box_from_stringf(UI_BoxFlag_Clip|UI_BoxFlag_Clickable|UI_BoxFlag_FloatingY, "###val_%I64x", row_hash);
|
||||
UI_Parent(box)
|
||||
{
|
||||
RD_Cfg *root = rd_immediate_cfg_from_keyf("view_%I64x_%I64x", rd_regs()->view, row_hash);
|
||||
RD_Cfg *view = rd_cfg_child_from_string_or_alloc(root, cell_info.view_ui_rule->name);
|
||||
RD_Cfg *expr = rd_cfg_child_from_string_or_alloc(view, str8_lit("expression"));
|
||||
rd_cfg_new(expr, e_string_from_expr(scratch.arena, cell_info.eval.expr));
|
||||
rd_cfg_new(view, str8_lit("selected"));
|
||||
RD_RegsScope(.view = view->id, .file_path = rd_file_path_from_eval(scratch.arena, cell_info.eval))
|
||||
UI_PermissionFlags(UI_PermissionFlag_Clicks|UI_PermissionFlag_ScrollX)
|
||||
UI_Flags(0)
|
||||
UI_PermissionFlags(UI_PermissionFlag_Clicks|UI_PermissionFlag_ScrollX)
|
||||
UI_Flags(0)
|
||||
{
|
||||
// rjf: 'pull out' button
|
||||
UI_TagF(".") UI_TagF("tab") UI_Rect(r2f32p(ui_top_font_size()*1.5f,
|
||||
ui_top_font_size()*1.5f,
|
||||
ui_top_font_size()*1.5f + ui_top_font_size()*3.f,
|
||||
ui_top_font_size()*1.5f + ui_top_font_size()*3.f))
|
||||
UI_CornerRadius(ui_top_font_size()*1.5f)
|
||||
UI_TextAlignment(UI_TextAlign_Center)
|
||||
RD_Font(RD_FontSlot_Icons)
|
||||
UI_FontSize(ui_top_font_size()*0.8f)
|
||||
{
|
||||
// rjf: 'pull out' button
|
||||
UI_TagF(".") UI_TagF("tab") UI_Rect(r2f32p(ui_top_font_size()*1.5f,
|
||||
ui_top_font_size()*1.5f,
|
||||
ui_top_font_size()*1.5f + ui_top_font_size()*3.f,
|
||||
ui_top_font_size()*1.5f + ui_top_font_size()*3.f))
|
||||
UI_CornerRadius(ui_top_font_size()*1.5f)
|
||||
UI_TextAlignment(UI_TextAlign_Center)
|
||||
RD_Font(RD_FontSlot_Icons)
|
||||
UI_FontSize(ui_top_font_size()*0.8f)
|
||||
UI_Box *box = ui_build_box_from_stringf(UI_BoxFlag_Clickable|
|
||||
UI_BoxFlag_Floating|
|
||||
UI_BoxFlag_DrawText|
|
||||
UI_BoxFlag_DrawBorder|
|
||||
UI_BoxFlag_DrawBackground|
|
||||
UI_BoxFlag_DrawActiveEffects|
|
||||
UI_BoxFlag_DrawHotEffects,
|
||||
"%S###pull_out",
|
||||
rd_icon_kind_text_table[RD_IconKind_Window]);
|
||||
UI_Signal sig = ui_signal_from_box(box);
|
||||
if(ui_dragging(sig) && !contains_2f32(box->rect, ui_mouse()))
|
||||
{
|
||||
UI_Box *box = ui_build_box_from_stringf(UI_BoxFlag_Clickable|
|
||||
UI_BoxFlag_Floating|
|
||||
UI_BoxFlag_DrawText|
|
||||
UI_BoxFlag_DrawBorder|
|
||||
UI_BoxFlag_DrawBackground|
|
||||
UI_BoxFlag_DrawActiveEffects|
|
||||
UI_BoxFlag_DrawHotEffects,
|
||||
"%S###pull_out",
|
||||
rd_icon_kind_text_table[RD_IconKind_Window]);
|
||||
UI_Signal sig = ui_signal_from_box(box);
|
||||
if(ui_dragging(sig) && !contains_2f32(box->rect, ui_mouse()))
|
||||
{
|
||||
rd_drag_begin(RD_RegSlot_View);
|
||||
}
|
||||
}
|
||||
|
||||
// rjf: loading animation container
|
||||
UI_Box *loading_overlay_container = &ui_nil_box;
|
||||
UI_Parent(box) UI_WidthFill UI_HeightFill
|
||||
{
|
||||
loading_overlay_container = ui_build_box_from_key(UI_BoxFlag_FloatingX|UI_BoxFlag_FloatingY, ui_key_zero());
|
||||
}
|
||||
|
||||
// rjf: view ui contents
|
||||
E_IRTreeAndType *prev_overridden_irtree = e_ir_state->overridden_irtree;
|
||||
e_ir_state->overridden_irtree = cell_info.eval.irtree.prev;
|
||||
cell_info.view_ui_rule->ui(cell_info.eval, cell_rect);
|
||||
e_ir_state->overridden_irtree = prev_overridden_irtree;
|
||||
|
||||
// rjf: loading fill
|
||||
UI_Parent(loading_overlay_container)
|
||||
{
|
||||
RD_ViewState *vs = rd_view_state_from_cfg(view);
|
||||
rd_loading_overlay(cell_rect, vs->loading_t, vs->loading_progress_v, vs->loading_progress_v_target);
|
||||
rd_drag_begin(RD_RegSlot_View);
|
||||
}
|
||||
}
|
||||
|
||||
// rjf: loading animation container
|
||||
UI_Box *loading_overlay_container = &ui_nil_box;
|
||||
UI_Parent(box) UI_WidthFill UI_HeightFill
|
||||
{
|
||||
loading_overlay_container = ui_build_box_from_key(UI_BoxFlag_FloatingX|UI_BoxFlag_FloatingY, ui_key_zero());
|
||||
}
|
||||
|
||||
// rjf: view ui contents
|
||||
E_IRTreeAndType *prev_overridden_irtree = e_ir_state->overridden_irtree;
|
||||
e_ir_state->overridden_irtree = cell_info.eval.irtree.prev;
|
||||
cell_info.view_ui_rule->ui(cell_info.eval, cell_rect);
|
||||
e_ir_state->overridden_irtree = prev_overridden_irtree;
|
||||
|
||||
// rjf: loading fill
|
||||
UI_Parent(loading_overlay_container)
|
||||
{
|
||||
RD_ViewState *vs = rd_view_state_from_cfg(view);
|
||||
rd_loading_overlay(cell_rect, vs->loading_t, vs->loading_progress_v, vs->loading_progress_v_target);
|
||||
}
|
||||
}
|
||||
sig = ui_signal_from_box(box);
|
||||
}
|
||||
@@ -4666,63 +4716,32 @@ rd_view_cfg_value_from_string(String8 string)
|
||||
return result;
|
||||
}
|
||||
|
||||
//- rjf: evaluation & tag (a view's 'call') parameter extraction
|
||||
|
||||
internal U64
|
||||
rd_base_offset_from_eval(E_Eval eval)
|
||||
rd_view_cfg_u64_from_string(String8 string)
|
||||
{
|
||||
if(e_type_kind_is_pointer_or_ref(e_type_kind_from_key(e_type_unwrap(eval.irtree.type_key))))
|
||||
{
|
||||
eval = e_value_eval_from_eval(eval);
|
||||
}
|
||||
return eval.value.u64;
|
||||
}
|
||||
|
||||
internal Rng1U64
|
||||
rd_range_from_eval(E_Eval eval)
|
||||
{
|
||||
U64 size = 0;
|
||||
E_Type *type = e_type_from_key__cached(eval.irtree.type_key);
|
||||
if(type->kind == E_TypeKind_Lens)
|
||||
{
|
||||
for EachIndex(idx, type->count)
|
||||
{
|
||||
E_Expr *arg = type->args[idx];
|
||||
if(arg->kind == E_ExprKind_Define && str8_match(arg->first->string, str8_lit("size"), 0))
|
||||
{
|
||||
size = e_value_from_expr(arg->first->next).u64;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
E_TypeKey type_key = e_type_unwrap(eval.irtree.type_key);
|
||||
E_TypeKind type_kind = e_type_kind_from_key(type_key);
|
||||
E_TypeKey direct_type_key = e_type_unwrap(e_type_direct_from_key(eval.irtree.type_key));
|
||||
E_TypeKind direct_type_kind = e_type_kind_from_key(direct_type_key);
|
||||
if(size == 0 && e_type_kind_is_pointer_or_ref(type_kind) && (direct_type_kind == E_TypeKind_Struct ||
|
||||
direct_type_kind == E_TypeKind_Union ||
|
||||
direct_type_kind == E_TypeKind_Class ||
|
||||
direct_type_kind == E_TypeKind_Array))
|
||||
{
|
||||
size = e_type_byte_size_from_key(e_type_direct_from_key(e_type_unwrap(eval.irtree.type_key)));
|
||||
}
|
||||
if(size == 0 && eval.irtree.mode == E_Mode_Offset && (type_kind == E_TypeKind_Struct ||
|
||||
type_kind == E_TypeKind_Union ||
|
||||
type_kind == E_TypeKind_Class ||
|
||||
type_kind == E_TypeKind_Array))
|
||||
{
|
||||
size = e_type_byte_size_from_key(e_type_unwrap(eval.irtree.type_key));
|
||||
}
|
||||
if(size == 0)
|
||||
{
|
||||
size = KB(16);
|
||||
}
|
||||
Rng1U64 result = {0};
|
||||
result.min = rd_base_offset_from_eval(eval);
|
||||
result.max = result.min + size;
|
||||
Temp scratch = scratch_begin(0, 0);
|
||||
RD_Cfg *root = rd_view_cfg_from_string(string);
|
||||
String8 expr = push_str8f(scratch.arena, "(uint64)(%S)", root->first->string);
|
||||
E_Eval eval = e_eval_from_string(scratch.arena, expr);
|
||||
U64 result = e_value_eval_from_eval(eval).value.u64;
|
||||
scratch_end(scratch);
|
||||
return result;
|
||||
}
|
||||
|
||||
internal F32
|
||||
rd_view_cfg_f32_from_string(String8 string)
|
||||
{
|
||||
Temp scratch = scratch_begin(0, 0);
|
||||
RD_Cfg *root = rd_view_cfg_from_string(string);
|
||||
String8 expr = push_str8f(scratch.arena, "(float32)(%S)", root->first->string);
|
||||
E_Eval eval = e_eval_from_string(scratch.arena, expr);
|
||||
F32 result = e_value_eval_from_eval(eval).value.f32;
|
||||
scratch_end(scratch);
|
||||
return result;
|
||||
}
|
||||
|
||||
//- rjf: evaluation & tag (a view's 'call') parameter extraction
|
||||
|
||||
internal TXT_LangKind
|
||||
rd_lang_kind_from_eval(E_Eval eval)
|
||||
{
|
||||
@@ -4794,62 +4813,6 @@ rd_arch_from_eval(E_Eval eval)
|
||||
return arch;
|
||||
}
|
||||
|
||||
internal Vec2S32
|
||||
rd_dim2s32_from_eval(E_Eval eval)
|
||||
{
|
||||
Vec2S32 dim = v2s32(1, 1);
|
||||
B32 got_x = 0;
|
||||
B32 got_y = 0;
|
||||
|
||||
// rjf: try explicitly passed dimensions
|
||||
E_Type *type = e_type_from_key__cached(eval.irtree.type_key);
|
||||
if(type->kind == E_TypeKind_Lens)
|
||||
{
|
||||
for EachIndex(idx, type->count)
|
||||
{
|
||||
E_Expr *arg = type->args[idx];
|
||||
if(arg->kind == E_ExprKind_Define)
|
||||
{
|
||||
if(str8_match(arg->first->string, str8_lit("w"), 0))
|
||||
{
|
||||
got_x = 1;
|
||||
dim.x = e_value_from_expr(arg->first->next).s64;
|
||||
}
|
||||
if(str8_match(arg->first->string, str8_lit("h"), 0))
|
||||
{
|
||||
got_y = 1;
|
||||
dim.y = e_value_from_expr(arg->first->next).s64;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// rjf: try ordered non-define arguments
|
||||
if(type->kind == E_TypeKind_Lens)
|
||||
{
|
||||
for EachIndex(idx, type->count)
|
||||
{
|
||||
E_Expr *arg = type->args[idx];
|
||||
if(arg->kind != E_ExprKind_Define)
|
||||
{
|
||||
if(!got_x)
|
||||
{
|
||||
got_x = 1;
|
||||
dim.x = e_value_from_expr(arg).s64;
|
||||
}
|
||||
else if(!got_y)
|
||||
{
|
||||
got_y = 1;
|
||||
dim.y = e_value_from_expr(arg).s64;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return dim;
|
||||
}
|
||||
|
||||
internal R_Tex2DFormat
|
||||
rd_tex2dformat_from_eval(E_Eval eval)
|
||||
{
|
||||
@@ -6381,7 +6344,7 @@ rd_window_frame(void)
|
||||
|
||||
// rjf: build view
|
||||
RD_Cfg *root = rd_immediate_cfg_from_keyf("hover_eval_view");
|
||||
RD_Cfg *view = rd_cfg_child_from_string_or_alloc(root, view_name);
|
||||
RD_Cfg *view = rd_view_from_eval(root, hover_eval);
|
||||
RD_Cfg *explicit_root = rd_cfg_child_from_string_or_alloc(view, str8_lit("explicit_root"));
|
||||
rd_cfg_new_replace(explicit_root, str8_lit("1"));
|
||||
|
||||
|
||||
@@ -952,6 +952,7 @@ internal String8 rd_query_from_eval_string(Arena *arena, String8 string);
|
||||
////////////////////////////////
|
||||
//~ rjf: View Functions
|
||||
|
||||
internal RD_Cfg *rd_view_from_eval(RD_Cfg *parent, E_Eval eval);
|
||||
internal RD_ViewState *rd_view_state_from_cfg(RD_Cfg *cfg);
|
||||
internal void rd_view_ui(Rng2F32 rect);
|
||||
|
||||
@@ -966,13 +967,12 @@ internal String8 rd_view_query_cmd(void);
|
||||
internal String8 rd_view_query_input(void);
|
||||
internal RD_Cfg *rd_view_cfg_from_string(String8 string);
|
||||
internal E_Value rd_view_cfg_value_from_string(String8 string);
|
||||
internal U64 rd_view_cfg_u64_from_string(String8 string);
|
||||
internal F32 rd_view_cfg_f32_from_string(String8 string);
|
||||
|
||||
//- rjf: evaluation & tag (a view's 'call') parameter extraction
|
||||
internal U64 rd_base_offset_from_eval(E_Eval eval);
|
||||
internal Rng1U64 rd_range_from_eval(E_Eval eval);
|
||||
internal TXT_LangKind rd_lang_kind_from_eval(E_Eval eval);
|
||||
internal Arch rd_arch_from_eval(E_Eval eval);
|
||||
internal Vec2S32 rd_dim2s32_from_eval(E_Eval eval);
|
||||
internal R_Tex2DFormat rd_tex2dformat_from_eval(E_Eval eval);
|
||||
internal E_Value rd_value_from_eval_key(E_Eval eval, String8 key);
|
||||
|
||||
|
||||
+12
-12
@@ -1743,7 +1743,7 @@ RD_VIEW_UI_FUNCTION_DEF(text)
|
||||
if(rd_regs()->cursor.column == 0) { rd_regs()->cursor.column = 1; }
|
||||
if(rd_regs()->mark.line == 0) { rd_regs()->mark.line = 1; }
|
||||
if(rd_regs()->mark.column == 0) { rd_regs()->mark.column = 1; }
|
||||
Rng1U64 range = rd_range_from_eval(eval);
|
||||
Rng1U64 range = e_range_from_eval(eval);
|
||||
rd_regs()->text_key = rd_key_from_eval_space_range(eval.space, range, 1);
|
||||
rd_regs()->lang_kind = rd_lang_kind_from_eval(eval);
|
||||
U128 hash = {0};
|
||||
@@ -2002,7 +2002,7 @@ RD_VIEW_UI_FUNCTION_DEF(disasm)
|
||||
{
|
||||
space = auto_space;
|
||||
}
|
||||
Rng1U64 range = rd_range_from_eval(eval);
|
||||
Rng1U64 range = e_range_from_eval(eval);
|
||||
Arch arch = rd_arch_from_eval(eval);
|
||||
CTRL_Entity *space_entity = rd_ctrl_entity_from_eval_space(space);
|
||||
CTRL_Entity *dasm_module = &ctrl_entity_nil;
|
||||
@@ -2170,7 +2170,7 @@ RD_VIEW_UI_FUNCTION_DEF(memory)
|
||||
//////////////////////////////
|
||||
//- rjf: unpack parameterization info
|
||||
//
|
||||
Rng1U64 space_range = rd_range_from_eval(eval);
|
||||
Rng1U64 space_range = e_range_from_eval(eval);
|
||||
if(eval.space.kind == 0)
|
||||
{
|
||||
eval.space = rd_eval_space_from_ctrl_entity(ctrl_entity_from_handle(d_state->ctrl_entity_store, rd_regs()->process), RD_EvalSpaceKind_CtrlEntity);
|
||||
@@ -3085,9 +3085,9 @@ RD_VIEW_UI_FUNCTION_DEF(bitmap)
|
||||
//////////////////////////////
|
||||
//- rjf: evaluate expression
|
||||
//
|
||||
Vec2S32 dim = rd_dim2s32_from_eval(eval);
|
||||
Vec2S32 dim = v2s32((S32)rd_view_cfg_u64_from_string(str8_lit("w")), (S32)rd_view_cfg_u64_from_string(str8_lit("h")));
|
||||
R_Tex2DFormat fmt = rd_tex2dformat_from_eval(eval);
|
||||
U64 base_offset = rd_base_offset_from_eval(eval);
|
||||
U64 base_offset = e_base_offset_from_eval(eval);
|
||||
U64 expected_size = dim.x*dim.y*r_tex2d_format_bytes_per_pixel_table[fmt];
|
||||
Rng1U64 offset_range = r1u64(base_offset, base_offset + expected_size);
|
||||
|
||||
@@ -3484,17 +3484,17 @@ RD_VIEW_UI_FUNCTION_DEF(geo3d)
|
||||
//////////////////////////////
|
||||
//- rjf: unpack parameters
|
||||
//
|
||||
U64 count = rd_value_from_eval_key(eval, str8_lit("count")).u64;
|
||||
U64 vtx_base_off = rd_value_from_eval_key(eval, str8_lit("vtx")).u64;
|
||||
U64 vtx_size = rd_value_from_eval_key(eval, str8_lit("vtx_size")).u64;
|
||||
F32 yaw_target = rd_view_cfg_value_from_string(str8_lit("yaw")).f32;
|
||||
F32 pitch_target = rd_view_cfg_value_from_string(str8_lit("pitch")).f32;
|
||||
F32 zoom_target = rd_view_cfg_value_from_string(str8_lit("zoom")).f32;
|
||||
U64 count = rd_view_cfg_u64_from_string(str8_lit("count"));
|
||||
U64 vtx_base_off = rd_view_cfg_u64_from_string(str8_lit("vtx"));
|
||||
U64 vtx_size = rd_view_cfg_u64_from_string(str8_lit("vtx_size"));
|
||||
F32 yaw_target = rd_view_cfg_f32_from_string(str8_lit("yaw"));
|
||||
F32 pitch_target = rd_view_cfg_f32_from_string(str8_lit("pitch"));
|
||||
F32 zoom_target = rd_view_cfg_f32_from_string(str8_lit("zoom"));
|
||||
|
||||
//////////////////////////////
|
||||
//- rjf: evaluate & unpack expression
|
||||
//
|
||||
U64 base_offset = rd_base_offset_from_eval(eval);
|
||||
U64 base_offset = e_base_offset_from_eval(eval);
|
||||
Rng1U64 idxs_range = r1u64(base_offset, base_offset+count*sizeof(U32));
|
||||
Rng1U64 vtxs_range = r1u64(vtx_base_off, vtx_base_off+vtx_size);
|
||||
U128 idxs_key = rd_key_from_eval_space_range(eval.space, idxs_range, 0);
|
||||
|
||||
Reference in New Issue
Block a user