mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-07-15 14:01:25 -07:00
irtree parent experiment (failed)
This commit is contained in:
+50
-5
@@ -90,6 +90,8 @@ e_select_ir_ctx(E_IRCtx *ctx)
|
||||
e_ir_state->string_id_map->id_slots = push_array(e_ir_state->arena, E_StringIDSlot, e_ir_state->string_id_map->id_slots_count);
|
||||
e_ir_state->string_id_map->hash_slots_count = 1024;
|
||||
e_ir_state->string_id_map->hash_slots = push_array(e_ir_state->arena, E_StringIDSlot, e_ir_state->string_id_map->hash_slots_count);
|
||||
e_ir_state->top_parent = 0;
|
||||
e_ir_state->free_parent = 0;
|
||||
String8 builtin_view_rule_names[] =
|
||||
{
|
||||
str8_lit_comp("bswap"),
|
||||
@@ -817,6 +819,32 @@ e_expr_unpoison(E_Expr *expr)
|
||||
}
|
||||
}
|
||||
|
||||
//- rjf: irtree parent selection
|
||||
|
||||
internal void
|
||||
e_push_irtree_parent(E_IRTreeAndType parent)
|
||||
{
|
||||
E_IRParentNode *parent_n = e_ir_state->free_parent;
|
||||
if(parent_n != 0)
|
||||
{
|
||||
SLLStackPop(e_ir_state->free_parent);
|
||||
}
|
||||
else
|
||||
{
|
||||
parent_n = push_array(e_ir_state->arena, E_IRParentNode, 1);
|
||||
}
|
||||
parent_n->v = parent;
|
||||
SLLStackPush(e_ir_state->top_parent, parent_n);
|
||||
}
|
||||
|
||||
internal void
|
||||
e_pop_irtree_parent(void)
|
||||
{
|
||||
E_IRParentNode *popped = e_ir_state->top_parent;
|
||||
SLLStackPop(e_ir_state->top_parent);
|
||||
SLLStackPush(e_ir_state->free_parent, popped);
|
||||
}
|
||||
|
||||
//- rjf: default type access hook
|
||||
|
||||
E_TYPE_ACCESS_FUNCTION_DEF(default)
|
||||
@@ -1073,12 +1101,11 @@ e_irtree_and_type_from_expr(Arena *arena, E_Expr *root_expr)
|
||||
{
|
||||
Task *next;
|
||||
E_Expr *expr;
|
||||
E_Expr *parent_expr;
|
||||
E_IRTreeAndType parent_irtree_and_type;
|
||||
};
|
||||
Task start_task = {0, root_expr, &e_expr_nil, {&e_irnode_nil}};
|
||||
Task start_task = {0, root_expr};
|
||||
Task *first_task = &start_task;
|
||||
Task *last_task = first_task;
|
||||
U64 num_parents = 0;
|
||||
for(Task *t = first_task; t != 0; t = t->next)
|
||||
{
|
||||
E_Expr *expr = t->expr;
|
||||
@@ -2038,6 +2065,16 @@ e_irtree_and_type_from_expr(Arena *arena, E_Expr *root_expr)
|
||||
}
|
||||
}
|
||||
|
||||
//- rjf: try to map name as parent expression signifier ('$')
|
||||
if(!string_mapped && str8_match(string, str8_lit("$"), 0) && e_ir_state->top_parent != 0)
|
||||
{
|
||||
E_OpList oplist = e_oplist_from_irtree(arena, e_ir_state->top_parent->v.root);
|
||||
string_mapped = 1;
|
||||
mapped_bytecode = e_bytecode_from_oplist(arena, &oplist);
|
||||
mapped_bytecode_mode = e_ir_state->top_parent->v.mode;
|
||||
mapped_type_key = e_ir_state->top_parent->v.type_key;
|
||||
}
|
||||
|
||||
//- rjf: try globals
|
||||
if(!string_mapped && (qualifier.size == 0 || str8_match(qualifier, str8_lit("global"), 0)))
|
||||
{
|
||||
@@ -2384,8 +2421,8 @@ e_irtree_and_type_from_expr(Arena *arena, E_Expr *root_expr)
|
||||
Task *task = push_array(scratch.arena, Task, 1);
|
||||
SLLQueuePush(first_task, last_task, task);
|
||||
task->expr = e;
|
||||
task->parent_expr = expr;
|
||||
task->parent_irtree_and_type = result;
|
||||
e_push_irtree_parent(result);
|
||||
num_parents += 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -2401,6 +2438,14 @@ e_irtree_and_type_from_expr(Arena *arena, E_Expr *root_expr)
|
||||
e_expr_unpoison(t->expr);
|
||||
}
|
||||
|
||||
//////////////////////////////
|
||||
//- rjf: pop all the parents that we used
|
||||
//
|
||||
for EachIndex(idx, num_parents)
|
||||
{
|
||||
e_pop_irtree_parent();
|
||||
}
|
||||
|
||||
//////////////////////////////
|
||||
//- rjf: apply inherited lenses to the resultant type
|
||||
//
|
||||
|
||||
@@ -140,6 +140,13 @@ struct E_IRCtx
|
||||
////////////////////////////////
|
||||
//~ rjf: IR State
|
||||
|
||||
typedef struct E_IRParentNode E_IRParentNode;
|
||||
struct E_IRParentNode
|
||||
{
|
||||
E_IRParentNode *next;
|
||||
E_IRTreeAndType v;
|
||||
};
|
||||
|
||||
typedef struct E_IRState E_IRState;
|
||||
struct E_IRState
|
||||
{
|
||||
@@ -152,6 +159,10 @@ struct E_IRState
|
||||
// rjf: unpacked ctx
|
||||
RDI_Procedure *thread_ip_procedure;
|
||||
|
||||
// rjf: parent stack
|
||||
E_IRParentNode *top_parent;
|
||||
E_IRParentNode *free_parent;
|
||||
|
||||
// rjf: caches
|
||||
E_UsedExprMap *used_expr_map;
|
||||
E_TypeAutoHookCacheMap *type_auto_hook_cache_map;
|
||||
@@ -228,6 +239,11 @@ internal B32 e_expr_is_poisoned(E_Expr *expr);
|
||||
internal void e_expr_poison(E_Expr *expr);
|
||||
internal void e_expr_unpoison(E_Expr *expr);
|
||||
|
||||
//- rjf: irtree parent selection
|
||||
internal void e_push_irtree_parent(E_IRTreeAndType parent);
|
||||
internal void e_pop_irtree_parent(void);
|
||||
#define E_IRTreeParentScope(p) DeferLoop(e_push_irtree_parent(p), e_pop_irtree_parent())
|
||||
|
||||
//- rjf: top-level irtree/type extraction
|
||||
E_TYPE_ACCESS_FUNCTION_DEF(default);
|
||||
internal E_IRTreeAndType e_irtree_and_type_from_expr(Arena *arena, E_Expr *expr);
|
||||
|
||||
@@ -4056,7 +4056,10 @@ rd_view_ui(Rng2F32 rect)
|
||||
}
|
||||
|
||||
// rjf: view ui contents
|
||||
cell_info.view_ui_rule->ui(cell_info.eval, cell_rect);
|
||||
E_IRTreeParentScope(cell_info.eval.irtree)
|
||||
{
|
||||
cell_info.view_ui_rule->ui(cell_info.eval, cell_rect);
|
||||
}
|
||||
|
||||
// rjf: loading fill
|
||||
UI_Parent(loading_overlay_container)
|
||||
@@ -4475,7 +4478,10 @@ rd_view_ui(Rng2F32 rect)
|
||||
Temp scratch = scratch_begin(0, 0);
|
||||
RD_ViewUIRule *view_ui_rule = rd_view_ui_rule_from_string(view_name);
|
||||
E_Eval expr_eval = e_eval_from_string(scratch.arena, expr_string);
|
||||
view_ui_rule->ui(expr_eval, rect);
|
||||
E_IRTreeParentScope(expr_eval.irtree)
|
||||
{
|
||||
view_ui_rule->ui(expr_eval, rect);
|
||||
}
|
||||
scratch_end(scratch);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user