mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-06-25 05:04:58 -07:00
further raddbgi -> rdi naming pass
This commit is contained in:
+118
-118
@@ -331,7 +331,7 @@ eval_type_group_from_kind(TG_Kind kind){
|
||||
}
|
||||
|
||||
internal TG_Key
|
||||
eval_type_unwrap_enum(TG_Graph *graph, RDI_Parsed *rdbg, TG_Key key)
|
||||
eval_type_unwrap_enum(TG_Graph *graph, RDI_Parsed *rdi, TG_Key key)
|
||||
{
|
||||
TG_Key result = key;
|
||||
for(B32 good = 1; good;)
|
||||
@@ -339,7 +339,7 @@ eval_type_unwrap_enum(TG_Graph *graph, RDI_Parsed *rdbg, TG_Key key)
|
||||
TG_Kind kind = tg_kind_from_key(key);
|
||||
if(kind == TG_Kind_Enum)
|
||||
{
|
||||
result = tg_direct_from_graph_rdi_key(graph, rdbg, result);
|
||||
result = tg_direct_from_graph_rdi_key(graph, rdi, result);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -350,7 +350,7 @@ eval_type_unwrap_enum(TG_Graph *graph, RDI_Parsed *rdbg, TG_Key key)
|
||||
}
|
||||
|
||||
internal TG_Key
|
||||
eval_type_promote(TG_Graph *graph, RDI_Parsed *rdbg, TG_Key key){
|
||||
eval_type_promote(TG_Graph *graph, RDI_Parsed *rdi, TG_Key key){
|
||||
TG_Key result = key;
|
||||
TG_Kind kind = tg_kind_from_key(key);
|
||||
if(kind == TG_Kind_Bool ||
|
||||
@@ -365,17 +365,17 @@ eval_type_promote(TG_Graph *graph, RDI_Parsed *rdbg, TG_Key key){
|
||||
}
|
||||
|
||||
internal TG_Key
|
||||
eval_type_coerce(TG_Graph *graph, RDI_Parsed *rdbg, TG_Key l, TG_Key r){
|
||||
eval_type_coerce(TG_Graph *graph, RDI_Parsed *rdi, 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)));
|
||||
|
||||
// replace enums with corresponding ints
|
||||
TG_Key lt = eval_type_unwrap_enum(graph, rdbg, l);
|
||||
TG_Key rt = eval_type_unwrap_enum(graph, rdbg, r);
|
||||
TG_Key lt = eval_type_unwrap_enum(graph, rdi, l);
|
||||
TG_Key rt = eval_type_unwrap_enum(graph, rdi, r);
|
||||
|
||||
// first promote each
|
||||
TG_Key lp = eval_type_promote(graph, rdbg, lt);
|
||||
TG_Key rp = eval_type_promote(graph, rdbg, rt);
|
||||
TG_Key lp = eval_type_promote(graph, rdi, lt);
|
||||
TG_Key rp = eval_type_promote(graph, rdi, rt);
|
||||
TG_Kind lk = tg_kind_from_key(lp);
|
||||
TG_Kind rk = tg_kind_from_key(rp);
|
||||
|
||||
@@ -384,12 +384,12 @@ eval_type_coerce(TG_Graph *graph, RDI_Parsed *rdbg, TG_Key l, TG_Key r){
|
||||
}
|
||||
|
||||
internal B32
|
||||
eval_type_match(TG_Graph *graph, RDI_Parsed *rdbg, TG_Key l, TG_Key r){
|
||||
eval_type_match(TG_Graph *graph, RDI_Parsed *rdi, TG_Key l, TG_Key r){
|
||||
B32 result = 0;
|
||||
|
||||
// unwrap
|
||||
TG_Key lu = tg_unwrapped_from_graph_rdi_key(graph, rdbg, l);
|
||||
TG_Key ru = tg_unwrapped_from_graph_rdi_key(graph, rdbg, r);
|
||||
TG_Key lu = tg_unwrapped_from_graph_rdi_key(graph, rdi, l);
|
||||
TG_Key ru = tg_unwrapped_from_graph_rdi_key(graph, rdi, r);
|
||||
|
||||
if (tg_key_match(lu, ru)){
|
||||
result = 1;
|
||||
@@ -408,21 +408,21 @@ eval_type_match(TG_Graph *graph, RDI_Parsed *rdbg, TG_Key l, TG_Key r){
|
||||
case TG_Kind_LRef:
|
||||
case TG_Kind_RRef:
|
||||
{
|
||||
TG_Key lud = tg_direct_from_graph_rdi_key(graph, rdbg, lu);
|
||||
TG_Key rud = tg_direct_from_graph_rdi_key(graph, rdbg, ru);
|
||||
if (eval_type_match(graph, rdbg, lud, rud)){
|
||||
TG_Key lud = tg_direct_from_graph_rdi_key(graph, rdi, lu);
|
||||
TG_Key rud = tg_direct_from_graph_rdi_key(graph, rdi, ru);
|
||||
if (eval_type_match(graph, rdi, lud, rud)){
|
||||
result = 1;
|
||||
}
|
||||
}break;
|
||||
|
||||
case TG_Kind_MemberPtr:
|
||||
{
|
||||
TG_Key lud = tg_direct_from_graph_rdi_key(graph, rdbg, lu);
|
||||
TG_Key rud = tg_direct_from_graph_rdi_key(graph, rdbg, ru);
|
||||
TG_Key luo = tg_owner_from_graph_rdi_key(graph, rdbg, lu);
|
||||
TG_Key ruo = tg_owner_from_graph_rdi_key(graph, rdbg, ru);
|
||||
if (eval_type_match(graph, rdbg, lud, rud) &&
|
||||
eval_type_match(graph, rdbg, luo, ruo)){
|
||||
TG_Key lud = tg_direct_from_graph_rdi_key(graph, rdi, lu);
|
||||
TG_Key rud = tg_direct_from_graph_rdi_key(graph, rdi, ru);
|
||||
TG_Key luo = tg_owner_from_graph_rdi_key(graph, rdi, lu);
|
||||
TG_Key ruo = tg_owner_from_graph_rdi_key(graph, rdi, ru);
|
||||
if (eval_type_match(graph, rdi, lud, rud) &&
|
||||
eval_type_match(graph, rdi, luo, ruo)){
|
||||
result = 1;
|
||||
}
|
||||
}break;
|
||||
@@ -430,9 +430,9 @@ eval_type_match(TG_Graph *graph, RDI_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_rdi_key(scratch.arena, graph, rdbg, l);
|
||||
TG_Type *rt = tg_type_from_graph_rdi_key(scratch.arena, graph, rdbg, r);
|
||||
if(lt->count == rt->count && eval_type_match(graph, rdbg, lt->direct_type_key, rt->direct_type_key))
|
||||
TG_Type *lt = tg_type_from_graph_rdi_key(scratch.arena, graph, rdi, l);
|
||||
TG_Type *rt = tg_type_from_graph_rdi_key(scratch.arena, graph, rdi, r);
|
||||
if(lt->count == rt->count && eval_type_match(graph, rdi, lt->direct_type_key, rt->direct_type_key))
|
||||
{
|
||||
result = 1;
|
||||
}
|
||||
@@ -442,9 +442,9 @@ eval_type_match(TG_Graph *graph, RDI_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_rdi_key(scratch.arena, graph, rdbg, l);
|
||||
TG_Type *rt = tg_type_from_graph_rdi_key(scratch.arena, graph, rdbg, r);
|
||||
if (lt->count == rt->count && eval_type_match(graph, rdbg, lt->direct_type_key, rt->direct_type_key))
|
||||
TG_Type *lt = tg_type_from_graph_rdi_key(scratch.arena, graph, rdi, l);
|
||||
TG_Type *rt = tg_type_from_graph_rdi_key(scratch.arena, graph, rdi, r);
|
||||
if (lt->count == rt->count && eval_type_match(graph, rdi, lt->direct_type_key, rt->direct_type_key))
|
||||
{
|
||||
B32 params_match = 1;
|
||||
TG_Key *lp = lt->param_type_keys;
|
||||
@@ -452,7 +452,7 @@ eval_type_match(TG_Graph *graph, RDI_Parsed *rdbg, TG_Key l, TG_Key r){
|
||||
U64 count = lt->count;
|
||||
for(U64 i = 0; i < count; i += 1, lp += 1, rp += 1)
|
||||
{
|
||||
if(!eval_type_match(graph, rdbg, *lp, *rp))
|
||||
if(!eval_type_match(graph, rdi, *lp, *rp))
|
||||
{
|
||||
params_match = 0;
|
||||
break;
|
||||
@@ -466,11 +466,11 @@ eval_type_match(TG_Graph *graph, RDI_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_rdi_key(scratch.arena, graph, rdbg, l);
|
||||
TG_Type *rt = tg_type_from_graph_rdi_key(scratch.arena, graph, rdbg, r);
|
||||
TG_Type *lt = tg_type_from_graph_rdi_key(scratch.arena, graph, rdi, l);
|
||||
TG_Type *rt = tg_type_from_graph_rdi_key(scratch.arena, graph, rdi, 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))
|
||||
eval_type_match(graph, rdi, lt->direct_type_key, rt->direct_type_key) &&
|
||||
eval_type_match(graph, rdi, lt->owner_type_key, rt->owner_type_key))
|
||||
{
|
||||
B32 params_match = 1;
|
||||
TG_Key *lp = lt->param_type_keys;
|
||||
@@ -478,7 +478,7 @@ eval_type_match(TG_Graph *graph, RDI_Parsed *rdbg, TG_Key l, TG_Key r){
|
||||
U64 count = lt->count;
|
||||
for(U64 i = 0; i < count; i += 1, lp += 1, rp += 1)
|
||||
{
|
||||
if(!eval_type_match(graph, rdbg, *lp, *rp))
|
||||
if(!eval_type_match(graph, rdi, *lp, *rp))
|
||||
{
|
||||
params_match = 0;
|
||||
break;
|
||||
@@ -589,8 +589,8 @@ 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, RDI_Parsed *rdbg, EVAL_IRTree *c, TG_Key type_key){
|
||||
U64 byte_size = tg_byte_size_from_graph_rdi_key(graph, rdbg, type_key);
|
||||
eval_irtree_mem_read_type(Arena *arena, TG_Graph *graph, RDI_Parsed *rdi, EVAL_IRTree *c, TG_Key type_key){
|
||||
U64 byte_size = tg_byte_size_from_graph_rdi_key(graph, rdi, type_key);
|
||||
EVAL_IRTree *result = &eval_irtree_nil;
|
||||
if (0 < byte_size && byte_size <= 8){
|
||||
// build the read node
|
||||
@@ -629,9 +629,9 @@ eval_irtree_convert_lo(Arena *arena, EVAL_IRTree *c, RDI_EvalTypeGroup out, RDI_
|
||||
}
|
||||
|
||||
internal EVAL_IRTree*
|
||||
eval_irtree_trunc(Arena *arena, TG_Graph *graph, RDI_Parsed *rdbg, EVAL_IRTree *c, TG_Key type_key){
|
||||
eval_irtree_trunc(Arena *arena, TG_Graph *graph, RDI_Parsed *rdi, EVAL_IRTree *c, TG_Key type_key){
|
||||
EVAL_IRTree *result = c;
|
||||
U64 byte_size = tg_byte_size_from_graph_rdi_key(graph, rdbg, type_key);
|
||||
U64 byte_size = tg_byte_size_from_graph_rdi_key(graph, rdi, type_key);
|
||||
if (byte_size < 64){
|
||||
RDI_EvalOp op = RDI_EvalOp_Trunc;
|
||||
TG_Kind kind = tg_kind_from_key(type_key);
|
||||
@@ -648,7 +648,7 @@ eval_irtree_trunc(Arena *arena, TG_Graph *graph, RDI_Parsed *rdbg, EVAL_IRTree *
|
||||
}
|
||||
|
||||
internal EVAL_IRTree*
|
||||
eval_irtree_convert_hi(Arena *arena, TG_Graph *graph, RDI_Parsed *rdbg, EVAL_IRTree *c, TG_Key out, TG_Key in){
|
||||
eval_irtree_convert_hi(Arena *arena, TG_Graph *graph, RDI_Parsed *rdi, 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);
|
||||
@@ -659,24 +659,24 @@ eval_irtree_convert_hi(Arena *arena, TG_Graph *graph, RDI_Parsed *rdbg, EVAL_IRT
|
||||
{
|
||||
result = eval_irtree_convert_lo(arena, result, out_group, in_group);
|
||||
}
|
||||
U64 in_byte_size = tg_byte_size_from_graph_rdi_key(graph, rdbg, in);
|
||||
U64 out_byte_size = tg_byte_size_from_graph_rdi_key(graph, rdbg, out);
|
||||
U64 in_byte_size = tg_byte_size_from_graph_rdi_key(graph, rdi, in);
|
||||
U64 out_byte_size = tg_byte_size_from_graph_rdi_key(graph, rdi, out);
|
||||
if(out_byte_size < in_byte_size && eval_kind_is_integer(out_kind))
|
||||
{
|
||||
result = eval_irtree_trunc(arena, graph, rdbg, result, out);
|
||||
result = eval_irtree_trunc(arena, graph, rdi, result, out);
|
||||
}
|
||||
return(result);
|
||||
}
|
||||
|
||||
internal EVAL_IRTree*
|
||||
eval_irtree_resolve_to_value(Arena *arena, TG_Graph *graph, RDI_Parsed *rdbg, EVAL_EvalMode from_mode,
|
||||
eval_irtree_resolve_to_value(Arena *arena, TG_Graph *graph, RDI_Parsed *rdi, EVAL_EvalMode from_mode,
|
||||
EVAL_IRTree *tree, TG_Key type_key){
|
||||
EVAL_IRTree *result = tree;
|
||||
switch (from_mode){
|
||||
default:{}break;
|
||||
case EVAL_EvalMode_Addr:
|
||||
{
|
||||
result = eval_irtree_mem_read_type(arena, graph, rdbg, tree, type_key);
|
||||
result = eval_irtree_mem_read_type(arena, graph, rdi, tree, type_key);
|
||||
}break;
|
||||
case EVAL_EvalMode_Reg:
|
||||
{
|
||||
@@ -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, RDI_Parsed *rdbg, EVAL_Expr *expr, EVAL_ErrorList *eout){
|
||||
eval_type_from_type_expr(Arena *arena, TG_Graph *graph, RDI_Parsed *rdi, EVAL_Expr *expr, EVAL_ErrorList *eout){
|
||||
TG_Key result = zero_struct;
|
||||
|
||||
EVAL_ExprKind kind = expr->kind;
|
||||
@@ -732,14 +732,14 @@ eval_type_from_type_expr(Arena *arena, TG_Graph *graph, RDI_Parsed *rdbg, EVAL_E
|
||||
|
||||
case EVAL_ExprKind_Ptr:
|
||||
{
|
||||
TG_Key direct_type_key = eval_type_from_type_expr(arena, graph, rdbg, expr->children[0], eout);
|
||||
TG_Key direct_type_key = eval_type_from_type_expr(arena, graph, rdi, expr->children[0], eout);
|
||||
result = tg_cons_type_make(graph, TG_Kind_Ptr, direct_type_key, 0);
|
||||
}break;
|
||||
|
||||
case EVAL_ExprKind_Array:
|
||||
{
|
||||
EVAL_Expr *child_expr = expr->child_and_constant.child;
|
||||
TG_Key direct_type_key = eval_type_from_type_expr(arena, graph, rdbg, child_expr, eout);
|
||||
TG_Key direct_type_key = eval_type_from_type_expr(arena, graph, rdi, child_expr, eout);
|
||||
result = tg_cons_type_make(graph, TG_Kind_Array, direct_type_key, expr->child_and_constant.u64);
|
||||
}break;
|
||||
|
||||
@@ -758,7 +758,7 @@ eval_type_from_type_expr(Arena *arena, TG_Graph *graph, RDI_Parsed *rdbg, EVAL_E
|
||||
}
|
||||
|
||||
internal EVAL_IRTreeAndType
|
||||
eval_irtree_and_type_from_expr(Arena *arena, TG_Graph *graph, RDI_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, RDI_Parsed *rdi, EVAL_String2ExprMap *leaf_ident_expr_map, EVAL_Expr *expr, EVAL_ErrorList *eout)
|
||||
{
|
||||
ProfBeginFunction();
|
||||
EVAL_IRTreeAndType result = {0};
|
||||
@@ -777,12 +777,12 @@ eval_irtree_and_type_from_expr(Arena *arena, TG_Graph *graph, RDI_Parsed *rdbg,
|
||||
EVAL_Expr *exprl = expr->children[0];
|
||||
EVAL_Expr *exprr = expr->children[1];
|
||||
|
||||
EVAL_IRTreeAndType l = eval_irtree_and_type_from_expr(arena, graph, rdbg, leaf_ident_expr_map, exprl, eout);
|
||||
EVAL_IRTreeAndType r = eval_irtree_and_type_from_expr(arena, graph, rdbg, leaf_ident_expr_map, exprr, eout);
|
||||
EVAL_IRTreeAndType l = eval_irtree_and_type_from_expr(arena, graph, rdi, leaf_ident_expr_map, exprl, eout);
|
||||
EVAL_IRTreeAndType r = eval_irtree_and_type_from_expr(arena, graph, rdi, leaf_ident_expr_map, exprr, eout);
|
||||
|
||||
if (l.tree->op != 0 && r.tree->op != 0){
|
||||
TG_Key l_restype = tg_unwrapped_from_graph_rdi_key(graph, rdbg, l.type_key);
|
||||
TG_Key r_restype = tg_unwrapped_from_graph_rdi_key(graph, rdbg, r.type_key);
|
||||
TG_Key l_restype = tg_unwrapped_from_graph_rdi_key(graph, rdi, l.type_key);
|
||||
TG_Key r_restype = tg_unwrapped_from_graph_rdi_key(graph, rdi, 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, RDI_Parsed *rdbg,
|
||||
eval_errorf(arena, eout, EVAL_ErrorKind_MalformedInput, exprr->location, "Cannot index with this type.");
|
||||
}
|
||||
else{
|
||||
direct_type = tg_unwrapped_direct_from_graph_rdi_key(graph, rdbg, l_restype);
|
||||
direct_type_size = tg_byte_size_from_graph_rdi_key(graph, rdbg, direct_type);
|
||||
direct_type = tg_unwrapped_direct_from_graph_rdi_key(graph, rdi, l_restype);
|
||||
direct_type_size = tg_byte_size_from_graph_rdi_key(graph, rdi, 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.");
|
||||
@@ -829,7 +829,7 @@ eval_irtree_and_type_from_expr(Arena *arena, TG_Graph *graph, RDI_Parsed *rdbg,
|
||||
// generate ir tree
|
||||
if (can_generate){
|
||||
// how to compute the index
|
||||
EVAL_IRTree *index_tree = eval_irtree_resolve_to_value(arena, graph, rdbg, r.mode, r.tree, r_restype);
|
||||
EVAL_IRTree *index_tree = eval_irtree_resolve_to_value(arena, graph, rdi, 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, RDI_EvalOp_Mul, index_tree, const_tree);
|
||||
@@ -838,7 +838,7 @@ eval_irtree_and_type_from_expr(Arena *arena, TG_Graph *graph, RDI_Parsed *rdbg,
|
||||
// how to compute the base address
|
||||
EVAL_IRTree *base_tree = l.tree;
|
||||
if (l_resolve){
|
||||
base_tree = eval_irtree_resolve_to_value(arena, graph, rdbg, l.mode, base_tree, l_restype);
|
||||
base_tree = eval_irtree_resolve_to_value(arena, graph, rdi, l.mode, base_tree, l_restype);
|
||||
}
|
||||
|
||||
// how to compute the final address
|
||||
@@ -857,17 +857,17 @@ eval_irtree_and_type_from_expr(Arena *arena, TG_Graph *graph, RDI_Parsed *rdbg,
|
||||
EVAL_Expr *exprl = expr->children[0];
|
||||
EVAL_Expr *exprr = expr->children[1];
|
||||
|
||||
EVAL_IRTreeAndType l = eval_irtree_and_type_from_expr(arena, graph, rdbg, leaf_ident_expr_map, exprl, eout);
|
||||
EVAL_IRTreeAndType l = eval_irtree_and_type_from_expr(arena, graph, rdi, 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_rdi_key(graph, rdbg, l.type_key);
|
||||
TG_Key l_restype = tg_unwrapped_from_graph_rdi_key(graph, rdi, 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_rdi_key(graph, rdbg, l_restype);
|
||||
check_type_key = tg_unwrapped_direct_from_graph_rdi_key(graph, rdi, 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, RDI_Parsed *rdbg,
|
||||
|
||||
if (l_good && r_good){
|
||||
Temp scratch = scratch_begin(&arena, 1);
|
||||
TG_MemberArray check_type_members = tg_data_members_from_graph_rdi_key(scratch.arena, graph, rdbg, check_type_key);
|
||||
TG_MemberArray check_type_members = tg_data_members_from_graph_rdi_key(scratch.arena, graph, rdi, check_type_key);
|
||||
|
||||
// lookup member
|
||||
String8 member_name = exprr->name;
|
||||
@@ -953,7 +953,7 @@ eval_irtree_and_type_from_expr(Arena *arena, TG_Graph *graph, RDI_Parsed *rdbg,
|
||||
if (can_generate){
|
||||
EVAL_IRTree *new_tree = l.tree;
|
||||
if (l_resolve){
|
||||
new_tree = eval_irtree_resolve_to_value(arena, graph, rdbg, l.mode, new_tree, l_restype);
|
||||
new_tree = eval_irtree_resolve_to_value(arena, graph, rdi, l.mode, new_tree, l_restype);
|
||||
}
|
||||
if (r_off != 0){
|
||||
EVAL_IRTree *const_tree = eval_irtree_const_u(arena, r_off);
|
||||
@@ -975,13 +975,13 @@ eval_irtree_and_type_from_expr(Arena *arena, TG_Graph *graph, RDI_Parsed *rdbg,
|
||||
{
|
||||
EVAL_Expr *exprc = expr->children[0];
|
||||
|
||||
EVAL_IRTreeAndType c = eval_irtree_and_type_from_expr(arena, graph, rdbg, leaf_ident_expr_map, exprc, eout);
|
||||
EVAL_IRTreeAndType c = eval_irtree_and_type_from_expr(arena, graph, rdi, leaf_ident_expr_map, exprc, eout);
|
||||
|
||||
if (c.tree->op != 0){
|
||||
TG_Key c_restype = tg_unwrapped_from_graph_rdi_key(graph, rdbg, c.type_key);
|
||||
TG_Key c_restype = tg_unwrapped_from_graph_rdi_key(graph, rdi, c.type_key);
|
||||
TG_Kind c_restype_kind = tg_kind_from_key(c_restype);
|
||||
TG_Key c_restype_direct = tg_unwrapped_direct_from_graph_rdi_key(graph, rdbg, c_restype);
|
||||
U64 c_restype_direct_size = tg_byte_size_from_graph_rdi_key(graph, rdbg, c_restype_direct);
|
||||
TG_Key c_restype_direct = tg_unwrapped_direct_from_graph_rdi_key(graph, rdi, c_restype);
|
||||
U64 c_restype_direct_size = tg_byte_size_from_graph_rdi_key(graph, rdi, c_restype_direct);
|
||||
|
||||
// analyze situation
|
||||
B32 can_generate = 0;
|
||||
@@ -1018,7 +1018,7 @@ eval_irtree_and_type_from_expr(Arena *arena, TG_Graph *graph, RDI_Parsed *rdbg,
|
||||
if (can_generate){
|
||||
EVAL_IRTree *new_tree = c.tree;
|
||||
if (c_resolve){
|
||||
new_tree = eval_irtree_resolve_to_value(arena, graph, rdbg, c.mode, c.tree, c_restype);
|
||||
new_tree = eval_irtree_resolve_to_value(arena, graph, rdi, c.mode, c.tree, c_restype);
|
||||
}
|
||||
|
||||
// fill result
|
||||
@@ -1032,10 +1032,10 @@ eval_irtree_and_type_from_expr(Arena *arena, TG_Graph *graph, RDI_Parsed *rdbg,
|
||||
case EVAL_ExprKind_Address:
|
||||
{
|
||||
EVAL_Expr *exprc = expr->children[0];
|
||||
EVAL_IRTreeAndType c = eval_irtree_and_type_from_expr(arena, graph, rdbg, leaf_ident_expr_map, exprc, eout);
|
||||
EVAL_IRTreeAndType c = eval_irtree_and_type_from_expr(arena, graph, rdi, 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_rdi_key(graph, rdbg, c.type_key);
|
||||
TG_Key c_restype = tg_unwrapped_from_graph_rdi_key(graph, rdi, c.type_key);
|
||||
TG_Kind c_restype_kind = tg_kind_from_key(c_restype);
|
||||
|
||||
// analyze situation
|
||||
@@ -1064,16 +1064,16 @@ eval_irtree_and_type_from_expr(Arena *arena, TG_Graph *graph, RDI_Parsed *rdbg,
|
||||
EVAL_Expr *exprl = expr->children[0];
|
||||
EVAL_Expr *exprr = expr->children[1];
|
||||
|
||||
TG_Key cast_type_key = eval_type_from_type_expr(arena, graph, rdbg, exprl, eout);
|
||||
TG_Key cast_type_key = eval_type_from_type_expr(arena, graph, rdi, exprl, eout);
|
||||
TG_Kind cast_type_kind = tg_kind_from_key(cast_type_key);
|
||||
EVAL_IRTreeAndType c = eval_irtree_and_type_from_expr(arena, graph, rdbg, leaf_ident_expr_map, exprr, eout);
|
||||
EVAL_IRTreeAndType c = eval_irtree_and_type_from_expr(arena, graph, rdi, leaf_ident_expr_map, exprr, eout);
|
||||
|
||||
if(cast_type_kind != TG_Kind_Null && c.tree->op != 0)
|
||||
{
|
||||
TG_Key c_restype = tg_unwrapped_from_graph_rdi_key(graph, rdbg, c.type_key);
|
||||
TG_Key c_restype = tg_unwrapped_from_graph_rdi_key(graph, rdi, c.type_key);
|
||||
TG_Kind c_restype_kind = tg_kind_from_key(c_restype);
|
||||
U64 c_restype_byte_size = tg_byte_size_from_graph_rdi_key(graph, rdbg, c_restype);
|
||||
U64 cast_type_byte_size = tg_byte_size_from_graph_rdi_key(graph, rdbg, cast_type_key);
|
||||
U64 c_restype_byte_size = tg_byte_size_from_graph_rdi_key(graph, rdi, c_restype);
|
||||
U64 cast_type_byte_size = tg_byte_size_from_graph_rdi_key(graph, rdi, cast_type_key);
|
||||
|
||||
// analyze situation
|
||||
U8 in_group = eval_type_group_from_kind(c_restype_kind);
|
||||
@@ -1086,14 +1086,14 @@ eval_irtree_and_type_from_expr(Arena *arena, TG_Graph *graph, RDI_Parsed *rdbg,
|
||||
case RDI_EvalConversionKind_Noop:
|
||||
case RDI_EvalConversionKind_Legal:
|
||||
{
|
||||
EVAL_IRTree *in_tree = eval_irtree_resolve_to_value(arena, graph, rdbg, c.mode, c.tree, c_restype);
|
||||
EVAL_IRTree *in_tree = eval_irtree_resolve_to_value(arena, graph, rdi, c.mode, c.tree, c_restype);
|
||||
|
||||
EVAL_IRTree *new_tree = in_tree;
|
||||
if (conversion_rule == RDI_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)){
|
||||
new_tree = eval_irtree_trunc(arena, graph, rdbg, in_tree, cast_type_key);
|
||||
new_tree = eval_irtree_trunc(arena, graph, rdi, in_tree, cast_type_key);
|
||||
}
|
||||
|
||||
result.tree = new_tree;
|
||||
@@ -1126,13 +1126,13 @@ eval_irtree_and_type_from_expr(Arena *arena, TG_Graph *graph, RDI_Parsed *rdbg,
|
||||
case EVAL_ExprKind_Array:
|
||||
case EVAL_ExprKind_Func:
|
||||
{
|
||||
type_key = eval_type_from_type_expr(arena, graph, rdbg, exprc, eout);
|
||||
type_key = eval_type_from_type_expr(arena, graph, rdi, exprc, eout);
|
||||
}break;
|
||||
|
||||
// size of value expression
|
||||
default:
|
||||
{
|
||||
EVAL_IRTreeAndType c = eval_irtree_and_type_from_expr(arena, graph, rdbg, leaf_ident_expr_map, exprc, eout);
|
||||
EVAL_IRTreeAndType c = eval_irtree_and_type_from_expr(arena, graph, rdi, leaf_ident_expr_map, exprc, eout);
|
||||
type_key = c.type_key;
|
||||
}break;
|
||||
}
|
||||
@@ -1141,7 +1141,7 @@ eval_irtree_and_type_from_expr(Arena *arena, TG_Graph *graph, RDI_Parsed *rdbg,
|
||||
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_rdi_key(graph, rdbg, type_key);
|
||||
size = tg_byte_size_from_graph_rdi_key(graph, rdi, type_key);
|
||||
}
|
||||
|
||||
// generate ir tree
|
||||
@@ -1160,10 +1160,10 @@ eval_irtree_and_type_from_expr(Arena *arena, TG_Graph *graph, RDI_Parsed *rdbg,
|
||||
{
|
||||
EVAL_Expr *exprc = expr->children[0];
|
||||
|
||||
EVAL_IRTreeAndType c = eval_irtree_and_type_from_expr(arena, graph, rdbg, leaf_ident_expr_map, exprc, eout);
|
||||
EVAL_IRTreeAndType c = eval_irtree_and_type_from_expr(arena, graph, rdi, leaf_ident_expr_map, exprc, eout);
|
||||
if (c.tree->op != 0){
|
||||
TG_Key c_restype = tg_unwrapped_from_graph_rdi_key(graph, rdbg, c.type_key);
|
||||
TG_Key p_type = eval_type_promote(graph, rdbg, c_restype);
|
||||
TG_Key c_restype = tg_unwrapped_from_graph_rdi_key(graph, rdi, c.type_key);
|
||||
TG_Key p_type = eval_type_promote(graph, rdi, c_restype);
|
||||
TG_Kind c_restype_kind = tg_kind_from_key(c_restype);
|
||||
|
||||
// analyze situation
|
||||
@@ -1179,8 +1179,8 @@ eval_irtree_and_type_from_expr(Arena *arena, TG_Graph *graph, RDI_Parsed *rdbg,
|
||||
|
||||
// generate ir tree
|
||||
if (can_generate){
|
||||
EVAL_IRTree *in_tree = eval_irtree_resolve_to_value(arena, graph, rdbg, c.mode, c.tree, c_restype);
|
||||
in_tree = eval_irtree_convert_hi(arena, graph, rdbg, in_tree, p_type, c_restype);
|
||||
EVAL_IRTree *in_tree = eval_irtree_resolve_to_value(arena, graph, rdi, c.mode, c.tree, c_restype);
|
||||
in_tree = eval_irtree_convert_hi(arena, graph, rdi, in_tree, p_type, c_restype);
|
||||
|
||||
EVAL_IRTree *new_tree = eval_irtree_unary_op(arena, op, c_group, in_tree);
|
||||
|
||||
@@ -1214,12 +1214,12 @@ eval_irtree_and_type_from_expr(Arena *arena, TG_Graph *graph, RDI_Parsed *rdbg,
|
||||
EVAL_Expr *exprl = expr->children[0];
|
||||
EVAL_Expr *exprr = expr->children[1];
|
||||
|
||||
EVAL_IRTreeAndType l = eval_irtree_and_type_from_expr(arena, graph, rdbg, leaf_ident_expr_map, exprl, eout);
|
||||
EVAL_IRTreeAndType r = eval_irtree_and_type_from_expr(arena, graph, rdbg, leaf_ident_expr_map, exprr, eout);
|
||||
EVAL_IRTreeAndType l = eval_irtree_and_type_from_expr(arena, graph, rdi, leaf_ident_expr_map, exprl, eout);
|
||||
EVAL_IRTreeAndType r = eval_irtree_and_type_from_expr(arena, graph, rdi, leaf_ident_expr_map, exprr, eout);
|
||||
|
||||
if (l.tree->op != 0 && r.tree->op != 0){
|
||||
TG_Key l_restype = tg_unwrapped_from_graph_rdi_key(graph, rdbg, l.type_key);
|
||||
TG_Key r_restype = tg_unwrapped_from_graph_rdi_key(graph, rdbg, r.type_key);
|
||||
TG_Key l_restype = tg_unwrapped_from_graph_rdi_key(graph, rdi, l.type_key);
|
||||
TG_Key r_restype = tg_unwrapped_from_graph_rdi_key(graph, rdi, 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);
|
||||
|
||||
@@ -1267,10 +1267,10 @@ eval_irtree_and_type_from_expr(Arena *arena, TG_Graph *graph, RDI_Parsed *rdbg,
|
||||
arith_path = EVAL_ArithPath_PtrAdd;
|
||||
}
|
||||
if (l_is_pointer_like && r_is_pointer_like){
|
||||
TG_Key l_restype_direct = tg_unwrapped_direct_from_graph_rdi_key(graph, rdbg, l_restype);
|
||||
TG_Key r_restype_direct = tg_unwrapped_direct_from_graph_rdi_key(graph, rdbg, r_restype);
|
||||
U64 l_restype_direct_byte_size = tg_byte_size_from_graph_rdi_key(graph, rdbg, l_restype_direct);
|
||||
U64 r_restype_direct_byte_size = tg_byte_size_from_graph_rdi_key(graph, rdbg, r_restype_direct);
|
||||
TG_Key l_restype_direct = tg_unwrapped_direct_from_graph_rdi_key(graph, rdi, l_restype);
|
||||
TG_Key r_restype_direct = tg_unwrapped_direct_from_graph_rdi_key(graph, rdi, r_restype);
|
||||
U64 l_restype_direct_byte_size = tg_byte_size_from_graph_rdi_key(graph, rdi, l_restype_direct);
|
||||
U64 r_restype_direct_byte_size = tg_byte_size_from_graph_rdi_key(graph, rdi, r_restype_direct);
|
||||
if (l_restype_direct_byte_size == r_restype_direct_byte_size){
|
||||
arith_path = EVAL_ArithPath_PtrSub;
|
||||
}
|
||||
@@ -1289,9 +1289,9 @@ eval_irtree_and_type_from_expr(Arena *arena, TG_Graph *graph, RDI_Parsed *rdbg,
|
||||
|
||||
TG_Key cv_type_key = zero_struct;
|
||||
if (both_basic){
|
||||
cv_type_key = eval_type_coerce(graph, rdbg, l_restype, r_restype);
|
||||
cv_type_key = eval_type_coerce(graph, rdi, l_restype, r_restype);
|
||||
}
|
||||
else if (is_comparison && eval_type_match(graph, rdbg, l_restype, r_restype)){
|
||||
else if (is_comparison && eval_type_match(graph, rdi, l_restype, r_restype)){
|
||||
cv_type_key = l_restype;
|
||||
}
|
||||
|
||||
@@ -1313,11 +1313,11 @@ eval_irtree_and_type_from_expr(Arena *arena, TG_Graph *graph, RDI_Parsed *rdbg,
|
||||
final_type_key = tg_key_basic(TG_Kind_Bool);
|
||||
}
|
||||
|
||||
EVAL_IRTree *l_tree = eval_irtree_resolve_to_value(arena, graph, rdbg, l.mode, l.tree, l_restype);
|
||||
l_tree = eval_irtree_convert_hi(arena, graph, rdbg, l_tree, cv_type_key, l_restype);
|
||||
EVAL_IRTree *l_tree = eval_irtree_resolve_to_value(arena, graph, rdi, l.mode, l.tree, l_restype);
|
||||
l_tree = eval_irtree_convert_hi(arena, graph, rdi, l_tree, cv_type_key, l_restype);
|
||||
|
||||
EVAL_IRTree *r_tree = eval_irtree_resolve_to_value(arena, graph, rdbg, r.mode, r.tree, r_restype);
|
||||
r_tree = eval_irtree_convert_hi(arena, graph, rdbg, r_tree, cv_type_key, r_restype);
|
||||
EVAL_IRTree *r_tree = eval_irtree_resolve_to_value(arena, graph, rdi, r.mode, r.tree, r_restype);
|
||||
r_tree = eval_irtree_convert_hi(arena, graph, rdi, r_tree, cv_type_key, r_restype);
|
||||
|
||||
EVAL_IRTree *new_tree = eval_irtree_binary_op(arena, op, cv_group, l_tree, r_tree);
|
||||
|
||||
@@ -1339,16 +1339,16 @@ eval_irtree_and_type_from_expr(Arena *arena, TG_Graph *graph, RDI_Parsed *rdbg,
|
||||
ptr_is_decay = r_is_decay;
|
||||
}
|
||||
|
||||
TG_Key direct = tg_unwrapped_direct_from_graph_rdi_key(graph, rdbg, ptr->type_key);
|
||||
U64 direct_type_size = tg_byte_size_from_graph_rdi_key(graph, rdbg, direct);
|
||||
TG_Key direct = tg_unwrapped_direct_from_graph_rdi_key(graph, rdi, ptr->type_key);
|
||||
U64 direct_type_size = tg_byte_size_from_graph_rdi_key(graph, rdi, direct);
|
||||
|
||||
// generate ir tree
|
||||
EVAL_IRTree *ptr_tree = ptr->tree;
|
||||
if (!ptr_is_decay){
|
||||
ptr_tree = eval_irtree_resolve_to_value(arena, graph, rdbg, ptr->mode, ptr_tree, ptr->type_key);
|
||||
ptr_tree = eval_irtree_resolve_to_value(arena, graph, rdi, ptr->mode, ptr_tree, ptr->type_key);
|
||||
}
|
||||
|
||||
EVAL_IRTree *integer_tree = eval_irtree_resolve_to_value(arena, graph, rdbg, integer->mode, integer->tree, integer->type_key);
|
||||
EVAL_IRTree *integer_tree = eval_irtree_resolve_to_value(arena, graph, rdi, 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, RDI_EvalOp_Mul, integer_tree, const_tree);
|
||||
@@ -1368,18 +1368,18 @@ eval_irtree_and_type_from_expr(Arena *arena, TG_Graph *graph, RDI_Parsed *rdbg,
|
||||
|
||||
case EVAL_ArithPath_PtrSub:
|
||||
{
|
||||
TG_Key direct = tg_unwrapped_direct_from_graph_rdi_key(graph, rdbg, l_restype);
|
||||
U64 direct_type_size = tg_byte_size_from_graph_rdi_key(graph, rdbg, direct);
|
||||
TG_Key direct = tg_unwrapped_direct_from_graph_rdi_key(graph, rdi, l_restype);
|
||||
U64 direct_type_size = tg_byte_size_from_graph_rdi_key(graph, rdi, direct);
|
||||
|
||||
// generate ir tree
|
||||
EVAL_IRTree *l_tree = l.tree;
|
||||
if (!l_is_decay){
|
||||
l_tree = eval_irtree_resolve_to_value(arena, graph, rdbg, l.mode, l.tree, l_restype);
|
||||
l_tree = eval_irtree_resolve_to_value(arena, graph, rdi, l.mode, l.tree, l_restype);
|
||||
}
|
||||
|
||||
EVAL_IRTree *r_tree = r.tree;
|
||||
if (!r_is_decay){
|
||||
r_tree = eval_irtree_resolve_to_value(arena, graph, rdbg, r.mode, r.tree, r_restype);
|
||||
r_tree = eval_irtree_resolve_to_value(arena, graph, rdi, r.mode, r.tree, r_restype);
|
||||
}
|
||||
|
||||
EVAL_IRTree *op_tree = eval_irtree_binary_op(arena, op, RDI_EvalTypeGroup_U, l_tree, r_tree);
|
||||
@@ -1404,15 +1404,15 @@ eval_irtree_and_type_from_expr(Arena *arena, TG_Graph *graph, RDI_Parsed *rdbg,
|
||||
EVAL_Expr *exprl = expr->children[1];
|
||||
EVAL_Expr *exprr = expr->children[2];
|
||||
|
||||
EVAL_IRTreeAndType c = eval_irtree_and_type_from_expr(arena, graph, rdbg, leaf_ident_expr_map, exprc, eout);
|
||||
EVAL_IRTreeAndType l = eval_irtree_and_type_from_expr(arena, graph, rdbg, leaf_ident_expr_map, exprl, eout);
|
||||
EVAL_IRTreeAndType r = eval_irtree_and_type_from_expr(arena, graph, rdbg, leaf_ident_expr_map, exprr, eout);
|
||||
EVAL_IRTreeAndType c = eval_irtree_and_type_from_expr(arena, graph, rdi, leaf_ident_expr_map, exprc, eout);
|
||||
EVAL_IRTreeAndType l = eval_irtree_and_type_from_expr(arena, graph, rdi, leaf_ident_expr_map, exprl, eout);
|
||||
EVAL_IRTreeAndType r = eval_irtree_and_type_from_expr(arena, graph, rdi, leaf_ident_expr_map, exprr, eout);
|
||||
|
||||
if (l.tree->op != 0 && r.tree->op != 0 && c.tree->op != 0){
|
||||
|
||||
TG_Key c_restype = tg_unwrapped_from_graph_rdi_key(graph, rdbg, c.type_key);
|
||||
TG_Key l_restype = tg_unwrapped_from_graph_rdi_key(graph, rdbg, l.type_key);
|
||||
TG_Key r_restype = tg_unwrapped_from_graph_rdi_key(graph, rdbg, r.type_key);
|
||||
TG_Key c_restype = tg_unwrapped_from_graph_rdi_key(graph, rdi, c.type_key);
|
||||
TG_Key l_restype = tg_unwrapped_from_graph_rdi_key(graph, rdi, l.type_key);
|
||||
TG_Key r_restype = tg_unwrapped_from_graph_rdi_key(graph, rdi, 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);
|
||||
@@ -1427,10 +1427,10 @@ eval_irtree_and_type_from_expr(Arena *arena, TG_Graph *graph, RDI_Parsed *rdbg,
|
||||
if (eval_kind_is_basic_or_enum(l_restype_kind) &&
|
||||
eval_kind_is_basic_or_enum(r_restype_kind)){
|
||||
can_generate = 1;
|
||||
final_type = eval_type_coerce(graph, rdbg, l_restype, r_restype);
|
||||
final_type = eval_type_coerce(graph, rdi, l_restype, r_restype);
|
||||
}
|
||||
else{
|
||||
if (eval_type_match(graph, rdbg, l_restype, r_restype)){
|
||||
if (eval_type_match(graph, rdi, l_restype, r_restype)){
|
||||
if (l_restype_kind == TG_Kind_Ptr){
|
||||
can_generate = 1;
|
||||
final_type = l_restype;
|
||||
@@ -1447,13 +1447,13 @@ eval_irtree_and_type_from_expr(Arena *arena, TG_Graph *graph, RDI_Parsed *rdbg,
|
||||
|
||||
// generate ir tree
|
||||
if (can_generate){
|
||||
EVAL_IRTree *c_tree = eval_irtree_resolve_to_value(arena, graph, rdbg, c.mode, c.tree, c_restype);
|
||||
EVAL_IRTree *c_tree = eval_irtree_resolve_to_value(arena, graph, rdi, c.mode, c.tree, c_restype);
|
||||
|
||||
EVAL_IRTree *l_tree = eval_irtree_resolve_to_value(arena, graph, rdbg, l.mode, l.tree, l_restype);
|
||||
l_tree = eval_irtree_convert_hi(arena, graph, rdbg, l_tree, final_type, l_restype);
|
||||
EVAL_IRTree *l_tree = eval_irtree_resolve_to_value(arena, graph, rdi, l.mode, l.tree, l_restype);
|
||||
l_tree = eval_irtree_convert_hi(arena, graph, rdi, l_tree, final_type, l_restype);
|
||||
|
||||
EVAL_IRTree *r_tree = eval_irtree_resolve_to_value(arena, graph, rdbg, r.mode, r.tree, r_restype);
|
||||
r_tree = eval_irtree_convert_hi(arena, graph, rdbg, r_tree, final_type, r_restype);
|
||||
EVAL_IRTree *r_tree = eval_irtree_resolve_to_value(arena, graph, rdi, r.mode, r.tree, r_restype);
|
||||
r_tree = eval_irtree_convert_hi(arena, graph, rdi, r_tree, final_type, r_restype);
|
||||
|
||||
EVAL_IRTree *new_tree = eval_irtree_conditional(arena, c_tree, l_tree, r_tree);
|
||||
|
||||
@@ -1540,7 +1540,7 @@ eval_irtree_and_type_from_expr(Arena *arena, TG_Graph *graph, RDI_Parsed *rdbg,
|
||||
{
|
||||
eval_errorf(arena, eout, EVAL_ErrorKind_MalformedInput, expr->location, "Left side of assignment must be an identifier.");
|
||||
}
|
||||
result = eval_irtree_and_type_from_expr(arena, graph, rdbg, leaf_ident_expr_map, expr->children[1], eout);
|
||||
result = eval_irtree_and_type_from_expr(arena, graph, rdi, leaf_ident_expr_map, expr->children[1], eout);
|
||||
}break;
|
||||
case EVAL_ExprKind_LeafIdent:
|
||||
{
|
||||
@@ -1553,7 +1553,7 @@ eval_irtree_and_type_from_expr(Arena *arena, TG_Graph *graph, RDI_Parsed *rdbg,
|
||||
else
|
||||
{
|
||||
eval_string2expr_map_inc_poison(leaf_ident_expr_map, name);
|
||||
result = eval_irtree_and_type_from_expr(arena, graph, rdbg, leaf_ident_expr_map, leaf_ident_expr, eout);
|
||||
result = eval_irtree_and_type_from_expr(arena, graph, rdi, leaf_ident_expr_map, leaf_ident_expr, eout);
|
||||
eval_string2expr_map_dec_poison(leaf_ident_expr_map, name);
|
||||
}
|
||||
}break;
|
||||
|
||||
+10
-10
@@ -42,11 +42,11 @@ internal EVAL_Expr* eval_expr_leaf_type(Arena *arena, void *location, TG_Key typ
|
||||
|
||||
internal RDI_EvalTypeGroup eval_type_group_from_kind(TG_Kind kind);
|
||||
|
||||
internal TG_Key eval_type_unwrap_enum(TG_Graph *graph, RDI_Parsed *rdbg, TG_Key key);
|
||||
internal TG_Key eval_type_promote(TG_Graph *graph, RDI_Parsed *rdbg, TG_Key key);
|
||||
internal TG_Key eval_type_coerce(TG_Graph *graph, RDI_Parsed *rdbg, TG_Key l, TG_Key r);
|
||||
internal TG_Key eval_type_unwrap_enum(TG_Graph *graph, RDI_Parsed *rdi, TG_Key key);
|
||||
internal TG_Key eval_type_promote(TG_Graph *graph, RDI_Parsed *rdi, TG_Key key);
|
||||
internal TG_Key eval_type_coerce(TG_Graph *graph, RDI_Parsed *rdi, TG_Key l, TG_Key r);
|
||||
|
||||
internal B32 eval_type_match(TG_Graph *graph, RDI_Parsed *rdbg, TG_Key l, TG_Key r);
|
||||
internal B32 eval_type_match(TG_Graph *graph, RDI_Parsed *rdi, TG_Key l, TG_Key r);
|
||||
|
||||
internal B32 eval_kind_is_integer(TG_Kind kind);
|
||||
internal B32 eval_kind_is_signed(TG_Kind kind);
|
||||
@@ -65,18 +65,18 @@ internal EVAL_IRTree* eval_irtree_bytecode_no_copy(Arena *arena, String8 bytecod
|
||||
////////////////////////////////
|
||||
//~ allen: EVAL IR-Tree High Level Helpers
|
||||
|
||||
internal EVAL_IRTree* eval_irtree_mem_read_type(Arena *arena, TG_Graph *graph, RDI_Parsed *rdbg, EVAL_IRTree *c, TG_Key type_key);
|
||||
internal EVAL_IRTree* eval_irtree_mem_read_type(Arena *arena, TG_Graph *graph, RDI_Parsed *rdi, EVAL_IRTree *c, TG_Key type_key);
|
||||
internal EVAL_IRTree* eval_irtree_convert_lo(Arena *arena, EVAL_IRTree *c, RDI_EvalTypeGroup out, RDI_EvalTypeGroup in);
|
||||
internal EVAL_IRTree* eval_irtree_trunc(Arena *arena, TG_Graph *graph, RDI_Parsed *rdbg, EVAL_IRTree *c, TG_Key type_key);
|
||||
internal EVAL_IRTree* eval_irtree_convert_hi(Arena *arena, TG_Graph *graph, RDI_Parsed *rdbg, EVAL_IRTree *c, TG_Key out, TG_Key in);
|
||||
internal EVAL_IRTree* eval_irtree_resolve_to_value(Arena *arena, TG_Graph *graph, RDI_Parsed *rdbg, EVAL_EvalMode from_mode, EVAL_IRTree *tree, TG_Key type_key);
|
||||
internal EVAL_IRTree* eval_irtree_trunc(Arena *arena, TG_Graph *graph, RDI_Parsed *rdi, EVAL_IRTree *c, TG_Key type_key);
|
||||
internal EVAL_IRTree* eval_irtree_convert_hi(Arena *arena, TG_Graph *graph, RDI_Parsed *rdi, EVAL_IRTree *c, TG_Key out, TG_Key in);
|
||||
internal EVAL_IRTree* eval_irtree_resolve_to_value(Arena *arena, TG_Graph *graph, RDI_Parsed *rdi, 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, RDI_Parsed *rdbg, EVAL_Expr *expr, EVAL_ErrorList *eout);
|
||||
internal EVAL_IRTreeAndType eval_irtree_and_type_from_expr(Arena *arena, TG_Graph *graph, RDI_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, RDI_Parsed *rdi, EVAL_Expr *expr, EVAL_ErrorList *eout);
|
||||
internal EVAL_IRTreeAndType eval_irtree_and_type_from_expr(Arena *arena, TG_Graph *graph, RDI_Parsed *rdi, 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
|
||||
|
||||
+81
-81
@@ -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_rdi_voff(Arena *arena, RDI_Parsed *rdbg, U64 voff)
|
||||
eval_push_locals_map_from_rdi_voff(Arena *arena, RDI_Parsed *rdi, U64 voff)
|
||||
{
|
||||
Temp scratch = scratch_begin(&arena, 1);
|
||||
|
||||
@@ -73,10 +73,10 @@ eval_push_locals_map_from_rdi_voff(Arena *arena, RDI_Parsed *rdbg, U64 voff)
|
||||
|
||||
//- rjf: voff -> tightest scope
|
||||
RDI_Scope *tightest_scope = 0;
|
||||
if(rdbg->scope_vmap != 0 && rdbg->scopes != 0)
|
||||
if(rdi->scope_vmap != 0 && rdi->scopes != 0)
|
||||
{
|
||||
U64 scope_idx = rdi_vmap_idx_from_voff(rdbg->scope_vmap, rdbg->scope_vmap_count, voff);
|
||||
RDI_Scope *scope = &rdbg->scopes[scope_idx];
|
||||
U64 scope_idx = rdi_vmap_idx_from_voff(rdi->scope_vmap, rdi->scope_vmap_count, voff);
|
||||
RDI_Scope *scope = &rdi->scopes[scope_idx];
|
||||
Task *task = push_array(scratch.arena, Task, 1);
|
||||
task->scope = scope;
|
||||
SLLQueuePush(first_task, last_task, task);
|
||||
@@ -84,10 +84,10 @@ eval_push_locals_map_from_rdi_voff(Arena *arena, RDI_Parsed *rdbg, U64 voff)
|
||||
}
|
||||
|
||||
//- rjf: voff-1 -> scope
|
||||
if(voff > 0 && rdbg->scope_vmap != 0 && rdbg->scopes != 0)
|
||||
if(voff > 0 && rdi->scope_vmap != 0 && rdi->scopes != 0)
|
||||
{
|
||||
U64 scope_idx = rdi_vmap_idx_from_voff(rdbg->scope_vmap, rdbg->scope_vmap_count, voff-1);
|
||||
RDI_Scope *scope = &rdbg->scopes[scope_idx];
|
||||
U64 scope_idx = rdi_vmap_idx_from_voff(rdi->scope_vmap, rdi->scope_vmap_count, voff-1);
|
||||
RDI_Scope *scope = &rdi->scopes[scope_idx];
|
||||
if(scope != tightest_scope)
|
||||
{
|
||||
Task *task = push_array(scratch.arena, Task, 1);
|
||||
@@ -99,9 +99,9 @@ eval_push_locals_map_from_rdi_voff(Arena *arena, RDI_Parsed *rdbg, U64 voff)
|
||||
//- rjf: tightest scope -> walk up the tree & build tasks for each parent scope
|
||||
if(tightest_scope != 0)
|
||||
{
|
||||
for(RDI_Scope *scope = &rdbg->scopes[tightest_scope->parent_scope_idx];
|
||||
scope != 0 && scope != &rdbg->scopes[0];
|
||||
scope = &rdbg->scopes[scope->parent_scope_idx])
|
||||
for(RDI_Scope *scope = &rdi->scopes[tightest_scope->parent_scope_idx];
|
||||
scope != 0 && scope != &rdi->scopes[0];
|
||||
scope = &rdi->scopes[scope->parent_scope_idx])
|
||||
{
|
||||
Task *task = push_array(scratch.arena, Task, 1);
|
||||
task->scope = scope;
|
||||
@@ -122,9 +122,9 @@ eval_push_locals_map_from_rdi_voff(Arena *arena, RDI_Parsed *rdbg, U64 voff)
|
||||
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)
|
||||
{
|
||||
RDI_Local *local_var = &rdbg->locals[local_idx];
|
||||
RDI_Local *local_var = &rdi->locals[local_idx];
|
||||
U64 local_name_size = 0;
|
||||
U8 *local_name_str = rdi_string_from_idx(rdbg, local_var->name_string_idx, &local_name_size);
|
||||
U8 *local_name_str = rdi_string_from_idx(rdi, 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,35 +136,35 @@ eval_push_locals_map_from_rdi_voff(Arena *arena, RDI_Parsed *rdbg, U64 voff)
|
||||
}
|
||||
|
||||
internal EVAL_String2NumMap *
|
||||
eval_push_member_map_from_rdi_voff(Arena *arena, RDI_Parsed *rdbg, U64 voff)
|
||||
eval_push_member_map_from_rdi_voff(Arena *arena, RDI_Parsed *rdi, U64 voff)
|
||||
{
|
||||
//- rjf: voff -> tightest scope
|
||||
RDI_Scope *tightest_scope = 0;
|
||||
if(rdbg->scope_vmap != 0 && rdbg->scopes != 0)
|
||||
if(rdi->scope_vmap != 0 && rdi->scopes != 0)
|
||||
{
|
||||
U64 scope_idx = rdi_vmap_idx_from_voff(rdbg->scope_vmap, rdbg->scope_vmap_count, voff);
|
||||
tightest_scope = &rdbg->scopes[scope_idx];
|
||||
U64 scope_idx = rdi_vmap_idx_from_voff(rdi->scope_vmap, rdi->scope_vmap_count, voff);
|
||||
tightest_scope = &rdi->scopes[scope_idx];
|
||||
}
|
||||
|
||||
//- rjf: tightest scope -> procedure
|
||||
RDI_Procedure *procedure = 0;
|
||||
if(tightest_scope != 0 && rdbg->procedures != 0)
|
||||
if(tightest_scope != 0 && rdi->procedures != 0)
|
||||
{
|
||||
U32 proc_idx = tightest_scope->proc_idx;
|
||||
if(0 < proc_idx && proc_idx < rdbg->procedures_count)
|
||||
if(0 < proc_idx && proc_idx < rdi->procedures_count)
|
||||
{
|
||||
procedure = &rdbg->procedures[proc_idx];
|
||||
procedure = &rdi->procedures[proc_idx];
|
||||
}
|
||||
}
|
||||
|
||||
//- rjf: procedure -> udt
|
||||
RDI_UDT *udt = 0;
|
||||
if(procedure != 0 && rdbg->udts != 0 && procedure->link_flags & RDI_LinkFlag_TypeScoped)
|
||||
if(procedure != 0 && rdi->udts != 0 && procedure->link_flags & RDI_LinkFlag_TypeScoped)
|
||||
{
|
||||
U32 udt_idx = procedure->container_idx;
|
||||
if(0 < udt_idx && udt_idx < rdbg->udts_count)
|
||||
if(0 < udt_idx && udt_idx < rdi->udts_count)
|
||||
{
|
||||
udt = &rdbg->udts[udt_idx];
|
||||
udt = &rdi->udts[udt_idx];
|
||||
}
|
||||
}
|
||||
|
||||
@@ -173,22 +173,22 @@ eval_push_member_map_from_rdi_voff(Arena *arena, RDI_Parsed *rdbg, U64 voff)
|
||||
*map = eval_string2num_map_make(arena, 64);
|
||||
|
||||
//- rjf: udt -> fill member map
|
||||
if(udt != 0 && !(udt->flags & RDI_UserDefinedTypeFlag_EnumMembers) && rdbg->members != 0)
|
||||
if(udt != 0 && !(udt->flags & RDI_UserDefinedTypeFlag_EnumMembers) && rdi->members != 0)
|
||||
{
|
||||
U64 data_member_num = 1;
|
||||
for(U32 member_idx = udt->member_first;
|
||||
member_idx < udt->member_first+udt->member_count;
|
||||
member_idx += 1)
|
||||
{
|
||||
if(member_idx < 1 || rdbg->members_count <= member_idx)
|
||||
if(member_idx < 1 || rdi->members_count <= member_idx)
|
||||
{
|
||||
break;
|
||||
}
|
||||
RDI_Member *m = &rdbg->members[member_idx];
|
||||
RDI_Member *m = &rdi->members[member_idx];
|
||||
if(m->kind == RDI_MemberKind_DataField)
|
||||
{
|
||||
String8 name = {0};
|
||||
name.str = rdi_string_from_idx(rdbg, m->name_string_idx, &name.size);
|
||||
name.str = rdi_string_from_idx(rdi, m->name_string_idx, &name.size);
|
||||
eval_string2num_map_insert(arena, map, name, data_member_num);
|
||||
data_member_num += 1;
|
||||
}
|
||||
@@ -464,23 +464,23 @@ eval_token_array_make_first_opl(EVAL_Token *first, EVAL_Token *opl)
|
||||
//~ rjf: Parser Functions
|
||||
|
||||
internal TG_Key
|
||||
eval_leaf_type_from_name(RDI_Parsed *rdbg, String8 name)
|
||||
eval_leaf_type_from_name(RDI_Parsed *rdi, String8 name)
|
||||
{
|
||||
TG_Key key = zero_struct;
|
||||
B32 found = 0;
|
||||
if(rdbg->type_nodes != 0)
|
||||
if(rdi->type_nodes != 0)
|
||||
{
|
||||
RDI_NameMap *name_map = rdi_name_map_from_kind(rdbg, RDI_NameMapKind_Types);
|
||||
RDI_NameMap *name_map = rdi_name_map_from_kind(rdi, RDI_NameMapKind_Types);
|
||||
RDI_ParsedNameMap parsed_name_map = {0};
|
||||
rdi_name_map_parse(rdbg, name_map, &parsed_name_map);
|
||||
RDI_NameMapNode *node = rdi_name_map_lookup(rdbg, &parsed_name_map, name.str, name.size);
|
||||
rdi_name_map_parse(rdi, name_map, &parsed_name_map);
|
||||
RDI_NameMapNode *node = rdi_name_map_lookup(rdi, &parsed_name_map, name.str, name.size);
|
||||
if(node != 0)
|
||||
{
|
||||
U32 match_count = 0;
|
||||
U32 *matches = rdi_matches_from_map_node(rdbg, node, &match_count);
|
||||
U32 *matches = rdi_matches_from_map_node(rdi, node, &match_count);
|
||||
if(match_count != 0)
|
||||
{
|
||||
RDI_TypeNode *type_node = rdi_element_from_idx(rdbg, type_nodes, matches[0]);
|
||||
RDI_TypeNode *type_node = rdi_element_from_idx(rdi, type_nodes, matches[0]);
|
||||
found = type_node->kind != RDI_TypeKind_NULL;
|
||||
key = tg_key_ext(tg_kind_from_rdi_type_kind(type_node->kind), (U64)matches[0]);
|
||||
}
|
||||
@@ -569,7 +569,7 @@ eval_parse_type_from_text_tokens(Arena *arena, EVAL_ParseCtx *ctx, String8 text,
|
||||
if(token.kind == EVAL_TokenKind_Identifier)
|
||||
{
|
||||
String8 token_string = str8_substr(text, token.range);
|
||||
TG_Key type_key = eval_leaf_type_from_name(ctx->rdbg, token_string);
|
||||
TG_Key type_key = eval_leaf_type_from_name(ctx->rdi, token_string);
|
||||
if(!tg_key_match(tg_key_zero(), type_key))
|
||||
{
|
||||
token_it += 1;
|
||||
@@ -680,7 +680,7 @@ eval_parse_expr_from_text_tokens__prec(Arena *arena, EVAL_ParseCtx *ctx, String8
|
||||
String8 some_type_identifier_maybe_string = str8_substr(text, some_type_identifier_maybe.range);
|
||||
if(some_type_identifier_maybe.kind == EVAL_TokenKind_Identifier)
|
||||
{
|
||||
TG_Key type_key = eval_leaf_type_from_name(ctx->rdbg, some_type_identifier_maybe_string);
|
||||
TG_Key type_key = eval_leaf_type_from_name(ctx->rdi, some_type_identifier_maybe_string);
|
||||
if(!tg_key_match(type_key, tg_key_zero()) || str8_match(some_type_identifier_maybe_string, str8_lit("unsigned"), 0))
|
||||
{
|
||||
// rjf: move past open paren
|
||||
@@ -798,14 +798,14 @@ eval_parse_expr_from_text_tokens__prec(Arena *arena, EVAL_ParseCtx *ctx, String8
|
||||
|
||||
//- rjf: form namespaceified fallback versions of this lookup string
|
||||
String8List namespaceified_token_strings = {0};
|
||||
if(ctx->rdbg->procedures != 0 && ctx->rdbg->scopes != 0 && ctx->rdbg->scope_vmap != 0)
|
||||
if(ctx->rdi->procedures != 0 && ctx->rdi->scopes != 0 && ctx->rdi->scope_vmap != 0)
|
||||
{
|
||||
U64 scope_idx = rdi_vmap_idx_from_voff(ctx->rdbg->scope_vmap, ctx->rdbg->scope_vmap_count, ctx->ip_voff);
|
||||
RDI_Scope *scope = &ctx->rdbg->scopes[scope_idx];
|
||||
U64 scope_idx = rdi_vmap_idx_from_voff(ctx->rdi->scope_vmap, ctx->rdi->scope_vmap_count, ctx->ip_voff);
|
||||
RDI_Scope *scope = &ctx->rdi->scopes[scope_idx];
|
||||
U64 proc_idx = scope->proc_idx;
|
||||
RDI_Procedure *procedure = &ctx->rdbg->procedures[proc_idx];
|
||||
RDI_Procedure *procedure = &ctx->rdi->procedures[proc_idx];
|
||||
U64 name_size = 0;
|
||||
U8 *name_ptr = rdi_string_from_idx(ctx->rdbg, procedure->name_string_idx, &name_size);
|
||||
U8 *name_ptr = rdi_string_from_idx(ctx->rdi, procedure->name_string_idx, &name_size);
|
||||
String8 containing_procedure_name = str8(name_ptr, name_size);
|
||||
U64 last_past_scope_resolution_pos = 0;
|
||||
for(;;)
|
||||
@@ -843,8 +843,8 @@ eval_parse_expr_from_text_tokens__prec(Arena *arena, EVAL_ParseCtx *ctx, String8
|
||||
{
|
||||
mapped_identifier = 1;
|
||||
identifier_type_is_possibly_dynamically_overridden = 1;
|
||||
RDI_Local *local_var = rdi_element_from_idx(ctx->rdbg, locals, local_num-1);
|
||||
RDI_TypeNode *type_node = rdi_element_from_idx(ctx->rdbg, type_nodes, local_var->type_idx);
|
||||
RDI_Local *local_var = rdi_element_from_idx(ctx->rdi, locals, local_num-1);
|
||||
RDI_TypeNode *type_node = rdi_element_from_idx(ctx->rdi, type_nodes, local_var->type_idx);
|
||||
type_key = tg_key_ext(tg_kind_from_rdi_type_kind(type_node->kind), (U64)local_var->type_idx);
|
||||
|
||||
// rjf: grab location info
|
||||
@@ -852,19 +852,19 @@ eval_parse_expr_from_text_tokens__prec(Arena *arena, EVAL_ParseCtx *ctx, String8
|
||||
loc_block_idx < local_var->location_opl;
|
||||
loc_block_idx += 1)
|
||||
{
|
||||
RDI_LocationBlock *block = &ctx->rdbg->location_blocks[loc_block_idx];
|
||||
RDI_LocationBlock *block = &ctx->rdi->location_blocks[loc_block_idx];
|
||||
if(block->scope_off_first <= ctx->ip_voff && ctx->ip_voff < block->scope_off_opl)
|
||||
{
|
||||
loc_kind = *((RDI_LocationKind *)(ctx->rdbg->location_data + block->location_data_off));
|
||||
loc_kind = *((RDI_LocationKind *)(ctx->rdi->location_data + block->location_data_off));
|
||||
switch(loc_kind)
|
||||
{
|
||||
default:{mapped_identifier = 0;}break;
|
||||
case RDI_LocationKind_AddrBytecodeStream:
|
||||
case RDI_LocationKind_ValBytecodeStream:
|
||||
{
|
||||
U8 *bytecode_base = ctx->rdbg->location_data + block->location_data_off + sizeof(RDI_LocationKind);
|
||||
U8 *bytecode_base = ctx->rdi->location_data + block->location_data_off + sizeof(RDI_LocationKind);
|
||||
U64 bytecode_size = 0;
|
||||
for(U64 idx = 0; idx < ctx->rdbg->location_data_size; idx += 1)
|
||||
for(U64 idx = 0; idx < ctx->rdi->location_data_size; idx += 1)
|
||||
{
|
||||
U8 op = bytecode_base[idx];
|
||||
if(op == 0)
|
||||
@@ -880,11 +880,11 @@ eval_parse_expr_from_text_tokens__prec(Arena *arena, EVAL_ParseCtx *ctx, String8
|
||||
case RDI_LocationKind_AddrRegisterPlusU16:
|
||||
case RDI_LocationKind_AddrAddrRegisterPlusU16:
|
||||
{
|
||||
MemoryCopy(&loc_reg_u16, (ctx->rdbg->location_data + block->location_data_off), sizeof(loc_reg_u16));
|
||||
MemoryCopy(&loc_reg_u16, (ctx->rdi->location_data + block->location_data_off), sizeof(loc_reg_u16));
|
||||
}break;
|
||||
case RDI_LocationKind_ValRegister:
|
||||
{
|
||||
MemoryCopy(&loc_reg, (ctx->rdbg->location_data + block->location_data_off), sizeof(loc_reg));
|
||||
MemoryCopy(&loc_reg, (ctx->rdi->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)
|
||||
{
|
||||
RDI_NameMap *name_map = rdi_name_map_from_kind(ctx->rdbg, RDI_NameMapKind_GlobalVariables);
|
||||
if(name_map != 0 && ctx->rdbg->global_variables != 0)
|
||||
RDI_NameMap *name_map = rdi_name_map_from_kind(ctx->rdi, RDI_NameMapKind_GlobalVariables);
|
||||
if(name_map != 0 && ctx->rdi->global_variables != 0)
|
||||
{
|
||||
RDI_ParsedNameMap parsed_name_map = {0};
|
||||
rdi_name_map_parse(ctx->rdbg, name_map, &parsed_name_map);
|
||||
RDI_NameMapNode *node = rdi_name_map_lookup(ctx->rdbg, &parsed_name_map, token_string.str, token_string.size);
|
||||
rdi_name_map_parse(ctx->rdi, name_map, &parsed_name_map);
|
||||
RDI_NameMapNode *node = rdi_name_map_lookup(ctx->rdi, &parsed_name_map, token_string.str, token_string.size);
|
||||
U32 matches_count = 0;
|
||||
U32 *matches = rdi_matches_from_map_node(ctx->rdbg, node, &matches_count);
|
||||
U32 *matches = rdi_matches_from_map_node(ctx->rdi, node, &matches_count);
|
||||
for(String8Node *n = namespaceified_token_strings.first;
|
||||
n != 0 && matches_count == 0;
|
||||
n = n->next)
|
||||
{
|
||||
node = rdi_name_map_lookup(ctx->rdbg, &parsed_name_map, n->string.str, n->string.size);
|
||||
node = rdi_name_map_lookup(ctx->rdi, &parsed_name_map, n->string.str, n->string.size);
|
||||
matches_count = 0;
|
||||
matches = rdi_matches_from_map_node(ctx->rdbg, node, &matches_count);
|
||||
matches = rdi_matches_from_map_node(ctx->rdi, node, &matches_count);
|
||||
}
|
||||
if(matches_count != 0)
|
||||
{
|
||||
@@ -942,15 +942,15 @@ 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];
|
||||
RDI_GlobalVariable *global_var = &ctx->rdbg->global_variables[match_idx];
|
||||
RDI_GlobalVariable *global_var = &ctx->rdi->global_variables[match_idx];
|
||||
EVAL_OpList oplist = {0};
|
||||
eval_oplist_push_op(arena, &oplist, RDI_EvalOp_ModuleOff, global_var->voff);
|
||||
loc_kind = RDI_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)
|
||||
if(type_idx < ctx->rdi->type_nodes_count)
|
||||
{
|
||||
RDI_TypeNode *type_node = &ctx->rdbg->type_nodes[type_idx];
|
||||
RDI_TypeNode *type_node = &ctx->rdi->type_nodes[type_idx];
|
||||
type_key = tg_key_ext(tg_kind_from_rdi_type_kind(type_node->kind), (U64)type_idx);
|
||||
}
|
||||
mapped_identifier = 1;
|
||||
@@ -961,34 +961,34 @@ eval_parse_expr_from_text_tokens__prec(Arena *arena, EVAL_ParseCtx *ctx, String8
|
||||
//- rjf: try thread variables
|
||||
if(mapped_identifier == 0)
|
||||
{
|
||||
RDI_NameMap *name_map = rdi_name_map_from_kind(ctx->rdbg, RDI_NameMapKind_ThreadVariables);
|
||||
if(name_map != 0 && ctx->rdbg->global_variables != 0)
|
||||
RDI_NameMap *name_map = rdi_name_map_from_kind(ctx->rdi, RDI_NameMapKind_ThreadVariables);
|
||||
if(name_map != 0 && ctx->rdi->global_variables != 0)
|
||||
{
|
||||
RDI_ParsedNameMap parsed_name_map = {0};
|
||||
rdi_name_map_parse(ctx->rdbg, name_map, &parsed_name_map);
|
||||
RDI_NameMapNode *node = rdi_name_map_lookup(ctx->rdbg, &parsed_name_map, token_string.str, token_string.size);
|
||||
rdi_name_map_parse(ctx->rdi, name_map, &parsed_name_map);
|
||||
RDI_NameMapNode *node = rdi_name_map_lookup(ctx->rdi, &parsed_name_map, token_string.str, token_string.size);
|
||||
U32 matches_count = 0;
|
||||
U32 *matches = rdi_matches_from_map_node(ctx->rdbg, node, &matches_count);
|
||||
U32 *matches = rdi_matches_from_map_node(ctx->rdi, node, &matches_count);
|
||||
for(String8Node *n = namespaceified_token_strings.first;
|
||||
n != 0 && matches_count == 0;
|
||||
n = n->next)
|
||||
{
|
||||
node = rdi_name_map_lookup(ctx->rdbg, &parsed_name_map, n->string.str, n->string.size);
|
||||
node = rdi_name_map_lookup(ctx->rdi, &parsed_name_map, n->string.str, n->string.size);
|
||||
matches_count = 0;
|
||||
matches = rdi_matches_from_map_node(ctx->rdbg, node, &matches_count);
|
||||
matches = rdi_matches_from_map_node(ctx->rdi, node, &matches_count);
|
||||
}
|
||||
if(matches_count != 0)
|
||||
{
|
||||
U32 match_idx = matches[0];
|
||||
RDI_ThreadVariable *thread_var = &ctx->rdbg->thread_variables[match_idx];
|
||||
RDI_ThreadVariable *thread_var = &ctx->rdi->thread_variables[match_idx];
|
||||
EVAL_OpList oplist = {0};
|
||||
eval_oplist_push_op(arena, &oplist, RDI_EvalOp_TLSOff, thread_var->tls_off);
|
||||
loc_kind = RDI_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)
|
||||
if(type_idx < ctx->rdi->type_nodes_count)
|
||||
{
|
||||
RDI_TypeNode *type_node = &ctx->rdbg->type_nodes[type_idx];
|
||||
RDI_TypeNode *type_node = &ctx->rdi->type_nodes[type_idx];
|
||||
type_key = tg_key_ext(tg_kind_from_rdi_type_kind(type_node->kind), (U64)type_idx);
|
||||
}
|
||||
mapped_identifier = 1;
|
||||
@@ -999,36 +999,36 @@ eval_parse_expr_from_text_tokens__prec(Arena *arena, EVAL_ParseCtx *ctx, String8
|
||||
//- rjf: try procedures
|
||||
if(mapped_identifier == 0)
|
||||
{
|
||||
RDI_NameMap *name_map = rdi_name_map_from_kind(ctx->rdbg, RDI_NameMapKind_Procedures);
|
||||
if(name_map != 0 && ctx->rdbg->procedures != 0 && ctx->rdbg->scopes != 0 && ctx->rdbg->scope_voffs)
|
||||
RDI_NameMap *name_map = rdi_name_map_from_kind(ctx->rdi, RDI_NameMapKind_Procedures);
|
||||
if(name_map != 0 && ctx->rdi->procedures != 0 && ctx->rdi->scopes != 0 && ctx->rdi->scope_voffs)
|
||||
{
|
||||
RDI_ParsedNameMap parsed_name_map = {0};
|
||||
rdi_name_map_parse(ctx->rdbg, name_map, &parsed_name_map);
|
||||
RDI_NameMapNode *node = rdi_name_map_lookup(ctx->rdbg, &parsed_name_map, token_string.str, token_string.size);
|
||||
rdi_name_map_parse(ctx->rdi, name_map, &parsed_name_map);
|
||||
RDI_NameMapNode *node = rdi_name_map_lookup(ctx->rdi, &parsed_name_map, token_string.str, token_string.size);
|
||||
U32 matches_count = 0;
|
||||
U32 *matches = rdi_matches_from_map_node(ctx->rdbg, node, &matches_count);
|
||||
U32 *matches = rdi_matches_from_map_node(ctx->rdi, node, &matches_count);
|
||||
for(String8Node *n = namespaceified_token_strings.first;
|
||||
n != 0 && matches_count == 0;
|
||||
n = n->next)
|
||||
{
|
||||
node = rdi_name_map_lookup(ctx->rdbg, &parsed_name_map, n->string.str, n->string.size);
|
||||
node = rdi_name_map_lookup(ctx->rdi, &parsed_name_map, n->string.str, n->string.size);
|
||||
matches_count = 0;
|
||||
matches = rdi_matches_from_map_node(ctx->rdbg, node, &matches_count);
|
||||
matches = rdi_matches_from_map_node(ctx->rdi, node, &matches_count);
|
||||
}
|
||||
if(matches_count != 0)
|
||||
{
|
||||
U32 match_idx = matches[0];
|
||||
RDI_Procedure *procedure = &ctx->rdbg->procedures[match_idx];
|
||||
RDI_Scope *scope = &ctx->rdbg->scopes[procedure->root_scope_idx];
|
||||
U64 voff = ctx->rdbg->scope_voffs[scope->voff_range_first];
|
||||
RDI_Procedure *procedure = &ctx->rdi->procedures[match_idx];
|
||||
RDI_Scope *scope = &ctx->rdi->scopes[procedure->root_scope_idx];
|
||||
U64 voff = ctx->rdi->scope_voffs[scope->voff_range_first];
|
||||
EVAL_OpList oplist = {0};
|
||||
eval_oplist_push_op(arena, &oplist, RDI_EvalOp_ModuleOff, voff);
|
||||
loc_kind = RDI_LocationKind_ValBytecodeStream;
|
||||
loc_bytecode = eval_bytecode_from_oplist(arena, &oplist);
|
||||
U32 type_idx = procedure->type_idx;
|
||||
if(type_idx < ctx->rdbg->type_nodes_count)
|
||||
if(type_idx < ctx->rdi->type_nodes_count)
|
||||
{
|
||||
RDI_TypeNode *type_node = &ctx->rdbg->type_nodes[type_idx];
|
||||
RDI_TypeNode *type_node = &ctx->rdi->type_nodes[type_idx];
|
||||
type_key = tg_key_ext(tg_kind_from_rdi_type_kind(type_node->kind), (U64)type_idx);
|
||||
}
|
||||
mapped_identifier = 1;
|
||||
@@ -1039,7 +1039,7 @@ eval_parse_expr_from_text_tokens__prec(Arena *arena, EVAL_ParseCtx *ctx, String8
|
||||
//- rjf: try types
|
||||
if(mapped_identifier == 0)
|
||||
{
|
||||
type_key = eval_leaf_type_from_name(ctx->rdbg, token_string);
|
||||
type_key = eval_leaf_type_from_name(ctx->rdi, token_string);
|
||||
if(!tg_key_match(tg_key_zero(), type_key))
|
||||
{
|
||||
mapped_identifier = 1;
|
||||
|
||||
@@ -67,7 +67,7 @@ struct EVAL_ParseCtx
|
||||
{
|
||||
Architecture arch;
|
||||
U64 ip_voff;
|
||||
RDI_Parsed *rdbg;
|
||||
RDI_Parsed *rdi;
|
||||
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_rdi_voff(Arena *arena, RDI_Parsed *rdbg, U64 voff);
|
||||
internal EVAL_String2NumMap *eval_push_member_map_from_rdi_voff(Arena *arena, RDI_Parsed *rdbg, U64 voff);
|
||||
internal EVAL_String2NumMap *eval_push_locals_map_from_rdi_voff(Arena *arena, RDI_Parsed *rdi, U64 voff);
|
||||
internal EVAL_String2NumMap *eval_push_member_map_from_rdi_voff(Arena *arena, RDI_Parsed *rdi, 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(RDI_Parsed *rdbg, String8 name);
|
||||
internal TG_Key eval_leaf_type_from_name(RDI_Parsed *rdi, 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