mirror of
https://github.com/Ed94/raddebugger.git
synced 2026-08-06 05:48:40 +00:00
sketch out type-based auto-view-rule in eval visualization system
This commit is contained in:
@@ -151,6 +151,13 @@ EV_VIEW_RULE_BLOCK_PROD_FUNCTION_DEF(default)
|
|||||||
EV_ViewRuleList *child_view_rules = ev_view_rule_list_from_inheritance(arena, view_rules);
|
EV_ViewRuleList *child_view_rules = ev_view_rule_list_from_inheritance(arena, view_rules);
|
||||||
{
|
{
|
||||||
String8 view_rule_string = ev_view_rule_from_key(view, child->key);
|
String8 view_rule_string = ev_view_rule_from_key(view, child->key);
|
||||||
|
if(view_rule_string.size == 0)
|
||||||
|
{
|
||||||
|
Temp scratch = scratch_begin(&arena, 1);
|
||||||
|
E_IRTreeAndType irtree = e_irtree_and_type_from_expr(arena, child_expr);
|
||||||
|
view_rule_string = ev_auto_view_rule_from_type_key(irtree.type_key);
|
||||||
|
scratch_end(scratch);
|
||||||
|
}
|
||||||
if(view_rule_string.size != 0)
|
if(view_rule_string.size != 0)
|
||||||
{
|
{
|
||||||
ev_view_rule_list_push_string(arena, child_view_rules, view_rule_string);
|
ev_view_rule_list_push_string(arena, child_view_rules, view_rule_string);
|
||||||
@@ -219,6 +226,13 @@ EV_VIEW_RULE_BLOCK_PROD_FUNCTION_DEF(default)
|
|||||||
EV_ViewRuleList *child_view_rules = ev_view_rule_list_from_inheritance(arena, view_rules);
|
EV_ViewRuleList *child_view_rules = ev_view_rule_list_from_inheritance(arena, view_rules);
|
||||||
{
|
{
|
||||||
String8 view_rule_string = ev_view_rule_from_key(view, child->key);
|
String8 view_rule_string = ev_view_rule_from_key(view, child->key);
|
||||||
|
if(view_rule_string.size == 0)
|
||||||
|
{
|
||||||
|
Temp scratch = scratch_begin(&arena, 1);
|
||||||
|
E_IRTreeAndType irtree = e_irtree_and_type_from_expr(arena, child_expr);
|
||||||
|
view_rule_string = ev_auto_view_rule_from_type_key(irtree.type_key);
|
||||||
|
scratch_end(scratch);
|
||||||
|
}
|
||||||
if(view_rule_string.size != 0)
|
if(view_rule_string.size != 0)
|
||||||
{
|
{
|
||||||
ev_view_rule_list_push_string(arena, child_view_rules, view_rule_string);
|
ev_view_rule_list_push_string(arena, child_view_rules, view_rule_string);
|
||||||
@@ -236,13 +250,21 @@ EV_VIEW_RULE_BLOCK_PROD_FUNCTION_DEF(default)
|
|||||||
//
|
//
|
||||||
else if(e_type_kind_is_pointer_or_ref(type_kind) && e_type_kind_is_pointer_or_ref(direct_type_kind))
|
else if(e_type_kind_is_pointer_or_ref(type_kind) && e_type_kind_is_pointer_or_ref(direct_type_kind))
|
||||||
{
|
{
|
||||||
// rjf: compute key
|
// rjf: compute key, compute expr
|
||||||
EV_Key child_key = ev_key_make(ev_hash_from_key(key), 1);
|
EV_Key child_key = ev_key_make(ev_hash_from_key(key), 1);
|
||||||
|
E_Expr *child_expr = e_expr_ref_deref(arena, expr);
|
||||||
|
|
||||||
// rjf: build child view rules
|
// rjf: build child view rules
|
||||||
EV_ViewRuleList *child_view_rules = ev_view_rule_list_from_inheritance(arena, view_rules);
|
EV_ViewRuleList *child_view_rules = ev_view_rule_list_from_inheritance(arena, view_rules);
|
||||||
{
|
{
|
||||||
String8 view_rule_string = ev_view_rule_from_key(view, child_key);
|
String8 view_rule_string = ev_view_rule_from_key(view, child_key);
|
||||||
|
if(view_rule_string.size == 0)
|
||||||
|
{
|
||||||
|
Temp scratch = scratch_begin(&arena, 1);
|
||||||
|
E_IRTreeAndType irtree = e_irtree_and_type_from_expr(arena, child_expr);
|
||||||
|
view_rule_string = ev_auto_view_rule_from_type_key(irtree.type_key);
|
||||||
|
scratch_end(scratch);
|
||||||
|
}
|
||||||
if(view_rule_string.size != 0)
|
if(view_rule_string.size != 0)
|
||||||
{
|
{
|
||||||
ev_view_rule_list_push_string(arena, child_view_rules, view_rule_string);
|
ev_view_rule_list_push_string(arena, child_view_rules, view_rule_string);
|
||||||
@@ -250,7 +272,6 @@ EV_VIEW_RULE_BLOCK_PROD_FUNCTION_DEF(default)
|
|||||||
}
|
}
|
||||||
|
|
||||||
// rjf: recurse for child
|
// rjf: recurse for child
|
||||||
E_Expr *child_expr = e_expr_ref_deref(arena, expr);
|
|
||||||
ev_append_expr_blocks__rec(arena, view, key, child_key, str8_zero(), child_expr, child_view_rules, depth, out);
|
ev_append_expr_blocks__rec(arena, view, key, child_key, str8_zero(), child_expr, child_view_rules, depth, out);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -352,6 +352,67 @@ ev_view_rule_info_from_string(String8 string)
|
|||||||
return info;
|
return info;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
//~ rjf: Automatic Type -> View Rule Table Building / Selection / Lookups
|
||||||
|
|
||||||
|
internal void
|
||||||
|
ev_auto_view_rule_table_push_new(Arena *arena, EV_AutoViewRuleTable *table, E_TypeKey type_key, String8 view_rule)
|
||||||
|
{
|
||||||
|
if(table->slots_count == 0)
|
||||||
|
{
|
||||||
|
table->slots_count = 4096;
|
||||||
|
table->slots = push_array(arena, EV_AutoViewRuleSlot, table->slots_count);
|
||||||
|
}
|
||||||
|
U64 hash = e_hash_from_string(5381, str8_struct(&type_key));
|
||||||
|
U64 slot_idx = hash%ev_auto_view_rule_table->slots_count;
|
||||||
|
EV_AutoViewRuleSlot *slot = &ev_auto_view_rule_table->slots[slot_idx];
|
||||||
|
EV_AutoViewRuleNode *node = 0;
|
||||||
|
for(EV_AutoViewRuleNode *n = slot->first; n != 0; n = n->next)
|
||||||
|
{
|
||||||
|
if(e_type_match(n->key, type_key))
|
||||||
|
{
|
||||||
|
node = n;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(node == 0)
|
||||||
|
{
|
||||||
|
node = push_array(arena, EV_AutoViewRuleNode, 1);
|
||||||
|
node->key = type_key;
|
||||||
|
node->view_rule = push_str8_copy(arena, view_rule);
|
||||||
|
SLLQueuePush(slot->first, slot->last, node);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal void
|
||||||
|
ev_select_auto_view_rule_table(EV_AutoViewRuleTable *table)
|
||||||
|
{
|
||||||
|
ev_auto_view_rule_table = table;
|
||||||
|
}
|
||||||
|
|
||||||
|
internal String8
|
||||||
|
ev_auto_view_rule_from_type_key(E_TypeKey type_key)
|
||||||
|
{
|
||||||
|
U64 hash = e_hash_from_string(5381, str8_struct(&type_key));
|
||||||
|
U64 slot_idx = hash%ev_auto_view_rule_table->slots_count;
|
||||||
|
EV_AutoViewRuleSlot *slot = &ev_auto_view_rule_table->slots[slot_idx];
|
||||||
|
EV_AutoViewRuleNode *node = 0;
|
||||||
|
for(EV_AutoViewRuleNode *n = slot->first; n != 0; n = n->next)
|
||||||
|
{
|
||||||
|
if(e_type_match(n->key, type_key))
|
||||||
|
{
|
||||||
|
node = n;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
String8 string = {0};
|
||||||
|
if(node != 0)
|
||||||
|
{
|
||||||
|
string = node->view_rule;
|
||||||
|
}
|
||||||
|
return string;
|
||||||
|
}
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ rjf: View Rule Instance List Building
|
//~ rjf: View Rule Instance List Building
|
||||||
|
|
||||||
@@ -562,6 +623,11 @@ ev_block_list_from_view_expr_keys(Arena *arena, EV_View *view, EV_ViewRuleList *
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
String8 view_rule_string = ev_view_rule_from_key(view, key);
|
String8 view_rule_string = ev_view_rule_from_key(view, key);
|
||||||
|
if(view_rule_string.size == 0)
|
||||||
|
{
|
||||||
|
E_IRTreeAndType irtree = e_irtree_and_type_from_expr(arena, parse.expr);
|
||||||
|
view_rule_string = ev_auto_view_rule_from_type_key(irtree.type_key);
|
||||||
|
}
|
||||||
EV_ViewRuleList *view_rule_list = ev_view_rule_list_copy(arena, view_rules);
|
EV_ViewRuleList *view_rule_list = ev_view_rule_list_copy(arena, view_rules);
|
||||||
for(String8Node *n = default_view_rules.first; n != 0; n = n->next)
|
for(String8Node *n = default_view_rules.first; n != 0; n = n->next)
|
||||||
{
|
{
|
||||||
@@ -849,6 +915,13 @@ ev_row_list_push_new(Arena *arena, EV_View *view, EV_WindowedRowList *rows, EV_B
|
|||||||
{
|
{
|
||||||
view_rules = ev_view_rule_list_from_inheritance(arena, block->view_rules);
|
view_rules = ev_view_rule_list_from_inheritance(arena, block->view_rules);
|
||||||
String8 row_view_rules = ev_view_rule_from_key(view, key);
|
String8 row_view_rules = ev_view_rule_from_key(view, key);
|
||||||
|
if(row_view_rules.size == 0)
|
||||||
|
{
|
||||||
|
Temp scratch = scratch_begin(&arena, 1);
|
||||||
|
E_IRTreeAndType irtree = e_irtree_and_type_from_expr(arena, expr);
|
||||||
|
row_view_rules = ev_auto_view_rule_from_type_key(irtree.type_key);
|
||||||
|
scratch_end(scratch);
|
||||||
|
}
|
||||||
if(row_view_rules.size != 0)
|
if(row_view_rules.size != 0)
|
||||||
{
|
{
|
||||||
ev_view_rule_list_push_string(arena, view_rules, row_view_rules);
|
ev_view_rule_list_push_string(arena, view_rules, row_view_rules);
|
||||||
|
|||||||
@@ -224,6 +224,32 @@ struct EV_ViewRuleInfoTable
|
|||||||
U64 slots_count;
|
U64 slots_count;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
//~ rjf: Automatic Type -> View Rule Map Types
|
||||||
|
|
||||||
|
typedef struct EV_AutoViewRuleNode EV_AutoViewRuleNode;
|
||||||
|
struct EV_AutoViewRuleNode
|
||||||
|
{
|
||||||
|
EV_AutoViewRuleNode *next;
|
||||||
|
E_TypeKey key;
|
||||||
|
String8 view_rule;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct EV_AutoViewRuleSlot EV_AutoViewRuleSlot;
|
||||||
|
struct EV_AutoViewRuleSlot
|
||||||
|
{
|
||||||
|
EV_AutoViewRuleNode *first;
|
||||||
|
EV_AutoViewRuleNode *last;
|
||||||
|
U64 count;
|
||||||
|
};
|
||||||
|
|
||||||
|
typedef struct EV_AutoViewRuleTable EV_AutoViewRuleTable;
|
||||||
|
struct EV_AutoViewRuleTable
|
||||||
|
{
|
||||||
|
EV_AutoViewRuleSlot *slots;
|
||||||
|
U64 slots_count;
|
||||||
|
};
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ rjf: Generated Code
|
//~ rjf: Generated Code
|
||||||
|
|
||||||
@@ -279,6 +305,7 @@ struct EV_WindowedRowList
|
|||||||
global read_only EV_ViewRuleInfo ev_nil_view_rule_info = {0};
|
global read_only EV_ViewRuleInfo ev_nil_view_rule_info = {0};
|
||||||
thread_static EV_ViewRuleInfoTable *ev_view_rule_info_table = 0;
|
thread_static EV_ViewRuleInfoTable *ev_view_rule_info_table = 0;
|
||||||
global read_only EV_ViewRuleList ev_nil_view_rule_list = {0};
|
global read_only EV_ViewRuleList ev_nil_view_rule_list = {0};
|
||||||
|
thread_static EV_AutoViewRuleTable *ev_auto_view_rule_table = 0;
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ rjf: Key Functions
|
//~ rjf: Key Functions
|
||||||
@@ -318,6 +345,13 @@ internal void ev_view_rule_info_table_push_builtins(Arena *arena, EV_ViewRuleInf
|
|||||||
internal void ev_select_view_rule_info_table(EV_ViewRuleInfoTable *table);
|
internal void ev_select_view_rule_info_table(EV_ViewRuleInfoTable *table);
|
||||||
internal EV_ViewRuleInfo *ev_view_rule_info_from_string(String8 string);
|
internal EV_ViewRuleInfo *ev_view_rule_info_from_string(String8 string);
|
||||||
|
|
||||||
|
////////////////////////////////
|
||||||
|
//~ rjf: Automatic Type -> View Rule Table Building / Selection / Lookups
|
||||||
|
|
||||||
|
internal void ev_auto_view_rule_table_push_new(Arena *arena, EV_AutoViewRuleTable *table, E_TypeKey type_key, String8 view_rule);
|
||||||
|
internal void ev_select_auto_view_rule_table(EV_AutoViewRuleTable *table);
|
||||||
|
internal String8 ev_auto_view_rule_from_type_key(E_TypeKey type_key);
|
||||||
|
|
||||||
////////////////////////////////
|
////////////////////////////////
|
||||||
//~ rjf: View Rule Instance List Building
|
//~ rjf: View Rule Instance List Building
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user