mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-08-06 13:58:40 +00:00
bundle per-module info in eval system; use all modules in all processes in ctrl layer evaluations; further sketching out of space info
This commit is contained in:
+54
-58
@@ -691,6 +691,9 @@ ctrl_entity_alloc(CTRL_EntityStore *store, CTRL_Entity *parent, CTRL_EntityKind
|
|||||||
node->entity = entity;
|
node->entity = entity;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// rjf: bump counter
|
||||||
|
store->entity_kind_counts[kind] += 1;
|
||||||
}
|
}
|
||||||
return entity;
|
return entity;
|
||||||
}
|
}
|
||||||
@@ -745,6 +748,9 @@ ctrl_entity_release(CTRL_EntityStore *store, CTRL_Entity *entity)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// rjf: dec counter
|
||||||
|
store->entity_kind_counts[t->e->kind] -= 1;
|
||||||
}
|
}
|
||||||
scratch_end(scratch);
|
scratch_end(scratch);
|
||||||
}
|
}
|
||||||
@@ -4630,56 +4636,48 @@ ctrl_thread__run(DMN_CtrlCtx *ctrl_ctx, CTRL_Msg *msg)
|
|||||||
if(conditions.node_count != 0) ProfScope("evaluate hit stop conditions")
|
if(conditions.node_count != 0) ProfScope("evaluate hit stop conditions")
|
||||||
{
|
{
|
||||||
DI_Scope *di_scope = di_scope_open();
|
DI_Scope *di_scope = di_scope_open();
|
||||||
|
|
||||||
|
// rjf: gather evaluation modules
|
||||||
|
U64 eval_modules_count = Max(1, ctrl_state->ctrl_thread_entity_store->entity_kind_counts[CTRL_EntityKind_Module]);
|
||||||
|
E_Module *eval_modules = push_array(temp.arena, E_Module, eval_modules_count);
|
||||||
|
E_Module *eval_modules_primary = &eval_modules[0];
|
||||||
|
eval_modules_primary->rdi = &di_rdi_parsed_nil;
|
||||||
|
eval_modules_primary->vaddr_range = r1u64(0, max_U64);
|
||||||
|
{
|
||||||
|
U64 eval_module_idx = 0;
|
||||||
|
for(CTRL_Entity *machine = ctrl_state->ctrl_thread_entity_store->root->first;
|
||||||
|
machine != &ctrl_entity_nil;
|
||||||
|
machine = machine->next)
|
||||||
|
{
|
||||||
|
if(machine->kind != CTRL_EntityKind_Machine) { continue; }
|
||||||
|
for(CTRL_Entity *process = machine->first;
|
||||||
|
process != &ctrl_entity_nil;
|
||||||
|
process = process->next)
|
||||||
|
{
|
||||||
|
if(process->kind != CTRL_EntityKind_Process) { continue; }
|
||||||
|
for(CTRL_Entity *module = process->first;
|
||||||
|
module != &ctrl_entity_nil;
|
||||||
|
module = module->next)
|
||||||
|
{
|
||||||
|
if(module->kind != CTRL_EntityKind_Module) { continue; }
|
||||||
|
CTRL_Entity *dbg_path = ctrl_entity_child_from_kind(module, CTRL_EntityKind_DebugInfoPath);
|
||||||
|
DI_Key dbgi_key = {dbg_path->string, dbg_path->timestamp};
|
||||||
|
eval_modules[eval_module_idx].rdi = di_rdi_from_key(di_scope, &dbgi_key, max_U64);
|
||||||
|
eval_modules[eval_module_idx].vaddr_range = module->vaddr_range;
|
||||||
|
eval_modules[eval_module_idx].space = (U64)process;
|
||||||
|
if(contains_1u64(module->vaddr_range, thread_rip_vaddr))
|
||||||
|
{
|
||||||
|
eval_modules_primary = &eval_modules[eval_module_idx];
|
||||||
|
}
|
||||||
|
eval_module_idx += 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// rjf: loop through all conditions, check all
|
||||||
for(String8Node *condition_n = conditions.first; condition_n != 0; condition_n = condition_n->next)
|
for(String8Node *condition_n = conditions.first; condition_n != 0; condition_n = condition_n->next)
|
||||||
{
|
{
|
||||||
// rjf: count all modules
|
|
||||||
U64 all_modules_count = 0;
|
|
||||||
for(CTRL_Entity *child = process->first; child != &ctrl_entity_nil; child = child->next)
|
|
||||||
{
|
|
||||||
if(child->kind == CTRL_EntityKind_Module)
|
|
||||||
{
|
|
||||||
all_modules_count += 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// rjf: gather debug infos
|
|
||||||
U64 rdis_count = Max(1, all_modules_count);
|
|
||||||
RDI_Parsed **rdis = push_array(temp.arena, RDI_Parsed *, rdis_count);
|
|
||||||
rdis[0] = &di_rdi_parsed_nil;
|
|
||||||
Rng1U64 *rdis_vaddr_ranges = push_array(temp.arena, Rng1U64, rdis_count);
|
|
||||||
U64 rdis_primary_idx = 0;
|
|
||||||
ProfScope("gather debug infos")
|
|
||||||
{
|
|
||||||
U64 primary_idx = 0;
|
|
||||||
U64 idx = 0;
|
|
||||||
for(CTRL_Entity *m = process->first;
|
|
||||||
m != &ctrl_entity_nil && idx < all_modules_count;
|
|
||||||
m = m->next)
|
|
||||||
{
|
|
||||||
if(m->kind != CTRL_EntityKind_Module)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// rjf: unpack
|
|
||||||
CTRL_Entity *dbg_path = ctrl_entity_child_from_kind(m, CTRL_EntityKind_DebugInfoPath);
|
|
||||||
DI_Key dbgi_key = {dbg_path->string, dbg_path->timestamp};
|
|
||||||
|
|
||||||
// rjf: fill
|
|
||||||
rdis[idx] = di_rdi_from_key(di_scope, &dbgi_key, max_U64);
|
|
||||||
rdis_vaddr_ranges[idx] = m->vaddr_range;
|
|
||||||
|
|
||||||
// rjf: pick primary module
|
|
||||||
if(m == module)
|
|
||||||
{
|
|
||||||
rdis_primary_idx = idx;
|
|
||||||
}
|
|
||||||
|
|
||||||
// rjf: inc
|
|
||||||
idx += 1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// rjf: build eval type context
|
// rjf: build eval type context
|
||||||
E_TypeCtx type_ctx = zero_struct;
|
E_TypeCtx type_ctx = zero_struct;
|
||||||
{
|
{
|
||||||
@@ -4687,10 +4685,9 @@ ctrl_thread__run(DMN_CtrlCtx *ctrl_ctx, CTRL_Msg *msg)
|
|||||||
ctx->arch = arch;
|
ctx->arch = arch;
|
||||||
ctx->ip_vaddr = thread_rip_vaddr;
|
ctx->ip_vaddr = thread_rip_vaddr;
|
||||||
ctx->ip_voff = thread_rip_voff;
|
ctx->ip_voff = thread_rip_voff;
|
||||||
ctx->rdis_count = rdis_count;
|
ctx->modules = eval_modules;
|
||||||
ctx->rdis_primary_idx = rdis_primary_idx;
|
ctx->modules_count = eval_modules_count;
|
||||||
ctx->rdis = rdis;
|
ctx->primary_module = eval_modules_primary;
|
||||||
ctx->rdis_vaddr_ranges = rdis_vaddr_ranges;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// rjf: build eval parse context
|
// rjf: build eval parse context
|
||||||
@@ -4701,14 +4698,13 @@ ctrl_thread__run(DMN_CtrlCtx *ctrl_ctx, CTRL_Msg *msg)
|
|||||||
ctx->arch = arch;
|
ctx->arch = arch;
|
||||||
ctx->ip_vaddr = thread_rip_vaddr;
|
ctx->ip_vaddr = thread_rip_vaddr;
|
||||||
ctx->ip_voff = thread_rip_voff;
|
ctx->ip_voff = thread_rip_voff;
|
||||||
ctx->rdis_count = rdis_count;
|
ctx->modules = eval_modules;
|
||||||
ctx->rdis_primary_idx = rdis_primary_idx;
|
ctx->modules_count = eval_modules_count;
|
||||||
ctx->rdis = rdis;
|
ctx->primary_module = eval_modules_primary;
|
||||||
ctx->rdis_vaddr_ranges = rdis_vaddr_ranges;
|
|
||||||
ctx->regs_map = ctrl_string2reg_from_arch(ctx->arch);
|
ctx->regs_map = ctrl_string2reg_from_arch(ctx->arch);
|
||||||
ctx->reg_alias_map = ctrl_string2alias_from_arch(ctx->arch);
|
ctx->reg_alias_map = ctrl_string2alias_from_arch(ctx->arch);
|
||||||
ctx->locals_map = e_push_locals_map_from_rdi_voff(temp.arena, ctx->rdis[ctx->rdis_primary_idx], thread_rip_voff);
|
ctx->locals_map = e_push_locals_map_from_rdi_voff(temp.arena, eval_modules_primary->rdi, thread_rip_voff);
|
||||||
ctx->member_map = e_push_member_map_from_rdi_voff(temp.arena, ctx->rdis[ctx->rdis_primary_idx], thread_rip_voff);
|
ctx->member_map = e_push_member_map_from_rdi_voff(temp.arena, eval_modules_primary->rdi, thread_rip_voff);
|
||||||
}
|
}
|
||||||
|
|
||||||
// rjf: build eval IR context
|
// rjf: build eval IR context
|
||||||
|
|||||||
@@ -104,6 +104,7 @@ struct CTRL_EntityStore
|
|||||||
CTRL_EntityHashNode *hash_node_free;
|
CTRL_EntityHashNode *hash_node_free;
|
||||||
U64 hash_slots_count;
|
U64 hash_slots_count;
|
||||||
CTRL_EntityStringChunkNode *free_string_chunks[8];
|
CTRL_EntityStringChunkNode *free_string_chunks[8];
|
||||||
|
U64 entity_kind_counts[CTRL_EntityKind_COUNT];
|
||||||
};
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
|
|||||||
+28
-10
@@ -8176,15 +8176,35 @@ df_core_begin_frame(Arena *arena, DF_CmdList *cmds, F32 dt)
|
|||||||
U64 rip_vaddr = df_query_cached_rip_from_thread_unwind(thread, unwind_count);
|
U64 rip_vaddr = df_query_cached_rip_from_thread_unwind(thread, unwind_count);
|
||||||
CTRL_Unwind unwind = df_query_cached_unwind_from_thread(thread);
|
CTRL_Unwind unwind = df_query_cached_unwind_from_thread(thread);
|
||||||
DF_Entity *module = df_module_from_process_vaddr(process, rip_vaddr);
|
DF_Entity *module = df_module_from_process_vaddr(process, rip_vaddr);
|
||||||
DF_EntityList all_modules = df_query_cached_entity_list_with_kind(DF_EntityKind_Module);
|
|
||||||
U64 rip_voff = df_voff_from_vaddr(module, rip_vaddr);
|
U64 rip_voff = df_voff_from_vaddr(module, rip_vaddr);
|
||||||
U64 tls_root_vaddr = ctrl_query_cached_tls_root_vaddr_from_thread(df_state->ctrl_entity_store, thread->ctrl_machine_id, thread->ctrl_handle);
|
U64 tls_root_vaddr = ctrl_query_cached_tls_root_vaddr_from_thread(df_state->ctrl_entity_store, thread->ctrl_machine_id, thread->ctrl_handle);
|
||||||
|
DF_EntityList all_modules = df_query_cached_entity_list_with_kind(DF_EntityKind_Module);
|
||||||
|
U64 eval_modules_count = Max(1, all_modules.count);
|
||||||
|
E_Module *eval_modules = push_array(arena, E_Module, eval_modules_count);
|
||||||
|
E_Module *eval_modules_primary = &eval_modules[0];
|
||||||
|
eval_modules_primary->rdi = &di_rdi_parsed_nil;
|
||||||
|
eval_modules_primary->vaddr_range = r1u64(0, max_U64);
|
||||||
|
DI_Key primary_dbgi_key = {0};
|
||||||
|
{
|
||||||
|
U64 eval_module_idx = 0;
|
||||||
|
for(DF_EntityNode *n = all_modules.first; n != 0; n = n->next, eval_module_idx += 1)
|
||||||
|
{
|
||||||
|
DF_Entity *module = n->entity;
|
||||||
|
DI_Key dbgi_key = df_dbgi_key_from_module(module);
|
||||||
|
eval_modules[eval_module_idx].rdi = di_rdi_from_key(df_state->frame_di_scope, &dbgi_key, 0);
|
||||||
|
eval_modules[eval_module_idx].vaddr_range = module->vaddr_rng;
|
||||||
|
eval_modules[eval_module_idx].space = (U64)df_entity_ancestor_from_kind(module, DF_EntityKind_Process);
|
||||||
|
if(contains_1u64(module->vaddr_rng, rip_voff))
|
||||||
|
{
|
||||||
|
eval_modules_primary = &eval_modules[eval_module_idx];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
U64 rdis_count = Max(1, all_modules.count);
|
U64 rdis_count = Max(1, all_modules.count);
|
||||||
RDI_Parsed **rdis = push_array(arena, RDI_Parsed *, rdis_count);
|
RDI_Parsed **rdis = push_array(arena, RDI_Parsed *, rdis_count);
|
||||||
rdis[0] = &di_rdi_parsed_nil;
|
rdis[0] = &di_rdi_parsed_nil;
|
||||||
U64 rdis_primary_idx = 0;
|
U64 rdis_primary_idx = 0;
|
||||||
Rng1U64 *rdis_vaddr_ranges = push_array(arena, Rng1U64, rdis_count);
|
Rng1U64 *rdis_vaddr_ranges = push_array(arena, Rng1U64, rdis_count);
|
||||||
DI_Key primary_dbgi_key = {0};
|
|
||||||
{
|
{
|
||||||
U64 idx = 0;
|
U64 idx = 0;
|
||||||
for(DF_EntityNode *n = all_modules.first; n != 0; n = n->next, idx += 1)
|
for(DF_EntityNode *n = all_modules.first; n != 0; n = n->next, idx += 1)
|
||||||
@@ -8207,10 +8227,9 @@ df_core_begin_frame(Arena *arena, DF_CmdList *cmds, F32 dt)
|
|||||||
ctx->arch = arch;
|
ctx->arch = arch;
|
||||||
ctx->ip_vaddr = rip_vaddr;
|
ctx->ip_vaddr = rip_vaddr;
|
||||||
ctx->ip_voff = rip_voff;
|
ctx->ip_voff = rip_voff;
|
||||||
ctx->rdis_count = rdis_count;
|
ctx->modules = eval_modules;
|
||||||
ctx->rdis_primary_idx = rdis_primary_idx;
|
ctx->modules_count = eval_modules_count;
|
||||||
ctx->rdis = rdis;
|
ctx->primary_module = eval_modules_primary;
|
||||||
ctx->rdis_vaddr_ranges = rdis_vaddr_ranges;
|
|
||||||
}
|
}
|
||||||
e_select_type_ctx(type_ctx);
|
e_select_type_ctx(type_ctx);
|
||||||
|
|
||||||
@@ -8222,10 +8241,9 @@ df_core_begin_frame(Arena *arena, DF_CmdList *cmds, F32 dt)
|
|||||||
ctx->arch = arch;
|
ctx->arch = arch;
|
||||||
ctx->ip_vaddr = rip_vaddr;
|
ctx->ip_vaddr = rip_vaddr;
|
||||||
ctx->ip_voff = rip_voff;
|
ctx->ip_voff = rip_voff;
|
||||||
ctx->rdis_count = rdis_count;
|
ctx->modules = eval_modules;
|
||||||
ctx->rdis_primary_idx = rdis_primary_idx;
|
ctx->modules_count = eval_modules_count;
|
||||||
ctx->rdis = rdis;
|
ctx->primary_module = eval_modules_primary;
|
||||||
ctx->rdis_vaddr_ranges = rdis_vaddr_ranges;
|
|
||||||
ctx->regs_map = ctrl_string2reg_from_arch(ctx->arch);
|
ctx->regs_map = ctrl_string2reg_from_arch(ctx->arch);
|
||||||
ctx->reg_alias_map = ctrl_string2alias_from_arch(ctx->arch);
|
ctx->reg_alias_map = ctrl_string2alias_from_arch(ctx->arch);
|
||||||
ctx->locals_map = df_query_cached_locals_map_from_dbgi_key_voff(&primary_dbgi_key, rip_voff);
|
ctx->locals_map = df_query_cached_locals_map_from_dbgi_key_voff(&primary_dbgi_key, rip_voff);
|
||||||
|
|||||||
+3
-3
@@ -9033,13 +9033,13 @@ df_eval_viz_windowed_row_list_from_viz_block_list(Arena *arena, DI_Scope *scope,
|
|||||||
RDI_Parsed *rdi = &di_rdi_parsed_nil;
|
RDI_Parsed *rdi = &di_rdi_parsed_nil;
|
||||||
U64 base_idx = 0;
|
U64 base_idx = 0;
|
||||||
{
|
{
|
||||||
for(U64 rdi_idx = 0; rdi_idx < e_parse_ctx->rdis_count; rdi_idx += 1)
|
for(U64 module_idx = 0; module_idx < e_parse_ctx->modules_count; module_idx += 1)
|
||||||
{
|
{
|
||||||
U64 all_items_count = 0;
|
U64 all_items_count = 0;
|
||||||
rdi_section_raw_table_from_kind(e_parse_ctx->rdis[rdi_idx], block->fzy_target, &all_items_count);
|
rdi_section_raw_table_from_kind(e_parse_ctx->modules[module_idx].rdi, block->fzy_target, &all_items_count);
|
||||||
if(base_idx <= item->idx && item->idx < base_idx + all_items_count)
|
if(base_idx <= item->idx && item->idx < base_idx + all_items_count)
|
||||||
{
|
{
|
||||||
rdi = e_parse_ctx->rdis[rdi_idx];
|
rdi = e_parse_ctx->modules[module_idx].rdi;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
base_idx += all_items_count;
|
base_idx += all_items_count;
|
||||||
|
|||||||
@@ -4228,7 +4228,7 @@ DF_VIEW_UI_FUNCTION_DEF(SymbolLister)
|
|||||||
U8 *name_base = rdi_string_from_idx(rdi, procedure->name_string_idx, &name_size);
|
U8 *name_base = rdi_string_from_idx(rdi, procedure->name_string_idx, &name_size);
|
||||||
String8 name = str8(name_base, name_size);
|
String8 name = str8(name_base, name_size);
|
||||||
RDI_TypeNode *type_node = rdi_element_from_name_idx(rdi, TypeNodes, procedure->type_idx);
|
RDI_TypeNode *type_node = rdi_element_from_name_idx(rdi, TypeNodes, procedure->type_idx);
|
||||||
E_TypeKey type_key = e_type_key_ext(e_type_kind_from_rdi(type_node->kind), procedure->type_idx, e_parse_ctx_idx_from_rdi(rdi));
|
E_TypeKey type_key = e_type_key_ext(e_type_kind_from_rdi(type_node->kind), procedure->type_idx, e_parse_ctx_module_idx_from_rdi(rdi));
|
||||||
|
|
||||||
//- rjf: build item button
|
//- rjf: build item button
|
||||||
ui_set_next_hover_cursor(OS_Cursor_HandPoint);
|
ui_set_next_hover_cursor(OS_Cursor_HandPoint);
|
||||||
@@ -5821,13 +5821,13 @@ DF_VIEW_UI_FUNCTION_DEF(CallStack)
|
|||||||
{
|
{
|
||||||
symbol_name.str = rdi_name_from_procedure(row->rdi, row->procedure, &symbol_name.size);
|
symbol_name.str = rdi_name_from_procedure(row->rdi, row->procedure, &symbol_name.size);
|
||||||
RDI_TypeNode *type = rdi_element_from_name_idx(row->rdi, TypeNodes, row->procedure->type_idx);
|
RDI_TypeNode *type = rdi_element_from_name_idx(row->rdi, TypeNodes, row->procedure->type_idx);
|
||||||
symbol_type_string = e_type_string_from_key(scratch.arena, e_type_key_ext(e_type_kind_from_rdi(type->kind), row->procedure->type_idx, e_parse_ctx_idx_from_rdi(row->rdi)));
|
symbol_type_string = e_type_string_from_key(scratch.arena, e_type_key_ext(e_type_kind_from_rdi(type->kind), row->procedure->type_idx, e_parse_ctx_module_idx_from_rdi(row->rdi)));
|
||||||
}
|
}
|
||||||
if(row->inline_site != 0)
|
if(row->inline_site != 0)
|
||||||
{
|
{
|
||||||
symbol_name.str = rdi_string_from_idx(row->rdi, row->inline_site->name_string_idx, &symbol_name.size);
|
symbol_name.str = rdi_string_from_idx(row->rdi, row->inline_site->name_string_idx, &symbol_name.size);
|
||||||
RDI_TypeNode *type = rdi_element_from_name_idx(row->rdi, TypeNodes, row->inline_site->type_idx);
|
RDI_TypeNode *type = rdi_element_from_name_idx(row->rdi, TypeNodes, row->inline_site->type_idx);
|
||||||
symbol_type_string = e_type_string_from_key(scratch.arena, e_type_key_ext(e_type_kind_from_rdi(type->kind), row->inline_site->type_idx, e_parse_ctx_idx_from_rdi(row->rdi)));
|
symbol_type_string = e_type_string_from_key(scratch.arena, e_type_key_ext(e_type_kind_from_rdi(type->kind), row->inline_site->type_idx, e_parse_ctx_module_idx_from_rdi(row->rdi)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// rjf: build row
|
// rjf: build row
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ e_autoresolved_eval_from_eval(E_Eval eval)
|
|||||||
{
|
{
|
||||||
if(e_parse_ctx &&
|
if(e_parse_ctx &&
|
||||||
e_interpret_ctx &&
|
e_interpret_ctx &&
|
||||||
e_parse_ctx->rdis_count > 0 &&
|
e_parse_ctx->modules_count > 0 &&
|
||||||
e_interpret_ctx->module_base != 0 &&
|
e_interpret_ctx->module_base != 0 &&
|
||||||
(eval.mode == E_Mode_Value || eval.mode == E_Mode_Reg) &&
|
(eval.mode == E_Mode_Value || eval.mode == E_Mode_Reg) &&
|
||||||
(e_type_key_match(eval.type_key, e_type_key_basic(E_TypeKind_S64)) ||
|
(e_type_key_match(eval.type_key, e_type_key_basic(E_TypeKind_S64)) ||
|
||||||
@@ -45,7 +45,7 @@ e_autoresolved_eval_from_eval(E_Eval eval)
|
|||||||
{
|
{
|
||||||
U64 vaddr = eval.value.u64;
|
U64 vaddr = eval.value.u64;
|
||||||
U64 voff = vaddr - e_interpret_ctx->module_base[0];
|
U64 voff = vaddr - e_interpret_ctx->module_base[0];
|
||||||
RDI_Parsed *rdi = e_parse_ctx->rdis[e_parse_ctx->rdis_primary_idx];
|
RDI_Parsed *rdi = e_parse_ctx->primary_module->rdi;
|
||||||
RDI_Scope *scope = rdi_scope_from_voff(rdi, voff);
|
RDI_Scope *scope = rdi_scope_from_voff(rdi, voff);
|
||||||
RDI_Procedure *procedure = rdi_procedure_from_voff(rdi, voff);
|
RDI_Procedure *procedure = rdi_procedure_from_voff(rdi, voff);
|
||||||
RDI_GlobalVariable *gvar = rdi_global_variable_from_voff(rdi, voff);
|
RDI_GlobalVariable *gvar = rdi_global_variable_from_voff(rdi, voff);
|
||||||
@@ -98,13 +98,13 @@ e_dynamically_typed_eval_from_eval(E_Eval eval)
|
|||||||
U32 rdi_idx = 0;
|
U32 rdi_idx = 0;
|
||||||
RDI_Parsed *rdi = 0;
|
RDI_Parsed *rdi = 0;
|
||||||
U64 module_base = 0;
|
U64 module_base = 0;
|
||||||
for(U64 idx = 0; idx < e_type_state->ctx->rdis_count; idx += 1)
|
for(U64 idx = 0; idx < e_type_state->ctx->modules_count; idx += 1)
|
||||||
{
|
{
|
||||||
if(contains_1u64(e_type_state->ctx->rdis_vaddr_ranges[idx], vtable_vaddr))
|
if(contains_1u64(e_type_state->ctx->modules[idx].vaddr_range, vtable_vaddr))
|
||||||
{
|
{
|
||||||
rdi_idx = (U32)idx;
|
rdi_idx = (U32)idx;
|
||||||
rdi = e_type_state->ctx->rdis[idx];
|
rdi = e_type_state->ctx->modules[idx].rdi;
|
||||||
module_base = e_type_state->ctx->rdis_vaddr_ranges[idx].min;
|
module_base = e_type_state->ctx->modules[idx].vaddr_range.min;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,63 @@
|
|||||||
|
// Copyright (c) 2024 Epic Games Tools
|
||||||
|
// Licensed under the MIT license (https://opensource.org/license/mit/)
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
//~ rjf: Generated Code
|
||||||
|
|
||||||
|
#include "eval/generated/eval.meta.c"
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
//~ rjf: Basic Helper Functions
|
||||||
|
|
||||||
|
internal U64
|
||||||
|
e_hash_from_string(U64 seed, String8 string)
|
||||||
|
{
|
||||||
|
U64 result = seed;
|
||||||
|
for(U64 i = 0; i < string.size; i += 1)
|
||||||
|
{
|
||||||
|
result = ((result << 5) + result) + string.str[i];
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
//~ rjf: Message Functions
|
||||||
|
|
||||||
|
internal void
|
||||||
|
e_msg(Arena *arena, E_MsgList *msgs, E_MsgKind kind, void *location, String8 text)
|
||||||
|
{
|
||||||
|
E_Msg *msg = push_array(arena, E_Msg, 1);
|
||||||
|
SLLQueuePush(msgs->first, msgs->last, msg);
|
||||||
|
msgs->count += 1;
|
||||||
|
msgs->max_kind = Max(kind, msgs->max_kind);
|
||||||
|
msg->kind = kind;
|
||||||
|
msg->location = location;
|
||||||
|
msg->text = text;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void
|
||||||
|
e_msgf(Arena *arena, E_MsgList *msgs, E_MsgKind kind, void *location, char *fmt, ...)
|
||||||
|
{
|
||||||
|
va_list args;
|
||||||
|
va_start(args, fmt);
|
||||||
|
String8 text = push_str8fv(arena, fmt, args);
|
||||||
|
va_end(args);
|
||||||
|
e_msg(arena, msgs, kind, location, text);
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void
|
||||||
|
e_msg_list_concat_in_place(E_MsgList *dst, E_MsgList *to_push)
|
||||||
|
{
|
||||||
|
if(dst->last != 0 && to_push->first != 0)
|
||||||
|
{
|
||||||
|
dst->last->next = to_push->first;
|
||||||
|
dst->last = to_push->last;
|
||||||
|
dst->count += to_push->count;
|
||||||
|
dst->max_kind = Max(dst->max_kind, to_push->max_kind);
|
||||||
|
}
|
||||||
|
else if(to_push->first != 0)
|
||||||
|
{
|
||||||
|
MemoryCopyStruct(dst, to_push);
|
||||||
|
}
|
||||||
|
MemoryZeroStruct(to_push);
|
||||||
|
}
|
||||||
@@ -0,0 +1,94 @@
|
|||||||
|
// Copyright (c) 2024 Epic Games Tools
|
||||||
|
// Licensed under the MIT license (https://opensource.org/license/mit/)
|
||||||
|
|
||||||
|
#ifndef EVAL_CORE_H
|
||||||
|
#define EVAL_CORE_H
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
//~ rjf: Messages
|
||||||
|
|
||||||
|
typedef enum E_MsgKind
|
||||||
|
{
|
||||||
|
E_MsgKind_Null,
|
||||||
|
E_MsgKind_MalformedInput,
|
||||||
|
E_MsgKind_MissingInfo,
|
||||||
|
E_MsgKind_ResolutionFailure,
|
||||||
|
E_MsgKind_InterpretationError,
|
||||||
|
E_MsgKind_COUNT
|
||||||
|
}
|
||||||
|
E_MsgKind;
|
||||||
|
|
||||||
|
typedef struct E_Msg E_Msg;
|
||||||
|
struct E_Msg
|
||||||
|
{
|
||||||
|
E_Msg *next;
|
||||||
|
E_MsgKind kind;
|
||||||
|
void *location;
|
||||||
|
String8 text;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct E_MsgList E_MsgList;
|
||||||
|
struct E_MsgList
|
||||||
|
{
|
||||||
|
E_Msg *first;
|
||||||
|
E_Msg *last;
|
||||||
|
E_MsgKind max_kind;
|
||||||
|
U64 count;
|
||||||
|
};
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
//~ rjf: Evaluation Spaces
|
||||||
|
|
||||||
|
typedef U64 E_Space;
|
||||||
|
//
|
||||||
|
// NOTE(rjf): Evaluations occur within the context of a "space". Each "space"
|
||||||
|
// refers to a different offset or address space, but it's a bit looser of a
|
||||||
|
// concept than just address space, since it can also refer to offsets into
|
||||||
|
// a register block, only type information, or the "space" of all possibly
|
||||||
|
// values. It is also used to refer to spaces of unique IDs for key-value
|
||||||
|
// stores, e.g. for information in the debugger.
|
||||||
|
//
|
||||||
|
// Effectively, when considering the result of an evaluation, you use the
|
||||||
|
// value for understanding a key *into* a space, e.g. 1+2 -> 3, in the space
|
||||||
|
// of all values, or &foo, in the space of all addresses in PID: 1234.
|
||||||
|
//
|
||||||
|
// The values in the E_Space enum are reserved, but apart from those, any
|
||||||
|
// arbitrary value can be used, and then later interpreted.
|
||||||
|
//
|
||||||
|
enum
|
||||||
|
{
|
||||||
|
E_Space_Null,
|
||||||
|
E_Space_Types, // values are not used; evaluation only contain type content
|
||||||
|
E_Space_Values, // values do not refer to any space, but are standalone numeric values
|
||||||
|
E_Space_Regs, // values index into evaluator thread's register block
|
||||||
|
};
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
//~ rjf: Modules
|
||||||
|
|
||||||
|
typedef struct E_Module E_Module;
|
||||||
|
struct E_Module
|
||||||
|
{
|
||||||
|
RDI_Parsed *rdi;
|
||||||
|
Rng1U64 vaddr_range;
|
||||||
|
E_Space space;
|
||||||
|
};
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
//~ rjf: Generated Code
|
||||||
|
|
||||||
|
#include "eval/generated/eval.meta.h"
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
//~ rjf: Basic Helper Functions
|
||||||
|
|
||||||
|
internal U64 e_hash_from_string(U64 seed, String8 string);
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
//~ rjf: Message Functions
|
||||||
|
|
||||||
|
internal void e_msg(Arena *arena, E_MsgList *msgs, E_MsgKind kind, void *location, String8 text);
|
||||||
|
internal void e_msgf(Arena *arena, E_MsgList *msgs, E_MsgKind kind, void *location, char *fmt, ...);
|
||||||
|
internal void e_msg_list_concat_in_place(E_MsgList *dst, E_MsgList *to_push);
|
||||||
|
|
||||||
|
#endif // EVAL_CORE_H
|
||||||
+1
-1
@@ -1,7 +1,7 @@
|
|||||||
// Copyright (c) 2024 Epic Games Tools
|
// Copyright (c) 2024 Epic Games Tools
|
||||||
// Licensed under the MIT license (https://opensource.org/license/mit/)
|
// Licensed under the MIT license (https://opensource.org/license/mit/)
|
||||||
|
|
||||||
#include "eval/generated/eval.meta.c"
|
#include "eval/eval_core.c"
|
||||||
#include "eval/eval_types.c"
|
#include "eval/eval_types.c"
|
||||||
#include "eval/eval_parse.c"
|
#include "eval/eval_parse.c"
|
||||||
#include "eval/eval_ir.c"
|
#include "eval/eval_ir.c"
|
||||||
|
|||||||
+1
-1
@@ -4,7 +4,7 @@
|
|||||||
#ifndef EVAL_INC_H
|
#ifndef EVAL_INC_H
|
||||||
#define EVAL_INC_H
|
#define EVAL_INC_H
|
||||||
|
|
||||||
#include "eval/generated/eval.meta.h"
|
#include "eval/eval_core.h"
|
||||||
#include "eval/eval_types.h"
|
#include "eval/eval_types.h"
|
||||||
#include "eval/eval_parse.h"
|
#include "eval/eval_parse.h"
|
||||||
#include "eval/eval_ir.h"
|
#include "eval/eval_ir.h"
|
||||||
|
|||||||
+14
-14
@@ -251,6 +251,14 @@ e_irtree_string_literal(Arena *arena, String8 string)
|
|||||||
return root;
|
return root;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal E_IRNode *
|
||||||
|
e_irtree_set_space(Arena *arena, E_Space space)
|
||||||
|
{
|
||||||
|
E_IRNode *root = e_push_irnode(arena, E_IRExtKind_SetSpace);
|
||||||
|
root->u64 = space;
|
||||||
|
return root;
|
||||||
|
}
|
||||||
|
|
||||||
internal E_IRNode *
|
internal E_IRNode *
|
||||||
e_irtree_mem_read_type(Arena *arena, E_IRNode *c, E_TypeKey type_key)
|
e_irtree_mem_read_type(Arena *arena, E_IRNode *c, E_TypeKey type_key)
|
||||||
{
|
{
|
||||||
@@ -343,14 +351,14 @@ e_irtree_resolve_to_value(Arena *arena, E_Mode from_mode, E_IRNode *tree, E_Type
|
|||||||
switch(from_mode)
|
switch(from_mode)
|
||||||
{
|
{
|
||||||
default:{}break;
|
default:{}break;
|
||||||
case E_Mode_Addr:
|
|
||||||
{
|
|
||||||
result = e_irtree_mem_read_type(arena, tree, type_key);
|
|
||||||
}break;
|
|
||||||
case E_Mode_Reg:
|
case E_Mode_Reg:
|
||||||
{
|
{
|
||||||
result = e_irtree_unary_op(arena, RDI_EvalOp_RegReadDyn, RDI_EvalTypeGroup_U, tree);
|
result = e_irtree_unary_op(arena, RDI_EvalOp_RegReadDyn, RDI_EvalTypeGroup_U, tree);
|
||||||
}break;
|
}break;
|
||||||
|
case E_Mode_Addr:
|
||||||
|
{
|
||||||
|
result = e_irtree_mem_read_type(arena, tree, type_key);
|
||||||
|
}break;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@@ -364,9 +372,7 @@ e_irtree_and_type_from_expr(Arena *arena, E_Expr *expr)
|
|||||||
E_ExprKind kind = expr->kind;
|
E_ExprKind kind = expr->kind;
|
||||||
switch(kind)
|
switch(kind)
|
||||||
{
|
{
|
||||||
default:
|
default:{}break;
|
||||||
{
|
|
||||||
}break;
|
|
||||||
|
|
||||||
//- rjf: array indices
|
//- rjf: array indices
|
||||||
case E_ExprKind_ArrayIndex:
|
case E_ExprKind_ArrayIndex:
|
||||||
@@ -577,11 +583,6 @@ e_irtree_and_type_from_expr(Arena *arena, E_Expr *expr)
|
|||||||
e_msgf(arena, &result.msgs, E_MsgKind_MalformedInput, r_expr->location, "Cannot dereference arrays of zero-sized types.");
|
e_msgf(arena, &result.msgs, E_MsgKind_MalformedInput, r_expr->location, "Cannot dereference arrays of zero-sized types.");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
else if(r_type_kind == E_TypeKind_Array && r_tree.mode != E_Mode_Addr)
|
|
||||||
{
|
|
||||||
e_msgf(arena, &result.msgs, E_MsgKind_MalformedInput, r_expr->location, "Cannot dereference arrays without base address.");
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
else if(r_type_kind != E_TypeKind_Array &&
|
else if(r_type_kind != E_TypeKind_Array &&
|
||||||
r_type_kind != E_TypeKind_Ptr &&
|
r_type_kind != E_TypeKind_Ptr &&
|
||||||
r_type_kind != E_TypeKind_LRef &&
|
r_type_kind != E_TypeKind_LRef &&
|
||||||
@@ -1067,10 +1068,9 @@ e_irtree_and_type_from_expr(Arena *arena, E_Expr *expr)
|
|||||||
{
|
{
|
||||||
E_IRNode *new_tree = e_irtree_bytecode_no_copy(arena, expr->string);
|
E_IRNode *new_tree = e_irtree_bytecode_no_copy(arena, expr->string);
|
||||||
E_TypeKey final_type_key = expr->type_key;
|
E_TypeKey final_type_key = expr->type_key;
|
||||||
E_Mode mode = expr->mode;
|
|
||||||
result.root = new_tree;
|
result.root = new_tree;
|
||||||
result.type_key = final_type_key;
|
result.type_key = final_type_key;
|
||||||
result.mode = mode;
|
result.mode = expr->mode;
|
||||||
}break;
|
}break;
|
||||||
|
|
||||||
//- rjf: (unexpected) leaf member
|
//- rjf: (unexpected) leaf member
|
||||||
|
|||||||
@@ -10,6 +10,7 @@
|
|||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
E_IRExtKind_Bytecode = RDI_EvalOp_COUNT,
|
E_IRExtKind_Bytecode = RDI_EvalOp_COUNT,
|
||||||
|
E_IRExtKind_SetSpace,
|
||||||
E_IRExtKind_COUNT
|
E_IRExtKind_COUNT
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -51,6 +52,7 @@ struct E_IRTreeAndType
|
|||||||
E_IRNode *root;
|
E_IRNode *root;
|
||||||
E_TypeKey type_key;
|
E_TypeKey type_key;
|
||||||
E_Mode mode;
|
E_Mode mode;
|
||||||
|
// E_Space space;
|
||||||
E_MsgList msgs;
|
E_MsgList msgs;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -104,6 +106,7 @@ internal E_IRNode *e_irtree_binary_op_u(Arena *arena, RDI_EvalOp op, E_IRNode *l
|
|||||||
internal E_IRNode *e_irtree_conditional(Arena *arena, E_IRNode *c, E_IRNode *l, E_IRNode *r);
|
internal E_IRNode *e_irtree_conditional(Arena *arena, E_IRNode *c, E_IRNode *l, E_IRNode *r);
|
||||||
internal E_IRNode *e_irtree_bytecode_no_copy(Arena *arena, String8 bytecode);
|
internal E_IRNode *e_irtree_bytecode_no_copy(Arena *arena, String8 bytecode);
|
||||||
internal E_IRNode *e_irtree_string_literal(Arena *arena, String8 string);
|
internal E_IRNode *e_irtree_string_literal(Arena *arena, String8 string);
|
||||||
|
internal E_IRNode *e_irtree_set_space(Arena *arena, E_Space space);
|
||||||
internal E_IRNode *e_irtree_mem_read_type(Arena *arena, E_IRNode *c, E_TypeKey type_key);
|
internal E_IRNode *e_irtree_mem_read_type(Arena *arena, E_IRNode *c, E_TypeKey type_key);
|
||||||
internal E_IRNode *e_irtree_convert_lo(Arena *arena, E_IRNode *c, RDI_EvalTypeGroup out, RDI_EvalTypeGroup in);
|
internal E_IRNode *e_irtree_convert_lo(Arena *arena, E_IRNode *c, RDI_EvalTypeGroup out, RDI_EvalTypeGroup in);
|
||||||
internal E_IRNode *e_irtree_trunc(Arena *arena, E_IRNode *c, E_TypeKey type_key);
|
internal E_IRNode *e_irtree_trunc(Arena *arena, E_IRNode *c, E_TypeKey type_key);
|
||||||
|
|||||||
+57
-107
@@ -53,20 +53,6 @@ global read_only struct {E_ExprKind kind; String8 string; S64 precedence;} e_bin
|
|||||||
|
|
||||||
global read_only S64 e_max_precedence = 15;
|
global read_only S64 e_max_precedence = 15;
|
||||||
|
|
||||||
////////////////////////////////
|
|
||||||
//~ rjf: Basic Helper Functions
|
|
||||||
|
|
||||||
internal U64
|
|
||||||
e_hash_from_string(U64 seed, String8 string)
|
|
||||||
{
|
|
||||||
U64 result = seed;
|
|
||||||
for(U64 i = 0; i < string.size; i += 1)
|
|
||||||
{
|
|
||||||
result = ((result << 5) + result) + string.str[i];
|
|
||||||
}
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ rjf: Basic Map Functions
|
//~ rjf: Basic Map Functions
|
||||||
|
|
||||||
@@ -385,48 +371,6 @@ e_push_member_map_from_rdi_voff(Arena *arena, RDI_Parsed *rdi, U64 voff)
|
|||||||
return map;
|
return map;
|
||||||
}
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
|
||||||
//~ rjf: Message Functions
|
|
||||||
|
|
||||||
internal void
|
|
||||||
e_msg(Arena *arena, E_MsgList *msgs, E_MsgKind kind, void *location, String8 text)
|
|
||||||
{
|
|
||||||
E_Msg *msg = push_array(arena, E_Msg, 1);
|
|
||||||
SLLQueuePush(msgs->first, msgs->last, msg);
|
|
||||||
msgs->count += 1;
|
|
||||||
msgs->max_kind = Max(kind, msgs->max_kind);
|
|
||||||
msg->kind = kind;
|
|
||||||
msg->location = location;
|
|
||||||
msg->text = text;
|
|
||||||
}
|
|
||||||
|
|
||||||
internal void
|
|
||||||
e_msgf(Arena *arena, E_MsgList *msgs, E_MsgKind kind, void *location, char *fmt, ...)
|
|
||||||
{
|
|
||||||
va_list args;
|
|
||||||
va_start(args, fmt);
|
|
||||||
String8 text = push_str8fv(arena, fmt, args);
|
|
||||||
va_end(args);
|
|
||||||
e_msg(arena, msgs, kind, location, text);
|
|
||||||
}
|
|
||||||
|
|
||||||
internal void
|
|
||||||
e_msg_list_concat_in_place(E_MsgList *dst, E_MsgList *to_push)
|
|
||||||
{
|
|
||||||
if(dst->last != 0 && to_push->first != 0)
|
|
||||||
{
|
|
||||||
dst->last->next = to_push->first;
|
|
||||||
dst->last = to_push->last;
|
|
||||||
dst->count += to_push->count;
|
|
||||||
dst->max_kind = Max(dst->max_kind, to_push->max_kind);
|
|
||||||
}
|
|
||||||
else if(to_push->first != 0)
|
|
||||||
{
|
|
||||||
MemoryCopyStruct(dst, to_push);
|
|
||||||
}
|
|
||||||
MemoryZeroStruct(to_push);
|
|
||||||
}
|
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ rjf: Tokenization Functions
|
//~ rjf: Tokenization Functions
|
||||||
|
|
||||||
@@ -711,12 +655,12 @@ e_select_parse_ctx(E_ParseCtx *ctx)
|
|||||||
}
|
}
|
||||||
|
|
||||||
internal U32
|
internal U32
|
||||||
e_parse_ctx_idx_from_rdi(RDI_Parsed *rdi)
|
e_parse_ctx_module_idx_from_rdi(RDI_Parsed *rdi)
|
||||||
{
|
{
|
||||||
U32 result = 0;
|
U32 result = 0;
|
||||||
for(U64 idx = 0; idx < e_parse_ctx->rdis_count; idx += 1)
|
for(U64 idx = 0; idx < e_parse_ctx->modules_count; idx += 1)
|
||||||
{
|
{
|
||||||
if(e_parse_ctx->rdis[idx] == rdi)
|
if(e_parse_ctx->modules[idx].rdi == rdi)
|
||||||
{
|
{
|
||||||
result = (U32)idx;
|
result = (U32)idx;
|
||||||
break;
|
break;
|
||||||
@@ -752,9 +696,9 @@ e_leaf_type_from_name(String8 name)
|
|||||||
{
|
{
|
||||||
E_TypeKey key = zero_struct;
|
E_TypeKey key = zero_struct;
|
||||||
B32 found = 0;
|
B32 found = 0;
|
||||||
for(U64 rdi_idx = 0; rdi_idx < e_parse_ctx->rdis_count; rdi_idx += 1)
|
for(U64 module_idx = 0; module_idx < e_parse_ctx->modules_count; module_idx += 1)
|
||||||
{
|
{
|
||||||
RDI_Parsed *rdi = e_parse_ctx->rdis[rdi_idx];
|
RDI_Parsed *rdi = e_parse_ctx->modules[module_idx].rdi;
|
||||||
RDI_NameMap *name_map = rdi_element_from_name_idx(rdi, NameMaps, RDI_NameMapKind_Types);
|
RDI_NameMap *name_map = rdi_element_from_name_idx(rdi, NameMaps, RDI_NameMapKind_Types);
|
||||||
RDI_ParsedNameMap parsed_name_map = {0};
|
RDI_ParsedNameMap parsed_name_map = {0};
|
||||||
rdi_parsed_from_name_map(rdi, name_map, &parsed_name_map);
|
rdi_parsed_from_name_map(rdi, name_map, &parsed_name_map);
|
||||||
@@ -766,8 +710,8 @@ e_leaf_type_from_name(String8 name)
|
|||||||
if(match_count != 0)
|
if(match_count != 0)
|
||||||
{
|
{
|
||||||
RDI_TypeNode *type_node = rdi_element_from_name_idx(rdi, TypeNodes, matches[0]);
|
RDI_TypeNode *type_node = rdi_element_from_name_idx(rdi, TypeNodes, matches[0]);
|
||||||
found = type_node->kind != RDI_TypeKind_NULL;
|
found = (type_node->kind != RDI_TypeKind_NULL);
|
||||||
key = e_type_key_ext(e_type_kind_from_rdi(type_node->kind), matches[0], rdi_idx);
|
key = e_type_key_ext(e_type_kind_from_rdi(type_node->kind), matches[0], module_idx);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -956,7 +900,6 @@ e_parse_type_from_text_tokens(Arena *arena, String8 text, E_TokenArray *tokens)
|
|||||||
// rjf: construct leaf type
|
// rjf: construct leaf type
|
||||||
parse.expr = e_push_expr(arena, E_ExprKind_TypeIdent, token_string.str);
|
parse.expr = e_push_expr(arena, E_ExprKind_TypeIdent, token_string.str);
|
||||||
parse.expr->type_key = type_key;
|
parse.expr->type_key = type_key;
|
||||||
parse.expr->space = E_Space_Types;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1200,17 +1143,19 @@ e_parse_expr_from_text_tokens__prec(Arena *arena, String8 text, E_TokenArray *to
|
|||||||
REGS_AliasCode alias_code = 0;
|
REGS_AliasCode alias_code = 0;
|
||||||
E_TypeKey type_key = zero_struct;
|
E_TypeKey type_key = zero_struct;
|
||||||
String8 local_lookup_string = token_string;
|
String8 local_lookup_string = token_string;
|
||||||
E_Space space = 0;
|
E_Space space = E_Space_Null;
|
||||||
|
|
||||||
//- rjf: form namespaceified fallback versions of this lookup string
|
//- rjf: form namespaceified fallback versions of this lookup string
|
||||||
String8List namespaceified_token_strings = {0};
|
String8List namespaceified_token_strings = {0};
|
||||||
{
|
{
|
||||||
U64 scope_idx = rdi_vmap_idx_from_section_kind_voff(e_parse_ctx->rdis[e_parse_ctx->rdis_primary_idx], RDI_SectionKind_ScopeVMap, e_parse_ctx->ip_voff);
|
E_Module *module = e_parse_ctx->primary_module;
|
||||||
RDI_Scope *scope = rdi_element_from_name_idx(e_parse_ctx->rdis[e_parse_ctx->rdis_primary_idx], Scopes, scope_idx);
|
RDI_Parsed *rdi = module->rdi;
|
||||||
|
U64 scope_idx = rdi_vmap_idx_from_section_kind_voff(rdi, RDI_SectionKind_ScopeVMap, e_parse_ctx->ip_voff);
|
||||||
|
RDI_Scope *scope = rdi_element_from_name_idx(rdi, Scopes, scope_idx);
|
||||||
U64 proc_idx = scope->proc_idx;
|
U64 proc_idx = scope->proc_idx;
|
||||||
RDI_Procedure *procedure = rdi_element_from_name_idx(e_parse_ctx->rdis[e_parse_ctx->rdis_primary_idx], Procedures, proc_idx);
|
RDI_Procedure *procedure = rdi_element_from_name_idx(rdi, Procedures, proc_idx);
|
||||||
U64 name_size = 0;
|
U64 name_size = 0;
|
||||||
U8 *name_ptr = rdi_string_from_idx(e_parse_ctx->rdis[e_parse_ctx->rdis_primary_idx], procedure->name_string_idx, &name_size);
|
U8 *name_ptr = rdi_string_from_idx(rdi, procedure->name_string_idx, &name_size);
|
||||||
String8 containing_procedure_name = str8(name_ptr, name_size);
|
String8 containing_procedure_name = str8(name_ptr, name_size);
|
||||||
U64 last_past_scope_resolution_pos = 0;
|
U64 last_past_scope_resolution_pos = 0;
|
||||||
for(;;)
|
for(;;)
|
||||||
@@ -1243,32 +1188,34 @@ e_parse_expr_from_text_tokens__prec(Arena *arena, String8 text, E_TokenArray *to
|
|||||||
//- rjf: try locals
|
//- rjf: try locals
|
||||||
if(mapped_identifier == 0)
|
if(mapped_identifier == 0)
|
||||||
{
|
{
|
||||||
|
E_Module *module = e_parse_ctx->primary_module;
|
||||||
|
RDI_Parsed *rdi = module->rdi;
|
||||||
U64 local_num = e_num_from_string(e_parse_ctx->locals_map, local_lookup_string);
|
U64 local_num = e_num_from_string(e_parse_ctx->locals_map, local_lookup_string);
|
||||||
if(local_num != 0)
|
if(local_num != 0)
|
||||||
{
|
{
|
||||||
identifier_type_is_possibly_dynamically_overridden = 1;
|
identifier_type_is_possibly_dynamically_overridden = 1;
|
||||||
RDI_Local *local_var = rdi_element_from_name_idx(e_parse_ctx->rdis[e_parse_ctx->rdis_primary_idx], Locals, local_num-1);
|
RDI_Local *local_var = rdi_element_from_name_idx(rdi, Locals, local_num-1);
|
||||||
RDI_TypeNode *type_node = rdi_element_from_name_idx(e_parse_ctx->rdis[e_parse_ctx->rdis_primary_idx], TypeNodes, local_var->type_idx);
|
RDI_TypeNode *type_node = rdi_element_from_name_idx(rdi, TypeNodes, local_var->type_idx);
|
||||||
type_key = e_type_key_ext(e_type_kind_from_rdi(type_node->kind), local_var->type_idx, (U32)e_parse_ctx->rdis_primary_idx);
|
type_key = e_type_key_ext(e_type_kind_from_rdi(type_node->kind), local_var->type_idx, (U32)(module - e_parse_ctx->modules));
|
||||||
|
|
||||||
// rjf: grab location info
|
// rjf: grab location info
|
||||||
for(U32 loc_block_idx = local_var->location_first;
|
for(U32 loc_block_idx = local_var->location_first;
|
||||||
loc_block_idx < local_var->location_opl;
|
loc_block_idx < local_var->location_opl;
|
||||||
loc_block_idx += 1)
|
loc_block_idx += 1)
|
||||||
{
|
{
|
||||||
RDI_LocationBlock *block = rdi_element_from_name_idx(e_parse_ctx->rdis[e_parse_ctx->rdis_primary_idx], LocationBlocks, loc_block_idx);
|
RDI_LocationBlock *block = rdi_element_from_name_idx(rdi, LocationBlocks, loc_block_idx);
|
||||||
if(block->scope_off_first <= e_parse_ctx->ip_voff && e_parse_ctx->ip_voff < block->scope_off_opl)
|
if(block->scope_off_first <= e_parse_ctx->ip_voff && e_parse_ctx->ip_voff < block->scope_off_opl)
|
||||||
{
|
{
|
||||||
mapped_identifier = 1;
|
mapped_identifier = 1;
|
||||||
// space = e_parse_ctx->rdis_spaces[e_parse_ctx->rdis_primary_idx];
|
|
||||||
U64 all_location_data_size = 0;
|
U64 all_location_data_size = 0;
|
||||||
U8 *all_location_data = rdi_table_from_name(e_parse_ctx->rdis[e_parse_ctx->rdis_primary_idx], LocationData, &all_location_data_size);
|
U8 *all_location_data = rdi_table_from_name(rdi, LocationData, &all_location_data_size);
|
||||||
loc_kind = *((RDI_LocationKind *)(all_location_data + block->location_data_off));
|
loc_kind = *((RDI_LocationKind *)(all_location_data + block->location_data_off));
|
||||||
switch(loc_kind)
|
switch(loc_kind)
|
||||||
{
|
{
|
||||||
default:{mapped_identifier = 0;}break;
|
default:{mapped_identifier = 0;}break;
|
||||||
case RDI_LocationKind_AddrBytecodeStream:
|
case RDI_LocationKind_ValBytecodeStream: space = E_Space_Values; goto bytecode_stream;
|
||||||
case RDI_LocationKind_ValBytecodeStream:
|
case RDI_LocationKind_AddrBytecodeStream: space = module->space; goto bytecode_stream;
|
||||||
|
bytecode_stream:;
|
||||||
{
|
{
|
||||||
U8 *bytecode_base = all_location_data + block->location_data_off + sizeof(RDI_LocationKind);
|
U8 *bytecode_base = all_location_data + block->location_data_off + sizeof(RDI_LocationKind);
|
||||||
U64 bytecode_size = 0;
|
U64 bytecode_size = 0;
|
||||||
@@ -1288,10 +1235,12 @@ e_parse_expr_from_text_tokens__prec(Arena *arena, String8 text, E_TokenArray *to
|
|||||||
case RDI_LocationKind_AddrRegPlusU16:
|
case RDI_LocationKind_AddrRegPlusU16:
|
||||||
case RDI_LocationKind_AddrAddrRegPlusU16:
|
case RDI_LocationKind_AddrAddrRegPlusU16:
|
||||||
{
|
{
|
||||||
|
space = module->space;
|
||||||
MemoryCopy(&loc_reg_u16, (all_location_data + block->location_data_off), sizeof(loc_reg_u16));
|
MemoryCopy(&loc_reg_u16, (all_location_data + block->location_data_off), sizeof(loc_reg_u16));
|
||||||
}break;
|
}break;
|
||||||
case RDI_LocationKind_ValReg:
|
case RDI_LocationKind_ValReg:
|
||||||
{
|
{
|
||||||
|
space = E_Space_Values;
|
||||||
MemoryCopy(&loc_reg, (all_location_data + block->location_data_off), sizeof(loc_reg));
|
MemoryCopy(&loc_reg, (all_location_data + block->location_data_off), sizeof(loc_reg));
|
||||||
}break;
|
}break;
|
||||||
}
|
}
|
||||||
@@ -1307,9 +1256,9 @@ e_parse_expr_from_text_tokens__prec(Arena *arena, String8 text, E_TokenArray *to
|
|||||||
if(reg_num != 0)
|
if(reg_num != 0)
|
||||||
{
|
{
|
||||||
reg_code = reg_num;
|
reg_code = reg_num;
|
||||||
|
type_key = e_type_key_reg(e_parse_ctx->arch, reg_code);
|
||||||
mapped_identifier = 1;
|
mapped_identifier = 1;
|
||||||
space = E_Space_Regs;
|
space = E_Space_Regs;
|
||||||
type_key = e_type_key_reg(e_parse_ctx->arch, reg_code);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1329,9 +1278,10 @@ e_parse_expr_from_text_tokens__prec(Arena *arena, String8 text, E_TokenArray *to
|
|||||||
//- rjf: try global variables
|
//- rjf: try global variables
|
||||||
if(mapped_identifier == 0)
|
if(mapped_identifier == 0)
|
||||||
{
|
{
|
||||||
for(U64 rdi_idx = 0; rdi_idx < e_parse_ctx->rdis_count; rdi_idx += 1)
|
for(U64 module_idx = 0; module_idx < e_parse_ctx->modules_count; module_idx += 1)
|
||||||
{
|
{
|
||||||
RDI_Parsed *rdi = e_parse_ctx->rdis[rdi_idx];
|
E_Module *module = &e_parse_ctx->modules[module_idx];
|
||||||
|
RDI_Parsed *rdi = module->rdi;
|
||||||
RDI_NameMap *name_map = rdi_element_from_name_idx(rdi, NameMaps, RDI_NameMapKind_GlobalVariables);
|
RDI_NameMap *name_map = rdi_element_from_name_idx(rdi, NameMaps, RDI_NameMapKind_GlobalVariables);
|
||||||
RDI_ParsedNameMap parsed_name_map = {0};
|
RDI_ParsedNameMap parsed_name_map = {0};
|
||||||
rdi_parsed_from_name_map(rdi, name_map, &parsed_name_map);
|
rdi_parsed_from_name_map(rdi, name_map, &parsed_name_map);
|
||||||
@@ -1360,8 +1310,9 @@ e_parse_expr_from_text_tokens__prec(Arena *arena, String8 text, E_TokenArray *to
|
|||||||
loc_bytecode = e_bytecode_from_oplist(arena, &oplist);
|
loc_bytecode = e_bytecode_from_oplist(arena, &oplist);
|
||||||
U32 type_idx = global_var->type_idx;
|
U32 type_idx = global_var->type_idx;
|
||||||
RDI_TypeNode *type_node = rdi_element_from_name_idx(rdi, TypeNodes, type_idx);
|
RDI_TypeNode *type_node = rdi_element_from_name_idx(rdi, TypeNodes, type_idx);
|
||||||
type_key = e_type_key_ext(e_type_kind_from_rdi(type_node->kind), type_idx, (U32)rdi_idx);
|
type_key = e_type_key_ext(e_type_kind_from_rdi(type_node->kind), type_idx, (U32)module_idx);
|
||||||
mapped_identifier = 1;
|
mapped_identifier = 1;
|
||||||
|
space = module->space;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1370,9 +1321,10 @@ e_parse_expr_from_text_tokens__prec(Arena *arena, String8 text, E_TokenArray *to
|
|||||||
//- rjf: try thread variables
|
//- rjf: try thread variables
|
||||||
if(mapped_identifier == 0)
|
if(mapped_identifier == 0)
|
||||||
{
|
{
|
||||||
for(U64 rdi_idx = 0; rdi_idx < e_parse_ctx->rdis_count; rdi_idx += 1)
|
for(U64 module_idx = 0; module_idx < e_parse_ctx->modules_count; module_idx += 1)
|
||||||
{
|
{
|
||||||
RDI_Parsed *rdi = e_parse_ctx->rdis[rdi_idx];
|
E_Module *module = &e_parse_ctx->modules[module_idx];
|
||||||
|
RDI_Parsed *rdi = module->rdi;
|
||||||
RDI_NameMap *name_map = rdi_element_from_name_idx(rdi, NameMaps, RDI_NameMapKind_ThreadVariables);
|
RDI_NameMap *name_map = rdi_element_from_name_idx(rdi, NameMaps, RDI_NameMapKind_ThreadVariables);
|
||||||
RDI_ParsedNameMap parsed_name_map = {0};
|
RDI_ParsedNameMap parsed_name_map = {0};
|
||||||
rdi_parsed_from_name_map(rdi, name_map, &parsed_name_map);
|
rdi_parsed_from_name_map(rdi, name_map, &parsed_name_map);
|
||||||
@@ -1397,8 +1349,9 @@ e_parse_expr_from_text_tokens__prec(Arena *arena, String8 text, E_TokenArray *to
|
|||||||
loc_bytecode = e_bytecode_from_oplist(arena, &oplist);
|
loc_bytecode = e_bytecode_from_oplist(arena, &oplist);
|
||||||
U32 type_idx = thread_var->type_idx;
|
U32 type_idx = thread_var->type_idx;
|
||||||
RDI_TypeNode *type_node = rdi_element_from_name_idx(rdi, TypeNodes, type_idx);
|
RDI_TypeNode *type_node = rdi_element_from_name_idx(rdi, TypeNodes, type_idx);
|
||||||
type_key = e_type_key_ext(e_type_kind_from_rdi(type_node->kind), type_idx, (U32)rdi_idx);
|
type_key = e_type_key_ext(e_type_kind_from_rdi(type_node->kind), type_idx, (U32)module_idx);
|
||||||
mapped_identifier = 1;
|
mapped_identifier = 1;
|
||||||
|
space = module->space;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1407,9 +1360,10 @@ e_parse_expr_from_text_tokens__prec(Arena *arena, String8 text, E_TokenArray *to
|
|||||||
//- rjf: try procedures
|
//- rjf: try procedures
|
||||||
if(mapped_identifier == 0)
|
if(mapped_identifier == 0)
|
||||||
{
|
{
|
||||||
for(U64 rdi_idx = 0; rdi_idx < e_parse_ctx->rdis_count; rdi_idx += 1)
|
for(U64 module_idx = 0; module_idx < e_parse_ctx->modules_count; module_idx += 1)
|
||||||
{
|
{
|
||||||
RDI_Parsed *rdi = e_parse_ctx->rdis[rdi_idx];
|
E_Module *module = &e_parse_ctx->modules[module_idx];
|
||||||
|
RDI_Parsed *rdi = module->rdi;
|
||||||
RDI_NameMap *name_map = rdi_element_from_name_idx(rdi, NameMaps, RDI_NameMapKind_Procedures);
|
RDI_NameMap *name_map = rdi_element_from_name_idx(rdi, NameMaps, RDI_NameMapKind_Procedures);
|
||||||
RDI_ParsedNameMap parsed_name_map = {0};
|
RDI_ParsedNameMap parsed_name_map = {0};
|
||||||
rdi_parsed_from_name_map(rdi, name_map, &parsed_name_map);
|
rdi_parsed_from_name_map(rdi, name_map, &parsed_name_map);
|
||||||
@@ -1436,8 +1390,9 @@ e_parse_expr_from_text_tokens__prec(Arena *arena, String8 text, E_TokenArray *to
|
|||||||
loc_bytecode = e_bytecode_from_oplist(arena, &oplist);
|
loc_bytecode = e_bytecode_from_oplist(arena, &oplist);
|
||||||
U32 type_idx = procedure->type_idx;
|
U32 type_idx = procedure->type_idx;
|
||||||
RDI_TypeNode *type_node = rdi_element_from_name_idx(rdi, TypeNodes, type_idx);
|
RDI_TypeNode *type_node = rdi_element_from_name_idx(rdi, TypeNodes, type_idx);
|
||||||
type_key = e_type_key_ext(e_type_kind_from_rdi(type_node->kind), type_idx, (U32)rdi_idx);
|
type_key = e_type_key_ext(e_type_kind_from_rdi(type_node->kind), type_idx, (U32)module_idx);
|
||||||
mapped_identifier = 1;
|
mapped_identifier = 1;
|
||||||
|
space = E_Space_Values;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1451,6 +1406,7 @@ e_parse_expr_from_text_tokens__prec(Arena *arena, String8 text, E_TokenArray *to
|
|||||||
{
|
{
|
||||||
mapped_identifier = 1;
|
mapped_identifier = 1;
|
||||||
identifier_looks_like_type_expr = 1;
|
identifier_looks_like_type_expr = 1;
|
||||||
|
space = E_Space_Types;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1479,10 +1435,9 @@ e_parse_expr_from_text_tokens__prec(Arena *arena, String8 text, E_TokenArray *to
|
|||||||
E_OpList oplist = {0};
|
E_OpList oplist = {0};
|
||||||
e_oplist_push_uconst(arena, &oplist, reg_rng.byte_off);
|
e_oplist_push_uconst(arena, &oplist, reg_rng.byte_off);
|
||||||
atom = e_push_expr(arena, E_ExprKind_LeafBytecode, token_string.str);
|
atom = e_push_expr(arena, E_ExprKind_LeafBytecode, token_string.str);
|
||||||
atom->mode = E_Mode_Reg;
|
atom->mode = E_Mode_Reg;
|
||||||
atom->space = space;
|
|
||||||
atom->type_key = type_key;
|
atom->type_key = type_key;
|
||||||
atom->string = e_bytecode_from_oplist(arena, &oplist);
|
atom->string = e_bytecode_from_oplist(arena, &oplist);
|
||||||
}
|
}
|
||||||
else if(alias_code != 0)
|
else if(alias_code != 0)
|
||||||
{
|
{
|
||||||
@@ -1491,10 +1446,9 @@ e_parse_expr_from_text_tokens__prec(Arena *arena, String8 text, E_TokenArray *to
|
|||||||
E_OpList oplist = {0};
|
E_OpList oplist = {0};
|
||||||
e_oplist_push_uconst(arena, &oplist, alias_reg_rng.byte_off + alias_slice.byte_off);
|
e_oplist_push_uconst(arena, &oplist, alias_reg_rng.byte_off + alias_slice.byte_off);
|
||||||
atom = e_push_expr(arena, E_ExprKind_LeafBytecode, token_string.str);
|
atom = e_push_expr(arena, E_ExprKind_LeafBytecode, token_string.str);
|
||||||
atom->mode = E_Mode_Reg;
|
atom->mode = E_Mode_Reg;
|
||||||
atom->space = space;
|
|
||||||
atom->type_key = type_key;
|
atom->type_key = type_key;
|
||||||
atom->string = e_bytecode_from_oplist(arena, &oplist);
|
atom->string = e_bytecode_from_oplist(arena, &oplist);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
@@ -1504,17 +1458,16 @@ e_parse_expr_from_text_tokens__prec(Arena *arena, String8 text, E_TokenArray *to
|
|||||||
case RDI_LocationKind_AddrBytecodeStream:
|
case RDI_LocationKind_AddrBytecodeStream:
|
||||||
{
|
{
|
||||||
atom = e_push_expr(arena, E_ExprKind_LeafBytecode, token_string.str);
|
atom = e_push_expr(arena, E_ExprKind_LeafBytecode, token_string.str);
|
||||||
atom->mode = E_Mode_Addr;
|
atom->mode = E_Mode_Addr;
|
||||||
atom->space = space;
|
|
||||||
atom->type_key = type_key;
|
atom->type_key = type_key;
|
||||||
atom->string = loc_bytecode;
|
atom->string = loc_bytecode;
|
||||||
}break;
|
}break;
|
||||||
case RDI_LocationKind_ValBytecodeStream:
|
case RDI_LocationKind_ValBytecodeStream:
|
||||||
{
|
{
|
||||||
atom = e_push_expr(arena, E_ExprKind_LeafBytecode, token_string.str);
|
atom = e_push_expr(arena, E_ExprKind_LeafBytecode, token_string.str);
|
||||||
atom->mode = E_Mode_Value;
|
atom->mode = E_Mode_Value;
|
||||||
atom->type_key = type_key;
|
atom->type_key = type_key;
|
||||||
atom->string = loc_bytecode;
|
atom->string = loc_bytecode;
|
||||||
}break;
|
}break;
|
||||||
case RDI_LocationKind_AddrRegPlusU16:
|
case RDI_LocationKind_AddrRegPlusU16:
|
||||||
{
|
{
|
||||||
@@ -1525,10 +1478,9 @@ e_parse_expr_from_text_tokens__prec(Arena *arena, String8 text, E_TokenArray *to
|
|||||||
e_oplist_push_op(arena, &oplist, RDI_EvalOp_ConstU16, loc_reg_u16.offset);
|
e_oplist_push_op(arena, &oplist, RDI_EvalOp_ConstU16, loc_reg_u16.offset);
|
||||||
e_oplist_push_op(arena, &oplist, RDI_EvalOp_Add, 0);
|
e_oplist_push_op(arena, &oplist, RDI_EvalOp_Add, 0);
|
||||||
atom = e_push_expr(arena, E_ExprKind_LeafBytecode, token_string.str);
|
atom = e_push_expr(arena, E_ExprKind_LeafBytecode, token_string.str);
|
||||||
atom->mode = E_Mode_Addr;
|
atom->mode = E_Mode_Addr;
|
||||||
atom->space = space;
|
|
||||||
atom->type_key = type_key;
|
atom->type_key = type_key;
|
||||||
atom->string = e_bytecode_from_oplist(arena, &oplist);
|
atom->string = e_bytecode_from_oplist(arena, &oplist);
|
||||||
}break;
|
}break;
|
||||||
case RDI_LocationKind_AddrAddrRegPlusU16:
|
case RDI_LocationKind_AddrAddrRegPlusU16:
|
||||||
{
|
{
|
||||||
@@ -1540,10 +1492,9 @@ e_parse_expr_from_text_tokens__prec(Arena *arena, String8 text, E_TokenArray *to
|
|||||||
e_oplist_push_op(arena, &oplist, RDI_EvalOp_Add, 0);
|
e_oplist_push_op(arena, &oplist, RDI_EvalOp_Add, 0);
|
||||||
e_oplist_push_op(arena, &oplist, RDI_EvalOp_MemRead, bit_size_from_arch(e_parse_ctx->arch)/8);
|
e_oplist_push_op(arena, &oplist, RDI_EvalOp_MemRead, bit_size_from_arch(e_parse_ctx->arch)/8);
|
||||||
atom = e_push_expr(arena, E_ExprKind_LeafBytecode, token_string.str);
|
atom = e_push_expr(arena, E_ExprKind_LeafBytecode, token_string.str);
|
||||||
atom->mode = E_Mode_Addr;
|
atom->mode = E_Mode_Addr;
|
||||||
atom->space = space;
|
|
||||||
atom->type_key = type_key;
|
atom->type_key = type_key;
|
||||||
atom->string = e_bytecode_from_oplist(arena, &oplist);
|
atom->string = e_bytecode_from_oplist(arena, &oplist);
|
||||||
}break;
|
}break;
|
||||||
case RDI_LocationKind_ValReg:
|
case RDI_LocationKind_ValReg:
|
||||||
{
|
{
|
||||||
@@ -1555,10 +1506,9 @@ e_parse_expr_from_text_tokens__prec(Arena *arena, String8 text, E_TokenArray *to
|
|||||||
U64 regread_param = RDI_EncodeRegReadParam(loc_reg.reg_code, byte_size, byte_pos);
|
U64 regread_param = RDI_EncodeRegReadParam(loc_reg.reg_code, byte_size, byte_pos);
|
||||||
e_oplist_push_op(arena, &oplist, RDI_EvalOp_RegRead, regread_param);
|
e_oplist_push_op(arena, &oplist, RDI_EvalOp_RegRead, regread_param);
|
||||||
atom = e_push_expr(arena, E_ExprKind_LeafBytecode, token_string.str);
|
atom = e_push_expr(arena, E_ExprKind_LeafBytecode, token_string.str);
|
||||||
atom->mode = E_Mode_Value;
|
atom->mode = E_Mode_Value;
|
||||||
atom->space = E_Space_Values;
|
|
||||||
atom->type_key = type_key;
|
atom->type_key = type_key;
|
||||||
atom->string = e_bytecode_from_oplist(arena, &oplist);
|
atom->string = e_bytecode_from_oplist(arena, &oplist);
|
||||||
}break;
|
}break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+8
-74
@@ -9,38 +9,6 @@
|
|||||||
|
|
||||||
#include "generated/eval.meta.h"
|
#include "generated/eval.meta.h"
|
||||||
|
|
||||||
////////////////////////////////
|
|
||||||
//~ rjf: Messages
|
|
||||||
|
|
||||||
typedef enum E_MsgKind
|
|
||||||
{
|
|
||||||
E_MsgKind_Null,
|
|
||||||
E_MsgKind_MalformedInput,
|
|
||||||
E_MsgKind_MissingInfo,
|
|
||||||
E_MsgKind_ResolutionFailure,
|
|
||||||
E_MsgKind_InterpretationError,
|
|
||||||
E_MsgKind_COUNT
|
|
||||||
}
|
|
||||||
E_MsgKind;
|
|
||||||
|
|
||||||
typedef struct E_Msg E_Msg;
|
|
||||||
struct E_Msg
|
|
||||||
{
|
|
||||||
E_Msg *next;
|
|
||||||
E_MsgKind kind;
|
|
||||||
void *location;
|
|
||||||
String8 text;
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef struct E_MsgList E_MsgList;
|
|
||||||
struct E_MsgList
|
|
||||||
{
|
|
||||||
E_Msg *first;
|
|
||||||
E_Msg *last;
|
|
||||||
E_MsgKind max_kind;
|
|
||||||
U64 count;
|
|
||||||
};
|
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ rjf: Token Types
|
//~ rjf: Token Types
|
||||||
|
|
||||||
@@ -79,27 +47,6 @@ struct E_TokenArray
|
|||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ rjf: Expression Tree Types
|
//~ rjf: Expression Tree Types
|
||||||
|
|
||||||
typedef U64 E_Space;
|
|
||||||
//
|
|
||||||
// NOTE(rjf): Evaluations occur within the context of a "space". Each "space"
|
|
||||||
// refers to a different offset or address space, but it's a bit looser of a
|
|
||||||
// concept than just address space, since it can also refer to offsets into
|
|
||||||
// a register block, only type information, or the "space" of all possibly
|
|
||||||
// values. It is also used to refer to spaces of unique IDs for key-value
|
|
||||||
// stores, e.g. for information in the debugger.
|
|
||||||
//
|
|
||||||
// Effectively, when considering the result of an evaluation, you use the
|
|
||||||
// value for understanding a key *into* a space, e.g. 1+2 -> 3, in the space
|
|
||||||
// of all values, or &foo, in the space of all addresses in PID: 1234.
|
|
||||||
//
|
|
||||||
enum
|
|
||||||
{
|
|
||||||
E_Space_Null,
|
|
||||||
E_Space_Types, // values are not used; evaluation only contain type content
|
|
||||||
E_Space_Values, // values do not refer to any space, but are standalone numeric values
|
|
||||||
E_Space_Regs, // values index into evaluator thread's register block
|
|
||||||
};
|
|
||||||
|
|
||||||
typedef enum E_Mode
|
typedef enum E_Mode
|
||||||
{
|
{
|
||||||
E_Mode_Null,
|
E_Mode_Null,
|
||||||
@@ -118,7 +65,7 @@ struct E_Expr
|
|||||||
void *location;
|
void *location;
|
||||||
E_ExprKind kind;
|
E_ExprKind kind;
|
||||||
E_Mode mode;
|
E_Mode mode;
|
||||||
E_Space space;
|
// E_Space space;
|
||||||
E_TypeKey type_key;
|
E_TypeKey type_key;
|
||||||
U32 u32;
|
U32 u32;
|
||||||
F32 f32;
|
F32 f32;
|
||||||
@@ -201,15 +148,14 @@ struct E_ParseCtx
|
|||||||
|
|
||||||
// rjf: instruction pointer info
|
// rjf: instruction pointer info
|
||||||
U64 ip_vaddr;
|
U64 ip_vaddr;
|
||||||
U64 ip_voff; // (within module, which uses `rdis[rdis_primary_idx]` for debug info)
|
U64 ip_voff;
|
||||||
|
|
||||||
// rjf: debug info
|
// rjf: modules
|
||||||
RDI_Parsed **rdis;
|
E_Module *modules;
|
||||||
Rng1U64 *rdis_vaddr_ranges;
|
U64 modules_count;
|
||||||
U64 rdis_count;
|
E_Module *primary_module;
|
||||||
U64 rdis_primary_idx;
|
|
||||||
|
|
||||||
// rjf: identifier resolution maps
|
// rjf: local identifier resolution maps
|
||||||
E_String2NumMap *regs_map;
|
E_String2NumMap *regs_map;
|
||||||
E_String2NumMap *reg_alias_map;
|
E_String2NumMap *reg_alias_map;
|
||||||
E_String2NumMap *locals_map; // (within `rdis[rdis_primary_idx]`)
|
E_String2NumMap *locals_map; // (within `rdis[rdis_primary_idx]`)
|
||||||
@@ -235,11 +181,6 @@ global read_only E_String2ExprMap e_string2expr_map_nil = {0};
|
|||||||
global read_only E_Expr e_expr_nil = {&e_expr_nil, &e_expr_nil, &e_expr_nil};
|
global read_only E_Expr e_expr_nil = {&e_expr_nil, &e_expr_nil, &e_expr_nil};
|
||||||
thread_static E_ParseCtx *e_parse_ctx = 0;
|
thread_static E_ParseCtx *e_parse_ctx = 0;
|
||||||
|
|
||||||
////////////////////////////////
|
|
||||||
//~ rjf: Basic Helper Functions
|
|
||||||
|
|
||||||
internal U64 e_hash_from_string(U64 seed, String8 string);
|
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ rjf: Basic Map Functions
|
//~ rjf: Basic Map Functions
|
||||||
|
|
||||||
@@ -264,13 +205,6 @@ internal E_Expr *e_expr_from_string(E_String2ExprMap *map, String8 string);
|
|||||||
internal E_String2NumMap *e_push_locals_map_from_rdi_voff(Arena *arena, RDI_Parsed *rdi, U64 voff);
|
internal E_String2NumMap *e_push_locals_map_from_rdi_voff(Arena *arena, RDI_Parsed *rdi, U64 voff);
|
||||||
internal E_String2NumMap *e_push_member_map_from_rdi_voff(Arena *arena, RDI_Parsed *rdi, U64 voff);
|
internal E_String2NumMap *e_push_member_map_from_rdi_voff(Arena *arena, RDI_Parsed *rdi, U64 voff);
|
||||||
|
|
||||||
////////////////////////////////
|
|
||||||
//~ rjf: Message Functions
|
|
||||||
|
|
||||||
internal void e_msg(Arena *arena, E_MsgList *msgs, E_MsgKind kind, void *location, String8 text);
|
|
||||||
internal void e_msgf(Arena *arena, E_MsgList *msgs, E_MsgKind kind, void *location, char *fmt, ...);
|
|
||||||
internal void e_msg_list_concat_in_place(E_MsgList *dst, E_MsgList *to_push);
|
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ rjf: Tokenization Functions
|
//~ rjf: Tokenization Functions
|
||||||
|
|
||||||
@@ -286,7 +220,7 @@ internal E_TokenArray e_token_array_make_first_opl(E_Token *first, E_Token *opl)
|
|||||||
|
|
||||||
internal E_ParseCtx *e_selected_parse_ctx(void);
|
internal E_ParseCtx *e_selected_parse_ctx(void);
|
||||||
internal void e_select_parse_ctx(E_ParseCtx *ctx);
|
internal void e_select_parse_ctx(E_ParseCtx *ctx);
|
||||||
internal U32 e_parse_ctx_idx_from_rdi(RDI_Parsed *rdi);
|
internal U32 e_parse_ctx_module_idx_from_rdi(RDI_Parsed *rdi);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ rjf: Expression Tree Building Functions
|
//~ rjf: Expression Tree Building Functions
|
||||||
|
|||||||
@@ -506,7 +506,7 @@ e_type_from_key(Arena *arena, E_TypeKey key)
|
|||||||
{
|
{
|
||||||
U64 type_node_idx = key.u32[1];
|
U64 type_node_idx = key.u32[1];
|
||||||
U32 rdi_idx = key.u32[2];
|
U32 rdi_idx = key.u32[2];
|
||||||
RDI_Parsed *rdi = e_type_state->ctx->rdis[rdi_idx];
|
RDI_Parsed *rdi = e_type_state->ctx->modules[rdi_idx].rdi;
|
||||||
RDI_TypeNode *rdi_type = rdi_element_from_name_idx(rdi, TypeNodes, type_node_idx);
|
RDI_TypeNode *rdi_type = rdi_element_from_name_idx(rdi, TypeNodes, type_node_idx);
|
||||||
if(rdi_type->kind != RDI_TypeKind_NULL)
|
if(rdi_type->kind != RDI_TypeKind_NULL)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -173,10 +173,9 @@ struct E_TypeCtx
|
|||||||
U64 ip_voff; // (within module, which uses `rdis[rdis_primary_idx]` for debug info)
|
U64 ip_voff; // (within module, which uses `rdis[rdis_primary_idx]` for debug info)
|
||||||
|
|
||||||
// rjf: debug info
|
// rjf: debug info
|
||||||
RDI_Parsed **rdis;
|
E_Module *modules;
|
||||||
Rng1U64 *rdis_vaddr_ranges;
|
U64 modules_count;
|
||||||
U64 rdis_count;
|
E_Module *primary_module;
|
||||||
U64 rdis_primary_idx;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct E_TypeState E_TypeState;
|
typedef struct E_TypeState E_TypeState;
|
||||||
|
|||||||
Reference in New Issue
Block a user