From 729a4aa1f95b0394ead519027e3544776f27cb17 Mon Sep 17 00:00:00 2001 From: Ryan Fleury Date: Fri, 23 Aug 2024 16:17:19 -0700 Subject: [PATCH] first step to collapsing separate view parameterization path, and just having views be parameterized by evaluation strings --- src/df/core/df_core.c | 110 +++++++++++++++++++- src/df/core/df_core.h | 9 ++ src/df/gfx/df_gfx.c | 161 ++++++++++++++++------------- src/df/gfx/df_gfx.h | 9 +- src/df/gfx/df_gfx.mdesk | 4 +- src/df/gfx/df_views.c | 75 ++++++++------ src/df/gfx/generated/df_gfx.meta.c | 4 +- src/eval/eval.mdesk | 2 +- src/eval/eval_core.h | 1 + src/eval/eval_ir.c | 12 +-- src/eval/eval_parse.c | 33 +++--- src/eval/eval_parse.h | 5 +- src/eval/generated/eval.meta.c | 4 +- src/eval/generated/eval.meta.h | 2 +- 14 files changed, 280 insertions(+), 151 deletions(-) diff --git a/src/df/core/df_core.c b/src/df/core/df_core.c index 22e1c103..3d601751 100644 --- a/src/df/core/df_core.c +++ b/src/df/core/df_core.c @@ -5429,6 +5429,23 @@ df_range_from_eval_cfg(E_Eval eval, DF_CfgNode *cfg) return result; } +internal TXT_LangKind +df_lang_kind_from_eval_cfg(E_Eval eval, DF_CfgNode *cfg) +{ + TXT_LangKind lang_kind = TXT_LangKind_Null; + if(eval.expr->kind == E_ExprKind_LeafFilePath) + { + lang_kind = txt_lang_kind_from_extension(str8_skip_last_dot(eval.expr->string)); + } + else + { + DF_CfgNode *lang_cfg = df_cfg_node_child_from_string(cfg, str8_lit("lang"), 0); + String8 lang_kind_string = lang_cfg->first->string; + lang_kind = txt_lang_kind_from_extension(lang_kind_string); + } + return lang_kind; +} + //- rjf: view rule eval application internal E_Eval @@ -5446,6 +5463,56 @@ df_eval_from_eval_cfg_table(Arena *arena, E_Eval eval, DF_CfgTable *cfg) return eval; } +//- rjf: eval -> entity + +internal DF_Entity * +df_entity_from_eval_string(String8 string) +{ + DF_Entity *entity = &df_g_nil_entity; + { + Temp scratch = scratch_begin(0, 0); + E_Eval eval = e_eval_from_string(scratch.arena, string); + entity = df_entity_from_eval_space(eval.space); + scratch_end(scratch); + } + return entity; +} + +internal String8 +df_eval_string_from_entity(Arena *arena, DF_Entity *entity) +{ + String8 eval_string = push_str8f(arena, "macro:`$%I64u`", entity->id); + return eval_string; +} + +//- rjf: eval <-> file path + +internal String8 +df_file_path_from_eval_string(Arena *arena, String8 string) +{ + String8 result = {0}; + { + Temp scratch = scratch_begin(&arena, 1); + E_Eval eval = e_eval_from_string(scratch.arena, string); + if(eval.expr->kind == E_ExprKind_LeafFilePath) + { + result = df_cfg_raw_from_escaped_string(arena, eval.expr->string); + } + scratch_end(scratch); + } + return result; +} + +internal String8 +df_eval_string_from_file_path(Arena *arena, String8 string) +{ + Temp scratch = scratch_begin(&arena, 1); + String8 string_escaped = df_cfg_escaped_from_raw_string(scratch.arena, string); + String8 result = push_str8f(arena, "file:\"%S\"", string_escaped); + scratch_end(scratch); + return result; +} + //////////////////////////////// //~ rjf: Main State Accessors/Mutators @@ -8557,7 +8624,7 @@ df_core_begin_frame(Arena *arena, DF_CmdList *cmds, F32 dt) if(!df_entity_is_nil(process)) { E_Expr *expr = e_push_expr(arena, E_ExprKind_LeafU64, 0); - expr->u64 = process->ctrl_id; + expr->value.u64 = process->ctrl_id; e_string2expr_map_insert(arena, ctx->macro_map, str8_lit("pid"), expr); } @@ -8565,11 +8632,50 @@ df_core_begin_frame(Arena *arena, DF_CmdList *cmds, F32 dt) if(!df_entity_is_nil(thread)) { E_Expr *expr = e_push_expr(arena, E_ExprKind_LeafU64, 0); - expr->u64 = thread->ctrl_id; + expr->value.u64 = thread->ctrl_id; e_string2expr_map_insert(arena, ctx->macro_map, str8_lit("tid"), expr); } } + //- rjf: add macros for entities + { + Temp scratch = scratch_begin(&arena, 1); + E_MemberList entity_members = {0}; + { + e_member_list_push_new(scratch.arena, &entity_members, .name = str8_lit("Enabled"), .off = 0, .type_key = e_type_key_basic(E_TypeKind_S64)); + e_member_list_push_new(scratch.arena, &entity_members, .name = str8_lit("Hit Count"),.off = 0+8, .type_key = e_type_key_basic(E_TypeKind_U64)); + e_member_list_push_new(scratch.arena, &entity_members, .name = str8_lit("Label"), .off = 0+8+8, .type_key = e_type_key_cons_ptr(architecture_from_context(), e_type_key_basic(E_TypeKind_Char8))); + e_member_list_push_new(scratch.arena, &entity_members, .name = str8_lit("Location"), .off = 0+8+8+8, .type_key = e_type_key_cons_ptr(architecture_from_context(), e_type_key_basic(E_TypeKind_Char8))); + e_member_list_push_new(scratch.arena, &entity_members, .name = str8_lit("Condition"),.off = 0+8+8+8+8,.type_key = e_type_key_cons_ptr(architecture_from_context(), e_type_key_basic(E_TypeKind_Char8))); + } + E_MemberArray entity_members_array = e_member_array_from_list(scratch.arena, &entity_members); + E_TypeKey entity_type = e_type_key_cons(.arch = architecture_from_context(), + .kind = E_TypeKind_Struct, + .name = str8_lit("Entity"), + .members = entity_members_array.v, + .count = entity_members_array.count); + DF_EntityKind evallable_kinds[] = + { + DF_EntityKind_Breakpoint, + DF_EntityKind_WatchPin, + DF_EntityKind_Target, + }; + for(U64 idx = 0; idx < ArrayCount(evallable_kinds); idx += 1) + { + DF_EntityList entities = df_query_cached_entity_list_with_kind(evallable_kinds[idx]); + for(DF_EntityNode *n = entities.first; n != 0; n = n->next) + { + DF_Entity *entity = n->entity; + E_Expr *expr = e_push_expr(arena, E_ExprKind_LeafOffset, 0); + expr->space = df_eval_space_from_entity(entity); + expr->mode = E_Mode_Offset; + expr->type_key = entity_type; + e_string2expr_map_insert(arena, ctx->macro_map, push_str8f(arena, "$%I64u", entity->id), expr); + } + } + scratch_end(scratch); + } + //- rjf: add macros for all watches which define identifiers DF_EntityList watches = df_query_cached_entity_list_with_kind(DF_EntityKind_Watch); for(DF_EntityNode *n = watches.first; n != 0; n = n->next) diff --git a/src/df/core/df_core.h b/src/df/core/df_core.h index e56ee386..b552a426 100644 --- a/src/df/core/df_core.h +++ b/src/df/core/df_core.h @@ -1652,10 +1652,19 @@ internal B32 df_viz_row_is_editable(DF_EvalVizRow *row); //- rjf: view rule config tree info extraction internal Rng1U64 df_range_from_eval_cfg(E_Eval eval, DF_CfgNode *cfg); +internal TXT_LangKind df_lang_kind_from_eval_cfg(E_Eval eval, DF_CfgNode *cfg); //- rjf: view rule eval application internal E_Eval df_eval_from_eval_cfg_table(Arena *arena, E_Eval eval, DF_CfgTable *cfg); +//- rjf: eval <-> entity +internal DF_Entity *df_entity_from_eval_string(String8 string); +internal String8 df_eval_string_from_entity(Arena *arena, DF_Entity *entity); + +//- rjf: eval <-> file path +internal String8 df_file_path_from_eval_string(Arena *arena, String8 string); +internal String8 df_eval_string_from_file_path(Arena *arena, String8 string); + //////////////////////////////// //~ rjf: Main State Accessors/Mutators diff --git a/src/df/gfx/df_gfx.c b/src/df/gfx/df_gfx.c index 65e3eb3f..1e487314 100644 --- a/src/df/gfx/df_gfx.c +++ b/src/df/gfx/df_gfx.c @@ -362,18 +362,28 @@ df_selected_tab_from_panel(DF_Panel *panel) internal String8 df_display_string_from_view(Arena *arena, DF_View *view) { - String8 result = {0}; - if(view->params_file_path.size != 0) + String8 result = view->spec->info.display_string; { - result = str8_skip_last_slash(view->params_file_path); - } - else if(!df_entity_is_nil(df_entity_from_handle(view->params_entity))) - { - result = df_display_string_from_entity(arena, df_entity_from_handle(view->params_entity)); - } - else - { - result = view->spec->info.display_string; + String8 query = str8(view->query_buffer, view->query_string_size); + if(query.size != 0) + { + Temp scratch = scratch_begin(&arena, 1); + E_Eval eval = e_eval_from_string(scratch.arena, query); + DF_Entity *entity = df_entity_from_eval_space(eval.space); + switch(entity->kind) + { + case DF_EntityKind_Nil: + if(eval.expr->kind == E_ExprKind_LeafFilePath) + { + result = str8_skip_last_slash(push_str8_copy(arena, eval.expr->string)); + }break; + default: + { + result = df_display_string_from_entity(arena, entity); + }break; + } + scratch_end(scratch); + } } return result; } @@ -768,9 +778,6 @@ df_view_alloc(void) // rjf: initialize view->arena = arena_alloc(); view->spec = &df_g_nil_view_spec; - view->params_arena = arena_alloc(); - view->params_entity = df_handle_zero(); - view->params_file_path = str8_zero(); view->project_path_arena = arena_alloc(); view->project_path = str8_zero(); view->query_cursor = view->query_mark = txt_pt(1, 1); @@ -789,7 +796,6 @@ df_view_release(DF_View *view) } view->first_arena_ext = view->last_arena_ext = 0; arena_release(view->project_path_arena); - arena_release(view->params_arena); arena_release(view->arena); view->generation += 1; df_gfx_state->allocated_view_count -= 1; @@ -797,12 +803,12 @@ df_view_release(DF_View *view) } internal void -df_view_equip_spec(DF_Window *window, DF_View *view, DF_ViewSpec *spec, DF_Entity *entity, String8 file_path, String8 default_query, DF_CfgNode *cfg_root) +df_view_equip_spec(DF_Window *window, DF_View *view, DF_ViewSpec *spec, String8 query, DF_CfgNode *cfg_root) { - // rjf: fill arguments buffer - view->query_string_size = Min(sizeof(view->query_buffer), default_query.size); - MemoryCopy(view->query_buffer, default_query.str, view->query_string_size); - view->query_cursor = view->query_mark = txt_pt(1, default_query.size+1); + // rjf: fill query buffer + view->query_string_size = Min(sizeof(view->query_buffer), query.size); + MemoryCopy(view->query_buffer, query.str, view->query_string_size); + view->query_cursor = view->query_mark = txt_pt(1, query.size+1); // rjf: initialize state for new view spec, if needed if(view->spec != spec || spec == &df_g_nil_view_spec) @@ -811,9 +817,6 @@ df_view_equip_spec(DF_Window *window, DF_View *view, DF_ViewSpec *spec, DF_Entit df_view_clear_user_state(view); MemoryZeroStruct(&view->scroll_pos); view->spec = spec; - arena_clear(view->params_arena); - view->params_file_path = push_str8_copy(view->params_arena, file_path); - view->params_entity = df_handle_from_entity(entity); if(spec->info.flags & DF_ViewSpecFlag_ProjectSpecific) { arena_clear(view->project_path_arena); @@ -1118,8 +1121,9 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) !df_view_is_nil(view); view = view->next) { - DF_Entity *entity = df_entity_from_handle(view->params_entity); - if(entity->flags & DF_EntityFlag_MarkedForDeletion || (df_entity_is_nil(entity) && !df_handle_match(df_handle_zero(), view->params_entity))) + DF_Entity *entity = df_entity_from_eval_string(str8(view->query_buffer, view->query_string_size)); + if(entity->flags & DF_EntityFlag_MarkedForDeletion || + (df_entity_is_nil(entity) && view->spec->info.flags & DF_ViewSpecFlag_ParameterizedByEntity)) { DF_CmdParams params = df_cmd_params_from_view(ws, panel, view); df_cmd_list_push(arena, cmds, ¶ms, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_CloseTab)); @@ -1474,87 +1478,87 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) if(df_view_is_nil(watch)) { watch = df_view_alloc(); - df_view_equip_spec(ws, watch, df_view_spec_from_gfx_view_kind(DF_GfxViewKind_Watch), &df_g_nil_entity, str8_lit(""), str8_lit(""), &df_g_nil_cfg_node); + df_view_equip_spec(ws, watch, df_view_spec_from_gfx_view_kind(DF_GfxViewKind_Watch), str8_zero(), &df_g_nil_cfg_node); } if(layout == Layout_Default && df_view_is_nil(locals)) { locals = df_view_alloc(); - df_view_equip_spec(ws, locals, df_view_spec_from_gfx_view_kind(DF_GfxViewKind_Locals), &df_g_nil_entity, str8_lit(""), str8_lit(""), &df_g_nil_cfg_node); + df_view_equip_spec(ws, locals, df_view_spec_from_gfx_view_kind(DF_GfxViewKind_Locals), str8_zero(), &df_g_nil_cfg_node); } if(layout == Layout_Default && df_view_is_nil(regs)) { regs = df_view_alloc(); - df_view_equip_spec(ws, regs, df_view_spec_from_gfx_view_kind(DF_GfxViewKind_Registers), &df_g_nil_entity, str8_lit(""), str8_lit(""), &df_g_nil_cfg_node); + df_view_equip_spec(ws, regs, df_view_spec_from_gfx_view_kind(DF_GfxViewKind_Registers), str8_zero(), &df_g_nil_cfg_node); } if(layout == Layout_Default && df_view_is_nil(globals)) { globals = df_view_alloc(); - df_view_equip_spec(ws, globals, df_view_spec_from_gfx_view_kind(DF_GfxViewKind_Globals), &df_g_nil_entity, str8_lit(""), str8_lit(""), &df_g_nil_cfg_node); + df_view_equip_spec(ws, globals, df_view_spec_from_gfx_view_kind(DF_GfxViewKind_Globals), str8_zero(), &df_g_nil_cfg_node); } if(layout == Layout_Default && df_view_is_nil(tlocals)) { tlocals = df_view_alloc(); - df_view_equip_spec(ws, tlocals, df_view_spec_from_gfx_view_kind(DF_GfxViewKind_ThreadLocals), &df_g_nil_entity, str8_lit(""), str8_lit(""), &df_g_nil_cfg_node); + df_view_equip_spec(ws, tlocals, df_view_spec_from_gfx_view_kind(DF_GfxViewKind_ThreadLocals), str8_zero(), &df_g_nil_cfg_node); } if(df_view_is_nil(types)) { types = df_view_alloc(); - df_view_equip_spec(ws, types, df_view_spec_from_gfx_view_kind(DF_GfxViewKind_Types), &df_g_nil_entity, str8_lit(""), str8_lit(""), &df_g_nil_cfg_node); + df_view_equip_spec(ws, types, df_view_spec_from_gfx_view_kind(DF_GfxViewKind_Types), str8_zero(), &df_g_nil_cfg_node); } if(layout == Layout_Default && df_view_is_nil(procs)) { procs = df_view_alloc(); - df_view_equip_spec(ws, procs, df_view_spec_from_gfx_view_kind(DF_GfxViewKind_Procedures), &df_g_nil_entity, str8_lit(""), str8_lit(""), &df_g_nil_cfg_node); + df_view_equip_spec(ws, procs, df_view_spec_from_gfx_view_kind(DF_GfxViewKind_Procedures), str8_zero(), &df_g_nil_cfg_node); } if(df_view_is_nil(callstack)) { callstack = df_view_alloc(); - df_view_equip_spec(ws, callstack, df_view_spec_from_gfx_view_kind(DF_GfxViewKind_CallStack), &df_g_nil_entity, str8_lit(""), str8_lit(""), &df_g_nil_cfg_node); + df_view_equip_spec(ws, callstack, df_view_spec_from_gfx_view_kind(DF_GfxViewKind_CallStack), str8_zero(), &df_g_nil_cfg_node); } if(df_view_is_nil(breakpoints)) { breakpoints = df_view_alloc(); - df_view_equip_spec(ws, breakpoints, df_view_spec_from_gfx_view_kind(DF_GfxViewKind_Breakpoints), &df_g_nil_entity, str8_lit(""), str8_lit(""), &df_g_nil_cfg_node); + df_view_equip_spec(ws, breakpoints, df_view_spec_from_gfx_view_kind(DF_GfxViewKind_Breakpoints), str8_zero(), &df_g_nil_cfg_node); } if(layout == Layout_Default && df_view_is_nil(watch_pins)) { watch_pins = df_view_alloc(); - df_view_equip_spec(ws, watch_pins, df_view_spec_from_gfx_view_kind(DF_GfxViewKind_WatchPins), &df_g_nil_entity, str8_lit(""), str8_lit(""), &df_g_nil_cfg_node); + df_view_equip_spec(ws, watch_pins, df_view_spec_from_gfx_view_kind(DF_GfxViewKind_WatchPins), str8_zero(), &df_g_nil_cfg_node); } if(df_view_is_nil(output)) { output = df_view_alloc(); - df_view_equip_spec(ws, output, df_view_spec_from_gfx_view_kind(DF_GfxViewKind_Output), &df_g_nil_entity, str8_lit(""), str8_lit(""), &df_g_nil_cfg_node); + df_view_equip_spec(ws, output, df_view_spec_from_gfx_view_kind(DF_GfxViewKind_Output), str8_zero(), &df_g_nil_cfg_node); } if(df_view_is_nil(targets)) { targets = df_view_alloc(); - df_view_equip_spec(ws, targets, df_view_spec_from_gfx_view_kind(DF_GfxViewKind_Targets), &df_g_nil_entity, str8_lit(""), str8_lit(""), &df_g_nil_cfg_node); + df_view_equip_spec(ws, targets, df_view_spec_from_gfx_view_kind(DF_GfxViewKind_Targets), str8_zero(), &df_g_nil_cfg_node); } if(df_view_is_nil(scheduler)) { scheduler = df_view_alloc(); - df_view_equip_spec(ws, scheduler, df_view_spec_from_gfx_view_kind(DF_GfxViewKind_Scheduler), &df_g_nil_entity, str8_lit(""), str8_lit(""), &df_g_nil_cfg_node); + df_view_equip_spec(ws, scheduler, df_view_spec_from_gfx_view_kind(DF_GfxViewKind_Scheduler), str8_zero(), &df_g_nil_cfg_node); } if(df_view_is_nil(modules)) { modules = df_view_alloc(); - df_view_equip_spec(ws, modules, df_view_spec_from_gfx_view_kind(DF_GfxViewKind_Modules), &df_g_nil_entity, str8_lit(""), str8_lit(""), &df_g_nil_cfg_node); + df_view_equip_spec(ws, modules, df_view_spec_from_gfx_view_kind(DF_GfxViewKind_Modules), str8_zero(), &df_g_nil_cfg_node); } if(df_view_is_nil(disasm)) { disasm = df_view_alloc(); - df_view_equip_spec(ws, disasm, df_view_spec_from_gfx_view_kind(DF_GfxViewKind_Disassembly), &df_g_nil_entity, str8_lit(""), str8_lit(""), &df_g_nil_cfg_node); + df_view_equip_spec(ws, disasm, df_view_spec_from_gfx_view_kind(DF_GfxViewKind_Disassembly), str8_zero(), &df_g_nil_cfg_node); } if(layout == Layout_Default && df_view_is_nil(memory)) { memory = df_view_alloc(); - df_view_equip_spec(ws, memory, df_view_spec_from_gfx_view_kind(DF_GfxViewKind_Memory), &df_g_nil_entity, str8_lit(""), str8_lit(""), &df_g_nil_cfg_node); + df_view_equip_spec(ws, memory, df_view_spec_from_gfx_view_kind(DF_GfxViewKind_Memory), str8_zero(), &df_g_nil_cfg_node); } if(code_views.count == 0 && df_view_is_nil(getting_started)) { getting_started = df_view_alloc(); - df_view_equip_spec(ws, getting_started, df_view_spec_from_gfx_view_kind(DF_GfxViewKind_GettingStarted), &df_g_nil_entity, str8_lit(""), str8_lit(""), &df_g_nil_cfg_node); + df_view_equip_spec(ws, getting_started, df_view_spec_from_gfx_view_kind(DF_GfxViewKind_GettingStarted), str8_zero(), &df_g_nil_cfg_node); } //- rjf: apply layout @@ -2007,7 +2011,20 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) if(!df_panel_is_nil(panel) && spec != &df_g_nil_view_spec) { DF_View *view = df_view_alloc(); - df_view_equip_spec(ws, view, spec, entity, params.file_path, params.string, params.cfg_node); + String8 query = {0}; + if(!df_entity_is_nil(entity)) + { + query = df_eval_string_from_entity(scratch.arena, entity); + } + else if(params.file_path.size != 0) + { + query = df_eval_string_from_file_path(scratch.arena, params.file_path); + } + else if(params.string.size != 0) + { + query = params.string; + } + df_view_equip_spec(ws, view, spec, query, params.cfg_node); df_panel_insert_tab_view(panel, panel->last_tab_view, view); df_panel_notify_mutation(ws, panel); } @@ -2087,6 +2104,8 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) }break; case DF_CoreCmdKind_Switch: { + // TODO(rjf): @viz_merge +#if 0 B32 already_opened = 0; DF_Panel *panel = df_panel_from_handle(params.panel); for(DF_View *v = panel->first_tab_view; !df_view_is_nil(v); v = v->next) @@ -2111,6 +2130,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) df_cmd_params_mark_slot(&p, DF_CmdParamSlot_Entity); df_cmd_list_push(arena, cmds, &p, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_PendingFile)); } +#endif }break; case DF_CoreCmdKind_SwitchToPartnerFile: { @@ -2119,11 +2139,11 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) DF_GfxViewKind view_kind = df_gfx_view_kind_from_string(view->spec->info.name); if(view_kind == DF_GfxViewKind_Code) { - String8 file_path = view->params_file_path; + String8 file_path = df_file_path_from_eval_string(scratch.arena, str8(view->query_buffer, view->query_string_size)); String8 file_full_path = path_normalized_from_string(scratch.arena, file_path); - String8 file_folder = str8_chop_last_slash(file_full_path); - String8 file_name = str8_skip_last_slash(str8_chop_last_dot(file_full_path)); - String8 file_ext = str8_skip_last_dot(file_full_path); + String8 file_folder = str8_chop_last_slash(file_full_path); + String8 file_name = str8_skip_last_slash(str8_chop_last_dot(file_full_path)); + String8 file_ext = str8_skip_last_dot(file_full_path); String8 partner_ext_candidates[] = { str8_lit_comp("h"), @@ -2963,9 +2983,10 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) for(DF_View *view = panel->first_tab_view; !df_view_is_nil(view); view = view->next) { if(df_view_is_project_filtered(view)) { continue; } + String8 view_file_path = df_file_path_from_eval_string(scratch.arena, str8(view->query_buffer, view->query_string_size)); DF_GfxViewKind view_kind = df_gfx_view_kind_from_string(view->spec->info.name); if((view_kind == DF_GfxViewKind_Code || view_kind == DF_GfxViewKind_PendingFile) && - path_match_normalized(view->params_file_path, file_path)) + path_match_normalized(view_file_path, file_path)) { panel_w_this_src_code = panel; view_w_this_src_code = view; @@ -3094,7 +3115,8 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) if(!df_panel_is_nil(dst_panel) && df_view_is_nil(view_w_this_src_code)) { DF_View *view = df_view_alloc(); - df_view_equip_spec(ws, view, df_view_spec_from_gfx_view_kind(DF_GfxViewKind_Code), &df_g_nil_entity, file_path, str8_lit(""), &df_g_nil_cfg_node); + String8 file_path_query = df_eval_string_from_file_path(scratch.arena, file_path); + df_view_equip_spec(ws, view, df_view_spec_from_gfx_view_kind(DF_GfxViewKind_Code), file_path_query, &df_g_nil_cfg_node); df_panel_insert_tab_view(dst_panel, dst_panel->last_tab_view, view); dst_view = view; } @@ -3142,7 +3164,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) if(!df_panel_is_nil(dst_panel) && df_view_is_nil(view_w_disasm)) { DF_View *view = df_view_alloc(); - df_view_equip_spec(ws, view, df_view_spec_from_gfx_view_kind(DF_GfxViewKind_Disassembly), &df_g_nil_entity, str8_lit(""), str8_lit(""), &df_g_nil_cfg_node); + df_view_equip_spec(ws, view, df_view_spec_from_gfx_view_kind(DF_GfxViewKind_Disassembly), str8_zero(), &df_g_nil_cfg_node); df_panel_insert_tab_view(dst_panel, dst_panel->last_tab_view, view); dst_view = view; } @@ -4396,7 +4418,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) DF_Panel *panel = df_panel_from_handle(ws->tab_ctx_menu_panel); DF_View *view = df_view_from_handle(ws->tab_ctx_menu_view); DF_IconKind view_icon = df_icon_kind_from_view(view); - String8 file_path = view->params_file_path; + String8 file_path = df_file_path_from_eval_string(scratch.arena, str8(view->query_buffer, view->query_string_size)); String8 display_name = df_display_string_from_view(scratch.arena, view); // rjf: title @@ -5855,7 +5877,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) // rjf: construct & push new view DF_View *view = df_view_alloc(); - df_view_equip_spec(ws, view, view_spec, &df_g_nil_entity, str8_lit(""), default_query, &df_g_nil_cfg_node); + df_view_equip_spec(ws, view, view_spec, default_query, &df_g_nil_cfg_node); if(cmd_spec->info.query.flags & DF_CmdQueryFlag_SelectOldInput) { view->query_mark = txt_pt(1, 1); @@ -7150,7 +7172,7 @@ df_window_update_and_render(Arena *arena, DF_Window *ws, DF_CmdList *cmds) DF_View *view = df_selected_tab_from_panel(panel); df_interact_regs()->cursor = view->cursor; df_interact_regs()->mark = view->mark; - df_interact_regs()->file_path = view->params_file_path; + df_interact_regs()->file_path = df_file_path_from_eval_string(df_frame_arena(), str8(view->query_buffer, view->query_string_size)); } //- rjf: build view container @@ -9341,19 +9363,17 @@ df_cfg_strings_from_gfx(Arena *arena, String8 root_path, DF_CfgSrc source) Temp scratch = scratch_begin(&arena, 1); String8 query_raw = str8(view->query_buffer, view->query_string_size); String8 query_sanitized = df_cfg_escaped_from_raw_string(scratch.arena, query_raw); + { + String8 query_file_path = df_file_path_from_eval_string(scratch.arena, query_sanitized); + if(query_file_path.size != 0) + { + query_file_path = path_relative_dst_from_absolute_dst_src(scratch.arena, query_file_path, root_path); + query_sanitized = push_str8f(scratch.arena, "file:\"%S\"", query_file_path); + } + } str8_list_pushf(arena, &strs, "query:{\"%S\"} ", query_sanitized); scratch_end(scratch); } - if(view->spec->info.flags & DF_ViewSpecFlag_CanSerializeFilePath && - view->params_file_path.size != 0) - { - Temp scratch = scratch_begin(&arena, 1); - String8 project_path = root_path; - String8 file_path = path_normalized_from_string(scratch.arena, view->params_file_path); - String8 file_path_rel = path_relative_dst_from_absolute_dst_src(scratch.arena, file_path, project_path); - str8_list_pushf(arena, &strs, "\"%S\"", file_path_rel); - scratch_end(scratch); - } String8 view_state_string = view->spec->info.string_from_state_hook(arena, view); str8_list_push(arena, &strs, view_state_string); str8_list_push(arena, &strs, str8_lit("}\n")); @@ -13537,17 +13557,18 @@ df_gfx_begin_frame(Arena *arena, DF_CmdList *cmds) view_query = df_cfg_raw_from_escaped_string(scratch.arena, escaped_query); } - // rjf: read path - String8 file_path = {0}; - if(view_spec_flags & DF_ViewSpecFlag_CanSerializeFilePath) + // rjf: convert file queries from relative to absolute { - String8 saved_path = df_first_cfg_node_child_from_flags(op, DF_CfgNodeFlag_StringLiteral)->string; - String8 saved_path_absolute = path_absolute_dst_from_relative_dst_src(scratch.arena, saved_path, cfg_folder); - file_path = saved_path_absolute; + String8 query_file_path = df_file_path_from_eval_string(scratch.arena, view_query); + if(query_file_path.size != 0) + { + query_file_path = path_absolute_dst_from_relative_dst_src(scratch.arena, query_file_path, cfg_folder); + view_query = push_str8f(scratch.arena, "file:\"%S\"", query_file_path); + } } // rjf: set up view - df_view_equip_spec(ws, view, view_spec, &df_g_nil_entity, file_path, view_query, op); + df_view_equip_spec(ws, view, view_spec, view_query, op); if(project_path.size != 0) { arena_clear(view->project_path_arena); diff --git a/src/df/gfx/df_gfx.h b/src/df/gfx/df_gfx.h index bd75a075..fa938879 100644 --- a/src/df/gfx/df_gfx.h +++ b/src/df/gfx/df_gfx.h @@ -195,11 +195,6 @@ struct DF_View Arena *project_path_arena; String8 project_path; - // rjf: view specification parameters - Arena *params_arena; - DF_Handle params_entity; - String8 params_file_path; - // rjf: view state UI_ScrollPt2 scroll_pos; TxtPt cursor; @@ -218,8 +213,8 @@ struct DF_View // rjf: text query state TxtPt query_cursor; TxtPt query_mark; - U8 query_buffer[1024]; U64 query_string_size; + U8 query_buffer[KB(4)]; }; //////////////////////////////// @@ -932,7 +927,7 @@ internal DF_ViewSpec *df_tab_view_spec_from_gfx_view_rule_spec(DF_GfxViewRuleSpe internal DF_View *df_view_alloc(void); internal void df_view_release(DF_View *view); -internal void df_view_equip_spec(DF_Window *window, DF_View *view, DF_ViewSpec *spec, DF_Entity *entity, String8 file_path, String8 default_query, DF_CfgNode *cfg_root); +internal void df_view_equip_spec(DF_Window *window, DF_View *view, DF_ViewSpec *spec, String8 query, DF_CfgNode *cfg_root); internal void df_view_equip_loading_info(DF_View *view, B32 is_loading, U64 progress_v, U64 progress_target); internal void df_view_clear_user_state(DF_View *view); internal void *df_view_get_or_push_user_state(DF_View *view, U64 size); diff --git a/src/df/gfx/df_gfx.mdesk b/src/df/gfx/df_gfx.mdesk index 79edf31d..16352ff2 100644 --- a/src/df/gfx/df_gfx.mdesk +++ b/src/df/gfx/df_gfx.mdesk @@ -228,8 +228,8 @@ DF_GfxViewTable: { Scheduler "scheduler" "Scheduler" Scheduler 0 0 1 0 1 1 1 1 "Displays all processes and threads to which the debugger is currently attached, and contains controls for selecting and freezing threads." } { CallStack "call_stack" "Call Stack" Thread 0 0 1 0 0 0 0 1 "Displays the call stack of the currently selected thread. Each frame in the call stack contains the associated module, function name, and return address. Allows selection of a particular call stack frame other than the top." } { Modules "modules" "Modules" Module 0 0 1 0 1 0 1 1 "Displays a table of all modules currently loaded by any process to which the debugger is attached. This table displays each module's name, virtual address range in the containing process' address space, and which debug info file is being used by the debugger for the associated module." } - { PendingFile "pending_file" "Pending File" FileOutline 1 0 0 0 0 0 0 0 "" } - { Code "code" "Code" FileOutline 1 1 1 1 0 0 0 0 "" } + { PendingFile "pending_file" "Pending File" FileOutline 0 0 0 0 0 0 0 0 "" } + { Code "code" "Code" FileOutline 0 1 1 1 0 0 0 0 "" } { Disassembly "disassembly" "Disassembly" Glasses 0 0 1 0 0 0 0 1 "Displays disassembled instructions in a textual form from the selected thread's containing process virtual address space." } { Watch "watch" "Watch" Binoculars 0 0 1 0 1 1 1 1 "The familiar 'watch window' debugger interface. Allows the inputting of a number of expressions. Each expression in the table is evaluated within the context of the selected thread's selected call stack frame. If applicable (depending on visualization rules and the expression's type), these expressions may be hierarchically expanded, which displays children as more rows in the table. The values of these expressions may also be edited, and if possible, can be used to write to registers or memory in attached processes. Also contains a new *view rule* column, not found in other major debuggers, which allows per-row specification of various visualization rules. These view rules may be used to visualize and inspect the evaluation of expressions in a variety of ways. To learn more, read the 'View Rules' section." } { Locals "locals" "Locals" Binoculars 0 0 1 0 1 1 1 1 "Nearly identical to `Watch`, but automatically filled with local variables found within the selected call stack frame of the selected thread, according to the associated debug info. View rules and evaluation values can be edited, like in `Watch`, but unlike `Watch`, expressions cannot be edited or added to the table." } diff --git a/src/df/gfx/df_views.c b/src/df/gfx/df_views.c index af2f05fe..76d8ff15 100644 --- a/src/df/gfx/df_views.c +++ b/src/df/gfx/df_views.c @@ -1524,7 +1524,7 @@ df_watch_view_build(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_WatchViewS } E_MemberArray bp_members_array = e_member_array_from_list(scratch.arena, &bp_members); E_TypeKey bp_type = e_type_key_cons(.arch = architecture_from_context(), .kind = E_TypeKind_Struct, .name = str8_lit("Breakpoint"), .members = bp_members_array.v, .count = bp_members_array.count); - E_Expr *bp_expr = e_push_expr(scratch.arena, E_ExprKind_LeafID, 0); + E_Expr *bp_expr = e_push_expr(scratch.arena, E_ExprKind_LeafOffset, 0); bp_expr->type_key = bp_type; bp_expr->mode = E_Mode_Offset; bp_expr->space = df_eval_space_from_entity(bp); @@ -1559,7 +1559,7 @@ df_watch_view_build(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_WatchViewS } E_MemberArray wp_members_array = e_member_array_from_list(scratch.arena, &wp_members); E_TypeKey wp_type = e_type_key_cons(.arch = architecture_from_context(), .kind = E_TypeKind_Struct, .name = str8_lit("Watch Pin"), .members = wp_members_array.v, .count = wp_members_array.count); - E_Expr *wp_expr = e_push_expr(scratch.arena, E_ExprKind_LeafID, 0); + E_Expr *wp_expr = e_push_expr(scratch.arena, E_ExprKind_LeafOffset, 0); wp_expr->type_key = wp_type; wp_expr->mode = E_Mode_Offset; wp_expr->space = df_eval_space_from_entity(wp); @@ -3128,21 +3128,21 @@ df_watch_view_build(DF_Window *ws, DF_Panel *panel, DF_View *view, DF_WatchViewS { ext = push_str8f(scratch.arena, "'%S'", t->expr->string); } - else if(t->expr->u32 != 0) + else if(t->expr->value.u32 != 0) { - ext = push_str8f(scratch.arena, "0x%x", t->expr->u32); + ext = push_str8f(scratch.arena, "0x%x", t->expr->value.u32); } - else if(t->expr->f32 != 0) + else if(t->expr->value.f32 != 0) { - ext = push_str8f(scratch.arena, "%f", t->expr->f32); + ext = push_str8f(scratch.arena, "%f", t->expr->value.f32); } - else if(t->expr->f64 != 0) + else if(t->expr->value.f64 != 0) { - ext = push_str8f(scratch.arena, "%f", t->expr->f64); + ext = push_str8f(scratch.arena, "%f", t->expr->value.f64); } - else if(t->expr->u64 != 0) + else if(t->expr->value.u64 != 0) { - ext = push_str8f(scratch.arena, "0x%I64x", t->expr->u64); + ext = push_str8f(scratch.arena, "0x%I64x", t->expr->value.u64); } }break; } @@ -3794,7 +3794,7 @@ DF_VIEW_UI_FUNCTION_DEF(FileSystem) if(query_normalized_with_opt_slash_props.flags & FilePropertyFlag_IsFolder) { String8 new_path = push_str8f(scratch.arena, "%S%S/", path_query.path, path_query.search); - df_view_equip_spec(ws, view, view->spec, &df_g_nil_entity, str8_zero(), new_path, &df_g_nil_cfg_node); + df_view_equip_spec(ws, view, view->spec, new_path, &df_g_nil_cfg_node); } // rjf: is a file -> complete view @@ -3824,7 +3824,7 @@ DF_VIEW_UI_FUNCTION_DEF(FileSystem) { String8 existing_path = str8_chop_last_slash(path_query.path); String8 new_path = push_str8f(scratch.arena, "%S/%S/", existing_path, files[0].filename); - df_view_equip_spec(ws, view, view->spec, &df_g_nil_entity, str8_zero(), new_path, &df_g_nil_cfg_node); + df_view_equip_spec(ws, view, view->spec, new_path, &df_g_nil_cfg_node); } else { @@ -3954,7 +3954,7 @@ DF_VIEW_UI_FUNCTION_DEF(FileSystem) String8 new_path = str8_chop_last_slash(str8_chop_last_slash(path_query.path)); new_path = path_normalized_from_string(scratch.arena, new_path); String8 new_cmd = push_str8f(scratch.arena, "%S%s", new_path, new_path.size != 0 ? "/" : ""); - df_view_equip_spec(ws, view, view->spec, &df_g_nil_entity, str8_zero(), new_cmd, &df_g_nil_cfg_node); + df_view_equip_spec(ws, view, view->spec, new_cmd, &df_g_nil_cfg_node); } } @@ -4036,7 +4036,7 @@ DF_VIEW_UI_FUNCTION_DEF(FileSystem) if(file->props.flags & FilePropertyFlag_IsFolder) { String8 new_cmd = push_str8f(scratch.arena, "%S%s", new_path, new_path.size != 0 ? "/" : ""); - df_view_equip_spec(ws, view, view->spec, &df_g_nil_entity, str8_zero(), new_cmd, &df_g_nil_cfg_node); + df_view_equip_spec(ws, view, view->spec, new_cmd, &df_g_nil_cfg_node); } else { @@ -4597,7 +4597,7 @@ DF_VIEW_STRING_FROM_STATE_FUNCTION_DEF(Target) DF_VIEW_CMD_FUNCTION_DEF(Target) { DF_TargetViewState *tv = df_view_user_state(view, DF_TargetViewState); - DF_Entity *entity = df_entity_from_handle(view->params_entity); + DF_Entity *entity = df_entity_from_eval_string(str8(view->query_buffer, view->query_string_size)); // rjf: process commands for(DF_CmdNode *n = cmds->first; n != 0; n = n->next) @@ -4640,7 +4640,7 @@ DF_VIEW_UI_FUNCTION_DEF(Target) { ProfBeginFunction(); Temp scratch = scratch_begin(0, 0); - DF_Entity *entity = df_entity_from_handle(view->params_entity); + DF_Entity *entity = df_entity_from_eval_string(str8(view->query_buffer, view->query_string_size)); DF_EntityList custom_entry_points = df_push_entity_child_list_with_kind(scratch.arena, entity, DF_EntityKind_EntryPoint); F32 row_height_px = floor_f32(ui_top_font_size()*2.5f); @@ -6357,7 +6357,7 @@ DF_VIEW_CMD_FUNCTION_DEF(PendingFile) } //- rjf: determine if file is ready, and which viewer to use - String8 file_path = view->params_file_path; + String8 file_path = df_file_path_from_eval_string(scratch.arena, str8(view->query_buffer, view->query_string_size)); B32 file_is_ready = 1; DF_GfxViewKind viewer_kind = DF_GfxViewKind_Code; @@ -6388,7 +6388,8 @@ DF_VIEW_CMD_FUNCTION_DEF(PendingFile) { view_spec = df_view_spec_from_gfx_view_kind(viewer_kind); } - df_view_equip_spec(ws, view, view_spec, &df_g_nil_entity, file_path, str8_lit(""), cfg_root); + String8 query = df_eval_string_from_file_path(scratch.arena, file_path); + df_view_equip_spec(ws, view, view_spec, query, cfg_root); df_panel_notify_mutation(ws, panel); } @@ -6447,9 +6448,10 @@ DF_VIEW_CMD_FUNCTION_DEF(Code) Temp scratch = scratch_begin(0, 0); HS_Scope *hs_scope = hs_scope_open(); TXT_Scope *txt_scope = txt_scope_open(); - String8 path = df_interact_regs()->file_path; - df_interact_regs()->text_key = fs_key_from_path_range(path, r1u64(0, max_U64)); - df_interact_regs()->lang_kind = txt_lang_kind_from_extension(str8_skip_last_dot(path)); + E_Eval eval = e_eval_from_string(scratch.arena, str8(view->query_buffer, view->query_string_size)); + Rng1U64 range = df_range_from_eval_cfg(eval, &df_g_nil_cfg_node); + df_interact_regs()->text_key = df_key_from_eval_space_range(eval.space, range); + df_interact_regs()->lang_kind = df_lang_kind_from_eval_cfg(eval, &df_g_nil_cfg_node); U128 hash = {0}; TXT_TextInfo info = txt_text_info_from_key_lang(txt_scope, df_interact_regs()->text_key, df_interact_regs()->lang_kind, &hash); String8 data = hs_data_from_hash(hs_scope, hash); @@ -6478,7 +6480,7 @@ DF_VIEW_CMD_FUNCTION_DEF(Code) // rjf: override file picking case DF_CoreCmdKind_PickFile: { - String8 src = view->params_file_path; + String8 src = df_file_path_from_eval_string(scratch.arena, str8(view->query_buffer, view->query_string_size)); String8 dst = cmd->params.file_path; if(src.size != 0 && dst.size != 0) { @@ -6489,8 +6491,8 @@ DF_VIEW_CMD_FUNCTION_DEF(Code) df_push_cmd__root(&p, df_cmd_spec_from_core_cmd_kind(DF_CoreCmdKind_SetFileReplacementPath)); // rjf: switch this view to viewing replacement file - arena_clear(view->params_arena); - view->params_file_path = push_str8_copy(view->params_arena, dst); + view->query_string_size = Min(sizeof(view->query_buffer), dst.size); + MemoryCopy(view->query_buffer, dst.str, view->query_string_size); } }break; } @@ -6516,11 +6518,13 @@ DF_VIEW_UI_FUNCTION_DEF(Code) Rng2F32 bottom_bar_rect = r2f32p(rect.x0, rect.y1 - bottom_bar_height, rect.x1, rect.y1); ////////////////////////////// - //- rjf: unpack entity info + //- rjf: unpack parameterization info // String8 path = df_interact_regs()->file_path; - df_interact_regs()->text_key = fs_key_from_path_range(path, r1u64(0, max_U64)); - df_interact_regs()->lang_kind = txt_lang_kind_from_extension(str8_skip_last_dot(path)); + E_Eval eval = e_eval_from_string(scratch.arena, str8(view->query_buffer, view->query_string_size)); + Rng1U64 range = df_range_from_eval_cfg(eval, &df_g_nil_cfg_node); + df_interact_regs()->text_key = df_key_from_eval_space_range(eval.space, range); + df_interact_regs()->lang_kind = df_lang_kind_from_eval_cfg(eval, &df_g_nil_cfg_node); U128 hash = {0}; TXT_TextInfo info = txt_text_info_from_key_lang(txt_scope, df_interact_regs()->text_key, df_interact_regs()->lang_kind, &hash); String8 data = hs_data_from_hash(hs_scope, hash); @@ -6593,15 +6597,18 @@ DF_VIEW_UI_FUNCTION_DEF(Code) B32 file_is_out_of_date = 0; String8 out_of_date_dbgi_name = {0}; { - for(DI_KeyNode *n = dbgi_keys.first; n != 0; n = n->next) + U64 file_timestamp = fs_timestamp_from_path(path); + if(file_timestamp != 0) { - DI_Key key = n->v; - U64 file_timestamp = fs_timestamp_from_path(path); - if(key.min_timestamp < file_timestamp) + for(DI_KeyNode *n = dbgi_keys.first; n != 0; n = n->next) { - file_is_out_of_date = 1; - out_of_date_dbgi_name = str8_skip_last_slash(key.path); - break; + DI_Key key = n->v; + if(key.min_timestamp < file_timestamp) + { + file_is_out_of_date = 1; + out_of_date_dbgi_name = str8_skip_last_slash(key.path); + break; + } } } } diff --git a/src/df/gfx/generated/df_gfx.meta.c b/src/df/gfx/generated/df_gfx.meta.c index bb56d694..96abe9b1 100644 --- a/src/df/gfx/generated/df_gfx.meta.c +++ b/src/df/gfx/generated/df_gfx.meta.c @@ -157,8 +157,8 @@ DF_ViewSpecInfo df_g_gfx_view_kind_spec_info_table[31] = {(0|0*DF_ViewSpecFlag_ParameterizedByEntity|0*DF_ViewSpecFlag_ProjectSpecific|1*DF_ViewSpecFlag_CanSerialize|0*DF_ViewSpecFlag_CanSerializeFilePath|1*(DF_ViewSpecFlag_CanFilter|DF_ViewSpecFlag_CanSerializeQuery)|1*DF_ViewSpecFlag_FilterIsCode|1*DF_ViewSpecFlag_TypingAutomaticallyFilters), str8_lit_comp("scheduler"), str8_lit_comp("Scheduler"), DF_IconKind_Scheduler, DF_VIEW_SETUP_FUNCTION_NAME(Scheduler), DF_VIEW_STRING_FROM_STATE_FUNCTION_NAME(Scheduler), DF_VIEW_CMD_FUNCTION_NAME(Scheduler), DF_VIEW_UI_FUNCTION_NAME(Scheduler)}, {(0|0*DF_ViewSpecFlag_ParameterizedByEntity|0*DF_ViewSpecFlag_ProjectSpecific|1*DF_ViewSpecFlag_CanSerialize|0*DF_ViewSpecFlag_CanSerializeFilePath|0*(DF_ViewSpecFlag_CanFilter|DF_ViewSpecFlag_CanSerializeQuery)|0*DF_ViewSpecFlag_FilterIsCode|0*DF_ViewSpecFlag_TypingAutomaticallyFilters), str8_lit_comp("call_stack"), str8_lit_comp("Call Stack"), DF_IconKind_Thread, DF_VIEW_SETUP_FUNCTION_NAME(CallStack), DF_VIEW_STRING_FROM_STATE_FUNCTION_NAME(CallStack), DF_VIEW_CMD_FUNCTION_NAME(CallStack), DF_VIEW_UI_FUNCTION_NAME(CallStack)}, {(0|0*DF_ViewSpecFlag_ParameterizedByEntity|0*DF_ViewSpecFlag_ProjectSpecific|1*DF_ViewSpecFlag_CanSerialize|0*DF_ViewSpecFlag_CanSerializeFilePath|1*(DF_ViewSpecFlag_CanFilter|DF_ViewSpecFlag_CanSerializeQuery)|0*DF_ViewSpecFlag_FilterIsCode|1*DF_ViewSpecFlag_TypingAutomaticallyFilters), str8_lit_comp("modules"), str8_lit_comp("Modules"), DF_IconKind_Module, DF_VIEW_SETUP_FUNCTION_NAME(Modules), DF_VIEW_STRING_FROM_STATE_FUNCTION_NAME(Modules), DF_VIEW_CMD_FUNCTION_NAME(Modules), DF_VIEW_UI_FUNCTION_NAME(Modules)}, -{(0|1*DF_ViewSpecFlag_ParameterizedByEntity|0*DF_ViewSpecFlag_ProjectSpecific|0*DF_ViewSpecFlag_CanSerialize|0*DF_ViewSpecFlag_CanSerializeFilePath|0*(DF_ViewSpecFlag_CanFilter|DF_ViewSpecFlag_CanSerializeQuery)|0*DF_ViewSpecFlag_FilterIsCode|0*DF_ViewSpecFlag_TypingAutomaticallyFilters), str8_lit_comp("pending_file"), str8_lit_comp("Pending File"), DF_IconKind_FileOutline, DF_VIEW_SETUP_FUNCTION_NAME(PendingFile), DF_VIEW_STRING_FROM_STATE_FUNCTION_NAME(PendingFile), DF_VIEW_CMD_FUNCTION_NAME(PendingFile), DF_VIEW_UI_FUNCTION_NAME(PendingFile)}, -{(0|1*DF_ViewSpecFlag_ParameterizedByEntity|1*DF_ViewSpecFlag_ProjectSpecific|1*DF_ViewSpecFlag_CanSerialize|1*DF_ViewSpecFlag_CanSerializeFilePath|0*(DF_ViewSpecFlag_CanFilter|DF_ViewSpecFlag_CanSerializeQuery)|0*DF_ViewSpecFlag_FilterIsCode|0*DF_ViewSpecFlag_TypingAutomaticallyFilters), str8_lit_comp("code"), str8_lit_comp("Code"), DF_IconKind_FileOutline, DF_VIEW_SETUP_FUNCTION_NAME(Code), DF_VIEW_STRING_FROM_STATE_FUNCTION_NAME(Code), DF_VIEW_CMD_FUNCTION_NAME(Code), DF_VIEW_UI_FUNCTION_NAME(Code)}, +{(0|0*DF_ViewSpecFlag_ParameterizedByEntity|0*DF_ViewSpecFlag_ProjectSpecific|0*DF_ViewSpecFlag_CanSerialize|0*DF_ViewSpecFlag_CanSerializeFilePath|0*(DF_ViewSpecFlag_CanFilter|DF_ViewSpecFlag_CanSerializeQuery)|0*DF_ViewSpecFlag_FilterIsCode|0*DF_ViewSpecFlag_TypingAutomaticallyFilters), str8_lit_comp("pending_file"), str8_lit_comp("Pending File"), DF_IconKind_FileOutline, DF_VIEW_SETUP_FUNCTION_NAME(PendingFile), DF_VIEW_STRING_FROM_STATE_FUNCTION_NAME(PendingFile), DF_VIEW_CMD_FUNCTION_NAME(PendingFile), DF_VIEW_UI_FUNCTION_NAME(PendingFile)}, +{(0|0*DF_ViewSpecFlag_ParameterizedByEntity|1*DF_ViewSpecFlag_ProjectSpecific|1*DF_ViewSpecFlag_CanSerialize|1*DF_ViewSpecFlag_CanSerializeFilePath|0*(DF_ViewSpecFlag_CanFilter|DF_ViewSpecFlag_CanSerializeQuery)|0*DF_ViewSpecFlag_FilterIsCode|0*DF_ViewSpecFlag_TypingAutomaticallyFilters), str8_lit_comp("code"), str8_lit_comp("Code"), DF_IconKind_FileOutline, DF_VIEW_SETUP_FUNCTION_NAME(Code), DF_VIEW_STRING_FROM_STATE_FUNCTION_NAME(Code), DF_VIEW_CMD_FUNCTION_NAME(Code), DF_VIEW_UI_FUNCTION_NAME(Code)}, {(0|0*DF_ViewSpecFlag_ParameterizedByEntity|0*DF_ViewSpecFlag_ProjectSpecific|1*DF_ViewSpecFlag_CanSerialize|0*DF_ViewSpecFlag_CanSerializeFilePath|0*(DF_ViewSpecFlag_CanFilter|DF_ViewSpecFlag_CanSerializeQuery)|0*DF_ViewSpecFlag_FilterIsCode|0*DF_ViewSpecFlag_TypingAutomaticallyFilters), str8_lit_comp("disassembly"), str8_lit_comp("Disassembly"), DF_IconKind_Glasses, DF_VIEW_SETUP_FUNCTION_NAME(Disassembly), DF_VIEW_STRING_FROM_STATE_FUNCTION_NAME(Disassembly), DF_VIEW_CMD_FUNCTION_NAME(Disassembly), DF_VIEW_UI_FUNCTION_NAME(Disassembly)}, {(0|0*DF_ViewSpecFlag_ParameterizedByEntity|0*DF_ViewSpecFlag_ProjectSpecific|1*DF_ViewSpecFlag_CanSerialize|0*DF_ViewSpecFlag_CanSerializeFilePath|1*(DF_ViewSpecFlag_CanFilter|DF_ViewSpecFlag_CanSerializeQuery)|1*DF_ViewSpecFlag_FilterIsCode|1*DF_ViewSpecFlag_TypingAutomaticallyFilters), str8_lit_comp("watch"), str8_lit_comp("Watch"), DF_IconKind_Binoculars, DF_VIEW_SETUP_FUNCTION_NAME(Watch), DF_VIEW_STRING_FROM_STATE_FUNCTION_NAME(Watch), DF_VIEW_CMD_FUNCTION_NAME(Watch), DF_VIEW_UI_FUNCTION_NAME(Watch)}, {(0|0*DF_ViewSpecFlag_ParameterizedByEntity|0*DF_ViewSpecFlag_ProjectSpecific|1*DF_ViewSpecFlag_CanSerialize|0*DF_ViewSpecFlag_CanSerializeFilePath|1*(DF_ViewSpecFlag_CanFilter|DF_ViewSpecFlag_CanSerializeQuery)|1*DF_ViewSpecFlag_FilterIsCode|1*DF_ViewSpecFlag_TypingAutomaticallyFilters), str8_lit_comp("locals"), str8_lit_comp("Locals"), DF_IconKind_Binoculars, DF_VIEW_SETUP_FUNCTION_NAME(Locals), DF_VIEW_STRING_FROM_STATE_FUNCTION_NAME(Locals), DF_VIEW_CMD_FUNCTION_NAME(Locals), DF_VIEW_UI_FUNCTION_NAME(Locals)}, diff --git a/src/eval/eval.mdesk b/src/eval/eval.mdesk index b46d0a53..67061e55 100644 --- a/src/eval/eval.mdesk +++ b/src/eval/eval.mdesk @@ -119,7 +119,7 @@ E_ExprKindTable: { LeafF64 Null 0 "F64" "" "" "" } { LeafF32 Null 0 "F32" "" "" "" } { LeafIdent Null 0 "leaf_ident" "" "" "" } - { LeafID Null 0 "leaf_id" "" "" "" } + { LeafOffset Null 0 "leaf_offset" "" "" "" } { LeafFilePath Null 0 "leaf_filepath" "" "" "" } { TypeIdent Null 0 "type_ident" "" "" "" } diff --git a/src/eval/eval_core.h b/src/eval/eval_core.h index 7ab47511..8c46e638 100644 --- a/src/eval/eval_core.h +++ b/src/eval/eval_core.h @@ -46,6 +46,7 @@ union E_Value U64 u256[4]; U128 u128; U64 u64; + U32 u32; S64 s64; F64 f64; F32 f32; diff --git a/src/eval/eval_ir.c b/src/eval/eval_ir.c index b641bdd7..6f7209cb 100644 --- a/src/eval/eval_ir.c +++ b/src/eval/eval_ir.c @@ -1169,7 +1169,7 @@ e_irtree_and_type_from_expr(Arena *arena, E_Expr *expr) //- rjf: leaf U64s case E_ExprKind_LeafU64: { - U64 val = expr->u64; + U64 val = expr->value.u64; E_IRNode *new_tree = e_irtree_const_u(arena, val); E_TypeKey type_key = zero_struct; if(0){} @@ -1184,7 +1184,7 @@ e_irtree_and_type_from_expr(Arena *arena, E_Expr *expr) //- rjf: leaf F64s case E_ExprKind_LeafF64: { - U64 val = expr->u64; + U64 val = expr->value.u64; E_IRNode *new_tree = e_irtree_const_u(arena, val); result.root = new_tree; result.type_key = e_type_key_basic(E_TypeKind_F64); @@ -1194,7 +1194,7 @@ e_irtree_and_type_from_expr(Arena *arena, E_Expr *expr) //- rjf: leaf F32s case E_ExprKind_LeafF32: { - U32 val = expr->u32; + U32 val = expr->value.u32; E_IRNode *new_tree = e_irtree_const_u(arena, val); result.root = new_tree; result.type_key = e_type_key_basic(E_TypeKind_F32); @@ -1217,11 +1217,11 @@ e_irtree_and_type_from_expr(Arena *arena, E_Expr *expr) } }break; - //- rjf: leaf IDs (opaque u64s with type info attached) - case E_ExprKind_LeafID: + //- rjf: leaf offsets + case E_ExprKind_LeafOffset: { E_IRNode *new_tree = e_push_irnode(arena, RDI_EvalOp_ConstU64); - new_tree->value.u64 = expr->u64; + new_tree->value.u64 = expr->value.u64; result.root = new_tree; result.type_key = expr->type_key; result.mode = E_Mode_Offset; diff --git a/src/eval/eval_parse.c b/src/eval/eval_parse.c index a2cfd90b..b0897b5b 100644 --- a/src/eval/eval_parse.c +++ b/src/eval/eval_parse.c @@ -486,7 +486,7 @@ e_token_array_from_text(Arena *arena, String8 text) }break; case E_TokenKind_Numeric: { - if(!char_is_alpha(byte) && !char_is_digit(byte, 10) && byte != '.') + if(!char_is_alpha(byte) && !char_is_digit(byte, 10) && byte != '.' && byte != ':') { advance = 0; token_formed = 1; @@ -680,7 +680,7 @@ e_expr_ref_array_index(Arena *arena, E_Expr *lhs, U64 index) E_Expr *root = e_push_expr(arena, E_ExprKind_ArrayIndex, 0); E_Expr *lhs_ref = e_expr_ref(arena, lhs); E_Expr *rhs = e_push_expr(arena, E_ExprKind_LeafU64, 0); - rhs->u64 = index; + rhs->value.u64 = index; e_expr_push_child(root, lhs_ref); e_expr_push_child(root, rhs); return root; @@ -744,19 +744,19 @@ e_append_strings_from_expr(Arena *arena, E_Expr *expr, String8List *out) }break; case E_ExprKind_LeafU64: { - str8_list_pushf(arena, out, "%I64u", expr->u64); + str8_list_pushf(arena, out, "%I64u", expr->value.u64); }break; - case E_ExprKind_LeafID: + case E_ExprKind_LeafOffset: { - str8_list_pushf(arena, out, "0x%I64x", expr->u64); + str8_list_pushf(arena, out, "0x%I64x", expr->value.u64); }break; case E_ExprKind_LeafF64: { - str8_list_pushf(arena, out, "%f", expr->f64); + str8_list_pushf(arena, out, "%f", expr->value.f64); }break; case E_ExprKind_LeafF32: { - str8_list_pushf(arena, out, "%f", expr->f32); + str8_list_pushf(arena, out, "%f", expr->value.f32); }break; case E_ExprKind_TypeIdent: { @@ -910,7 +910,7 @@ e_type_from_expr(E_Expr *expr) { E_Expr *child_expr = expr->first; E_TypeKey direct_type_key = e_type_from_expr(child_expr); - result = e_type_key_cons_array(direct_type_key, expr->u64); + result = e_type_key_cons_array(direct_type_key, expr->value.u64); }break; } return result; @@ -1688,15 +1688,8 @@ e_parse_expr_from_text_tokens__prec(Arena *arena, String8 text, E_TokenArray *to { U64 val = 0; try_u64_from_str8_c_rules(token_string, &val); - if(str8_match(resolution_qualifier, str8_lit("id"), 0)) - { - atom = e_push_expr(arena, E_ExprKind_LeafID, token_string.str); - } - else - { - atom = e_push_expr(arena, E_ExprKind_LeafU64, token_string.str); - } - atom->u64 = val; + atom = e_push_expr(arena, E_ExprKind_LeafU64, token_string.str); + atom->value.u64 = val; break; } @@ -1710,14 +1703,14 @@ e_parse_expr_from_text_tokens__prec(Arena *arena, String8 text, E_TokenArray *to if(f_pos < token_string.size) { atom = e_push_expr(arena, E_ExprKind_LeafF32, token_string.str); - atom->f32 = (F32)val; + atom->value.f32 = (F32)val; } // rjf: no f => f64 else { atom = e_push_expr(arena, E_ExprKind_LeafF64, token_string.str); - atom->f64 = val; + atom->value.f64 = val; } } }break; @@ -1732,7 +1725,7 @@ e_parse_expr_from_text_tokens__prec(Arena *arena, String8 text, E_TokenArray *to String8 char_literal_raw = e_raw_from_escaped_string(scratch.arena, char_literal_escaped); U8 char_val = char_literal_raw.size > 0 ? char_literal_raw.str[0] : 0; atom = e_push_expr(arena, E_ExprKind_LeafU64, token_string.str); - atom->u64 = (U64)char_val; + atom->value.u64 = (U64)char_val; } else { diff --git a/src/eval/eval_parse.h b/src/eval/eval_parse.h index 91ff30c2..df8a8acb 100644 --- a/src/eval/eval_parse.h +++ b/src/eval/eval_parse.h @@ -59,10 +59,7 @@ struct E_Expr E_Mode mode; E_Space space; E_TypeKey type_key; - U32 u32; - F32 f32; - U64 u64; - F64 f64; + E_Value value; String8 string; String8 bytecode; }; diff --git a/src/eval/generated/eval.meta.c b/src/eval/generated/eval.meta.c index 75cf1e5b..d3a86ef8 100644 --- a/src/eval/generated/eval.meta.c +++ b/src/eval/generated/eval.meta.c @@ -53,7 +53,7 @@ str8_lit_comp("LeafU64"), str8_lit_comp("LeafF64"), str8_lit_comp("LeafF32"), str8_lit_comp("LeafIdent"), -str8_lit_comp("LeafID"), +str8_lit_comp("LeafOffset"), str8_lit_comp("LeafFilePath"), str8_lit_comp("TypeIdent"), str8_lit_comp("Ptr"), @@ -116,7 +116,7 @@ E_OpInfo e_expr_kind_op_info_table[44] = { E_OpKind_Null, 0, str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp("LeafF64") }, { E_OpKind_Null, 0, str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp("LeafF32") }, { E_OpKind_Null, 0, str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp("LeafIdent") }, -{ E_OpKind_Null, 0, str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp("LeafID") }, +{ E_OpKind_Null, 0, str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp("LeafOffset") }, { E_OpKind_Null, 0, str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp("LeafFilePath") }, { E_OpKind_Null, 0, str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp("TypeIdent") }, { E_OpKind_Null, 0, str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp("Ptr") }, diff --git a/src/eval/generated/eval.meta.h b/src/eval/generated/eval.meta.h index 48dfcb2d..2b1a86f9 100644 --- a/src/eval/generated/eval.meta.h +++ b/src/eval/generated/eval.meta.h @@ -127,7 +127,7 @@ E_ExprKind_LeafU64, E_ExprKind_LeafF64, E_ExprKind_LeafF32, E_ExprKind_LeafIdent, -E_ExprKind_LeafID, +E_ExprKind_LeafOffset, E_ExprKind_LeafFilePath, E_ExprKind_TypeIdent, E_ExprKind_Ptr,