mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-06-17 17:42:22 -07:00
raddbg -> raddbgi
This commit is contained in:
+149
-149
@@ -23,8 +23,8 @@ eval_bytecode_from_oplist(Arena *arena, EVAL_OpList *list){
|
||||
default:
|
||||
{
|
||||
// compute bytecode advance
|
||||
U8 ctrlbits = raddbg_eval_opcode_ctrlbits[opcode];
|
||||
U64 extra_byte_count = RADDBG_DECODEN_FROM_CTRLBITS(ctrlbits);
|
||||
U8 ctrlbits = raddbgi_eval_opcode_ctrlbits[opcode];
|
||||
U64 extra_byte_count = RADDBGI_DECODEN_FROM_CTRLBITS(ctrlbits);
|
||||
|
||||
U8 *next_ptr = ptr + 1 + extra_byte_count;
|
||||
Assert(next_ptr <= opl);
|
||||
@@ -62,9 +62,9 @@ eval_bytecode_from_oplist(Arena *arena, EVAL_OpList *list){
|
||||
}
|
||||
|
||||
internal void
|
||||
eval_oplist_push_op(Arena *arena, EVAL_OpList *list, RADDBG_EvalOp opcode, U64 p){
|
||||
U8 ctrlbits = raddbg_eval_opcode_ctrlbits[opcode];
|
||||
U32 p_size = RADDBG_DECODEN_FROM_CTRLBITS(ctrlbits);
|
||||
eval_oplist_push_op(Arena *arena, EVAL_OpList *list, RADDBGI_EvalOp opcode, U64 p){
|
||||
U8 ctrlbits = raddbgi_eval_opcode_ctrlbits[opcode];
|
||||
U32 p_size = RADDBGI_DECODEN_FROM_CTRLBITS(ctrlbits);
|
||||
|
||||
EVAL_Op *node = push_array_no_zero(arena, EVAL_Op, 1);
|
||||
node->opcode = opcode;
|
||||
@@ -78,35 +78,35 @@ eval_oplist_push_op(Arena *arena, EVAL_OpList *list, RADDBG_EvalOp opcode, U64 p
|
||||
internal void
|
||||
eval_oplist_push_uconst(Arena *arena, EVAL_OpList *list, U64 x){
|
||||
if (x <= 0xFF){
|
||||
eval_oplist_push_op(arena, list, RADDBG_EvalOp_ConstU8, x);
|
||||
eval_oplist_push_op(arena, list, RADDBGI_EvalOp_ConstU8, x);
|
||||
}
|
||||
else if (x <= 0xFFFF){
|
||||
eval_oplist_push_op(arena, list, RADDBG_EvalOp_ConstU16, x);
|
||||
eval_oplist_push_op(arena, list, RADDBGI_EvalOp_ConstU16, x);
|
||||
}
|
||||
else if (x <= 0xFFFFFFFF){
|
||||
eval_oplist_push_op(arena, list, RADDBG_EvalOp_ConstU32, x);
|
||||
eval_oplist_push_op(arena, list, RADDBGI_EvalOp_ConstU32, x);
|
||||
}
|
||||
else{
|
||||
eval_oplist_push_op(arena, list, RADDBG_EvalOp_ConstU64, x);
|
||||
eval_oplist_push_op(arena, list, RADDBGI_EvalOp_ConstU64, x);
|
||||
}
|
||||
}
|
||||
|
||||
internal void
|
||||
eval_oplist_push_sconst(Arena *arena, EVAL_OpList *list, S64 x){
|
||||
if (-0x80 <= x && x <= 0x7F){
|
||||
eval_oplist_push_op(arena, list, RADDBG_EvalOp_ConstU8, (U64)x);
|
||||
eval_oplist_push_op(arena, list, RADDBG_EvalOp_TruncSigned, 8);
|
||||
eval_oplist_push_op(arena, list, RADDBGI_EvalOp_ConstU8, (U64)x);
|
||||
eval_oplist_push_op(arena, list, RADDBGI_EvalOp_TruncSigned, 8);
|
||||
}
|
||||
else if (-0x8000 <= x && x <= 0x7FFF){
|
||||
eval_oplist_push_op(arena, list, RADDBG_EvalOp_ConstU16, (U64)x);
|
||||
eval_oplist_push_op(arena, list, RADDBG_EvalOp_TruncSigned, 16);
|
||||
eval_oplist_push_op(arena, list, RADDBGI_EvalOp_ConstU16, (U64)x);
|
||||
eval_oplist_push_op(arena, list, RADDBGI_EvalOp_TruncSigned, 16);
|
||||
}
|
||||
else if (-0x80000000ll <= x && x <= 0x7FFFFFFFll){
|
||||
eval_oplist_push_op(arena, list, RADDBG_EvalOp_ConstU32, (U64)x);
|
||||
eval_oplist_push_op(arena, list, RADDBG_EvalOp_TruncSigned, 32);
|
||||
eval_oplist_push_op(arena, list, RADDBGI_EvalOp_ConstU32, (U64)x);
|
||||
eval_oplist_push_op(arena, list, RADDBGI_EvalOp_TruncSigned, 32);
|
||||
}
|
||||
else{
|
||||
eval_oplist_push_op(arena, list, RADDBG_EvalOp_ConstU64, (U64)x);
|
||||
eval_oplist_push_op(arena, list, RADDBGI_EvalOp_ConstU64, (U64)x);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -138,31 +138,31 @@ eval_oplist_concat_in_place(EVAL_OpList *left_dst, EVAL_OpList *right_destroyed)
|
||||
////////////////////////////////
|
||||
//~ allen: EVAL Expression Info Functions
|
||||
|
||||
internal RADDBG_EvalOp
|
||||
internal RADDBGI_EvalOp
|
||||
eval_opcode_from_expr_kind(EVAL_ExprKind kind){
|
||||
RADDBG_EvalOp result = RADDBG_EvalOp_Stop;
|
||||
RADDBGI_EvalOp result = RADDBGI_EvalOp_Stop;
|
||||
switch (kind){
|
||||
case EVAL_ExprKind_Neg: result = RADDBG_EvalOp_Neg; break;
|
||||
case EVAL_ExprKind_LogNot: result = RADDBG_EvalOp_LogNot; break;
|
||||
case EVAL_ExprKind_BitNot: result = RADDBG_EvalOp_BitNot; break;
|
||||
case EVAL_ExprKind_Mul: result = RADDBG_EvalOp_Mul; break;
|
||||
case EVAL_ExprKind_Div: result = RADDBG_EvalOp_Div; break;
|
||||
case EVAL_ExprKind_Mod: result = RADDBG_EvalOp_Mod; break;
|
||||
case EVAL_ExprKind_Add: result = RADDBG_EvalOp_Add; break;
|
||||
case EVAL_ExprKind_Sub: result = RADDBG_EvalOp_Sub; break;
|
||||
case EVAL_ExprKind_LShift: result = RADDBG_EvalOp_LShift; break;
|
||||
case EVAL_ExprKind_RShift: result = RADDBG_EvalOp_RShift; break;
|
||||
case EVAL_ExprKind_Less: result = RADDBG_EvalOp_Less; break;
|
||||
case EVAL_ExprKind_LsEq: result = RADDBG_EvalOp_LsEq; break;
|
||||
case EVAL_ExprKind_Grtr: result = RADDBG_EvalOp_Grtr; break;
|
||||
case EVAL_ExprKind_GrEq: result = RADDBG_EvalOp_GrEq; break;
|
||||
case EVAL_ExprKind_EqEq: result = RADDBG_EvalOp_EqEq; break;
|
||||
case EVAL_ExprKind_NtEq: result = RADDBG_EvalOp_NtEq; break;
|
||||
case EVAL_ExprKind_BitAnd: result = RADDBG_EvalOp_BitAnd; break;
|
||||
case EVAL_ExprKind_BitXor: result = RADDBG_EvalOp_BitXor; break;
|
||||
case EVAL_ExprKind_BitOr: result = RADDBG_EvalOp_BitOr; break;
|
||||
case EVAL_ExprKind_LogAnd: result = RADDBG_EvalOp_LogAnd; break;
|
||||
case EVAL_ExprKind_LogOr: result = RADDBG_EvalOp_LogOr; break;
|
||||
case EVAL_ExprKind_Neg: result = RADDBGI_EvalOp_Neg; break;
|
||||
case EVAL_ExprKind_LogNot: result = RADDBGI_EvalOp_LogNot; break;
|
||||
case EVAL_ExprKind_BitNot: result = RADDBGI_EvalOp_BitNot; break;
|
||||
case EVAL_ExprKind_Mul: result = RADDBGI_EvalOp_Mul; break;
|
||||
case EVAL_ExprKind_Div: result = RADDBGI_EvalOp_Div; break;
|
||||
case EVAL_ExprKind_Mod: result = RADDBGI_EvalOp_Mod; break;
|
||||
case EVAL_ExprKind_Add: result = RADDBGI_EvalOp_Add; break;
|
||||
case EVAL_ExprKind_Sub: result = RADDBGI_EvalOp_Sub; break;
|
||||
case EVAL_ExprKind_LShift: result = RADDBGI_EvalOp_LShift; break;
|
||||
case EVAL_ExprKind_RShift: result = RADDBGI_EvalOp_RShift; break;
|
||||
case EVAL_ExprKind_Less: result = RADDBGI_EvalOp_Less; break;
|
||||
case EVAL_ExprKind_LsEq: result = RADDBGI_EvalOp_LsEq; break;
|
||||
case EVAL_ExprKind_Grtr: result = RADDBGI_EvalOp_Grtr; break;
|
||||
case EVAL_ExprKind_GrEq: result = RADDBGI_EvalOp_GrEq; break;
|
||||
case EVAL_ExprKind_EqEq: result = RADDBGI_EvalOp_EqEq; break;
|
||||
case EVAL_ExprKind_NtEq: result = RADDBGI_EvalOp_NtEq; break;
|
||||
case EVAL_ExprKind_BitAnd: result = RADDBGI_EvalOp_BitAnd; break;
|
||||
case EVAL_ExprKind_BitXor: result = RADDBGI_EvalOp_BitXor; break;
|
||||
case EVAL_ExprKind_BitOr: result = RADDBGI_EvalOp_BitOr; break;
|
||||
case EVAL_ExprKind_LogAnd: result = RADDBGI_EvalOp_LogAnd; break;
|
||||
case EVAL_ExprKind_LogOr: result = RADDBGI_EvalOp_LogOr; break;
|
||||
}
|
||||
return(result);
|
||||
}
|
||||
@@ -286,9 +286,9 @@ eval_expr_leaf_type(Arena *arena, void *location, TG_Key type_key){
|
||||
////////////////////////////////
|
||||
//~ allen: EVAL Type Information Transformers
|
||||
|
||||
internal RADDBG_EvalTypeGroup
|
||||
internal RADDBGI_EvalTypeGroup
|
||||
eval_type_group_from_kind(TG_Kind kind){
|
||||
RADDBG_EvalTypeGroup result = 0;
|
||||
RADDBGI_EvalTypeGroup result = 0;
|
||||
switch (kind){
|
||||
default:{}break;
|
||||
|
||||
@@ -303,7 +303,7 @@ eval_type_group_from_kind(TG_Kind kind){
|
||||
case TG_Kind_IncompleteStruct: case TG_Kind_IncompleteClass:
|
||||
case TG_Kind_IncompleteUnion: case TG_Kind_IncompleteEnum:
|
||||
case TG_Kind_Bitfield: case TG_Kind_Variadic:
|
||||
result = RADDBG_EvalTypeGroup_Other; break;
|
||||
result = RADDBGI_EvalTypeGroup_Other; break;
|
||||
|
||||
case TG_Kind_Handle:
|
||||
case TG_Kind_UChar8: case TG_Kind_UChar16: case TG_Kind_UChar32:
|
||||
@@ -312,26 +312,26 @@ eval_type_group_from_kind(TG_Kind kind){
|
||||
case TG_Kind_U512:
|
||||
case TG_Kind_Ptr: case TG_Kind_LRef: case TG_Kind_RRef:
|
||||
case TG_Kind_Function: case TG_Kind_Method: case TG_Kind_MemberPtr:
|
||||
result = RADDBG_EvalTypeGroup_U; break;
|
||||
result = RADDBGI_EvalTypeGroup_U; break;
|
||||
|
||||
case TG_Kind_Char8: case TG_Kind_Char16: case TG_Kind_Char32:
|
||||
case TG_Kind_S8: case TG_Kind_S16: case TG_Kind_S32:
|
||||
case TG_Kind_S64: case TG_Kind_S128: case TG_Kind_S256:
|
||||
case TG_Kind_S512:
|
||||
case TG_Kind_Bool:
|
||||
result = RADDBG_EvalTypeGroup_S; break;
|
||||
result = RADDBGI_EvalTypeGroup_S; break;
|
||||
|
||||
case TG_Kind_F32:
|
||||
result = RADDBG_EvalTypeGroup_F32; break;
|
||||
result = RADDBGI_EvalTypeGroup_F32; break;
|
||||
|
||||
case TG_Kind_F64:
|
||||
result = RADDBG_EvalTypeGroup_F64; break;
|
||||
result = RADDBGI_EvalTypeGroup_F64; break;
|
||||
}
|
||||
return(result);
|
||||
}
|
||||
|
||||
internal TG_Key
|
||||
eval_type_unwrap_enum(TG_Graph *graph, RADDBG_Parsed *rdbg, TG_Key key)
|
||||
eval_type_unwrap_enum(TG_Graph *graph, RADDBGI_Parsed *rdbg, TG_Key key)
|
||||
{
|
||||
TG_Key result = key;
|
||||
for(B32 good = 1; good;)
|
||||
@@ -339,7 +339,7 @@ eval_type_unwrap_enum(TG_Graph *graph, RADDBG_Parsed *rdbg, TG_Key key)
|
||||
TG_Kind kind = tg_kind_from_key(key);
|
||||
if(kind == TG_Kind_Enum)
|
||||
{
|
||||
result = tg_direct_from_graph_raddbg_key(graph, rdbg, result);
|
||||
result = tg_direct_from_graph_raddbgi_key(graph, rdbg, result);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -350,7 +350,7 @@ eval_type_unwrap_enum(TG_Graph *graph, RADDBG_Parsed *rdbg, TG_Key key)
|
||||
}
|
||||
|
||||
internal TG_Key
|
||||
eval_type_promote(TG_Graph *graph, RADDBG_Parsed *rdbg, TG_Key key){
|
||||
eval_type_promote(TG_Graph *graph, RADDBGI_Parsed *rdbg, TG_Key key){
|
||||
TG_Key result = key;
|
||||
TG_Kind kind = tg_kind_from_key(key);
|
||||
if(kind == TG_Kind_Bool ||
|
||||
@@ -365,7 +365,7 @@ eval_type_promote(TG_Graph *graph, RADDBG_Parsed *rdbg, TG_Key key){
|
||||
}
|
||||
|
||||
internal TG_Key
|
||||
eval_type_coerce(TG_Graph *graph, RADDBG_Parsed *rdbg, TG_Key l, TG_Key r){
|
||||
eval_type_coerce(TG_Graph *graph, RADDBGI_Parsed *rdbg, TG_Key l, TG_Key r){
|
||||
Assert(eval_kind_is_basic_or_enum(tg_kind_from_key(l)) &&
|
||||
eval_kind_is_basic_or_enum(tg_kind_from_key(r)));
|
||||
|
||||
@@ -384,12 +384,12 @@ eval_type_coerce(TG_Graph *graph, RADDBG_Parsed *rdbg, TG_Key l, TG_Key r){
|
||||
}
|
||||
|
||||
internal B32
|
||||
eval_type_match(TG_Graph *graph, RADDBG_Parsed *rdbg, TG_Key l, TG_Key r){
|
||||
eval_type_match(TG_Graph *graph, RADDBGI_Parsed *rdbg, TG_Key l, TG_Key r){
|
||||
B32 result = 0;
|
||||
|
||||
// unwrap
|
||||
TG_Key lu = tg_unwrapped_from_graph_raddbg_key(graph, rdbg, l);
|
||||
TG_Key ru = tg_unwrapped_from_graph_raddbg_key(graph, rdbg, r);
|
||||
TG_Key lu = tg_unwrapped_from_graph_raddbgi_key(graph, rdbg, l);
|
||||
TG_Key ru = tg_unwrapped_from_graph_raddbgi_key(graph, rdbg, r);
|
||||
|
||||
if (tg_key_match(lu, ru)){
|
||||
result = 1;
|
||||
@@ -408,8 +408,8 @@ eval_type_match(TG_Graph *graph, RADDBG_Parsed *rdbg, TG_Key l, TG_Key r){
|
||||
case TG_Kind_LRef:
|
||||
case TG_Kind_RRef:
|
||||
{
|
||||
TG_Key lud = tg_direct_from_graph_raddbg_key(graph, rdbg, lu);
|
||||
TG_Key rud = tg_direct_from_graph_raddbg_key(graph, rdbg, ru);
|
||||
TG_Key lud = tg_direct_from_graph_raddbgi_key(graph, rdbg, lu);
|
||||
TG_Key rud = tg_direct_from_graph_raddbgi_key(graph, rdbg, ru);
|
||||
if (eval_type_match(graph, rdbg, lud, rud)){
|
||||
result = 1;
|
||||
}
|
||||
@@ -417,10 +417,10 @@ eval_type_match(TG_Graph *graph, RADDBG_Parsed *rdbg, TG_Key l, TG_Key r){
|
||||
|
||||
case TG_Kind_MemberPtr:
|
||||
{
|
||||
TG_Key lud = tg_direct_from_graph_raddbg_key(graph, rdbg, lu);
|
||||
TG_Key rud = tg_direct_from_graph_raddbg_key(graph, rdbg, ru);
|
||||
TG_Key luo = tg_owner_from_graph_raddbg_key(graph, rdbg, lu);
|
||||
TG_Key ruo = tg_owner_from_graph_raddbg_key(graph, rdbg, ru);
|
||||
TG_Key lud = tg_direct_from_graph_raddbgi_key(graph, rdbg, lu);
|
||||
TG_Key rud = tg_direct_from_graph_raddbgi_key(graph, rdbg, ru);
|
||||
TG_Key luo = tg_owner_from_graph_raddbgi_key(graph, rdbg, lu);
|
||||
TG_Key ruo = tg_owner_from_graph_raddbgi_key(graph, rdbg, ru);
|
||||
if (eval_type_match(graph, rdbg, lud, rud) &&
|
||||
eval_type_match(graph, rdbg, luo, ruo)){
|
||||
result = 1;
|
||||
@@ -430,8 +430,8 @@ eval_type_match(TG_Graph *graph, RADDBG_Parsed *rdbg, TG_Key l, TG_Key r){
|
||||
case TG_Kind_Array:
|
||||
{
|
||||
Temp scratch = scratch_begin(0, 0);
|
||||
TG_Type *lt = tg_type_from_graph_raddbg_key(scratch.arena, graph, rdbg, l);
|
||||
TG_Type *rt = tg_type_from_graph_raddbg_key(scratch.arena, graph, rdbg, r);
|
||||
TG_Type *lt = tg_type_from_graph_raddbgi_key(scratch.arena, graph, rdbg, l);
|
||||
TG_Type *rt = tg_type_from_graph_raddbgi_key(scratch.arena, graph, rdbg, r);
|
||||
if(lt->count == rt->count && eval_type_match(graph, rdbg, lt->direct_type_key, rt->direct_type_key))
|
||||
{
|
||||
result = 1;
|
||||
@@ -442,8 +442,8 @@ eval_type_match(TG_Graph *graph, RADDBG_Parsed *rdbg, TG_Key l, TG_Key r){
|
||||
case TG_Kind_Function:
|
||||
{
|
||||
Temp scratch = scratch_begin(0, 0);
|
||||
TG_Type *lt = tg_type_from_graph_raddbg_key(scratch.arena, graph, rdbg, l);
|
||||
TG_Type *rt = tg_type_from_graph_raddbg_key(scratch.arena, graph, rdbg, r);
|
||||
TG_Type *lt = tg_type_from_graph_raddbgi_key(scratch.arena, graph, rdbg, l);
|
||||
TG_Type *rt = tg_type_from_graph_raddbgi_key(scratch.arena, graph, rdbg, r);
|
||||
if (lt->count == rt->count && eval_type_match(graph, rdbg, lt->direct_type_key, rt->direct_type_key))
|
||||
{
|
||||
B32 params_match = 1;
|
||||
@@ -466,8 +466,8 @@ eval_type_match(TG_Graph *graph, RADDBG_Parsed *rdbg, TG_Key l, TG_Key r){
|
||||
case TG_Kind_Method:
|
||||
{
|
||||
Temp scratch = scratch_begin(0, 0);
|
||||
TG_Type *lt = tg_type_from_graph_raddbg_key(scratch.arena, graph, rdbg, l);
|
||||
TG_Type *rt = tg_type_from_graph_raddbg_key(scratch.arena, graph, rdbg, r);
|
||||
TG_Type *lt = tg_type_from_graph_raddbgi_key(scratch.arena, graph, rdbg, l);
|
||||
TG_Type *rt = tg_type_from_graph_raddbgi_key(scratch.arena, graph, rdbg, r);
|
||||
if (lt->count == rt->count &&
|
||||
eval_type_match(graph, rdbg, lt->direct_type_key, rt->direct_type_key) &&
|
||||
eval_type_match(graph, rdbg, lt->owner_type_key, rt->owner_type_key))
|
||||
@@ -522,15 +522,15 @@ eval_kind_is_basic_or_enum(TG_Kind kind){
|
||||
internal EVAL_IRTree*
|
||||
eval_irtree_const_u(Arena *arena, U64 v){
|
||||
// choose encoding op
|
||||
RADDBG_EvalOp op = RADDBG_EvalOp_ConstU64;
|
||||
RADDBGI_EvalOp op = RADDBGI_EvalOp_ConstU64;
|
||||
if (v < 0x100){
|
||||
op = RADDBG_EvalOp_ConstU8;
|
||||
op = RADDBGI_EvalOp_ConstU8;
|
||||
}
|
||||
else if (v < 0x10000){
|
||||
op = RADDBG_EvalOp_ConstU16;
|
||||
op = RADDBGI_EvalOp_ConstU16;
|
||||
}
|
||||
else if (v < 0x100000000){
|
||||
op = RADDBG_EvalOp_ConstU32;
|
||||
op = RADDBGI_EvalOp_ConstU32;
|
||||
}
|
||||
|
||||
// make the tree node
|
||||
@@ -541,8 +541,8 @@ eval_irtree_const_u(Arena *arena, U64 v){
|
||||
}
|
||||
|
||||
internal EVAL_IRTree*
|
||||
eval_irtree_unary_op(Arena *arena, RADDBG_EvalOp op,
|
||||
RADDBG_EvalTypeGroup group, EVAL_IRTree *c){
|
||||
eval_irtree_unary_op(Arena *arena, RADDBGI_EvalOp op,
|
||||
RADDBGI_EvalTypeGroup group, EVAL_IRTree *c){
|
||||
EVAL_IRTree *result = push_array(arena, EVAL_IRTree, 1);
|
||||
result->op = op;
|
||||
result->p = group;
|
||||
@@ -551,7 +551,7 @@ eval_irtree_unary_op(Arena *arena, RADDBG_EvalOp op,
|
||||
}
|
||||
|
||||
internal EVAL_IRTree*
|
||||
eval_irtree_binary_op(Arena *arena, RADDBG_EvalOp op, RADDBG_EvalTypeGroup group,
|
||||
eval_irtree_binary_op(Arena *arena, RADDBGI_EvalOp op, RADDBGI_EvalTypeGroup group,
|
||||
EVAL_IRTree *l, EVAL_IRTree *r){
|
||||
EVAL_IRTree *result = push_array(arena, EVAL_IRTree, 1);
|
||||
result->op = op;
|
||||
@@ -562,15 +562,15 @@ eval_irtree_binary_op(Arena *arena, RADDBG_EvalOp op, RADDBG_EvalTypeGroup group
|
||||
}
|
||||
|
||||
internal EVAL_IRTree*
|
||||
eval_irtree_binary_op_u(Arena *arena, RADDBG_EvalOp op, EVAL_IRTree *l, EVAL_IRTree *r){
|
||||
EVAL_IRTree *result = eval_irtree_binary_op(arena, op, RADDBG_EvalTypeGroup_U, l, r);
|
||||
eval_irtree_binary_op_u(Arena *arena, RADDBGI_EvalOp op, EVAL_IRTree *l, EVAL_IRTree *r){
|
||||
EVAL_IRTree *result = eval_irtree_binary_op(arena, op, RADDBGI_EvalTypeGroup_U, l, r);
|
||||
return(result);
|
||||
}
|
||||
|
||||
internal EVAL_IRTree*
|
||||
eval_irtree_conditional(Arena *arena, EVAL_IRTree *c, EVAL_IRTree *l, EVAL_IRTree *r){
|
||||
EVAL_IRTree *result = push_array(arena, EVAL_IRTree, 1);
|
||||
result->op = RADDBG_EvalOp_Cond;
|
||||
result->op = RADDBGI_EvalOp_Cond;
|
||||
result->children[0] = c;
|
||||
result->children[1] = l;
|
||||
result->children[2] = r;
|
||||
@@ -589,13 +589,13 @@ eval_irtree_bytecode_no_copy(Arena *arena, String8 bytecode){
|
||||
//~ allen: EVAL IR-Tree High Level Helpers
|
||||
|
||||
internal EVAL_IRTree*
|
||||
eval_irtree_mem_read_type(Arena *arena, TG_Graph *graph, RADDBG_Parsed *rdbg, EVAL_IRTree *c, TG_Key type_key){
|
||||
U64 byte_size = tg_byte_size_from_graph_raddbg_key(graph, rdbg, type_key);
|
||||
eval_irtree_mem_read_type(Arena *arena, TG_Graph *graph, RADDBGI_Parsed *rdbg, EVAL_IRTree *c, TG_Key type_key){
|
||||
U64 byte_size = tg_byte_size_from_graph_raddbgi_key(graph, rdbg, type_key);
|
||||
EVAL_IRTree *result = &eval_irtree_nil;
|
||||
if (0 < byte_size && byte_size <= 8){
|
||||
// build the read node
|
||||
EVAL_IRTree *read_node = push_array(arena, EVAL_IRTree, 1);
|
||||
read_node->op = RADDBG_EvalOp_MemRead;
|
||||
read_node->op = RADDBGI_EvalOp_MemRead;
|
||||
read_node->p = byte_size;
|
||||
read_node->children[0] = c;
|
||||
|
||||
@@ -605,7 +605,7 @@ eval_irtree_mem_read_type(Arena *arena, TG_Graph *graph, RADDBG_Parsed *rdbg, EV
|
||||
TG_Kind kind = tg_kind_from_key(type_key);
|
||||
if (bit_size < 64 && eval_kind_is_signed(kind)){
|
||||
with_trunc = push_array(arena, EVAL_IRTree, 1);
|
||||
with_trunc->op = RADDBG_EvalOp_TruncSigned;
|
||||
with_trunc->op = RADDBGI_EvalOp_TruncSigned;
|
||||
with_trunc->p = bit_size;
|
||||
with_trunc->children[0] = read_node;
|
||||
}
|
||||
@@ -620,23 +620,23 @@ eval_irtree_mem_read_type(Arena *arena, TG_Graph *graph, RADDBG_Parsed *rdbg, EV
|
||||
}
|
||||
|
||||
internal EVAL_IRTree*
|
||||
eval_irtree_convert_lo(Arena *arena, EVAL_IRTree *c, RADDBG_EvalTypeGroup out, RADDBG_EvalTypeGroup in){
|
||||
eval_irtree_convert_lo(Arena *arena, EVAL_IRTree *c, RADDBGI_EvalTypeGroup out, RADDBGI_EvalTypeGroup in){
|
||||
EVAL_IRTree *result = push_array(arena, EVAL_IRTree, 1);
|
||||
result->op = RADDBG_EvalOp_Convert;
|
||||
result->op = RADDBGI_EvalOp_Convert;
|
||||
result->p = in | (out << 8);
|
||||
result->children[0] = c;
|
||||
return(result);
|
||||
}
|
||||
|
||||
internal EVAL_IRTree*
|
||||
eval_irtree_trunc(Arena *arena, TG_Graph *graph, RADDBG_Parsed *rdbg, EVAL_IRTree *c, TG_Key type_key){
|
||||
eval_irtree_trunc(Arena *arena, TG_Graph *graph, RADDBGI_Parsed *rdbg, EVAL_IRTree *c, TG_Key type_key){
|
||||
EVAL_IRTree *result = c;
|
||||
U64 byte_size = tg_byte_size_from_graph_raddbg_key(graph, rdbg, type_key);
|
||||
U64 byte_size = tg_byte_size_from_graph_raddbgi_key(graph, rdbg, type_key);
|
||||
if (byte_size < 64){
|
||||
RADDBG_EvalOp op = RADDBG_EvalOp_Trunc;
|
||||
RADDBGI_EvalOp op = RADDBGI_EvalOp_Trunc;
|
||||
TG_Kind kind = tg_kind_from_key(type_key);
|
||||
if (eval_kind_is_signed(kind)){
|
||||
op = RADDBG_EvalOp_TruncSigned;
|
||||
op = RADDBGI_EvalOp_TruncSigned;
|
||||
}
|
||||
U64 bit_size = byte_size << 3;
|
||||
result = push_array(arena, EVAL_IRTree, 1);
|
||||
@@ -648,19 +648,19 @@ eval_irtree_trunc(Arena *arena, TG_Graph *graph, RADDBG_Parsed *rdbg, EVAL_IRTre
|
||||
}
|
||||
|
||||
internal EVAL_IRTree*
|
||||
eval_irtree_convert_hi(Arena *arena, TG_Graph *graph, RADDBG_Parsed *rdbg, EVAL_IRTree *c, TG_Key out, TG_Key in){
|
||||
eval_irtree_convert_hi(Arena *arena, TG_Graph *graph, RADDBGI_Parsed *rdbg, EVAL_IRTree *c, TG_Key out, TG_Key in){
|
||||
EVAL_IRTree *result = c;
|
||||
TG_Kind in_kind = tg_kind_from_key(in);
|
||||
TG_Kind out_kind = tg_kind_from_key(out);
|
||||
U8 in_group = eval_type_group_from_kind(in_kind);
|
||||
U8 out_group = eval_type_group_from_kind(out_kind);
|
||||
U32 conversion_rule = raddbg_eval_conversion_rule(in_group, out_group);
|
||||
if(conversion_rule == RADDBG_EvalConversionKind_Legal)
|
||||
U32 conversion_rule = raddbgi_eval_conversion_rule(in_group, out_group);
|
||||
if(conversion_rule == RADDBGI_EvalConversionKind_Legal)
|
||||
{
|
||||
result = eval_irtree_convert_lo(arena, result, out_group, in_group);
|
||||
}
|
||||
U64 in_byte_size = tg_byte_size_from_graph_raddbg_key(graph, rdbg, in);
|
||||
U64 out_byte_size = tg_byte_size_from_graph_raddbg_key(graph, rdbg, out);
|
||||
U64 in_byte_size = tg_byte_size_from_graph_raddbgi_key(graph, rdbg, in);
|
||||
U64 out_byte_size = tg_byte_size_from_graph_raddbgi_key(graph, rdbg, out);
|
||||
if(out_byte_size < in_byte_size && eval_kind_is_integer(out_kind))
|
||||
{
|
||||
result = eval_irtree_trunc(arena, graph, rdbg, result, out);
|
||||
@@ -669,7 +669,7 @@ eval_irtree_convert_hi(Arena *arena, TG_Graph *graph, RADDBG_Parsed *rdbg, EVAL_
|
||||
}
|
||||
|
||||
internal EVAL_IRTree*
|
||||
eval_irtree_resolve_to_value(Arena *arena, TG_Graph *graph, RADDBG_Parsed *rdbg, EVAL_EvalMode from_mode,
|
||||
eval_irtree_resolve_to_value(Arena *arena, TG_Graph *graph, RADDBGI_Parsed *rdbg, EVAL_EvalMode from_mode,
|
||||
EVAL_IRTree *tree, TG_Key type_key){
|
||||
EVAL_IRTree *result = tree;
|
||||
switch (from_mode){
|
||||
@@ -680,7 +680,7 @@ eval_irtree_resolve_to_value(Arena *arena, TG_Graph *graph, RADDBG_Parsed *rdbg,
|
||||
}break;
|
||||
case EVAL_EvalMode_Reg:
|
||||
{
|
||||
result = eval_irtree_unary_op(arena, RADDBG_EvalOp_RegReadDyn, RADDBG_EvalTypeGroup_U, tree);
|
||||
result = eval_irtree_unary_op(arena, RADDBGI_EvalOp_RegReadDyn, RADDBGI_EvalTypeGroup_U, tree);
|
||||
}break;
|
||||
}
|
||||
return(result);
|
||||
@@ -715,7 +715,7 @@ eval_push_leaf_ident_exprs_from_expr__in_place(Arena *arena, EVAL_String2ExprMap
|
||||
}
|
||||
|
||||
internal TG_Key
|
||||
eval_type_from_type_expr(Arena *arena, TG_Graph *graph, RADDBG_Parsed *rdbg, EVAL_Expr *expr, EVAL_ErrorList *eout){
|
||||
eval_type_from_type_expr(Arena *arena, TG_Graph *graph, RADDBGI_Parsed *rdbg, EVAL_Expr *expr, EVAL_ErrorList *eout){
|
||||
TG_Key result = zero_struct;
|
||||
|
||||
EVAL_ExprKind kind = expr->kind;
|
||||
@@ -758,7 +758,7 @@ eval_type_from_type_expr(Arena *arena, TG_Graph *graph, RADDBG_Parsed *rdbg, EVA
|
||||
}
|
||||
|
||||
internal EVAL_IRTreeAndType
|
||||
eval_irtree_and_type_from_expr(Arena *arena, TG_Graph *graph, RADDBG_Parsed *rdbg, EVAL_String2ExprMap *leaf_ident_expr_map, EVAL_Expr *expr, EVAL_ErrorList *eout)
|
||||
eval_irtree_and_type_from_expr(Arena *arena, TG_Graph *graph, RADDBGI_Parsed *rdbg, EVAL_String2ExprMap *leaf_ident_expr_map, EVAL_Expr *expr, EVAL_ErrorList *eout)
|
||||
{
|
||||
ProfBeginFunction();
|
||||
EVAL_IRTreeAndType result = {0};
|
||||
@@ -781,8 +781,8 @@ eval_irtree_and_type_from_expr(Arena *arena, TG_Graph *graph, RADDBG_Parsed *rdb
|
||||
EVAL_IRTreeAndType r = eval_irtree_and_type_from_expr(arena, graph, rdbg, leaf_ident_expr_map, exprr, eout);
|
||||
|
||||
if (l.tree->op != 0 && r.tree->op != 0){
|
||||
TG_Key l_restype = tg_unwrapped_from_graph_raddbg_key(graph, rdbg, l.type_key);
|
||||
TG_Key r_restype = tg_unwrapped_from_graph_raddbg_key(graph, rdbg, r.type_key);
|
||||
TG_Key l_restype = tg_unwrapped_from_graph_raddbgi_key(graph, rdbg, l.type_key);
|
||||
TG_Key r_restype = tg_unwrapped_from_graph_raddbgi_key(graph, rdbg, r.type_key);
|
||||
TG_Kind l_restype_kind = tg_kind_from_key(l_restype);
|
||||
TG_Kind r_restype_kind = tg_kind_from_key(r_restype);
|
||||
|
||||
@@ -795,8 +795,8 @@ eval_irtree_and_type_from_expr(Arena *arena, TG_Graph *graph, RADDBG_Parsed *rdb
|
||||
eval_errorf(arena, eout, EVAL_ErrorKind_MalformedInput, exprr->location, "Cannot index with this type.");
|
||||
}
|
||||
else{
|
||||
direct_type = tg_unwrapped_direct_from_graph_raddbg_key(graph, rdbg, l_restype);
|
||||
direct_type_size = tg_byte_size_from_graph_raddbg_key(graph, rdbg, direct_type);
|
||||
direct_type = tg_unwrapped_direct_from_graph_raddbgi_key(graph, rdbg, l_restype);
|
||||
direct_type_size = tg_byte_size_from_graph_raddbgi_key(graph, rdbg, direct_type);
|
||||
if (l_restype_kind == TG_Kind_Ptr){
|
||||
if (direct_type_size == 0){
|
||||
eval_errorf(arena, eout, EVAL_ErrorKind_MalformedInput, exprr->location, "Cannot index into pointers of zero-sized types.");
|
||||
@@ -832,7 +832,7 @@ eval_irtree_and_type_from_expr(Arena *arena, TG_Graph *graph, RADDBG_Parsed *rdb
|
||||
EVAL_IRTree *index_tree = eval_irtree_resolve_to_value(arena, graph, rdbg, r.mode, r.tree, r_restype);
|
||||
if (direct_type_size > 1){
|
||||
EVAL_IRTree *const_tree = eval_irtree_const_u(arena, direct_type_size);
|
||||
index_tree = eval_irtree_binary_op_u(arena, RADDBG_EvalOp_Mul, index_tree, const_tree);
|
||||
index_tree = eval_irtree_binary_op_u(arena, RADDBGI_EvalOp_Mul, index_tree, const_tree);
|
||||
}
|
||||
|
||||
// how to compute the base address
|
||||
@@ -842,7 +842,7 @@ eval_irtree_and_type_from_expr(Arena *arena, TG_Graph *graph, RADDBG_Parsed *rdb
|
||||
}
|
||||
|
||||
// how to compute the final address
|
||||
EVAL_IRTree *new_tree = eval_irtree_binary_op_u(arena, RADDBG_EvalOp_Add, index_tree, base_tree);
|
||||
EVAL_IRTree *new_tree = eval_irtree_binary_op_u(arena, RADDBGI_EvalOp_Add, index_tree, base_tree);
|
||||
|
||||
// fill result
|
||||
result.tree = new_tree;
|
||||
@@ -860,14 +860,14 @@ eval_irtree_and_type_from_expr(Arena *arena, TG_Graph *graph, RADDBG_Parsed *rdb
|
||||
EVAL_IRTreeAndType l = eval_irtree_and_type_from_expr(arena, graph, rdbg, leaf_ident_expr_map, exprl, eout);
|
||||
|
||||
if (l.tree->op != 0 && !tg_key_match(tg_key_zero(), l.type_key)){
|
||||
TG_Key l_restype = tg_unwrapped_from_graph_raddbg_key(graph, rdbg, l.type_key);
|
||||
TG_Key l_restype = tg_unwrapped_from_graph_raddbgi_key(graph, rdbg, l.type_key);
|
||||
TG_Kind l_restype_kind = tg_kind_from_key(l_restype);
|
||||
|
||||
// determine which type to use
|
||||
TG_Key check_type_key = l_restype;
|
||||
TG_Kind check_type_kind = l_restype_kind;
|
||||
if (l_restype_kind == TG_Kind_Ptr || l_restype_kind == TG_Kind_LRef || l_restype_kind == TG_Kind_RRef){
|
||||
check_type_key = tg_unwrapped_direct_from_graph_raddbg_key(graph, rdbg, l_restype);
|
||||
check_type_key = tg_unwrapped_direct_from_graph_raddbgi_key(graph, rdbg, l_restype);
|
||||
check_type_kind = tg_kind_from_key(check_type_key);
|
||||
}
|
||||
|
||||
@@ -921,7 +921,7 @@ eval_irtree_and_type_from_expr(Arena *arena, TG_Graph *graph, RADDBG_Parsed *rdb
|
||||
|
||||
if (l_good && r_good){
|
||||
Temp scratch = scratch_begin(&arena, 1);
|
||||
TG_MemberArray check_type_members = tg_data_members_from_graph_raddbg_key(scratch.arena, graph, rdbg, check_type_key);
|
||||
TG_MemberArray check_type_members = tg_data_members_from_graph_raddbgi_key(scratch.arena, graph, rdbg, check_type_key);
|
||||
|
||||
// lookup member
|
||||
String8 member_name = exprr->name;
|
||||
@@ -957,7 +957,7 @@ eval_irtree_and_type_from_expr(Arena *arena, TG_Graph *graph, RADDBG_Parsed *rdb
|
||||
}
|
||||
if (r_off != 0){
|
||||
EVAL_IRTree *const_tree = eval_irtree_const_u(arena, r_off);
|
||||
new_tree = eval_irtree_binary_op_u(arena, RADDBG_EvalOp_Add, new_tree, const_tree);
|
||||
new_tree = eval_irtree_binary_op_u(arena, RADDBGI_EvalOp_Add, new_tree, const_tree);
|
||||
}
|
||||
|
||||
// fill result
|
||||
@@ -978,10 +978,10 @@ eval_irtree_and_type_from_expr(Arena *arena, TG_Graph *graph, RADDBG_Parsed *rdb
|
||||
EVAL_IRTreeAndType c = eval_irtree_and_type_from_expr(arena, graph, rdbg, leaf_ident_expr_map, exprc, eout);
|
||||
|
||||
if (c.tree->op != 0){
|
||||
TG_Key c_restype = tg_unwrapped_from_graph_raddbg_key(graph, rdbg, c.type_key);
|
||||
TG_Key c_restype = tg_unwrapped_from_graph_raddbgi_key(graph, rdbg, c.type_key);
|
||||
TG_Kind c_restype_kind = tg_kind_from_key(c_restype);
|
||||
TG_Key c_restype_direct = tg_unwrapped_direct_from_graph_raddbg_key(graph, rdbg, c_restype);
|
||||
U64 c_restype_direct_size = tg_byte_size_from_graph_raddbg_key(graph, rdbg, c_restype_direct);
|
||||
TG_Key c_restype_direct = tg_unwrapped_direct_from_graph_raddbgi_key(graph, rdbg, c_restype);
|
||||
U64 c_restype_direct_size = tg_byte_size_from_graph_raddbgi_key(graph, rdbg, c_restype_direct);
|
||||
|
||||
// analyze situation
|
||||
B32 can_generate = 0;
|
||||
@@ -1035,7 +1035,7 @@ eval_irtree_and_type_from_expr(Arena *arena, TG_Graph *graph, RADDBG_Parsed *rdb
|
||||
EVAL_IRTreeAndType c = eval_irtree_and_type_from_expr(arena, graph, rdbg, leaf_ident_expr_map, exprc, eout);
|
||||
if(c.tree->op != 0 && !tg_key_match(c.type_key, tg_key_zero()))
|
||||
{
|
||||
TG_Key c_restype = tg_unwrapped_from_graph_raddbg_key(graph, rdbg, c.type_key);
|
||||
TG_Key c_restype = tg_unwrapped_from_graph_raddbgi_key(graph, rdbg, c.type_key);
|
||||
TG_Kind c_restype_kind = tg_kind_from_key(c_restype);
|
||||
|
||||
// analyze situation
|
||||
@@ -1070,26 +1070,26 @@ eval_irtree_and_type_from_expr(Arena *arena, TG_Graph *graph, RADDBG_Parsed *rdb
|
||||
|
||||
if(cast_type_kind != TG_Kind_Null && c.tree->op != 0)
|
||||
{
|
||||
TG_Key c_restype = tg_unwrapped_from_graph_raddbg_key(graph, rdbg, c.type_key);
|
||||
TG_Key c_restype = tg_unwrapped_from_graph_raddbgi_key(graph, rdbg, c.type_key);
|
||||
TG_Kind c_restype_kind = tg_kind_from_key(c_restype);
|
||||
U64 c_restype_byte_size = tg_byte_size_from_graph_raddbg_key(graph, rdbg, c_restype);
|
||||
U64 cast_type_byte_size = tg_byte_size_from_graph_raddbg_key(graph, rdbg, cast_type_key);
|
||||
U64 c_restype_byte_size = tg_byte_size_from_graph_raddbgi_key(graph, rdbg, c_restype);
|
||||
U64 cast_type_byte_size = tg_byte_size_from_graph_raddbgi_key(graph, rdbg, cast_type_key);
|
||||
|
||||
// analyze situation
|
||||
U8 in_group = eval_type_group_from_kind(c_restype_kind);
|
||||
U8 out_group = eval_type_group_from_kind(cast_type_kind);
|
||||
RADDBG_EvalConversionKind conversion_rule = raddbg_eval_conversion_rule(in_group, out_group);
|
||||
RADDBGI_EvalConversionKind conversion_rule = raddbgi_eval_conversion_rule(in_group, out_group);
|
||||
|
||||
// generate tree
|
||||
switch(conversion_rule)
|
||||
{
|
||||
case RADDBG_EvalConversionKind_Noop:
|
||||
case RADDBG_EvalConversionKind_Legal:
|
||||
case RADDBGI_EvalConversionKind_Noop:
|
||||
case RADDBGI_EvalConversionKind_Legal:
|
||||
{
|
||||
EVAL_IRTree *in_tree = eval_irtree_resolve_to_value(arena, graph, rdbg, c.mode, c.tree, c_restype);
|
||||
|
||||
EVAL_IRTree *new_tree = in_tree;
|
||||
if (conversion_rule == RADDBG_EvalConversionKind_Legal){
|
||||
if (conversion_rule == RADDBGI_EvalConversionKind_Legal){
|
||||
new_tree = eval_irtree_convert_lo(arena, in_tree, out_group, in_group);
|
||||
}
|
||||
if (cast_type_byte_size < c_restype_byte_size && eval_kind_is_integer(cast_type_kind)){
|
||||
@@ -1104,8 +1104,8 @@ eval_irtree_and_type_from_expr(Arena *arena, TG_Graph *graph, RADDBG_Parsed *rdb
|
||||
default:
|
||||
{
|
||||
String8 text = str8_lit("(internal) unknown conversion rule");
|
||||
if (conversion_rule < RADDBG_EvalConversionKind_COUNT){
|
||||
text.str = raddbg_eval_conversion_message(conversion_rule, &text.size);
|
||||
if (conversion_rule < RADDBGI_EvalConversionKind_COUNT){
|
||||
text.str = raddbgi_eval_conversion_message(conversion_rule, &text.size);
|
||||
}
|
||||
eval_error(arena, eout, EVAL_ErrorKind_MalformedInput, expr->location, text);
|
||||
}break;
|
||||
@@ -1141,7 +1141,7 @@ eval_irtree_and_type_from_expr(Arena *arena, TG_Graph *graph, RADDBG_Parsed *rdb
|
||||
TG_Kind type_kind = tg_kind_from_key(type_key);
|
||||
if (type_kind != TG_Kind_Null){
|
||||
can_generate = 1;
|
||||
size = tg_byte_size_from_graph_raddbg_key(graph, rdbg, type_key);
|
||||
size = tg_byte_size_from_graph_raddbgi_key(graph, rdbg, type_key);
|
||||
}
|
||||
|
||||
// generate ir tree
|
||||
@@ -1162,15 +1162,15 @@ eval_irtree_and_type_from_expr(Arena *arena, TG_Graph *graph, RADDBG_Parsed *rdb
|
||||
|
||||
EVAL_IRTreeAndType c = eval_irtree_and_type_from_expr(arena, graph, rdbg, leaf_ident_expr_map, exprc, eout);
|
||||
if (c.tree->op != 0){
|
||||
TG_Key c_restype = tg_unwrapped_from_graph_raddbg_key(graph, rdbg, c.type_key);
|
||||
TG_Key c_restype = tg_unwrapped_from_graph_raddbgi_key(graph, rdbg, c.type_key);
|
||||
TG_Key p_type = eval_type_promote(graph, rdbg, c_restype);
|
||||
TG_Kind c_restype_kind = tg_kind_from_key(c_restype);
|
||||
|
||||
// analyze situation
|
||||
B32 can_generate = 0;
|
||||
RADDBG_EvalOp op = eval_opcode_from_expr_kind(kind);
|
||||
RADDBGI_EvalOp op = eval_opcode_from_expr_kind(kind);
|
||||
U8 c_group = eval_type_group_from_kind(c_restype_kind);
|
||||
if (!raddbg_eval_opcode_type_compatible(op, c_group)){
|
||||
if (!raddbgi_eval_opcode_type_compatible(op, c_group)){
|
||||
eval_errorf(arena, eout, EVAL_ErrorKind_MalformedInput, expr->location, "Cannot use this operator on this type.");
|
||||
}
|
||||
else{
|
||||
@@ -1218,8 +1218,8 @@ eval_irtree_and_type_from_expr(Arena *arena, TG_Graph *graph, RADDBG_Parsed *rdb
|
||||
EVAL_IRTreeAndType r = eval_irtree_and_type_from_expr(arena, graph, rdbg, leaf_ident_expr_map, exprr, eout);
|
||||
|
||||
if (l.tree->op != 0 && r.tree->op != 0){
|
||||
TG_Key l_restype = tg_unwrapped_from_graph_raddbg_key(graph, rdbg, l.type_key);
|
||||
TG_Key r_restype = tg_unwrapped_from_graph_raddbg_key(graph, rdbg, r.type_key);
|
||||
TG_Key l_restype = tg_unwrapped_from_graph_raddbgi_key(graph, rdbg, l.type_key);
|
||||
TG_Key r_restype = tg_unwrapped_from_graph_raddbgi_key(graph, rdbg, r.type_key);
|
||||
TG_Kind l_restype_kind = tg_kind_from_key(l_restype);
|
||||
TG_Kind r_restype_kind = tg_kind_from_key(r_restype);
|
||||
|
||||
@@ -1235,7 +1235,7 @@ eval_irtree_and_type_from_expr(Arena *arena, TG_Graph *graph, RADDBG_Parsed *rdb
|
||||
r_restype_kind = tg_kind_from_key(r_restype);
|
||||
}
|
||||
|
||||
RADDBG_EvalOp op = eval_opcode_from_expr_kind(kind);
|
||||
RADDBGI_EvalOp op = eval_opcode_from_expr_kind(kind);
|
||||
|
||||
//- pointer decay
|
||||
B32 l_is_pointer = (l_restype_kind == TG_Kind_Ptr);
|
||||
@@ -1267,10 +1267,10 @@ eval_irtree_and_type_from_expr(Arena *arena, TG_Graph *graph, RADDBG_Parsed *rdb
|
||||
arith_path = EVAL_ArithPath_PtrAdd;
|
||||
}
|
||||
if (l_is_pointer_like && r_is_pointer_like){
|
||||
TG_Key l_restype_direct = tg_unwrapped_direct_from_graph_raddbg_key(graph, rdbg, l_restype);
|
||||
TG_Key r_restype_direct = tg_unwrapped_direct_from_graph_raddbg_key(graph, rdbg, r_restype);
|
||||
U64 l_restype_direct_byte_size = tg_byte_size_from_graph_raddbg_key(graph, rdbg, l_restype_direct);
|
||||
U64 r_restype_direct_byte_size = tg_byte_size_from_graph_raddbg_key(graph, rdbg, r_restype_direct);
|
||||
TG_Key l_restype_direct = tg_unwrapped_direct_from_graph_raddbgi_key(graph, rdbg, l_restype);
|
||||
TG_Key r_restype_direct = tg_unwrapped_direct_from_graph_raddbgi_key(graph, rdbg, r_restype);
|
||||
U64 l_restype_direct_byte_size = tg_byte_size_from_graph_raddbgi_key(graph, rdbg, l_restype_direct);
|
||||
U64 r_restype_direct_byte_size = tg_byte_size_from_graph_raddbgi_key(graph, rdbg, r_restype_direct);
|
||||
if (l_restype_direct_byte_size == r_restype_direct_byte_size){
|
||||
arith_path = EVAL_ArithPath_PtrSub;
|
||||
}
|
||||
@@ -1299,7 +1299,7 @@ eval_irtree_and_type_from_expr(Arena *arena, TG_Graph *graph, RADDBG_Parsed *rdb
|
||||
U8 cv_group = eval_type_group_from_kind(cv_type_kind);
|
||||
|
||||
B32 can_generate = 0;
|
||||
if (raddbg_eval_opcode_type_compatible(op, cv_group)){
|
||||
if (raddbgi_eval_opcode_type_compatible(op, cv_group)){
|
||||
can_generate = 1;
|
||||
}
|
||||
else{
|
||||
@@ -1339,8 +1339,8 @@ eval_irtree_and_type_from_expr(Arena *arena, TG_Graph *graph, RADDBG_Parsed *rdb
|
||||
ptr_is_decay = r_is_decay;
|
||||
}
|
||||
|
||||
TG_Key direct = tg_unwrapped_direct_from_graph_raddbg_key(graph, rdbg, ptr->type_key);
|
||||
U64 direct_type_size = tg_byte_size_from_graph_raddbg_key(graph, rdbg, direct);
|
||||
TG_Key direct = tg_unwrapped_direct_from_graph_raddbgi_key(graph, rdbg, ptr->type_key);
|
||||
U64 direct_type_size = tg_byte_size_from_graph_raddbgi_key(graph, rdbg, direct);
|
||||
|
||||
// generate ir tree
|
||||
EVAL_IRTree *ptr_tree = ptr->tree;
|
||||
@@ -1351,7 +1351,7 @@ eval_irtree_and_type_from_expr(Arena *arena, TG_Graph *graph, RADDBG_Parsed *rdb
|
||||
EVAL_IRTree *integer_tree = eval_irtree_resolve_to_value(arena, graph, rdbg, integer->mode, integer->tree, integer->type_key);
|
||||
if (direct_type_size > 1){
|
||||
EVAL_IRTree *const_tree = eval_irtree_const_u(arena, direct_type_size);
|
||||
integer_tree = eval_irtree_binary_op_u(arena, RADDBG_EvalOp_Mul, integer_tree, const_tree);
|
||||
integer_tree = eval_irtree_binary_op_u(arena, RADDBGI_EvalOp_Mul, integer_tree, const_tree);
|
||||
}
|
||||
|
||||
TG_Key ptr_type = ptr->type_key;
|
||||
@@ -1359,7 +1359,7 @@ eval_irtree_and_type_from_expr(Arena *arena, TG_Graph *graph, RADDBG_Parsed *rdb
|
||||
ptr_type = tg_cons_type_make(graph, TG_Kind_Ptr, direct, 0);
|
||||
}
|
||||
|
||||
EVAL_IRTree *new_tree = eval_irtree_binary_op(arena, op, RADDBG_EvalTypeGroup_U, ptr_tree, integer_tree);
|
||||
EVAL_IRTree *new_tree = eval_irtree_binary_op(arena, op, RADDBGI_EvalTypeGroup_U, ptr_tree, integer_tree);
|
||||
|
||||
result.tree = new_tree;
|
||||
result.type_key = ptr_type;
|
||||
@@ -1368,8 +1368,8 @@ eval_irtree_and_type_from_expr(Arena *arena, TG_Graph *graph, RADDBG_Parsed *rdb
|
||||
|
||||
case EVAL_ArithPath_PtrSub:
|
||||
{
|
||||
TG_Key direct = tg_unwrapped_direct_from_graph_raddbg_key(graph, rdbg, l_restype);
|
||||
U64 direct_type_size = tg_byte_size_from_graph_raddbg_key(graph, rdbg, direct);
|
||||
TG_Key direct = tg_unwrapped_direct_from_graph_raddbgi_key(graph, rdbg, l_restype);
|
||||
U64 direct_type_size = tg_byte_size_from_graph_raddbgi_key(graph, rdbg, direct);
|
||||
|
||||
// generate ir tree
|
||||
EVAL_IRTree *l_tree = l.tree;
|
||||
@@ -1382,12 +1382,12 @@ eval_irtree_and_type_from_expr(Arena *arena, TG_Graph *graph, RADDBG_Parsed *rdb
|
||||
r_tree = eval_irtree_resolve_to_value(arena, graph, rdbg, r.mode, r.tree, r_restype);
|
||||
}
|
||||
|
||||
EVAL_IRTree *op_tree = eval_irtree_binary_op(arena, op, RADDBG_EvalTypeGroup_U, l_tree, r_tree);
|
||||
EVAL_IRTree *op_tree = eval_irtree_binary_op(arena, op, RADDBGI_EvalTypeGroup_U, l_tree, r_tree);
|
||||
|
||||
EVAL_IRTree *new_tree = op_tree;
|
||||
if (direct_type_size > 1){
|
||||
EVAL_IRTree *const_tree = eval_irtree_const_u(arena, direct_type_size);
|
||||
new_tree = eval_irtree_binary_op(arena, RADDBG_EvalOp_Div, RADDBG_EvalTypeGroup_U, new_tree, const_tree);
|
||||
new_tree = eval_irtree_binary_op(arena, RADDBGI_EvalOp_Div, RADDBGI_EvalTypeGroup_U, new_tree, const_tree);
|
||||
}
|
||||
|
||||
result.tree = new_tree;
|
||||
@@ -1410,9 +1410,9 @@ eval_irtree_and_type_from_expr(Arena *arena, TG_Graph *graph, RADDBG_Parsed *rdb
|
||||
|
||||
if (l.tree->op != 0 && r.tree->op != 0 && c.tree->op != 0){
|
||||
|
||||
TG_Key c_restype = tg_unwrapped_from_graph_raddbg_key(graph, rdbg, c.type_key);
|
||||
TG_Key l_restype = tg_unwrapped_from_graph_raddbg_key(graph, rdbg, l.type_key);
|
||||
TG_Key r_restype = tg_unwrapped_from_graph_raddbg_key(graph, rdbg, r.type_key);
|
||||
TG_Key c_restype = tg_unwrapped_from_graph_raddbgi_key(graph, rdbg, c.type_key);
|
||||
TG_Key l_restype = tg_unwrapped_from_graph_raddbgi_key(graph, rdbg, l.type_key);
|
||||
TG_Key r_restype = tg_unwrapped_from_graph_raddbgi_key(graph, rdbg, r.type_key);
|
||||
TG_Kind c_restype_kind = tg_kind_from_key(c_restype);
|
||||
TG_Kind l_restype_kind = tg_kind_from_key(l_restype);
|
||||
TG_Kind r_restype_kind = tg_kind_from_key(r_restype);
|
||||
@@ -1568,8 +1568,8 @@ eval_oplist_from_irtree(Arena *arena, EVAL_IRTree *tree, EVAL_OpList *out){
|
||||
ProfBeginFunction();
|
||||
U32 op = tree->op;
|
||||
switch (op){
|
||||
case RADDBG_EvalOp_Stop:
|
||||
case RADDBG_EvalOp_Skip:
|
||||
case RADDBGI_EvalOp_Stop:
|
||||
case RADDBGI_EvalOp_Skip:
|
||||
{
|
||||
// TODO: error - invalid ir-tree op
|
||||
}break;
|
||||
@@ -1579,7 +1579,7 @@ eval_oplist_from_irtree(Arena *arena, EVAL_IRTree *tree, EVAL_OpList *out){
|
||||
eval_oplist_push_bytecode(arena, out, tree->bytecode);
|
||||
}break;
|
||||
|
||||
case RADDBG_EvalOp_Cond:
|
||||
case RADDBGI_EvalOp_Cond:
|
||||
{
|
||||
// split out each of the children
|
||||
EVAL_OpList prt_cond = {0};
|
||||
@@ -1598,11 +1598,11 @@ eval_oplist_from_irtree(Arena *arena, EVAL_IRTree *tree, EVAL_OpList *out){
|
||||
// 4.
|
||||
|
||||
// modify prt_right in place to create step 2
|
||||
eval_oplist_push_op(arena, &prt_right, RADDBG_EvalOp_Skip, prt_left.encoded_size);
|
||||
eval_oplist_push_op(arena, &prt_right, RADDBGI_EvalOp_Skip, prt_left.encoded_size);
|
||||
|
||||
// merge 1 into out
|
||||
eval_oplist_concat_in_place(out, &prt_cond);
|
||||
eval_oplist_push_op(arena, out, RADDBG_EvalOp_Cond, prt_right.encoded_size);
|
||||
eval_oplist_push_op(arena, out, RADDBGI_EvalOp_Cond, prt_right.encoded_size);
|
||||
|
||||
// merge 2 into out
|
||||
eval_oplist_concat_in_place(out, &prt_right);
|
||||
@@ -1613,20 +1613,20 @@ eval_oplist_from_irtree(Arena *arena, EVAL_IRTree *tree, EVAL_OpList *out){
|
||||
|
||||
default:
|
||||
{
|
||||
if (op >= RADDBG_EvalOp_COUNT){
|
||||
if (op >= RADDBGI_EvalOp_COUNT){
|
||||
// TODO: error - invalid ir-tree op
|
||||
}
|
||||
else{
|
||||
// handle all children
|
||||
U8 ctrlbits = raddbg_eval_opcode_ctrlbits[op];
|
||||
U64 child_count = RADDBG_POPN_FROM_CTRLBITS(ctrlbits);
|
||||
U8 ctrlbits = raddbgi_eval_opcode_ctrlbits[op];
|
||||
U64 child_count = RADDBGI_POPN_FROM_CTRLBITS(ctrlbits);
|
||||
EVAL_IRTree**child = tree->children;
|
||||
for (U64 i = 0; i < child_count; i += 1, child += 1){
|
||||
eval_oplist_from_irtree(arena, *child, out);
|
||||
}
|
||||
|
||||
// emit op to compute this node
|
||||
eval_oplist_push_op(arena, out, (RADDBG_EvalOp)tree->op, tree->p);
|
||||
eval_oplist_push_op(arena, out, (RADDBGI_EvalOp)tree->op, tree->p);
|
||||
}
|
||||
}break;
|
||||
}
|
||||
|
||||
+18
-18
@@ -9,7 +9,7 @@
|
||||
|
||||
internal String8 eval_bytecode_from_oplist(Arena *arena, EVAL_OpList *list);
|
||||
|
||||
internal void eval_oplist_push_op(Arena *arena, EVAL_OpList *list, RADDBG_EvalOp op, U64 p);
|
||||
internal void eval_oplist_push_op(Arena *arena, EVAL_OpList *list, RADDBGI_EvalOp op, U64 p);
|
||||
internal void eval_oplist_push_uconst(Arena *arena, EVAL_OpList *list, U64 x);
|
||||
internal void eval_oplist_push_sconst(Arena *arena, EVAL_OpList *list, S64 x);
|
||||
|
||||
@@ -20,8 +20,8 @@ internal void eval_oplist_concat_in_place(EVAL_OpList *left_dst, EVAL_OpList *ri
|
||||
////////////////////////////////
|
||||
//~ allen: EVAL Expression Info Functions
|
||||
|
||||
internal RADDBG_EvalOp eval_opcode_from_expr_kind(EVAL_ExprKind kind);
|
||||
internal B32 eval_expr_kind_is_comparison(EVAL_ExprKind kind);
|
||||
internal RADDBGI_EvalOp eval_opcode_from_expr_kind(EVAL_ExprKind kind);
|
||||
internal B32 eval_expr_kind_is_comparison(EVAL_ExprKind kind);
|
||||
|
||||
////////////////////////////////
|
||||
//~ allen: EVAL Expression Constructors
|
||||
@@ -40,13 +40,13 @@ internal EVAL_Expr* eval_expr_leaf_type(Arena *arena, void *location, TG_Key typ
|
||||
////////////////////////////////
|
||||
//~ allen: EVAL Type Information Transformers
|
||||
|
||||
internal RADDBG_EvalTypeGroup eval_type_group_from_kind(TG_Kind kind);
|
||||
internal RADDBGI_EvalTypeGroup eval_type_group_from_kind(TG_Kind kind);
|
||||
|
||||
internal TG_Key eval_type_unwrap_enum(TG_Graph *graph, RADDBG_Parsed *rdbg, TG_Key key);
|
||||
internal TG_Key eval_type_promote(TG_Graph *graph, RADDBG_Parsed *rdbg, TG_Key key);
|
||||
internal TG_Key eval_type_coerce(TG_Graph *graph, RADDBG_Parsed *rdbg, TG_Key l, TG_Key r);
|
||||
internal TG_Key eval_type_unwrap_enum(TG_Graph *graph, RADDBGI_Parsed *rdbg, TG_Key key);
|
||||
internal TG_Key eval_type_promote(TG_Graph *graph, RADDBGI_Parsed *rdbg, TG_Key key);
|
||||
internal TG_Key eval_type_coerce(TG_Graph *graph, RADDBGI_Parsed *rdbg, TG_Key l, TG_Key r);
|
||||
|
||||
internal B32 eval_type_match(TG_Graph *graph, RADDBG_Parsed *rdbg, TG_Key l, TG_Key r);
|
||||
internal B32 eval_type_match(TG_Graph *graph, RADDBGI_Parsed *rdbg, TG_Key l, TG_Key r);
|
||||
|
||||
internal B32 eval_kind_is_integer(TG_Kind kind);
|
||||
internal B32 eval_kind_is_signed(TG_Kind kind);
|
||||
@@ -56,27 +56,27 @@ internal B32 eval_kind_is_basic_or_enum(TG_Kind kind);
|
||||
//~ allen: EVAL IR-Tree Constructors
|
||||
|
||||
internal EVAL_IRTree* eval_irtree_const_u(Arena *arena, U64 v);
|
||||
internal EVAL_IRTree* eval_irtree_unary_op(Arena *arena, RADDBG_EvalOp op, RADDBG_EvalTypeGroup group, EVAL_IRTree *c);
|
||||
internal EVAL_IRTree* eval_irtree_binary_op(Arena *arena, RADDBG_EvalOp op, RADDBG_EvalTypeGroup group, EVAL_IRTree *l, EVAL_IRTree *r);
|
||||
internal EVAL_IRTree* eval_irtree_binary_op_u(Arena *arena, RADDBG_EvalOp op, EVAL_IRTree *l, EVAL_IRTree *r);
|
||||
internal EVAL_IRTree* eval_irtree_unary_op(Arena *arena, RADDBGI_EvalOp op, RADDBGI_EvalTypeGroup group, EVAL_IRTree *c);
|
||||
internal EVAL_IRTree* eval_irtree_binary_op(Arena *arena, RADDBGI_EvalOp op, RADDBGI_EvalTypeGroup group, EVAL_IRTree *l, EVAL_IRTree *r);
|
||||
internal EVAL_IRTree* eval_irtree_binary_op_u(Arena *arena, RADDBGI_EvalOp op, EVAL_IRTree *l, EVAL_IRTree *r);
|
||||
internal EVAL_IRTree* eval_irtree_conditional(Arena *arena, EVAL_IRTree *c, EVAL_IRTree *l, EVAL_IRTree *r);
|
||||
internal EVAL_IRTree* eval_irtree_bytecode_no_copy(Arena *arena, String8 bytecode);
|
||||
|
||||
////////////////////////////////
|
||||
//~ allen: EVAL IR-Tree High Level Helpers
|
||||
|
||||
internal EVAL_IRTree* eval_irtree_mem_read_type(Arena *arena, TG_Graph *graph, RADDBG_Parsed *rdbg, EVAL_IRTree *c, TG_Key type_key);
|
||||
internal EVAL_IRTree* eval_irtree_convert_lo(Arena *arena, EVAL_IRTree *c, RADDBG_EvalTypeGroup out, RADDBG_EvalTypeGroup in);
|
||||
internal EVAL_IRTree* eval_irtree_trunc(Arena *arena, TG_Graph *graph, RADDBG_Parsed *rdbg, EVAL_IRTree *c, TG_Key type_key);
|
||||
internal EVAL_IRTree* eval_irtree_convert_hi(Arena *arena, TG_Graph *graph, RADDBG_Parsed *rdbg, EVAL_IRTree *c, TG_Key out, TG_Key in);
|
||||
internal EVAL_IRTree* eval_irtree_resolve_to_value(Arena *arena, TG_Graph *graph, RADDBG_Parsed *rdbg, EVAL_EvalMode from_mode, EVAL_IRTree *tree, TG_Key type_key);
|
||||
internal EVAL_IRTree* eval_irtree_mem_read_type(Arena *arena, TG_Graph *graph, RADDBGI_Parsed *rdbg, EVAL_IRTree *c, TG_Key type_key);
|
||||
internal EVAL_IRTree* eval_irtree_convert_lo(Arena *arena, EVAL_IRTree *c, RADDBGI_EvalTypeGroup out, RADDBGI_EvalTypeGroup in);
|
||||
internal EVAL_IRTree* eval_irtree_trunc(Arena *arena, TG_Graph *graph, RADDBGI_Parsed *rdbg, EVAL_IRTree *c, TG_Key type_key);
|
||||
internal EVAL_IRTree* eval_irtree_convert_hi(Arena *arena, TG_Graph *graph, RADDBGI_Parsed *rdbg, EVAL_IRTree *c, TG_Key out, TG_Key in);
|
||||
internal EVAL_IRTree* eval_irtree_resolve_to_value(Arena *arena, TG_Graph *graph, RADDBGI_Parsed *rdbg, EVAL_EvalMode from_mode, EVAL_IRTree *tree, TG_Key type_key);
|
||||
|
||||
////////////////////////////////
|
||||
//~ allen: EVAL Compiler Phases
|
||||
|
||||
internal void eval_push_leaf_ident_exprs_from_expr__in_place(Arena *arena, EVAL_String2ExprMap *map, EVAL_Expr *expr, EVAL_ErrorList *eout);
|
||||
internal TG_Key eval_type_from_type_expr(Arena *arena, TG_Graph *graph, RADDBG_Parsed *rdbg, EVAL_Expr *expr, EVAL_ErrorList *eout);
|
||||
internal EVAL_IRTreeAndType eval_irtree_and_type_from_expr(Arena *arena, TG_Graph *graph, RADDBG_Parsed *rdbg, EVAL_String2ExprMap *leaf_ident_expr_map, EVAL_Expr *expr, EVAL_ErrorList *eout);
|
||||
internal TG_Key eval_type_from_type_expr(Arena *arena, TG_Graph *graph, RADDBGI_Parsed *rdbg, EVAL_Expr *expr, EVAL_ErrorList *eout);
|
||||
internal EVAL_IRTreeAndType eval_irtree_and_type_from_expr(Arena *arena, TG_Graph *graph, RADDBGI_Parsed *rdbg, EVAL_String2ExprMap *leaf_ident_expr_map, EVAL_Expr *expr, EVAL_ErrorList *eout);
|
||||
internal void eval_oplist_from_irtree(Arena *arena, EVAL_IRTree *tree, EVAL_OpList *out);
|
||||
|
||||
#endif //EVAL_COMPILER_H
|
||||
|
||||
@@ -41,7 +41,7 @@ struct EVAL_ErrorList
|
||||
|
||||
enum
|
||||
{
|
||||
EVAL_IRExtKind_Bytecode = RADDBG_EvalOp_COUNT,
|
||||
EVAL_IRExtKind_Bytecode = RADDBGI_EvalOp_COUNT,
|
||||
EVAL_IRExtKind_COUNT
|
||||
};
|
||||
|
||||
@@ -49,7 +49,7 @@ typedef struct EVAL_Op EVAL_Op;
|
||||
struct EVAL_Op
|
||||
{
|
||||
EVAL_Op *next;
|
||||
RADDBG_EvalOp opcode;
|
||||
RADDBGI_EvalOp opcode;
|
||||
union
|
||||
{
|
||||
U64 p;
|
||||
@@ -115,7 +115,7 @@ struct EVAL_Expr
|
||||
|
||||
typedef struct EVAL_IRTree EVAL_IRTree;
|
||||
struct EVAL_IRTree{
|
||||
RADDBG_EvalOp op;
|
||||
RADDBGI_EvalOp op;
|
||||
EVAL_IRTree *children[3];
|
||||
union{
|
||||
U64 p;
|
||||
|
||||
+113
-113
@@ -22,18 +22,18 @@ eval_interpret(EVAL_Machine *machine, String8 bytecode)
|
||||
|
||||
for (;ptr < opl;){
|
||||
// consume opcode
|
||||
RADDBG_EvalOp op = (RADDBG_EvalOp)*ptr;
|
||||
if (op >= RADDBG_EvalOp_COUNT){
|
||||
RADDBGI_EvalOp op = (RADDBGI_EvalOp)*ptr;
|
||||
if (op >= RADDBGI_EvalOp_COUNT){
|
||||
result.code = EVAL_ResultCode_BadOp;
|
||||
goto done;
|
||||
}
|
||||
U8 ctrlbits = raddbg_eval_opcode_ctrlbits[op];
|
||||
U8 ctrlbits = raddbgi_eval_opcode_ctrlbits[op];
|
||||
ptr += 1;
|
||||
|
||||
// decode
|
||||
U64 imm = 0;
|
||||
{
|
||||
U32 decode_size = RADDBG_DECODEN_FROM_CTRLBITS(ctrlbits);
|
||||
U32 decode_size = RADDBGI_DECODEN_FROM_CTRLBITS(ctrlbits);
|
||||
U8 *next_ptr = ptr + decode_size;
|
||||
if (next_ptr > opl){
|
||||
result.code = EVAL_ResultCode_BadOp;
|
||||
@@ -54,7 +54,7 @@ eval_interpret(EVAL_Machine *machine, String8 bytecode)
|
||||
// pop
|
||||
EVAL_Slot *svals = 0;
|
||||
{
|
||||
U32 pop_count = RADDBG_POPN_FROM_CTRLBITS(ctrlbits);
|
||||
U32 pop_count = RADDBGI_POPN_FROM_CTRLBITS(ctrlbits);
|
||||
if (pop_count > stack_count){
|
||||
result.code = EVAL_ResultCode_BadOp;
|
||||
goto done;
|
||||
@@ -68,29 +68,29 @@ eval_interpret(EVAL_Machine *machine, String8 bytecode)
|
||||
// interpret
|
||||
EVAL_Slot nval = {0};
|
||||
switch (op){
|
||||
case RADDBG_EvalOp_Stop:
|
||||
case RADDBGI_EvalOp_Stop:
|
||||
{
|
||||
goto done;
|
||||
}break;
|
||||
|
||||
case RADDBG_EvalOp_Noop:
|
||||
case RADDBGI_EvalOp_Noop:
|
||||
{
|
||||
// do nothing
|
||||
}break;
|
||||
|
||||
case RADDBG_EvalOp_Cond:
|
||||
case RADDBGI_EvalOp_Cond:
|
||||
{
|
||||
if (svals[0].u64){
|
||||
ptr += imm;
|
||||
}
|
||||
}break;
|
||||
|
||||
case RADDBG_EvalOp_Skip:
|
||||
case RADDBGI_EvalOp_Skip:
|
||||
{
|
||||
ptr += imm;
|
||||
}break;
|
||||
|
||||
case RADDBG_EvalOp_MemRead:
|
||||
case RADDBGI_EvalOp_MemRead:
|
||||
{
|
||||
U64 addr = svals[0].u64;
|
||||
U64 size = imm;
|
||||
@@ -105,12 +105,12 @@ eval_interpret(EVAL_Machine *machine, String8 bytecode)
|
||||
}
|
||||
}break;
|
||||
|
||||
case RADDBG_EvalOp_RegRead:
|
||||
case RADDBGI_EvalOp_RegRead:
|
||||
{
|
||||
U8 raddbg_reg_code = (imm&0x0000FF)>>0;
|
||||
U8 byte_size = (imm&0x00FF00)>>8;
|
||||
U8 byte_off = (imm&0xFF0000)>>16;
|
||||
REGS_RegCode base_reg_code = regs_reg_code_from_arch_raddbg_code(machine->arch, raddbg_reg_code);
|
||||
U8 raddbgi_reg_code = (imm&0x0000FF)>>0;
|
||||
U8 byte_size = (imm&0x00FF00)>>8;
|
||||
U8 byte_off = (imm&0xFF0000)>>16;
|
||||
REGS_RegCode base_reg_code = regs_reg_code_from_arch_raddbgi_code(machine->arch, raddbgi_reg_code);
|
||||
REGS_Rng rng = regs_reg_code_rng_table_from_architecture(machine->arch)[base_reg_code];
|
||||
U64 off = (U64)rng.byte_off + byte_off;
|
||||
U64 size = (U64)byte_size;
|
||||
@@ -123,7 +123,7 @@ eval_interpret(EVAL_Machine *machine, String8 bytecode)
|
||||
}
|
||||
}break;
|
||||
|
||||
case RADDBG_EvalOp_RegReadDyn:
|
||||
case RADDBGI_EvalOp_RegReadDyn:
|
||||
{
|
||||
U64 off = svals[0].u64;
|
||||
U64 size = bit_size_from_arch(machine->arch)/8;
|
||||
@@ -136,7 +136,7 @@ eval_interpret(EVAL_Machine *machine, String8 bytecode)
|
||||
}
|
||||
}break;
|
||||
|
||||
case RADDBG_EvalOp_FrameOff:
|
||||
case RADDBGI_EvalOp_FrameOff:
|
||||
{
|
||||
if (machine->frame_base != 0){
|
||||
nval.u64 = *machine->frame_base + imm;
|
||||
@@ -147,7 +147,7 @@ eval_interpret(EVAL_Machine *machine, String8 bytecode)
|
||||
}
|
||||
}break;
|
||||
|
||||
case RADDBG_EvalOp_ModuleOff:
|
||||
case RADDBGI_EvalOp_ModuleOff:
|
||||
{
|
||||
if (machine->module_base != 0){
|
||||
nval.u64 = *machine->module_base + imm;
|
||||
@@ -158,7 +158,7 @@ eval_interpret(EVAL_Machine *machine, String8 bytecode)
|
||||
}
|
||||
}break;
|
||||
|
||||
case RADDBG_EvalOp_TLSOff:
|
||||
case RADDBGI_EvalOp_TLSOff:
|
||||
{
|
||||
if (machine->tls_base != 0){
|
||||
nval.u64 = *machine->tls_base + imm;
|
||||
@@ -169,23 +169,23 @@ eval_interpret(EVAL_Machine *machine, String8 bytecode)
|
||||
}
|
||||
}break;
|
||||
|
||||
case RADDBG_EvalOp_ConstU8:
|
||||
case RADDBG_EvalOp_ConstU16:
|
||||
case RADDBG_EvalOp_ConstU32:
|
||||
case RADDBG_EvalOp_ConstU64:
|
||||
case RADDBGI_EvalOp_ConstU8:
|
||||
case RADDBGI_EvalOp_ConstU16:
|
||||
case RADDBGI_EvalOp_ConstU32:
|
||||
case RADDBGI_EvalOp_ConstU64:
|
||||
{
|
||||
nval.u64 = imm;
|
||||
}break;
|
||||
|
||||
case RADDBG_EvalOp_Abs:
|
||||
case RADDBGI_EvalOp_Abs:
|
||||
{
|
||||
if (imm == RADDBG_EvalTypeGroup_F32){
|
||||
if (imm == RADDBGI_EvalTypeGroup_F32){
|
||||
nval.f32 = svals[0].f32;
|
||||
if (svals[0].f32 < 0){
|
||||
nval.f32 = -svals[0].f32;
|
||||
}
|
||||
}
|
||||
else if (imm == RADDBG_EvalTypeGroup_F64){
|
||||
else if (imm == RADDBGI_EvalTypeGroup_F64){
|
||||
nval.f64 = svals[0].f64;
|
||||
if (svals[0].f64 < 0){
|
||||
nval.f64 = -svals[0].f64;
|
||||
@@ -199,12 +199,12 @@ eval_interpret(EVAL_Machine *machine, String8 bytecode)
|
||||
}
|
||||
}break;
|
||||
|
||||
case RADDBG_EvalOp_Neg:
|
||||
case RADDBGI_EvalOp_Neg:
|
||||
{
|
||||
if (imm == RADDBG_EvalTypeGroup_F32){
|
||||
if (imm == RADDBGI_EvalTypeGroup_F32){
|
||||
nval.f32 = -svals[0].f32;
|
||||
}
|
||||
else if (imm == RADDBG_EvalTypeGroup_F64){
|
||||
else if (imm == RADDBGI_EvalTypeGroup_F64){
|
||||
nval.f64 = -svals[0].f64;
|
||||
}
|
||||
else{
|
||||
@@ -212,12 +212,12 @@ eval_interpret(EVAL_Machine *machine, String8 bytecode)
|
||||
}
|
||||
}break;
|
||||
|
||||
case RADDBG_EvalOp_Add:
|
||||
case RADDBGI_EvalOp_Add:
|
||||
{
|
||||
if (imm == RADDBG_EvalTypeGroup_F32){
|
||||
if (imm == RADDBGI_EvalTypeGroup_F32){
|
||||
nval.f32 = svals[0].f32 + svals[1].f32;
|
||||
}
|
||||
else if (imm == RADDBG_EvalTypeGroup_F64){
|
||||
else if (imm == RADDBGI_EvalTypeGroup_F64){
|
||||
nval.f64 = svals[0].f64 + svals[1].f64;
|
||||
}
|
||||
else{
|
||||
@@ -225,12 +225,12 @@ eval_interpret(EVAL_Machine *machine, String8 bytecode)
|
||||
}
|
||||
}break;
|
||||
|
||||
case RADDBG_EvalOp_Sub:
|
||||
case RADDBGI_EvalOp_Sub:
|
||||
{
|
||||
if (imm == RADDBG_EvalTypeGroup_F32){
|
||||
if (imm == RADDBGI_EvalTypeGroup_F32){
|
||||
nval.f32 = svals[0].f32 - svals[1].f32;
|
||||
}
|
||||
else if (imm == RADDBG_EvalTypeGroup_F64){
|
||||
else if (imm == RADDBGI_EvalTypeGroup_F64){
|
||||
nval.f64 = svals[0].f64 - svals[1].f64;
|
||||
}
|
||||
else{
|
||||
@@ -238,12 +238,12 @@ eval_interpret(EVAL_Machine *machine, String8 bytecode)
|
||||
}
|
||||
}break;
|
||||
|
||||
case RADDBG_EvalOp_Mul:
|
||||
case RADDBGI_EvalOp_Mul:
|
||||
{
|
||||
if (imm == RADDBG_EvalTypeGroup_F32){
|
||||
if (imm == RADDBGI_EvalTypeGroup_F32){
|
||||
nval.f32 = svals[0].f32*svals[1].f32;
|
||||
}
|
||||
else if (imm == RADDBG_EvalTypeGroup_F64){
|
||||
else if (imm == RADDBGI_EvalTypeGroup_F64){
|
||||
nval.f64 = svals[0].f64*svals[1].f64;
|
||||
}
|
||||
else{
|
||||
@@ -251,9 +251,9 @@ eval_interpret(EVAL_Machine *machine, String8 bytecode)
|
||||
}
|
||||
}break;
|
||||
|
||||
case RADDBG_EvalOp_Div:
|
||||
case RADDBGI_EvalOp_Div:
|
||||
{
|
||||
if (imm == RADDBG_EvalTypeGroup_F32){
|
||||
if (imm == RADDBGI_EvalTypeGroup_F32){
|
||||
if (svals[1].f32 != 0.f){
|
||||
nval.f32 = svals[0].f32/svals[1].f32;
|
||||
}
|
||||
@@ -263,7 +263,7 @@ eval_interpret(EVAL_Machine *machine, String8 bytecode)
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
else if (imm == RADDBG_EvalTypeGroup_F64){
|
||||
else if (imm == RADDBGI_EvalTypeGroup_F64){
|
||||
if (svals[1].f64 != 0.){
|
||||
nval.f64 = svals[0].f64/svals[1].f64;
|
||||
}
|
||||
@@ -273,8 +273,8 @@ eval_interpret(EVAL_Machine *machine, String8 bytecode)
|
||||
goto done;
|
||||
}
|
||||
}
|
||||
else if (imm == RADDBG_EvalTypeGroup_U ||
|
||||
imm == RADDBG_EvalTypeGroup_S){
|
||||
else if (imm == RADDBGI_EvalTypeGroup_U ||
|
||||
imm == RADDBGI_EvalTypeGroup_S){
|
||||
if (svals[1].u64 != 0){
|
||||
nval.u64 = svals[0].u64/svals[1].u64;
|
||||
}
|
||||
@@ -290,10 +290,10 @@ eval_interpret(EVAL_Machine *machine, String8 bytecode)
|
||||
}
|
||||
}break;
|
||||
|
||||
case RADDBG_EvalOp_Mod:
|
||||
case RADDBGI_EvalOp_Mod:
|
||||
{
|
||||
if (imm == RADDBG_EvalTypeGroup_U ||
|
||||
imm == RADDBG_EvalTypeGroup_S){
|
||||
if (imm == RADDBGI_EvalTypeGroup_U ||
|
||||
imm == RADDBGI_EvalTypeGroup_S){
|
||||
if (svals[1].u64 != 0){
|
||||
nval.u64 = svals[0].u64%svals[1].u64;
|
||||
}
|
||||
@@ -304,10 +304,10 @@ eval_interpret(EVAL_Machine *machine, String8 bytecode)
|
||||
}
|
||||
}break;
|
||||
|
||||
case RADDBG_EvalOp_LShift:
|
||||
case RADDBGI_EvalOp_LShift:
|
||||
{
|
||||
if (imm == RADDBG_EvalTypeGroup_U ||
|
||||
imm == RADDBG_EvalTypeGroup_S){
|
||||
if (imm == RADDBGI_EvalTypeGroup_U ||
|
||||
imm == RADDBGI_EvalTypeGroup_S){
|
||||
nval.u64 = svals[0].u64 << svals[1].u64;
|
||||
}
|
||||
else{
|
||||
@@ -316,12 +316,12 @@ eval_interpret(EVAL_Machine *machine, String8 bytecode)
|
||||
}
|
||||
}break;
|
||||
|
||||
case RADDBG_EvalOp_RShift:
|
||||
case RADDBGI_EvalOp_RShift:
|
||||
{
|
||||
if (imm == RADDBG_EvalTypeGroup_U){
|
||||
if (imm == RADDBGI_EvalTypeGroup_U){
|
||||
nval.u64 = svals[0].u64 >> svals[1].u64;
|
||||
}
|
||||
else if (imm == RADDBG_EvalTypeGroup_S){
|
||||
else if (imm == RADDBGI_EvalTypeGroup_S){
|
||||
nval.u64 = svals[0].s64 >> svals[1].u64;
|
||||
}
|
||||
else{
|
||||
@@ -330,10 +330,10 @@ eval_interpret(EVAL_Machine *machine, String8 bytecode)
|
||||
}
|
||||
}break;
|
||||
|
||||
case RADDBG_EvalOp_BitAnd:
|
||||
case RADDBGI_EvalOp_BitAnd:
|
||||
{
|
||||
if (imm == RADDBG_EvalTypeGroup_U ||
|
||||
imm == RADDBG_EvalTypeGroup_S){
|
||||
if (imm == RADDBGI_EvalTypeGroup_U ||
|
||||
imm == RADDBGI_EvalTypeGroup_S){
|
||||
nval.u64 = svals[0].u64&svals[1].u64;
|
||||
}
|
||||
else{
|
||||
@@ -342,10 +342,10 @@ eval_interpret(EVAL_Machine *machine, String8 bytecode)
|
||||
}
|
||||
}break;
|
||||
|
||||
case RADDBG_EvalOp_BitOr:
|
||||
case RADDBGI_EvalOp_BitOr:
|
||||
{
|
||||
if (imm == RADDBG_EvalTypeGroup_U ||
|
||||
imm == RADDBG_EvalTypeGroup_S){
|
||||
if (imm == RADDBGI_EvalTypeGroup_U ||
|
||||
imm == RADDBGI_EvalTypeGroup_S){
|
||||
nval.u64 = svals[0].u64|svals[1].u64;
|
||||
}
|
||||
else{
|
||||
@@ -354,10 +354,10 @@ eval_interpret(EVAL_Machine *machine, String8 bytecode)
|
||||
}
|
||||
}break;
|
||||
|
||||
case RADDBG_EvalOp_BitXor:
|
||||
case RADDBGI_EvalOp_BitXor:
|
||||
{
|
||||
if (imm == RADDBG_EvalTypeGroup_U ||
|
||||
imm == RADDBG_EvalTypeGroup_S){
|
||||
if (imm == RADDBGI_EvalTypeGroup_U ||
|
||||
imm == RADDBGI_EvalTypeGroup_S){
|
||||
nval.u64 = svals[0].u64^svals[1].u64;
|
||||
}
|
||||
else{
|
||||
@@ -366,10 +366,10 @@ eval_interpret(EVAL_Machine *machine, String8 bytecode)
|
||||
}
|
||||
}break;
|
||||
|
||||
case RADDBG_EvalOp_BitNot:
|
||||
case RADDBGI_EvalOp_BitNot:
|
||||
{
|
||||
if (imm == RADDBG_EvalTypeGroup_U ||
|
||||
imm == RADDBG_EvalTypeGroup_S){
|
||||
if (imm == RADDBGI_EvalTypeGroup_U ||
|
||||
imm == RADDBGI_EvalTypeGroup_S){
|
||||
nval.u64 = ~svals[0].u64;
|
||||
}
|
||||
else{
|
||||
@@ -378,10 +378,10 @@ eval_interpret(EVAL_Machine *machine, String8 bytecode)
|
||||
}
|
||||
}break;
|
||||
|
||||
case RADDBG_EvalOp_LogAnd:
|
||||
case RADDBGI_EvalOp_LogAnd:
|
||||
{
|
||||
if (imm == RADDBG_EvalTypeGroup_U ||
|
||||
imm == RADDBG_EvalTypeGroup_S){
|
||||
if (imm == RADDBGI_EvalTypeGroup_U ||
|
||||
imm == RADDBGI_EvalTypeGroup_S){
|
||||
nval.u64 = (svals[0].u64 && svals[1].u64);
|
||||
}
|
||||
else{
|
||||
@@ -390,10 +390,10 @@ eval_interpret(EVAL_Machine *machine, String8 bytecode)
|
||||
}
|
||||
}break;
|
||||
|
||||
case RADDBG_EvalOp_LogOr:
|
||||
case RADDBGI_EvalOp_LogOr:
|
||||
{
|
||||
if (imm == RADDBG_EvalTypeGroup_U ||
|
||||
imm == RADDBG_EvalTypeGroup_S){
|
||||
if (imm == RADDBGI_EvalTypeGroup_U ||
|
||||
imm == RADDBGI_EvalTypeGroup_S){
|
||||
nval.u64 = (svals[0].u64 || svals[1].u64);
|
||||
}
|
||||
else{
|
||||
@@ -402,10 +402,10 @@ eval_interpret(EVAL_Machine *machine, String8 bytecode)
|
||||
}
|
||||
}break;
|
||||
|
||||
case RADDBG_EvalOp_LogNot:
|
||||
case RADDBGI_EvalOp_LogNot:
|
||||
{
|
||||
if (imm == RADDBG_EvalTypeGroup_U ||
|
||||
imm == RADDBG_EvalTypeGroup_S){
|
||||
if (imm == RADDBGI_EvalTypeGroup_U ||
|
||||
imm == RADDBGI_EvalTypeGroup_S){
|
||||
nval.u64 = (!svals[0].u64);
|
||||
}
|
||||
else{
|
||||
@@ -414,28 +414,28 @@ eval_interpret(EVAL_Machine *machine, String8 bytecode)
|
||||
}
|
||||
}break;
|
||||
|
||||
case RADDBG_EvalOp_EqEq:
|
||||
case RADDBGI_EvalOp_EqEq:
|
||||
{
|
||||
nval.u64 = (svals[0].u64 == svals[1].u64);
|
||||
}break;
|
||||
|
||||
case RADDBG_EvalOp_NtEq:
|
||||
case RADDBGI_EvalOp_NtEq:
|
||||
{
|
||||
nval.u64 = (svals[0].u64 != svals[1].u64);
|
||||
}break;
|
||||
|
||||
case RADDBG_EvalOp_LsEq:
|
||||
case RADDBGI_EvalOp_LsEq:
|
||||
{
|
||||
if (imm == RADDBG_EvalTypeGroup_F32){
|
||||
if (imm == RADDBGI_EvalTypeGroup_F32){
|
||||
nval.u64 = (svals[0].f32 <= svals[1].f32);
|
||||
}
|
||||
else if (imm == RADDBG_EvalTypeGroup_F64){
|
||||
else if (imm == RADDBGI_EvalTypeGroup_F64){
|
||||
nval.u64 = (svals[0].f64 <= svals[1].f64);
|
||||
}
|
||||
else if (imm == RADDBG_EvalTypeGroup_U){
|
||||
else if (imm == RADDBGI_EvalTypeGroup_U){
|
||||
nval.u64 = (svals[0].u64 <= svals[1].u64);
|
||||
}
|
||||
else if (imm == RADDBG_EvalTypeGroup_S){
|
||||
else if (imm == RADDBGI_EvalTypeGroup_S){
|
||||
nval.u64 = (svals[0].s64 <= svals[1].s64);
|
||||
}
|
||||
else{
|
||||
@@ -444,18 +444,18 @@ eval_interpret(EVAL_Machine *machine, String8 bytecode)
|
||||
}
|
||||
}break;
|
||||
|
||||
case RADDBG_EvalOp_GrEq:
|
||||
case RADDBGI_EvalOp_GrEq:
|
||||
{
|
||||
if (imm == RADDBG_EvalTypeGroup_F32){
|
||||
if (imm == RADDBGI_EvalTypeGroup_F32){
|
||||
nval.u64 = (svals[0].f32 >= svals[1].f32);
|
||||
}
|
||||
else if (imm == RADDBG_EvalTypeGroup_F64){
|
||||
else if (imm == RADDBGI_EvalTypeGroup_F64){
|
||||
nval.u64 = (svals[0].f64 >= svals[1].f64);
|
||||
}
|
||||
else if (imm == RADDBG_EvalTypeGroup_U){
|
||||
else if (imm == RADDBGI_EvalTypeGroup_U){
|
||||
nval.u64 = (svals[0].u64 >= svals[1].u64);
|
||||
}
|
||||
else if (imm == RADDBG_EvalTypeGroup_S){
|
||||
else if (imm == RADDBGI_EvalTypeGroup_S){
|
||||
nval.u64 = (svals[0].s64 >= svals[1].s64);
|
||||
}
|
||||
else{
|
||||
@@ -464,18 +464,18 @@ eval_interpret(EVAL_Machine *machine, String8 bytecode)
|
||||
}
|
||||
}break;
|
||||
|
||||
case RADDBG_EvalOp_Less:
|
||||
case RADDBGI_EvalOp_Less:
|
||||
{
|
||||
if (imm == RADDBG_EvalTypeGroup_F32){
|
||||
if (imm == RADDBGI_EvalTypeGroup_F32){
|
||||
nval.u64 = (svals[0].f32 < svals[1].f32);
|
||||
}
|
||||
else if (imm == RADDBG_EvalTypeGroup_F64){
|
||||
else if (imm == RADDBGI_EvalTypeGroup_F64){
|
||||
nval.u64 = (svals[0].f64 < svals[1].f64);
|
||||
}
|
||||
else if (imm == RADDBG_EvalTypeGroup_U){
|
||||
else if (imm == RADDBGI_EvalTypeGroup_U){
|
||||
nval.u64 = (svals[0].u64 < svals[1].u64);
|
||||
}
|
||||
else if (imm == RADDBG_EvalTypeGroup_S){
|
||||
else if (imm == RADDBGI_EvalTypeGroup_S){
|
||||
nval.u64 = (svals[0].s64 < svals[1].s64);
|
||||
}
|
||||
else{
|
||||
@@ -484,18 +484,18 @@ eval_interpret(EVAL_Machine *machine, String8 bytecode)
|
||||
}
|
||||
}break;
|
||||
|
||||
case RADDBG_EvalOp_Grtr:
|
||||
case RADDBGI_EvalOp_Grtr:
|
||||
{
|
||||
if (imm == RADDBG_EvalTypeGroup_F32){
|
||||
if (imm == RADDBGI_EvalTypeGroup_F32){
|
||||
nval.u64 = (svals[0].f32 > svals[1].f32);
|
||||
}
|
||||
else if (imm == RADDBG_EvalTypeGroup_F64){
|
||||
else if (imm == RADDBGI_EvalTypeGroup_F64){
|
||||
nval.u64 = (svals[0].f64 > svals[1].f64);
|
||||
}
|
||||
else if (imm == RADDBG_EvalTypeGroup_U){
|
||||
else if (imm == RADDBGI_EvalTypeGroup_U){
|
||||
nval.u64 = (svals[0].u64 > svals[1].u64);
|
||||
}
|
||||
else if (imm == RADDBG_EvalTypeGroup_S){
|
||||
else if (imm == RADDBGI_EvalTypeGroup_S){
|
||||
nval.u64 = (svals[0].s64 > svals[1].s64);
|
||||
}
|
||||
else{
|
||||
@@ -504,7 +504,7 @@ eval_interpret(EVAL_Machine *machine, String8 bytecode)
|
||||
}
|
||||
}break;
|
||||
|
||||
case RADDBG_EvalOp_Trunc:
|
||||
case RADDBGI_EvalOp_Trunc:
|
||||
{
|
||||
if (0 < imm){
|
||||
U64 mask = 0;
|
||||
@@ -515,7 +515,7 @@ eval_interpret(EVAL_Machine *machine, String8 bytecode)
|
||||
}
|
||||
}break;
|
||||
|
||||
case RADDBG_EvalOp_TruncSigned:
|
||||
case RADDBGI_EvalOp_TruncSigned:
|
||||
{
|
||||
if (0 < imm){
|
||||
U64 mask = 0;
|
||||
@@ -530,52 +530,52 @@ eval_interpret(EVAL_Machine *machine, String8 bytecode)
|
||||
}
|
||||
}break;
|
||||
|
||||
case RADDBG_EvalOp_Convert:
|
||||
case RADDBGI_EvalOp_Convert:
|
||||
{
|
||||
U32 in = imm&0xFF;
|
||||
U32 out = (imm >> 8)&0xFF;
|
||||
if (in != out){
|
||||
switch (in + out*RADDBG_EvalTypeGroup_COUNT){
|
||||
case RADDBG_EvalTypeGroup_F32 + RADDBG_EvalTypeGroup_U*RADDBG_EvalTypeGroup_COUNT:
|
||||
switch (in + out*RADDBGI_EvalTypeGroup_COUNT){
|
||||
case RADDBGI_EvalTypeGroup_F32 + RADDBGI_EvalTypeGroup_U*RADDBGI_EvalTypeGroup_COUNT:
|
||||
{
|
||||
nval.u64 = (U64)svals[0].f32;
|
||||
}break;
|
||||
case RADDBG_EvalTypeGroup_F64 + RADDBG_EvalTypeGroup_U*RADDBG_EvalTypeGroup_COUNT:
|
||||
case RADDBGI_EvalTypeGroup_F64 + RADDBGI_EvalTypeGroup_U*RADDBGI_EvalTypeGroup_COUNT:
|
||||
{
|
||||
nval.u64 = (U64)svals[0].f64;
|
||||
}break;
|
||||
|
||||
case RADDBG_EvalTypeGroup_F32 + RADDBG_EvalTypeGroup_S*RADDBG_EvalTypeGroup_COUNT:
|
||||
case RADDBGI_EvalTypeGroup_F32 + RADDBGI_EvalTypeGroup_S*RADDBGI_EvalTypeGroup_COUNT:
|
||||
{
|
||||
nval.s64 = (S64)svals[0].f32;
|
||||
}break;
|
||||
case RADDBG_EvalTypeGroup_F64 + RADDBG_EvalTypeGroup_S*RADDBG_EvalTypeGroup_COUNT:
|
||||
case RADDBGI_EvalTypeGroup_F64 + RADDBGI_EvalTypeGroup_S*RADDBGI_EvalTypeGroup_COUNT:
|
||||
{
|
||||
nval.s64 = (S64)svals[0].f64;
|
||||
}break;
|
||||
|
||||
case RADDBG_EvalTypeGroup_U + RADDBG_EvalTypeGroup_F32*RADDBG_EvalTypeGroup_COUNT:
|
||||
case RADDBGI_EvalTypeGroup_U + RADDBGI_EvalTypeGroup_F32*RADDBGI_EvalTypeGroup_COUNT:
|
||||
{
|
||||
nval.f32 = (F32)svals[0].u64;
|
||||
}break;
|
||||
case RADDBG_EvalTypeGroup_S + RADDBG_EvalTypeGroup_F32*RADDBG_EvalTypeGroup_COUNT:
|
||||
case RADDBGI_EvalTypeGroup_S + RADDBGI_EvalTypeGroup_F32*RADDBGI_EvalTypeGroup_COUNT:
|
||||
{
|
||||
nval.f32 = (F32)svals[0].s64;
|
||||
}break;
|
||||
case RADDBG_EvalTypeGroup_F64 + RADDBG_EvalTypeGroup_F32*RADDBG_EvalTypeGroup_COUNT:
|
||||
case RADDBGI_EvalTypeGroup_F64 + RADDBGI_EvalTypeGroup_F32*RADDBGI_EvalTypeGroup_COUNT:
|
||||
{
|
||||
nval.f32 = (F32)svals[0].f64;
|
||||
}break;
|
||||
|
||||
case RADDBG_EvalTypeGroup_U + RADDBG_EvalTypeGroup_F64*RADDBG_EvalTypeGroup_COUNT:
|
||||
case RADDBGI_EvalTypeGroup_U + RADDBGI_EvalTypeGroup_F64*RADDBGI_EvalTypeGroup_COUNT:
|
||||
{
|
||||
nval.f64 = (F64)svals[0].u64;
|
||||
}break;
|
||||
case RADDBG_EvalTypeGroup_S + RADDBG_EvalTypeGroup_F64*RADDBG_EvalTypeGroup_COUNT:
|
||||
case RADDBGI_EvalTypeGroup_S + RADDBGI_EvalTypeGroup_F64*RADDBGI_EvalTypeGroup_COUNT:
|
||||
{
|
||||
nval.f64 = (F64)svals[0].s64;
|
||||
}break;
|
||||
case RADDBG_EvalTypeGroup_F32 + RADDBG_EvalTypeGroup_F64*RADDBG_EvalTypeGroup_COUNT:
|
||||
case RADDBGI_EvalTypeGroup_F32 + RADDBGI_EvalTypeGroup_F64*RADDBGI_EvalTypeGroup_COUNT:
|
||||
{
|
||||
nval.f64 = (F64)svals[0].f32;
|
||||
}break;
|
||||
@@ -583,7 +583,7 @@ eval_interpret(EVAL_Machine *machine, String8 bytecode)
|
||||
}
|
||||
}break;
|
||||
|
||||
case RADDBG_EvalOp_Pick:
|
||||
case RADDBGI_EvalOp_Pick:
|
||||
{
|
||||
if (stack_count > imm){
|
||||
nval = stack[stack_count - imm - 1];
|
||||
@@ -594,12 +594,12 @@ eval_interpret(EVAL_Machine *machine, String8 bytecode)
|
||||
}
|
||||
}break;
|
||||
|
||||
case RADDBG_EvalOp_Pop:
|
||||
case RADDBGI_EvalOp_Pop:
|
||||
{
|
||||
// do nothing - the pop is handled by the control bits
|
||||
}break;
|
||||
|
||||
case RADDBG_EvalOp_Insert:
|
||||
case RADDBGI_EvalOp_Insert:
|
||||
{
|
||||
if (stack_count > imm){
|
||||
if (imm > 0){
|
||||
@@ -619,7 +619,7 @@ eval_interpret(EVAL_Machine *machine, String8 bytecode)
|
||||
|
||||
// push
|
||||
{
|
||||
U64 push_count = RADDBG_PUSHN_FROM_CTRLBITS(ctrlbits);
|
||||
U64 push_count = RADDBGI_PUSHN_FROM_CTRLBITS(ctrlbits);
|
||||
if (push_count == 1){
|
||||
if (stack_count < stack_cap){
|
||||
stack[stack_count] = nval;
|
||||
|
||||
+104
-104
@@ -57,7 +57,7 @@ global read_only S64 eval_g_max_precedence = 15;
|
||||
//~ rjf: Map Building Fast Paths
|
||||
|
||||
internal EVAL_String2NumMap *
|
||||
eval_push_locals_map_from_raddbg_voff(Arena *arena, RADDBG_Parsed *rdbg, U64 voff)
|
||||
eval_push_locals_map_from_raddbgi_voff(Arena *arena, RADDBGI_Parsed *rdbg, U64 voff)
|
||||
{
|
||||
Temp scratch = scratch_begin(&arena, 1);
|
||||
|
||||
@@ -66,17 +66,17 @@ eval_push_locals_map_from_raddbg_voff(Arena *arena, RADDBG_Parsed *rdbg, U64 vof
|
||||
struct Task
|
||||
{
|
||||
Task *next;
|
||||
RADDBG_Scope *scope;
|
||||
RADDBGI_Scope *scope;
|
||||
};
|
||||
Task *first_task = 0;
|
||||
Task *last_task = 0;
|
||||
|
||||
//- rjf: voff -> tightest scope
|
||||
RADDBG_Scope *tightest_scope = 0;
|
||||
RADDBGI_Scope *tightest_scope = 0;
|
||||
if(rdbg->scope_vmap != 0 && rdbg->scopes != 0)
|
||||
{
|
||||
U64 scope_idx = raddbg_vmap_idx_from_voff(rdbg->scope_vmap, rdbg->scope_vmap_count, voff);
|
||||
RADDBG_Scope *scope = &rdbg->scopes[scope_idx];
|
||||
U64 scope_idx = raddbgi_vmap_idx_from_voff(rdbg->scope_vmap, rdbg->scope_vmap_count, voff);
|
||||
RADDBGI_Scope *scope = &rdbg->scopes[scope_idx];
|
||||
Task *task = push_array(scratch.arena, Task, 1);
|
||||
task->scope = scope;
|
||||
SLLQueuePush(first_task, last_task, task);
|
||||
@@ -86,8 +86,8 @@ eval_push_locals_map_from_raddbg_voff(Arena *arena, RADDBG_Parsed *rdbg, U64 vof
|
||||
//- rjf: voff-1 -> scope
|
||||
if(voff > 0 && rdbg->scope_vmap != 0 && rdbg->scopes != 0)
|
||||
{
|
||||
U64 scope_idx = raddbg_vmap_idx_from_voff(rdbg->scope_vmap, rdbg->scope_vmap_count, voff-1);
|
||||
RADDBG_Scope *scope = &rdbg->scopes[scope_idx];
|
||||
U64 scope_idx = raddbgi_vmap_idx_from_voff(rdbg->scope_vmap, rdbg->scope_vmap_count, voff-1);
|
||||
RADDBGI_Scope *scope = &rdbg->scopes[scope_idx];
|
||||
if(scope != tightest_scope)
|
||||
{
|
||||
Task *task = push_array(scratch.arena, Task, 1);
|
||||
@@ -99,7 +99,7 @@ eval_push_locals_map_from_raddbg_voff(Arena *arena, RADDBG_Parsed *rdbg, U64 vof
|
||||
//- rjf: tightest scope -> walk up the tree & build tasks for each parent scope
|
||||
if(tightest_scope != 0)
|
||||
{
|
||||
for(RADDBG_Scope *scope = &rdbg->scopes[tightest_scope->parent_scope_idx];
|
||||
for(RADDBGI_Scope *scope = &rdbg->scopes[tightest_scope->parent_scope_idx];
|
||||
scope != 0 && scope != &rdbg->scopes[0];
|
||||
scope = &rdbg->scopes[scope->parent_scope_idx])
|
||||
{
|
||||
@@ -116,15 +116,15 @@ eval_push_locals_map_from_raddbg_voff(Arena *arena, RADDBG_Parsed *rdbg, U64 vof
|
||||
//- rjf: accumulate locals for all tasks
|
||||
for(Task *task = first_task; task != 0; task = task->next)
|
||||
{
|
||||
RADDBG_Scope *scope = task->scope;
|
||||
RADDBGI_Scope *scope = task->scope;
|
||||
if(scope != 0)
|
||||
{
|
||||
U32 local_opl_idx = scope->local_first + scope->local_count;
|
||||
for(U32 local_idx = scope->local_first; local_idx < local_opl_idx; local_idx += 1)
|
||||
{
|
||||
RADDBG_Local *local_var = &rdbg->locals[local_idx];
|
||||
RADDBGI_Local *local_var = &rdbg->locals[local_idx];
|
||||
U64 local_name_size = 0;
|
||||
U8 *local_name_str = raddbg_string_from_idx(rdbg, local_var->name_string_idx, &local_name_size);
|
||||
U8 *local_name_str = raddbgi_string_from_idx(rdbg, local_var->name_string_idx, &local_name_size);
|
||||
String8 name = push_str8_copy(arena, str8(local_name_str, local_name_size));
|
||||
eval_string2num_map_insert(arena, map, name, (U64)local_idx+1);
|
||||
}
|
||||
@@ -136,18 +136,18 @@ eval_push_locals_map_from_raddbg_voff(Arena *arena, RADDBG_Parsed *rdbg, U64 vof
|
||||
}
|
||||
|
||||
internal EVAL_String2NumMap *
|
||||
eval_push_member_map_from_raddbg_voff(Arena *arena, RADDBG_Parsed *rdbg, U64 voff)
|
||||
eval_push_member_map_from_raddbgi_voff(Arena *arena, RADDBGI_Parsed *rdbg, U64 voff)
|
||||
{
|
||||
//- rjf: voff -> tightest scope
|
||||
RADDBG_Scope *tightest_scope = 0;
|
||||
RADDBGI_Scope *tightest_scope = 0;
|
||||
if(rdbg->scope_vmap != 0 && rdbg->scopes != 0)
|
||||
{
|
||||
U64 scope_idx = raddbg_vmap_idx_from_voff(rdbg->scope_vmap, rdbg->scope_vmap_count, voff);
|
||||
U64 scope_idx = raddbgi_vmap_idx_from_voff(rdbg->scope_vmap, rdbg->scope_vmap_count, voff);
|
||||
tightest_scope = &rdbg->scopes[scope_idx];
|
||||
}
|
||||
|
||||
//- rjf: tightest scope -> procedure
|
||||
RADDBG_Procedure *procedure = 0;
|
||||
RADDBGI_Procedure *procedure = 0;
|
||||
if(tightest_scope != 0 && rdbg->procedures != 0)
|
||||
{
|
||||
U32 proc_idx = tightest_scope->proc_idx;
|
||||
@@ -158,8 +158,8 @@ eval_push_member_map_from_raddbg_voff(Arena *arena, RADDBG_Parsed *rdbg, U64 vof
|
||||
}
|
||||
|
||||
//- rjf: procedure -> udt
|
||||
RADDBG_UDT *udt = 0;
|
||||
if(procedure != 0 && rdbg->udts != 0 && procedure->link_flags & RADDBG_LinkFlag_TypeScoped)
|
||||
RADDBGI_UDT *udt = 0;
|
||||
if(procedure != 0 && rdbg->udts != 0 && procedure->link_flags & RADDBGI_LinkFlag_TypeScoped)
|
||||
{
|
||||
U32 udt_idx = procedure->container_idx;
|
||||
if(0 < udt_idx && udt_idx < rdbg->udts_count)
|
||||
@@ -173,7 +173,7 @@ eval_push_member_map_from_raddbg_voff(Arena *arena, RADDBG_Parsed *rdbg, U64 vof
|
||||
*map = eval_string2num_map_make(arena, 64);
|
||||
|
||||
//- rjf: udt -> fill member map
|
||||
if(udt != 0 && !(udt->flags & RADDBG_UserDefinedTypeFlag_EnumMembers) && rdbg->members != 0)
|
||||
if(udt != 0 && !(udt->flags & RADDBGI_UserDefinedTypeFlag_EnumMembers) && rdbg->members != 0)
|
||||
{
|
||||
U64 data_member_num = 1;
|
||||
for(U32 member_idx = udt->member_first;
|
||||
@@ -184,11 +184,11 @@ eval_push_member_map_from_raddbg_voff(Arena *arena, RADDBG_Parsed *rdbg, U64 vof
|
||||
{
|
||||
break;
|
||||
}
|
||||
RADDBG_Member *m = &rdbg->members[member_idx];
|
||||
if(m->kind == RADDBG_MemberKind_DataField)
|
||||
RADDBGI_Member *m = &rdbg->members[member_idx];
|
||||
if(m->kind == RADDBGI_MemberKind_DataField)
|
||||
{
|
||||
String8 name = {0};
|
||||
name.str = raddbg_string_from_idx(rdbg, m->name_string_idx, &name.size);
|
||||
name.str = raddbgi_string_from_idx(rdbg, m->name_string_idx, &name.size);
|
||||
eval_string2num_map_insert(arena, map, name, data_member_num);
|
||||
data_member_num += 1;
|
||||
}
|
||||
@@ -464,25 +464,25 @@ eval_token_array_make_first_opl(EVAL_Token *first, EVAL_Token *opl)
|
||||
//~ rjf: Parser Functions
|
||||
|
||||
internal TG_Key
|
||||
eval_leaf_type_from_name(RADDBG_Parsed *rdbg, String8 name)
|
||||
eval_leaf_type_from_name(RADDBGI_Parsed *rdbg, String8 name)
|
||||
{
|
||||
TG_Key key = zero_struct;
|
||||
B32 found = 0;
|
||||
if(rdbg->type_nodes != 0)
|
||||
{
|
||||
RADDBG_NameMap *name_map = raddbg_name_map_from_kind(rdbg, RADDBG_NameMapKind_Types);
|
||||
RADDBG_ParsedNameMap parsed_name_map = {0};
|
||||
raddbg_name_map_parse(rdbg, name_map, &parsed_name_map);
|
||||
RADDBG_NameMapNode *node = raddbg_name_map_lookup(rdbg, &parsed_name_map, name.str, name.size);
|
||||
RADDBGI_NameMap *name_map = raddbgi_name_map_from_kind(rdbg, RADDBGI_NameMapKind_Types);
|
||||
RADDBGI_ParsedNameMap parsed_name_map = {0};
|
||||
raddbgi_name_map_parse(rdbg, name_map, &parsed_name_map);
|
||||
RADDBGI_NameMapNode *node = raddbgi_name_map_lookup(rdbg, &parsed_name_map, name.str, name.size);
|
||||
if(node != 0)
|
||||
{
|
||||
U32 match_count = 0;
|
||||
U32 *matches = raddbg_matches_from_map_node(rdbg, node, &match_count);
|
||||
U32 *matches = raddbgi_matches_from_map_node(rdbg, node, &match_count);
|
||||
if(match_count != 0)
|
||||
{
|
||||
RADDBG_TypeNode *type_node = raddbg_element_from_idx(rdbg, type_nodes, matches[0]);
|
||||
found = type_node->kind != RADDBG_TypeKind_NULL;
|
||||
key = tg_key_ext(tg_kind_from_raddbg_type_kind(type_node->kind), (U64)matches[0]);
|
||||
RADDBGI_TypeNode *type_node = raddbgi_element_from_idx(rdbg, type_nodes, matches[0]);
|
||||
found = type_node->kind != RADDBGI_TypeKind_NULL;
|
||||
key = tg_key_ext(tg_kind_from_raddbgi_type_kind(type_node->kind), (U64)matches[0]);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -787,9 +787,9 @@ eval_parse_expr_from_text_tokens__prec(Arena *arena, EVAL_ParseCtx *ctx, String8
|
||||
B32 mapped_identifier = 0;
|
||||
B32 identifier_type_is_possibly_dynamically_overridden = 0;
|
||||
B32 identifier_looks_like_type_expr = 0;
|
||||
RADDBG_LocationKind loc_kind = RADDBG_LocationKind_NULL;
|
||||
RADDBG_LocationRegister loc_reg = {0};
|
||||
RADDBG_LocationRegisterPlusU16 loc_reg_u16 = {0};
|
||||
RADDBGI_LocationKind loc_kind = RADDBGI_LocationKind_NULL;
|
||||
RADDBGI_LocationRegister loc_reg = {0};
|
||||
RADDBGI_LocationRegisterPlusU16 loc_reg_u16 = {0};
|
||||
String8 loc_bytecode = {0};
|
||||
REGS_RegCode reg_code = 0;
|
||||
REGS_AliasCode alias_code = 0;
|
||||
@@ -800,12 +800,12 @@ eval_parse_expr_from_text_tokens__prec(Arena *arena, EVAL_ParseCtx *ctx, String8
|
||||
String8List namespaceified_token_strings = {0};
|
||||
if(ctx->rdbg->procedures != 0 && ctx->rdbg->scopes != 0 && ctx->rdbg->scope_vmap != 0)
|
||||
{
|
||||
U64 scope_idx = raddbg_vmap_idx_from_voff(ctx->rdbg->scope_vmap, ctx->rdbg->scope_vmap_count, ctx->ip_voff);
|
||||
RADDBG_Scope *scope = &ctx->rdbg->scopes[scope_idx];
|
||||
U64 scope_idx = raddbgi_vmap_idx_from_voff(ctx->rdbg->scope_vmap, ctx->rdbg->scope_vmap_count, ctx->ip_voff);
|
||||
RADDBGI_Scope *scope = &ctx->rdbg->scopes[scope_idx];
|
||||
U64 proc_idx = scope->proc_idx;
|
||||
RADDBG_Procedure *procedure = &ctx->rdbg->procedures[proc_idx];
|
||||
RADDBGI_Procedure *procedure = &ctx->rdbg->procedures[proc_idx];
|
||||
U64 name_size = 0;
|
||||
U8 *name_ptr = raddbg_string_from_idx(ctx->rdbg, procedure->name_string_idx, &name_size);
|
||||
U8 *name_ptr = raddbgi_string_from_idx(ctx->rdbg, procedure->name_string_idx, &name_size);
|
||||
String8 containing_procedure_name = str8(name_ptr, name_size);
|
||||
U64 last_past_scope_resolution_pos = 0;
|
||||
for(;;)
|
||||
@@ -843,26 +843,26 @@ eval_parse_expr_from_text_tokens__prec(Arena *arena, EVAL_ParseCtx *ctx, String8
|
||||
{
|
||||
mapped_identifier = 1;
|
||||
identifier_type_is_possibly_dynamically_overridden = 1;
|
||||
RADDBG_Local *local_var = raddbg_element_from_idx(ctx->rdbg, locals, local_num-1);
|
||||
RADDBG_TypeNode *type_node = raddbg_element_from_idx(ctx->rdbg, type_nodes, local_var->type_idx);
|
||||
type_key = tg_key_ext(tg_kind_from_raddbg_type_kind(type_node->kind), (U64)local_var->type_idx);
|
||||
RADDBGI_Local *local_var = raddbgi_element_from_idx(ctx->rdbg, locals, local_num-1);
|
||||
RADDBGI_TypeNode *type_node = raddbgi_element_from_idx(ctx->rdbg, type_nodes, local_var->type_idx);
|
||||
type_key = tg_key_ext(tg_kind_from_raddbgi_type_kind(type_node->kind), (U64)local_var->type_idx);
|
||||
|
||||
// rjf: grab location info
|
||||
for(U32 loc_block_idx = local_var->location_first;
|
||||
loc_block_idx < local_var->location_opl;
|
||||
loc_block_idx += 1)
|
||||
{
|
||||
RADDBG_LocationBlock *block = &ctx->rdbg->location_blocks[loc_block_idx];
|
||||
RADDBGI_LocationBlock *block = &ctx->rdbg->location_blocks[loc_block_idx];
|
||||
if(block->scope_off_first <= ctx->ip_voff && ctx->ip_voff < block->scope_off_opl)
|
||||
{
|
||||
loc_kind = *((RADDBG_LocationKind *)(ctx->rdbg->location_data + block->location_data_off));
|
||||
loc_kind = *((RADDBGI_LocationKind *)(ctx->rdbg->location_data + block->location_data_off));
|
||||
switch(loc_kind)
|
||||
{
|
||||
default:{mapped_identifier = 0;}break;
|
||||
case RADDBG_LocationKind_AddrBytecodeStream:
|
||||
case RADDBG_LocationKind_ValBytecodeStream:
|
||||
case RADDBGI_LocationKind_AddrBytecodeStream:
|
||||
case RADDBGI_LocationKind_ValBytecodeStream:
|
||||
{
|
||||
U8 *bytecode_base = ctx->rdbg->location_data + block->location_data_off + sizeof(RADDBG_LocationKind);
|
||||
U8 *bytecode_base = ctx->rdbg->location_data + block->location_data_off + sizeof(RADDBGI_LocationKind);
|
||||
U64 bytecode_size = 0;
|
||||
for(U64 idx = 0; idx < ctx->rdbg->location_data_size; idx += 1)
|
||||
{
|
||||
@@ -871,18 +871,18 @@ eval_parse_expr_from_text_tokens__prec(Arena *arena, EVAL_ParseCtx *ctx, String8
|
||||
{
|
||||
break;
|
||||
}
|
||||
U8 ctrlbits = raddbg_eval_opcode_ctrlbits[op];
|
||||
U32 p_size = RADDBG_DECODEN_FROM_CTRLBITS(ctrlbits);
|
||||
U8 ctrlbits = raddbgi_eval_opcode_ctrlbits[op];
|
||||
U32 p_size = RADDBGI_DECODEN_FROM_CTRLBITS(ctrlbits);
|
||||
bytecode_size += 1+p_size;
|
||||
}
|
||||
loc_bytecode = str8(bytecode_base, bytecode_size);
|
||||
}break;
|
||||
case RADDBG_LocationKind_AddrRegisterPlusU16:
|
||||
case RADDBG_LocationKind_AddrAddrRegisterPlusU16:
|
||||
case RADDBGI_LocationKind_AddrRegisterPlusU16:
|
||||
case RADDBGI_LocationKind_AddrAddrRegisterPlusU16:
|
||||
{
|
||||
MemoryCopy(&loc_reg_u16, (ctx->rdbg->location_data + block->location_data_off), sizeof(loc_reg_u16));
|
||||
}break;
|
||||
case RADDBG_LocationKind_ValRegister:
|
||||
case RADDBGI_LocationKind_ValRegister:
|
||||
{
|
||||
MemoryCopy(&loc_reg, (ctx->rdbg->location_data + block->location_data_off), sizeof(loc_reg));
|
||||
}break;
|
||||
@@ -919,21 +919,21 @@ eval_parse_expr_from_text_tokens__prec(Arena *arena, EVAL_ParseCtx *ctx, String8
|
||||
//- rjf: try global variables
|
||||
if(mapped_identifier == 0)
|
||||
{
|
||||
RADDBG_NameMap *name_map = raddbg_name_map_from_kind(ctx->rdbg, RADDBG_NameMapKind_GlobalVariables);
|
||||
RADDBGI_NameMap *name_map = raddbgi_name_map_from_kind(ctx->rdbg, RADDBGI_NameMapKind_GlobalVariables);
|
||||
if(name_map != 0 && ctx->rdbg->global_variables != 0)
|
||||
{
|
||||
RADDBG_ParsedNameMap parsed_name_map = {0};
|
||||
raddbg_name_map_parse(ctx->rdbg, name_map, &parsed_name_map);
|
||||
RADDBG_NameMapNode *node = raddbg_name_map_lookup(ctx->rdbg, &parsed_name_map, token_string.str, token_string.size);
|
||||
RADDBGI_ParsedNameMap parsed_name_map = {0};
|
||||
raddbgi_name_map_parse(ctx->rdbg, name_map, &parsed_name_map);
|
||||
RADDBGI_NameMapNode *node = raddbgi_name_map_lookup(ctx->rdbg, &parsed_name_map, token_string.str, token_string.size);
|
||||
U32 matches_count = 0;
|
||||
U32 *matches = raddbg_matches_from_map_node(ctx->rdbg, node, &matches_count);
|
||||
U32 *matches = raddbgi_matches_from_map_node(ctx->rdbg, node, &matches_count);
|
||||
for(String8Node *n = namespaceified_token_strings.first;
|
||||
n != 0 && matches_count == 0;
|
||||
n = n->next)
|
||||
{
|
||||
node = raddbg_name_map_lookup(ctx->rdbg, &parsed_name_map, n->string.str, n->string.size);
|
||||
node = raddbgi_name_map_lookup(ctx->rdbg, &parsed_name_map, n->string.str, n->string.size);
|
||||
matches_count = 0;
|
||||
matches = raddbg_matches_from_map_node(ctx->rdbg, node, &matches_count);
|
||||
matches = raddbgi_matches_from_map_node(ctx->rdbg, node, &matches_count);
|
||||
}
|
||||
if(matches_count != 0)
|
||||
{
|
||||
@@ -942,16 +942,16 @@ eval_parse_expr_from_text_tokens__prec(Arena *arena, EVAL_ParseCtx *ctx, String8
|
||||
// don't know of a magic hash table fixup path in PDBs, so
|
||||
// in this case, I'm going to prefer the latest-added global.
|
||||
U32 match_idx = matches[matches_count-1];
|
||||
RADDBG_GlobalVariable *global_var = &ctx->rdbg->global_variables[match_idx];
|
||||
RADDBGI_GlobalVariable *global_var = &ctx->rdbg->global_variables[match_idx];
|
||||
EVAL_OpList oplist = {0};
|
||||
eval_oplist_push_op(arena, &oplist, RADDBG_EvalOp_ModuleOff, global_var->voff);
|
||||
loc_kind = RADDBG_LocationKind_AddrBytecodeStream;
|
||||
eval_oplist_push_op(arena, &oplist, RADDBGI_EvalOp_ModuleOff, global_var->voff);
|
||||
loc_kind = RADDBGI_LocationKind_AddrBytecodeStream;
|
||||
loc_bytecode = eval_bytecode_from_oplist(arena, &oplist);
|
||||
U32 type_idx = global_var->type_idx;
|
||||
if(type_idx < ctx->rdbg->type_nodes_count)
|
||||
{
|
||||
RADDBG_TypeNode *type_node = &ctx->rdbg->type_nodes[type_idx];
|
||||
type_key = tg_key_ext(tg_kind_from_raddbg_type_kind(type_node->kind), (U64)type_idx);
|
||||
RADDBGI_TypeNode *type_node = &ctx->rdbg->type_nodes[type_idx];
|
||||
type_key = tg_key_ext(tg_kind_from_raddbgi_type_kind(type_node->kind), (U64)type_idx);
|
||||
}
|
||||
mapped_identifier = 1;
|
||||
}
|
||||
@@ -961,35 +961,35 @@ eval_parse_expr_from_text_tokens__prec(Arena *arena, EVAL_ParseCtx *ctx, String8
|
||||
//- rjf: try thread variables
|
||||
if(mapped_identifier == 0)
|
||||
{
|
||||
RADDBG_NameMap *name_map = raddbg_name_map_from_kind(ctx->rdbg, RADDBG_NameMapKind_ThreadVariables);
|
||||
RADDBGI_NameMap *name_map = raddbgi_name_map_from_kind(ctx->rdbg, RADDBGI_NameMapKind_ThreadVariables);
|
||||
if(name_map != 0 && ctx->rdbg->global_variables != 0)
|
||||
{
|
||||
RADDBG_ParsedNameMap parsed_name_map = {0};
|
||||
raddbg_name_map_parse(ctx->rdbg, name_map, &parsed_name_map);
|
||||
RADDBG_NameMapNode *node = raddbg_name_map_lookup(ctx->rdbg, &parsed_name_map, token_string.str, token_string.size);
|
||||
RADDBGI_ParsedNameMap parsed_name_map = {0};
|
||||
raddbgi_name_map_parse(ctx->rdbg, name_map, &parsed_name_map);
|
||||
RADDBGI_NameMapNode *node = raddbgi_name_map_lookup(ctx->rdbg, &parsed_name_map, token_string.str, token_string.size);
|
||||
U32 matches_count = 0;
|
||||
U32 *matches = raddbg_matches_from_map_node(ctx->rdbg, node, &matches_count);
|
||||
U32 *matches = raddbgi_matches_from_map_node(ctx->rdbg, node, &matches_count);
|
||||
for(String8Node *n = namespaceified_token_strings.first;
|
||||
n != 0 && matches_count == 0;
|
||||
n = n->next)
|
||||
{
|
||||
node = raddbg_name_map_lookup(ctx->rdbg, &parsed_name_map, n->string.str, n->string.size);
|
||||
node = raddbgi_name_map_lookup(ctx->rdbg, &parsed_name_map, n->string.str, n->string.size);
|
||||
matches_count = 0;
|
||||
matches = raddbg_matches_from_map_node(ctx->rdbg, node, &matches_count);
|
||||
matches = raddbgi_matches_from_map_node(ctx->rdbg, node, &matches_count);
|
||||
}
|
||||
if(matches_count != 0)
|
||||
{
|
||||
U32 match_idx = matches[0];
|
||||
RADDBG_ThreadVariable *thread_var = &ctx->rdbg->thread_variables[match_idx];
|
||||
RADDBGI_ThreadVariable *thread_var = &ctx->rdbg->thread_variables[match_idx];
|
||||
EVAL_OpList oplist = {0};
|
||||
eval_oplist_push_op(arena, &oplist, RADDBG_EvalOp_TLSOff, thread_var->tls_off);
|
||||
loc_kind = RADDBG_LocationKind_AddrBytecodeStream;
|
||||
eval_oplist_push_op(arena, &oplist, RADDBGI_EvalOp_TLSOff, thread_var->tls_off);
|
||||
loc_kind = RADDBGI_LocationKind_AddrBytecodeStream;
|
||||
loc_bytecode = eval_bytecode_from_oplist(arena, &oplist);
|
||||
U32 type_idx = thread_var->type_idx;
|
||||
if(type_idx < ctx->rdbg->type_nodes_count)
|
||||
{
|
||||
RADDBG_TypeNode *type_node = &ctx->rdbg->type_nodes[type_idx];
|
||||
type_key = tg_key_ext(tg_kind_from_raddbg_type_kind(type_node->kind), (U64)type_idx);
|
||||
RADDBGI_TypeNode *type_node = &ctx->rdbg->type_nodes[type_idx];
|
||||
type_key = tg_key_ext(tg_kind_from_raddbgi_type_kind(type_node->kind), (U64)type_idx);
|
||||
}
|
||||
mapped_identifier = 1;
|
||||
}
|
||||
@@ -999,37 +999,37 @@ eval_parse_expr_from_text_tokens__prec(Arena *arena, EVAL_ParseCtx *ctx, String8
|
||||
//- rjf: try procedures
|
||||
if(mapped_identifier == 0)
|
||||
{
|
||||
RADDBG_NameMap *name_map = raddbg_name_map_from_kind(ctx->rdbg, RADDBG_NameMapKind_Procedures);
|
||||
RADDBGI_NameMap *name_map = raddbgi_name_map_from_kind(ctx->rdbg, RADDBGI_NameMapKind_Procedures);
|
||||
if(name_map != 0 && ctx->rdbg->procedures != 0 && ctx->rdbg->scopes != 0 && ctx->rdbg->scope_voffs)
|
||||
{
|
||||
RADDBG_ParsedNameMap parsed_name_map = {0};
|
||||
raddbg_name_map_parse(ctx->rdbg, name_map, &parsed_name_map);
|
||||
RADDBG_NameMapNode *node = raddbg_name_map_lookup(ctx->rdbg, &parsed_name_map, token_string.str, token_string.size);
|
||||
RADDBGI_ParsedNameMap parsed_name_map = {0};
|
||||
raddbgi_name_map_parse(ctx->rdbg, name_map, &parsed_name_map);
|
||||
RADDBGI_NameMapNode *node = raddbgi_name_map_lookup(ctx->rdbg, &parsed_name_map, token_string.str, token_string.size);
|
||||
U32 matches_count = 0;
|
||||
U32 *matches = raddbg_matches_from_map_node(ctx->rdbg, node, &matches_count);
|
||||
U32 *matches = raddbgi_matches_from_map_node(ctx->rdbg, node, &matches_count);
|
||||
for(String8Node *n = namespaceified_token_strings.first;
|
||||
n != 0 && matches_count == 0;
|
||||
n = n->next)
|
||||
{
|
||||
node = raddbg_name_map_lookup(ctx->rdbg, &parsed_name_map, n->string.str, n->string.size);
|
||||
node = raddbgi_name_map_lookup(ctx->rdbg, &parsed_name_map, n->string.str, n->string.size);
|
||||
matches_count = 0;
|
||||
matches = raddbg_matches_from_map_node(ctx->rdbg, node, &matches_count);
|
||||
matches = raddbgi_matches_from_map_node(ctx->rdbg, node, &matches_count);
|
||||
}
|
||||
if(matches_count != 0)
|
||||
{
|
||||
U32 match_idx = matches[0];
|
||||
RADDBG_Procedure *procedure = &ctx->rdbg->procedures[match_idx];
|
||||
RADDBG_Scope *scope = &ctx->rdbg->scopes[procedure->root_scope_idx];
|
||||
RADDBGI_Procedure *procedure = &ctx->rdbg->procedures[match_idx];
|
||||
RADDBGI_Scope *scope = &ctx->rdbg->scopes[procedure->root_scope_idx];
|
||||
U64 voff = ctx->rdbg->scope_voffs[scope->voff_range_first];
|
||||
EVAL_OpList oplist = {0};
|
||||
eval_oplist_push_op(arena, &oplist, RADDBG_EvalOp_ModuleOff, voff);
|
||||
loc_kind = RADDBG_LocationKind_ValBytecodeStream;
|
||||
eval_oplist_push_op(arena, &oplist, RADDBGI_EvalOp_ModuleOff, voff);
|
||||
loc_kind = RADDBGI_LocationKind_ValBytecodeStream;
|
||||
loc_bytecode = eval_bytecode_from_oplist(arena, &oplist);
|
||||
U32 type_idx = procedure->type_idx;
|
||||
if(type_idx < ctx->rdbg->type_nodes_count)
|
||||
{
|
||||
RADDBG_TypeNode *type_node = &ctx->rdbg->type_nodes[type_idx];
|
||||
type_key = tg_key_ext(tg_kind_from_raddbg_type_kind(type_node->kind), (U64)type_idx);
|
||||
RADDBGI_TypeNode *type_node = &ctx->rdbg->type_nodes[type_idx];
|
||||
type_key = tg_key_ext(tg_kind_from_raddbgi_type_kind(type_node->kind), (U64)type_idx);
|
||||
}
|
||||
mapped_identifier = 1;
|
||||
}
|
||||
@@ -1086,44 +1086,44 @@ eval_parse_expr_from_text_tokens__prec(Arena *arena, EVAL_ParseCtx *ctx, String8
|
||||
eval_errorf(arena, &result.errors, EVAL_ErrorKind_MissingInfo, token_string.str, "Missing location information for \"%S\".", token_string);
|
||||
}
|
||||
}break;
|
||||
case RADDBG_LocationKind_AddrBytecodeStream:
|
||||
case RADDBGI_LocationKind_AddrBytecodeStream:
|
||||
{
|
||||
atom = eval_expr_leaf_bytecode(arena, token_string.str, type_key, loc_bytecode, EVAL_EvalMode_Addr);
|
||||
}break;
|
||||
case RADDBG_LocationKind_ValBytecodeStream:
|
||||
case RADDBGI_LocationKind_ValBytecodeStream:
|
||||
{
|
||||
atom = eval_expr_leaf_bytecode(arena, token_string.str, type_key, loc_bytecode, EVAL_EvalMode_Value);
|
||||
}break;
|
||||
case RADDBG_LocationKind_AddrRegisterPlusU16:
|
||||
case RADDBGI_LocationKind_AddrRegisterPlusU16:
|
||||
{
|
||||
EVAL_OpList oplist = {0};
|
||||
U64 byte_size = bit_size_from_arch(ctx->arch)/8;
|
||||
U64 regread_param = RADDBG_EncodeRegReadParam(loc_reg_u16.register_code, byte_size, 0);
|
||||
eval_oplist_push_op(arena, &oplist, RADDBG_EvalOp_RegRead, regread_param);
|
||||
eval_oplist_push_op(arena, &oplist, RADDBG_EvalOp_ConstU16, loc_reg_u16.offset);
|
||||
eval_oplist_push_op(arena, &oplist, RADDBG_EvalOp_Add, 0);
|
||||
U64 regread_param = RADDBGI_EncodeRegReadParam(loc_reg_u16.register_code, byte_size, 0);
|
||||
eval_oplist_push_op(arena, &oplist, RADDBGI_EvalOp_RegRead, regread_param);
|
||||
eval_oplist_push_op(arena, &oplist, RADDBGI_EvalOp_ConstU16, loc_reg_u16.offset);
|
||||
eval_oplist_push_op(arena, &oplist, RADDBGI_EvalOp_Add, 0);
|
||||
atom = eval_expr_leaf_op_list(arena, token_string.str, type_key, &oplist, EVAL_EvalMode_Addr);
|
||||
}break;
|
||||
case RADDBG_LocationKind_AddrAddrRegisterPlusU16:
|
||||
case RADDBGI_LocationKind_AddrAddrRegisterPlusU16:
|
||||
{
|
||||
EVAL_OpList oplist = {0};
|
||||
U64 byte_size = bit_size_from_arch(ctx->arch)/8;
|
||||
U64 regread_param = RADDBG_EncodeRegReadParam(loc_reg_u16.register_code, byte_size, 0);
|
||||
eval_oplist_push_op(arena, &oplist, RADDBG_EvalOp_RegRead, regread_param);
|
||||
eval_oplist_push_op(arena, &oplist, RADDBG_EvalOp_ConstU16, loc_reg_u16.offset);
|
||||
eval_oplist_push_op(arena, &oplist, RADDBG_EvalOp_Add, 0);
|
||||
eval_oplist_push_op(arena, &oplist, RADDBG_EvalOp_MemRead, bit_size_from_arch(ctx->arch)/8);
|
||||
U64 regread_param = RADDBGI_EncodeRegReadParam(loc_reg_u16.register_code, byte_size, 0);
|
||||
eval_oplist_push_op(arena, &oplist, RADDBGI_EvalOp_RegRead, regread_param);
|
||||
eval_oplist_push_op(arena, &oplist, RADDBGI_EvalOp_ConstU16, loc_reg_u16.offset);
|
||||
eval_oplist_push_op(arena, &oplist, RADDBGI_EvalOp_Add, 0);
|
||||
eval_oplist_push_op(arena, &oplist, RADDBGI_EvalOp_MemRead, bit_size_from_arch(ctx->arch)/8);
|
||||
atom = eval_expr_leaf_op_list(arena, token_string.str, type_key, &oplist, EVAL_EvalMode_Addr);
|
||||
}break;
|
||||
case RADDBG_LocationKind_ValRegister:
|
||||
case RADDBGI_LocationKind_ValRegister:
|
||||
{
|
||||
REGS_RegCode regs_reg_code = regs_reg_code_from_arch_raddbg_code(ctx->arch, loc_reg.register_code);
|
||||
REGS_RegCode regs_reg_code = regs_reg_code_from_arch_raddbgi_code(ctx->arch, loc_reg.register_code);
|
||||
REGS_Rng reg_rng = regs_reg_code_rng_table_from_architecture(ctx->arch)[regs_reg_code];
|
||||
EVAL_OpList oplist = {0};
|
||||
U64 byte_size = (U64)reg_rng.byte_size;
|
||||
U64 byte_pos = 0;
|
||||
U64 regread_param = RADDBG_EncodeRegReadParam(loc_reg.register_code, byte_size, byte_pos);
|
||||
eval_oplist_push_op(arena, &oplist, RADDBG_EvalOp_RegRead, regread_param);
|
||||
U64 regread_param = RADDBGI_EncodeRegReadParam(loc_reg.register_code, byte_size, byte_pos);
|
||||
eval_oplist_push_op(arena, &oplist, RADDBGI_EvalOp_RegRead, regread_param);
|
||||
atom = eval_expr_leaf_op_list(arena, token_string.str, type_key, &oplist, EVAL_EvalMode_Value);
|
||||
}break;
|
||||
}
|
||||
|
||||
@@ -67,7 +67,7 @@ struct EVAL_ParseCtx
|
||||
{
|
||||
Architecture arch;
|
||||
U64 ip_voff;
|
||||
RADDBG_Parsed *rdbg;
|
||||
RADDBGI_Parsed *rdbg;
|
||||
TG_Graph *type_graph;
|
||||
EVAL_String2NumMap *regs_map;
|
||||
EVAL_String2NumMap *reg_alias_map;
|
||||
@@ -85,8 +85,8 @@ global read_only EVAL_ParseResult eval_parse_result_nil = {0, &eval_expr_nil};
|
||||
////////////////////////////////
|
||||
//~ rjf: Debug-Info-Driven Map Building Fast Paths
|
||||
|
||||
internal EVAL_String2NumMap *eval_push_locals_map_from_raddbg_voff(Arena *arena, RADDBG_Parsed *rdbg, U64 voff);
|
||||
internal EVAL_String2NumMap *eval_push_member_map_from_raddbg_voff(Arena *arena, RADDBG_Parsed *rdbg, U64 voff);
|
||||
internal EVAL_String2NumMap *eval_push_locals_map_from_raddbgi_voff(Arena *arena, RADDBGI_Parsed *rdbg, U64 voff);
|
||||
internal EVAL_String2NumMap *eval_push_member_map_from_raddbgi_voff(Arena *arena, RADDBGI_Parsed *rdbg, U64 voff);
|
||||
|
||||
////////////////////////////////
|
||||
//~ rjf: Tokenization Functions
|
||||
@@ -101,7 +101,7 @@ internal EVAL_TokenArray eval_token_array_make_first_opl(EVAL_Token *first, EVAL
|
||||
////////////////////////////////
|
||||
//~ rjf: Parser Functions
|
||||
|
||||
internal TG_Key eval_leaf_type_from_name(RADDBG_Parsed *rdbg, String8 name);
|
||||
internal TG_Key eval_leaf_type_from_name(RADDBGI_Parsed *rdbg, String8 name);
|
||||
internal EVAL_ParseResult eval_parse_type_from_text_tokens(Arena *arena, EVAL_ParseCtx *ctx, String8 text, EVAL_TokenArray *tokens);
|
||||
internal EVAL_ParseResult eval_parse_expr_from_text_tokens__prec(Arena *arena, EVAL_ParseCtx *ctx, String8 text, EVAL_TokenArray *tokens, S64 max_precedence);
|
||||
internal EVAL_ParseResult eval_parse_expr_from_text_tokens(Arena *arena, EVAL_ParseCtx *ctx, String8 text, EVAL_TokenArray *tokens);
|
||||
|
||||
Reference in New Issue
Block a user