mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-06-13 07:32:23 -07:00
symbolof operation in eval
This commit is contained in:
@@ -93,6 +93,7 @@ E_ExprKindTable:
|
||||
{ Cast Null 1 "cast(" ")" "" "" }
|
||||
{ Sizeof UnaryPrefix 1 "sizeof " "" "" "" }
|
||||
{ Typeof UnaryPrefix 1 "typeof " "" "" "" }
|
||||
{ Symbolof UnaryPrefix 1 "symbolof " "" "" "" }
|
||||
{ ByteSwap UnaryPrefix 1 "bswap " "" "" "" }
|
||||
|
||||
{ Pos UnaryPrefix 2 "+" "" "" "" }
|
||||
|
||||
@@ -953,6 +953,53 @@ e_push_irtree_and_type_from_expr(Arena *arena, E_IRTreeAndType *root_parent, E_I
|
||||
result.mode = E_Mode_Null;
|
||||
}break;
|
||||
|
||||
//- rjf: symbolof
|
||||
case E_ExprKind_Symbolof:
|
||||
{
|
||||
E_IRTreeAndType r_tree = e_push_irtree_and_type_from_expr(arena, parent, &e_default_identifier_resolution_rule, disallow_autohooks, 1, expr->first);
|
||||
E_IRNode *r_value_tree = e_irtree_resolve_to_value(arena, r_tree.mode, r_tree.root, r_tree.type_key);
|
||||
E_OpList oplist = e_oplist_from_irtree(scratch.arena, r_value_tree);
|
||||
String8 bytecode = e_bytecode_from_oplist(scratch.arena, &oplist);
|
||||
E_Interpretation interpretation = e_interpret(bytecode);
|
||||
E_Module *module = &e_module_nil;
|
||||
U32 rdi_idx = 0;
|
||||
for EachIndex(idx, e_base_ctx->modules_count)
|
||||
{
|
||||
E_Module *m = &e_base_ctx->modules[idx];
|
||||
if(e_space_match(interpretation.space, m->space) && contains_1u64(m->vaddr_range, interpretation.value.u64))
|
||||
{
|
||||
module = m;
|
||||
rdi_idx = (U32)idx;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if(module != &e_module_nil)
|
||||
{
|
||||
U64 voff = interpretation.value.u64 - module->vaddr_range.min;
|
||||
U64 new_vaddr = 0;
|
||||
RDI_Procedure *p = rdi_procedure_from_voff(module->rdi, voff);
|
||||
RDI_GlobalVariable *g = rdi_global_variable_from_voff(module->rdi, voff);
|
||||
U32 type_idx = 0;
|
||||
if(p->name_string_idx != 0)
|
||||
{
|
||||
type_idx = p->type_idx;
|
||||
new_vaddr = module->vaddr_range.min + rdi_first_voff_from_procedure(module->rdi, p);
|
||||
}
|
||||
else if(g->name_string_idx != 0)
|
||||
{
|
||||
type_idx = g->type_idx;
|
||||
new_vaddr = module->vaddr_range.min + g->voff;
|
||||
}
|
||||
if(type_idx != 0)
|
||||
{
|
||||
RDI_TypeNode *t = rdi_element_from_name_idx(module->rdi, TypeNodes, type_idx);
|
||||
result.root = e_irtree_const_u(arena, new_vaddr);
|
||||
result.mode = E_Mode_Value;
|
||||
result.type_key = e_type_key_ext(e_type_kind_from_rdi(t->kind), type_idx, rdi_idx);
|
||||
}
|
||||
}
|
||||
}break;
|
||||
|
||||
//- rjf: byteswap
|
||||
case E_ExprKind_ByteSwap:
|
||||
{
|
||||
|
||||
@@ -144,7 +144,7 @@ U8 e_type_kind_basic_byte_size_table[61] =
|
||||
0,
|
||||
};
|
||||
|
||||
String8 e_expr_kind_strings[49] =
|
||||
String8 e_expr_kind_strings[50] =
|
||||
{
|
||||
str8_lit_comp("Nil"),
|
||||
str8_lit_comp("Ref"),
|
||||
@@ -155,6 +155,7 @@ str8_lit_comp("Address"),
|
||||
str8_lit_comp("Cast"),
|
||||
str8_lit_comp("Sizeof"),
|
||||
str8_lit_comp("Typeof"),
|
||||
str8_lit_comp("Symbolof"),
|
||||
str8_lit_comp("ByteSwap"),
|
||||
str8_lit_comp("Pos"),
|
||||
str8_lit_comp("Neg"),
|
||||
@@ -197,7 +198,7 @@ str8_lit_comp("Unsigned"),
|
||||
str8_lit_comp("Define"),
|
||||
};
|
||||
|
||||
E_OpInfo e_expr_kind_op_info_table[49] =
|
||||
E_OpInfo e_expr_kind_op_info_table[50] =
|
||||
{
|
||||
{ E_OpKind_Null, 0, str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp("") },
|
||||
{ E_OpKind_Null, 0, str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp("") },
|
||||
@@ -208,6 +209,7 @@ E_OpInfo e_expr_kind_op_info_table[49] =
|
||||
{ E_OpKind_Null, 1, str8_lit_comp("cast("), str8_lit_comp(")"), str8_lit_comp(""), str8_lit_comp("") },
|
||||
{ E_OpKind_UnaryPrefix, 1, str8_lit_comp("sizeof "), str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp("") },
|
||||
{ E_OpKind_UnaryPrefix, 1, str8_lit_comp("typeof "), str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp("") },
|
||||
{ E_OpKind_UnaryPrefix, 1, str8_lit_comp("symbolof "), str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp("") },
|
||||
{ E_OpKind_UnaryPrefix, 1, str8_lit_comp("bswap "), str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp("") },
|
||||
{ E_OpKind_UnaryPrefix, 2, str8_lit_comp("+"), str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp("") },
|
||||
{ E_OpKind_UnaryPrefix, 2, str8_lit_comp("-"), str8_lit_comp(""), str8_lit_comp(""), str8_lit_comp("") },
|
||||
|
||||
@@ -107,6 +107,7 @@ E_ExprKind_Address,
|
||||
E_ExprKind_Cast,
|
||||
E_ExprKind_Sizeof,
|
||||
E_ExprKind_Typeof,
|
||||
E_ExprKind_Symbolof,
|
||||
E_ExprKind_ByteSwap,
|
||||
E_ExprKind_Pos,
|
||||
E_ExprKind_Neg,
|
||||
@@ -170,8 +171,8 @@ C_LINKAGE_BEGIN
|
||||
extern String8 e_token_kind_strings[6];
|
||||
extern String8 e_type_kind_basic_string_table[61];
|
||||
extern U8 e_type_kind_basic_byte_size_table[61];
|
||||
extern String8 e_expr_kind_strings[49];
|
||||
extern E_OpInfo e_expr_kind_op_info_table[49];
|
||||
extern String8 e_expr_kind_strings[50];
|
||||
extern E_OpInfo e_expr_kind_op_info_table[50];
|
||||
extern String8 e_interpretation_code_display_strings[11];
|
||||
|
||||
C_LINKAGE_END
|
||||
|
||||
Reference in New Issue
Block a user